diff --git a/go.mod b/go.mod index 7aebe20..c0b3928 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ toolchain go1.23.1 // replace github.com/0xsequence/ethkit => /Users/peter/Dev/0xsequence/ethkit require ( - github.com/0xsequence/ethkit v1.29.5 + github.com/0xsequence/ethkit v1.30.0 github.com/0xsequence/go-ethauth v0.13.0 github.com/BurntSushi/toml v1.2.1 github.com/davecgh/go-spew v1.1.1 @@ -20,13 +20,13 @@ require ( require ( github.com/Microsoft/go-winio v0.6.2 // indirect - github.com/bits-and-blooms/bitset v1.14.3 // indirect + github.com/bits-and-blooms/bitset v1.19.1 // indirect github.com/btcsuite/btcd v0.24.2 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect github.com/btcsuite/btcd/btcutil v1.1.6 // indirect github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/consensys/bavard v0.1.22 // indirect + github.com/consensys/bavard v0.1.24 // indirect github.com/consensys/gnark-crypto v0.14.0 // indirect github.com/crate-crypto/go-kzg-4844 v1.1.0 // indirect github.com/deckarep/golang-set/v2 v2.6.0 // indirect @@ -41,19 +41,19 @@ require ( github.com/goware/singleflight v0.2.0 // indirect github.com/goware/superr v0.0.2 // indirect github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect - github.com/holiman/uint256 v1.3.1 // indirect + github.com/holiman/uint256 v1.3.2 // indirect github.com/mmcloughlin/addchain v0.4.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/redis/go-redis/v9 v9.6.1 // indirect github.com/stretchr/objx v0.5.2 // indirect github.com/supranational/blst v0.3.13 // indirect github.com/tyler-smith/go-bip39 v1.1.0 // indirect - golang.org/x/crypto v0.28.0 // indirect + golang.org/x/crypto v0.31.0 // indirect golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect golang.org/x/net v0.29.0 // indirect - golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.26.0 // indirect - golang.org/x/text v0.19.0 // indirect + golang.org/x/sync v0.10.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/text v0.21.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) diff --git a/go.sum b/go.sum index cca9c45..2984360 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -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.30.0 h1:X6yD+R3wewj/8GYKeyXROMv/NksBhuUTQfLsbDF6rDQ= +github.com/0xsequence/ethkit v1.30.0/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 v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= @@ -7,8 +7,8 @@ github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbi github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= -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= github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c= github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= @@ -44,8 +44,8 @@ github.com/cespare/cp v1.1.1 h1:nCb6ZLdB7NRaqsm91JtQTAme2SKJzXVsdPIPkyJr1MU= github.com/cespare/cp v1.1.1/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -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= github.com/consensys/gnark-crypto v0.14.0/go.mod h1:CU4UijNPsHawiVGNxe9co07FkzCeWHHrb1li/n1XoU0= github.com/crate-crypto/go-kzg-4844 v1.1.0 h1:EN/u9k2TF6OWSHrCCDBBU6GLNMq88OspHHlMnHfoyU4= @@ -106,8 +106,8 @@ github.com/goware/superr v0.0.2 h1:71xI6ojd+YXyq2RamI8lMpkYTNoErI5Uyrv8vFAPr1U= github.com/goware/superr v0.0.2/go.mod h1:EcKklaJ9ql9J+gKfwThuYsQ1IpUlOdUabO3qkAJrv60= 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= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= @@ -161,8 +161,8 @@ github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3C golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -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-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk= golang.org/x/exp v0.0.0-20240909161429-701f63a606c0/go.mod h1:2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -173,8 +173,8 @@ golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -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-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -184,13 +184,13 @@ golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -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/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= -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/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/go.work.sum b/go.work.sum index ed545b3..3e59717 100644 --- a/go.work.sum +++ b/go.work.sum @@ -38,6 +38,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/0xsequence/ethkit v1.27.11 h1:fWcABQx1WIH4SWvesCuKBJ+D4XdwZcIGWGSYnBCM+VU= 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/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= @@ -345,11 +347,13 @@ golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457/go.mod h1:pRgIJT+bRLFKnoM1ldnzKoxTIn14Yxz928LQRYYgIN0= golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= +golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 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/intents/intent.gen.go b/intents/intent.gen.go index 540e262..6dba047 100644 --- a/intents/intent.gen.go +++ b/intents/intent.gen.go @@ -1,4 +1,4 @@ -// sequence-waas-intents v0.1.0 47010351881054ccb75b704db39b04ddc8837c4b +// sequence-waas-intents v0.1.0 2ceeffac8ca0cebead69d58a1aa7a27d30ecb864 // -- // Code generated by webrpc-gen@v0.19.3 with golang generator. DO NOT EDIT. // @@ -11,6 +11,8 @@ import ( "errors" "fmt" "net/http" + + "github.com/0xsequence/ethkit/ethcoder" ) // WebRPC description and code-gen version @@ -25,7 +27,7 @@ func WebRPCSchemaVersion() string { // Schema hash generated from your RIDL schema func WebRPCSchemaHash() string { - return "47010351881054ccb75b704db39b04ddc8837c4b" + return "2ceeffac8ca0cebead69d58a1aa7a27d30ecb864" } // @@ -45,6 +47,7 @@ const ( IntentName_sessionAuthProof IntentName = "sessionAuthProof" IntentName_feeOptions IntentName = "feeOptions" IntentName_signMessage IntentName = "signMessage" + IntentName_signTypedData IntentName = "signTypedData" IntentName_sendTransaction IntentName = "sendTransaction" IntentName_getTransactionReceipt IntentName = "getTransactionReceipt" IntentName_federateAccount IntentName = "federateAccount" @@ -122,6 +125,7 @@ const ( IntentResponseCode_validationFinished IntentResponseCode = "validationFinished" IntentResponseCode_sessionAuthProof IntentResponseCode = "sessionAuthProof" IntentResponseCode_signedMessage IntentResponseCode = "signedMessage" + IntentResponseCode_signedTypedData IntentResponseCode = "signedTypedData" IntentResponseCode_feeOptions IntentResponseCode = "feeOptions" IntentResponseCode_transactionReceipt IntentResponseCode = "transactionReceipt" IntentResponseCode_transactionFailed IntentResponseCode = "transactionFailed" @@ -331,6 +335,12 @@ type IntentDataSignMessage struct { Message string `json:"message"` } +type IntentDataSignTypedData struct { + Network string `json:"network"` + Wallet string `json:"wallet"` + TypedData *ethcoder.TypedData `json:"typedData"` +} + type IntentDataFeeOptions struct { Network string `json:"network"` Wallet string `json:"wallet"` @@ -520,6 +530,11 @@ type IntentResponseSignedMessage struct { Message string `json:"message"` } +type IntentResponseSignedTypedData struct { + Signature string `json:"signature"` + EncodedTypedData string `json:"encodedTypedData"` +} + type FeeOption struct { Token *FeeToken `json:"token"` To string `json:"to"` diff --git a/intents/intent.ridl b/intents/intent.ridl index 51899d9..c0e4e31 100644 --- a/intents/intent.ridl +++ b/intents/intent.ridl @@ -28,6 +28,7 @@ enum IntentName: string - sessionAuthProof - feeOptions - signMessage + - signTypedData - sendTransaction - getTransactionReceipt - federateAccount @@ -82,7 +83,7 @@ struct IntentDataValidateSession struct IntentDataFinishValidateSession - sessionId: string + go.field.name = SessionID - - wallet: string + - wallet: string - salt: string - challenge: string @@ -101,19 +102,25 @@ struct IntentDataSessionAuthProof struct IntentDataSignMessage - network: string - - wallet: string + - wallet: string - message: string +struct IntentDataSignTypedData + - network: string + - wallet: string + - typedData: any + + go.field.type = *ethcoder.TypedData + struct IntentDataFeeOptions - network: string - - wallet: string + - wallet: string - identifier: string # is used to generate nonce space - transactions: []any + go.field.type = []json.RawMessage struct IntentDataSendTransaction - network: string - - wallet: string + - wallet: string - identifier: string # is used to generate nonce space - transactions: []any + go.field.type = []json.RawMessage @@ -252,6 +259,7 @@ enum IntentResponseCode: string - validationFinished - sessionAuthProof - signedMessage + - signedTypedData - feeOptions - transactionReceipt - transactionFailed @@ -312,6 +320,10 @@ struct IntentResponseSignedMessage - signature: string - message: string +struct IntentResponseSignedTypedData + - signature: string + - encodedTypedData: string + struct FeeOption - token: FeeToken - to: string diff --git a/intents/intent_data_sign_712_ext.go b/intents/intent_data_sign_712_ext.go new file mode 100644 index 0000000..f008b03 --- /dev/null +++ b/intents/intent_data_sign_712_ext.go @@ -0,0 +1,81 @@ +package intents + +import ( + "bytes" + "fmt" + "math/big" + + "github.com/0xsequence/ethkit/go-ethereum/common" + "github.com/0xsequence/go-sequence" +) + +func (p *IntentDataSignTypedData) chainID() (*big.Int, error) { + n, ok := sequence.ParseHexOrDec(p.Network) + if !ok { + return nil, fmt.Errorf("invalid network id '%s'", p.Network) + } + return n, nil +} + +func (p *IntentDataSignTypedData) message() ([]byte, error) { + // typedData, ok := p.TypedData.(*ethcoder.TypedData) + // if !ok { + // return nil, fmt.Errorf("typedData field is not a valid typed data object") + // } + + _, encodedMessage, err := p.TypedData.Encode() + if err != nil { + return nil, err + } + + return encodedMessage, nil +} + +func (p *IntentDataSignTypedData) wallet() common.Address { + return common.HexToAddress(p.Wallet) +} + +func (p *IntentDataSignTypedData) subdigest() ([]byte, error) { + chainID, err := p.chainID() + if err != nil { + return nil, err + } + msgData, err := p.message() + if err != nil { + return nil, err + } + return sequence.SubDigest(chainID, p.wallet(), sequence.MessageDigest(msgData)) +} + +func (p *IntentDataSignTypedData) IsValidInterpretation(subdigest common.Hash) bool { + selfSubDigest, err := p.subdigest() + if err != nil { + return false + } + + return bytes.Equal(selfSubDigest, subdigest[:]) +} + +// func (p *IntentDataSignTypedData) UnmarshalJSON(data []byte) error { +// type Raw struct { +// Network string `json:"network"` +// Wallet string `json:"wallet"` +// TypedData json.RawMessage `json:"typedData"` +// } + +// dec := json.NewDecoder(bytes.NewReader(data)) +// var raw Raw +// if err := dec.Decode(&raw); err != nil { +// return err +// } + +// typedData, err := ethcoder.TypedDataFromJSON(string(raw.TypedData)) +// if err != nil { +// return err +// } + +// p.Network = raw.Network +// p.Wallet = raw.Wallet +// p.TypedData = typedData +// return nil +// } diff --git a/intents/intent_data_sign_712_ext_test.go b/intents/intent_data_sign_712_ext_test.go new file mode 100644 index 0000000..3dac871 --- /dev/null +++ b/intents/intent_data_sign_712_ext_test.go @@ -0,0 +1,98 @@ +package intents + +import ( + "encoding/json" + "math/big" + "testing" + "time" + + "github.com/0xsequence/ethkit/ethwallet" + "github.com/0xsequence/ethkit/go-ethereum/common" + "github.com/0xsequence/go-sequence" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestRecoverTypedDataIntent(t *testing.T) { + data := `{ + "version": "1", + "name": "signTypedData", + "issued": 0, + "expires": 0, + "data": { + "wallet": "0xD67FC48b298B09Ed3D03403d930769C527186c4e", + "network": "1", + "typedData": { + "types": { + "EIP712Domain": [ + {"name": "name", "type": "string"}, + {"name": "version", "type": "string"}, + {"name": "chainId", "type": "uint256"}, + {"name": "verifyingContract", "type": "address"} + ], + "Person": [ + {"name": "name", "type": "string"}, + {"name": "wallet", "type": "address"}, + {"name": "count", "type": "uint8"} + ] + }, + "primaryType": "Person", + "domain": { + "name": "Ether Mail", + "version": "1", + "chainId": 1, + "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC" + }, + "message": { + "name": "Bob", + "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB", + "count": 4 + } + } + }, + "signatures": [] + }` + + intent := &Intent{} + err := json.Unmarshal([]byte(data), intent) + require.Nil(t, err) + + require.Equal(t, "1", intent.Version) + require.Equal(t, IntentName_signTypedData, intent.Name) + + hash, err := intent.Hash() + require.Nil(t, err) + require.NotNil(t, common.Bytes2Hex(hash)) + + intent.IssuedAt = uint64(time.Now().Unix()) + intent.ExpiresAt = uint64(time.Now().Unix()) + 60 + + wallet, err := ethwallet.NewWalletFromRandomEntropy() + require.Nil(t, err) + + session := NewSessionP256K1(wallet) + + err = session.Sign(intent) + require.Nil(t, err) + + intentTyped, err := NewIntentTypedFromIntent[IntentDataSignTypedData](intent) + require.NoError(t, err) + + signers := intent.Signers() + require.Equal(t, 1, len(signers)) + require.Equal(t, "0x"+common.Bytes2Hex(append([]byte{0x00}, wallet.Address().Bytes()...)), signers[0]) + + messageDigest, err := intentTyped.Data.TypedData.EncodeDigest() + require.NoError(t, err) + require.NotNil(t, messageDigest) + + subdigest, err := sequence.SubDigest( + big.NewInt(1), + common.HexToAddress("0xD67FC48b298B09Ed3D03403d930769C527186c4e"), + common.BytesToHash(messageDigest), + ) + + assert.Nil(t, err) + assert.True(t, intentTyped.Data.IsValidInterpretation(common.BytesToHash(subdigest))) + +} diff --git a/intents/intent_response_typed.go b/intents/intent_response_typed.go index 7da6a22..a3d519f 100644 --- a/intents/intent_response_typed.go +++ b/intents/intent_response_typed.go @@ -22,6 +22,8 @@ func IntentResponseTypeToCode[T any](t *T) IntentResponseCode { return IntentResponseCode_sessionAuthProof case *IntentResponseSignedMessage: return IntentResponseCode_signedMessage + case *IntentResponseSignedTypedData: + return IntentResponseCode_signedTypedData case *IntentResponseFeeOptions: return IntentResponseCode_feeOptions case *IntentResponseTransactionReceipt: diff --git a/intents/intent_typed.go b/intents/intent_typed.go index 96cbe09..4455b4d 100644 --- a/intents/intent_typed.go +++ b/intents/intent_typed.go @@ -27,6 +27,8 @@ func IntentDataTypeToName[T any](t *T) IntentName { return IntentName_sessionAuthProof case *IntentDataSignMessage: return IntentName_signMessage + case *IntentDataSignTypedData: + return IntentName_signTypedData case *IntentDataFeeOptions: return IntentName_feeOptions case *IntentDataSendTransaction: