From 8a0861e8de3ec7b8f141ac9aa445bf1353bfe40e Mon Sep 17 00:00:00 2001 From: Agusx1211 Date: Thu, 28 Sep 2023 16:05:53 +0000 Subject: [PATCH] Use canonical json --- go.mod | 1 + go.sum | 2 ++ intents/intent.go | 4 +++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 017273f..1a542c0 100644 --- a/go.mod +++ b/go.mod @@ -26,6 +26,7 @@ require ( github.com/deckarep/golang-set v1.8.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect + github.com/gibson042/canonicaljson-go v1.0.3 // indirect github.com/go-stack/stack v1.8.1 // indirect github.com/google/uuid v1.3.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect diff --git a/go.sum b/go.sum index e58bb63..09503ea 100644 --- a/go.sum +++ b/go.sum @@ -54,6 +54,8 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/gibson042/canonicaljson-go v1.0.3 h1:EAyF8L74AWabkyUmrvEFHEt/AGFQeD6RfwbAuf0j1bI= +github.com/gibson042/canonicaljson-go v1.0.3/go.mod h1:DsLpJTThXyGNO+KZlI85C1/KDcImpP67k/RKVjcaEqo= github.com/go-chi/httpvcr v0.2.0 h1:jOsPvc4ZOoyNv9KCv/O4YoSjMFrHFq/Orc90A0DotUU= github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= diff --git a/intents/intent.go b/intents/intent.go index 26f60ee..699c511 100644 --- a/intents/intent.go +++ b/intents/intent.go @@ -5,6 +5,8 @@ import ( "fmt" "strings" + "github.com/gibson042/canonicaljson-go" + "github.com/0xsequence/ethkit/go-ethereum/common" "github.com/0xsequence/ethkit/go-ethereum/crypto" ) @@ -54,7 +56,7 @@ func (intent *Intent) Hash() ([]byte, error) { packet := intent.Packet // Convert packet to bytes - packetBytes, err := json.Marshal(packet) + packetBytes, err := canonicaljson.Marshal(packet) if err != nil { return nil, err }