diff --git a/go.mod b/go.mod index 49356fce..40f30281 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,8 @@ go 1.22.7 toolchain go1.23.2 require ( - github.com/0xsequence/ethkit v1.30.1 - github.com/0xsequence/go-sequence v0.44.1 + github.com/0xsequence/ethkit v1.30.2 + github.com/0xsequence/go-sequence v0.44.2 github.com/0xsequence/nitrocontrol v0.3.0 github.com/BurntSushi/toml v1.4.0 github.com/aws/aws-sdk-go-v2 v1.30.3 @@ -48,7 +48,7 @@ require ( require ( dario.cat/mergo v1.0.0 // indirect - github.com/0xsequence/go-ethauth v0.13.0 // indirect + github.com/0xsequence/go-ethauth v0.14.0 // indirect github.com/0xsequence/nsm v0.1.0 // indirect github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect github.com/Masterminds/goutils v1.1.1 // indirect @@ -86,7 +86,7 @@ require ( github.com/crate-crypto/go-kzg-4844 v1.1.0 // indirect github.com/cyphar/filepath-securejoin v0.2.5 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/deckarep/golang-set/v2 v2.6.0 // indirect + github.com/deckarep/golang-set/v2 v2.7.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/distribution/reference v0.5.0 // indirect @@ -192,7 +192,7 @@ require ( golang.org/x/crypto v0.31.0 // indirect golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect golang.org/x/mod v0.21.0 // indirect - golang.org/x/net v0.30.0 // indirect + golang.org/x/net v0.32.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect golang.org/x/time v0.7.0 // indirect diff --git a/go.sum b/go.sum index dfd868ab..7b56a803 100644 --- a/go.sum +++ b/go.sum @@ -1,24 +1,12 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= -github.com/0xsequence/ethkit v1.29.5 h1:piN0JAsMSvQA+AnlA7g+MXD+F+ggNqY+Po9UbENvfsc= -github.com/0xsequence/ethkit v1.29.5/go.mod h1:rv0FAIyEyN0hhwGefbduAz4ujmyjyJXhCd6a0/yF3tk= -github.com/0xsequence/ethkit v1.29.8-0.20241213155324-eebd3750367c h1:1GSb6htokPSD5Te/J1VuZ34VAds2iIHjCFUHzw1mMrw= -github.com/0xsequence/ethkit v1.29.8-0.20241213155324-eebd3750367c/go.mod h1:rv0FAIyEyN0hhwGefbduAz4ujmyjyJXhCd6a0/yF3tk= -github.com/0xsequence/ethkit v1.30.0 h1:X6yD+R3wewj/8GYKeyXROMv/NksBhuUTQfLsbDF6rDQ= -github.com/0xsequence/ethkit v1.30.0/go.mod h1:rv0FAIyEyN0hhwGefbduAz4ujmyjyJXhCd6a0/yF3tk= -github.com/0xsequence/ethkit v1.30.1 h1:i0jYd7OP8f30reAyIK9e0YJ62eH56JzYCeSTKVi5oWg= -github.com/0xsequence/ethkit v1.30.1/go.mod h1:rv0FAIyEyN0hhwGefbduAz4ujmyjyJXhCd6a0/yF3tk= -github.com/0xsequence/go-ethauth v0.13.0 h1:ZaqFEEqy574A2b1P7vjpcy5tb4W/izn+A3swwOYi9wA= -github.com/0xsequence/go-ethauth v0.13.0/go.mod h1:f3kx39S9F+W+qvZEB6bkKKbpUstmyB7goUntO3wvlhg= -github.com/0xsequence/go-sequence v0.43.6 h1:zab3UEmMR2BJbgBuafTQqavz0A1VuqtKdBFIwsxLY9Y= -github.com/0xsequence/go-sequence v0.43.6/go.mod h1:WC6QAMqHqvRsB1fashBuc6ZOksuQ1+3VK9VeTB9ByV4= -github.com/0xsequence/go-sequence v0.43.8-0.20241213022115-a1289f91a2af h1:zTg/cc0/BM9QzwqjA4N838AQX5ZF8E/9y1AD7Wlu3Eo= -github.com/0xsequence/go-sequence v0.43.8-0.20241213022115-a1289f91a2af/go.mod h1:WC6QAMqHqvRsB1fashBuc6ZOksuQ1+3VK9VeTB9ByV4= -github.com/0xsequence/go-sequence v0.44.0 h1:qSg+W68n347JX8bv4WT/2Yonac90X3zCVv7Iw0iCeM4= -github.com/0xsequence/go-sequence v0.44.0/go.mod h1:O4CHhtf9apxrgPj5qN67kS7nRCUYMm1r9OyRK2zD8t4= -github.com/0xsequence/go-sequence v0.44.1 h1:z5H8rdiqWRBO6ThxzlIPygf7zM5FtvmW+ASiujGvq68= -github.com/0xsequence/go-sequence v0.44.1/go.mod h1:8AmF6vjY0WnrqFknB1/oWKOJsD4/ClKwM7uhEVnuyrk= +github.com/0xsequence/ethkit v1.30.2 h1:TZCxXF+5kjJWE8+CKQGQkDm/coeLL7uwYuLiHiJ4iuM= +github.com/0xsequence/ethkit v1.30.2/go.mod h1:rv0FAIyEyN0hhwGefbduAz4ujmyjyJXhCd6a0/yF3tk= +github.com/0xsequence/go-ethauth v0.14.0 h1:0TQKu/bFpTZ0hNtedqfHuRn/fa2wI8qlLJE0rDgJ0Dw= +github.com/0xsequence/go-ethauth v0.14.0/go.mod h1:AX6zc0LNxzRHXW+i+IPyuLLgj+AdLl7KjLNRXB/10r0= +github.com/0xsequence/go-sequence v0.44.2 h1:UMc0DWme4bcFl32OZu2ace4wNh5XkUI9AQ2cUGtn3/g= +github.com/0xsequence/go-sequence v0.44.2/go.mod h1:taksc+Fh5cMK07swbzJa4BKNKmfi9qbNEiIWoElW2GU= github.com/0xsequence/nitrocontrol v0.3.0 h1:D0/gX576zQhitrJnBfBrOFFufEOzh6f2jO/+2ynwIUA= github.com/0xsequence/nitrocontrol v0.3.0/go.mod h1:sTG5akVPzoVr3unv/7h9aZGaT+BVGmvUMOdwXFeIEEA= github.com/0xsequence/nsm v0.1.0 h1:gVOViRWPUW/c5VEmGy2gCw1az/nqP3gY7VD9V2+069k= @@ -100,8 +88,6 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bits-and-blooms/bitset v1.14.3 h1:Gd2c8lSNf9pKXom5JtD7AaKO8o7fGQ2LtFj1436qilA= -github.com/bits-and-blooms/bitset v1.14.3/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/bits-and-blooms/bitset v1.19.1 h1:mv2yVhy96D2CuskLPXnc58oJNMs5PCWjAZuyYU0p12M= github.com/bits-and-blooms/bitset v1.19.1/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= @@ -151,8 +137,6 @@ github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUK github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= github.com/cloudflare/circl v1.3.9 h1:QFrlgFYf2Qpi8bSpVPK1HBvWpx16v/1TZivyo7pGuBE= github.com/cloudflare/circl v1.3.9/go.mod h1:PDRU+oXvdD7KCtgKxW95M5Z8BpSCJXQORiZFnBQS5QU= -github.com/consensys/bavard v0.1.22 h1:Uw2CGvbXSZWhqK59X0VG/zOjpTFuOMcPLStrp1ihI0A= -github.com/consensys/bavard v0.1.22/go.mod h1:k/zVjHHC4B+PQy1Pg7fgvG3ALicQw540Crag8qx+dZs= github.com/consensys/bavard v0.1.24 h1:Lfe+bjYbpaoT7K5JTFoMi5wo9V4REGLvQQbHmatoN2I= github.com/consensys/bavard v0.1.24/go.mod h1:k/zVjHHC4B+PQy1Pg7fgvG3ALicQw540Crag8qx+dZs= github.com/consensys/gnark-crypto v0.14.0 h1:DDBdl4HaBtdQsq/wfMwJvZNE80sHidrK3Nfrefatm0E= @@ -176,8 +160,8 @@ github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/deckarep/golang-set/v2 v2.6.0 h1:XfcQbWM1LlMB8BsJ8N9vW5ehnnPVIw0je80NsVHagjM= -github.com/deckarep/golang-set/v2 v2.6.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= +github.com/deckarep/golang-set/v2 v2.7.0 h1:gIloKvD7yH2oip4VLhsv3JyLLFnC0Y2mlusgcvJYW5k= +github.com/deckarep/golang-set/v2 v2.7.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= @@ -334,8 +318,6 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rH github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg= github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= -github.com/holiman/uint256 v1.3.1 h1:JfTzmih28bittyHM8z360dCjIA9dbPIBlcTI6lmctQs= -github.com/holiman/uint256 v1.3.1/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= github.com/holiman/uint256 v1.3.2 h1:a9EgMPSC1AAaj1SZL5zIQD3WbwTuHrMGOerLjGmM/TA= github.com/holiman/uint256 v1.3.2/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= @@ -684,8 +666,6 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= -golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= -golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY= @@ -739,8 +719,8 @@ golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= -golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= @@ -758,8 +738,6 @@ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -817,8 +795,6 @@ golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= -golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -835,9 +811,8 @@ golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= -golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= -golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= +golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -852,8 +827,6 @@ golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= -golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= diff --git a/vendor/github.com/0xsequence/ethkit/ethcoder/typed_data.go b/vendor/github.com/0xsequence/ethkit/ethcoder/typed_data.go index 5cca8c3a..9551b55a 100644 --- a/vendor/github.com/0xsequence/ethkit/ethcoder/typed_data.go +++ b/vendor/github.com/0xsequence/ethkit/ethcoder/typed_data.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "math/big" + "slices" "sort" "strings" @@ -320,7 +321,12 @@ func (t *TypedData) UnmarshalJSON(data []byte) error { // Ensure primary type is defined if raw.PrimaryType == "" { - return fmt.Errorf("primary type is required") + // detect primary type if its unspecified + primaryType, err := typedDataDetectPrimaryType(raw.Types.Map(), raw.Message) + if err != nil { + return err + } + raw.PrimaryType = primaryType } _, ok = raw.Types[raw.PrimaryType] if !ok { @@ -346,6 +352,50 @@ func (t *TypedData) UnmarshalJSON(data []byte) error { return nil } +func typedDataDetectPrimaryType(typesMap map[string]map[string]string, message map[string]interface{}) (string, error) { + // If there are only two types, and one is the EIP712Domain, then the other is the primary type + if len(typesMap) == 2 { + _, ok := typesMap["EIP712Domain"] + if ok { + for typ := range typesMap { + if typ == "EIP712Domain" { + continue + } + return typ, nil + } + } + } + + // Otherwise search for the primary type by looking for the first type that has a message field keys + messageKeys := []string{} + for k := range message { + messageKeys = append(messageKeys, k) + } + sort.Strings(messageKeys) + + for typ := range typesMap { + if typ == "EIP712Domain" { + continue + } + if len(typesMap[typ]) != len(messageKeys) { + continue + } + + typKeys := []string{} + for k := range typesMap[typ] { + typKeys = append(typKeys, k) + } + sort.Strings(typKeys) + + if !slices.Equal(messageKeys, typKeys) { + continue + } + return typ, nil + } + + return "", fmt.Errorf("no primary type found") +} + func typedDataDecodeRawMessageMap(typesMap map[string]map[string]string, primaryType string, data interface{}) (interface{}, error) { // Handle array types if arr, ok := data.([]interface{}); ok { diff --git a/vendor/github.com/0xsequence/go-ethauth/proof.go b/vendor/github.com/0xsequence/go-ethauth/proof.go index 3cd123b7..086bc618 100644 --- a/vendor/github.com/0xsequence/go-ethauth/proof.go +++ b/vendor/github.com/0xsequence/go-ethauth/proof.go @@ -5,6 +5,7 @@ import ( "time" "github.com/0xsequence/ethkit/ethcoder" + "github.com/0xsequence/ethkit/go-ethereum/crypto" ) type Proof struct { @@ -34,6 +35,10 @@ func NewProof() *Proof { } } +func (t *Proof) Message() ([]byte, error) { + return t.Claims.Message() +} + func (t *Proof) MessageDigest() ([]byte, error) { return t.Claims.MessageDigest() } @@ -152,7 +157,7 @@ func (c Claims) TypedData() (*ethcoder.TypedData, error) { return td, nil } -func (c Claims) MessageDigest() ([]byte, error) { +func (c Claims) Message() ([]byte, error) { if err := c.Valid(); err != nil { return nil, fmt.Errorf("claims are invalid - %w", err) } @@ -162,10 +167,19 @@ func (c Claims) MessageDigest() ([]byte, error) { return nil, fmt.Errorf("ethauth: failed to compute claims typed data - %w", err) } - digest, err := typedData.EncodeDigest() + _, encodedTypedData, err := typedData.Encode() if err != nil { - return nil, fmt.Errorf("ethauth: failed to compute claims message digest - %w", err) + return nil, fmt.Errorf("ethauth: failed to encode claims typed data - %w", err) } + return encodedTypedData, nil +} + +func (c Claims) MessageDigest() ([]byte, error) { + encodedTypedData, err := c.Message() + if err != nil { + return nil, fmt.Errorf("ethauth: failed to compute claims message digest - %w", err) + } + digest := crypto.Keccak256(encodedTypedData) return digest, nil } diff --git a/vendor/github.com/0xsequence/go-ethauth/validate.go b/vendor/github.com/0xsequence/go-ethauth/validate.go index 61416b0c..519ba29b 100644 --- a/vendor/github.com/0xsequence/go-ethauth/validate.go +++ b/vendor/github.com/0xsequence/go-ethauth/validate.go @@ -4,14 +4,13 @@ import ( "context" "fmt" "math/big" - "strings" "github.com/0xsequence/ethkit/ethcoder" "github.com/0xsequence/ethkit/ethrpc" + "github.com/0xsequence/ethkit/ethwallet" "github.com/0xsequence/ethkit/go-ethereum" "github.com/0xsequence/ethkit/go-ethereum/common" "github.com/0xsequence/ethkit/go-ethereum/common/hexutil" - "github.com/0xsequence/ethkit/go-ethereum/crypto" ) type ValidatorFunc func(ctx context.Context, provider *ethrpc.Provider, chainID *big.Int, proof *Proof) (bool, string, error) @@ -19,13 +18,13 @@ type ValidatorFunc func(ctx context.Context, provider *ethrpc.Provider, chainID // ValidateEOAProof verifies the account proof, testing if the proof claims have been signed with an // EOA (externally owned account) and will return success/failture, the account address as a string, and any errors. func ValidateEOAProof(ctx context.Context, provider *ethrpc.Provider, chainID *big.Int, proof *Proof) (bool, string, error) { - // Compute eip712 message digest from the proof claims - messageDigest, err := proof.MessageDigest() + // Compute eip712 encoded message from the proof claims + message, err := proof.Message() if err != nil { return false, "", fmt.Errorf("ValidateEOAProof failed. Unable to compute ethauth message digest, because %w", err) } - isValid, err := ValidateEOASignature(proof.Address, messageDigest, proof.Signature) + isValid, err := ValidateEOASignature(proof.Address, message, proof.Signature) if err != nil { return false, "", err } @@ -71,7 +70,7 @@ func ValidateContractAccountProof(ctx context.Context, provider *ethrpc.Provider return false, "", fmt.Errorf("ValidateContractAccountProof failed. HexDecode of proof.signature failed - %w", err) } - input, err := ethcoder.AbiEncodeMethodCalldata("isValidSignature(bytes32,bytes)", []interface{}{ + input, err := ethcoder.ABIEncodeMethodCalldata("isValidSignature(bytes32,bytes)", []interface{}{ ethcoder.BytesToBytes32(messageDigest), signature, }) @@ -110,26 +109,20 @@ func ValidateEOASignature(address string, message []byte, signatureHex string) ( if len(message) < 1 || len(signatureHex) < 1 { return false, fmt.Errorf("ValidateEOASignature, message and signature must not be empty") } - msg := fmt.Sprintf("\x19Ethereum Signed Message:\n%v%s", len(message), message) + sig, err := hexutil.Decode(signatureHex) if err != nil { return false, fmt.Errorf("ValidateEOASignature, signature is an invalid hex string") } - if len(sig) != 65 { - return false, fmt.Errorf("ValidateEOASignature, signature is not of proper length") - } - hash := crypto.Keccak256([]byte(msg)) - if sig[64] > 1 { - sig[64] -= 27 // recovery ID - } - pubkey, err := crypto.SigToPub(hash, sig) + isValid, err := ethwallet.IsValid191Signature(common.HexToAddress(address), message, sig) if err != nil { - return false, err + fmt.Println("NO1") + return false, fmt.Errorf("ValidateEOASignature, invalid signature") } - key := crypto.PubkeyToAddress(*pubkey).Hex() - if strings.ToLower(key) == strings.ToLower(address) { - return true, nil + if !isValid { + fmt.Println("NO2") + return false, fmt.Errorf("ValidateEOASignature, invalid signature") } - return false, fmt.Errorf("ValidateEOASignature, invalid signature") + return true, nil } diff --git a/vendor/github.com/0xsequence/go-sequence/go.work.sum b/vendor/github.com/0xsequence/go-sequence/go.work.sum index 3e59717b..f71bbe2c 100644 --- a/vendor/github.com/0xsequence/go-sequence/go.work.sum +++ b/vendor/github.com/0xsequence/go-sequence/go.work.sum @@ -40,6 +40,8 @@ github.com/0xsequence/ethkit v1.27.11 h1:fWcABQx1WIH4SWvesCuKBJ+D4XdwZcIGWGSYnBC github.com/0xsequence/ethkit v1.27.11/go.mod h1:rv0FAIyEyN0hhwGefbduAz4ujmyjyJXhCd6a0/yF3tk= github.com/0xsequence/ethkit v1.29.5 h1:piN0JAsMSvQA+AnlA7g+MXD+F+ggNqY+Po9UbENvfsc= github.com/0xsequence/ethkit v1.29.5/go.mod h1:rv0FAIyEyN0hhwGefbduAz4ujmyjyJXhCd6a0/yF3tk= +github.com/0xsequence/go-ethauth v0.13.0 h1:ZaqFEEqy574A2b1P7vjpcy5tb4W/izn+A3swwOYi9wA= +github.com/0xsequence/go-ethauth v0.13.0/go.mod h1:f3kx39S9F+W+qvZEB6bkKKbpUstmyB7goUntO3wvlhg= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= @@ -225,6 +227,7 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= +golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -291,6 +294,7 @@ golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -353,7 +357,6 @@ golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3 golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= -golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/vendor/github.com/0xsequence/go-sequence/signature.go b/vendor/github.com/0xsequence/go-sequence/signature.go index 2579a698..f4837c58 100644 --- a/vendor/github.com/0xsequence/go-sequence/signature.go +++ b/vendor/github.com/0xsequence/go-sequence/signature.go @@ -172,6 +172,21 @@ func IsValidMessageSignature(address common.Address, message []byte, signature [ return IsValidSignature(log, address, common.BytesToHash(accounts.TextHash(message)), signature, SequenceContexts(), chainID, provider) } +func IsValidTypedDataSignature(address common.Address, encodedTypedData []byte, signature []byte, chainID *big.Int, provider *ethrpc.Provider, optLogger *logger.Logger) (bool, error) { + log := logger.Nop() + if optLogger != nil { + log = *optLogger + } + + isValid, err := ethwallet.IsValid191Signature(address, encodedTypedData, signature) + if err == nil && isValid { + return true, nil + } + + typedDataDigest := common.BytesToHash(ethcoder.Keccak256(encodedTypedData)) + return IsValidSignature(log, address, typedDataDigest, signature, SequenceContexts(), chainID, provider) +} + func IsValidSignature(log logger.Logger, walletAddress common.Address, digest common.Hash, seqSig []byte, walletContexts WalletContexts, chainID *big.Int, provider *ethrpc.Provider) (bool, error) { eip6492isValid, _ := eip6492.ValidateEIP6492Offchain(context.Background(), provider, walletAddress, digest, seqSig, nil) if eip6492isValid { diff --git a/vendor/github.com/0xsequence/go-sequence/wallet.go b/vendor/github.com/0xsequence/go-sequence/wallet.go index f144ffdf..d715c1c8 100644 --- a/vendor/github.com/0xsequence/go-sequence/wallet.go +++ b/vendor/github.com/0xsequence/go-sequence/wallet.go @@ -435,6 +435,18 @@ func (w *Wallet[C]) SignMessage(msg []byte) ([]byte, error) { return w.SignDigest(context.Background(), MessageDigest(msg)) } +func (w *Wallet[C]) SignTypedData(typedData *ethcoder.TypedData) ([]byte, []byte, error) { + digest, encodedTypedData, err := typedData.Encode() + if err != nil { + return nil, nil, err + } + signature, err := w.SignDigest(context.Background(), common.Hash(digest)) + if err != nil { + return nil, nil, err + } + return signature, encodedTypedData, nil +} + var _ MessageSigner = (*Wallet[*v1.WalletConfig])(nil) var _ MessageSigner = (*Wallet[*v2.WalletConfig])(nil) diff --git a/vendor/github.com/deckarep/golang-set/v2/README.md b/vendor/github.com/deckarep/golang-set/v2/README.md index 921f0cec..bb691b1c 100644 --- a/vendor/github.com/deckarep/golang-set/v2/README.md +++ b/vendor/github.com/deckarep/golang-set/v2/README.md @@ -6,6 +6,15 @@ The missing `generic` set collection for the Go language. Until Go has sets built-in...use this. +## Psst +* Hi there, 👋! Do you use or have interest in the [Zig programming language](https://ziglang.org/) created by Andrew Kelley? If so, the golang-set project has a new sibling project: [ziglang-set](https://github.com/deckarep/ziglang-set)! Come check it out! + +## Update 12/3/2024 +* Packaged version: `2.7.0` fixes a long-standing bug with *JSON Unmarshaling*. A large refactor in the interest of performance +introduced this bug and there was no way around it but to revert the code back to how it was previously. The performance +difference was likely negligible to begin with. JSON Marshaling and Unmarshaling is now properly supported again without +needing to do workarounds. + ## Update 3/5/2023 * Packaged version: `2.2.0` release includes a refactor to minimize pointer indirection, better method documentation standards and a few constructor convenience methods to increase ergonomics when appending items `Append` or creating a new set from an exist `Map`. * supports `new generic` syntax diff --git a/vendor/github.com/deckarep/golang-set/v2/threadsafe.go b/vendor/github.com/deckarep/golang-set/v2/threadsafe.go index ad7a834b..93f20c86 100644 --- a/vendor/github.com/deckarep/golang-set/v2/threadsafe.go +++ b/vendor/github.com/deckarep/golang-set/v2/threadsafe.go @@ -29,7 +29,7 @@ import "sync" type threadSafeSet[T comparable] struct { sync.RWMutex - uss threadUnsafeSet[T] + uss *threadUnsafeSet[T] } func newThreadSafeSet[T comparable]() *threadSafeSet[T] { @@ -123,7 +123,7 @@ func (t *threadSafeSet[T]) Union(other Set[T]) Set[T] { t.RLock() o.RLock() - unsafeUnion := t.uss.Union(o.uss).(threadUnsafeSet[T]) + unsafeUnion := t.uss.Union(o.uss).(*threadUnsafeSet[T]) ret := &threadSafeSet[T]{uss: unsafeUnion} t.RUnlock() o.RUnlock() @@ -136,7 +136,7 @@ func (t *threadSafeSet[T]) Intersect(other Set[T]) Set[T] { t.RLock() o.RLock() - unsafeIntersection := t.uss.Intersect(o.uss).(threadUnsafeSet[T]) + unsafeIntersection := t.uss.Intersect(o.uss).(*threadUnsafeSet[T]) ret := &threadSafeSet[T]{uss: unsafeIntersection} t.RUnlock() o.RUnlock() @@ -149,7 +149,7 @@ func (t *threadSafeSet[T]) Difference(other Set[T]) Set[T] { t.RLock() o.RLock() - unsafeDifference := t.uss.Difference(o.uss).(threadUnsafeSet[T]) + unsafeDifference := t.uss.Difference(o.uss).(*threadUnsafeSet[T]) ret := &threadSafeSet[T]{uss: unsafeDifference} t.RUnlock() o.RUnlock() @@ -162,7 +162,7 @@ func (t *threadSafeSet[T]) SymmetricDifference(other Set[T]) Set[T] { t.RLock() o.RLock() - unsafeDifference := t.uss.SymmetricDifference(o.uss).(threadUnsafeSet[T]) + unsafeDifference := t.uss.SymmetricDifference(o.uss).(*threadUnsafeSet[T]) ret := &threadSafeSet[T]{uss: unsafeDifference} t.RUnlock() o.RUnlock() @@ -177,7 +177,7 @@ func (t *threadSafeSet[T]) Clear() { func (t *threadSafeSet[T]) Remove(v T) { t.Lock() - delete(t.uss, v) + delete(*t.uss, v) t.Unlock() } @@ -190,12 +190,12 @@ func (t *threadSafeSet[T]) RemoveAll(i ...T) { func (t *threadSafeSet[T]) Cardinality() int { t.RLock() defer t.RUnlock() - return len(t.uss) + return len(*t.uss) } func (t *threadSafeSet[T]) Each(cb func(T) bool) { t.RLock() - for elem := range t.uss { + for elem := range *t.uss { if cb(elem) { break } @@ -208,7 +208,7 @@ func (t *threadSafeSet[T]) Iter() <-chan T { go func() { t.RLock() - for elem := range t.uss { + for elem := range *t.uss { ch <- elem } close(ch) @@ -224,7 +224,7 @@ func (t *threadSafeSet[T]) Iterator() *Iterator[T] { go func() { t.RLock() L: - for elem := range t.uss { + for elem := range *t.uss { select { case <-stopCh: break L @@ -253,7 +253,7 @@ func (t *threadSafeSet[T]) Equal(other Set[T]) bool { func (t *threadSafeSet[T]) Clone() Set[T] { t.RLock() - unsafeClone := t.uss.Clone().(threadUnsafeSet[T]) + unsafeClone := t.uss.Clone().(*threadUnsafeSet[T]) ret := &threadSafeSet[T]{uss: unsafeClone} t.RUnlock() return ret @@ -275,7 +275,7 @@ func (t *threadSafeSet[T]) Pop() (T, bool) { func (t *threadSafeSet[T]) ToSlice() []T { keys := make([]T, 0, t.Cardinality()) t.RLock() - for elem := range t.uss { + for elem := range *t.uss { keys = append(keys, elem) } t.RUnlock() diff --git a/vendor/github.com/deckarep/golang-set/v2/threadunsafe.go b/vendor/github.com/deckarep/golang-set/v2/threadunsafe.go index 8b17b017..7e3243b2 100644 --- a/vendor/github.com/deckarep/golang-set/v2/threadunsafe.go +++ b/vendor/github.com/deckarep/golang-set/v2/threadunsafe.go @@ -34,14 +34,16 @@ import ( type threadUnsafeSet[T comparable] map[T]struct{} // Assert concrete type:threadUnsafeSet adheres to Set interface. -var _ Set[string] = (threadUnsafeSet[string])(nil) +var _ Set[string] = (*threadUnsafeSet[string])(nil) -func newThreadUnsafeSet[T comparable]() threadUnsafeSet[T] { - return make(threadUnsafeSet[T]) +func newThreadUnsafeSet[T comparable]() *threadUnsafeSet[T] { + t := make(threadUnsafeSet[T]) + return &t } -func newThreadUnsafeSetWithSize[T comparable](cardinality int) threadUnsafeSet[T] { - return make(threadUnsafeSet[T], cardinality) +func newThreadUnsafeSetWithSize[T comparable](cardinality int) *threadUnsafeSet[T] { + t := make(threadUnsafeSet[T], cardinality) + return &t } func (s threadUnsafeSet[T]) Add(v T) bool { @@ -50,57 +52,57 @@ func (s threadUnsafeSet[T]) Add(v T) bool { return prevLen != len(s) } -func (s threadUnsafeSet[T]) Append(v ...T) int { - prevLen := len(s) +func (s *threadUnsafeSet[T]) Append(v ...T) int { + prevLen := len(*s) for _, val := range v { - (s)[val] = struct{}{} + (*s)[val] = struct{}{} } - return len(s) - prevLen + return len(*s) - prevLen } // private version of Add which doesn't return a value -func (s threadUnsafeSet[T]) add(v T) { - s[v] = struct{}{} +func (s *threadUnsafeSet[T]) add(v T) { + (*s)[v] = struct{}{} } -func (s threadUnsafeSet[T]) Cardinality() int { - return len(s) +func (s *threadUnsafeSet[T]) Cardinality() int { + return len(*s) } -func (s threadUnsafeSet[T]) Clear() { +func (s *threadUnsafeSet[T]) Clear() { // Constructions like this are optimised by compiler, and replaced by // mapclear() function, defined in // https://github.com/golang/go/blob/29bbca5c2c1ad41b2a9747890d183b6dd3a4ace4/src/runtime/map.go#L993) - for key := range s { - delete(s, key) + for key := range *s { + delete(*s, key) } } -func (s threadUnsafeSet[T]) Clone() Set[T] { +func (s *threadUnsafeSet[T]) Clone() Set[T] { clonedSet := newThreadUnsafeSetWithSize[T](s.Cardinality()) - for elem := range s { + for elem := range *s { clonedSet.add(elem) } return clonedSet } -func (s threadUnsafeSet[T]) Contains(v ...T) bool { +func (s *threadUnsafeSet[T]) Contains(v ...T) bool { for _, val := range v { - if _, ok := s[val]; !ok { + if _, ok := (*s)[val]; !ok { return false } } return true } -func (s threadUnsafeSet[T]) ContainsOne(v T) bool { - _, ok := s[v] +func (s *threadUnsafeSet[T]) ContainsOne(v T) bool { + _, ok := (*s)[v] return ok } -func (s threadUnsafeSet[T]) ContainsAny(v ...T) bool { +func (s *threadUnsafeSet[T]) ContainsAny(v ...T) bool { for _, val := range v { - if _, ok := s[val]; ok { + if _, ok := (*s)[val]; ok { return true } } @@ -108,16 +110,16 @@ func (s threadUnsafeSet[T]) ContainsAny(v ...T) bool { } // private version of Contains for a single element v -func (s threadUnsafeSet[T]) contains(v T) (ok bool) { - _, ok = s[v] +func (s *threadUnsafeSet[T]) contains(v T) (ok bool) { + _, ok = (*s)[v] return ok } -func (s threadUnsafeSet[T]) Difference(other Set[T]) Set[T] { - o := other.(threadUnsafeSet[T]) +func (s *threadUnsafeSet[T]) Difference(other Set[T]) Set[T] { + o := other.(*threadUnsafeSet[T]) diff := newThreadUnsafeSet[T]() - for elem := range s { + for elem := range *s { if !o.contains(elem) { diff.add(elem) } @@ -125,21 +127,21 @@ func (s threadUnsafeSet[T]) Difference(other Set[T]) Set[T] { return diff } -func (s threadUnsafeSet[T]) Each(cb func(T) bool) { - for elem := range s { +func (s *threadUnsafeSet[T]) Each(cb func(T) bool) { + for elem := range *s { if cb(elem) { break } } } -func (s threadUnsafeSet[T]) Equal(other Set[T]) bool { - o := other.(threadUnsafeSet[T]) +func (s *threadUnsafeSet[T]) Equal(other Set[T]) bool { + o := other.(*threadUnsafeSet[T]) if s.Cardinality() != other.Cardinality() { return false } - for elem := range s { + for elem := range *s { if !o.contains(elem) { return false } @@ -147,19 +149,19 @@ func (s threadUnsafeSet[T]) Equal(other Set[T]) bool { return true } -func (s threadUnsafeSet[T]) Intersect(other Set[T]) Set[T] { - o := other.(threadUnsafeSet[T]) +func (s *threadUnsafeSet[T]) Intersect(other Set[T]) Set[T] { + o := other.(*threadUnsafeSet[T]) intersection := newThreadUnsafeSet[T]() // loop over smaller set if s.Cardinality() < other.Cardinality() { - for elem := range s { + for elem := range *s { if o.contains(elem) { intersection.add(elem) } } } else { - for elem := range o { + for elem := range *o { if s.contains(elem) { intersection.add(elem) } @@ -168,24 +170,24 @@ func (s threadUnsafeSet[T]) Intersect(other Set[T]) Set[T] { return intersection } -func (s threadUnsafeSet[T]) IsEmpty() bool { +func (s *threadUnsafeSet[T]) IsEmpty() bool { return s.Cardinality() == 0 } -func (s threadUnsafeSet[T]) IsProperSubset(other Set[T]) bool { +func (s *threadUnsafeSet[T]) IsProperSubset(other Set[T]) bool { return s.Cardinality() < other.Cardinality() && s.IsSubset(other) } -func (s threadUnsafeSet[T]) IsProperSuperset(other Set[T]) bool { +func (s *threadUnsafeSet[T]) IsProperSuperset(other Set[T]) bool { return s.Cardinality() > other.Cardinality() && s.IsSuperset(other) } -func (s threadUnsafeSet[T]) IsSubset(other Set[T]) bool { - o := other.(threadUnsafeSet[T]) +func (s *threadUnsafeSet[T]) IsSubset(other Set[T]) bool { + o := other.(*threadUnsafeSet[T]) if s.Cardinality() > other.Cardinality() { return false } - for elem := range s { + for elem := range *s { if !o.contains(elem) { return false } @@ -193,14 +195,14 @@ func (s threadUnsafeSet[T]) IsSubset(other Set[T]) bool { return true } -func (s threadUnsafeSet[T]) IsSuperset(other Set[T]) bool { +func (s *threadUnsafeSet[T]) IsSuperset(other Set[T]) bool { return other.IsSubset(s) } -func (s threadUnsafeSet[T]) Iter() <-chan T { +func (s *threadUnsafeSet[T]) Iter() <-chan T { ch := make(chan T) go func() { - for elem := range s { + for elem := range *s { ch <- elem } close(ch) @@ -209,12 +211,12 @@ func (s threadUnsafeSet[T]) Iter() <-chan T { return ch } -func (s threadUnsafeSet[T]) Iterator() *Iterator[T] { +func (s *threadUnsafeSet[T]) Iterator() *Iterator[T] { iterator, ch, stopCh := newIterator[T]() go func() { L: - for elem := range s { + for elem := range *s { select { case <-stopCh: break L @@ -229,9 +231,9 @@ func (s threadUnsafeSet[T]) Iterator() *Iterator[T] { // Pop returns a popped item in case set is not empty, or nil-value of T // if set is already empty -func (s threadUnsafeSet[T]) Pop() (v T, ok bool) { - for item := range s { - delete(s, item) +func (s *threadUnsafeSet[T]) Pop() (v T, ok bool) { + for item := range *s { + delete(*s, item) return item, true } return v, false @@ -256,16 +258,16 @@ func (s threadUnsafeSet[T]) String() string { return fmt.Sprintf("Set{%s}", strings.Join(items, ", ")) } -func (s threadUnsafeSet[T]) SymmetricDifference(other Set[T]) Set[T] { - o := other.(threadUnsafeSet[T]) +func (s *threadUnsafeSet[T]) SymmetricDifference(other Set[T]) Set[T] { + o := other.(*threadUnsafeSet[T]) sd := newThreadUnsafeSet[T]() - for elem := range s { + for elem := range *s { if !o.contains(elem) { sd.add(elem) } } - for elem := range o { + for elem := range *o { if !s.contains(elem) { sd.add(elem) } @@ -283,7 +285,7 @@ func (s threadUnsafeSet[T]) ToSlice() []T { } func (s threadUnsafeSet[T]) Union(other Set[T]) Set[T] { - o := other.(threadUnsafeSet[T]) + o := other.(*threadUnsafeSet[T]) n := s.Cardinality() if o.Cardinality() > n { @@ -294,10 +296,10 @@ func (s threadUnsafeSet[T]) Union(other Set[T]) Set[T] { for elem := range s { unionedSet.add(elem) } - for elem := range o { + for elem := range *o { unionedSet.add(elem) } - return unionedSet + return &unionedSet } // MarshalJSON creates a JSON array from the set, it marshals all elements @@ -318,7 +320,7 @@ func (s threadUnsafeSet[T]) MarshalJSON() ([]byte, error) { // UnmarshalJSON recreates a set from a JSON array, it only decodes // primitive types. Numbers are decoded as json.Number. -func (s threadUnsafeSet[T]) UnmarshalJSON(b []byte) error { +func (s *threadUnsafeSet[T]) UnmarshalJSON(b []byte) error { var i []T err := json.Unmarshal(b, &i) if err != nil { diff --git a/vendor/modules.txt b/vendor/modules.txt index 5945c188..fa6c1ae0 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,7 +1,7 @@ # dario.cat/mergo v1.0.0 ## explicit; go 1.13 dario.cat/mergo -# github.com/0xsequence/ethkit v1.30.1 +# github.com/0xsequence/ethkit v1.30.2 ## explicit; go 1.21 github.com/0xsequence/ethkit github.com/0xsequence/ethkit/ethartifact @@ -38,10 +38,10 @@ github.com/0xsequence/ethkit/go-ethereum/rlp github.com/0xsequence/ethkit/go-ethereum/rlp/internal/rlpstruct github.com/0xsequence/ethkit/go-ethereum/rpc github.com/0xsequence/ethkit/util -# github.com/0xsequence/go-ethauth v0.13.0 -## explicit; go 1.17 +# github.com/0xsequence/go-ethauth v0.14.0 +## explicit; go 1.22 github.com/0xsequence/go-ethauth -# github.com/0xsequence/go-sequence v0.44.1 +# github.com/0xsequence/go-sequence v0.44.2 ## explicit; go 1.22.0 github.com/0xsequence/go-sequence github.com/0xsequence/go-sequence/contracts @@ -344,7 +344,7 @@ github.com/cyphar/filepath-securejoin # github.com/davecgh/go-spew v1.1.1 ## explicit github.com/davecgh/go-spew/spew -# github.com/deckarep/golang-set/v2 v2.6.0 +# github.com/deckarep/golang-set/v2 v2.7.0 ## explicit; go 1.18 github.com/deckarep/golang-set/v2 # github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 @@ -998,7 +998,7 @@ golang.org/x/exp/constraints golang.org/x/mod/internal/lazyregexp golang.org/x/mod/module golang.org/x/mod/semver -# golang.org/x/net v0.30.0 +# golang.org/x/net v0.32.0 ## explicit; go 1.18 golang.org/x/net/bpf golang.org/x/net/context