tempo.ts 0.7.6 → 0.8.0

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.
Files changed (129) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/chains.d.ts +6 -20
  3. package/dist/chains.d.ts.map +1 -1
  4. package/dist/chains.js +14 -15
  5. package/dist/chains.js.map +1 -1
  6. package/dist/ox/KeyAuthorization.d.ts +356 -0
  7. package/dist/ox/KeyAuthorization.d.ts.map +1 -0
  8. package/dist/ox/KeyAuthorization.js +360 -0
  9. package/dist/ox/KeyAuthorization.js.map +1 -0
  10. package/dist/ox/SignatureEnvelope.d.ts +21 -6
  11. package/dist/ox/SignatureEnvelope.d.ts.map +1 -1
  12. package/dist/ox/SignatureEnvelope.js +43 -3
  13. package/dist/ox/SignatureEnvelope.js.map +1 -1
  14. package/dist/ox/Transaction.d.ts +5 -1
  15. package/dist/ox/Transaction.d.ts.map +1 -1
  16. package/dist/ox/Transaction.js +5 -0
  17. package/dist/ox/Transaction.js.map +1 -1
  18. package/dist/ox/TransactionEnvelopeAA.d.ts +9 -0
  19. package/dist/ox/TransactionEnvelopeAA.d.ts.map +1 -1
  20. package/dist/ox/TransactionEnvelopeAA.js +17 -4
  21. package/dist/ox/TransactionEnvelopeAA.js.map +1 -1
  22. package/dist/ox/TransactionRequest.d.ts +7 -1
  23. package/dist/ox/TransactionRequest.d.ts.map +1 -1
  24. package/dist/ox/TransactionRequest.js +12 -0
  25. package/dist/ox/TransactionRequest.js.map +1 -1
  26. package/dist/ox/index.d.ts +1 -0
  27. package/dist/ox/index.d.ts.map +1 -1
  28. package/dist/ox/index.js +1 -0
  29. package/dist/ox/index.js.map +1 -1
  30. package/dist/prool/Instance.js +1 -1
  31. package/dist/prool/Instance.js.map +1 -1
  32. package/{src/prool/internal → dist/prool}/chain.json +4 -2
  33. package/dist/viem/Abis.d.ts +319 -6
  34. package/dist/viem/Abis.d.ts.map +1 -1
  35. package/dist/viem/Abis.js +199 -7
  36. package/dist/viem/Abis.js.map +1 -1
  37. package/dist/viem/Account.d.ts +103 -14
  38. package/dist/viem/Account.d.ts.map +1 -1
  39. package/dist/viem/Account.js +177 -23
  40. package/dist/viem/Account.js.map +1 -1
  41. package/dist/viem/Actions/account.d.ts.map +1 -1
  42. package/dist/viem/Actions/account.js +4 -5
  43. package/dist/viem/Actions/account.js.map +1 -1
  44. package/dist/viem/Actions/amm.d.ts +72 -0
  45. package/dist/viem/Actions/amm.d.ts.map +1 -1
  46. package/dist/viem/Actions/dex.d.ts +156 -4
  47. package/dist/viem/Actions/dex.d.ts.map +1 -1
  48. package/dist/viem/Actions/fee.d.ts +4 -0
  49. package/dist/viem/Actions/fee.d.ts.map +1 -1
  50. package/dist/viem/Actions/reward.d.ts +78 -0
  51. package/dist/viem/Actions/reward.d.ts.map +1 -1
  52. package/dist/viem/Actions/token.d.ts +585 -0
  53. package/dist/viem/Actions/token.d.ts.map +1 -1
  54. package/dist/viem/Actions/token.js +2 -2
  55. package/dist/viem/Actions/token.js.map +1 -1
  56. package/dist/viem/Addresses.d.ts +1 -1
  57. package/dist/viem/Addresses.d.ts.map +1 -1
  58. package/dist/viem/Addresses.js +1 -1
  59. package/dist/viem/Addresses.js.map +1 -1
  60. package/dist/viem/Chain.d.ts +35 -0
  61. package/dist/viem/Chain.d.ts.map +1 -1
  62. package/dist/viem/Chain.js +37 -0
  63. package/dist/viem/Chain.js.map +1 -1
  64. package/dist/viem/Formatters.d.ts.map +1 -1
  65. package/dist/viem/Formatters.js +8 -7
  66. package/dist/viem/Formatters.js.map +1 -1
  67. package/dist/viem/Storage.d.ts +1 -0
  68. package/dist/viem/Storage.d.ts.map +1 -1
  69. package/dist/viem/Storage.js +21 -0
  70. package/dist/viem/Storage.js.map +1 -1
  71. package/dist/viem/TokenIds.d.ts +1 -1
  72. package/dist/viem/TokenIds.d.ts.map +1 -1
  73. package/dist/viem/TokenIds.js +1 -1
  74. package/dist/viem/TokenIds.js.map +1 -1
  75. package/dist/viem/Transaction.d.ts +9 -1
  76. package/dist/viem/Transaction.d.ts.map +1 -1
  77. package/dist/viem/Transaction.js +2 -1
  78. package/dist/viem/Transaction.js.map +1 -1
  79. package/dist/viem/WebAuthnP256.d.ts +4 -1
  80. package/dist/viem/WebAuthnP256.d.ts.map +1 -1
  81. package/dist/viem/WebAuthnP256.js +3 -1
  82. package/dist/viem/WebAuthnP256.js.map +1 -1
  83. package/dist/wagmi/Connector.d.ts +25 -8
  84. package/dist/wagmi/Connector.d.ts.map +1 -1
  85. package/dist/wagmi/Connector.js +120 -27
  86. package/dist/wagmi/Connector.js.map +1 -1
  87. package/package.json +3 -2
  88. package/src/chains.ts +14 -15
  89. package/src/ox/KeyAuthorization.test.ts +1332 -0
  90. package/src/ox/KeyAuthorization.ts +542 -0
  91. package/src/ox/SignatureEnvelope.test.ts +624 -0
  92. package/src/ox/SignatureEnvelope.ts +89 -9
  93. package/src/ox/Transaction.test.ts +214 -0
  94. package/src/ox/Transaction.ts +13 -1
  95. package/src/ox/TransactionEnvelopeAA.test.ts +164 -4
  96. package/src/ox/TransactionEnvelopeAA.ts +36 -3
  97. package/src/ox/TransactionRequest.ts +22 -1
  98. package/src/ox/e2e.test.ts +612 -5
  99. package/src/ox/index.ts +1 -0
  100. package/src/prool/Instance.ts +1 -1
  101. package/src/prool/chain.json +238 -0
  102. package/src/server/Handler.test.ts +20 -36
  103. package/src/viem/Abis.ts +200 -7
  104. package/src/viem/Account.test.ts +444 -0
  105. package/src/viem/Account.ts +355 -42
  106. package/src/viem/Actions/account.ts +3 -5
  107. package/src/viem/Actions/amm.test.ts +4 -4
  108. package/src/viem/Actions/token.test.ts +8 -8
  109. package/src/viem/Actions/token.ts +2 -2
  110. package/src/viem/Addresses.ts +1 -1
  111. package/src/viem/Chain.test.ts +168 -0
  112. package/src/viem/Chain.ts +37 -1
  113. package/src/viem/Formatters.ts +8 -7
  114. package/src/viem/Storage.ts +22 -0
  115. package/src/viem/TokenIds.ts +1 -1
  116. package/src/viem/Transaction.ts +14 -2
  117. package/src/viem/WebAuthnP256.ts +8 -2
  118. package/src/viem/e2e.test.ts +299 -96
  119. package/src/wagmi/Actions/amm.test.ts +2 -2
  120. package/src/wagmi/Connector.test.ts +1 -1
  121. package/src/wagmi/Connector.ts +184 -54
  122. package/src/wagmi/Hooks/amm.test.ts +4 -4
  123. package/src/wagmi/Hooks/fee.test.ts +10 -4
  124. package/src/wagmi/Hooks/token.test.ts +0 -488
  125. package/dist/viem/internal/account.d.ts +0 -21
  126. package/dist/viem/internal/account.d.ts.map +0 -1
  127. package/dist/viem/internal/account.js +0 -61
  128. package/dist/viem/internal/account.js.map +0 -1
  129. package/src/viem/internal/account.ts +0 -89
@@ -1,3 +1,4 @@
1
+ import type * as Address from 'ox/Address'
1
2
  import * as Errors from 'ox/Errors'
2
3
  import * as Hex from 'ox/Hex'
3
4
  import * as Json from 'ox/Json'
@@ -10,11 +11,13 @@ import type {
10
11
  IsNarrowable,
11
12
  OneOf,
12
13
  PartialBy,
14
+ UnionPartialBy,
13
15
  } from '../internal/types.js'
14
16
 
15
17
  /** Signature type identifiers for encoding/decoding */
16
18
  const serializedP256Type = '0x01'
17
19
  const serializedWebAuthnType = '0x02'
20
+ const serializedKeychainType = '0x03'
18
21
 
19
22
  /**
20
23
  * Statically determines the signature type of an envelope at compile time.
@@ -53,7 +56,11 @@ export type GetType<
53
56
  signature: { r: bigint; s: bigint; yParity: number }
54
57
  }
55
58
  ? 'secp256k1'
56
- : never
59
+ : envelope extends {
60
+ userAddress: Address.Address
61
+ }
62
+ ? 'keychain'
63
+ : never
57
64
 
58
65
  /**
59
66
  * Represents a signature envelope that can contain different signature types.
@@ -67,12 +74,29 @@ export type SignatureEnvelope<bigintType = bigint, numberType = number> = OneOf<
67
74
  | Secp256k1<bigintType, numberType>
68
75
  | P256<bigintType, numberType>
69
76
  | WebAuthn<bigintType, numberType>
77
+ | Keychain<bigintType, numberType>
70
78
  >
71
79
 
72
80
  /**
73
81
  * RPC-formatted signature envelope.
74
82
  */
75
- export type SignatureEnvelopeRpc = OneOf<Secp256k1Rpc | P256Rpc | WebAuthnRpc>
83
+ export type SignatureEnvelopeRpc = OneOf<
84
+ Secp256k1Rpc | P256Rpc | WebAuthnRpc | KeychainRpc
85
+ >
86
+
87
+ export type Keychain<bigintType = bigint, numberType = number> = {
88
+ /** Root account address that this transaction is being executed for */
89
+ userAddress: Address.Address
90
+ /** The actual signature from the access key (can be Secp256k1, P256, or WebAuthn) */
91
+ inner: SignatureEnvelope<bigintType, numberType>
92
+ type: 'keychain'
93
+ }
94
+
95
+ export type KeychainRpc = {
96
+ type: 'keychain'
97
+ userAddress: Address.Address
98
+ signature: SignatureEnvelopeRpc
99
+ }
76
100
 
77
101
  export type P256<bigintType = bigint, numberType = number> = {
78
102
  prehash: boolean
@@ -159,7 +183,8 @@ export function assert(envelope: PartialBy<SignatureEnvelope, 'type'>): void {
159
183
  const type = getType(envelope)
160
184
 
161
185
  if (type === 'secp256k1') {
162
- Signature.assert(envelope.signature)
186
+ const secp256k1 = envelope as Secp256k1
187
+ Signature.assert(secp256k1.signature)
163
188
  return
164
189
  }
165
190
 
@@ -204,6 +229,12 @@ export function assert(envelope: PartialBy<SignatureEnvelope, 'type'>): void {
204
229
  throw new MissingPropertiesError({ envelope, missing, type: 'webAuthn' })
205
230
  return
206
231
  }
232
+
233
+ if (type === 'keychain') {
234
+ const keychain = envelope as Keychain
235
+ assert(keychain.inner)
236
+ return
237
+ }
207
238
  }
208
239
 
209
240
  export declare namespace assert {
@@ -233,7 +264,7 @@ export function deserialize(serialized: Serialized): SignatureEnvelope {
233
264
  if (size === 65) {
234
265
  const signature = Signature.fromHex(serialized)
235
266
  Signature.assert(signature)
236
- return { signature, type: 'secp256k1' }
267
+ return { signature, type: 'secp256k1' } satisfies Secp256k1
237
268
  }
238
269
 
239
270
  // For all other lengths, first byte is the type identifier
@@ -261,7 +292,7 @@ export function deserialize(serialized: Serialized): SignatureEnvelope {
261
292
  s: Hex.toBigInt(Hex.slice(data, 32, 64)),
262
293
  },
263
294
  type: 'p256',
264
- } as P256
295
+ } satisfies P256
265
296
  }
266
297
 
267
298
  if (typeId === serializedWebAuthnType) {
@@ -325,7 +356,18 @@ export function deserialize(serialized: Serialized): SignatureEnvelope {
325
356
  ),
326
357
  },
327
358
  type: 'webAuthn',
328
- } as WebAuthn
359
+ } satisfies WebAuthn
360
+ }
361
+
362
+ if (typeId === serializedKeychainType) {
363
+ const userAddress = Hex.slice(data, 0, 20)
364
+ const inner = deserialize(Hex.slice(data, 20))
365
+
366
+ return {
367
+ userAddress,
368
+ inner,
369
+ type: 'keychain',
370
+ } satisfies Keychain
329
371
  }
330
372
 
331
373
  throw new InvalidSerializedError({
@@ -361,7 +403,10 @@ export function from<const value extends from.Value>(
361
403
  }
362
404
 
363
405
  export declare namespace from {
364
- type Value = PartialBy<SignatureEnvelope, 'type'> | Secp256k1Flat | Serialized
406
+ type Value =
407
+ | UnionPartialBy<SignatureEnvelope, 'type'>
408
+ | Secp256k1Flat
409
+ | Serialized
365
410
 
366
411
  type ReturnValue<value extends Value> = Compute<
367
412
  OneOf<
@@ -451,6 +496,16 @@ export function fromRpc(envelope: SignatureEnvelopeRpc): SignatureEnvelope {
451
496
  }
452
497
  }
453
498
 
499
+ if (
500
+ envelope.type === 'keychain' ||
501
+ ('userAddress' in envelope && 'signature' in envelope)
502
+ )
503
+ return {
504
+ type: 'keychain',
505
+ userAddress: envelope.userAddress,
506
+ inner: fromRpc(envelope.signature),
507
+ }
508
+
454
509
  throw new CoercionError({ envelope })
455
510
  }
456
511
 
@@ -513,6 +568,10 @@ export function getType<
513
568
  )
514
569
  return 'webAuthn' as never
515
570
 
571
+ // Detect Keychain signature
572
+ if ('userAddress' in envelope && 'inner' in envelope)
573
+ return 'keychain' as never
574
+
516
575
  throw new CoercionError({
517
576
  envelope,
518
577
  })
@@ -531,12 +590,15 @@ export function getType<
531
590
  * @throws {CoercionError} If the envelope cannot be serialized.
532
591
  */
533
592
  export function serialize(
534
- envelope: PartialBy<SignatureEnvelope, 'prehash'>,
593
+ envelope: UnionPartialBy<SignatureEnvelope, 'prehash'>,
535
594
  ): Serialized {
536
595
  const type = getType(envelope)
537
596
 
538
597
  // Backward compatibility: no type identifier for secp256k1
539
- if (type === 'secp256k1') return Signature.toHex(envelope.signature)
598
+ if (type === 'secp256k1') {
599
+ const secp256k1 = envelope as Secp256k1
600
+ return Signature.toHex(secp256k1.signature)
601
+ }
540
602
 
541
603
  if (type === 'p256') {
542
604
  const p256 = envelope as P256
@@ -569,6 +631,15 @@ export function serialize(
569
631
  )
570
632
  }
571
633
 
634
+ if (type === 'keychain') {
635
+ const keychain = envelope as Keychain
636
+ return Hex.concat(
637
+ serializedKeychainType,
638
+ keychain.userAddress,
639
+ serialize(keychain.inner),
640
+ )
641
+ }
642
+
572
643
  throw new CoercionError({ envelope })
573
644
  }
574
645
 
@@ -618,6 +689,15 @@ export function toRpc(envelope: SignatureEnvelope): SignatureEnvelopeRpc {
618
689
  }
619
690
  }
620
691
 
692
+ if (type === 'keychain') {
693
+ const keychain = envelope as Keychain
694
+ return {
695
+ type: 'keychain',
696
+ userAddress: keychain.userAddress,
697
+ signature: toRpc(keychain.inner),
698
+ }
699
+ }
700
+
621
701
  throw new CoercionError({ envelope })
622
702
  }
623
703
 
@@ -152,6 +152,113 @@ describe('fromRpc', () => {
152
152
  }
153
153
  `)
154
154
  })
155
+
156
+ test('with keyAuthorization', () => {
157
+ const transaction = Transaction.fromRpc({
158
+ accessList: [],
159
+ calls: [
160
+ {
161
+ input: '0xdeadbeef',
162
+ to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
163
+ value: '0x9b6e64a8ec60000',
164
+ },
165
+ ],
166
+ keyAuthorization: {
167
+ expiry: '0xffffffffffff',
168
+ keyId: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
169
+ keyType: 'secp256k1',
170
+ limits: [
171
+ {
172
+ token: '0x20c0000000000000000000000000000000000001',
173
+ limit: '0x8ac7230489e80000',
174
+ },
175
+ ],
176
+ signature: {
177
+ r: '0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d',
178
+ s: '0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540',
179
+ type: 'secp256k1',
180
+ yParity: '0x0',
181
+ },
182
+ },
183
+ maxFeePerGas: '0x2',
184
+ maxPriorityFeePerGas: '0x1',
185
+ hash: '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
186
+ nonce: '0x357',
187
+ blockHash:
188
+ '0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
189
+ blockNumber: '0x12f296f',
190
+ transactionIndex: '0x2',
191
+ feeToken: '0x20c0000000000000000000000000000000000000',
192
+ from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
193
+ gas: '0x43f5d',
194
+ gasPrice: '0x2ca6ae494',
195
+ signature: {
196
+ r: '0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d',
197
+ s: '0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540',
198
+ v: '0x0',
199
+ type: 'secp256k1',
200
+ yParity: '0x0',
201
+ },
202
+ chainId: '0x1',
203
+ type: '0x76',
204
+ })
205
+
206
+ expect(transaction).toMatchInlineSnapshot(`
207
+ {
208
+ "accessList": [],
209
+ "blockHash": "0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b",
210
+ "blockNumber": 19868015n,
211
+ "calls": [
212
+ {
213
+ "data": "0xdeadbeef",
214
+ "to": "0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad",
215
+ "value": 700000000000000000n,
216
+ },
217
+ ],
218
+ "chainId": 1,
219
+ "data": undefined,
220
+ "feeToken": "0x20c0000000000000000000000000000000000000",
221
+ "from": "0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6",
222
+ "gas": 278365n,
223
+ "gasPrice": 11985937556n,
224
+ "hash": "0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0",
225
+ "keyAuthorization": {
226
+ "address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
227
+ "chainId": 0n,
228
+ "expiry": 281474976710655,
229
+ "limits": [
230
+ {
231
+ "limit": 10000000000000000000n,
232
+ "token": "0x20c0000000000000000000000000000000000001",
233
+ },
234
+ ],
235
+ "signature": {
236
+ "signature": {
237
+ "r": 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
238
+ "s": 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
239
+ "yParity": 0,
240
+ },
241
+ "type": "secp256k1",
242
+ },
243
+ "type": "secp256k1",
244
+ },
245
+ "maxFeePerGas": 2n,
246
+ "maxPriorityFeePerGas": 1n,
247
+ "nonce": 855n,
248
+ "signature": {
249
+ "signature": {
250
+ "r": 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
251
+ "s": 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
252
+ "yParity": 0,
253
+ },
254
+ "type": "secp256k1",
255
+ },
256
+ "transactionIndex": 2,
257
+ "type": "aa",
258
+ "value": 0n,
259
+ }
260
+ `)
261
+ })
155
262
  })
156
263
 
157
264
  describe('toRpc', () => {
@@ -306,4 +413,111 @@ describe('toRpc', () => {
306
413
  }
307
414
  `)
308
415
  })
416
+
417
+ test('with keyAuthorization', () => {
418
+ const transaction = Transaction.toRpc({
419
+ accessList: [],
420
+ blockHash:
421
+ '0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
422
+ blockNumber: 19868015n,
423
+ calls: [
424
+ {
425
+ data: '0xdeadbeef',
426
+ to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
427
+ value: 700000000000000000n,
428
+ },
429
+ ],
430
+ chainId: 1,
431
+ data: undefined,
432
+ keyAuthorization: {
433
+ address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
434
+ expiry: 281474976710655,
435
+ type: 'secp256k1',
436
+ limits: [
437
+ {
438
+ limit: 10000000000000000000n,
439
+ token: '0x20c0000000000000000000000000000000000001',
440
+ },
441
+ ],
442
+ signature: {
443
+ signature: {
444
+ r: 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
445
+ s: 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
446
+ yParity: 0,
447
+ },
448
+ type: 'secp256k1',
449
+ },
450
+ },
451
+ feeToken: '0x20c0000000000000000000000000000000000000',
452
+ from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
453
+ gas: 278365n,
454
+ gasPrice: 11985937556n,
455
+ hash: '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
456
+ maxFeePerGas: 2n,
457
+ maxPriorityFeePerGas: 1n,
458
+ nonce: 855n,
459
+ signature: {
460
+ signature: {
461
+ r: 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
462
+ s: 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
463
+ yParity: 0,
464
+ },
465
+ type: 'secp256k1',
466
+ },
467
+ transactionIndex: 2,
468
+ type: 'aa',
469
+ })
470
+ expect(transaction).toMatchInlineSnapshot(`
471
+ {
472
+ "accessList": [],
473
+ "blockHash": "0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b",
474
+ "blockNumber": "0x12f296f",
475
+ "calls": [
476
+ {
477
+ "data": "0xdeadbeef",
478
+ "to": "0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad",
479
+ "value": "0x9b6e64a8ec60000",
480
+ },
481
+ ],
482
+ "chainId": "0x1",
483
+ "feeToken": "0x20c0000000000000000000000000000000000000",
484
+ "from": "0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6",
485
+ "gas": "0x43f5d",
486
+ "gasPrice": "0x2ca6ae494",
487
+ "hash": "0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0",
488
+ "input": undefined,
489
+ "keyAuthorization": {
490
+ "chainId": "0x",
491
+ "expiry": "0xffffffffffff",
492
+ "keyId": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
493
+ "keyType": "secp256k1",
494
+ "limits": [
495
+ {
496
+ "limit": "0x8ac7230489e80000",
497
+ "token": "0x20c0000000000000000000000000000000000001",
498
+ },
499
+ ],
500
+ "signature": {
501
+ "r": "0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d",
502
+ "s": "0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540",
503
+ "type": "secp256k1",
504
+ "yParity": "0x0",
505
+ },
506
+ },
507
+ "maxFeePerGas": "0x2",
508
+ "maxPriorityFeePerGas": "0x1",
509
+ "nonce": "0x357",
510
+ "signature": {
511
+ "r": "0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d",
512
+ "s": "0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540",
513
+ "type": "secp256k1",
514
+ "yParity": "0x0",
515
+ },
516
+ "to": undefined,
517
+ "transactionIndex": "0x2",
518
+ "type": "0x76",
519
+ "value": "0x0",
520
+ }
521
+ `)
522
+ })
309
523
  })
@@ -6,6 +6,7 @@ import * as Hex from 'ox/Hex'
6
6
  import * as Signature from 'ox/Signature'
7
7
  import * as ox_Transaction from 'ox/Transaction'
8
8
  import type { Compute, OneOf, UnionCompute } from '../internal/types.js'
9
+ import * as KeyAuthorization from './KeyAuthorization.js'
9
10
  import * as SignatureEnvelope from './SignatureEnvelope.js'
10
11
  import type { Call } from './TransactionEnvelopeAA.js'
11
12
 
@@ -69,6 +70,10 @@ export type AA<
69
70
  feeToken: Address.Address
70
71
  /** Effective gas price paid by the sender in wei. */
71
72
  gasPrice?: bigintType | undefined
73
+ /** Key authorization for provisioning a new access key. */
74
+ keyAuthorization?:
75
+ | KeyAuthorization.KeyAuthorization<true, bigintType, numberType>
76
+ | undefined
72
77
  /** Total fee per gas in wei (gasPrice/baseFeePerGas + maxPriorityFeePerGas). */
73
78
  maxFeePerGas: bigintType
74
79
  /** Max priority fee per gas (in wei). */
@@ -90,7 +95,7 @@ export type AA<
90
95
  export type AARpc<pending extends boolean = false> = Compute<
91
96
  Omit<
92
97
  AA<pending, Hex.Hex, Hex.Hex, ToRpcType['aa']>,
93
- 'calls' | 'signature'
98
+ 'calls' | 'keyAuthorization' | 'signature'
94
99
  > & {
95
100
  calls:
96
101
  | readonly {
@@ -99,6 +104,7 @@ export type AARpc<pending extends boolean = false> = Compute<
99
104
  value?: Hex.Hex | undefined
100
105
  }[]
101
106
  | undefined
107
+ keyAuthorization?: KeyAuthorization.Rpc | undefined
102
108
  signature: SignatureEnvelope.SignatureEnvelopeRpc
103
109
  }
104
110
  >
@@ -200,6 +206,10 @@ export function fromRpc<
200
206
  transaction_.validAfter = Number(transaction.validAfter)
201
207
  if (transaction.validBefore)
202
208
  transaction_.validBefore = Number(transaction.validBefore)
209
+ if (transaction.keyAuthorization)
210
+ transaction_.keyAuthorization = KeyAuthorization.fromRpc(
211
+ transaction.keyAuthorization,
212
+ )
203
213
  if (transaction.feePayerSignature) {
204
214
  transaction_.feePayerSignature = Signature.fromRpc(
205
215
  transaction.feePayerSignature,
@@ -282,6 +292,8 @@ export function toRpc<pending extends boolean = false>(
282
292
  data: call.data,
283
293
  }))
284
294
  if (transaction.feeToken) rpc.feeToken = transaction.feeToken
295
+ if (transaction.keyAuthorization)
296
+ rpc.keyAuthorization = KeyAuthorization.toRpc(transaction.keyAuthorization)
285
297
  if (transaction.feePayerSignature) {
286
298
  rpc.feePayerSignature = Signature.toRpc(
287
299
  transaction.feePayerSignature,