tempo.ts 0.8.2 → 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.
- package/CHANGELOG.md +25 -0
- package/dist/ox/KeyAuthorization.d.ts +3 -3
- package/dist/ox/KeyAuthorization.js +2 -2
- package/dist/ox/Transaction.d.ts +8 -8
- package/dist/ox/Transaction.d.ts.map +1 -1
- package/dist/ox/Transaction.js +3 -3
- package/dist/ox/Transaction.js.map +1 -1
- package/dist/ox/{TransactionEnvelopeAA.d.ts → TransactionEnvelopeTempo.d.ts} +70 -70
- package/dist/ox/TransactionEnvelopeTempo.d.ts.map +1 -0
- package/dist/ox/{TransactionEnvelopeAA.js → TransactionEnvelopeTempo.js} +57 -57
- package/dist/ox/TransactionEnvelopeTempo.js.map +1 -0
- package/dist/ox/TransactionReceipt.d.ts +3 -3
- package/dist/ox/TransactionReceipt.d.ts.map +1 -1
- package/dist/ox/TransactionReceipt.js +2 -2
- package/dist/ox/TransactionReceipt.js.map +1 -1
- package/dist/ox/TransactionRequest.d.ts +1 -1
- package/dist/ox/TransactionRequest.d.ts.map +1 -1
- package/dist/ox/TransactionRequest.js +2 -2
- package/dist/ox/TransactionRequest.js.map +1 -1
- package/dist/ox/index.d.ts +1 -1
- package/dist/ox/index.d.ts.map +1 -1
- package/dist/ox/index.js +1 -1
- package/dist/ox/index.js.map +1 -1
- package/dist/viem/Chain.d.ts +4 -6
- package/dist/viem/Chain.d.ts.map +1 -1
- package/dist/viem/Formatters.d.ts +2 -4
- package/dist/viem/Formatters.d.ts.map +1 -1
- package/dist/viem/Formatters.js +10 -8
- package/dist/viem/Formatters.js.map +1 -1
- package/dist/viem/Transaction.d.ts +17 -17
- package/dist/viem/Transaction.d.ts.map +1 -1
- package/dist/viem/Transaction.js +16 -16
- package/dist/viem/Transaction.js.map +1 -1
- package/dist/viem/internal/types.d.ts +2 -2
- package/dist/viem/internal/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ox/KeyAuthorization.ts +3 -3
- package/src/ox/Transaction.test.ts +6 -6
- package/src/ox/Transaction.ts +11 -11
- package/src/ox/{TransactionEnvelopeAA.test.ts → TransactionEnvelopeTempo.test.ts} +154 -139
- package/src/ox/{TransactionEnvelopeAA.ts → TransactionEnvelopeTempo.ts} +78 -76
- package/src/ox/TransactionReceipt.ts +3 -3
- package/src/ox/TransactionRequest.ts +3 -3
- package/src/ox/e2e.test.ts +79 -70
- package/src/ox/index.ts +1 -1
- package/src/viem/Formatters.ts +18 -13
- package/src/viem/Transaction.ts +43 -40
- package/src/viem/e2e.test.ts +14 -14
- package/src/viem/internal/types.ts +2 -2
- package/dist/ox/TransactionEnvelopeAA.d.ts.map +0 -1
- package/dist/ox/TransactionEnvelopeAA.js.map +0 -1
package/src/ox/e2e.test.ts
CHANGED
|
@@ -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
|
|
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 =
|
|
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:
|
|
46
|
+
payload: TransactionEnvelopeTempo.getSignPayload(transaction),
|
|
47
47
|
privateKey,
|
|
48
48
|
})
|
|
49
49
|
|
|
50
|
-
const serialized_signed =
|
|
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": "
|
|
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 =
|
|
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:
|
|
180
|
+
payload: TransactionEnvelopeTempo.getSignPayload(transaction),
|
|
181
181
|
privateKey,
|
|
182
182
|
hash: false,
|
|
183
183
|
})
|
|
184
184
|
|
|
185
|
-
const serialized_signed =
|
|
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": "
|
|
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 =
|
|
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:
|
|
319
|
+
payload: TransactionEnvelopeTempo.getSignPayload(transaction),
|
|
320
320
|
privateKey: keyPair.privateKey,
|
|
321
321
|
})
|
|
322
322
|
|
|
323
|
-
const serialized_signed =
|
|
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": "
|
|
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 =
|
|
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:
|
|
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 =
|
|
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": "
|
|
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 =
|
|
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:
|
|
617
|
+
payload: TransactionEnvelopeTempo.getSignPayload(transaction),
|
|
618
618
|
// unfunded PK
|
|
619
619
|
privateKey: senderPrivateKey,
|
|
620
620
|
})
|
|
621
621
|
|
|
622
|
-
const transaction_signed =
|
|
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 =
|
|
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:
|
|
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 =
|
|
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 =
|
|
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:
|
|
764
|
+
payload: TransactionEnvelopeTempo.getSignPayload(transaction),
|
|
765
765
|
privateKey: access.privateKey,
|
|
766
766
|
})
|
|
767
767
|
|
|
768
|
-
const serialized_signed =
|
|
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": "
|
|
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 =
|
|
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:
|
|
901
|
+
payload: TransactionEnvelopeTempo.getSignPayload(transaction),
|
|
902
902
|
privateKey: access.privateKey,
|
|
903
903
|
})
|
|
904
904
|
|
|
905
|
-
const serialized_signed =
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
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 =
|
|
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:
|
|
971
|
+
payload: TransactionEnvelopeTempo.getSignPayload(transaction),
|
|
969
972
|
privateKey: access.privateKey,
|
|
970
973
|
})
|
|
971
974
|
|
|
972
|
-
const serialized_signed =
|
|
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": "
|
|
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 =
|
|
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:
|
|
1114
|
+
payload: TransactionEnvelopeTempo.getSignPayload(transaction),
|
|
1112
1115
|
privateKey: access.privateKey,
|
|
1113
1116
|
})
|
|
1114
1117
|
|
|
1115
|
-
const serialized_signed =
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
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
|
-
|
|
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 =
|
|
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:
|
|
1187
|
+
payload: TransactionEnvelopeTempo.getSignPayload(transaction),
|
|
1182
1188
|
privateKey: keyPair.privateKey,
|
|
1183
1189
|
})
|
|
1184
1190
|
|
|
1185
|
-
const serialized_signed =
|
|
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": "
|
|
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 =
|
|
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:
|
|
1293
|
+
payload: TransactionEnvelopeTempo.getSignPayload(transaction),
|
|
1288
1294
|
privateKey: keyPair.privateKey,
|
|
1289
1295
|
})
|
|
1290
1296
|
|
|
1291
|
-
const serialized_signed =
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
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
|
-
|
|
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
|
|
12
|
+
export * as TransactionEnvelopeTempo from './TransactionEnvelopeTempo.js'
|
package/src/viem/Formatters.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
formatTransactionReceipt as viem_formatTransactionReceipt,
|
|
9
9
|
formatTransactionRequest as viem_formatTransactionRequest,
|
|
10
10
|
} from 'viem'
|
|
11
|
-
import { parseAccount } from 'viem/accounts'
|
|
11
|
+
import { type Address, parseAccount } from 'viem/accounts'
|
|
12
12
|
import type { UnionOmit } from '../internal/types.js'
|
|
13
13
|
import * as ox_Transaction from '../ox/Transaction.js'
|
|
14
14
|
import * as ox_TransactionRequest from '../ox/TransactionRequest.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.
|
|
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 '
|
|
61
|
+
type: tx.type as 'tempo',
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -72,16 +72,20 @@ type Request<chain extends Chain | undefined> = UnionOmit<
|
|
|
72
72
|
TransactionRequest,
|
|
73
73
|
'feeToken'
|
|
74
74
|
> &
|
|
75
|
-
GetFeeTokenParameter<chain>
|
|
75
|
+
GetFeeTokenParameter<chain>
|
|
76
76
|
export function formatTransactionRequest<chain extends Chain | undefined>(
|
|
77
77
|
r: Request<chain>,
|
|
78
78
|
action?: string | undefined,
|
|
79
79
|
): TransactionRequestRpc {
|
|
80
|
-
const request = r as Request<chain>
|
|
81
|
-
|
|
80
|
+
const request = r as Request<chain> & {
|
|
81
|
+
account?: viem_Account | Address | undefined
|
|
82
|
+
}
|
|
83
|
+
const account = request.account
|
|
84
|
+
? parseAccount<Account | viem_Account | Address>(request.account)
|
|
85
|
+
: undefined
|
|
82
86
|
|
|
83
|
-
// Convert EIP-1559 transactions to
|
|
84
|
-
if (request.type === 'eip1559') (request as any).type = '
|
|
87
|
+
// Convert EIP-1559 transactions to Tempo transactions.
|
|
88
|
+
if (request.type === 'eip1559') (request as any).type = 'tempo'
|
|
85
89
|
|
|
86
90
|
// If the request is not a Tempo transaction, route to Viem formatter.
|
|
87
91
|
if (!isTempo(request))
|
|
@@ -108,7 +112,7 @@ export function formatTransactionRequest<chain extends Chain | undefined>(
|
|
|
108
112
|
s: BigInt(auth.s!),
|
|
109
113
|
yParity: Number(auth.yParity),
|
|
110
114
|
})),
|
|
111
|
-
type: '
|
|
115
|
+
type: 'tempo',
|
|
112
116
|
} as never)
|
|
113
117
|
|
|
114
118
|
if (action === 'estimateGas') {
|
|
@@ -122,7 +126,7 @@ export function formatTransactionRequest<chain extends Chain | undefined>(
|
|
|
122
126
|
// TODO: `calls` will not be supported by a lot of JSON-RPC accounts (wallet),
|
|
123
127
|
// use `wallet_sendCalls` or sequential `eth_sendTransaction` to mimic the
|
|
124
128
|
// behavior of `calls`.
|
|
125
|
-
if (
|
|
129
|
+
if (account?.type === 'json-rpc') {
|
|
126
130
|
if (rpc.calls?.length && rpc.calls.length > 1)
|
|
127
131
|
throw new Error(
|
|
128
132
|
'Batch calls are not supported with JSON-RPC accounts yet.',
|
|
@@ -130,18 +134,19 @@ export function formatTransactionRequest<chain extends Chain | undefined>(
|
|
|
130
134
|
rpc.type = undefined
|
|
131
135
|
}
|
|
132
136
|
|
|
133
|
-
// We rely on `calls` for
|
|
137
|
+
// We rely on `calls` for Tempo transactions.
|
|
134
138
|
// However, `calls` may not be supported by JSON-RPC accounts (wallets) yet,
|
|
135
139
|
// so we will not remove the `data`, `to`, and `value` fields to make it
|
|
136
140
|
// compatible with the base transaction structure.
|
|
137
|
-
if (
|
|
141
|
+
if (account?.type !== 'json-rpc') {
|
|
138
142
|
rpc.to = undefined
|
|
139
143
|
rpc.data = undefined
|
|
140
144
|
rpc.value = undefined
|
|
141
145
|
}
|
|
142
146
|
|
|
143
147
|
const [keyType, keyData] = (() => {
|
|
144
|
-
const type =
|
|
148
|
+
const type =
|
|
149
|
+
account && 'keyType' in account ? account.keyType : account?.source
|
|
145
150
|
if (!type) return [undefined, undefined]
|
|
146
151
|
if (type === 'webAuthn')
|
|
147
152
|
// TODO: derive correct bytes size of key data based on webauthn create metadata.
|