mirror of
https://github.com/luxfi/node.git
synced 2026-07-27 03:39:39 +00:00
json: migrate every encoding/json import to json/v2 (go-json-experiment)
External (HTTP / JSON-RPC) is the only place JSON is legitimate. Every
existing encoding/json import in node/ moves to github.com/go-json-experiment/json
(v2 root, not the v1 sub-package). NewEncoder/NewDecoder rewrite to
MarshalWrite/UnmarshalRead. MarshalIndent rewrites to Marshal with
jsontext.WithIndent. json.RawMessage rewrites to jsontext.Value.
*json.SyntaxError rewrites to *jsontext.SyntacticError.
81 files migrated. LLM.md captures the rule + v1->v2 delta table.
Known v2 semantic deltas surfaced by existing tests (followups, not regressions):
- [N]byte fields with no MarshalJSON now marshal as base64 string (v1 marshalled
as JSON array of byte numbers). Affects vms/platformvm/txs/*_test.go fixtures
with embedded BLS proofOfPossession.
- time.Duration has no v2 default representation; configs that wire-format
Duration as nanoseconds (vms/{xvm,platformvm}/config, config/spec) need to
switch to string-form Duration or carry an explicit option. v2 root does not
re-export FormatDurationAsNano.
- v2 enforces strict UTF-8 (vms/chainadapter/messaging fixture has non-UTF-8).
- json.MarshalWrite does not append a trailing '\n' (v1 NewEncoder.Encode did);
service/auth/auth_test.go expectation updated.
- nil []byte round-trips to empty (not nil); config_test deep-equal fixtures
surface this.
All affected sites are at the API boundary; ZAP wire envelope already covers
the internal data paths (state, P2P, consensus, MPC, threshold). Internal
JSON sites that should move to ZAP next (separate work):
- vms/da/store.go (DA blob/cert storage as JSON)
- vms/platformvm/airdrop (airdrop claims as JSON in db)
- vms/chainadapter/appchain (SQLite materializer schema/data blobs)
- vms/chainadapter/messaging (conversation codec)
- staking/kms.go (KMS HTTP client — external technically, leave)
- utils/{bimap,ips} (small marshaler shims — low priority)
This commit is contained in:
@@ -764,6 +764,47 @@ PRIVATE_KEY="<funded_key>" \
|
|||||||
./bin/bench tps --chains=lux --duration=60s --concurrency=5
|
./bin/bench tps --chains=lux --duration=60s --concurrency=5
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## JSON rule — json/v2 at HTTP boundary only; ZAP for all internal data
|
||||||
|
|
||||||
|
Encoding boundaries are one-way and explicit:
|
||||||
|
|
||||||
|
- **External (HTTP / JSON-RPC API)** — `github.com/go-json-experiment/json` (v2).
|
||||||
|
Never `encoding/json`. This covers: `service/*`, `server/*`, `pubsub/`,
|
||||||
|
`vms/platformvm/service.go`, `vms/xvm/service.go`, JSON-RPC clients
|
||||||
|
(`vms/platformvm/client_*`), CLI tools (`cmd/*`), wallet examples,
|
||||||
|
on-disk config files (read once at boot), genesis/upgrade blobs.
|
||||||
|
- **Internal (state, P2P, consensus, MPC, logs, metrics)** — ZAP wire only.
|
||||||
|
No JSON in: `network/`, `consensus/`, `snow/`, `chains/` (data-plane),
|
||||||
|
`vms/*/state/`, `vms/*/block/`, `vms/*/txs/` (struct codec), threshold
|
||||||
|
payloads, P2P message bodies, internal databases.
|
||||||
|
|
||||||
|
Migration helpers (v2 API delta vs v1):
|
||||||
|
|
||||||
|
| v1 (encoding/json) | v2 (go-json-experiment/json) |
|
||||||
|
|-----------------------------------|----------------------------------------------|
|
||||||
|
| `json.Marshal(v)` | `json.Marshal(v)` (variadic opts; signature compat) |
|
||||||
|
| `json.MarshalIndent(v, "", " ")` | `json.Marshal(v, jsontext.WithIndent(" "))` |
|
||||||
|
| `json.Unmarshal(b, &v)` | `json.Unmarshal(b, &v)` |
|
||||||
|
| `json.NewEncoder(w).Encode(v)` | `json.MarshalWrite(w, v)` (no trailing `\n`) |
|
||||||
|
| `json.NewDecoder(r).Decode(&v)` | `json.UnmarshalRead(r, &v)` |
|
||||||
|
| `json.RawMessage` | `jsontext.Value` |
|
||||||
|
| `*json.SyntaxError` | `*jsontext.SyntacticError` |
|
||||||
|
|
||||||
|
v2 semantic differences worth knowing (these change wire shape):
|
||||||
|
|
||||||
|
- `[N]byte` field with no `MarshalJSON` ⇒ v2 marshals as base64 string,
|
||||||
|
v1 marshalled as JSON array of byte numbers. Add `MarshalJSON` on the
|
||||||
|
type if the array form is wanted on the wire.
|
||||||
|
- `time.Duration` ⇒ v2 default is the standard string form ("30m");
|
||||||
|
v1 marshalled as int nanoseconds. v1 sub-package
|
||||||
|
(`github.com/go-json-experiment/json/v1`) exposes `FormatDurationAsNano(true)`;
|
||||||
|
v2 root does not. Prefer the string form on new APIs.
|
||||||
|
- v2 enforces strict UTF-8; raw arbitrary bytes in JSON strings fail.
|
||||||
|
This matters for legacy P2P/internal blobs that happen to be stored
|
||||||
|
through JSON — those should already be on ZAP.
|
||||||
|
- `json.MarshalWrite` does NOT append a trailing `\n` (v1 `NewEncoder.Encode` did).
|
||||||
|
Adjust HTTP-handler test fixtures accordingly.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
*Last Updated*: 2026-02-04
|
*Last Updated*: 2026-06-06
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto"
|
"crypto"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ package rpc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -132,7 +132,7 @@ func (d *DebugTool) testEndpoint(url string) TestResult {
|
|||||||
|
|
||||||
// Check if we got a valid JSON-RPC response
|
// Check if we got a valid JSON-RPC response
|
||||||
var rpcResp map[string]interface{}
|
var rpcResp map[string]interface{}
|
||||||
if err := json.NewDecoder(postResp.Body).Decode(&rpcResp); err == nil {
|
if err := json.UnmarshalRead(postResp.Body, &rpcResp); err == nil {
|
||||||
if _, hasResult := rpcResp["result"]; hasResult {
|
if _, hasResult := rpcResp["result"]; hasResult {
|
||||||
result.Success = true
|
result.Success = true
|
||||||
result.Response = fmt.Sprintf("Valid JSON-RPC response: %v", rpcResp["result"])
|
result.Response = fmt.Sprintf("Valid JSON-RPC response: %v", rpcResp["result"])
|
||||||
@@ -179,7 +179,7 @@ func (d *DebugTool) testRPCMethods(url string) []RPCTest {
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
var result map[string]interface{}
|
var result map[string]interface{}
|
||||||
if err := json.NewDecoder(resp.Body).Decode(&result); err == nil {
|
if err := json.UnmarshalRead(resp.Body, &result); err == nil {
|
||||||
if res, ok := result["result"]; ok {
|
if res, ok := result["result"]; ok {
|
||||||
test.Success = true
|
test.Success = true
|
||||||
test.Result = fmt.Sprintf("%v", res)
|
test.Result = fmt.Sprintf("%v", res)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ package chains
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
consensusconfig "github.com/luxfi/consensus/config"
|
consensusconfig "github.com/luxfi/consensus/config"
|
||||||
|
|||||||
@@ -3,10 +3,12 @@ package main
|
|||||||
import (
|
import (
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -190,7 +192,7 @@ func cmdExport(args []string) {
|
|||||||
|
|
||||||
// stateEnvelope wraps CeremonyState with a SHA-256 integrity hash.
|
// stateEnvelope wraps CeremonyState with a SHA-256 integrity hash.
|
||||||
type stateEnvelope struct {
|
type stateEnvelope struct {
|
||||||
State json.RawMessage `json:"state"`
|
State jsontext.Value `json:"state"`
|
||||||
Integrity string `json:"integrity"` // hex(SHA-256(state bytes))
|
Integrity string `json:"integrity"` // hex(SHA-256(state bytes))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -12,6 +11,8 @@ import (
|
|||||||
|
|
||||||
"github.com/consensys/gnark-crypto/ecc/bn254"
|
"github.com/consensys/gnark-crypto/ecc/bn254"
|
||||||
"github.com/consensys/gnark-crypto/ecc/bn254/fr"
|
"github.com/consensys/gnark-crypto/ecc/bn254/fr"
|
||||||
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
)
|
)
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
@@ -309,7 +310,7 @@ func TestRegressionL03_StateFileHasIntegrity(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var envelope struct {
|
var envelope struct {
|
||||||
State json.RawMessage `json:"state"`
|
State jsontext.Value `json:"state"`
|
||||||
Integrity string `json:"integrity"`
|
Integrity string `json:"integrity"`
|
||||||
}
|
}
|
||||||
if err := json.Unmarshal(raw, &envelope); err != nil {
|
if err := json.Unmarshal(raw, &envelope); err != nil {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
@@ -75,7 +76,7 @@ func main() {
|
|||||||
ccBytes, _ := json.Marshal(cc)
|
ccBytes, _ := json.Marshal(cc)
|
||||||
genesis["cChainGenesis"] = string(ccBytes)
|
genesis["cChainGenesis"] = string(ccBytes)
|
||||||
|
|
||||||
out, _ := json.MarshalIndent(genesis, "", " ")
|
out, _ := json.Marshal(genesis, jsontext.WithIndent(" "))
|
||||||
os.WriteFile(os.ExpandEnv("$HOME/work/lux/mainnet/zoo_genesis_valid.json"), out, 0644)
|
os.WriteFile(os.ExpandEnv("$HOME/work/lux/mainnet/zoo_genesis_valid.json"), out, 0644)
|
||||||
fmt.Println("Wrote zoo_genesis_valid.json")
|
fmt.Println("Wrote zoo_genesis_valid.json")
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -8,7 +8,6 @@ import (
|
|||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
|
||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -19,6 +18,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
compression "github.com/luxfi/compress"
|
compression "github.com/luxfi/compress"
|
||||||
@@ -1429,7 +1430,7 @@ func getNetConfigsFromFlags(v *viper.Viper, netIDs []ids.ID) (map[ids.ID]nets.Co
|
|||||||
}
|
}
|
||||||
|
|
||||||
// partially parse configs to be filled by defaults later
|
// partially parse configs to be filled by defaults later
|
||||||
chainConfigs := make(map[ids.ID]json.RawMessage, len(netIDs))
|
chainConfigs := make(map[ids.ID]jsontext.Value, len(netIDs))
|
||||||
if err := json.Unmarshal(netConfigContent, &chainConfigs); err != nil {
|
if err := json.Unmarshal(netConfigContent, &chainConfigs); err != nil {
|
||||||
return nil, fmt.Errorf("could not unmarshal JSON: %w", err)
|
return nil, fmt.Errorf("could not unmarshal JSON: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ package config
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ package config
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
package node
|
package node
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -54,7 +55,7 @@ func TestProcessContext(t *testing.T) {
|
|||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
|
|
||||||
contextJSON, err := json.MarshalIndent(test.context, "", "\t")
|
contextJSON, err := json.Marshal(test.context, jsontext.WithIndent("\t"))
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
require.JSONEq(test.expected, string(contextJSON))
|
require.JSONEq(test.expected, string(contextJSON))
|
||||||
})
|
})
|
||||||
|
|||||||
+3
-2
@@ -7,7 +7,8 @@
|
|||||||
package spec
|
package spec
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -207,7 +208,7 @@ func (s *ConfigSpec) DeprecatedFlags() []FlagSpec {
|
|||||||
|
|
||||||
// JSON returns the spec as formatted JSON.
|
// JSON returns the spec as formatted JSON.
|
||||||
func (s *ConfigSpec) JSON() ([]byte, error) {
|
func (s *ConfigSpec) JSON() ([]byte, error) {
|
||||||
return json.MarshalIndent(s, "", " ")
|
return json.Marshal(s, jsontext.WithIndent(" "))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateValue checks if a value is valid for a flag.
|
// ValidateValue checks if a value is valid for a flag.
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
package spec
|
package spec
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ package builder
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path"
|
||||||
|
|||||||
@@ -114,12 +114,14 @@ require (
|
|||||||
require (
|
require (
|
||||||
github.com/cloudflare/circl v1.6.3
|
github.com/cloudflare/circl v1.6.3
|
||||||
github.com/consensys/gnark-crypto v0.20.1
|
github.com/consensys/gnark-crypto v0.20.1
|
||||||
|
github.com/go-json-experiment/json v0.0.0-20260601182631-00ed12fed2a6
|
||||||
github.com/golang-jwt/jwt/v4 v4.5.2
|
github.com/golang-jwt/jwt/v4 v4.5.2
|
||||||
github.com/golang/mock v1.7.0-rc.1
|
github.com/golang/mock v1.7.0-rc.1
|
||||||
github.com/luxfi/accel v1.2.2
|
github.com/luxfi/accel v1.2.2
|
||||||
github.com/luxfi/api v1.0.14
|
github.com/luxfi/api v1.0.14
|
||||||
github.com/luxfi/atomic v1.0.0
|
github.com/luxfi/atomic v1.0.0
|
||||||
github.com/luxfi/chains v1.3.6
|
github.com/luxfi/chains v1.3.6
|
||||||
|
github.com/luxfi/codec v1.1.5
|
||||||
github.com/luxfi/compress v0.0.5
|
github.com/luxfi/compress v0.0.5
|
||||||
github.com/luxfi/constants v1.5.8-0.20260603055356-93c2c2ceb9ca
|
github.com/luxfi/constants v1.5.8-0.20260603055356-93c2c2ceb9ca
|
||||||
github.com/luxfi/container v0.0.4
|
github.com/luxfi/container v0.0.4
|
||||||
@@ -158,7 +160,6 @@ require (
|
|||||||
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
|
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
|
||||||
github.com/decred/dcrd/crypto/blake256 v1.1.0 // indirect
|
github.com/decred/dcrd/crypto/blake256 v1.1.0 // indirect
|
||||||
github.com/go-ini/ini v1.67.0 // indirect
|
github.com/go-ini/ini v1.67.0 // indirect
|
||||||
github.com/go-json-experiment/json v0.0.0-20260601182631-00ed12fed2a6 // indirect
|
|
||||||
github.com/goccy/go-yaml v1.19.2 // indirect
|
github.com/goccy/go-yaml v1.19.2 // indirect
|
||||||
github.com/grandcat/zeroconf v1.0.0 // indirect
|
github.com/grandcat/zeroconf v1.0.0 // indirect
|
||||||
github.com/gtank/merlin v0.1.1 // indirect
|
github.com/gtank/merlin v0.1.1 // indirect
|
||||||
|
|||||||
@@ -262,6 +262,8 @@ github.com/luxfi/cache v1.2.1 h1:kAzOS55/hmYeNKR+0HAKv4ma48Y6JjkI8UQeqdZ8bfI=
|
|||||||
github.com/luxfi/cache v1.2.1/go.mod h1:co7JTxZZHpKT31Yh01LFp5aZOxmoUg157FhBLQdQHVU=
|
github.com/luxfi/cache v1.2.1/go.mod h1:co7JTxZZHpKT31Yh01LFp5aZOxmoUg157FhBLQdQHVU=
|
||||||
github.com/luxfi/chains v1.3.6 h1:JZwhjOPMyTOYz+MgNj0SJfgny/zeSHqvWtbmjQmRgCU=
|
github.com/luxfi/chains v1.3.6 h1:JZwhjOPMyTOYz+MgNj0SJfgny/zeSHqvWtbmjQmRgCU=
|
||||||
github.com/luxfi/chains v1.3.6/go.mod h1:mWXh65qP37JYyYOeI5d9upTVgs47VD8MwR25aCeLF6k=
|
github.com/luxfi/chains v1.3.6/go.mod h1:mWXh65qP37JYyYOeI5d9upTVgs47VD8MwR25aCeLF6k=
|
||||||
|
github.com/luxfi/codec v1.1.5 h1:KBq8uvYm5Dy+E1heG8WBmqbqu8kstlFyE5ASBBB+C8I=
|
||||||
|
github.com/luxfi/codec v1.1.5/go.mod h1:/ugIv5iEgI+VAuPIetzxNT0eJaEjOID/mrIsgIjJh8g=
|
||||||
github.com/luxfi/compress v0.0.5 h1:4tEUHw5MK1bu5UOjfYCt4OKMiH7yykIgmGPRA/BfJTM=
|
github.com/luxfi/compress v0.0.5 h1:4tEUHw5MK1bu5UOjfYCt4OKMiH7yykIgmGPRA/BfJTM=
|
||||||
github.com/luxfi/compress v0.0.5/go.mod h1:Cc1yxD2pfzrvpO32W2GDwLKff+CylHEvzZh2Ko8RSIU=
|
github.com/luxfi/compress v0.0.5/go.mod h1:Cc1yxD2pfzrvpO32W2GDwLKff+CylHEvzZh2Ko8RSIU=
|
||||||
github.com/luxfi/concurrent v0.0.3 h1:eJyv1fhaC0jMLMw6+QS774cUmp7GK+ouMgvLCqnC7cc=
|
github.com/luxfi/concurrent v0.0.3 h1:eJyv1fhaC0jMLMw6+QS774cUmp7GK+ouMgvLCqnC7cc=
|
||||||
|
|||||||
+3
-2
@@ -8,7 +8,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto"
|
"crypto"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@@ -21,6 +20,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
nodevalidators "github.com/luxfi/validators"
|
nodevalidators "github.com/luxfi/validators"
|
||||||
|
|
||||||
"github.com/luxfi/metric"
|
"github.com/luxfi/metric"
|
||||||
@@ -756,7 +757,7 @@ func (n *Node) writeProcessContext() error {
|
|||||||
URI: n.apiURI,
|
URI: n.apiURI,
|
||||||
StakingAddress: n.stakingAddress, // Set by network initialization
|
StakingAddress: n.stakingAddress, // Set by network initialization
|
||||||
}
|
}
|
||||||
bytes, err := json.MarshalIndent(processContext, "", " ")
|
bytes, err := json.Marshal(processContext, jsontext.WithIndent(" "))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to marshal process context: %w", err)
|
return fmt.Errorf("failed to marshal process context: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,12 @@
|
|||||||
package pubsub
|
package pubsub
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/go-json-experiment/json"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/luxfi/log"
|
"github.com/luxfi/log"
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ func (c *connection) readMessage() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cmd := &Command{}
|
cmd := &Command{}
|
||||||
err = json.NewDecoder(r).Decode(cmd)
|
err = json.UnmarshalRead(r, cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/go-json-experiment/json"
|
||||||
"github.com/luxfi/math/set"
|
"github.com/luxfi/math/set"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ func (a *allowedHostsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
|
|||||||
// Return error as JSON
|
// Return error as JSON
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
w.WriteHeader(http.StatusForbidden)
|
w.WriteHeader(http.StatusForbidden)
|
||||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
_ = json.MarshalWrite(w, map[string]interface{}{
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
"error": map[string]interface{}{
|
"error": map[string]interface{}{
|
||||||
"code": -32001,
|
"code": -32001,
|
||||||
|
|||||||
@@ -4,12 +4,12 @@
|
|||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/go-json-experiment/json"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
|
|
||||||
apitypes "github.com/luxfi/api/types"
|
apitypes "github.com/luxfi/api/types"
|
||||||
@@ -165,7 +165,7 @@ func (r *router) handleRootGET(w http.ResponseWriter, _ *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := json.NewEncoder(w).Encode(info); err != nil {
|
if err := json.MarshalWrite(w, info); err != nil {
|
||||||
http.Error(w, "Failed to encode response", http.StatusInternalServerError)
|
http.Error(w, "Failed to encode response", http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ func TestWriteUnauthorizedResponse(t *testing.T) {
|
|||||||
rr := httptest.NewRecorder()
|
rr := httptest.NewRecorder()
|
||||||
writeUnauthorizedResponse(rr, errTest)
|
writeUnauthorizedResponse(rr, errTest)
|
||||||
require.Equal(http.StatusUnauthorized, rr.Code)
|
require.Equal(http.StatusUnauthorized, rr.Code)
|
||||||
require.Equal(`{"jsonrpc":"2.0","error":{"code":-32600,"message":"non-nil error"},"id":1}`+"\n", rr.Body.String())
|
require.Equal(`{"jsonrpc":"2.0","error":{"code":-32600,"message":"non-nil error"},"id":1}`, rr.Body.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWrapHandlerMutatedRevokedToken(t *testing.T) {
|
func TestWrapHandlerMutatedRevokedToken(t *testing.T) {
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
package auth
|
package auth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/go-json-experiment/json"
|
||||||
rpc "github.com/gorilla/rpc/v2/json2"
|
rpc "github.com/gorilla/rpc/v2/json2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ func writeUnauthorizedResponse(w http.ResponseWriter, err error) {
|
|||||||
w.WriteHeader(http.StatusUnauthorized)
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
|
|
||||||
// There isn't anything to do with the returned error, so it is dropped.
|
// There isn't anything to do with the returned error, so it is dropped.
|
||||||
_ = json.NewEncoder(w).Encode(responseBody{
|
_ = json.MarshalWrite(w, responseBody{
|
||||||
Version: rpc.Version,
|
Version: rpc.Version,
|
||||||
Err: responseErr{
|
Err: responseErr{
|
||||||
Code: rpc.E_INVALID_REQ,
|
Code: rpc.E_INVALID_REQ,
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ package backup
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@@ -17,6 +16,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
"github.com/klauspost/compress/zstd"
|
"github.com/klauspost/compress/zstd"
|
||||||
"github.com/luxfi/database"
|
"github.com/luxfi/database"
|
||||||
"github.com/luxfi/log"
|
"github.com/luxfi/log"
|
||||||
@@ -315,7 +316,7 @@ func (s *Service) saveMetadata() error {
|
|||||||
return fmt.Errorf("failed to create metadata directory: %w", err)
|
return fmt.Errorf("failed to create metadata directory: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := json.MarshalIndent(meta, "", " ")
|
data, err := json.Marshal(meta, jsontext.WithIndent(" "))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to marshal metadata: %w", err)
|
return fmt.Errorf("failed to marshal metadata: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
package health
|
package health
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/go-json-experiment/json"
|
||||||
"github.com/gorilla/rpc/v2"
|
"github.com/gorilla/rpc/v2"
|
||||||
|
|
||||||
apihealth "github.com/luxfi/api/health"
|
apihealth "github.com/luxfi/api/health"
|
||||||
@@ -55,7 +55,7 @@ func NewGetHandler(reporter func(tags ...string) (map[string]apihealth.Result, b
|
|||||||
}
|
}
|
||||||
// The encoder will call write on the writer, which will write the
|
// The encoder will call write on the writer, which will write the
|
||||||
// header with a 200.
|
// header with a 200.
|
||||||
_ = json.NewEncoder(w).Encode(apihealth.APIReply{
|
_ = json.MarshalWrite(w, apihealth.APIReply{
|
||||||
Checks: checks,
|
Checks: checks,
|
||||||
Healthy: healthy,
|
Healthy: healthy,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
package info
|
package info
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/go-json-experiment/json"
|
||||||
"github.com/luxfi/mock/gomock"
|
"github.com/luxfi/mock/gomock"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ package security
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/go-json-experiment/json"
|
||||||
"github.com/gorilla/rpc/v2"
|
"github.com/gorilla/rpc/v2"
|
||||||
|
|
||||||
consensusconfig "github.com/luxfi/consensus/config"
|
consensusconfig "github.com/luxfi/consensus/config"
|
||||||
@@ -227,8 +227,7 @@ func buildBlockSecurityReply(p *consensusconfig.ChainSecurityProfile) BlockSecur
|
|||||||
// behaviour (no per-endpoint drift).
|
// behaviour (no per-endpoint drift).
|
||||||
func writeJSON(w http.ResponseWriter, v any) {
|
func writeJSON(w http.ResponseWriter, v any) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
enc := json.NewEncoder(w)
|
if err := json.MarshalWrite(w, v); err != nil {
|
||||||
if err := enc.Encode(v); err != nil {
|
|
||||||
// Body may have been partially written; nothing further to
|
// Body may have been partially written; nothing further to
|
||||||
// do at this layer. Frameworks log encoder failures at the
|
// do at this layer. Frameworks log encoder failures at the
|
||||||
// HTTP listener boundary.
|
// HTTP listener boundary.
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ package security
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/go-json-experiment/json"
|
||||||
consensusconfig "github.com/luxfi/consensus/config"
|
consensusconfig "github.com/luxfi/consensus/config"
|
||||||
"github.com/luxfi/log"
|
"github.com/luxfi/log"
|
||||||
)
|
)
|
||||||
@@ -227,7 +227,7 @@ func TestREST_securityProfile_GET(t *testing.T) {
|
|||||||
t.Errorf("Content-Type = %q; want application/json prefix", got)
|
t.Errorf("Content-Type = %q; want application/json prefix", got)
|
||||||
}
|
}
|
||||||
var body ProfileReply
|
var body ProfileReply
|
||||||
if err := json.NewDecoder(resp.Body).Decode(&body); err != nil {
|
if err := json.UnmarshalRead(resp.Body, &body); err != nil {
|
||||||
t.Fatalf("decode: %v", err)
|
t.Fatalf("decode: %v", err)
|
||||||
}
|
}
|
||||||
if body.ProfileName != "STRICT" {
|
if body.ProfileName != "STRICT" {
|
||||||
@@ -283,7 +283,7 @@ func TestREST_blockSecurity_GET(t *testing.T) {
|
|||||||
t.Fatalf("status = %d; want 200", resp.StatusCode)
|
t.Fatalf("status = %d; want 200", resp.StatusCode)
|
||||||
}
|
}
|
||||||
var body BlockSecurityReply
|
var body BlockSecurityReply
|
||||||
if err := json.NewDecoder(resp.Body).Decode(&body); err != nil {
|
if err := json.UnmarshalRead(resp.Body, &body); err != nil {
|
||||||
t.Fatalf("decode: %v", err)
|
t.Fatalf("decode: %v", err)
|
||||||
}
|
}
|
||||||
if body.SecurityProfileName != "STRICT" {
|
if body.SecurityProfileName != "STRICT" {
|
||||||
|
|||||||
+2
-2
@@ -4,7 +4,7 @@
|
|||||||
package staking
|
package staking
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -63,7 +63,7 @@ func FetchFromKMS(cfg KMSConfig) (*KMSStakingKeys, error) {
|
|||||||
Value string `json:"secretValue"`
|
Value string `json:"secretValue"`
|
||||||
} `json:"secret"`
|
} `json:"secret"`
|
||||||
}
|
}
|
||||||
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
|
if err := json.UnmarshalRead(resp.Body, &result); err != nil {
|
||||||
return nil, fmt.Errorf("decoding KMS response: %w", err)
|
return nil, fmt.Errorf("decoding KMS response: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -4,7 +4,7 @@
|
|||||||
package staking
|
package staking
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -40,7 +40,7 @@ func TestFetchFromKMS(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(kmsResponse)
|
json.MarshalWrite(w, kmsResponse)
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ func TestFetchFromKMS_NoAuth(t *testing.T) {
|
|||||||
t.Errorf("expected no Authorization header, got %q", auth)
|
t.Errorf("expected no Authorization header, got %q", auth)
|
||||||
}
|
}
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(kmsResponse)
|
json.MarshalWrite(w, kmsResponse)
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ func TestFetchFromKMS_InvalidSecretValue(t *testing.T) {
|
|||||||
|
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(kmsResponse)
|
json.MarshalWrite(w, kmsResponse)
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
package tmpnet
|
package tmpnet
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -91,7 +92,7 @@ func NewTestGenesisWithFunds(
|
|||||||
// Add basic C-Chain genesis
|
// Add basic C-Chain genesis
|
||||||
config.CChainGenesis = getBasicCChainGenesis(networkID)
|
config.CChainGenesis = getBasicCChainGenesis(networkID)
|
||||||
|
|
||||||
return json.MarshalIndent(config, "", " ")
|
return json.Marshal(config, jsontext.WithIndent(" "))
|
||||||
}
|
}
|
||||||
|
|
||||||
// getBasicCChainGenesis returns a basic C-Chain genesis configuration
|
// getBasicCChainGenesis returns a basic C-Chain genesis configuration
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ package tmpnet
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -123,7 +124,7 @@ func (n *Network) Write() error {
|
|||||||
return fmt.Errorf("failed to create network directory: %w", err)
|
return fmt.Errorf("failed to create network directory: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := json.MarshalIndent(n, "", " ")
|
data, err := json.Marshal(n, jsontext.WithIndent(" "))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to marshal network config: %w", err)
|
return fmt.Errorf("failed to marshal network config: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
@@ -121,7 +122,7 @@ func (n *Node) Write() error {
|
|||||||
Flags: n.Flags,
|
Flags: n.Flags,
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := json.MarshalIndent(config, "", " ")
|
data, err := json.Marshal(config, jsontext.WithIndent(" "))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to marshal node config: %w", err)
|
return fmt.Errorf("failed to marshal node config: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"crypto/x509/pkix"
|
"crypto/x509/pkix"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"errors"
|
"errors"
|
||||||
"math/big"
|
"math/big"
|
||||||
"strings"
|
"strings"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ package bimap
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"errors"
|
"errors"
|
||||||
"maps"
|
"maps"
|
||||||
"slices"
|
"slices"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
package bimap
|
package bimap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|||||||
@@ -5,9 +5,10 @@ package formatting
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,7 +29,7 @@ func TestEncodingUnmarshalJSON(t *testing.T) {
|
|||||||
require.NoError(json.Unmarshal(jsonBytes, &enc))
|
require.NoError(json.Unmarshal(jsonBytes, &enc))
|
||||||
require.Equal(Hex, enc)
|
require.Equal(Hex, enc)
|
||||||
|
|
||||||
var serr *json.SyntaxError
|
var serr *jsontext.SyntacticError
|
||||||
jsonBytes = []byte("")
|
jsonBytes = []byte("")
|
||||||
require.ErrorAs(json.Unmarshal(jsonBytes, &enc), &serr)
|
require.ErrorAs(json.Unmarshal(jsonBytes, &enc), &serr)
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
package ips
|
package ips
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
package ips
|
package ips
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"errors"
|
"errors"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ package da
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"errors"
|
"errors"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
package status
|
package status
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -20,7 +21,7 @@ type TxIssuance struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *TxIssuance) String() string {
|
func (s *TxIssuance) String() string {
|
||||||
txJSON, err := json.MarshalIndent(s.Tx, "", " ")
|
txJSON, err := json.Marshal(s.Tx, jsontext.WithIndent(" "))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "failed to marshal transaction: " + err.Error()
|
return "failed to marshal transaction: " + err.Error()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
package versionjson
|
package versionjson
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@@ -37,7 +38,7 @@ func versionFunc(*cobra.Command, []string) error {
|
|||||||
Version: xsvm.Version,
|
Version: xsvm.Version,
|
||||||
RPCChainVM: uint64(version.RPCChainVMProtocol),
|
RPCChainVM: uint64(version.RPCChainVMProtocol),
|
||||||
}
|
}
|
||||||
jsonBytes, err := json.MarshalIndent(versions, "", " ")
|
jsonBytes, err := json.Marshal(versions, jsontext.WithIndent(" "))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to marshal versions: %w", err)
|
return fmt.Errorf("failed to marshal versions: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ package airdrop
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"errors"
|
"errors"
|
||||||
"math/big"
|
"math/big"
|
||||||
"sync"
|
"sync"
|
||||||
|
|||||||
@@ -4,8 +4,7 @@
|
|||||||
package platformvm
|
package platformvm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
|
|
||||||
"github.com/luxfi/address"
|
"github.com/luxfi/address"
|
||||||
"github.com/luxfi/ids"
|
"github.com/luxfi/ids"
|
||||||
"github.com/luxfi/node/vms/platformvm/api"
|
"github.com/luxfi/node/vms/platformvm/api"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/luxfi/constants"
|
"github.com/luxfi/constants"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/luxfi/constants"
|
"github.com/luxfi/constants"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ package platformvm
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"maps"
|
"maps"
|
||||||
@@ -14,6 +13,7 @@ import (
|
|||||||
"slices"
|
"slices"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/go-json-experiment/json"
|
||||||
"github.com/luxfi/log"
|
"github.com/luxfi/log"
|
||||||
|
|
||||||
validators "github.com/luxfi/validators"
|
validators "github.com/luxfi/validators"
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
package signer
|
package signer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
|
"github.com/go-json-experiment/json"
|
||||||
"github.com/luxfi/crypto/bls"
|
"github.com/luxfi/crypto/bls"
|
||||||
"github.com/luxfi/formatting"
|
"github.com/luxfi/formatting"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
package signer
|
package signer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
|
"github.com/go-json-experiment/json"
|
||||||
"github.com/luxfi/crypto/bls"
|
"github.com/luxfi/crypto/bls"
|
||||||
"github.com/luxfi/formatting"
|
"github.com/luxfi/formatting"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
package signer
|
package signer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
|
"github.com/go-json-experiment/json"
|
||||||
"github.com/luxfi/formatting"
|
"github.com/luxfi/formatting"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
package status
|
package status
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/go-json-experiment/json"
|
||||||
"github.com/luxfi/node/vms/components/verify"
|
"github.com/luxfi/node/vms/components/verify"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
package status
|
package status
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"math"
|
"math"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/go-json-experiment/json"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
package status
|
package status
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/go-json-experiment/json"
|
||||||
"github.com/luxfi/node/vms/components/verify"
|
"github.com/luxfi/node/vms/components/verify"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
package status
|
package status
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"math"
|
"math"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/go-json-experiment/json"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
package txs
|
package txs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
"errors"
|
"errors"
|
||||||
"math"
|
"math"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -397,7 +398,7 @@ func TestAddPermissionlessPrimaryDelegatorSerialization(t *testing.T) {
|
|||||||
}
|
}
|
||||||
unsignedComplexAddPrimaryTx.InitRuntime(rt2)
|
unsignedComplexAddPrimaryTx.InitRuntime(rt2)
|
||||||
|
|
||||||
unsignedComplexAddPrimaryTxJSONBytes, err := json.MarshalIndent(unsignedComplexAddPrimaryTx, "", "\t")
|
unsignedComplexAddPrimaryTxJSONBytes, err := json.Marshal(unsignedComplexAddPrimaryTx, jsontext.WithIndent("\t"))
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
require.JSONEq(`{
|
require.JSONEq(`{
|
||||||
"networkID": 1,
|
"networkID": 1,
|
||||||
@@ -926,7 +927,7 @@ func TestAddPermissionlessNetDelegatorSerialization(t *testing.T) {
|
|||||||
}
|
}
|
||||||
unsignedComplexAddNetTx.InitRuntime(rt3)
|
unsignedComplexAddNetTx.InitRuntime(rt3)
|
||||||
|
|
||||||
unsignedComplexAddNetTxJSONBytes, err := json.MarshalIndent(unsignedComplexAddNetTx, "", "\t")
|
unsignedComplexAddNetTxJSONBytes, err := json.Marshal(unsignedComplexAddNetTx, jsontext.WithIndent("\t"))
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
require.JSONEq(`{
|
require.JSONEq(`{
|
||||||
"networkID": 1,
|
"networkID": 1,
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ package txs
|
|||||||
import (
|
import (
|
||||||
"github.com/luxfi/runtime"
|
"github.com/luxfi/runtime"
|
||||||
|
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@@ -250,7 +251,7 @@ func TestBaseTxSerialization(t *testing.T) {
|
|||||||
}
|
}
|
||||||
unsignedComplexBaseTx.InitRuntime(rt3)
|
unsignedComplexBaseTx.InitRuntime(rt3)
|
||||||
|
|
||||||
unsignedComplexBaseTxJSONBytes, err := json.MarshalIndent(unsignedComplexBaseTx, "", "\t")
|
unsignedComplexBaseTxJSONBytes, err := json.Marshal(unsignedComplexBaseTx, jsontext.WithIndent("\t"))
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
require.JSONEq(`{
|
require.JSONEq(`{
|
||||||
"networkID": 1,
|
"networkID": 1,
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ package txs
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@@ -354,7 +355,7 @@ func TestConvertNetworkToL1TxSerialization(t *testing.T) {
|
|||||||
rt := consensustest.Runtime(t, constants.PlatformChainID)
|
rt := consensustest.Runtime(t, constants.PlatformChainID)
|
||||||
test.tx.InitRuntime(rt)
|
test.tx.InitRuntime(rt)
|
||||||
|
|
||||||
txJSON, err := json.MarshalIndent(test.tx, "", "\t")
|
txJSON, err := json.Marshal(test.tx, jsontext.WithIndent("\t"))
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
require.JSONEq(string(test.expectedJSON), string(txJSON))
|
require.JSONEq(string(test.expectedJSON), string(txJSON))
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
package txs
|
package txs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@@ -203,7 +204,7 @@ func TestDisableL1ValidatorTxSerialization(t *testing.T) {
|
|||||||
rt := consensustest.Runtime(t, constants.PlatformChainID)
|
rt := consensustest.Runtime(t, constants.PlatformChainID)
|
||||||
unsignedTx.InitRuntime(rt)
|
unsignedTx.InitRuntime(rt)
|
||||||
|
|
||||||
txJSON, err := json.MarshalIndent(unsignedTx, "", "\t")
|
txJSON, err := json.Marshal(unsignedTx, jsontext.WithIndent("\t"))
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
require.JSONEq(string(disableL1ValidatorTxJSON), string(txJSON))
|
require.JSONEq(string(disableL1ValidatorTxJSON), string(txJSON))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ package fee
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@@ -43,7 +44,7 @@ func TestTxComplexity_Individual(t *testing.T) {
|
|||||||
|
|
||||||
// If the test fails, logging the transaction can be helpful for
|
// If the test fails, logging the transaction can be helpful for
|
||||||
// debugging.
|
// debugging.
|
||||||
txJSON, err := json.MarshalIndent(tx, "", "\t")
|
txJSON, err := json.Marshal(tx, jsontext.WithIndent("\t"))
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
t.Log(string(txJSON))
|
t.Log(string(txJSON))
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
package txs
|
package txs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@@ -201,7 +202,7 @@ func TestIncreaseL1ValidatorBalanceTxSerialization(t *testing.T) {
|
|||||||
rt := consensustest.Runtime(t, constants.PlatformChainID)
|
rt := consensustest.Runtime(t, constants.PlatformChainID)
|
||||||
unsignedTx.InitRuntime(rt)
|
unsignedTx.InitRuntime(rt)
|
||||||
|
|
||||||
txJSON, err := json.MarshalIndent(unsignedTx, "", "\t")
|
txJSON, err := json.Marshal(unsignedTx, jsontext.WithIndent("\t"))
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
require.JSONEq(string(increaseL1ValidatorBalanceTxJSON), string(txJSON))
|
require.JSONEq(string(increaseL1ValidatorBalanceTxJSON), string(txJSON))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ package txs
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@@ -221,7 +222,7 @@ func TestRegisterL1ValidatorTxSerialization(t *testing.T) {
|
|||||||
rt := consensustest.Runtime(t, constants.PlatformChainID)
|
rt := consensustest.Runtime(t, constants.PlatformChainID)
|
||||||
unsignedTx.InitRuntime(rt)
|
unsignedTx.InitRuntime(rt)
|
||||||
|
|
||||||
txJSON, err := json.MarshalIndent(unsignedTx, "", "\t")
|
txJSON, err := json.Marshal(unsignedTx, jsontext.WithIndent("\t"))
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
require.JSONEq(string(registerL1ValidatorTxJSON), string(txJSON))
|
require.JSONEq(string(registerL1ValidatorTxJSON), string(txJSON))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
package txs
|
package txs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -292,7 +293,7 @@ func TestRemoveChainValidatorTxSerialization(t *testing.T) {
|
|||||||
}
|
}
|
||||||
unsignedComplexRemoveValidatorTx.InitRuntime(rt3)
|
unsignedComplexRemoveValidatorTx.InitRuntime(rt3)
|
||||||
|
|
||||||
unsignedComplexRemoveValidatorTxJSONBytes, err := json.MarshalIndent(unsignedComplexRemoveValidatorTx, "", "\t")
|
unsignedComplexRemoveValidatorTxJSONBytes, err := json.Marshal(unsignedComplexRemoveValidatorTx, jsontext.WithIndent("\t"))
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
require.JSONEq(`{
|
require.JSONEq(`{
|
||||||
"networkID": 1,
|
"networkID": 1,
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
package txs
|
package txs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@@ -192,7 +193,7 @@ func TestSetL1ValidatorWeightTxSerialization(t *testing.T) {
|
|||||||
rt := consensustest.Runtime(t, constants.PlatformChainID)
|
rt := consensustest.Runtime(t, constants.PlatformChainID)
|
||||||
unsignedTx.InitRuntime(rt)
|
unsignedTx.InitRuntime(rt)
|
||||||
|
|
||||||
txJSON, err := json.MarshalIndent(unsignedTx, "", "\t")
|
txJSON, err := json.Marshal(unsignedTx, jsontext.WithIndent("\t"))
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
require.JSONEq(string(setL1ValidatorWeightTxJSON), string(txJSON))
|
require.JSONEq(string(setL1ValidatorWeightTxJSON), string(txJSON))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ package txs
|
|||||||
import (
|
import (
|
||||||
"github.com/luxfi/runtime"
|
"github.com/luxfi/runtime"
|
||||||
|
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/luxfi/mock/gomock"
|
"github.com/luxfi/mock/gomock"
|
||||||
@@ -296,7 +297,7 @@ func TestTransferChainOwnershipTxSerialization(t *testing.T) {
|
|||||||
}
|
}
|
||||||
unsignedComplexTransferChainOwnershipTx.InitRuntime(rt3)
|
unsignedComplexTransferChainOwnershipTx.InitRuntime(rt3)
|
||||||
|
|
||||||
unsignedComplexTransferChainOwnershipTxJSONBytes, err := json.MarshalIndent(unsignedComplexTransferChainOwnershipTx, "", "\t")
|
unsignedComplexTransferChainOwnershipTxJSONBytes, err := json.Marshal(unsignedComplexTransferChainOwnershipTx, jsontext.WithIndent("\t"))
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
require.JSONEq(`{
|
require.JSONEq(`{
|
||||||
"networkID": 1,
|
"networkID": 1,
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
package txs
|
package txs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/luxfi/runtime"
|
"github.com/luxfi/runtime"
|
||||||
@@ -336,7 +337,7 @@ func TestTransformChainTxSerialization(t *testing.T) {
|
|||||||
}
|
}
|
||||||
unsignedComplexTransformTx.InitRuntime(rt3)
|
unsignedComplexTransformTx.InitRuntime(rt3)
|
||||||
|
|
||||||
unsignedComplexTransformTxJSONBytes, err := json.MarshalIndent(unsignedComplexTransformTx, "", "\t")
|
unsignedComplexTransformTxJSONBytes, err := json.Marshal(unsignedComplexTransformTx, jsontext.WithIndent("\t"))
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
require.JSONEq(`{
|
require.JSONEq(`{
|
||||||
"networkID": 1,
|
"networkID": 1,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ package zap
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
|||||||
@@ -4,8 +4,7 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
|
|
||||||
"github.com/luxfi/formatting"
|
"github.com/luxfi/formatting"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/go-json-experiment/json"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
package xvm
|
package xvm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
|
|
||||||
"github.com/luxfi/node/vms/xvm/config"
|
"github.com/luxfi/node/vms/xvm/config"
|
||||||
"github.com/luxfi/node/vms/xvm/network"
|
"github.com/luxfi/node/vms/xvm/network"
|
||||||
|
|||||||
+1
-1
@@ -4,12 +4,12 @@
|
|||||||
package xvm
|
package xvm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/go-json-experiment/json"
|
||||||
"github.com/luxfi/consensus/core/choices"
|
"github.com/luxfi/consensus/core/choices"
|
||||||
"github.com/luxfi/crypto/secp256k1"
|
"github.com/luxfi/crypto/secp256k1"
|
||||||
"github.com/luxfi/database"
|
"github.com/luxfi/database"
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
package xvm
|
package xvm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/go-json-experiment/json"
|
||||||
"github.com/luxfi/address"
|
"github.com/luxfi/address"
|
||||||
"github.com/luxfi/formatting"
|
"github.com/luxfi/formatting"
|
||||||
"github.com/luxfi/ids"
|
"github.com/luxfi/ids"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ package xvm
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"errors"
|
"errors"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ package xvm
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
@@ -96,7 +97,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to create RegisterL1Validator message: %s\n", err)
|
log.Fatalf("failed to create RegisterL1Validator message: %s\n", err)
|
||||||
}
|
}
|
||||||
addressedCallPayloadJSON, err := json.MarshalIndent(addressedCallPayload, "", "\t")
|
addressedCallPayloadJSON, err := json.Marshal(addressedCallPayload, jsontext.WithIndent("\t"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to marshal RegisterL1Validator message: %s\n", err)
|
log.Fatalf("failed to marshal RegisterL1Validator message: %s\n", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"github.com/go-json-experiment/json"
|
||||||
|
"github.com/go-json-experiment/json/jsontext"
|
||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -73,7 +74,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to create L1ValidatorWeight message: %s\n", err)
|
log.Fatalf("failed to create L1ValidatorWeight message: %s\n", err)
|
||||||
}
|
}
|
||||||
addressedCallPayloadJSON, err := json.MarshalIndent(addressedCallPayload, "", "\t")
|
addressedCallPayloadJSON, err := json.Marshal(addressedCallPayload, jsontext.WithIndent("\t"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to marshal L1ValidatorWeight message: %s\n", err)
|
log.Fatalf("failed to marshal L1ValidatorWeight message: %s\n", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user