mirror of
https://github.com/luxfi/node.git
synced 2026-07-27 03:39:39 +00:00
platformvm/txs: emit [N]byte fields as JSON arrays for v1 RPC parity
RegisterL1ValidatorTx (and other txs reachable through Service.GetTx, Service.GetBlock, Service.GetBlockByHeight) contains ProofOfPossession [bls.SignatureLen]byte and PublicKey [bls.PublicKeyLen]byte. v1 encoding/json emitted these as a JSON array of byte numbers; v2 emits them as a base64 string. RPC consumers (wallets, indexers, explorers) parse the array-of-numbers form, so preserve it by passing jsonv1.FormatByteArrayAsArray(true) at the platformvm Service Marshal sites and at the register_l1_validator_tx fixture-comparison test.
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/go-json-experiment/json"
|
||||
jsonv1 "github.com/go-json-experiment/json/v1"
|
||||
"github.com/luxfi/log"
|
||||
|
||||
validators "github.com/luxfi/validators"
|
||||
@@ -1504,7 +1505,7 @@ func (s *Service) GetTx(_ *http.Request, args *apitypes.GetTxArgs, response *api
|
||||
}
|
||||
}
|
||||
|
||||
response.Tx, err = json.Marshal(result)
|
||||
response.Tx, err = json.Marshal(result, jsonv1.FormatByteArrayAsArray(true))
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -2029,7 +2030,7 @@ func (s *Service) GetBlock(_ *http.Request, args *apitypes.GetBlockArgs, respons
|
||||
}
|
||||
}
|
||||
|
||||
response.Block, err = json.Marshal(result)
|
||||
response.Block, err = json.Marshal(result, jsonv1.FormatByteArrayAsArray(true))
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -2071,7 +2072,7 @@ func (s *Service) GetBlockByHeight(_ *http.Request, args *apitypes.GetBlockByHei
|
||||
}
|
||||
}
|
||||
|
||||
response.Block, err = json.Marshal(result)
|
||||
response.Block, err = json.Marshal(result, jsonv1.FormatByteArrayAsArray(true))
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ package txs
|
||||
import (
|
||||
"encoding/hex"
|
||||
"github.com/go-json-experiment/json"
|
||||
jsonv1 "github.com/go-json-experiment/json/v1"
|
||||
"github.com/go-json-experiment/json/jsontext"
|
||||
"testing"
|
||||
|
||||
@@ -222,7 +223,7 @@ func TestRegisterL1ValidatorTxSerialization(t *testing.T) {
|
||||
rt := consensustest.Runtime(t, constants.PlatformChainID)
|
||||
unsignedTx.InitRuntime(rt)
|
||||
|
||||
txJSON, err := json.Marshal(unsignedTx, jsontext.WithIndent("\t"))
|
||||
txJSON, err := json.Marshal(unsignedTx, jsontext.WithIndent("\t"), jsonv1.FormatByteArrayAsArray(true))
|
||||
require.NoError(err)
|
||||
require.JSONEq(string(registerL1ValidatorTxJSON), string(txJSON))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user