tempo.ts 0.5.4 → 0.6.1

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 (43) hide show
  1. package/CHANGELOG.md +427 -0
  2. package/dist/ox/Transaction.d.ts +0 -2
  3. package/dist/ox/Transaction.d.ts.map +1 -1
  4. package/dist/ox/Transaction.js +0 -8
  5. package/dist/ox/Transaction.js.map +1 -1
  6. package/dist/ox/TransactionReceipt.d.ts +155 -0
  7. package/dist/ox/TransactionReceipt.d.ts.map +1 -0
  8. package/dist/ox/TransactionReceipt.js +136 -0
  9. package/dist/ox/TransactionReceipt.js.map +1 -0
  10. package/dist/prool/Instance.d.ts +2 -2
  11. package/dist/prool/Instance.d.ts.map +1 -1
  12. package/dist/prool/Instance.js +2 -2
  13. package/dist/prool/Instance.js.map +1 -1
  14. package/dist/viem/Chain.d.ts +25 -6
  15. package/dist/viem/Chain.d.ts.map +1 -1
  16. package/dist/viem/Chain.js +4 -1
  17. package/dist/viem/Chain.js.map +1 -1
  18. package/dist/viem/Formatters.d.ts +4 -3
  19. package/dist/viem/Formatters.d.ts.map +1 -1
  20. package/dist/viem/Formatters.js +8 -5
  21. package/dist/viem/Formatters.js.map +1 -1
  22. package/dist/viem/Transaction.d.ts +7 -2
  23. package/dist/viem/Transaction.d.ts.map +1 -1
  24. package/dist/viem/Transaction.js.map +1 -1
  25. package/dist/viem/internal/account.d.ts.map +1 -1
  26. package/dist/viem/internal/account.js +0 -8
  27. package/dist/viem/internal/account.js.map +1 -1
  28. package/dist/wagmi/Connector.d.ts +6 -0
  29. package/dist/wagmi/Connector.d.ts.map +1 -1
  30. package/dist/wagmi/Connector.js +26 -2
  31. package/dist/wagmi/Connector.js.map +1 -1
  32. package/package.json +3 -2
  33. package/src/ox/Transaction.test.ts +0 -3
  34. package/src/ox/Transaction.ts +0 -14
  35. package/src/ox/TransactionReceipt.ts +190 -0
  36. package/src/ox/e2e.test.ts +145 -106
  37. package/src/prool/Instance.ts +4 -4
  38. package/src/viem/Chain.ts +4 -0
  39. package/src/viem/Formatters.ts +13 -4
  40. package/src/viem/Transaction.ts +19 -1
  41. package/src/viem/e2e.test.ts +4 -16
  42. package/src/viem/internal/account.ts +0 -12
  43. package/src/wagmi/Connector.ts +29 -2
@@ -22,6 +22,7 @@ import {
22
22
  type Signature as viem_Signature,
23
23
  serializeTransaction as viem_serializeTransaction,
24
24
  type Transaction as viem_Transaction,
25
+ type TransactionReceipt as viem_TransactionReceipt,
25
26
  type TransactionRequest as viem_TransactionRequest,
26
27
  type TransactionSerializable as viem_TransactionSerializable,
27
28
  type TransactionSerialized as viem_TransactionSerialized,
@@ -30,6 +31,7 @@ import {
30
31
  import type { ExactPartial, OneOf, PartialBy } from '../internal/types.js'
31
32
  import * as SignatureEnvelope from '../ox/SignatureEnvelope.js'
32
33
  import * as TxAA from '../ox/TransactionEnvelopeAA.js'
34
+ import type * as ox_TransactionReceipt from '../ox/TransactionReceipt.js'
33
35
 
34
36
  export type Transaction<
35
37
  bigintType = bigint,
@@ -63,7 +65,6 @@ export type TransactionAA<
63
65
  calls: readonly TxAA.Call<quantity>[]
64
66
  chainId: index
65
67
  feeToken?: Address | undefined
66
- feePayer?: Address | undefined
67
68
  feePayerSignature?: viem_Signature | undefined
68
69
  nonceKey?: quantity | undefined
69
70
  signature: SignatureEnvelope.SignatureEnvelope
@@ -83,6 +84,23 @@ export type TransactionRequestRpc = OneOf<
83
84
  viem_RpcTransactionRequest | TransactionRequestAA<Hex.Hex, Hex.Hex, '0x76'>
84
85
  >
85
86
 
87
+ export type TransactionReceipt<
88
+ quantity = bigint,
89
+ index = number,
90
+ status = 'success' | 'reverted',
91
+ type = TransactionType,
92
+ > = viem_TransactionReceipt<quantity, index, status, type> & {
93
+ feePayer?: Address | undefined
94
+ feeToken?: Address | undefined
95
+ }
96
+
97
+ export type TransactionReceiptRpc = TransactionReceipt<
98
+ Hex.Hex,
99
+ Hex.Hex,
100
+ ox_TransactionReceipt.RpcStatus,
101
+ ox_TransactionReceipt.RpcType
102
+ >
103
+
86
104
  export type TransactionRequestAA<
87
105
  quantity = bigint,
88
106
  index = number,
@@ -45,6 +45,7 @@ describe('sendTransaction', () => {
45
45
  maxPriorityFeePerGas,
46
46
  nonce,
47
47
  signature,
48
+ transactionIndex,
48
49
  ...transaction
49
50
  } = await client.getTransaction({ hash })
50
51
 
@@ -59,6 +60,7 @@ describe('sendTransaction', () => {
59
60
  expect(maxPriorityFeePerGas).toBeDefined()
60
61
  expect(nonce).toBeDefined()
61
62
  expect(signature).toBeDefined()
63
+ expect(transactionIndex).toBeDefined()
62
64
  expect(transaction).toMatchInlineSnapshot(`
63
65
  {
64
66
  "aaAuthorizationList": [],
@@ -77,7 +79,6 @@ describe('sendTransaction', () => {
77
79
  "maxFeePerBlobGas": undefined,
78
80
  "nonceKey": 0n,
79
81
  "to": null,
80
- "transactionIndex": 1,
81
82
  "type": "aa",
82
83
  "typeHex": "0x76",
83
84
  "v": undefined,
@@ -118,6 +119,7 @@ describe('sendTransaction', () => {
118
119
  maxPriorityFeePerGas,
119
120
  nonce,
120
121
  signature,
122
+ transactionIndex,
121
123
  ...transaction
122
124
  } = await client.getTransaction({ hash })
123
125
 
@@ -133,6 +135,7 @@ describe('sendTransaction', () => {
133
135
  expect(maxPriorityFeePerGas).toBeDefined()
134
136
  expect(nonce).toBeDefined()
135
137
  expect(signature).toBeDefined()
138
+ expect(transactionIndex).toBeDefined()
136
139
  expect(transaction).toMatchInlineSnapshot(`
137
140
  {
138
141
  "aaAuthorizationList": [],
@@ -144,7 +147,6 @@ describe('sendTransaction', () => {
144
147
  "maxFeePerBlobGas": undefined,
145
148
  "nonceKey": 0n,
146
149
  "to": null,
147
- "transactionIndex": 1,
148
150
  "type": "aa",
149
151
  "typeHex": "0x76",
150
152
  "v": undefined,
@@ -171,7 +173,6 @@ describe('sendTransaction', () => {
171
173
  blockHash,
172
174
  blockNumber,
173
175
  chainId,
174
- feePayer: feePayer_,
175
176
  feePayerSignature,
176
177
  from,
177
178
  gas,
@@ -188,7 +189,6 @@ describe('sendTransaction', () => {
188
189
  expect(blockHash).toBeDefined()
189
190
  expect(blockNumber).toBeDefined()
190
191
  expect(chainId).toBeDefined()
191
- expect(feePayer_).toBe(feePayer.address.toLowerCase())
192
192
  expect(feePayerSignature).toBeDefined()
193
193
  expect(from).toBe(account.address.toLowerCase())
194
194
  expect(gas).toBeDefined()
@@ -396,7 +396,6 @@ describe('sendTransaction', () => {
396
396
  blockHash,
397
397
  blockNumber,
398
398
  chainId,
399
- feePayer: feePayer_,
400
399
  feePayerSignature,
401
400
  from,
402
401
  gas,
@@ -413,7 +412,6 @@ describe('sendTransaction', () => {
413
412
  expect(blockHash).toBeDefined()
414
413
  expect(blockNumber).toBeDefined()
415
414
  expect(chainId).toBeDefined()
416
- expect(feePayer_).toBe(feePayer.address.toLowerCase())
417
415
  expect(feePayerSignature).toBeDefined()
418
416
  expect(from).toBe(account.address.toLowerCase())
419
417
  expect(gas).toBeDefined()
@@ -799,7 +797,6 @@ describe('sendTransaction', () => {
799
797
  blockHash,
800
798
  blockNumber,
801
799
  chainId,
802
- feePayer: feePayer_,
803
800
  feePayerSignature,
804
801
  from,
805
802
  gas,
@@ -816,7 +813,6 @@ describe('sendTransaction', () => {
816
813
  expect(blockHash).toBeDefined()
817
814
  expect(blockNumber).toBeDefined()
818
815
  expect(chainId).toBeDefined()
819
- expect(feePayer_).toBe(feePayer.address.toLowerCase())
820
816
  expect(feePayerSignature).toBeDefined()
821
817
  expect(from).toBe(account.address.toLowerCase())
822
818
  expect(gas).toBeDefined()
@@ -888,7 +884,6 @@ describe('signTransaction', () => {
888
884
  blockHash,
889
885
  blockNumber,
890
886
  chainId,
891
- feePayer: feePayer_,
892
887
  feePayerSignature,
893
888
  from,
894
889
  gasPrice,
@@ -904,7 +899,6 @@ describe('signTransaction', () => {
904
899
  expect(blockHash).toBeDefined()
905
900
  expect(blockNumber).toBeDefined()
906
901
  expect(chainId).toBeDefined()
907
- expect(feePayer_).toBe(feePayer.address.toLowerCase())
908
902
  expect(feePayerSignature).toBeDefined()
909
903
  expect(from).toBe(account.address.toLowerCase())
910
904
  expect(gasPrice).toBeDefined()
@@ -1051,7 +1045,6 @@ describe('relay', () => {
1051
1045
  blockHash,
1052
1046
  blockNumber,
1053
1047
  chainId,
1054
- feePayer,
1055
1048
  feePayerSignature,
1056
1049
  from,
1057
1050
  gas,
@@ -1068,7 +1061,6 @@ describe('relay', () => {
1068
1061
  expect(blockHash).toBeDefined()
1069
1062
  expect(blockNumber).toBeDefined()
1070
1063
  expect(chainId).toBeDefined()
1071
- expect(feePayer).toBe(accounts[0].address.toLowerCase())
1072
1064
  expect(feePayerSignature).toBeDefined()
1073
1065
  expect(from).toBe(account.address.toLowerCase())
1074
1066
  expect(gas).toBeDefined()
@@ -1132,7 +1124,6 @@ describe('relay', () => {
1132
1124
  blockHash,
1133
1125
  blockNumber,
1134
1126
  chainId,
1135
- feePayer,
1136
1127
  feePayerSignature,
1137
1128
  from,
1138
1129
  gas,
@@ -1149,7 +1140,6 @@ describe('relay', () => {
1149
1140
  expect(blockHash).toBeDefined()
1150
1141
  expect(blockNumber).toBeDefined()
1151
1142
  expect(chainId).toBeDefined()
1152
- expect(feePayer).toBe(accounts[0].address.toLowerCase())
1153
1143
  expect(feePayerSignature).toBeDefined()
1154
1144
  expect(from).toBe(account.address.toLowerCase())
1155
1145
  expect(gas).toBeDefined()
@@ -1244,7 +1234,6 @@ describe('relay', () => {
1244
1234
  blockHash,
1245
1235
  blockNumber,
1246
1236
  chainId,
1247
- feePayer,
1248
1237
  feePayerSignature,
1249
1238
  from,
1250
1239
  gas,
@@ -1261,7 +1250,6 @@ describe('relay', () => {
1261
1250
  expect(blockHash).toBeDefined()
1262
1251
  expect(blockNumber).toBeDefined()
1263
1252
  expect(chainId).toBeDefined()
1264
- expect(feePayer).toBe(accounts[0].address.toLowerCase())
1265
1253
  expect(feePayerSignature).toBeDefined()
1266
1254
  expect(from).toBe(account.address.toLowerCase())
1267
1255
  expect(gas).toBeDefined()
@@ -52,12 +52,6 @@ export function toPrivateKeyAccount(
52
52
  const { message } = parameters
53
53
  const signature = await sign({ hash: hashMessage(message) })
54
54
  const envelope = SignatureEnvelope.from(signature)
55
- if (envelope.type !== 'secp256k1')
56
- throw new Error(
57
- 'Unsupported signature type. Expected `secp256k1` but got `' +
58
- envelope.type +
59
- '`.',
60
- )
61
55
  return SignatureEnvelope.serialize(envelope)
62
56
  },
63
57
  async signTransaction(transaction, options) {
@@ -71,12 +65,6 @@ export function toPrivateKeyAccount(
71
65
  async signTypedData(typedData) {
72
66
  const signature = await sign({ hash: hashTypedData(typedData) })
73
67
  const envelope = SignatureEnvelope.from(signature)
74
- if (envelope.type !== 'secp256k1')
75
- throw new Error(
76
- 'Unsupported signature type. Expected `secp256k1` but got `' +
77
- envelope.type +
78
- '`.',
79
- )
80
68
  return SignatureEnvelope.serialize(envelope)
81
69
  },
82
70
  publicKey,
@@ -296,8 +296,14 @@ export function webAuthn(options: webAuthn.Parameters = {}) {
296
296
  })
297
297
  }
298
298
 
299
- config.storage?.setItem('webAuthn.activeCredential', credential)
300
- config.storage?.setItem('webAuthn.lastActiveCredential', credential)
299
+ config.storage?.setItem(
300
+ 'webAuthn.activeCredential',
301
+ normalizeValue(credential),
302
+ )
303
+ config.storage?.setItem(
304
+ 'webAuthn.lastActiveCredential',
305
+ normalizeValue(credential),
306
+ )
301
307
  return Account.fromWebAuthnP256(credential)
302
308
  })()
303
309
 
@@ -399,3 +405,24 @@ export declare namespace webAuthn {
399
405
  rpId?: string | undefined
400
406
  }
401
407
  }
408
+
409
+ /**
410
+ * Normalizes a value into a structured-clone compatible format.
411
+ *
412
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/structuredClone
413
+ */
414
+ export function normalizeValue<type>(value: type): type {
415
+ if (Array.isArray(value)) return value.map(normalizeValue) as never
416
+ if (typeof value === 'function') return undefined as never
417
+ if (typeof value !== 'object' || value === null) return value
418
+ if (Object.getPrototypeOf(value) !== Object.prototype)
419
+ try {
420
+ return structuredClone(value)
421
+ } catch {
422
+ return undefined as never
423
+ }
424
+
425
+ const normalized: Record<string, unknown> = {}
426
+ for (const [k, v] of Object.entries(value)) normalized[k] = normalizeValue(v)
427
+ return normalized as never
428
+ }