@towns-labs/relayer 2.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +161 -0
- package/dist/README.md +1 -0
- package/dist/index.js +47482 -0
- package/dist/index.js.map +8 -0
- package/package.json +53 -0
- package/src/rpc/schema/getCallsStatus.ts +21 -0
- package/src/rpc/schema/getCapabilities.ts +91 -0
- package/src/rpc/schema/getKeys.ts +40 -0
- package/src/rpc/schema/prepareCalls.ts +173 -0
- package/src/rpc/schema/sendPreparedCalls.ts +23 -0
- package/src/rpc/schema/upgradeAccount.ts +172 -0
- package/src/rpc/schema/verifySignature.ts +27 -0
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@towns-labs/relayer",
|
|
3
|
+
"version": "2.0.12",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./dist/index.js",
|
|
8
|
+
"./rpc/schema/*": "./src/rpc/schema/*.ts"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"src/rpc/schema"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc --noEmit && wrangler build",
|
|
16
|
+
"deploy": "wrangler deploy",
|
|
17
|
+
"deploy:prod": "wrangler deploy --env prod",
|
|
18
|
+
"deploy:stage": "wrangler deploy --env stage",
|
|
19
|
+
"dev": "./scripts/dev.sh --crosschain",
|
|
20
|
+
"dev:prod": "wrangler dev --env prod",
|
|
21
|
+
"dev:stage": "wrangler dev --env stage",
|
|
22
|
+
"dev:wrangler": "wrangler dev",
|
|
23
|
+
"format": "prettier --write .",
|
|
24
|
+
"format:check": "prettier --check .",
|
|
25
|
+
"lint": "oxlint --deny-warnings",
|
|
26
|
+
"lint:fix": "oxlint --fix",
|
|
27
|
+
"logs:prod": "wrangler tail --env prod",
|
|
28
|
+
"logs:stage": "wrangler tail --env stage",
|
|
29
|
+
"telemetry:summary": "bun run scripts/telemetry-summary.ts",
|
|
30
|
+
"telemetry:summary:stage": "wrangler tail --env stage --format json | bun run scripts/telemetry-summary.ts",
|
|
31
|
+
"telemetry:summary:prod": "wrangler tail --env prod --format json | bun run scripts/telemetry-summary.ts",
|
|
32
|
+
"test": "vitest",
|
|
33
|
+
"test:run": "vitest run"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@hono/zod-validator": "0.7.6",
|
|
37
|
+
"@scure/bip32": "2.0.1",
|
|
38
|
+
"@scure/bip39": "2.0.1",
|
|
39
|
+
"@towns-labs/contracts": "^2.0.12",
|
|
40
|
+
"hono": "^4.11.7",
|
|
41
|
+
"oxlint": "^1.41.0",
|
|
42
|
+
"pino": "10.2.0",
|
|
43
|
+
"viem": "2.45.1",
|
|
44
|
+
"zod": "^4.3.6"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@cloudflare/vitest-pool-workers": "^0.8.38",
|
|
48
|
+
"@cloudflare/workers-types": "^4.20250618.0",
|
|
49
|
+
"typescript": "~5.8.3",
|
|
50
|
+
"vitest": "^3.2.3",
|
|
51
|
+
"wrangler": "^4.61.0"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Hex } from 'viem'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Result of wallet_getCallsStatus
|
|
5
|
+
*/
|
|
6
|
+
export interface GetCallsStatusResult {
|
|
7
|
+
id: string
|
|
8
|
+
status: number // 100=Pending, 200=Confirmed, 201=PreConfirmed, 300=Failed, 400=Reverted, 500=Partially Reverted
|
|
9
|
+
receipts: Array<{
|
|
10
|
+
chain_id: string
|
|
11
|
+
transaction_hash: Hex
|
|
12
|
+
status: boolean // Transaction success
|
|
13
|
+
block_hash?: string
|
|
14
|
+
block_number?: string
|
|
15
|
+
gas_used: string
|
|
16
|
+
logs: unknown[]
|
|
17
|
+
/** Intent execution error (bytes4 selector, e.g., 0x9054c912 for ExceededSpendLimit) */
|
|
18
|
+
intent_error?: Hex
|
|
19
|
+
}>
|
|
20
|
+
capabilities?: Record<string, unknown>
|
|
21
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { Address } from 'viem'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Parameters for wallet_getCapabilities
|
|
5
|
+
*/
|
|
6
|
+
export interface GetCapabilitiesParams {
|
|
7
|
+
/** Hex-encoded chain IDs to filter (e.g., ["0x1", "0xa"]) */
|
|
8
|
+
chains?: string[]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Versioned contract addresses (spec-compliant)
|
|
13
|
+
*/
|
|
14
|
+
export interface VersionedContracts {
|
|
15
|
+
orchestrator: Address
|
|
16
|
+
delegation: Address
|
|
17
|
+
simulator: Address
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Quote configuration for fee estimation
|
|
22
|
+
*/
|
|
23
|
+
export interface QuoteConfig {
|
|
24
|
+
/** Default quote TTL in seconds */
|
|
25
|
+
ttlSeconds?: number
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Fee token configuration
|
|
30
|
+
*/
|
|
31
|
+
export interface ChainFeeToken {
|
|
32
|
+
/** Asset unique identifier (e.g., "usdc") */
|
|
33
|
+
uid: string
|
|
34
|
+
/** Token address */
|
|
35
|
+
address: Address
|
|
36
|
+
/** Token decimals */
|
|
37
|
+
decimals: number
|
|
38
|
+
/** Whether this token can be used for fees */
|
|
39
|
+
feeToken: boolean
|
|
40
|
+
/** Token symbol */
|
|
41
|
+
symbol?: string
|
|
42
|
+
/** Rate of 1 token against native token (hex) */
|
|
43
|
+
nativeRate?: string
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Fees configuration (spec-compliant)
|
|
48
|
+
*/
|
|
49
|
+
export interface ChainFees {
|
|
50
|
+
recipient: Address
|
|
51
|
+
quoteConfig: QuoteConfig
|
|
52
|
+
tokens: ChainFeeToken[]
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Individual signer information
|
|
57
|
+
*/
|
|
58
|
+
export interface SignerInfo {
|
|
59
|
+
index: number
|
|
60
|
+
address: string | null
|
|
61
|
+
balance: string | null
|
|
62
|
+
balanceEth: string | null
|
|
63
|
+
capacity: number
|
|
64
|
+
pending: number
|
|
65
|
+
paused: boolean
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Pool status information
|
|
70
|
+
*/
|
|
71
|
+
export interface PoolInfo {
|
|
72
|
+
signerCount: number
|
|
73
|
+
totalCapacity: number
|
|
74
|
+
totalPending: number
|
|
75
|
+
availableCapacity: number
|
|
76
|
+
signers: SignerInfo[]
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Capabilities for a single chain (spec-compliant)
|
|
81
|
+
*/
|
|
82
|
+
export interface ChainCapabilities {
|
|
83
|
+
contracts: VersionedContracts
|
|
84
|
+
fees: ChainFees
|
|
85
|
+
pool: PoolInfo
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Result type for wallet_getCapabilities
|
|
90
|
+
*/
|
|
91
|
+
export type GetCapabilitiesResult = Record<string, ChainCapabilities>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Address, Hex } from 'viem'
|
|
2
|
+
import type { CallPermission, KeyType, SpendPermission } from './upgradeAccount'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Spend permission response - extends SpendPermission with current spent amount
|
|
6
|
+
*/
|
|
7
|
+
export interface SpendPermissionResponse extends Omit<SpendPermission, 'limit'> {
|
|
8
|
+
limit: Hex
|
|
9
|
+
spent: Hex
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Permission types returned by getKeys
|
|
14
|
+
*/
|
|
15
|
+
export type PermissionResponse = CallPermission | SpendPermissionResponse
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Authorized key response with permissions
|
|
19
|
+
*/
|
|
20
|
+
export interface AuthorizedKeyResponse {
|
|
21
|
+
hash: Hex
|
|
22
|
+
expiry: Hex
|
|
23
|
+
type: KeyType
|
|
24
|
+
role: 'admin' | 'normal'
|
|
25
|
+
publicKey: Hex
|
|
26
|
+
permissions: PermissionResponse[]
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Parameters for wallet_getKeys
|
|
31
|
+
*/
|
|
32
|
+
export interface GetKeysParams {
|
|
33
|
+
address: Address
|
|
34
|
+
chainIds?: string[]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Result type for wallet_getKeys - keyed by hex chain ID
|
|
39
|
+
*/
|
|
40
|
+
export type GetKeysResult = Record<string, AuthorizedKeyResponse[]>
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import type { Address, Hex } from 'viem'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Call object in JSON-RPC format
|
|
5
|
+
*/
|
|
6
|
+
export interface RpcCall {
|
|
7
|
+
to: Address
|
|
8
|
+
data?: Hex
|
|
9
|
+
value?: string // hex
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Key type for signing
|
|
14
|
+
*/
|
|
15
|
+
export type KeyType = 'secp256k1'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Call key for signing
|
|
19
|
+
*/
|
|
20
|
+
export interface CallKey {
|
|
21
|
+
type: KeyType
|
|
22
|
+
publicKey: Hex
|
|
23
|
+
prehash: boolean
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Parameters for wallet_prepareCalls
|
|
28
|
+
*/
|
|
29
|
+
export interface PrepareCallsParams {
|
|
30
|
+
from?: Address
|
|
31
|
+
chain_id: string // hex
|
|
32
|
+
calls: RpcCall[]
|
|
33
|
+
key?: {
|
|
34
|
+
type: string
|
|
35
|
+
public_key: Hex
|
|
36
|
+
prehash?: boolean
|
|
37
|
+
}
|
|
38
|
+
capabilities?: {
|
|
39
|
+
meta?: {
|
|
40
|
+
fee_payer?: Address
|
|
41
|
+
fee_token?: Address
|
|
42
|
+
fee_max_amount?: string
|
|
43
|
+
nonce?: string
|
|
44
|
+
seq_key?: string
|
|
45
|
+
settler?: Address
|
|
46
|
+
settler_context?: Hex
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Intent structure within a Quote
|
|
53
|
+
*/
|
|
54
|
+
export interface QuoteIntent {
|
|
55
|
+
eoa: Address
|
|
56
|
+
calls: { to: Address; value: string; data: Hex }[]
|
|
57
|
+
nonce: string
|
|
58
|
+
combinedGas: string
|
|
59
|
+
expiry: string
|
|
60
|
+
encodedPreCalls?: Hex[]
|
|
61
|
+
funder?: Address
|
|
62
|
+
encodedFundTransfers?: Hex[]
|
|
63
|
+
settler?: Address
|
|
64
|
+
settlerContext?: Hex
|
|
65
|
+
payer?: Address
|
|
66
|
+
paymentToken?: Address
|
|
67
|
+
paymentMaxAmount?: string
|
|
68
|
+
/** Payment signature for third-party sponsorship (when payer != eoa) */
|
|
69
|
+
paymentSignature?: Hex
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Quote for a prepared call bundle
|
|
74
|
+
*/
|
|
75
|
+
export interface Quote {
|
|
76
|
+
chainId: string
|
|
77
|
+
intent: QuoteIntent
|
|
78
|
+
extraPayment: string
|
|
79
|
+
ethPrice: string
|
|
80
|
+
paymentTokenDecimals: number
|
|
81
|
+
txGas: number
|
|
82
|
+
nativeFeeEstimate: {
|
|
83
|
+
maxFeePerGas: number
|
|
84
|
+
maxPriorityFeePerGas: number
|
|
85
|
+
}
|
|
86
|
+
/** Calculated payment amount in fee token units (set by relayer) */
|
|
87
|
+
paymentAmount: string
|
|
88
|
+
orchestrator: Address
|
|
89
|
+
feeTokenDeficit: string
|
|
90
|
+
assetDeficits: Array<{
|
|
91
|
+
address?: Address
|
|
92
|
+
metadata: { name?: string; symbol?: string; decimals?: number }
|
|
93
|
+
required: string
|
|
94
|
+
deficit: string
|
|
95
|
+
}>
|
|
96
|
+
telemetry?: {
|
|
97
|
+
simulationGas?: string
|
|
98
|
+
combinedGas?: string
|
|
99
|
+
txGas?: string
|
|
100
|
+
paymentEnabled?: boolean
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Signed quotes with relay signature
|
|
106
|
+
*/
|
|
107
|
+
export interface SignedQuotes {
|
|
108
|
+
quotes: Quote[]
|
|
109
|
+
signature: Hex
|
|
110
|
+
ttl: number
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Asset metadata
|
|
115
|
+
*/
|
|
116
|
+
export interface AssetMetadata {
|
|
117
|
+
name?: string
|
|
118
|
+
symbol?: string
|
|
119
|
+
decimals?: number
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Asset price
|
|
124
|
+
*/
|
|
125
|
+
export interface AssetPrice {
|
|
126
|
+
currency: string
|
|
127
|
+
value: number
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Asset diff for tracking balance changes
|
|
132
|
+
*/
|
|
133
|
+
export interface AssetDiff {
|
|
134
|
+
address?: Address
|
|
135
|
+
tokenKind?: 'native' | 'erc20' | 'erc721'
|
|
136
|
+
metadata: AssetMetadata
|
|
137
|
+
value: string
|
|
138
|
+
direction: 'incoming' | 'outgoing'
|
|
139
|
+
fiat?: AssetPrice
|
|
140
|
+
recipients: Address[]
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Context returned by prepareCalls, used in sendPreparedCalls (spec-compliant)
|
|
145
|
+
*/
|
|
146
|
+
export type PrepareCallsContext = { quote: SignedQuotes }
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Capabilities in the prepareCalls response
|
|
150
|
+
*/
|
|
151
|
+
export interface PrepareCallsCapabilities {
|
|
152
|
+
authorizeKeys: unknown[]
|
|
153
|
+
revokeKeys: unknown[]
|
|
154
|
+
feeTotals: Record<string, AssetPrice>
|
|
155
|
+
assetDiffs: Record<string, Array<[Address, AssetDiff[]]>>
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Result of wallet_prepareCalls (spec-compliant)
|
|
160
|
+
*/
|
|
161
|
+
export interface PrepareCallsResult {
|
|
162
|
+
context: PrepareCallsContext
|
|
163
|
+
digest: Hex
|
|
164
|
+
typedData: {
|
|
165
|
+
domain: Record<string, unknown>
|
|
166
|
+
types: Record<string, unknown>
|
|
167
|
+
primaryType: string
|
|
168
|
+
message: Record<string, unknown>
|
|
169
|
+
}
|
|
170
|
+
capabilities: PrepareCallsCapabilities
|
|
171
|
+
key?: CallKey
|
|
172
|
+
signature: Hex
|
|
173
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Hex } from 'viem'
|
|
2
|
+
import type { CallKey, PrepareCallsContext } from './prepareCalls'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Parameters for wallet_sendPreparedCalls (spec-compliant)
|
|
6
|
+
*/
|
|
7
|
+
export interface SendPreparedCallsParams {
|
|
8
|
+
context: PrepareCallsContext
|
|
9
|
+
signature: Hex
|
|
10
|
+
key?: CallKey
|
|
11
|
+
/** Payment signature for third-party sponsorship (when payer != sender) */
|
|
12
|
+
paymentSignature?: Hex
|
|
13
|
+
capabilities?: {
|
|
14
|
+
feeSignature?: Hex
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Result of wallet_sendPreparedCalls
|
|
20
|
+
*/
|
|
21
|
+
export interface SendPreparedCallsResult {
|
|
22
|
+
id: string
|
|
23
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import type { Address, Hex } from 'viem'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Key types supported for authorization
|
|
5
|
+
*/
|
|
6
|
+
export type KeyType = 'secp256k1' | 'external'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Spend period for spending limits
|
|
10
|
+
*/
|
|
11
|
+
export type SpendPeriod = 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year' | 'forever'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Call permission
|
|
15
|
+
*/
|
|
16
|
+
export interface CallPermission {
|
|
17
|
+
type: 'call'
|
|
18
|
+
to: Address
|
|
19
|
+
selector: Hex
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Spend permission
|
|
24
|
+
*/
|
|
25
|
+
export interface SpendPermission {
|
|
26
|
+
type: 'spend'
|
|
27
|
+
token: Address
|
|
28
|
+
limit: string
|
|
29
|
+
period: SpendPeriod
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Permission types
|
|
34
|
+
*/
|
|
35
|
+
export type Permission = CallPermission | SpendPermission
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Key authorization request
|
|
39
|
+
*/
|
|
40
|
+
export interface AuthorizeKey {
|
|
41
|
+
expiry: string
|
|
42
|
+
type: KeyType
|
|
43
|
+
role: 'admin' | 'normal'
|
|
44
|
+
publicKey: Hex
|
|
45
|
+
permissions: Permission[]
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Key authorization response (includes hash)
|
|
50
|
+
*/
|
|
51
|
+
export interface AuthorizeKeyResponse extends AuthorizeKey {
|
|
52
|
+
hash: Hex
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* EIP-7702 Authorization (unsigned)
|
|
57
|
+
*/
|
|
58
|
+
export interface Authorization {
|
|
59
|
+
contractAddress: Address
|
|
60
|
+
chainId: number
|
|
61
|
+
nonce: number
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Signed call for precall execution
|
|
66
|
+
*/
|
|
67
|
+
export interface SignedCall {
|
|
68
|
+
eoa: Address
|
|
69
|
+
executionData: Hex
|
|
70
|
+
nonce: string
|
|
71
|
+
signature: Hex
|
|
72
|
+
chainId: string
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Parameters for wallet_prepareUpgradeAccount (spec-compliant)
|
|
77
|
+
*/
|
|
78
|
+
export interface PrepareUpgradeParams {
|
|
79
|
+
/** EOA address to upgrade */
|
|
80
|
+
address: Address
|
|
81
|
+
/** Target chain ID (hex), defaults to relayer's chain */
|
|
82
|
+
chainId?: string
|
|
83
|
+
/** TownsAccount implementation address, defaults to config */
|
|
84
|
+
delegation: Address
|
|
85
|
+
/** Capabilities for the upgrade */
|
|
86
|
+
capabilities: {
|
|
87
|
+
authorizeKeys: AuthorizeKey[]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Context returned by prepareUpgradeAccount (spec-compliant)
|
|
93
|
+
*/
|
|
94
|
+
export interface UpgradeAccountContext {
|
|
95
|
+
/** EOA address being upgraded */
|
|
96
|
+
address: Address
|
|
97
|
+
/** Target chain ID (hex) */
|
|
98
|
+
chainId: string
|
|
99
|
+
/** EIP-7702 authorization (unsigned) */
|
|
100
|
+
authorization: Authorization
|
|
101
|
+
/** PreCall for key initialization */
|
|
102
|
+
preCall: SignedCall
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Digests to sign for account upgrade
|
|
107
|
+
*/
|
|
108
|
+
export interface UpgradeAccountDigests {
|
|
109
|
+
/** EIP-7702 authorization digest */
|
|
110
|
+
auth: Hex
|
|
111
|
+
/** Precall execution digest */
|
|
112
|
+
exec: Hex
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Capabilities in the upgrade response
|
|
117
|
+
*/
|
|
118
|
+
export interface UpgradeAccountCapabilities {
|
|
119
|
+
authorizeKeys: AuthorizeKeyResponse[]
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Result of wallet_prepareUpgradeAccount (spec-compliant)
|
|
124
|
+
*/
|
|
125
|
+
export interface PrepareUpgradeResult {
|
|
126
|
+
/** Chain ID (hex) */
|
|
127
|
+
chainId: string
|
|
128
|
+
/** Context to pass to upgradeAccount */
|
|
129
|
+
context: UpgradeAccountContext
|
|
130
|
+
/** Digests to sign */
|
|
131
|
+
digests: UpgradeAccountDigests
|
|
132
|
+
/** EIP-712 typed data for the exec signature */
|
|
133
|
+
typedData: {
|
|
134
|
+
domain: Record<string, unknown>
|
|
135
|
+
types: Record<string, unknown>
|
|
136
|
+
primaryType: string
|
|
137
|
+
message: Record<string, unknown>
|
|
138
|
+
}
|
|
139
|
+
/** Capabilities with processed keys */
|
|
140
|
+
capabilities: UpgradeAccountCapabilities
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Signatures for wallet_upgradeAccount
|
|
145
|
+
*/
|
|
146
|
+
export interface UpgradeAccountSignatures {
|
|
147
|
+
/** EIP-7702 authorization signature */
|
|
148
|
+
auth: Hex
|
|
149
|
+
/** Precall execution signature */
|
|
150
|
+
exec: Hex
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Parameters for wallet_upgradeAccount (spec-compliant)
|
|
155
|
+
*/
|
|
156
|
+
export interface UpgradeAccountParams {
|
|
157
|
+
/** Context from prepareUpgradeAccount */
|
|
158
|
+
context: UpgradeAccountContext
|
|
159
|
+
/** Both signatures */
|
|
160
|
+
signatures: UpgradeAccountSignatures
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Result of wallet_upgradeAccount
|
|
165
|
+
*
|
|
166
|
+
* Returns success: true only after the delegation tx is mined and confirmed.
|
|
167
|
+
* This allows clients to proceed immediately without polling.
|
|
168
|
+
*/
|
|
169
|
+
export interface UpgradeAccountResult {
|
|
170
|
+
success: boolean
|
|
171
|
+
txHash?: string
|
|
172
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Address, Hex } from 'viem'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Parameters for wallet_verifySignature
|
|
5
|
+
*/
|
|
6
|
+
export interface VerifySignatureParams {
|
|
7
|
+
address: Address
|
|
8
|
+
digest: Hex
|
|
9
|
+
signature: Hex
|
|
10
|
+
chain_id: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Proof of valid signature
|
|
15
|
+
*/
|
|
16
|
+
export interface ValidSignatureProof {
|
|
17
|
+
account: Address
|
|
18
|
+
key_hash: Hex
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Result of wallet_verifySignature
|
|
23
|
+
*/
|
|
24
|
+
export interface VerifySignatureResult {
|
|
25
|
+
valid: boolean
|
|
26
|
+
proof: ValidSignatureProof | null
|
|
27
|
+
}
|