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.
- package/CHANGELOG.md +19 -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 +3 -3
- package/dist/viem/Formatters.js +4 -4
- 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 +6 -6
- 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
|
@@ -2,7 +2,7 @@ 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
4
|
import * as KeyAuthorization from './KeyAuthorization.js'
|
|
5
|
-
import * as
|
|
5
|
+
import * as TransactionEnvelopeTempo from './TransactionEnvelopeTempo.js'
|
|
6
6
|
|
|
7
7
|
const privateKey =
|
|
8
8
|
'0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'
|
|
@@ -10,54 +10,54 @@ const privateKey =
|
|
|
10
10
|
describe('assert', () => {
|
|
11
11
|
test('empty calls list', () => {
|
|
12
12
|
expect(() =>
|
|
13
|
-
|
|
13
|
+
TransactionEnvelopeTempo.assert({
|
|
14
14
|
calls: [],
|
|
15
15
|
chainId: 1,
|
|
16
16
|
}),
|
|
17
17
|
).toThrowErrorMatchingInlineSnapshot(
|
|
18
|
-
`[
|
|
18
|
+
`[TransactionEnvelopeTempo.CallsEmptyError: Calls list cannot be empty.]`,
|
|
19
19
|
)
|
|
20
20
|
})
|
|
21
21
|
|
|
22
22
|
test('missing calls', () => {
|
|
23
23
|
expect(() =>
|
|
24
|
-
|
|
24
|
+
TransactionEnvelopeTempo.assert({
|
|
25
25
|
chainId: 1,
|
|
26
26
|
} as any),
|
|
27
27
|
).toThrowErrorMatchingInlineSnapshot(
|
|
28
|
-
`[
|
|
28
|
+
`[TransactionEnvelopeTempo.CallsEmptyError: Calls list cannot be empty.]`,
|
|
29
29
|
)
|
|
30
30
|
})
|
|
31
31
|
|
|
32
32
|
test('invalid validity window', () => {
|
|
33
33
|
expect(() =>
|
|
34
|
-
|
|
34
|
+
TransactionEnvelopeTempo.assert({
|
|
35
35
|
calls: [{ to: '0x0000000000000000000000000000000000000000' }],
|
|
36
36
|
chainId: 1,
|
|
37
37
|
validBefore: 100,
|
|
38
38
|
validAfter: 200,
|
|
39
39
|
}),
|
|
40
40
|
).toThrowErrorMatchingInlineSnapshot(
|
|
41
|
-
`[
|
|
41
|
+
`[TransactionEnvelopeTempo.InvalidValidityWindowError: validBefore (100) must be greater than validAfter (200).]`,
|
|
42
42
|
)
|
|
43
43
|
})
|
|
44
44
|
|
|
45
45
|
test('invalid validity window (equal)', () => {
|
|
46
46
|
expect(() =>
|
|
47
|
-
|
|
47
|
+
TransactionEnvelopeTempo.assert({
|
|
48
48
|
calls: [{ to: '0x0000000000000000000000000000000000000000' }],
|
|
49
49
|
chainId: 1,
|
|
50
50
|
validBefore: 100,
|
|
51
51
|
validAfter: 100,
|
|
52
52
|
}),
|
|
53
53
|
).toThrowErrorMatchingInlineSnapshot(
|
|
54
|
-
`[
|
|
54
|
+
`[TransactionEnvelopeTempo.InvalidValidityWindowError: validBefore (100) must be greater than validAfter (100).]`,
|
|
55
55
|
)
|
|
56
56
|
})
|
|
57
57
|
|
|
58
58
|
test('invalid call address', () => {
|
|
59
59
|
expect(() =>
|
|
60
|
-
|
|
60
|
+
TransactionEnvelopeTempo.assert({
|
|
61
61
|
calls: [{ to: '0x000000000000000000000000000000000000000z' }],
|
|
62
62
|
chainId: 1,
|
|
63
63
|
}),
|
|
@@ -72,7 +72,7 @@ describe('assert', () => {
|
|
|
72
72
|
|
|
73
73
|
test('fee cap too high', () => {
|
|
74
74
|
expect(() =>
|
|
75
|
-
|
|
75
|
+
TransactionEnvelopeTempo.assert({
|
|
76
76
|
calls: [{ to: '0x0000000000000000000000000000000000000000' }],
|
|
77
77
|
maxFeePerGas: 2n ** 256n - 1n + 1n,
|
|
78
78
|
chainId: 1,
|
|
@@ -84,7 +84,7 @@ describe('assert', () => {
|
|
|
84
84
|
|
|
85
85
|
test('tip above fee cap', () => {
|
|
86
86
|
expect(() =>
|
|
87
|
-
|
|
87
|
+
TransactionEnvelopeTempo.assert({
|
|
88
88
|
calls: [{ to: '0x0000000000000000000000000000000000000000' }],
|
|
89
89
|
chainId: 1,
|
|
90
90
|
maxFeePerGas: 10n,
|
|
@@ -97,7 +97,7 @@ describe('assert', () => {
|
|
|
97
97
|
|
|
98
98
|
test('invalid chain id', () => {
|
|
99
99
|
expect(() =>
|
|
100
|
-
|
|
100
|
+
TransactionEnvelopeTempo.assert({
|
|
101
101
|
calls: [{ to: '0x0000000000000000000000000000000000000000' }],
|
|
102
102
|
chainId: 0,
|
|
103
103
|
}),
|
|
@@ -108,7 +108,7 @@ describe('assert', () => {
|
|
|
108
108
|
})
|
|
109
109
|
|
|
110
110
|
describe('deserialize', () => {
|
|
111
|
-
const transaction =
|
|
111
|
+
const transaction = TransactionEnvelopeTempo.from({
|
|
112
112
|
chainId: 1,
|
|
113
113
|
calls: [
|
|
114
114
|
{
|
|
@@ -122,24 +122,26 @@ describe('deserialize', () => {
|
|
|
122
122
|
})
|
|
123
123
|
|
|
124
124
|
test('default', () => {
|
|
125
|
-
const serialized =
|
|
126
|
-
const deserialized =
|
|
125
|
+
const serialized = TransactionEnvelopeTempo.serialize(transaction)
|
|
126
|
+
const deserialized = TransactionEnvelopeTempo.deserialize(serialized)
|
|
127
127
|
expect(deserialized).toEqual(transaction)
|
|
128
128
|
})
|
|
129
129
|
|
|
130
130
|
test('minimal', () => {
|
|
131
|
-
const transaction =
|
|
131
|
+
const transaction = TransactionEnvelopeTempo.from({
|
|
132
132
|
chainId: 1,
|
|
133
133
|
calls: [{}],
|
|
134
134
|
nonce: 0n,
|
|
135
135
|
nonceKey: 0n,
|
|
136
136
|
})
|
|
137
|
-
const serialized =
|
|
138
|
-
expect(
|
|
137
|
+
const serialized = TransactionEnvelopeTempo.serialize(transaction)
|
|
138
|
+
expect(TransactionEnvelopeTempo.deserialize(serialized)).toEqual(
|
|
139
|
+
transaction,
|
|
140
|
+
)
|
|
139
141
|
})
|
|
140
142
|
|
|
141
143
|
test('multiple calls', () => {
|
|
142
|
-
const transaction_multiCall =
|
|
144
|
+
const transaction_multiCall = TransactionEnvelopeTempo.from({
|
|
143
145
|
...transaction,
|
|
144
146
|
calls: [
|
|
145
147
|
{
|
|
@@ -152,25 +154,25 @@ describe('deserialize', () => {
|
|
|
152
154
|
},
|
|
153
155
|
],
|
|
154
156
|
})
|
|
155
|
-
const serialized =
|
|
156
|
-
expect(
|
|
157
|
+
const serialized = TransactionEnvelopeTempo.serialize(transaction_multiCall)
|
|
158
|
+
expect(TransactionEnvelopeTempo.deserialize(serialized)).toEqual(
|
|
157
159
|
transaction_multiCall,
|
|
158
160
|
)
|
|
159
161
|
})
|
|
160
162
|
|
|
161
163
|
test('gas', () => {
|
|
162
|
-
const transaction_gas =
|
|
164
|
+
const transaction_gas = TransactionEnvelopeTempo.from({
|
|
163
165
|
...transaction,
|
|
164
166
|
gas: 21001n,
|
|
165
167
|
})
|
|
166
|
-
const serialized =
|
|
167
|
-
expect(
|
|
168
|
+
const serialized = TransactionEnvelopeTempo.serialize(transaction_gas)
|
|
169
|
+
expect(TransactionEnvelopeTempo.deserialize(serialized)).toEqual(
|
|
168
170
|
transaction_gas,
|
|
169
171
|
)
|
|
170
172
|
})
|
|
171
173
|
|
|
172
174
|
test('accessList', () => {
|
|
173
|
-
const transaction_accessList =
|
|
175
|
+
const transaction_accessList = TransactionEnvelopeTempo.from({
|
|
174
176
|
...transaction,
|
|
175
177
|
accessList: [
|
|
176
178
|
{
|
|
@@ -182,75 +184,81 @@ describe('deserialize', () => {
|
|
|
182
184
|
},
|
|
183
185
|
],
|
|
184
186
|
})
|
|
185
|
-
const serialized =
|
|
186
|
-
|
|
187
|
+
const serialized = TransactionEnvelopeTempo.serialize(
|
|
188
|
+
transaction_accessList,
|
|
189
|
+
)
|
|
190
|
+
expect(TransactionEnvelopeTempo.deserialize(serialized)).toEqual(
|
|
187
191
|
transaction_accessList,
|
|
188
192
|
)
|
|
189
193
|
})
|
|
190
194
|
|
|
191
195
|
test('nonce', () => {
|
|
192
|
-
const transaction_nonce =
|
|
196
|
+
const transaction_nonce = TransactionEnvelopeTempo.from({
|
|
193
197
|
...transaction,
|
|
194
198
|
nonce: 0n,
|
|
195
199
|
})
|
|
196
|
-
const serialized =
|
|
197
|
-
expect(
|
|
200
|
+
const serialized = TransactionEnvelopeTempo.serialize(transaction_nonce)
|
|
201
|
+
expect(TransactionEnvelopeTempo.deserialize(serialized)).toEqual(
|
|
198
202
|
transaction_nonce,
|
|
199
203
|
)
|
|
200
204
|
})
|
|
201
205
|
|
|
202
206
|
test('nonceKey', () => {
|
|
203
|
-
const transaction_nonceKey =
|
|
207
|
+
const transaction_nonceKey = TransactionEnvelopeTempo.from({
|
|
204
208
|
...transaction,
|
|
205
209
|
nonceKey: 0n,
|
|
206
210
|
})
|
|
207
|
-
const serialized =
|
|
208
|
-
expect(
|
|
211
|
+
const serialized = TransactionEnvelopeTempo.serialize(transaction_nonceKey)
|
|
212
|
+
expect(TransactionEnvelopeTempo.deserialize(serialized)).toEqual(
|
|
209
213
|
transaction_nonceKey,
|
|
210
214
|
)
|
|
211
215
|
})
|
|
212
216
|
|
|
213
217
|
test('validBefore', () => {
|
|
214
|
-
const transaction_validBefore =
|
|
218
|
+
const transaction_validBefore = TransactionEnvelopeTempo.from({
|
|
215
219
|
...transaction,
|
|
216
220
|
validBefore: 1000000,
|
|
217
221
|
})
|
|
218
|
-
const serialized =
|
|
219
|
-
|
|
222
|
+
const serialized = TransactionEnvelopeTempo.serialize(
|
|
223
|
+
transaction_validBefore,
|
|
224
|
+
)
|
|
225
|
+
expect(TransactionEnvelopeTempo.deserialize(serialized)).toEqual(
|
|
220
226
|
transaction_validBefore,
|
|
221
227
|
)
|
|
222
228
|
})
|
|
223
229
|
|
|
224
230
|
test('validAfter', () => {
|
|
225
|
-
const transaction_validAfter =
|
|
231
|
+
const transaction_validAfter = TransactionEnvelopeTempo.from({
|
|
226
232
|
...transaction,
|
|
227
233
|
validAfter: 500000,
|
|
228
234
|
})
|
|
229
|
-
const serialized =
|
|
230
|
-
|
|
235
|
+
const serialized = TransactionEnvelopeTempo.serialize(
|
|
236
|
+
transaction_validAfter,
|
|
237
|
+
)
|
|
238
|
+
expect(TransactionEnvelopeTempo.deserialize(serialized)).toEqual(
|
|
231
239
|
transaction_validAfter,
|
|
232
240
|
)
|
|
233
241
|
})
|
|
234
242
|
|
|
235
243
|
test('validBefore and validAfter', () => {
|
|
236
|
-
const transaction_validity =
|
|
244
|
+
const transaction_validity = TransactionEnvelopeTempo.from({
|
|
237
245
|
...transaction,
|
|
238
246
|
validBefore: 1000000,
|
|
239
247
|
validAfter: 500000,
|
|
240
248
|
})
|
|
241
|
-
const serialized =
|
|
242
|
-
expect(
|
|
249
|
+
const serialized = TransactionEnvelopeTempo.serialize(transaction_validity)
|
|
250
|
+
expect(TransactionEnvelopeTempo.deserialize(serialized)).toEqual(
|
|
243
251
|
transaction_validity,
|
|
244
252
|
)
|
|
245
253
|
})
|
|
246
254
|
|
|
247
255
|
test('feeToken', () => {
|
|
248
|
-
const transaction_feeToken =
|
|
256
|
+
const transaction_feeToken = TransactionEnvelopeTempo.from({
|
|
249
257
|
...transaction,
|
|
250
258
|
feeToken: '0x20c0000000000000000000000000000000000000',
|
|
251
259
|
})
|
|
252
|
-
const serialized =
|
|
253
|
-
expect(
|
|
260
|
+
const serialized = TransactionEnvelopeTempo.serialize(transaction_feeToken)
|
|
261
|
+
expect(TransactionEnvelopeTempo.deserialize(serialized)).toEqual(
|
|
254
262
|
transaction_feeToken,
|
|
255
263
|
)
|
|
256
264
|
})
|
|
@@ -273,15 +281,15 @@ describe('deserialize', () => {
|
|
|
273
281
|
}),
|
|
274
282
|
})
|
|
275
283
|
|
|
276
|
-
const transaction_keyAuthorization =
|
|
284
|
+
const transaction_keyAuthorization = TransactionEnvelopeTempo.from({
|
|
277
285
|
...transaction,
|
|
278
286
|
keyAuthorization,
|
|
279
287
|
})
|
|
280
288
|
|
|
281
|
-
const serialized =
|
|
289
|
+
const serialized = TransactionEnvelopeTempo.serialize(
|
|
282
290
|
transaction_keyAuthorization,
|
|
283
291
|
)
|
|
284
|
-
expect(
|
|
292
|
+
expect(TransactionEnvelopeTempo.deserialize(serialized)).toEqual(
|
|
285
293
|
transaction_keyAuthorization,
|
|
286
294
|
)
|
|
287
295
|
})
|
|
@@ -289,13 +297,13 @@ describe('deserialize', () => {
|
|
|
289
297
|
describe('signature', () => {
|
|
290
298
|
test('secp256k1', () => {
|
|
291
299
|
const signature = Secp256k1.sign({
|
|
292
|
-
payload:
|
|
300
|
+
payload: TransactionEnvelopeTempo.getSignPayload(transaction),
|
|
293
301
|
privateKey,
|
|
294
302
|
})
|
|
295
|
-
const serialized =
|
|
303
|
+
const serialized = TransactionEnvelopeTempo.serialize(transaction, {
|
|
296
304
|
signature: SignatureEnvelope.from(signature),
|
|
297
305
|
})
|
|
298
|
-
expect(
|
|
306
|
+
expect(TransactionEnvelopeTempo.deserialize(serialized)).toEqual({
|
|
299
307
|
...transaction,
|
|
300
308
|
signature: { signature, type: 'secp256k1' },
|
|
301
309
|
})
|
|
@@ -305,10 +313,10 @@ describe('deserialize', () => {
|
|
|
305
313
|
const privateKey = P256.randomPrivateKey()
|
|
306
314
|
const publicKey = P256.getPublicKey({ privateKey })
|
|
307
315
|
const signature = P256.sign({
|
|
308
|
-
payload:
|
|
316
|
+
payload: TransactionEnvelopeTempo.getSignPayload(transaction),
|
|
309
317
|
privateKey,
|
|
310
318
|
})
|
|
311
|
-
const serialized =
|
|
319
|
+
const serialized = TransactionEnvelopeTempo.serialize(transaction, {
|
|
312
320
|
signature: SignatureEnvelope.from({
|
|
313
321
|
signature,
|
|
314
322
|
publicKey,
|
|
@@ -318,7 +326,7 @@ describe('deserialize', () => {
|
|
|
318
326
|
// biome-ignore lint/suspicious/noTsIgnore: _
|
|
319
327
|
// @ts-ignore
|
|
320
328
|
delete signature.yParity
|
|
321
|
-
expect(
|
|
329
|
+
expect(TransactionEnvelopeTempo.deserialize(serialized)).toEqual({
|
|
322
330
|
...transaction,
|
|
323
331
|
signature: { prehash: true, publicKey, signature, type: 'p256' },
|
|
324
332
|
})
|
|
@@ -326,12 +334,12 @@ describe('deserialize', () => {
|
|
|
326
334
|
})
|
|
327
335
|
|
|
328
336
|
test('feePayerSignature null', () => {
|
|
329
|
-
const transaction_feePayer =
|
|
337
|
+
const transaction_feePayer = TransactionEnvelopeTempo.from({
|
|
330
338
|
...transaction,
|
|
331
339
|
feePayerSignature: null,
|
|
332
340
|
})
|
|
333
|
-
const serialized =
|
|
334
|
-
expect(
|
|
341
|
+
const serialized = TransactionEnvelopeTempo.serialize(transaction_feePayer)
|
|
342
|
+
expect(TransactionEnvelopeTempo.deserialize(serialized)).toEqual(
|
|
335
343
|
transaction_feePayer,
|
|
336
344
|
)
|
|
337
345
|
})
|
|
@@ -358,7 +366,7 @@ describe('deserialize', () => {
|
|
|
358
366
|
'0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', // feePayerSignatureOrSender (address)
|
|
359
367
|
[], // authorizationList
|
|
360
368
|
]).slice(2)}` as const
|
|
361
|
-
const deserialized =
|
|
369
|
+
const deserialized = TransactionEnvelopeTempo.deserialize(serialized)
|
|
362
370
|
expect(deserialized.feePayerSignature).toBe(null)
|
|
363
371
|
})
|
|
364
372
|
|
|
@@ -384,7 +392,7 @@ describe('deserialize', () => {
|
|
|
384
392
|
[Hex.fromNumber(0), Hex.fromNumber(1), Hex.fromNumber(2)], // feePayerSignatureOrSender (signature tuple)
|
|
385
393
|
[], // authorizationList
|
|
386
394
|
]).slice(2)}` as const
|
|
387
|
-
const deserialized =
|
|
395
|
+
const deserialized = TransactionEnvelopeTempo.deserialize(serialized)
|
|
388
396
|
expect(deserialized.feePayerSignature).toEqual({
|
|
389
397
|
yParity: 0,
|
|
390
398
|
r: 1n,
|
|
@@ -416,7 +424,7 @@ describe('deserialize', () => {
|
|
|
416
424
|
[], // authorizationList
|
|
417
425
|
]).slice(2)}` as const
|
|
418
426
|
expect(
|
|
419
|
-
|
|
427
|
+
TransactionEnvelopeTempo.deserialize(serialized),
|
|
420
428
|
).toMatchInlineSnapshot(`
|
|
421
429
|
{
|
|
422
430
|
"calls": [
|
|
@@ -431,7 +439,7 @@ describe('deserialize', () => {
|
|
|
431
439
|
"maxPriorityFeePerGas": 1n,
|
|
432
440
|
"nonce": 0n,
|
|
433
441
|
"nonceKey": 0n,
|
|
434
|
-
"type": "
|
|
442
|
+
"type": "tempo",
|
|
435
443
|
}
|
|
436
444
|
`)
|
|
437
445
|
})
|
|
@@ -459,7 +467,7 @@ describe('deserialize', () => {
|
|
|
459
467
|
[], // authorizationList
|
|
460
468
|
]).slice(2)}` as const
|
|
461
469
|
expect(
|
|
462
|
-
|
|
470
|
+
TransactionEnvelopeTempo.deserialize(serialized),
|
|
463
471
|
).toMatchInlineSnapshot(`
|
|
464
472
|
{
|
|
465
473
|
"calls": [
|
|
@@ -474,7 +482,7 @@ describe('deserialize', () => {
|
|
|
474
482
|
"maxPriorityFeePerGas": 1n,
|
|
475
483
|
"nonce": 0n,
|
|
476
484
|
"nonceKey": 0n,
|
|
477
|
-
"type": "
|
|
485
|
+
"type": "tempo",
|
|
478
486
|
}
|
|
479
487
|
`)
|
|
480
488
|
})
|
|
@@ -483,9 +491,9 @@ describe('deserialize', () => {
|
|
|
483
491
|
describe('errors', () => {
|
|
484
492
|
test('invalid transaction (all missing)', () => {
|
|
485
493
|
expect(() =>
|
|
486
|
-
|
|
494
|
+
TransactionEnvelopeTempo.deserialize(`0x76${Rlp.fromHex([]).slice(2)}`),
|
|
487
495
|
).toThrowErrorMatchingInlineSnapshot(`
|
|
488
|
-
[TransactionEnvelope.InvalidSerializedError: Invalid serialized transaction of type "
|
|
496
|
+
[TransactionEnvelope.InvalidSerializedError: Invalid serialized transaction of type "tempo" was provided.
|
|
489
497
|
|
|
490
498
|
Serialized Transaction: "0x76c0"
|
|
491
499
|
Missing Attributes: chainId, maxPriorityFeePerGas, maxFeePerGas, gas, calls, accessList, keyAuthorization, nonceKey, nonce, validBefore, validAfter, feeToken, feePayerSignatureOrSender]
|
|
@@ -494,11 +502,11 @@ describe('deserialize', () => {
|
|
|
494
502
|
|
|
495
503
|
test('invalid transaction (some missing)', () => {
|
|
496
504
|
expect(() =>
|
|
497
|
-
|
|
505
|
+
TransactionEnvelopeTempo.deserialize(
|
|
498
506
|
`0x76${Rlp.fromHex(['0x00', '0x01']).slice(2)}`,
|
|
499
507
|
),
|
|
500
508
|
).toThrowErrorMatchingInlineSnapshot(`
|
|
501
|
-
[TransactionEnvelope.InvalidSerializedError: Invalid serialized transaction of type "
|
|
509
|
+
[TransactionEnvelope.InvalidSerializedError: Invalid serialized transaction of type "tempo" was provided.
|
|
502
510
|
|
|
503
511
|
Serialized Transaction: "0x76c20001"
|
|
504
512
|
Missing Attributes: maxFeePerGas, gas, calls, accessList, keyAuthorization, nonceKey, nonce, validBefore, validAfter, feeToken, feePayerSignatureOrSender]
|
|
@@ -507,7 +515,7 @@ describe('deserialize', () => {
|
|
|
507
515
|
|
|
508
516
|
test('invalid transaction (empty calls)', () => {
|
|
509
517
|
expect(() =>
|
|
510
|
-
|
|
518
|
+
TransactionEnvelopeTempo.deserialize(
|
|
511
519
|
`0x76${Rlp.fromHex([
|
|
512
520
|
Hex.fromNumber(1), // chainId
|
|
513
521
|
Hex.fromNumber(1), // maxPriorityFeePerGas
|
|
@@ -525,13 +533,13 @@ describe('deserialize', () => {
|
|
|
525
533
|
]).slice(2)}`,
|
|
526
534
|
),
|
|
527
535
|
).toThrowErrorMatchingInlineSnapshot(
|
|
528
|
-
`[
|
|
536
|
+
`[TransactionEnvelopeTempo.CallsEmptyError: Calls list cannot be empty.]`,
|
|
529
537
|
)
|
|
530
538
|
})
|
|
531
539
|
|
|
532
540
|
test('invalid transaction (too many fields with signature)', () => {
|
|
533
541
|
expect(() =>
|
|
534
|
-
|
|
542
|
+
TransactionEnvelopeTempo.deserialize(
|
|
535
543
|
`0x76${Rlp.fromHex([
|
|
536
544
|
Hex.fromNumber(1), // chainId
|
|
537
545
|
Hex.fromNumber(1), // maxPriorityFeePerGas
|
|
@@ -558,7 +566,7 @@ describe('deserialize', () => {
|
|
|
558
566
|
]).slice(2)}`,
|
|
559
567
|
),
|
|
560
568
|
).toThrowErrorMatchingInlineSnapshot(`
|
|
561
|
-
[TransactionEnvelope.InvalidSerializedError: Invalid serialized transaction of type "
|
|
569
|
+
[TransactionEnvelope.InvalidSerializedError: Invalid serialized transaction of type "tempo" was provided.
|
|
562
570
|
|
|
563
571
|
Serialized Transaction: "0x76ec01010101d8d7940000000000000000000000000000000000000000008080000080808080c0c0821234825678"]
|
|
564
572
|
`)
|
|
@@ -569,7 +577,7 @@ describe('deserialize', () => {
|
|
|
569
577
|
describe('from', () => {
|
|
570
578
|
test('default', () => {
|
|
571
579
|
{
|
|
572
|
-
const envelope =
|
|
580
|
+
const envelope = TransactionEnvelopeTempo.from({
|
|
573
581
|
chainId: 1,
|
|
574
582
|
calls: [{}],
|
|
575
583
|
nonce: 0n,
|
|
@@ -583,16 +591,16 @@ describe('from', () => {
|
|
|
583
591
|
"chainId": 1,
|
|
584
592
|
"nonce": 0n,
|
|
585
593
|
"nonceKey": 0n,
|
|
586
|
-
"type": "
|
|
594
|
+
"type": "tempo",
|
|
587
595
|
}
|
|
588
596
|
`)
|
|
589
|
-
const serialized =
|
|
590
|
-
const envelope2 =
|
|
597
|
+
const serialized = TransactionEnvelopeTempo.serialize(envelope)
|
|
598
|
+
const envelope2 = TransactionEnvelopeTempo.from(serialized)
|
|
591
599
|
expect(envelope2).toEqual(envelope)
|
|
592
600
|
}
|
|
593
601
|
|
|
594
602
|
{
|
|
595
|
-
const envelope =
|
|
603
|
+
const envelope = TransactionEnvelopeTempo.from({
|
|
596
604
|
chainId: 1,
|
|
597
605
|
calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' }],
|
|
598
606
|
nonce: 0n,
|
|
@@ -621,11 +629,11 @@ describe('from', () => {
|
|
|
621
629
|
},
|
|
622
630
|
"type": "secp256k1",
|
|
623
631
|
},
|
|
624
|
-
"type": "
|
|
632
|
+
"type": "tempo",
|
|
625
633
|
}
|
|
626
634
|
`)
|
|
627
|
-
const serialized =
|
|
628
|
-
const envelope2 =
|
|
635
|
+
const serialized = TransactionEnvelopeTempo.serialize(envelope)
|
|
636
|
+
const envelope2 = TransactionEnvelopeTempo.from(serialized)
|
|
629
637
|
expect(envelope2).toEqual({
|
|
630
638
|
...envelope,
|
|
631
639
|
signature: { ...envelope.signature, type: 'secp256k1' },
|
|
@@ -634,7 +642,7 @@ describe('from', () => {
|
|
|
634
642
|
})
|
|
635
643
|
|
|
636
644
|
test('options: signature', () => {
|
|
637
|
-
const envelope =
|
|
645
|
+
const envelope = TransactionEnvelopeTempo.from(
|
|
638
646
|
{
|
|
639
647
|
chainId: 1,
|
|
640
648
|
calls: [{}],
|
|
@@ -665,16 +673,16 @@ describe('from', () => {
|
|
|
665
673
|
},
|
|
666
674
|
"type": "secp256k1",
|
|
667
675
|
},
|
|
668
|
-
"type": "
|
|
676
|
+
"type": "tempo",
|
|
669
677
|
}
|
|
670
678
|
`)
|
|
671
|
-
const serialized =
|
|
672
|
-
const envelope2 =
|
|
679
|
+
const serialized = TransactionEnvelopeTempo.serialize(envelope)
|
|
680
|
+
const envelope2 = TransactionEnvelopeTempo.from(serialized)
|
|
673
681
|
expect(envelope2).toEqual(envelope)
|
|
674
682
|
})
|
|
675
683
|
|
|
676
684
|
test('options: feePayerSignature', () => {
|
|
677
|
-
const envelope =
|
|
685
|
+
const envelope = TransactionEnvelopeTempo.from(
|
|
678
686
|
{
|
|
679
687
|
chainId: 1,
|
|
680
688
|
calls: [{}],
|
|
@@ -705,14 +713,14 @@ describe('from', () => {
|
|
|
705
713
|
"nonce": 0n,
|
|
706
714
|
"r": 1n,
|
|
707
715
|
"s": 2n,
|
|
708
|
-
"type": "
|
|
716
|
+
"type": "tempo",
|
|
709
717
|
"yParity": 0,
|
|
710
718
|
}
|
|
711
719
|
`)
|
|
712
720
|
})
|
|
713
721
|
|
|
714
722
|
test('options: feePayerSignature (null)', () => {
|
|
715
|
-
const envelope =
|
|
723
|
+
const envelope = TransactionEnvelopeTempo.from(
|
|
716
724
|
{
|
|
717
725
|
chainId: 1,
|
|
718
726
|
calls: [{}],
|
|
@@ -729,7 +737,7 @@ describe('from', () => {
|
|
|
729
737
|
],
|
|
730
738
|
"chainId": 1,
|
|
731
739
|
"nonce": 0n,
|
|
732
|
-
"type": "
|
|
740
|
+
"type": "tempo",
|
|
733
741
|
}
|
|
734
742
|
`)
|
|
735
743
|
})
|
|
@@ -737,7 +745,7 @@ describe('from', () => {
|
|
|
737
745
|
|
|
738
746
|
describe('serialize', () => {
|
|
739
747
|
test('default', () => {
|
|
740
|
-
const transaction =
|
|
748
|
+
const transaction = TransactionEnvelopeTempo.from({
|
|
741
749
|
chainId: 1,
|
|
742
750
|
calls: [
|
|
743
751
|
{
|
|
@@ -748,37 +756,39 @@ describe('serialize', () => {
|
|
|
748
756
|
maxFeePerGas: Value.fromGwei('2'),
|
|
749
757
|
maxPriorityFeePerGas: Value.fromGwei('2'),
|
|
750
758
|
})
|
|
751
|
-
expect(
|
|
759
|
+
expect(
|
|
760
|
+
TransactionEnvelopeTempo.serialize(transaction),
|
|
761
|
+
).toMatchInlineSnapshot(
|
|
752
762
|
`"0x76ef018477359400847735940080d8d79470997970c51812dc3a010c7d01b50e0d17dc79c88080c08082031180808080c0"`,
|
|
753
763
|
)
|
|
754
764
|
})
|
|
755
765
|
|
|
756
766
|
test('minimal', () => {
|
|
757
|
-
const transaction =
|
|
767
|
+
const transaction = TransactionEnvelopeTempo.from({
|
|
758
768
|
chainId: 1,
|
|
759
769
|
calls: [{}],
|
|
760
770
|
nonce: 0n,
|
|
761
771
|
})
|
|
762
|
-
expect(
|
|
763
|
-
|
|
764
|
-
)
|
|
772
|
+
expect(
|
|
773
|
+
TransactionEnvelopeTempo.serialize(transaction),
|
|
774
|
+
).toMatchInlineSnapshot(`"0x76d101808080c4c3808080c0808080808080c0"`)
|
|
765
775
|
})
|
|
766
776
|
|
|
767
777
|
test('undefined nonceKey', () => {
|
|
768
|
-
const transaction =
|
|
778
|
+
const transaction = TransactionEnvelopeTempo.from({
|
|
769
779
|
chainId: 1,
|
|
770
780
|
calls: [{}],
|
|
771
781
|
nonce: 0n,
|
|
772
782
|
nonceKey: undefined,
|
|
773
783
|
})
|
|
774
|
-
const serialized =
|
|
784
|
+
const serialized = TransactionEnvelopeTempo.serialize(transaction)
|
|
775
785
|
expect(serialized).toMatchInlineSnapshot(
|
|
776
786
|
`"0x76d101808080c4c3808080c0808080808080c0"`,
|
|
777
787
|
)
|
|
778
788
|
})
|
|
779
789
|
|
|
780
790
|
test('multiple calls', () => {
|
|
781
|
-
const transaction =
|
|
791
|
+
const transaction = TransactionEnvelopeTempo.from({
|
|
782
792
|
chainId: 1,
|
|
783
793
|
calls: [
|
|
784
794
|
{
|
|
@@ -792,7 +802,9 @@ describe('serialize', () => {
|
|
|
792
802
|
],
|
|
793
803
|
nonce: 0n,
|
|
794
804
|
})
|
|
795
|
-
expect(
|
|
805
|
+
expect(
|
|
806
|
+
TransactionEnvelopeTempo.serialize(transaction),
|
|
807
|
+
).toMatchInlineSnapshot(
|
|
796
808
|
`"0x76f84101808080f4d79470997970c51812dc3a010c7d01b50e0d17dc79c88080db943c44cdddb6a900fa2b585dd299e03d12fa4293bc8207d0821234c0808080808080c0"`,
|
|
797
809
|
)
|
|
798
810
|
})
|
|
@@ -815,19 +827,19 @@ describe('serialize', () => {
|
|
|
815
827
|
}),
|
|
816
828
|
})
|
|
817
829
|
|
|
818
|
-
const transaction =
|
|
830
|
+
const transaction = TransactionEnvelopeTempo.from({
|
|
819
831
|
chainId: 1,
|
|
820
832
|
calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' }],
|
|
821
833
|
nonce: 0n,
|
|
822
834
|
keyAuthorization,
|
|
823
835
|
})
|
|
824
836
|
|
|
825
|
-
const serialized =
|
|
837
|
+
const serialized = TransactionEnvelopeTempo.serialize(transaction)
|
|
826
838
|
expect(serialized).toMatchInlineSnapshot(
|
|
827
839
|
`"0x76f8a201808080d8d79470997970c51812dc3a010c7d01b50e0d17dc79c88080c0808080808080c0f87bf7808094be95c3f554e9fc85ec51be69a3d807a0d55bcf2c84499602d2dad99420c000000000000000000000000000000000000183989680b841635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f05401b"`,
|
|
828
840
|
)
|
|
829
841
|
|
|
830
|
-
const deserialized =
|
|
842
|
+
const deserialized = TransactionEnvelopeTempo.deserialize(serialized)
|
|
831
843
|
expect(deserialized.keyAuthorization).toEqual(keyAuthorization)
|
|
832
844
|
})
|
|
833
845
|
|
|
@@ -856,19 +868,19 @@ describe('serialize', () => {
|
|
|
856
868
|
}),
|
|
857
869
|
})
|
|
858
870
|
|
|
859
|
-
const transaction =
|
|
871
|
+
const transaction = TransactionEnvelopeTempo.from({
|
|
860
872
|
chainId: 1,
|
|
861
873
|
calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' }],
|
|
862
874
|
nonce: 0n,
|
|
863
875
|
keyAuthorization,
|
|
864
876
|
})
|
|
865
877
|
|
|
866
|
-
const serialized =
|
|
878
|
+
const serialized = TransactionEnvelopeTempo.serialize(transaction)
|
|
867
879
|
expect(serialized).toMatchInlineSnapshot(
|
|
868
880
|
`"0x76f8e301808080d8d79470997970c51812dc3a010c7d01b50e0d17dc79c88080c0808080808080c0f8bcf7800194be95c3f554e9fc85ec51be69a3d807a0d55bcf2c84499602d2dad99420c000000000000000000000000000000000000183989680b88201ccbb3485d4726235f13cb15ef394fb7158179fb7b1925eccec0147671090c52e77c3c53373cc1e3b05e7c23f609deb17cea8fe097300c45411237e9fe4166b35ad8ac16e167d6992c3e120d7f17d2376bc1cbcf30c46ba6dd00ce07303e742f511edf6ce1c32de66846f56afa7be1cbd729bc35750b6d0cdcf3ec9d75461aba001"`,
|
|
869
881
|
)
|
|
870
882
|
|
|
871
|
-
const deserialized =
|
|
883
|
+
const deserialized = TransactionEnvelopeTempo.deserialize(serialized)
|
|
872
884
|
expect(deserialized.keyAuthorization).toEqual(keyAuthorization)
|
|
873
885
|
})
|
|
874
886
|
|
|
@@ -907,36 +919,36 @@ describe('serialize', () => {
|
|
|
907
919
|
}),
|
|
908
920
|
})
|
|
909
921
|
|
|
910
|
-
const transaction =
|
|
922
|
+
const transaction = TransactionEnvelopeTempo.from({
|
|
911
923
|
chainId: 1,
|
|
912
924
|
calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' }],
|
|
913
925
|
nonce: 0n,
|
|
914
926
|
keyAuthorization,
|
|
915
927
|
})
|
|
916
928
|
|
|
917
|
-
const serialized =
|
|
929
|
+
const serialized = TransactionEnvelopeTempo.serialize(transaction)
|
|
918
930
|
expect(serialized).toMatchInlineSnapshot(
|
|
919
931
|
`"0x76f9016501808080d8d79470997970c51812dc3a010c7d01b50e0d17dc79c88080c0808080808080c0f9013df7800294be95c3f554e9fc85ec51be69a3d807a0d55bcf2c84499602d2dad99420c000000000000000000000000000000000000183989680b901020249960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d976305000000007b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a223371322d3777222c226f726967696e223a22687474703a2f2f6c6f63616c686f7374222c2263726f73734f726967696e223a66616c73657dccbb3485d4726235f13cb15ef394fb7158179fb7b1925eccec0147671090c52e77c3c53373cc1e3b05e7c23f609deb17cea8fe097300c45411237e9fe4166b35ad8ac16e167d6992c3e120d7f17d2376bc1cbcf30c46ba6dd00ce07303e742f511edf6ce1c32de66846f56afa7be1cbd729bc35750b6d0cdcf3ec9d75461aba0"`,
|
|
920
932
|
)
|
|
921
933
|
|
|
922
934
|
// Verify roundtrip
|
|
923
|
-
const deserialized =
|
|
935
|
+
const deserialized = TransactionEnvelopeTempo.deserialize(serialized)
|
|
924
936
|
expect(deserialized.keyAuthorization).toEqual(keyAuthorization)
|
|
925
937
|
})
|
|
926
938
|
|
|
927
939
|
describe('with signature', () => {
|
|
928
940
|
test('secp256k1', () => {
|
|
929
|
-
const transaction =
|
|
941
|
+
const transaction = TransactionEnvelopeTempo.from({
|
|
930
942
|
chainId: 1,
|
|
931
943
|
calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' }],
|
|
932
944
|
nonce: 0n,
|
|
933
945
|
})
|
|
934
946
|
const signature = Secp256k1.sign({
|
|
935
|
-
payload:
|
|
947
|
+
payload: TransactionEnvelopeTempo.getSignPayload(transaction),
|
|
936
948
|
privateKey,
|
|
937
949
|
})
|
|
938
950
|
expect(
|
|
939
|
-
|
|
951
|
+
TransactionEnvelopeTempo.serialize(transaction, {
|
|
940
952
|
signature: SignatureEnvelope.from(signature),
|
|
941
953
|
}),
|
|
942
954
|
).toMatchInlineSnapshot(
|
|
@@ -945,7 +957,7 @@ describe('serialize', () => {
|
|
|
945
957
|
})
|
|
946
958
|
|
|
947
959
|
test('p256', () => {
|
|
948
|
-
const transaction =
|
|
960
|
+
const transaction = TransactionEnvelopeTempo.from({
|
|
949
961
|
chainId: 1,
|
|
950
962
|
calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' }],
|
|
951
963
|
nonce: 0n,
|
|
@@ -953,10 +965,10 @@ describe('serialize', () => {
|
|
|
953
965
|
const privateKey = P256.randomPrivateKey()
|
|
954
966
|
const publicKey = P256.getPublicKey({ privateKey })
|
|
955
967
|
const signature = P256.sign({
|
|
956
|
-
payload:
|
|
968
|
+
payload: TransactionEnvelopeTempo.getSignPayload(transaction),
|
|
957
969
|
privateKey,
|
|
958
970
|
})
|
|
959
|
-
const serialized =
|
|
971
|
+
const serialized = TransactionEnvelopeTempo.serialize(transaction, {
|
|
960
972
|
signature: SignatureEnvelope.from({
|
|
961
973
|
signature,
|
|
962
974
|
publicKey,
|
|
@@ -966,7 +978,7 @@ describe('serialize', () => {
|
|
|
966
978
|
// biome-ignore lint/suspicious/noTsIgnore: _
|
|
967
979
|
// @ts-ignore
|
|
968
980
|
delete signature.yParity
|
|
969
|
-
expect(
|
|
981
|
+
expect(TransactionEnvelopeTempo.deserialize(serialized)).toEqual({
|
|
970
982
|
...transaction,
|
|
971
983
|
nonceKey: 0n,
|
|
972
984
|
signature: { prehash: true, publicKey, signature, type: 'p256' },
|
|
@@ -975,13 +987,13 @@ describe('serialize', () => {
|
|
|
975
987
|
})
|
|
976
988
|
|
|
977
989
|
test('with feePayerSignature', () => {
|
|
978
|
-
const transaction =
|
|
990
|
+
const transaction = TransactionEnvelopeTempo.from({
|
|
979
991
|
chainId: 1,
|
|
980
992
|
calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' }],
|
|
981
993
|
nonce: 0n,
|
|
982
994
|
})
|
|
983
995
|
expect(
|
|
984
|
-
|
|
996
|
+
TransactionEnvelopeTempo.serialize(transaction, {
|
|
985
997
|
feePayerSignature: {
|
|
986
998
|
r: 1n,
|
|
987
999
|
s: 2n,
|
|
@@ -994,13 +1006,13 @@ describe('serialize', () => {
|
|
|
994
1006
|
})
|
|
995
1007
|
|
|
996
1008
|
test('with feePayerSignature (null)', () => {
|
|
997
|
-
const transaction =
|
|
1009
|
+
const transaction = TransactionEnvelopeTempo.from({
|
|
998
1010
|
chainId: 1,
|
|
999
1011
|
calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' }],
|
|
1000
1012
|
nonce: 0n,
|
|
1001
1013
|
})
|
|
1002
1014
|
expect(
|
|
1003
|
-
|
|
1015
|
+
TransactionEnvelopeTempo.serialize(transaction, {
|
|
1004
1016
|
feePayerSignature: null,
|
|
1005
1017
|
}),
|
|
1006
1018
|
).toMatchInlineSnapshot(
|
|
@@ -1009,13 +1021,13 @@ describe('serialize', () => {
|
|
|
1009
1021
|
})
|
|
1010
1022
|
|
|
1011
1023
|
test('format: feePayer', () => {
|
|
1012
|
-
const transaction =
|
|
1024
|
+
const transaction = TransactionEnvelopeTempo.from({
|
|
1013
1025
|
chainId: 1,
|
|
1014
1026
|
calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' }],
|
|
1015
1027
|
nonce: 0n,
|
|
1016
1028
|
})
|
|
1017
1029
|
expect(
|
|
1018
|
-
|
|
1030
|
+
TransactionEnvelopeTempo.serialize(transaction, {
|
|
1019
1031
|
sender: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
|
|
1020
1032
|
format: 'feePayer',
|
|
1021
1033
|
}),
|
|
@@ -1028,7 +1040,7 @@ describe('serialize', () => {
|
|
|
1028
1040
|
describe('hash', () => {
|
|
1029
1041
|
describe('default', () => {
|
|
1030
1042
|
test('secp256k1', () => {
|
|
1031
|
-
const transaction =
|
|
1043
|
+
const transaction = TransactionEnvelopeTempo.from({
|
|
1032
1044
|
chainId: 1,
|
|
1033
1045
|
calls: [
|
|
1034
1046
|
{
|
|
@@ -1038,20 +1050,20 @@ describe('hash', () => {
|
|
|
1038
1050
|
nonce: 0n,
|
|
1039
1051
|
})
|
|
1040
1052
|
const signature = Secp256k1.sign({
|
|
1041
|
-
payload:
|
|
1053
|
+
payload: TransactionEnvelopeTempo.getSignPayload(transaction),
|
|
1042
1054
|
privateKey,
|
|
1043
1055
|
})
|
|
1044
|
-
const signed =
|
|
1056
|
+
const signed = TransactionEnvelopeTempo.from(transaction, {
|
|
1045
1057
|
signature: SignatureEnvelope.from(signature),
|
|
1046
1058
|
})
|
|
1047
|
-
expect(
|
|
1059
|
+
expect(TransactionEnvelopeTempo.hash(signed)).toMatchInlineSnapshot(
|
|
1048
1060
|
`"0x04ad27d1607bc3fc37445724d8864b0843f88008bafd818814474e5ee94647eb"`,
|
|
1049
1061
|
)
|
|
1050
1062
|
})
|
|
1051
1063
|
})
|
|
1052
1064
|
|
|
1053
1065
|
test('presign', () => {
|
|
1054
|
-
const transaction =
|
|
1066
|
+
const transaction = TransactionEnvelopeTempo.from({
|
|
1055
1067
|
chainId: 1,
|
|
1056
1068
|
calls: [
|
|
1057
1069
|
{
|
|
@@ -1061,7 +1073,7 @@ describe('hash', () => {
|
|
|
1061
1073
|
nonce: 0n,
|
|
1062
1074
|
})
|
|
1063
1075
|
expect(
|
|
1064
|
-
|
|
1076
|
+
TransactionEnvelopeTempo.hash(transaction, { presign: true }),
|
|
1065
1077
|
).toMatchInlineSnapshot(
|
|
1066
1078
|
`"0xe1222a45806457acbe3a13940aae4c34f3180659fa16613b5a45dc183adae07c"`,
|
|
1067
1079
|
)
|
|
@@ -1070,7 +1082,7 @@ describe('hash', () => {
|
|
|
1070
1082
|
|
|
1071
1083
|
describe('getSignPayload', () => {
|
|
1072
1084
|
test('default', () => {
|
|
1073
|
-
const transaction =
|
|
1085
|
+
const transaction = TransactionEnvelopeTempo.from({
|
|
1074
1086
|
chainId: 1,
|
|
1075
1087
|
calls: [
|
|
1076
1088
|
{
|
|
@@ -1080,7 +1092,7 @@ describe('getSignPayload', () => {
|
|
|
1080
1092
|
nonce: 0n,
|
|
1081
1093
|
})
|
|
1082
1094
|
expect(
|
|
1083
|
-
|
|
1095
|
+
TransactionEnvelopeTempo.getSignPayload(transaction),
|
|
1084
1096
|
).toMatchInlineSnapshot(
|
|
1085
1097
|
`"0xe1222a45806457acbe3a13940aae4c34f3180659fa16613b5a45dc183adae07c"`,
|
|
1086
1098
|
)
|
|
@@ -1089,7 +1101,7 @@ describe('getSignPayload', () => {
|
|
|
1089
1101
|
|
|
1090
1102
|
describe('getFeePayerSignPayload', () => {
|
|
1091
1103
|
test('default', () => {
|
|
1092
|
-
const transaction =
|
|
1104
|
+
const transaction = TransactionEnvelopeTempo.from({
|
|
1093
1105
|
chainId: 1,
|
|
1094
1106
|
calls: [
|
|
1095
1107
|
{
|
|
@@ -1099,7 +1111,7 @@ describe('getFeePayerSignPayload', () => {
|
|
|
1099
1111
|
nonce: 0n,
|
|
1100
1112
|
})
|
|
1101
1113
|
expect(
|
|
1102
|
-
|
|
1114
|
+
TransactionEnvelopeTempo.getFeePayerSignPayload(transaction, {
|
|
1103
1115
|
sender: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
|
|
1104
1116
|
}),
|
|
1105
1117
|
).toMatchInlineSnapshot(
|
|
@@ -1108,7 +1120,7 @@ describe('getFeePayerSignPayload', () => {
|
|
|
1108
1120
|
})
|
|
1109
1121
|
|
|
1110
1122
|
test('with feeToken', () => {
|
|
1111
|
-
const transaction =
|
|
1123
|
+
const transaction = TransactionEnvelopeTempo.from({
|
|
1112
1124
|
chainId: 1,
|
|
1113
1125
|
calls: [
|
|
1114
1126
|
{
|
|
@@ -1118,18 +1130,21 @@ describe('getFeePayerSignPayload', () => {
|
|
|
1118
1130
|
nonce: 0n,
|
|
1119
1131
|
feeToken: '0x20c0000000000000000000000000000000000000',
|
|
1120
1132
|
})
|
|
1121
|
-
const hash1 =
|
|
1133
|
+
const hash1 = TransactionEnvelopeTempo.getFeePayerSignPayload(transaction, {
|
|
1122
1134
|
sender: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
|
|
1123
1135
|
})
|
|
1124
1136
|
|
|
1125
1137
|
// Change feeToken - hash should be different
|
|
1126
|
-
const transaction2 =
|
|
1138
|
+
const transaction2 = TransactionEnvelopeTempo.from({
|
|
1127
1139
|
...transaction,
|
|
1128
1140
|
feeToken: '0x20c0000000000000000000000000000000000001',
|
|
1129
1141
|
})
|
|
1130
|
-
const hash2 =
|
|
1131
|
-
|
|
1132
|
-
|
|
1142
|
+
const hash2 = TransactionEnvelopeTempo.getFeePayerSignPayload(
|
|
1143
|
+
transaction2,
|
|
1144
|
+
{
|
|
1145
|
+
sender: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
|
|
1146
|
+
},
|
|
1147
|
+
)
|
|
1133
1148
|
|
|
1134
1149
|
expect(hash1).not.toBe(hash2)
|
|
1135
1150
|
})
|
|
@@ -1138,7 +1153,7 @@ describe('getFeePayerSignPayload', () => {
|
|
|
1138
1153
|
describe('validate', () => {
|
|
1139
1154
|
test('valid', () => {
|
|
1140
1155
|
expect(
|
|
1141
|
-
|
|
1156
|
+
TransactionEnvelopeTempo.validate({
|
|
1142
1157
|
calls: [{ to: '0x0000000000000000000000000000000000000000' }],
|
|
1143
1158
|
chainId: 1,
|
|
1144
1159
|
}),
|
|
@@ -1147,7 +1162,7 @@ describe('validate', () => {
|
|
|
1147
1162
|
|
|
1148
1163
|
test('invalid (empty calls)', () => {
|
|
1149
1164
|
expect(
|
|
1150
|
-
|
|
1165
|
+
TransactionEnvelopeTempo.validate({
|
|
1151
1166
|
calls: [],
|
|
1152
1167
|
chainId: 1,
|
|
1153
1168
|
}),
|
|
@@ -1156,7 +1171,7 @@ describe('validate', () => {
|
|
|
1156
1171
|
|
|
1157
1172
|
test('invalid (validity window)', () => {
|
|
1158
1173
|
expect(
|
|
1159
|
-
|
|
1174
|
+
TransactionEnvelopeTempo.validate({
|
|
1160
1175
|
calls: [{ to: '0x0000000000000000000000000000000000000000' }],
|
|
1161
1176
|
chainId: 1,
|
|
1162
1177
|
validBefore: 100,
|