diff --git a/intentv1/intent.gen.go b/intentv1/intent.gen.go index b686844..d549c59 100644 --- a/intentv1/intent.gen.go +++ b/intentv1/intent.gen.go @@ -1,4 +1,4 @@ -// sequence-waas-intents v0.1.0 b0dc5c3bceb25d04f130e1807829bd8110a0a3e4 +// sequence-waas-intents v0.1.0 cee7350afc8c71efb922f9b8c6a79991997f5d7a // -- // Code generated by webrpc-gen@v0.14.0-dev with golang generator. DO NOT EDIT. // @@ -24,7 +24,7 @@ func WebRPCSchemaVersion() string { // Schema hash generated from your RIDL schema func WebRPCSchemaHash() string { - return "b0dc5c3bceb25d04f130e1807829bd8110a0a3e4" + return "cee7350afc8c71efb922f9b8c6a79991997f5d7a" } // @@ -39,20 +39,16 @@ type Signature struct { type Intent struct { Version string `json:"version"` Name string `json:"name"` - Expires uint64 `json:"expires"` - Issued uint64 `json:"issued"` + ExpiresAt uint64 `json:"expiresAt"` + IssuedAt uint64 `json:"issuedAt"` Data interface{} `json:"data"` Signatures []*Signature `json:"signatures"` } -type SessionPacketProof struct { - Email *string `json:"email"` - IdToken *string `json:"idToken"` -} - type IntentDataOpenSession struct { - SessionId string `json:"sessionId"` - Proof *SessionPacketProof `json:"proof"` + SessionId string `json:"sessionId"` + Email *string `json:"email"` + IdToken *string `json:"idToken"` } type IntentDataCloseSession struct { @@ -82,7 +78,7 @@ type IntentDataSign struct { Message string `json:"message"` } -type IntentDataTransaction struct { +type IntentDataSendTransaction struct { Network string `json:"network"` Identifier string `json:"identifier"` Transactions []interface{} `json:"transactions"` @@ -96,19 +92,19 @@ type TransactionRaw struct { } type TransactionERC20 struct { - Type string `json:"type"` - Token string `json:"token"` - To string `json:"to"` - Value string `json:"value"` + Type string `json:"type"` + TokenAddress string `json:"tokenAddress"` + To string `json:"to"` + Value string `json:"value"` } type TransactionERC721 struct { - Type string `json:"type"` - Token string `json:"token"` - To string `json:"to"` - Id string `json:"id"` - Safe *bool `json:"safe"` - Data *string `json:"data"` + Type string `json:"type"` + TokenAddress string `json:"tokenAddress"` + To string `json:"to"` + Id string `json:"id"` + Safe *bool `json:"safe"` + Data *string `json:"data"` } type TransactionERC1155Value struct { @@ -117,11 +113,11 @@ type TransactionERC1155Value struct { } type TransactionERC1155 struct { - Type string `json:"type"` - Token string `json:"token"` - To string `json:"to"` - Vals []*TransactionERC1155Value `json:"vals"` - Data *string `json:"data"` + Type string `json:"type"` + TokenAddress string `json:"tokenAddress"` + To string `json:"to"` + Vals []*TransactionERC1155Value `json:"vals"` + Data *string `json:"data"` } type IntentResponse struct { diff --git a/intentv1/intent.gen.ts b/intentv1/intent.gen.ts index c2ff608..a276130 100644 --- a/intentv1/intent.gen.ts +++ b/intentv1/intent.gen.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -// sequence-waas-intents v0.1.0 b0dc5c3bceb25d04f130e1807829bd8110a0a3e4 +// sequence-waas-intents v0.1.0 cee7350afc8c71efb922f9b8c6a79991997f5d7a // -- // Code generated by webrpc-gen@v0.14.0-dev with typescript generator. DO NOT EDIT. // @@ -12,7 +12,7 @@ export const WebRPCVersion = "v1" export const WebRPCSchemaVersion = "v0.1.0" // Schema hash generated from your RIDL schema -export const WebRPCSchemaHash = "b0dc5c3bceb25d04f130e1807829bd8110a0a3e4" +export const WebRPCSchemaHash = "cee7350afc8c71efb922f9b8c6a79991997f5d7a" // // Types @@ -27,20 +27,16 @@ export interface Signature { export interface Intent { version: string name: string - expires: number - issued: number + expiresAt: number + issuedAt: number data: any signatures: Array } -export interface SessionPacketProof { - email?: string - idToken?: string -} - export interface IntentDataOpenSession { sessionId: string - proof: SessionPacketProof + email?: string + idToken?: string } export interface IntentDataCloseSession { @@ -70,7 +66,7 @@ export interface IntentDataSign { message: string } -export interface IntentDataTransaction { +export interface IntentDataSendTransaction { network: string identifier: string transactions: Array @@ -85,14 +81,14 @@ export interface TransactionRaw { export interface TransactionERC20 { type: string - token: string + tokenAddress: string to: string value: string } export interface TransactionERC721 { type: string - token: string + tokenAddress: string to: string id: string safe?: boolean @@ -106,7 +102,7 @@ export interface TransactionERC1155Value { export interface TransactionERC1155 { type: string - token: string + tokenAddress: string to: string vals: Array data?: string diff --git a/intentv1/intent.ridl b/intentv1/intent.ridl index 208f83d..011d5e9 100644 --- a/intentv1/intent.ridl +++ b/intentv1/intent.ridl @@ -3,6 +3,14 @@ webrpc = v1 name = sequence-waas-intents version = v0.1.0 +struct Intent + - version: string + - name: string + - expiresAt: uint64 + - issuedAt: uint64 + - data: any + - signatures: []Signature + struct Signature - sessionId: string - signature: string @@ -16,23 +24,12 @@ struct Signature # - listSessions # - getSession # - sign -# - transaction - -struct Intent - - version: string - - name: string - - expires: uint64 - - issued: uint64 - - data: any - - signatures: []Signature - -struct SessionPacketProof - - email?: string - - idToken?: string +# - sendTransaction struct IntentDataOpenSession - sessionId: string - - proof: SessionPacketProof + - email?: string + - idToken?: string struct IntentDataCloseSession - sessionId: string @@ -55,11 +52,17 @@ struct IntentDataSign - network: string - message: string -struct IntentDataTransaction +struct IntentDataSendTransaction - network: string - identifier: string - transactions: []any +struct TransactionRaw + - type: string + - to: string + - value: string + - data: string + # no way to generate string enums #enum TransactionType: uint8 # - transaction @@ -67,21 +70,15 @@ struct IntentDataTransaction # - erc721send # - erc1155send -struct TransactionRaw - - type: string - - to: string - - value: string - - data: string - struct TransactionERC20 - type: string - - token: string + - tokenAddress: string - to: string - value: string struct TransactionERC721 - type: string - - token: string + - tokenAddress: string - to: string - id: string - safe?: bool @@ -93,7 +90,7 @@ struct TransactionERC1155Value struct TransactionERC1155 - type: string - - token: string + - tokenAddress: string - to: string - vals: []TransactionERC1155Value - data?: string diff --git a/intentv1/intent_ext.go b/intentv1/intent_ext.go index 8aad017..58dc093 100644 --- a/intentv1/intent_ext.go +++ b/intentv1/intent_ext.go @@ -46,12 +46,12 @@ func (intent *Intent) IsValid() error { } // check if the intent is expired - if intent.Expires+IntentAllowedTimeDriftInSec < uint64(time.Now().Unix()) { + if intent.ExpiresAt+IntentAllowedTimeDriftInSec < uint64(time.Now().Unix()) { return fmt.Errorf("intent expired") } // check if the intent is issued in the future - if intent.Issued-IntentAllowedTimeDriftInSec > uint64(time.Now().Unix()) { + if intent.IssuedAt-IntentAllowedTimeDriftInSec > uint64(time.Now().Unix()) { return fmt.Errorf("intent issued in the future") } @@ -158,7 +158,7 @@ func (intent *Intent) isValidSignatureP256R1(sessionId string, signature string) // validate session id sessionIdBytes := common.FromHex(sessionId) - if len(sessionIdBytes) != 65 { + if len(sessionIdBytes) != 66 { return fmt.Errorf("invalid sessionId length") } diff --git a/intentv1/intent_typed.go b/intentv1/intent_typed.go index 6dd8468..dc1aecd 100644 --- a/intentv1/intent_typed.go +++ b/intentv1/intent_typed.go @@ -23,8 +23,8 @@ func IntentDataTypeToName[T any](t *T) string { return "getSession" case *IntentDataSign: return "sign" - case *IntentDataTransaction: - return "transaction" + case *IntentDataSendTransaction: + return "sendTransaction" default: return "" } @@ -38,11 +38,11 @@ type IntentTyped[T any] struct { func NewIntentTyped[T any](data T) *IntentTyped[T] { return &IntentTyped[T]{ Intent: Intent{ - Version: "1", - Expires: uint64(time.Now().Unix()) + IntentValidTimeInSec, - Issued: uint64(time.Now().Unix()), - Name: IntentDataTypeToName(&data), - Data: data, + Version: "1", + ExpiresAt: uint64(time.Now().Unix()) + IntentValidTimeInSec, + IssuedAt: uint64(time.Now().Unix()), + Name: IntentDataTypeToName(&data), + Data: data, }, Data: data, } diff --git a/intentv1/intent_typed_test.go b/intentv1/intent_typed_test.go index a984e76..5e71380 100644 --- a/intentv1/intent_typed_test.go +++ b/intentv1/intent_typed_test.go @@ -48,8 +48,8 @@ func TestIntentNewIntentTyped(t *testing.T) { }) t.Run("transaction", func(t *testing.T) { - intent := NewIntentTyped(IntentDataTransaction{}) - assert.Equal(t, "transaction", intent.Name) + intent := NewIntentTyped(IntentDataSendTransaction{}) + assert.Equal(t, "sendTransaction", intent.Name) }) t.Run("unknown", func(t *testing.T) { @@ -138,7 +138,7 @@ func TestIntentIsValid(t *testing.T) { t.Run("expired", func(t *testing.T) { intent := NewIntentTyped(IntentDataOpenSession{SessionId: "0x1234"}) - intent.Expires = 0 + intent.ExpiresAt = 0 wallet, err := ethwallet.NewWalletFromRandomEntropy() require.NoError(t, err) @@ -152,7 +152,7 @@ func TestIntentIsValid(t *testing.T) { t.Run("issuedInFuture", func(t *testing.T) { intent := NewIntentTyped(IntentDataOpenSession{SessionId: "0x1234"}) - intent.Issued = uint64(1 << 63) + intent.IssuedAt = uint64(1 << 63) wallet, err := ethwallet.NewWalletFromRandomEntropy() require.NoError(t, err)