tempo.ts 0.8.3 → 0.9.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 (48) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/ox/KeyAuthorization.d.ts +3 -3
  3. package/dist/ox/KeyAuthorization.js +2 -2
  4. package/dist/ox/Transaction.d.ts +8 -8
  5. package/dist/ox/Transaction.d.ts.map +1 -1
  6. package/dist/ox/Transaction.js +3 -3
  7. package/dist/ox/Transaction.js.map +1 -1
  8. package/dist/ox/{TransactionEnvelopeAA.d.ts → TransactionEnvelopeTempo.d.ts} +70 -70
  9. package/dist/ox/TransactionEnvelopeTempo.d.ts.map +1 -0
  10. package/dist/ox/{TransactionEnvelopeAA.js → TransactionEnvelopeTempo.js} +57 -57
  11. package/dist/ox/TransactionEnvelopeTempo.js.map +1 -0
  12. package/dist/ox/TransactionReceipt.d.ts +3 -3
  13. package/dist/ox/TransactionReceipt.d.ts.map +1 -1
  14. package/dist/ox/TransactionReceipt.js +2 -2
  15. package/dist/ox/TransactionReceipt.js.map +1 -1
  16. package/dist/ox/TransactionRequest.d.ts +1 -1
  17. package/dist/ox/TransactionRequest.d.ts.map +1 -1
  18. package/dist/ox/TransactionRequest.js +2 -2
  19. package/dist/ox/TransactionRequest.js.map +1 -1
  20. package/dist/ox/index.d.ts +1 -1
  21. package/dist/ox/index.d.ts.map +1 -1
  22. package/dist/ox/index.js +1 -1
  23. package/dist/ox/index.js.map +1 -1
  24. package/dist/viem/Chain.d.ts +3 -3
  25. package/dist/viem/Formatters.js +4 -4
  26. package/dist/viem/Formatters.js.map +1 -1
  27. package/dist/viem/Transaction.d.ts +17 -17
  28. package/dist/viem/Transaction.d.ts.map +1 -1
  29. package/dist/viem/Transaction.js +16 -16
  30. package/dist/viem/Transaction.js.map +1 -1
  31. package/dist/viem/internal/types.d.ts +2 -2
  32. package/dist/viem/internal/types.d.ts.map +1 -1
  33. package/package.json +1 -1
  34. package/src/ox/KeyAuthorization.ts +3 -3
  35. package/src/ox/Transaction.test.ts +6 -6
  36. package/src/ox/Transaction.ts +11 -11
  37. package/src/ox/{TransactionEnvelopeAA.test.ts → TransactionEnvelopeTempo.test.ts} +154 -139
  38. package/src/ox/{TransactionEnvelopeAA.ts → TransactionEnvelopeTempo.ts} +78 -76
  39. package/src/ox/TransactionReceipt.ts +3 -3
  40. package/src/ox/TransactionRequest.ts +3 -3
  41. package/src/ox/e2e.test.ts +79 -70
  42. package/src/ox/index.ts +1 -1
  43. package/src/viem/Formatters.ts +6 -6
  44. package/src/viem/Transaction.ts +43 -40
  45. package/src/viem/e2e.test.ts +14 -14
  46. package/src/viem/internal/types.ts +2 -2
  47. package/dist/ox/TransactionEnvelopeAA.d.ts.map +0 -1
  48. package/dist/ox/TransactionEnvelopeAA.js.map +0 -1
@@ -12,7 +12,7 @@ import { chainId } from '../../test/config.js'
12
12
  import { client, fundAddress } from '../../test/viem/config.js'
13
13
  import { KeyAuthorization, SignatureEnvelope } from './index.js'
14
14
  import * as Transaction from './Transaction.js'
15
- import * as TransactionEnvelopeAA from './TransactionEnvelopeAA.js'
15
+ import * as TransactionEnvelopeTempo from './TransactionEnvelopeTempo.js'
16
16
  import * as TransactionReceipt from './TransactionReceipt.js'
17
17
 
18
18
  test('behavior: default (secp256k1)', async () => {
@@ -28,7 +28,7 @@ test('behavior: default (secp256k1)', async () => {
28
28
  blockTag: 'pending',
29
29
  })
30
30
 
31
- const transaction = TransactionEnvelopeAA.from({
31
+ const transaction = TransactionEnvelopeTempo.from({
32
32
  calls: [
33
33
  {
34
34
  to: '0x0000000000000000000000000000000000000000',
@@ -43,11 +43,11 @@ test('behavior: default (secp256k1)', async () => {
43
43
  })
44
44
 
45
45
  const signature = Secp256k1.sign({
46
- payload: TransactionEnvelopeAA.getSignPayload(transaction),
46
+ payload: TransactionEnvelopeTempo.getSignPayload(transaction),
47
47
  privateKey,
48
48
  })
49
49
 
50
- const serialized_signed = TransactionEnvelopeAA.serialize(transaction, {
50
+ const serialized_signed = TransactionEnvelopeTempo.serialize(transaction, {
51
51
  signature: SignatureEnvelope.from(signature),
52
52
  })
53
53
 
@@ -110,7 +110,7 @@ test('behavior: default (secp256k1)', async () => {
110
110
  "gas": 100000n,
111
111
  "gasPrice": 20000000000n,
112
112
  "nonceKey": 0n,
113
- "type": "aa",
113
+ "type": "tempo",
114
114
  "validAfter": null,
115
115
  "validBefore": null,
116
116
  "value": 0n,
@@ -163,7 +163,7 @@ test('behavior: default (p256)', async () => {
163
163
  address,
164
164
  })
165
165
 
166
- const transaction = TransactionEnvelopeAA.from({
166
+ const transaction = TransactionEnvelopeTempo.from({
167
167
  calls: [
168
168
  {
169
169
  to: '0x0000000000000000000000000000000000000000',
@@ -177,12 +177,12 @@ test('behavior: default (p256)', async () => {
177
177
  })
178
178
 
179
179
  const signature = P256.sign({
180
- payload: TransactionEnvelopeAA.getSignPayload(transaction),
180
+ payload: TransactionEnvelopeTempo.getSignPayload(transaction),
181
181
  privateKey,
182
182
  hash: false,
183
183
  })
184
184
 
185
- const serialized_signed = TransactionEnvelopeAA.serialize(transaction, {
185
+ const serialized_signed = TransactionEnvelopeTempo.serialize(transaction, {
186
186
  signature: SignatureEnvelope.from({
187
187
  signature,
188
188
  publicKey,
@@ -250,7 +250,7 @@ test('behavior: default (p256)', async () => {
250
250
  "gas": 100000n,
251
251
  "gasPrice": 20000000000n,
252
252
  "nonceKey": 0n,
253
- "type": "aa",
253
+ "type": "tempo",
254
254
  "validAfter": null,
255
255
  "validBefore": null,
256
256
  "value": 0n,
@@ -302,7 +302,7 @@ test('behavior: default (p256 - webcrypto)', async () => {
302
302
  address,
303
303
  })
304
304
 
305
- const transaction = TransactionEnvelopeAA.from({
305
+ const transaction = TransactionEnvelopeTempo.from({
306
306
  calls: [
307
307
  {
308
308
  to: '0x0000000000000000000000000000000000000000',
@@ -316,11 +316,11 @@ test('behavior: default (p256 - webcrypto)', async () => {
316
316
  })
317
317
 
318
318
  const signature = await WebCryptoP256.sign({
319
- payload: TransactionEnvelopeAA.getSignPayload(transaction),
319
+ payload: TransactionEnvelopeTempo.getSignPayload(transaction),
320
320
  privateKey: keyPair.privateKey,
321
321
  })
322
322
 
323
- const serialized_signed = TransactionEnvelopeAA.serialize(transaction, {
323
+ const serialized_signed = TransactionEnvelopeTempo.serialize(transaction, {
324
324
  signature: SignatureEnvelope.from({
325
325
  signature,
326
326
  publicKey: keyPair.publicKey,
@@ -389,7 +389,7 @@ test('behavior: default (p256 - webcrypto)', async () => {
389
389
  "gas": 100000n,
390
390
  "gasPrice": 20000000000n,
391
391
  "nonceKey": 0n,
392
- "type": "aa",
392
+ "type": "tempo",
393
393
  "validAfter": null,
394
394
  "validBefore": null,
395
395
  "value": 0n,
@@ -442,7 +442,7 @@ test('behavior: default (webauthn)', async () => {
442
442
  address,
443
443
  })
444
444
 
445
- const transaction = TransactionEnvelopeAA.from({
445
+ const transaction = TransactionEnvelopeTempo.from({
446
446
  calls: [
447
447
  {
448
448
  to: '0x0000000000000000000000000000000000000000',
@@ -456,7 +456,7 @@ test('behavior: default (webauthn)', async () => {
456
456
  })
457
457
 
458
458
  const { metadata, payload } = WebAuthnP256.getSignPayload({
459
- challenge: TransactionEnvelopeAA.getSignPayload(transaction),
459
+ challenge: TransactionEnvelopeTempo.getSignPayload(transaction),
460
460
  rpId: 'localhost',
461
461
  origin: 'http://localhost',
462
462
  })
@@ -467,7 +467,7 @@ test('behavior: default (webauthn)', async () => {
467
467
  hash: true,
468
468
  })
469
469
 
470
- const serialized_signed = TransactionEnvelopeAA.serialize(transaction, {
470
+ const serialized_signed = TransactionEnvelopeTempo.serialize(transaction, {
471
471
  signature: SignatureEnvelope.from({
472
472
  signature,
473
473
  publicKey,
@@ -535,7 +535,7 @@ test('behavior: default (webauthn)', async () => {
535
535
  "gas": 100000n,
536
536
  "gasPrice": 20000000000n,
537
537
  "nonceKey": 0n,
538
- "type": "aa",
538
+ "type": "tempo",
539
539
  "validAfter": null,
540
540
  "validBefore": null,
541
541
  "value": 0n,
@@ -603,7 +603,7 @@ test('behavior: feePayerSignature (user → feePayer)', async () => {
603
603
  //////////////////////////////////////////////////////////////////
604
604
  // Sender flow
605
605
 
606
- const transaction = TransactionEnvelopeAA.from({
606
+ const transaction = TransactionEnvelopeTempo.from({
607
607
  calls: [{ to: '0x0000000000000000000000000000000000000000', value: 0n }],
608
608
  chainId,
609
609
  feePayerSignature: null,
@@ -614,32 +614,32 @@ test('behavior: feePayerSignature (user → feePayer)', async () => {
614
614
  })
615
615
 
616
616
  const signature = Secp256k1.sign({
617
- payload: TransactionEnvelopeAA.getSignPayload(transaction),
617
+ payload: TransactionEnvelopeTempo.getSignPayload(transaction),
618
618
  // unfunded PK
619
619
  privateKey: senderPrivateKey,
620
620
  })
621
621
 
622
- const transaction_signed = TransactionEnvelopeAA.from(transaction, {
622
+ const transaction_signed = TransactionEnvelopeTempo.from(transaction, {
623
623
  signature: SignatureEnvelope.from(signature),
624
624
  })
625
625
 
626
626
  //////////////////////////////////////////////////////////////////
627
627
  // Fee payer flow
628
628
 
629
- const transaction_feePayer = TransactionEnvelopeAA.from({
629
+ const transaction_feePayer = TransactionEnvelopeTempo.from({
630
630
  ...transaction_signed,
631
631
  feeToken: '0x20c0000000000000000000000000000000000001',
632
632
  })
633
633
 
634
634
  const feePayerSignature = Secp256k1.sign({
635
- payload: TransactionEnvelopeAA.getFeePayerSignPayload(
635
+ payload: TransactionEnvelopeTempo.getFeePayerSignPayload(
636
636
  transaction_feePayer,
637
637
  { sender: senderAddress },
638
638
  ),
639
639
  privateKey: feePayerPrivateKey,
640
640
  })
641
641
 
642
- const serialized_signed = TransactionEnvelopeAA.serialize(
642
+ const serialized_signed = TransactionEnvelopeTempo.serialize(
643
643
  transaction_feePayer,
644
644
  {
645
645
  feePayerSignature,
@@ -745,7 +745,7 @@ describe('behavior: keyAuthorization', () => {
745
745
  blockTag: 'pending',
746
746
  })
747
747
 
748
- const transaction = TransactionEnvelopeAA.from({
748
+ const transaction = TransactionEnvelopeTempo.from({
749
749
  calls: [
750
750
  {
751
751
  to: '0x0000000000000000000000000000000000000000',
@@ -761,11 +761,11 @@ describe('behavior: keyAuthorization', () => {
761
761
  })
762
762
 
763
763
  const signature = Secp256k1.sign({
764
- payload: TransactionEnvelopeAA.getSignPayload(transaction),
764
+ payload: TransactionEnvelopeTempo.getSignPayload(transaction),
765
765
  privateKey: access.privateKey,
766
766
  })
767
767
 
768
- const serialized_signed = TransactionEnvelopeAA.serialize(transaction, {
768
+ const serialized_signed = TransactionEnvelopeTempo.serialize(transaction, {
769
769
  signature: SignatureEnvelope.from({
770
770
  userAddress: root.address,
771
771
  inner: SignatureEnvelope.from(signature),
@@ -832,7 +832,7 @@ describe('behavior: keyAuthorization', () => {
832
832
  "feeToken": "0x20c0000000000000000000000000000000000001",
833
833
  "gas": 100000n,
834
834
  "nonceKey": 0n,
835
- "type": "aa",
835
+ "type": "tempo",
836
836
  "validAfter": null,
837
837
  "validBefore": null,
838
838
  "value": 0n,
@@ -883,7 +883,7 @@ describe('behavior: keyAuthorization', () => {
883
883
  blockTag: 'pending',
884
884
  })
885
885
 
886
- const transaction = TransactionEnvelopeAA.from({
886
+ const transaction = TransactionEnvelopeTempo.from({
887
887
  calls: [
888
888
  {
889
889
  to: '0x0000000000000000000000000000000000000000',
@@ -898,17 +898,20 @@ describe('behavior: keyAuthorization', () => {
898
898
  })
899
899
 
900
900
  const signature = Secp256k1.sign({
901
- payload: TransactionEnvelopeAA.getSignPayload(transaction),
901
+ payload: TransactionEnvelopeTempo.getSignPayload(transaction),
902
902
  privateKey: access.privateKey,
903
903
  })
904
904
 
905
- const serialized_signed = TransactionEnvelopeAA.serialize(transaction, {
906
- signature: SignatureEnvelope.from({
907
- userAddress: root.address,
908
- inner: SignatureEnvelope.from(signature),
909
- type: 'keychain',
910
- }),
911
- })
905
+ const serialized_signed = TransactionEnvelopeTempo.serialize(
906
+ transaction,
907
+ {
908
+ signature: SignatureEnvelope.from({
909
+ userAddress: root.address,
910
+ inner: SignatureEnvelope.from(signature),
911
+ type: 'keychain',
912
+ }),
913
+ },
914
+ )
912
915
 
913
916
  const receipt = await client.request({
914
917
  method: 'eth_sendRawTransactionSync',
@@ -949,7 +952,7 @@ describe('behavior: keyAuthorization', () => {
949
952
  blockTag: 'pending',
950
953
  })
951
954
 
952
- const transaction = TransactionEnvelopeAA.from({
955
+ const transaction = TransactionEnvelopeTempo.from({
953
956
  calls: [
954
957
  {
955
958
  to: '0x0000000000000000000000000000000000000000',
@@ -965,11 +968,11 @@ describe('behavior: keyAuthorization', () => {
965
968
  })
966
969
 
967
970
  const signature = P256.sign({
968
- payload: TransactionEnvelopeAA.getSignPayload(transaction),
971
+ payload: TransactionEnvelopeTempo.getSignPayload(transaction),
969
972
  privateKey: access.privateKey,
970
973
  })
971
974
 
972
- const serialized_signed = TransactionEnvelopeAA.serialize(transaction, {
975
+ const serialized_signed = TransactionEnvelopeTempo.serialize(transaction, {
973
976
  signature: SignatureEnvelope.from({
974
977
  userAddress: root.address,
975
978
  inner: SignatureEnvelope.from({
@@ -1042,7 +1045,7 @@ describe('behavior: keyAuthorization', () => {
1042
1045
  "feeToken": "0x20c0000000000000000000000000000000000001",
1043
1046
  "gas": 100000n,
1044
1047
  "nonceKey": 0n,
1045
- "type": "aa",
1048
+ "type": "tempo",
1046
1049
  "validAfter": null,
1047
1050
  "validBefore": null,
1048
1051
  "value": 0n,
@@ -1093,7 +1096,7 @@ describe('behavior: keyAuthorization', () => {
1093
1096
  blockTag: 'pending',
1094
1097
  })
1095
1098
 
1096
- const transaction = TransactionEnvelopeAA.from({
1099
+ const transaction = TransactionEnvelopeTempo.from({
1097
1100
  calls: [
1098
1101
  {
1099
1102
  to: '0x0000000000000000000000000000000000000000',
@@ -1108,22 +1111,25 @@ describe('behavior: keyAuthorization', () => {
1108
1111
  })
1109
1112
 
1110
1113
  const signature = P256.sign({
1111
- payload: TransactionEnvelopeAA.getSignPayload(transaction),
1114
+ payload: TransactionEnvelopeTempo.getSignPayload(transaction),
1112
1115
  privateKey: access.privateKey,
1113
1116
  })
1114
1117
 
1115
- const serialized_signed = TransactionEnvelopeAA.serialize(transaction, {
1116
- signature: SignatureEnvelope.from({
1117
- userAddress: root.address,
1118
- inner: SignatureEnvelope.from({
1119
- prehash: false,
1120
- publicKey: access.publicKey,
1121
- signature,
1122
- type: 'p256',
1118
+ const serialized_signed = TransactionEnvelopeTempo.serialize(
1119
+ transaction,
1120
+ {
1121
+ signature: SignatureEnvelope.from({
1122
+ userAddress: root.address,
1123
+ inner: SignatureEnvelope.from({
1124
+ prehash: false,
1125
+ publicKey: access.publicKey,
1126
+ signature,
1127
+ type: 'p256',
1128
+ }),
1129
+ type: 'keychain',
1123
1130
  }),
1124
- type: 'keychain',
1125
- }),
1126
- })
1131
+ },
1132
+ )
1127
1133
 
1128
1134
  const receipt = await client.request({
1129
1135
  method: 'eth_sendRawTransactionSync',
@@ -1162,7 +1168,7 @@ describe('behavior: keyAuthorization', () => {
1162
1168
  blockTag: 'pending',
1163
1169
  })
1164
1170
 
1165
- const transaction = TransactionEnvelopeAA.from({
1171
+ const transaction = TransactionEnvelopeTempo.from({
1166
1172
  calls: [
1167
1173
  {
1168
1174
  to: '0x0000000000000000000000000000000000000000',
@@ -1178,11 +1184,11 @@ describe('behavior: keyAuthorization', () => {
1178
1184
  })
1179
1185
 
1180
1186
  const signature = await WebCryptoP256.sign({
1181
- payload: TransactionEnvelopeAA.getSignPayload(transaction),
1187
+ payload: TransactionEnvelopeTempo.getSignPayload(transaction),
1182
1188
  privateKey: keyPair.privateKey,
1183
1189
  })
1184
1190
 
1185
- const serialized_signed = TransactionEnvelopeAA.serialize(transaction, {
1191
+ const serialized_signed = TransactionEnvelopeTempo.serialize(transaction, {
1186
1192
  signature: SignatureEnvelope.from({
1187
1193
  userAddress: root.address,
1188
1194
  inner: SignatureEnvelope.from({
@@ -1254,7 +1260,7 @@ describe('behavior: keyAuthorization', () => {
1254
1260
  "feeToken": "0x20c0000000000000000000000000000000000001",
1255
1261
  "gas": 100000n,
1256
1262
  "nonceKey": 0n,
1257
- "type": "aa",
1263
+ "type": "tempo",
1258
1264
  "validAfter": null,
1259
1265
  "validBefore": null,
1260
1266
  "value": 0n,
@@ -1269,7 +1275,7 @@ describe('behavior: keyAuthorization', () => {
1269
1275
  blockTag: 'pending',
1270
1276
  })
1271
1277
 
1272
- const transaction = TransactionEnvelopeAA.from({
1278
+ const transaction = TransactionEnvelopeTempo.from({
1273
1279
  calls: [
1274
1280
  {
1275
1281
  to: '0x0000000000000000000000000000000000000000',
@@ -1284,22 +1290,25 @@ describe('behavior: keyAuthorization', () => {
1284
1290
  })
1285
1291
 
1286
1292
  const signature = await WebCryptoP256.sign({
1287
- payload: TransactionEnvelopeAA.getSignPayload(transaction),
1293
+ payload: TransactionEnvelopeTempo.getSignPayload(transaction),
1288
1294
  privateKey: keyPair.privateKey,
1289
1295
  })
1290
1296
 
1291
- const serialized_signed = TransactionEnvelopeAA.serialize(transaction, {
1292
- signature: SignatureEnvelope.from({
1293
- userAddress: root.address,
1294
- inner: SignatureEnvelope.from({
1295
- prehash: true,
1296
- publicKey: access.publicKey,
1297
- signature,
1298
- type: 'p256',
1297
+ const serialized_signed = TransactionEnvelopeTempo.serialize(
1298
+ transaction,
1299
+ {
1300
+ signature: SignatureEnvelope.from({
1301
+ userAddress: root.address,
1302
+ inner: SignatureEnvelope.from({
1303
+ prehash: true,
1304
+ publicKey: access.publicKey,
1305
+ signature,
1306
+ type: 'p256',
1307
+ }),
1308
+ type: 'keychain',
1299
1309
  }),
1300
- type: 'keychain',
1301
- }),
1302
- })
1310
+ },
1311
+ )
1303
1312
 
1304
1313
  const receipt = await client.request({
1305
1314
  method: 'eth_sendRawTransactionSync',
package/src/ox/index.ts CHANGED
@@ -9,4 +9,4 @@ export * as Tick from './Tick.js'
9
9
  export * as TokenId from './TokenId.js'
10
10
  export * as TokenRole from './TokenRole.js'
11
11
  export * as Transaction from './Transaction.js'
12
- export * as TransactionEnvelopeAA from './TransactionEnvelopeAA.js'
12
+ export * as TransactionEnvelopeTempo from './TransactionEnvelopeTempo.js'
@@ -34,7 +34,7 @@ export function formatTransaction(
34
34
  gasPrice: _,
35
35
  nonce,
36
36
  ...tx
37
- } = ox_Transaction.fromRpc(transaction as never) as ox_Transaction.AA
37
+ } = ox_Transaction.fromRpc(transaction as never) as ox_Transaction.Tempo
38
38
 
39
39
  return {
40
40
  ...tx,
@@ -58,7 +58,7 @@ export function formatTransaction(
58
58
  ox_Transaction.toRpcType[
59
59
  tx.type as keyof typeof ox_Transaction.toRpcType
60
60
  ],
61
- type: tx.type as 'aa',
61
+ type: tx.type as 'tempo',
62
62
  }
63
63
  }
64
64
 
@@ -84,8 +84,8 @@ export function formatTransactionRequest<chain extends Chain | undefined>(
84
84
  ? parseAccount<Account | viem_Account | Address>(request.account)
85
85
  : undefined
86
86
 
87
- // Convert EIP-1559 transactions to AA transactions.
88
- if (request.type === 'eip1559') (request as any).type = 'aa'
87
+ // Convert EIP-1559 transactions to Tempo transactions.
88
+ if (request.type === 'eip1559') (request as any).type = 'tempo'
89
89
 
90
90
  // If the request is not a Tempo transaction, route to Viem formatter.
91
91
  if (!isTempo(request))
@@ -112,7 +112,7 @@ export function formatTransactionRequest<chain extends Chain | undefined>(
112
112
  s: BigInt(auth.s!),
113
113
  yParity: Number(auth.yParity),
114
114
  })),
115
- type: 'aa',
115
+ type: 'tempo',
116
116
  } as never)
117
117
 
118
118
  if (action === 'estimateGas') {
@@ -134,7 +134,7 @@ export function formatTransactionRequest<chain extends Chain | undefined>(
134
134
  rpc.type = undefined
135
135
  }
136
136
 
137
- // We rely on `calls` for AA transactions.
137
+ // We rely on `calls` for Tempo transactions.
138
138
  // However, `calls` may not be supported by JSON-RPC accounts (wallets) yet,
139
139
  // so we will not remove the `data`, `to`, and `value` fields to make it
140
140
  // compatible with the base transaction structure.