tempo.ts 0.7.5 → 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 (147) hide show
  1. package/CHANGELOG.md +32 -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 +84 -32
  45. package/dist/viem/Actions/amm.d.ts.map +1 -1
  46. package/dist/viem/Actions/amm.js +12 -32
  47. package/dist/viem/Actions/amm.js.map +1 -1
  48. package/dist/viem/Actions/dex.d.ts +156 -4
  49. package/dist/viem/Actions/dex.d.ts.map +1 -1
  50. package/dist/viem/Actions/fee.d.ts +4 -0
  51. package/dist/viem/Actions/fee.d.ts.map +1 -1
  52. package/dist/viem/Actions/reward.d.ts +78 -0
  53. package/dist/viem/Actions/reward.d.ts.map +1 -1
  54. package/dist/viem/Actions/token.d.ts +585 -0
  55. package/dist/viem/Actions/token.d.ts.map +1 -1
  56. package/dist/viem/Actions/token.js +2 -2
  57. package/dist/viem/Actions/token.js.map +1 -1
  58. package/dist/viem/Addresses.d.ts +1 -1
  59. package/dist/viem/Addresses.d.ts.map +1 -1
  60. package/dist/viem/Addresses.js +1 -1
  61. package/dist/viem/Addresses.js.map +1 -1
  62. package/dist/viem/Chain.d.ts +35 -0
  63. package/dist/viem/Chain.d.ts.map +1 -1
  64. package/dist/viem/Chain.js +37 -0
  65. package/dist/viem/Chain.js.map +1 -1
  66. package/dist/viem/Decorator.d.ts +193 -16
  67. package/dist/viem/Decorator.d.ts.map +1 -1
  68. package/dist/viem/Decorator.js +7 -0
  69. package/dist/viem/Decorator.js.map +1 -1
  70. package/dist/viem/Formatters.d.ts.map +1 -1
  71. package/dist/viem/Formatters.js +8 -7
  72. package/dist/viem/Formatters.js.map +1 -1
  73. package/dist/viem/Storage.d.ts +1 -0
  74. package/dist/viem/Storage.d.ts.map +1 -1
  75. package/dist/viem/Storage.js +21 -0
  76. package/dist/viem/Storage.js.map +1 -1
  77. package/dist/viem/TokenIds.d.ts +1 -1
  78. package/dist/viem/TokenIds.d.ts.map +1 -1
  79. package/dist/viem/TokenIds.js +1 -1
  80. package/dist/viem/TokenIds.js.map +1 -1
  81. package/dist/viem/Transaction.d.ts +9 -1
  82. package/dist/viem/Transaction.d.ts.map +1 -1
  83. package/dist/viem/Transaction.js +2 -1
  84. package/dist/viem/Transaction.js.map +1 -1
  85. package/dist/viem/WebAuthnP256.d.ts +4 -1
  86. package/dist/viem/WebAuthnP256.d.ts.map +1 -1
  87. package/dist/viem/WebAuthnP256.js +3 -1
  88. package/dist/viem/WebAuthnP256.js.map +1 -1
  89. package/dist/wagmi/Actions/amm.d.ts +6 -16
  90. package/dist/wagmi/Actions/amm.d.ts.map +1 -1
  91. package/dist/wagmi/Actions/amm.js +6 -16
  92. package/dist/wagmi/Actions/amm.js.map +1 -1
  93. package/dist/wagmi/Connector.d.ts +25 -8
  94. package/dist/wagmi/Connector.d.ts.map +1 -1
  95. package/dist/wagmi/Connector.js +120 -27
  96. package/dist/wagmi/Connector.js.map +1 -1
  97. package/dist/wagmi/Hooks/amm.d.ts +6 -16
  98. package/dist/wagmi/Hooks/amm.d.ts.map +1 -1
  99. package/dist/wagmi/Hooks/amm.js +6 -16
  100. package/dist/wagmi/Hooks/amm.js.map +1 -1
  101. package/package.json +3 -2
  102. package/src/chains.ts +14 -15
  103. package/src/ox/KeyAuthorization.test.ts +1332 -0
  104. package/src/ox/KeyAuthorization.ts +542 -0
  105. package/src/ox/SignatureEnvelope.test.ts +624 -0
  106. package/src/ox/SignatureEnvelope.ts +89 -9
  107. package/src/ox/Transaction.test.ts +214 -0
  108. package/src/ox/Transaction.ts +13 -1
  109. package/src/ox/TransactionEnvelopeAA.test.ts +164 -4
  110. package/src/ox/TransactionEnvelopeAA.ts +36 -3
  111. package/src/ox/TransactionRequest.ts +22 -1
  112. package/src/ox/e2e.test.ts +612 -5
  113. package/src/ox/index.ts +1 -0
  114. package/src/prool/Instance.ts +1 -1
  115. package/src/prool/chain.json +238 -0
  116. package/src/server/Handler.test.ts +20 -36
  117. package/src/viem/Abis.ts +200 -7
  118. package/src/viem/Account.test.ts +444 -0
  119. package/src/viem/Account.ts +355 -42
  120. package/src/viem/Actions/account.ts +3 -5
  121. package/src/viem/Actions/amm.test.ts +220 -1
  122. package/src/viem/Actions/amm.ts +12 -32
  123. package/src/viem/Actions/token.test.ts +8 -8
  124. package/src/viem/Actions/token.ts +2 -2
  125. package/src/viem/Addresses.ts +1 -1
  126. package/src/viem/Chain.test.ts +168 -0
  127. package/src/viem/Chain.ts +37 -1
  128. package/src/viem/Decorator.ts +214 -16
  129. package/src/viem/Formatters.ts +8 -7
  130. package/src/viem/Storage.ts +22 -0
  131. package/src/viem/TokenIds.ts +1 -1
  132. package/src/viem/Transaction.ts +14 -2
  133. package/src/viem/WebAuthnP256.ts +8 -2
  134. package/src/viem/e2e.test.ts +299 -96
  135. package/src/wagmi/Actions/amm.test.ts +93 -2
  136. package/src/wagmi/Actions/amm.ts +6 -16
  137. package/src/wagmi/Connector.test.ts +1 -1
  138. package/src/wagmi/Connector.ts +184 -54
  139. package/src/wagmi/Hooks/amm.test.ts +335 -0
  140. package/src/wagmi/Hooks/amm.ts +6 -16
  141. package/src/wagmi/Hooks/fee.test.ts +10 -4
  142. package/src/wagmi/Hooks/token.test.ts +0 -488
  143. package/dist/viem/internal/account.d.ts +0 -21
  144. package/dist/viem/internal/account.d.ts.map +0 -1
  145. package/dist/viem/internal/account.js +0 -61
  146. package/dist/viem/internal/account.js.map +0 -1
  147. package/src/viem/internal/account.ts +0 -89
@@ -1,6 +1,7 @@
1
- import { Hex, P256, Rlp, Secp256k1, Value } from 'ox'
1
+ import { Hex, P256, Rlp, Secp256k1, Value, WebAuthnP256 } from 'ox'
2
2
  import { describe, expect, test } from 'vitest'
3
3
  import { SignatureEnvelope } from './index.js'
4
+ import * as KeyAuthorization from './KeyAuthorization.js'
4
5
  import * as TransactionEnvelopeAA from './TransactionEnvelopeAA.js'
5
6
 
6
7
  const privateKey =
@@ -254,6 +255,37 @@ describe('deserialize', () => {
254
255
  )
255
256
  })
256
257
 
258
+ test('keyAuthorization', () => {
259
+ const keyAuthorization = KeyAuthorization.from({
260
+ expiry: 1234567890,
261
+ address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
262
+ type: 'secp256k1',
263
+ limits: [
264
+ {
265
+ token: '0x20c0000000000000000000000000000000000001',
266
+ limit: Value.from('10', 6),
267
+ },
268
+ ],
269
+ signature: SignatureEnvelope.from({
270
+ r: 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
271
+ s: 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
272
+ yParity: 0,
273
+ }),
274
+ })
275
+
276
+ const transaction_keyAuthorization = TransactionEnvelopeAA.from({
277
+ ...transaction,
278
+ keyAuthorization,
279
+ })
280
+
281
+ const serialized = TransactionEnvelopeAA.serialize(
282
+ transaction_keyAuthorization,
283
+ )
284
+ expect(TransactionEnvelopeAA.deserialize(serialized)).toEqual(
285
+ transaction_keyAuthorization,
286
+ )
287
+ })
288
+
257
289
  describe('signature', () => {
258
290
  test('secp256k1', () => {
259
291
  const signature = Secp256k1.sign({
@@ -456,7 +488,7 @@ describe('deserialize', () => {
456
488
  [TransactionEnvelope.InvalidSerializedError: Invalid serialized transaction of type "aa" was provided.
457
489
 
458
490
  Serialized Transaction: "0x76c0"
459
- Missing Attributes: chainId, maxPriorityFeePerGas, maxFeePerGas, gas, calls, accessList, nonceKey, nonce, validBefore, validAfter, feeToken, feePayerSignatureOrSender]
491
+ Missing Attributes: chainId, maxPriorityFeePerGas, maxFeePerGas, gas, calls, accessList, keyAuthorization, nonceKey, nonce, validBefore, validAfter, feeToken, feePayerSignatureOrSender]
460
492
  `)
461
493
  })
462
494
 
@@ -469,7 +501,7 @@ describe('deserialize', () => {
469
501
  [TransactionEnvelope.InvalidSerializedError: Invalid serialized transaction of type "aa" was provided.
470
502
 
471
503
  Serialized Transaction: "0x76c20001"
472
- Missing Attributes: maxFeePerGas, gas, calls, accessList, nonceKey, nonce, validBefore, validAfter, feeToken, feePayerSignatureOrSender]
504
+ Missing Attributes: maxFeePerGas, gas, calls, accessList, keyAuthorization, nonceKey, nonce, validBefore, validAfter, feeToken, feePayerSignatureOrSender]
473
505
  `)
474
506
  })
475
507
 
@@ -520,6 +552,7 @@ describe('deserialize', () => {
520
552
  '0x', // feeToken
521
553
  '0x', // feePayerSignature
522
554
  [], // authorizationList
555
+ [], // keyAuthorization
523
556
  '0x1234', // signature
524
557
  '0x5678', // extra field
525
558
  ]).slice(2)}`,
@@ -527,7 +560,7 @@ describe('deserialize', () => {
527
560
  ).toThrowErrorMatchingInlineSnapshot(`
528
561
  [TransactionEnvelope.InvalidSerializedError: Invalid serialized transaction of type "aa" was provided.
529
562
 
530
- Serialized Transaction: "0x76eb01010101d8d7940000000000000000000000000000000000000000008080000080808080c0821234825678"]
563
+ Serialized Transaction: "0x76ec01010101d8d7940000000000000000000000000000000000000000008080000080808080c0c0821234825678"]
531
564
  `)
532
565
  })
533
566
  })
@@ -764,6 +797,133 @@ describe('serialize', () => {
764
797
  )
765
798
  })
766
799
 
800
+ test('keyAuthorization (secp256k1)', () => {
801
+ const keyAuthorization = KeyAuthorization.from({
802
+ address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
803
+ expiry: 1234567890,
804
+ type: 'secp256k1',
805
+ limits: [
806
+ {
807
+ token: '0x20c0000000000000000000000000000000000001',
808
+ limit: Value.from('10', 6),
809
+ },
810
+ ],
811
+ signature: SignatureEnvelope.from({
812
+ r: 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
813
+ s: 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
814
+ yParity: 0,
815
+ }),
816
+ })
817
+
818
+ const transaction = TransactionEnvelopeAA.from({
819
+ chainId: 1,
820
+ calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' }],
821
+ nonce: 0n,
822
+ keyAuthorization,
823
+ })
824
+
825
+ const serialized = TransactionEnvelopeAA.serialize(transaction)
826
+ expect(serialized).toMatchInlineSnapshot(
827
+ `"0x76f8a201808080d8d79470997970c51812dc3a010c7d01b50e0d17dc79c88080c0808080808080c0f87bf7808094be95c3f554e9fc85ec51be69a3d807a0d55bcf2c84499602d2dad99420c000000000000000000000000000000000000183989680b841635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f05401b"`,
828
+ )
829
+
830
+ const deserialized = TransactionEnvelopeAA.deserialize(serialized)
831
+ expect(deserialized.keyAuthorization).toEqual(keyAuthorization)
832
+ })
833
+
834
+ test('keyAuthorization (p256)', () => {
835
+ const keyAuthorization = KeyAuthorization.from({
836
+ address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
837
+ expiry: 1234567890,
838
+ type: 'p256',
839
+ limits: [
840
+ {
841
+ token: '0x20c0000000000000000000000000000000000001',
842
+ limit: Value.from('10', 6),
843
+ },
844
+ ],
845
+ signature: SignatureEnvelope.from({
846
+ signature: {
847
+ r: 92602584010956101470289867944347135737570451066466093224269890121909314569518n,
848
+ s: 54171125190222965779385658110416711469231271457324878825831748147306957269813n,
849
+ },
850
+ publicKey: {
851
+ prefix: 4,
852
+ x: 78495282704852028275327922540131762143565388050940484317945369745559774511861n,
853
+ y: 8109764566587999957624872393871720746996669263962991155166704261108473113504n,
854
+ },
855
+ prehash: true,
856
+ }),
857
+ })
858
+
859
+ const transaction = TransactionEnvelopeAA.from({
860
+ chainId: 1,
861
+ calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' }],
862
+ nonce: 0n,
863
+ keyAuthorization,
864
+ })
865
+
866
+ const serialized = TransactionEnvelopeAA.serialize(transaction)
867
+ expect(serialized).toMatchInlineSnapshot(
868
+ `"0x76f8e301808080d8d79470997970c51812dc3a010c7d01b50e0d17dc79c88080c0808080808080c0f8bcf7800194be95c3f554e9fc85ec51be69a3d807a0d55bcf2c84499602d2dad99420c000000000000000000000000000000000000183989680b88201ccbb3485d4726235f13cb15ef394fb7158179fb7b1925eccec0147671090c52e77c3c53373cc1e3b05e7c23f609deb17cea8fe097300c45411237e9fe4166b35ad8ac16e167d6992c3e120d7f17d2376bc1cbcf30c46ba6dd00ce07303e742f511edf6ce1c32de66846f56afa7be1cbd729bc35750b6d0cdcf3ec9d75461aba001"`,
869
+ )
870
+
871
+ const deserialized = TransactionEnvelopeAA.deserialize(serialized)
872
+ expect(deserialized.keyAuthorization).toEqual(keyAuthorization)
873
+ })
874
+
875
+ test('keyAuthorization (webAuthn)', () => {
876
+ const metadata = {
877
+ authenticatorData: WebAuthnP256.getAuthenticatorData({
878
+ rpId: 'localhost',
879
+ }),
880
+ clientDataJSON: WebAuthnP256.getClientDataJSON({
881
+ challenge: '0xdeadbeef',
882
+ origin: 'http://localhost',
883
+ }),
884
+ }
885
+
886
+ const keyAuthorization = KeyAuthorization.from({
887
+ address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
888
+ expiry: 1234567890,
889
+ type: 'webAuthn',
890
+ limits: [
891
+ {
892
+ token: '0x20c0000000000000000000000000000000000001',
893
+ limit: Value.from('10', 6),
894
+ },
895
+ ],
896
+ signature: SignatureEnvelope.from({
897
+ signature: {
898
+ r: 92602584010956101470289867944347135737570451066466093224269890121909314569518n,
899
+ s: 54171125190222965779385658110416711469231271457324878825831748147306957269813n,
900
+ },
901
+ publicKey: {
902
+ prefix: 4,
903
+ x: 78495282704852028275327922540131762143565388050940484317945369745559774511861n,
904
+ y: 8109764566587999957624872393871720746996669263962991155166704261108473113504n,
905
+ },
906
+ metadata,
907
+ }),
908
+ })
909
+
910
+ const transaction = TransactionEnvelopeAA.from({
911
+ chainId: 1,
912
+ calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' }],
913
+ nonce: 0n,
914
+ keyAuthorization,
915
+ })
916
+
917
+ const serialized = TransactionEnvelopeAA.serialize(transaction)
918
+ expect(serialized).toMatchInlineSnapshot(
919
+ `"0x76f9016501808080d8d79470997970c51812dc3a010c7d01b50e0d17dc79c88080c0808080808080c0f9013df7800294be95c3f554e9fc85ec51be69a3d807a0d55bcf2c84499602d2dad99420c000000000000000000000000000000000000183989680b901020249960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d976305000000007b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a223371322d3777222c226f726967696e223a22687474703a2f2f6c6f63616c686f7374222c2263726f73734f726967696e223a66616c73657dccbb3485d4726235f13cb15ef394fb7158179fb7b1925eccec0147671090c52e77c3c53373cc1e3b05e7c23f609deb17cea8fe097300c45411237e9fe4166b35ad8ac16e167d6992c3e120d7f17d2376bc1cbcf30c46ba6dd00ce07303e742f511edf6ce1c32de66846f56afa7be1cbd729bc35750b6d0cdcf3ec9d75461aba0"`,
920
+ )
921
+
922
+ // Verify roundtrip
923
+ const deserialized = TransactionEnvelopeAA.deserialize(serialized)
924
+ expect(deserialized.keyAuthorization).toEqual(keyAuthorization)
925
+ })
926
+
767
927
  describe('with signature', () => {
768
928
  test('secp256k1', () => {
769
929
  const transaction = TransactionEnvelopeAA.from({
@@ -14,6 +14,7 @@ import type {
14
14
  PartialBy,
15
15
  UnionPartialBy,
16
16
  } from '../internal/types.js'
17
+ import * as KeyAuthorization from './KeyAuthorization.js'
17
18
  import * as SignatureEnvelope from './SignatureEnvelope.js'
18
19
  import * as TokenId from './TokenId.js'
19
20
 
@@ -57,6 +58,16 @@ export type TransactionEnvelopeAA<
57
58
  | undefined
58
59
  /** Fee token preference. Address or ID of the TIP-20 token. */
59
60
  feeToken?: TokenId.TokenIdOrAddress | undefined
61
+ /**
62
+ * Key authorization for provisioning a new access key.
63
+ *
64
+ * When present, this transaction will add the specified key to the AccountKeychain precompile,
65
+ * before verifying the transaction signature.
66
+ * The authorization must be signed with the root key, the tx can be signed by the Keychain signature.
67
+ */
68
+ keyAuthorization?:
69
+ | KeyAuthorization.Signed<bigintType, numberType>
70
+ | undefined
60
71
  /** Total fee per gas in wei (gasPrice/baseFeePerGas + maxPriorityFeePerGas). */
61
72
  maxFeePerGas?: bigintType | undefined
62
73
  /** Max priority fee per gas (in wei). */
@@ -216,10 +227,24 @@ export function deserialize(
216
227
  feeToken,
217
228
  feePayerSignatureOrSender,
218
229
  _authorizationList, // TODO: add
219
- signature,
230
+ keyAuthorizationOrSignature,
231
+ maybeSignature,
220
232
  ] = transactionArray as readonly Hex.Hex[]
221
233
 
222
- if (!(transactionArray.length === 13 || transactionArray.length === 14))
234
+ const keyAuthorization = Array.isArray(keyAuthorizationOrSignature)
235
+ ? keyAuthorizationOrSignature
236
+ : undefined
237
+ const signature = keyAuthorization
238
+ ? maybeSignature
239
+ : keyAuthorizationOrSignature
240
+
241
+ if (
242
+ !(
243
+ transactionArray.length === 13 ||
244
+ transactionArray.length === 14 ||
245
+ transactionArray.length === 15
246
+ )
247
+ )
223
248
  throw new TransactionEnvelope.InvalidSerializedError({
224
249
  attributes: {
225
250
  chainId,
@@ -228,6 +253,7 @@ export function deserialize(
228
253
  gas,
229
254
  calls,
230
255
  accessList,
256
+ keyAuthorization,
231
257
  nonceKey,
232
258
  nonce,
233
259
  validBefore,
@@ -296,6 +322,11 @@ export function deserialize(
296
322
  )
297
323
  }
298
324
 
325
+ if (keyAuthorization)
326
+ transaction.keyAuthorization = KeyAuthorization.fromTuple(
327
+ keyAuthorization as never,
328
+ )
329
+
299
330
  const signatureEnvelope = signature
300
331
  ? SignatureEnvelope.deserialize(signature)
301
332
  : undefined
@@ -516,6 +547,7 @@ export function serialize(
516
547
  chainId,
517
548
  feeToken,
518
549
  gas,
550
+ keyAuthorization,
519
551
  nonce,
520
552
  nonceKey,
521
553
  maxFeePerGas,
@@ -562,7 +594,8 @@ export function serialize(
562
594
  ? TokenId.toAddress(feeToken)
563
595
  : '0x',
564
596
  feePayerSignatureOrSender,
565
- [], // TODO: authlist
597
+ [], // TODO: authList
598
+ ...(keyAuthorization ? [KeyAuthorization.toTuple(keyAuthorization)] : []),
566
599
  ...(signature
567
600
  ? [SignatureEnvelope.serialize(SignatureEnvelope.from(signature))]
568
601
  : []),
@@ -3,6 +3,7 @@ import type * as Errors from 'ox/Errors'
3
3
  import * as Hex from 'ox/Hex'
4
4
  import * as ox_TransactionRequest from 'ox/TransactionRequest'
5
5
  import type { Compute } from '../internal/types.js'
6
+ import * as KeyAuthorization from './KeyAuthorization.js'
6
7
  import * as TokenId from './TokenId.js'
7
8
  import * as Transaction from './Transaction.js'
8
9
  import type { Call } from './TransactionEnvelopeAA.js'
@@ -17,16 +18,24 @@ export type TransactionRequest<
17
18
  > = Compute<
18
19
  ox_TransactionRequest.TransactionRequest<bigintType, numberType, type> & {
19
20
  calls?: readonly Call<bigintType>[] | undefined
21
+ keyAuthorization?: KeyAuthorization.KeyAuthorization<true> | undefined
20
22
  keyData?: Hex.Hex | undefined
21
23
  keyType?: KeyType | undefined
22
24
  feeToken?: TokenId.TokenIdOrAddress | undefined
25
+ nonceKey?: 'random' | bigintType | undefined
23
26
  validBefore?: numberType | undefined
24
27
  validAfter?: numberType | undefined
25
28
  }
26
29
  >
27
30
 
28
31
  /** RPC representation of a {@link ox#TransactionRequest.TransactionRequest}. */
29
- export type Rpc = TransactionRequest<Hex.Hex, Hex.Hex, string>
32
+ export type Rpc = Omit<
33
+ TransactionRequest<Hex.Hex, Hex.Hex, string>,
34
+ 'keyAuthorization'
35
+ > & {
36
+ keyAuthorization?: KeyAuthorization.Rpc | undefined
37
+ nonceKey?: Hex.Hex | undefined
38
+ }
30
39
 
31
40
  /**
32
41
  * Converts a {@link ox#TransactionRequest.TransactionRequest} to a {@link ox#TransactionRequest.Rpc}.
@@ -82,11 +91,23 @@ export function toRpc(request: TransactionRequest): Rpc {
82
91
  }))
83
92
  if (typeof request.feeToken !== 'undefined')
84
93
  request_rpc.feeToken = TokenId.toAddress(request.feeToken)
94
+ if (request.keyAuthorization)
95
+ request_rpc.keyAuthorization = KeyAuthorization.toRpc(
96
+ request.keyAuthorization,
97
+ )
85
98
  if (typeof request.validBefore !== 'undefined')
86
99
  request_rpc.validBefore = Hex.fromNumber(request.validBefore)
87
100
  if (typeof request.validAfter !== 'undefined')
88
101
  request_rpc.validAfter = Hex.fromNumber(request.validAfter)
89
102
 
103
+ const nonceKey = (() => {
104
+ if (request.nonceKey === 'random') return Hex.random(6)
105
+ if (typeof request.nonceKey === 'bigint')
106
+ return Hex.fromNumber(request.nonceKey)
107
+ return undefined
108
+ })()
109
+ if (nonceKey) request_rpc.nonceKey = nonceKey
110
+
90
111
  if (
91
112
  request.calls ||
92
113
  typeof request.feeToken !== 'undefined' ||