From 987252dbcf5e50a7fd73368854dc9841ba2e9daf Mon Sep 17 00:00:00 2001 From: Ethan Reesor Date: Fri, 12 Jul 2024 17:10:13 -0500 Subject: [PATCH] Rename EIP-712 signature type --- internal/core/execute/v2/block/sig_user.go | 4 +- pkg/client/signing/builder.go | 6 +- pkg/types/address/address.go | 4 +- pkg/types/address/from.go | 2 +- pkg/types/encoding/eip712_test.go | 2 +- protocol/enums.yml | 2 +- protocol/enums_gen.go | 14 +- protocol/signature.go | 30 +- protocol/signature_eip712.go | 4 +- protocol/signature_test.go | 6 +- protocol/signatures.yml | 2 +- protocol/types_gen.go | 797 +++++++++++---------- protocol/unions_gen.go | 20 +- test/e2e/sig_eip712_test.go | 6 +- 14 files changed, 450 insertions(+), 449 deletions(-) diff --git a/internal/core/execute/v2/block/sig_user.go b/internal/core/execute/v2/block/sig_user.go index 84055fd27..a96969389 100644 --- a/internal/core/execute/v2/block/sig_user.go +++ b/internal/core/execute/v2/block/sig_user.go @@ -38,7 +38,7 @@ func init() { func(ctx *SignatureContext) bool { return ctx.GetActiveGlobals().ExecutorVersion.V2VandenbergEnabled() }, protocol.SignatureTypeRsaSha256, protocol.SignatureTypeEcdsaSha256, - protocol.SignatureTypeEip712TypedData, + protocol.SignatureTypeTypedData, ) } @@ -184,7 +184,7 @@ func (UserSignature) unwrapDelegated(ctx *userSigContext) error { } func (UserSignature) checkChainID(ctx *userSigContext) error { - sig, ok := ctx.keySig.(*protocol.Eip712TypedDataSignature) + sig, ok := ctx.keySig.(*protocol.TypedDataSignature) if !ok { return nil } diff --git a/pkg/client/signing/builder.go b/pkg/client/signing/builder.go index 0dbd97cf8..bec364669 100644 --- a/pkg/client/signing/builder.go +++ b/pkg/client/signing/builder.go @@ -221,7 +221,7 @@ func (s *Builder) prepare(init bool) (protocol.KeySignature, error) { protocol.SignatureTypeETH, protocol.SignatureTypeRsaSha256, protocol.SignatureTypeEcdsaSha256, - protocol.SignatureTypeEip712TypedData, + protocol.SignatureTypeTypedData, protocol.SignatureTypeBTCLegacy: case protocol.SignatureTypeReceipt, protocol.SignatureTypePartition: @@ -320,8 +320,8 @@ func (s *Builder) prepare(init bool) (protocol.KeySignature, error) { sig.Data = s.Data return sig, s.Signer.SetPublicKey(sig) - case protocol.SignatureTypeEip712TypedData: - sig := new(protocol.Eip712TypedDataSignature) + case protocol.SignatureTypeTypedData: + sig := new(protocol.TypedDataSignature) sig.Signer = s.Url sig.SignerVersion = s.Version sig.Timestamp = timestamp diff --git a/pkg/types/address/address.go b/pkg/types/address/address.go index 9d701de77..b07137c4b 100644 --- a/pkg/types/address/address.go +++ b/pkg/types/address/address.go @@ -117,7 +117,7 @@ func (p *PrivateKey) String() string { case protocol.SignatureTypeRCD1: return FormatFs(p.Key[:32]) - case protocol.SignatureTypeETH, protocol.SignatureTypeEip712TypedData: + case protocol.SignatureTypeETH, protocol.SignatureTypeTypedData: return hex.EncodeToString(p.Key) case protocol.SignatureTypeBTCLegacy, protocol.SignatureTypeBTC: @@ -164,7 +164,7 @@ func formatAddr(typ protocol.SignatureType, hash []byte) string { protocol.SignatureTypeBTCLegacy: return FormatBTC(hash) - case protocol.SignatureTypeETH, protocol.SignatureTypeEip712TypedData: + case protocol.SignatureTypeETH, protocol.SignatureTypeTypedData: return FormatETH(hash) case protocol.SignatureTypeEcdsaSha256: diff --git a/pkg/types/address/from.go b/pkg/types/address/from.go index dde78611d..4d1ca51ba 100644 --- a/pkg/types/address/from.go +++ b/pkg/types/address/from.go @@ -134,7 +134,7 @@ func FromPrivateKeyBytes(priv []byte, typ protocol.SignatureType) (*PrivateKey, case protocol.SignatureTypeETH, protocol.SignatureTypeBTCLegacy, - protocol.SignatureTypeEip712TypedData: + protocol.SignatureTypeTypedData: _, pk := btc.PrivKeyFromBytes(btc.S256(), priv) pub = pk.SerializeUncompressed() diff --git a/pkg/types/encoding/eip712_test.go b/pkg/types/encoding/eip712_test.go index 7984e1636..e0a704bb6 100644 --- a/pkg/types/encoding/eip712_test.go +++ b/pkg/types/encoding/eip712_test.go @@ -46,7 +46,7 @@ func TestEIP712Arrays(t *testing.T) { for _, txn := range cases { t.Run(hex.EncodeToString(txn.GetHash()), func(t *testing.T) { priv := acctesting.NewSECP256K1(t.Name()) - sig := &protocol.Eip712TypedDataSignature{ + sig := &protocol.TypedDataSignature{ ChainID: protocol.EthChainID("Kermit"), PublicKey: eth.FromECDSAPub(&priv.PublicKey), Signer: url.MustParse("acc://adi.acme/book/1"), diff --git a/protocol/enums.yml b/protocol/enums.yml index 98108ba8f..eadac1052 100644 --- a/protocol/enums.yml +++ b/protocol/enums.yml @@ -113,7 +113,7 @@ SignatureType: EcdsaSha256: value: 15 description: represents a signature of SHA256 hashed data from an ecdsa algorithm with supported standard curves from NIST, SECG, and Brainpool typically (SEC, ANS.1 enocding) - Eip712TypedData: + TypedData: value: 16 description: implements EIP-712 sign typed data specification diff --git a/protocol/enums_gen.go b/protocol/enums_gen.go index 910735f17..b5eb0d08c 100644 --- a/protocol/enums_gen.go +++ b/protocol/enums_gen.go @@ -239,8 +239,8 @@ const SignatureTypeRsaSha256 SignatureType = 14 // SignatureTypeEcdsaSha256 represents a signature of SHA256 hashed data from an ecdsa algorithm with supported standard curves from NIST, SECG, and Brainpool typically (SEC, ANS.1 enocding). const SignatureTypeEcdsaSha256 SignatureType = 15 -// SignatureTypeEip712TypedData implements EIP-712 sign typed data specification. -const SignatureTypeEip712TypedData SignatureType = 16 +// SignatureTypeTypedData implements EIP-712 sign typed data specification. +const SignatureTypeTypedData SignatureType = 16 // TransactionMaxUser is the highest number reserved for user transactions. const TransactionMaxUser TransactionMax = 48 @@ -1163,7 +1163,7 @@ func (v SignatureType) GetEnumValue() uint64 { return uint64(v) } func (v *SignatureType) SetEnumValue(id uint64) bool { u := SignatureType(id) switch u { - case SignatureTypeUnknown, SignatureTypeLegacyED25519, SignatureTypeED25519, SignatureTypeRCD1, SignatureTypeReceipt, SignatureTypePartition, SignatureTypeSet, SignatureTypeRemote, SignatureTypeBTC, SignatureTypeBTCLegacy, SignatureTypeETH, SignatureTypeDelegated, SignatureTypeInternal, SignatureTypeAuthority, SignatureTypeRsaSha256, SignatureTypeEcdsaSha256, SignatureTypeEip712TypedData: + case SignatureTypeUnknown, SignatureTypeLegacyED25519, SignatureTypeED25519, SignatureTypeRCD1, SignatureTypeReceipt, SignatureTypePartition, SignatureTypeSet, SignatureTypeRemote, SignatureTypeBTC, SignatureTypeBTCLegacy, SignatureTypeETH, SignatureTypeDelegated, SignatureTypeInternal, SignatureTypeAuthority, SignatureTypeRsaSha256, SignatureTypeEcdsaSha256, SignatureTypeTypedData: *v = u return true } @@ -1205,8 +1205,8 @@ func (v SignatureType) String() string { return "rsaSha256" case SignatureTypeEcdsaSha256: return "ecdsaSha256" - case SignatureTypeEip712TypedData: - return "eip712TypedData" + case SignatureTypeTypedData: + return "typedData" } return fmt.Sprintf("SignatureType:%d", v) } @@ -1248,8 +1248,8 @@ func SignatureTypeByName(name string) (SignatureType, bool) { return SignatureTypeRsaSha256, true case "ecdsasha256": return SignatureTypeEcdsaSha256, true - case "eip712typeddata": - return SignatureTypeEip712TypedData, true + case "typeddata": + return SignatureTypeTypedData, true } return 0, false } diff --git a/protocol/signature.go b/protocol/signature.go index adfad5a6f..6eb9ab345 100644 --- a/protocol/signature.go +++ b/protocol/signature.go @@ -110,7 +110,7 @@ func PublicKeyHash(key []byte, typ SignatureType) ([]byte, error) { return BTCHash(key), nil case SignatureTypeETH, - SignatureTypeEip712TypedData: + SignatureTypeTypedData: return ETHhash(key), nil case SignatureTypeReceipt, @@ -1193,7 +1193,7 @@ func (e *EcdsaSha256Signature) Verify(sig Signature, msg Signable) bool { * EIP-712 Typed Data Signature * privateKey must be ecdsa */ -func SignEip712TypedData(sig *Eip712TypedDataSignature, privateKey []byte, outer Signature, txn *Transaction) error { +func SignEip712TypedData(sig *TypedDataSignature, privateKey []byte, outer Signature, txn *Transaction) error { if outer == nil { outer = sig } @@ -1213,34 +1213,34 @@ func SignEip712TypedData(sig *Eip712TypedDataSignature, privateKey []byte, outer } // GetSigner returns Signer. -func (s *Eip712TypedDataSignature) GetSigner() *url.URL { return s.Signer } +func (s *TypedDataSignature) GetSigner() *url.URL { return s.Signer } // RoutingLocation returns Signer. -func (s *Eip712TypedDataSignature) RoutingLocation() *url.URL { return s.Signer } +func (s *TypedDataSignature) RoutingLocation() *url.URL { return s.Signer } // GetSignerVersion returns SignerVersion. -func (s *Eip712TypedDataSignature) GetSignerVersion() uint64 { return s.SignerVersion } +func (s *TypedDataSignature) GetSignerVersion() uint64 { return s.SignerVersion } // GetTimestamp returns Timestamp. -func (s *Eip712TypedDataSignature) GetTimestamp() uint64 { return s.Timestamp } +func (s *TypedDataSignature) GetTimestamp() uint64 { return s.Timestamp } // GetPublicKeyHash returns the hash of PublicKey. -func (s *Eip712TypedDataSignature) GetPublicKeyHash() []byte { return ETHhash(s.PublicKey) } +func (s *TypedDataSignature) GetPublicKeyHash() []byte { return ETHhash(s.PublicKey) } // GetPublicKey returns PublicKey. -func (s *Eip712TypedDataSignature) GetPublicKey() []byte { return s.PublicKey } +func (s *TypedDataSignature) GetPublicKey() []byte { return s.PublicKey } // GetSignature returns Signature. -func (s *Eip712TypedDataSignature) GetSignature() []byte { return s.Signature } +func (s *TypedDataSignature) GetSignature() []byte { return s.Signature } // GetTransactionHash returns TransactionHash. -func (s *Eip712TypedDataSignature) GetTransactionHash() [32]byte { return s.TransactionHash } +func (s *TypedDataSignature) GetTransactionHash() [32]byte { return s.TransactionHash } // Hash returns the hash of the signature. -func (s *Eip712TypedDataSignature) Hash() []byte { return signatureHash(s) } +func (s *TypedDataSignature) Hash() []byte { return signatureHash(s) } // Metadata returns the signature's metadata. -func (s *Eip712TypedDataSignature) Metadata() Signature { +func (s *TypedDataSignature) Metadata() Signature { r := s.Copy() // Copy the struct r.Signature = nil // Clear the signature r.TransactionHash = [32]byte{} // And the transaction hash @@ -1248,7 +1248,7 @@ func (s *Eip712TypedDataSignature) Metadata() Signature { } // Initiator returns a Hasher that calculates the Merkle hash of the signature. -func (s *Eip712TypedDataSignature) Initiator() (hash.Hasher, error) { +func (s *TypedDataSignature) Initiator() (hash.Hasher, error) { if len(s.PublicKey) == 0 || s.Signer == nil || s.SignerVersion == 0 || s.Timestamp == 0 { return nil, ErrCannotInitiate } @@ -1262,13 +1262,13 @@ func (s *Eip712TypedDataSignature) Initiator() (hash.Hasher, error) { } // GetVote returns how the signer votes on a particular transaction -func (s *Eip712TypedDataSignature) GetVote() VoteType { +func (s *TypedDataSignature) GetVote() VoteType { return s.Vote } // Verify returns true if this signature is a valid EIP-712 signature following // the spec. -func (e *Eip712TypedDataSignature) Verify(sig Signature, msg Signable) bool { +func (e *TypedDataSignature) Verify(sig Signature, msg Signable) bool { txn, ok := msg.(*Transaction) if !ok { // EIP-712 cannot be used to sign something that isn't a transaction diff --git a/protocol/signature_eip712.go b/protocol/signature_eip712.go index eb8873d84..df1eace7a 100644 --- a/protocol/signature_eip712.go +++ b/protocol/signature_eip712.go @@ -103,13 +103,13 @@ func EIP712Hash(txn *Transaction, sig Signature) ([]byte, error) { // newEIP712Call converts the transaction and signature to an EIP-712 message. func newEIP712Call(txn *Transaction, sig Signature) (*encoding.EIP712Call, error) { var delegators []any - var inner *Eip712TypedDataSignature + var inner *TypedDataSignature for inner == nil { switch s := sig.(type) { case *DelegatedSignature: delegators = append(delegators, s.Delegator.String()) sig = s.Signature - case *Eip712TypedDataSignature: + case *TypedDataSignature: inner = s default: return nil, fmt.Errorf("unsupported signature type %v", s.Type()) diff --git a/protocol/signature_test.go b/protocol/signature_test.go index 909e132b6..253b49750 100644 --- a/protocol/signature_test.go +++ b/protocol/signature_test.go @@ -503,7 +503,7 @@ func TestEip712TypedDataSignature(t *testing.T) { require.NoError(t, err) priv := acctesting.NewSECP256K1(t.Name()) - eip712sig := &Eip712TypedDataSignature{ + eip712sig := &TypedDataSignature{ ChainID: protocol.EthChainID("MainNet"), PublicKey: eth.FromECDSAPub(&priv.PublicKey), Signer: url.MustParse("acc://adi.acme/book/1"), @@ -530,7 +530,7 @@ func TestEIP712DelegatedKeyPageUpdate(t *testing.T) { require.NoError(t, err) priv := acctesting.NewSECP256K1(t.Name()) - inner := &Eip712TypedDataSignature{ + inner := &TypedDataSignature{ ChainID: protocol.EthChainID("MainNet"), PublicKey: eth.FromECDSAPub(&priv.PublicKey), Signer: url.MustParse("acc://adi.acme/book/1"), @@ -570,7 +570,7 @@ func TestEIP712MessageForWallet(t *testing.T) { require.NoError(t, err) priv := acctesting.NewSECP256K1(t.Name()) - sig := &Eip712TypedDataSignature{ + sig := &TypedDataSignature{ ChainID: protocol.EthChainID("MainNet"), PublicKey: eth.FromECDSAPub(&priv.PublicKey), Signer: url.MustParse("acc://adi.acme/book/1"), diff --git a/protocol/signatures.yml b/protocol/signatures.yml index 4c9b3a883..15e9a72be 100644 --- a/protocol/signatures.yml +++ b/protocol/signatures.yml @@ -226,7 +226,7 @@ EcdsaSha256Signature: type: bytes optional: true -Eip712TypedDataSignature: +TypedDataSignature: description: is an EIP-712 compliant typed data signature for an Accumulate transaction union: { type: signature } fields: diff --git a/protocol/types_gen.go b/protocol/types_gen.go index 0c72c46e8..a6dfecf80 100644 --- a/protocol/types_gen.go +++ b/protocol/types_gen.go @@ -386,21 +386,6 @@ type EcdsaSha256Signature struct { extraData []byte } -type Eip712TypedDataSignature struct { - fieldsSet []bool - PublicKey []byte `json:"publicKey,omitempty" form:"publicKey" query:"publicKey" validate:"required"` - ChainID *big.Int `json:"chainID,omitempty" form:"chainID" query:"chainID" validate:"required"` - Signature []byte `json:"signature,omitempty" form:"signature" query:"signature" validate:"required"` - Signer *url.URL `json:"signer,omitempty" form:"signer" query:"signer" validate:"required"` - SignerVersion uint64 `json:"signerVersion,omitempty" form:"signerVersion" query:"signerVersion" validate:"required"` - Timestamp uint64 `json:"timestamp,omitempty" form:"timestamp" query:"timestamp"` - Vote VoteType `json:"vote,omitempty" form:"vote" query:"vote"` - TransactionHash [32]byte `json:"transactionHash,omitempty" form:"transactionHash" query:"transactionHash"` - Memo string `json:"memo,omitempty" form:"memo" query:"memo"` - Data []byte `json:"data,omitempty" form:"data" query:"data"` - extraData []byte -} - type EmptyResult struct { fieldsSet []bool extraData []byte @@ -1052,6 +1037,22 @@ type TxIdSet struct { extraData []byte } +// TypedDataSignature is an EIP-712 compliant typed data signature for an Accumulate transaction. +type TypedDataSignature struct { + fieldsSet []bool + PublicKey []byte `json:"publicKey,omitempty" form:"publicKey" query:"publicKey" validate:"required"` + Signature []byte `json:"signature,omitempty" form:"signature" query:"signature" validate:"required"` + Signer *url.URL `json:"signer,omitempty" form:"signer" query:"signer" validate:"required"` + SignerVersion uint64 `json:"signerVersion,omitempty" form:"signerVersion" query:"signerVersion" validate:"required"` + Timestamp uint64 `json:"timestamp,omitempty" form:"timestamp" query:"timestamp"` + Vote VoteType `json:"vote,omitempty" form:"vote" query:"vote"` + TransactionHash [32]byte `json:"transactionHash,omitempty" form:"transactionHash" query:"transactionHash"` + Memo string `json:"memo,omitempty" form:"memo" query:"memo"` + Data []byte `json:"data,omitempty" form:"data" query:"data"` + ChainID *big.Int `json:"chainID,omitempty" form:"chainID" query:"chainID" validate:"required"` + extraData []byte +} + type UnknownAccount struct { fieldsSet []bool Url *url.URL `json:"url,omitempty" form:"url" query:"url" validate:"required"` @@ -1203,8 +1204,6 @@ func (*ETHSignature) Type() SignatureType { return SignatureTypeETH } func (*EcdsaSha256Signature) Type() SignatureType { return SignatureTypeEcdsaSha256 } -func (*Eip712TypedDataSignature) Type() SignatureType { return SignatureTypeEip712TypedData } - func (*EmptyResult) Type() TransactionType { return TransactionTypeUnknown } func (*EnableAccountAuthOperation) Type() AccountAuthOperationType { @@ -1299,6 +1298,8 @@ func (*TokenIssuer) Type() AccountType { return AccountTypeTokenIssuer } func (*TransferCredits) Type() TransactionType { return TransactionTypeTransferCredits } +func (*TypedDataSignature) Type() SignatureType { return SignatureTypeTypedData } + func (*UnknownAccount) Type() AccountType { return AccountTypeUnknown } func (*UnknownSigner) Type() AccountType { return AccountTypeUnknownSigner } @@ -2127,33 +2128,6 @@ func (v *EcdsaSha256Signature) Copy() *EcdsaSha256Signature { func (v *EcdsaSha256Signature) CopyAsInterface() interface{} { return v.Copy() } -func (v *Eip712TypedDataSignature) Copy() *Eip712TypedDataSignature { - u := new(Eip712TypedDataSignature) - - u.PublicKey = encoding.BytesCopy(v.PublicKey) - if v.ChainID != nil { - u.ChainID = encoding.BigintCopy(v.ChainID) - } - u.Signature = encoding.BytesCopy(v.Signature) - if v.Signer != nil { - u.Signer = v.Signer - } - u.SignerVersion = v.SignerVersion - u.Timestamp = v.Timestamp - u.Vote = v.Vote - u.TransactionHash = v.TransactionHash - u.Memo = v.Memo - u.Data = encoding.BytesCopy(v.Data) - if len(v.extraData) > 0 { - u.extraData = make([]byte, len(v.extraData)) - copy(u.extraData, v.extraData) - } - - return u -} - -func (v *Eip712TypedDataSignature) CopyAsInterface() interface{} { return v.Copy() } - func (v *EmptyResult) Copy() *EmptyResult { u := new(EmptyResult) @@ -3541,6 +3515,33 @@ func (v *TxIdSet) Copy() *TxIdSet { func (v *TxIdSet) CopyAsInterface() interface{} { return v.Copy() } +func (v *TypedDataSignature) Copy() *TypedDataSignature { + u := new(TypedDataSignature) + + u.PublicKey = encoding.BytesCopy(v.PublicKey) + u.Signature = encoding.BytesCopy(v.Signature) + if v.Signer != nil { + u.Signer = v.Signer + } + u.SignerVersion = v.SignerVersion + u.Timestamp = v.Timestamp + u.Vote = v.Vote + u.TransactionHash = v.TransactionHash + u.Memo = v.Memo + u.Data = encoding.BytesCopy(v.Data) + if v.ChainID != nil { + u.ChainID = encoding.BigintCopy(v.ChainID) + } + if len(v.extraData) > 0 { + u.extraData = make([]byte, len(v.extraData)) + copy(u.extraData, v.extraData) + } + + return u +} + +func (v *TypedDataSignature) CopyAsInterface() interface{} { return v.Copy() } + func (v *UnknownAccount) Copy() *UnknownAccount { u := new(UnknownAccount) @@ -4602,51 +4603,6 @@ func (v *EcdsaSha256Signature) Equal(u *EcdsaSha256Signature) bool { return true } -func (v *Eip712TypedDataSignature) Equal(u *Eip712TypedDataSignature) bool { - if !(bytes.Equal(v.PublicKey, u.PublicKey)) { - return false - } - switch { - case v.ChainID == u.ChainID: - // equal - case v.ChainID == nil || u.ChainID == nil: - return false - case !((v.ChainID).Cmp(u.ChainID) == 0): - return false - } - if !(bytes.Equal(v.Signature, u.Signature)) { - return false - } - switch { - case v.Signer == u.Signer: - // equal - case v.Signer == nil || u.Signer == nil: - return false - case !((v.Signer).Equal(u.Signer)): - return false - } - if !(v.SignerVersion == u.SignerVersion) { - return false - } - if !(v.Timestamp == u.Timestamp) { - return false - } - if !(v.Vote == u.Vote) { - return false - } - if !(v.TransactionHash == u.TransactionHash) { - return false - } - if !(v.Memo == u.Memo) { - return false - } - if !(bytes.Equal(v.Data, u.Data)) { - return false - } - - return true -} - func (v *EmptyResult) Equal(u *EmptyResult) bool { return true @@ -6063,6 +6019,51 @@ func (v *TxIdSet) Equal(u *TxIdSet) bool { return true } +func (v *TypedDataSignature) Equal(u *TypedDataSignature) bool { + if !(bytes.Equal(v.PublicKey, u.PublicKey)) { + return false + } + if !(bytes.Equal(v.Signature, u.Signature)) { + return false + } + switch { + case v.Signer == u.Signer: + // equal + case v.Signer == nil || u.Signer == nil: + return false + case !((v.Signer).Equal(u.Signer)): + return false + } + if !(v.SignerVersion == u.SignerVersion) { + return false + } + if !(v.Timestamp == u.Timestamp) { + return false + } + if !(v.Vote == u.Vote) { + return false + } + if !(v.TransactionHash == u.TransactionHash) { + return false + } + if !(v.Memo == u.Memo) { + return false + } + if !(bytes.Equal(v.Data, u.Data)) { + return false + } + switch { + case v.ChainID == u.ChainID: + // equal + case v.ChainID == nil || u.ChainID == nil: + return false + case !((v.ChainID).Cmp(u.ChainID) == 0): + return false + } + + return true +} + func (v *UnknownAccount) Equal(u *UnknownAccount) bool { switch { case v.Url == u.Url: @@ -8759,110 +8760,6 @@ func (v *EcdsaSha256Signature) IsValid() error { } } -var fieldNames_Eip712TypedDataSignature = []string{ - 1: "Type", - 2: "PublicKey", - 3: "ChainID", - 4: "Signature", - 5: "Signer", - 6: "SignerVersion", - 7: "Timestamp", - 8: "Vote", - 9: "TransactionHash", - 10: "Memo", - 11: "Data", -} - -func (v *Eip712TypedDataSignature) MarshalBinary() ([]byte, error) { - if v == nil { - return []byte{encoding.EmptyObject}, nil - } - - buffer := new(bytes.Buffer) - writer := encoding.NewWriter(buffer) - - writer.WriteEnum(1, v.Type()) - if !(len(v.PublicKey) == 0) { - writer.WriteBytes(2, v.PublicKey) - } - if !(v.ChainID == nil) { - writer.WriteBigInt(3, v.ChainID) - } - if !(len(v.Signature) == 0) { - writer.WriteBytes(4, v.Signature) - } - if !(v.Signer == nil) { - writer.WriteUrl(5, v.Signer) - } - if !(v.SignerVersion == 0) { - writer.WriteUint(6, v.SignerVersion) - } - if !(v.Timestamp == 0) { - writer.WriteUint(7, v.Timestamp) - } - if !(v.Vote == 0) { - writer.WriteEnum(8, v.Vote) - } - if !(v.TransactionHash == ([32]byte{})) { - writer.WriteHash(9, &v.TransactionHash) - } - if !(len(v.Memo) == 0) { - writer.WriteString(10, v.Memo) - } - if !(len(v.Data) == 0) { - writer.WriteBytes(11, v.Data) - } - - _, _, err := writer.Reset(fieldNames_Eip712TypedDataSignature) - if err != nil { - return nil, encoding.Error{E: err} - } - buffer.Write(v.extraData) - return buffer.Bytes(), nil -} - -func (v *Eip712TypedDataSignature) IsValid() error { - var errs []string - - if len(v.fieldsSet) > 0 && !v.fieldsSet[0] { - errs = append(errs, "field Type is missing") - } - if len(v.fieldsSet) > 1 && !v.fieldsSet[1] { - errs = append(errs, "field PublicKey is missing") - } else if len(v.PublicKey) == 0 { - errs = append(errs, "field PublicKey is not set") - } - if len(v.fieldsSet) > 2 && !v.fieldsSet[2] { - errs = append(errs, "field ChainID is missing") - } else if v.ChainID == nil { - errs = append(errs, "field ChainID is not set") - } - if len(v.fieldsSet) > 3 && !v.fieldsSet[3] { - errs = append(errs, "field Signature is missing") - } else if len(v.Signature) == 0 { - errs = append(errs, "field Signature is not set") - } - if len(v.fieldsSet) > 4 && !v.fieldsSet[4] { - errs = append(errs, "field Signer is missing") - } else if v.Signer == nil { - errs = append(errs, "field Signer is not set") - } - if len(v.fieldsSet) > 5 && !v.fieldsSet[5] { - errs = append(errs, "field SignerVersion is missing") - } else if v.SignerVersion == 0 { - errs = append(errs, "field SignerVersion is not set") - } - - switch len(errs) { - case 0: - return nil - case 1: - return errors.New(errs[0]) - default: - return errors.New(strings.Join(errs, "; ")) - } -} - var fieldNames_EmptyResult = []string{ 1: "Type", } @@ -13230,13 +13127,117 @@ func (v *TxIdSet) IsValid() error { } } -var fieldNames_UnknownAccount = []string{ - 1: "Type", - 2: "Url", -} - -func (v *UnknownAccount) MarshalBinary() ([]byte, error) { - if v == nil { +var fieldNames_TypedDataSignature = []string{ + 1: "Type", + 2: "PublicKey", + 3: "Signature", + 4: "Signer", + 5: "SignerVersion", + 6: "Timestamp", + 7: "Vote", + 8: "TransactionHash", + 9: "Memo", + 10: "Data", + 11: "ChainID", +} + +func (v *TypedDataSignature) MarshalBinary() ([]byte, error) { + if v == nil { + return []byte{encoding.EmptyObject}, nil + } + + buffer := new(bytes.Buffer) + writer := encoding.NewWriter(buffer) + + writer.WriteEnum(1, v.Type()) + if !(len(v.PublicKey) == 0) { + writer.WriteBytes(2, v.PublicKey) + } + if !(len(v.Signature) == 0) { + writer.WriteBytes(3, v.Signature) + } + if !(v.Signer == nil) { + writer.WriteUrl(4, v.Signer) + } + if !(v.SignerVersion == 0) { + writer.WriteUint(5, v.SignerVersion) + } + if !(v.Timestamp == 0) { + writer.WriteUint(6, v.Timestamp) + } + if !(v.Vote == 0) { + writer.WriteEnum(7, v.Vote) + } + if !(v.TransactionHash == ([32]byte{})) { + writer.WriteHash(8, &v.TransactionHash) + } + if !(len(v.Memo) == 0) { + writer.WriteString(9, v.Memo) + } + if !(len(v.Data) == 0) { + writer.WriteBytes(10, v.Data) + } + if !(v.ChainID == nil) { + writer.WriteBigInt(11, v.ChainID) + } + + _, _, err := writer.Reset(fieldNames_TypedDataSignature) + if err != nil { + return nil, encoding.Error{E: err} + } + buffer.Write(v.extraData) + return buffer.Bytes(), nil +} + +func (v *TypedDataSignature) IsValid() error { + var errs []string + + if len(v.fieldsSet) > 0 && !v.fieldsSet[0] { + errs = append(errs, "field Type is missing") + } + if len(v.fieldsSet) > 1 && !v.fieldsSet[1] { + errs = append(errs, "field PublicKey is missing") + } else if len(v.PublicKey) == 0 { + errs = append(errs, "field PublicKey is not set") + } + if len(v.fieldsSet) > 2 && !v.fieldsSet[2] { + errs = append(errs, "field Signature is missing") + } else if len(v.Signature) == 0 { + errs = append(errs, "field Signature is not set") + } + if len(v.fieldsSet) > 3 && !v.fieldsSet[3] { + errs = append(errs, "field Signer is missing") + } else if v.Signer == nil { + errs = append(errs, "field Signer is not set") + } + if len(v.fieldsSet) > 4 && !v.fieldsSet[4] { + errs = append(errs, "field SignerVersion is missing") + } else if v.SignerVersion == 0 { + errs = append(errs, "field SignerVersion is not set") + } + if len(v.fieldsSet) > 10 && !v.fieldsSet[10] { + errs = append(errs, "field ChainID is missing") + } else if v.ChainID == nil { + errs = append(errs, "field ChainID is not set") + } + + switch len(errs) { + case 0: + return nil + case 1: + return errors.New(errs[0]) + default: + return errors.New(strings.Join(errs, "; ")) + } +} + +var fieldNames_UnknownAccount = []string{ + 1: "Type", + 2: "Url", +} + +func (v *UnknownAccount) MarshalBinary() ([]byte, error) { + if v == nil { return []byte{encoding.EmptyObject}, nil } @@ -15516,68 +15517,6 @@ func (v *EcdsaSha256Signature) UnmarshalFieldsFrom(reader *encoding.Reader) erro return nil } -func (v *Eip712TypedDataSignature) UnmarshalBinary(data []byte) error { - return v.UnmarshalBinaryFrom(bytes.NewReader(data)) -} - -func (v *Eip712TypedDataSignature) UnmarshalBinaryFrom(rd io.Reader) error { - reader := encoding.NewReader(rd) - - var vType SignatureType - if x := new(SignatureType); reader.ReadEnum(1, x) { - vType = *x - } - if !(v.Type() == vType) { - return fmt.Errorf("field Type: not equal: want %v, got %v", v.Type(), vType) - } - - return v.UnmarshalFieldsFrom(reader) -} - -func (v *Eip712TypedDataSignature) UnmarshalFieldsFrom(reader *encoding.Reader) error { - if x, ok := reader.ReadBytes(2); ok { - v.PublicKey = x - } - if x, ok := reader.ReadBigInt(3); ok { - v.ChainID = x - } - if x, ok := reader.ReadBytes(4); ok { - v.Signature = x - } - if x, ok := reader.ReadUrl(5); ok { - v.Signer = x - } - if x, ok := reader.ReadUint(6); ok { - v.SignerVersion = x - } - if x, ok := reader.ReadUint(7); ok { - v.Timestamp = x - } - if x := new(VoteType); reader.ReadEnum(8, x) { - v.Vote = *x - } - if x, ok := reader.ReadHash(9); ok { - v.TransactionHash = *x - } - if x, ok := reader.ReadString(10); ok { - v.Memo = x - } - if x, ok := reader.ReadBytes(11); ok { - v.Data = x - } - - seen, err := reader.Reset(fieldNames_Eip712TypedDataSignature) - if err != nil { - return encoding.Error{E: err} - } - v.fieldsSet = seen - v.extraData, err = reader.ReadAll() - if err != nil { - return encoding.Error{E: err} - } - return nil -} - func (v *EmptyResult) UnmarshalBinary(data []byte) error { return v.UnmarshalBinaryFrom(bytes.NewReader(data)) } @@ -18221,6 +18160,68 @@ func (v *TxIdSet) UnmarshalBinaryFrom(rd io.Reader) error { return nil } +func (v *TypedDataSignature) UnmarshalBinary(data []byte) error { + return v.UnmarshalBinaryFrom(bytes.NewReader(data)) +} + +func (v *TypedDataSignature) UnmarshalBinaryFrom(rd io.Reader) error { + reader := encoding.NewReader(rd) + + var vType SignatureType + if x := new(SignatureType); reader.ReadEnum(1, x) { + vType = *x + } + if !(v.Type() == vType) { + return fmt.Errorf("field Type: not equal: want %v, got %v", v.Type(), vType) + } + + return v.UnmarshalFieldsFrom(reader) +} + +func (v *TypedDataSignature) UnmarshalFieldsFrom(reader *encoding.Reader) error { + if x, ok := reader.ReadBytes(2); ok { + v.PublicKey = x + } + if x, ok := reader.ReadBytes(3); ok { + v.Signature = x + } + if x, ok := reader.ReadUrl(4); ok { + v.Signer = x + } + if x, ok := reader.ReadUint(5); ok { + v.SignerVersion = x + } + if x, ok := reader.ReadUint(6); ok { + v.Timestamp = x + } + if x := new(VoteType); reader.ReadEnum(7, x) { + v.Vote = *x + } + if x, ok := reader.ReadHash(8); ok { + v.TransactionHash = *x + } + if x, ok := reader.ReadString(9); ok { + v.Memo = x + } + if x, ok := reader.ReadBytes(10); ok { + v.Data = x + } + if x, ok := reader.ReadBigInt(11); ok { + v.ChainID = x + } + + seen, err := reader.Reset(fieldNames_TypedDataSignature) + if err != nil { + return encoding.Error{E: err} + } + v.fieldsSet = seen + v.extraData, err = reader.ReadAll() + if err != nil { + return encoding.Error{E: err} + } + return nil +} + func (v *UnknownAccount) UnmarshalBinary(data []byte) error { return v.UnmarshalBinaryFrom(bytes.NewReader(data)) } @@ -18987,20 +18988,6 @@ func init() { encoding.NewTypeField("data", "bytes"), }, "EcdsaSha256Signature", "ecdsaSha256Signature") - encoding.RegisterTypeDefinition(&[]*encoding.TypeField{ - encoding.NewTypeField("type", "string"), - encoding.NewTypeField("publicKey", "bytes"), - encoding.NewTypeField("chainID", "uint256"), - encoding.NewTypeField("signature", "bytes"), - encoding.NewTypeField("signer", "string"), - encoding.NewTypeField("signerVersion", "uint64"), - encoding.NewTypeField("timestamp", "uint64"), - encoding.NewTypeField("vote", "string"), - encoding.NewTypeField("transactionHash", "bytes32"), - encoding.NewTypeField("memo", "string"), - encoding.NewTypeField("data", "bytes"), - }, "Eip712TypedDataSignature", "eip712TypedDataSignature") - encoding.RegisterTypeDefinition(&[]*encoding.TypeField{ encoding.NewTypeField("type", "string"), }, "EmptyResult", "emptyResult") @@ -19509,6 +19496,20 @@ func init() { encoding.NewTypeField("entries", "string[]"), }, "TxIdSet", "txIdSet") + encoding.RegisterTypeDefinition(&[]*encoding.TypeField{ + encoding.NewTypeField("type", "string"), + encoding.NewTypeField("publicKey", "bytes"), + encoding.NewTypeField("signature", "bytes"), + encoding.NewTypeField("signer", "string"), + encoding.NewTypeField("signerVersion", "uint64"), + encoding.NewTypeField("timestamp", "uint64"), + encoding.NewTypeField("vote", "string"), + encoding.NewTypeField("transactionHash", "bytes32"), + encoding.NewTypeField("memo", "string"), + encoding.NewTypeField("data", "bytes"), + encoding.NewTypeField("chainID", "uint256"), + }, "TypedDataSignature", "typedDataSignature") + encoding.RegisterTypeDefinition(&[]*encoding.TypeField{ encoding.NewTypeField("type", "string"), encoding.NewTypeField("url", "string"), @@ -20445,56 +20446,6 @@ func (v *EcdsaSha256Signature) MarshalJSON() ([]byte, error) { return json.Marshal(&u) } -func (v *Eip712TypedDataSignature) MarshalJSON() ([]byte, error) { - u := struct { - Type SignatureType `json:"type"` - PublicKey *string `json:"publicKey,omitempty"` - ChainID *string `json:"chainID,omitempty"` - Signature *string `json:"signature,omitempty"` - Signer *url.URL `json:"signer,omitempty"` - SignerVersion uint64 `json:"signerVersion,omitempty"` - Timestamp uint64 `json:"timestamp,omitempty"` - Vote VoteType `json:"vote,omitempty"` - TransactionHash *string `json:"transactionHash,omitempty"` - Memo string `json:"memo,omitempty"` - Data *string `json:"data,omitempty"` - ExtraData *string `json:"$epilogue,omitempty"` - }{} - u.Type = v.Type() - if !(len(v.PublicKey) == 0) { - u.PublicKey = encoding.BytesToJSON(v.PublicKey) - } - if !(v.ChainID == nil) { - u.ChainID = encoding.BigintToJSON(v.ChainID) - } - if !(len(v.Signature) == 0) { - u.Signature = encoding.BytesToJSON(v.Signature) - } - if !(v.Signer == nil) { - u.Signer = v.Signer - } - if !(v.SignerVersion == 0) { - u.SignerVersion = v.SignerVersion - } - if !(v.Timestamp == 0) { - u.Timestamp = v.Timestamp - } - if !(v.Vote == 0) { - u.Vote = v.Vote - } - if !(v.TransactionHash == ([32]byte{})) { - u.TransactionHash = encoding.ChainToJSON(&v.TransactionHash) - } - if !(len(v.Memo) == 0) { - u.Memo = v.Memo - } - if !(len(v.Data) == 0) { - u.Data = encoding.BytesToJSON(v.Data) - } - u.ExtraData = encoding.BytesToJSON(v.extraData) - return json.Marshal(&u) -} - func (v *EmptyResult) MarshalJSON() ([]byte, error) { u := struct { Type TransactionType `json:"type"` @@ -21899,6 +21850,56 @@ func (v *TxIdSet) MarshalJSON() ([]byte, error) { return json.Marshal(&u) } +func (v *TypedDataSignature) MarshalJSON() ([]byte, error) { + u := struct { + Type SignatureType `json:"type"` + PublicKey *string `json:"publicKey,omitempty"` + Signature *string `json:"signature,omitempty"` + Signer *url.URL `json:"signer,omitempty"` + SignerVersion uint64 `json:"signerVersion,omitempty"` + Timestamp uint64 `json:"timestamp,omitempty"` + Vote VoteType `json:"vote,omitempty"` + TransactionHash *string `json:"transactionHash,omitempty"` + Memo string `json:"memo,omitempty"` + Data *string `json:"data,omitempty"` + ChainID *string `json:"chainID,omitempty"` + ExtraData *string `json:"$epilogue,omitempty"` + }{} + u.Type = v.Type() + if !(len(v.PublicKey) == 0) { + u.PublicKey = encoding.BytesToJSON(v.PublicKey) + } + if !(len(v.Signature) == 0) { + u.Signature = encoding.BytesToJSON(v.Signature) + } + if !(v.Signer == nil) { + u.Signer = v.Signer + } + if !(v.SignerVersion == 0) { + u.SignerVersion = v.SignerVersion + } + if !(v.Timestamp == 0) { + u.Timestamp = v.Timestamp + } + if !(v.Vote == 0) { + u.Vote = v.Vote + } + if !(v.TransactionHash == ([32]byte{})) { + u.TransactionHash = encoding.ChainToJSON(&v.TransactionHash) + } + if !(len(v.Memo) == 0) { + u.Memo = v.Memo + } + if !(len(v.Data) == 0) { + u.Data = encoding.BytesToJSON(v.Data) + } + if !(v.ChainID == nil) { + u.ChainID = encoding.BigintToJSON(v.ChainID) + } + u.ExtraData = encoding.BytesToJSON(v.extraData) + return json.Marshal(&u) +} + func (v *UnknownAccount) MarshalJSON() ([]byte, error) { u := struct { Type AccountType `json:"type"` @@ -23313,78 +23314,6 @@ func (v *EcdsaSha256Signature) UnmarshalJSON(data []byte) error { return nil } -func (v *Eip712TypedDataSignature) UnmarshalJSON(data []byte) error { - u := struct { - Type SignatureType `json:"type"` - PublicKey *string `json:"publicKey,omitempty"` - ChainID *string `json:"chainID,omitempty"` - Signature *string `json:"signature,omitempty"` - Signer *url.URL `json:"signer,omitempty"` - SignerVersion uint64 `json:"signerVersion,omitempty"` - Timestamp uint64 `json:"timestamp,omitempty"` - Vote VoteType `json:"vote,omitempty"` - TransactionHash *string `json:"transactionHash,omitempty"` - Memo string `json:"memo,omitempty"` - Data *string `json:"data,omitempty"` - ExtraData *string `json:"$epilogue,omitempty"` - }{} - u.Type = v.Type() - u.PublicKey = encoding.BytesToJSON(v.PublicKey) - u.ChainID = encoding.BigintToJSON(v.ChainID) - u.Signature = encoding.BytesToJSON(v.Signature) - u.Signer = v.Signer - u.SignerVersion = v.SignerVersion - u.Timestamp = v.Timestamp - u.Vote = v.Vote - u.TransactionHash = encoding.ChainToJSON(&v.TransactionHash) - u.Memo = v.Memo - u.Data = encoding.BytesToJSON(v.Data) - err := json.Unmarshal(data, &u) - if err != nil { - return err - } - if !(v.Type() == u.Type) { - return fmt.Errorf("field Type: not equal: want %v, got %v", v.Type(), u.Type) - } - if x, err := encoding.BytesFromJSON(u.PublicKey); err != nil { - return fmt.Errorf("error decoding PublicKey: %w", err) - } else { - v.PublicKey = x - } - if u.ChainID != nil { - if x, err := encoding.BigintFromJSON(u.ChainID); err != nil { - return fmt.Errorf("error decoding ChainID: %w", err) - } else { - v.ChainID = x - } - } - if x, err := encoding.BytesFromJSON(u.Signature); err != nil { - return fmt.Errorf("error decoding Signature: %w", err) - } else { - v.Signature = x - } - v.Signer = u.Signer - v.SignerVersion = u.SignerVersion - v.Timestamp = u.Timestamp - v.Vote = u.Vote - if x, err := encoding.ChainFromJSON(u.TransactionHash); err != nil { - return fmt.Errorf("error decoding TransactionHash: %w", err) - } else { - v.TransactionHash = *x - } - v.Memo = u.Memo - if x, err := encoding.BytesFromJSON(u.Data); err != nil { - return fmt.Errorf("error decoding Data: %w", err) - } else { - v.Data = x - } - v.extraData, err = encoding.BytesFromJSON(u.ExtraData) - if err != nil { - return err - } - return nil -} - func (v *EmptyResult) UnmarshalJSON(data []byte) error { u := struct { Type TransactionType `json:"type"` @@ -25332,6 +25261,78 @@ func (v *TxIdSet) UnmarshalJSON(data []byte) error { return nil } +func (v *TypedDataSignature) UnmarshalJSON(data []byte) error { + u := struct { + Type SignatureType `json:"type"` + PublicKey *string `json:"publicKey,omitempty"` + Signature *string `json:"signature,omitempty"` + Signer *url.URL `json:"signer,omitempty"` + SignerVersion uint64 `json:"signerVersion,omitempty"` + Timestamp uint64 `json:"timestamp,omitempty"` + Vote VoteType `json:"vote,omitempty"` + TransactionHash *string `json:"transactionHash,omitempty"` + Memo string `json:"memo,omitempty"` + Data *string `json:"data,omitempty"` + ChainID *string `json:"chainID,omitempty"` + ExtraData *string `json:"$epilogue,omitempty"` + }{} + u.Type = v.Type() + u.PublicKey = encoding.BytesToJSON(v.PublicKey) + u.Signature = encoding.BytesToJSON(v.Signature) + u.Signer = v.Signer + u.SignerVersion = v.SignerVersion + u.Timestamp = v.Timestamp + u.Vote = v.Vote + u.TransactionHash = encoding.ChainToJSON(&v.TransactionHash) + u.Memo = v.Memo + u.Data = encoding.BytesToJSON(v.Data) + u.ChainID = encoding.BigintToJSON(v.ChainID) + err := json.Unmarshal(data, &u) + if err != nil { + return err + } + if !(v.Type() == u.Type) { + return fmt.Errorf("field Type: not equal: want %v, got %v", v.Type(), u.Type) + } + if x, err := encoding.BytesFromJSON(u.PublicKey); err != nil { + return fmt.Errorf("error decoding PublicKey: %w", err) + } else { + v.PublicKey = x + } + if x, err := encoding.BytesFromJSON(u.Signature); err != nil { + return fmt.Errorf("error decoding Signature: %w", err) + } else { + v.Signature = x + } + v.Signer = u.Signer + v.SignerVersion = u.SignerVersion + v.Timestamp = u.Timestamp + v.Vote = u.Vote + if x, err := encoding.ChainFromJSON(u.TransactionHash); err != nil { + return fmt.Errorf("error decoding TransactionHash: %w", err) + } else { + v.TransactionHash = *x + } + v.Memo = u.Memo + if x, err := encoding.BytesFromJSON(u.Data); err != nil { + return fmt.Errorf("error decoding Data: %w", err) + } else { + v.Data = x + } + if u.ChainID != nil { + if x, err := encoding.BigintFromJSON(u.ChainID); err != nil { + return fmt.Errorf("error decoding ChainID: %w", err) + } else { + v.ChainID = x + } + } + v.extraData, err = encoding.BytesFromJSON(u.ExtraData) + if err != nil { + return err + } + return nil +} + func (v *UnknownAccount) UnmarshalJSON(data []byte) error { u := struct { Type AccountType `json:"type"` diff --git a/protocol/unions_gen.go b/protocol/unions_gen.go index 20fef5232..a3841eb43 100644 --- a/protocol/unions_gen.go +++ b/protocol/unions_gen.go @@ -1069,8 +1069,6 @@ func NewSignature(typ SignatureType) (Signature, error) { return new(ETHSignature), nil case SignatureTypeEcdsaSha256: return new(EcdsaSha256Signature), nil - case SignatureTypeEip712TypedData: - return new(Eip712TypedDataSignature), nil case SignatureTypeInternal: return new(InternalSignature), nil case SignatureTypeLegacyED25519: @@ -1087,6 +1085,8 @@ func NewSignature(typ SignatureType) (Signature, error) { return new(RsaSha256Signature), nil case SignatureTypeSet: return new(SignatureSet), nil + case SignatureTypeTypedData: + return new(TypedDataSignature), nil } return nil, fmt.Errorf("unknown signature %v", typ) } @@ -1139,12 +1139,6 @@ func EqualSignature(a, b Signature) bool { } b, ok := b.(*EcdsaSha256Signature) return ok && a.Equal(b) - case *Eip712TypedDataSignature: - if a == nil { - return b == nil - } - b, ok := b.(*Eip712TypedDataSignature) - return ok && a.Equal(b) case *InternalSignature: if a == nil { return b == nil @@ -1193,6 +1187,12 @@ func EqualSignature(a, b Signature) bool { } b, ok := b.(*SignatureSet) return ok && a.Equal(b) + case *TypedDataSignature: + if a == nil { + return b == nil + } + b, ok := b.(*TypedDataSignature) + return ok && a.Equal(b) } return false } @@ -1214,8 +1214,6 @@ func CopySignature(v Signature) Signature { return v.Copy() case *EcdsaSha256Signature: return v.Copy() - case *Eip712TypedDataSignature: - return v.Copy() case *InternalSignature: return v.Copy() case *LegacyED25519Signature: @@ -1232,6 +1230,8 @@ func CopySignature(v Signature) Signature { return v.Copy() case *SignatureSet: return v.Copy() + case *TypedDataSignature: + return v.Copy() default: return v.CopyAsInterface().(Signature) } diff --git a/test/e2e/sig_eip712_test.go b/test/e2e/sig_eip712_test.go index 81ad132fb..36274cda9 100644 --- a/test/e2e/sig_eip712_test.go +++ b/test/e2e/sig_eip712_test.go @@ -39,7 +39,7 @@ func TestEIP712Signature(t *testing.T) { // Sign it pk, _ := aliceKey.GetPublicKey() - sig := &Eip712TypedDataSignature{ + sig := &TypedDataSignature{ ChainID: EthChainID("DevNet"), Signer: alice.Url().JoinPath("book", "1"), PublicKey: pk, @@ -75,7 +75,7 @@ func TestEIP712Signature(t *testing.T) { // Sign it pk, _ := aliceKey.GetPublicKey() - sig := &Eip712TypedDataSignature{ + sig := &TypedDataSignature{ ChainID: EthChainID("MainNet"), Signer: alice.Url().JoinPath("book", "1"), PublicKey: pk, @@ -119,7 +119,7 @@ func TestEIP712ExternalWallet(t *testing.T) { // Sign it pk, _ := aliceKey.GetPublicKey() - sig := &Eip712TypedDataSignature{ + sig := &TypedDataSignature{ ChainID: EthChainID("DevNet"), Signer: alice.Url().JoinPath("book", "1"), PublicKey: pk,