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
|
@@ -19,7 +19,7 @@ import * as SignatureEnvelope from './SignatureEnvelope.js'
|
|
|
19
19
|
import * as TokenId from './TokenId.js'
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
* Represents a single call within
|
|
22
|
+
* Represents a single call within a Tempo transaction.
|
|
23
23
|
*/
|
|
24
24
|
export type Call<bigintType = bigint> = {
|
|
25
25
|
/** Call data. */
|
|
@@ -30,7 +30,7 @@ export type Call<bigintType = bigint> = {
|
|
|
30
30
|
value?: bigintType | undefined
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export type
|
|
33
|
+
export type TransactionEnvelopeTempo<
|
|
34
34
|
signed extends boolean = boolean,
|
|
35
35
|
bigintType = bigint,
|
|
36
36
|
numberType = number,
|
|
@@ -93,7 +93,7 @@ export type TransactionEnvelopeAA<
|
|
|
93
93
|
})
|
|
94
94
|
>
|
|
95
95
|
|
|
96
|
-
export type Rpc<signed extends boolean = boolean> =
|
|
96
|
+
export type Rpc<signed extends boolean = boolean> = TransactionEnvelopeTempo<
|
|
97
97
|
signed,
|
|
98
98
|
Hex.Hex,
|
|
99
99
|
Hex.Hex,
|
|
@@ -105,22 +105,22 @@ export type FeePayerMagic = typeof feePayerMagic
|
|
|
105
105
|
|
|
106
106
|
export type Serialized = `${SerializedType}${string}`
|
|
107
107
|
|
|
108
|
-
export type Signed =
|
|
108
|
+
export type Signed = TransactionEnvelopeTempo<true>
|
|
109
109
|
|
|
110
110
|
export const serializedType = '0x76' as const
|
|
111
111
|
export type SerializedType = typeof serializedType
|
|
112
112
|
|
|
113
|
-
export const type = '
|
|
113
|
+
export const type = 'tempo' as const
|
|
114
114
|
export type Type = typeof type
|
|
115
115
|
|
|
116
116
|
/**
|
|
117
|
-
* Asserts a {@link ox#
|
|
117
|
+
* Asserts a {@link ox#TransactionEnvelopeTempo.TransactionEnvelopeTempo} is valid.
|
|
118
118
|
*
|
|
119
119
|
* @example
|
|
120
120
|
* ```ts twoslash
|
|
121
|
-
* import {
|
|
121
|
+
* import { TransactionEnvelopeTempo } from 'ox/tempo'
|
|
122
122
|
*
|
|
123
|
-
*
|
|
123
|
+
* TransactionEnvelopeTempo.assert({
|
|
124
124
|
* calls: [{ to: '0x0000000000000000000000000000000000000000', value: 0n }],
|
|
125
125
|
* chainId: 1,
|
|
126
126
|
* maxFeePerGas: 1000000000n,
|
|
@@ -129,7 +129,7 @@ export type Type = typeof type
|
|
|
129
129
|
*
|
|
130
130
|
* @param envelope - The transaction envelope to assert.
|
|
131
131
|
*/
|
|
132
|
-
export function assert(envelope: PartialBy<
|
|
132
|
+
export function assert(envelope: PartialBy<TransactionEnvelopeTempo, 'type'>) {
|
|
133
133
|
const {
|
|
134
134
|
calls,
|
|
135
135
|
chainId,
|
|
@@ -189,15 +189,15 @@ export declare namespace assert {
|
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
/**
|
|
192
|
-
* Deserializes a {@link ox#
|
|
192
|
+
* Deserializes a {@link ox#TransactionEnvelopeTempo.TransactionEnvelopeTempo} from its serialized form.
|
|
193
193
|
*
|
|
194
194
|
* @example
|
|
195
195
|
* ```ts twoslash
|
|
196
|
-
* import {
|
|
196
|
+
* import { TransactionEnvelopeTempo } from 'ox/tempo'
|
|
197
197
|
*
|
|
198
|
-
* const envelope =
|
|
198
|
+
* const envelope = TransactionEnvelopeTempo.deserialize('0x76f84a0182031184773594008477359400809470997970c51812dc3a010c7d01b50e0d17dc79c8880de0b6b3a764000080c0808080')
|
|
199
199
|
* // @log: {
|
|
200
|
-
* // @log: type: '
|
|
200
|
+
* // @log: type: 'tempo',
|
|
201
201
|
* // @log: nonce: 785n,
|
|
202
202
|
* // @log: maxFeePerGas: 2000000000n,
|
|
203
203
|
* // @log: gas: 1000000n,
|
|
@@ -210,7 +210,7 @@ export declare namespace assert {
|
|
|
210
210
|
*/
|
|
211
211
|
export function deserialize(
|
|
212
212
|
serialized: Serialized,
|
|
213
|
-
): Compute<
|
|
213
|
+
): Compute<TransactionEnvelopeTempo> {
|
|
214
214
|
const transactionArray = Rlp.toHex(Hex.slice(serialized, 1))
|
|
215
215
|
|
|
216
216
|
const [
|
|
@@ -273,7 +273,7 @@ export function deserialize(
|
|
|
273
273
|
let transaction = {
|
|
274
274
|
chainId: Number(chainId),
|
|
275
275
|
type,
|
|
276
|
-
} as
|
|
276
|
+
} as TransactionEnvelopeTempo
|
|
277
277
|
|
|
278
278
|
if (Hex.validate(gas) && gas !== '0x') transaction.gas = BigInt(gas)
|
|
279
279
|
if (Hex.validate(nonce))
|
|
@@ -346,14 +346,14 @@ export declare namespace deserialize {
|
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
/**
|
|
349
|
-
* Converts an arbitrary transaction object into
|
|
349
|
+
* Converts an arbitrary transaction object into a Tempo Transaction Envelope.
|
|
350
350
|
*
|
|
351
351
|
* @example
|
|
352
352
|
* ```ts twoslash
|
|
353
353
|
* import { Value } from 'ox'
|
|
354
|
-
* import {
|
|
354
|
+
* import { TransactionEnvelopeTempo } from 'ox/tempo'
|
|
355
355
|
*
|
|
356
|
-
* const envelope =
|
|
356
|
+
* const envelope = TransactionEnvelopeTempo.from({ // [!code focus]
|
|
357
357
|
* chainId: 1, // [!code focus]
|
|
358
358
|
* calls: [{ to: '0x0000000000000000000000000000000000000000', value: Value.fromEther('1') }], // [!code focus]
|
|
359
359
|
* maxFeePerGas: Value.fromGwei('10'), // [!code focus]
|
|
@@ -369,9 +369,9 @@ export declare namespace deserialize {
|
|
|
369
369
|
* ```ts twoslash
|
|
370
370
|
* // @noErrors
|
|
371
371
|
* import { Secp256k1, Value } from 'ox'
|
|
372
|
-
* import {
|
|
372
|
+
* import { TransactionEnvelopeTempo } from 'ox/tempo'
|
|
373
373
|
*
|
|
374
|
-
* const envelope =
|
|
374
|
+
* const envelope = TransactionEnvelopeTempo.from({
|
|
375
375
|
* chainId: 1,
|
|
376
376
|
* calls: [{ to: '0x0000000000000000000000000000000000000000', value: Value.fromEther('1') }],
|
|
377
377
|
* maxFeePerGas: Value.fromGwei('10'),
|
|
@@ -379,11 +379,11 @@ export declare namespace deserialize {
|
|
|
379
379
|
* })
|
|
380
380
|
*
|
|
381
381
|
* const signature = Secp256k1.sign({
|
|
382
|
-
* payload:
|
|
382
|
+
* payload: TransactionEnvelopeTempo.getSignPayload(envelope),
|
|
383
383
|
* privateKey: '0x...',
|
|
384
384
|
* })
|
|
385
385
|
*
|
|
386
|
-
* const envelope_signed =
|
|
386
|
+
* const envelope_signed = TransactionEnvelopeTempo.from(envelope, { // [!code focus]
|
|
387
387
|
* signature, // [!code focus]
|
|
388
388
|
* }) // [!code focus]
|
|
389
389
|
* // @log: {
|
|
@@ -391,7 +391,7 @@ export declare namespace deserialize {
|
|
|
391
391
|
* // @log: calls: [{ to: '0x0000000000000000000000000000000000000000', value: 1000000000000000000n }],
|
|
392
392
|
* // @log: maxFeePerGas: 10000000000n,
|
|
393
393
|
* // @log: maxPriorityFeePerGas: 1000000000n,
|
|
394
|
-
* // @log: type: '
|
|
394
|
+
* // @log: type: 'tempo',
|
|
395
395
|
* // @log: r: 125...n,
|
|
396
396
|
* // @log: s: 642...n,
|
|
397
397
|
* // @log: yParity: 0,
|
|
@@ -401,27 +401,27 @@ export declare namespace deserialize {
|
|
|
401
401
|
* @example
|
|
402
402
|
* ### From Serialized
|
|
403
403
|
*
|
|
404
|
-
* It is possible to instantiate
|
|
404
|
+
* It is possible to instantiate a Tempo Transaction Envelope from a {@link ox#TransactionEnvelopeTempo.Serialized} value.
|
|
405
405
|
*
|
|
406
406
|
* ```ts twoslash
|
|
407
|
-
* import {
|
|
407
|
+
* import { TransactionEnvelopeTempo } from 'ox/tempo'
|
|
408
408
|
*
|
|
409
|
-
* const envelope =
|
|
409
|
+
* const envelope = TransactionEnvelopeTempo.from('0x76f84a0182031184773594008477359400809470997970c51812dc3a010c7d01b50e0d17dc79c8880de0b6b3a764000080c0808080')
|
|
410
410
|
* // @log: {
|
|
411
411
|
* // @log: chainId: 1,
|
|
412
412
|
* // @log: calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n }],
|
|
413
413
|
* // @log: maxFeePerGas: 10000000000n,
|
|
414
|
-
* // @log: type: '
|
|
414
|
+
* // @log: type: 'tempo',
|
|
415
415
|
* // @log: }
|
|
416
416
|
* ```
|
|
417
417
|
*
|
|
418
418
|
* @param envelope - The transaction object to convert.
|
|
419
419
|
* @param options - Options.
|
|
420
|
-
* @returns
|
|
420
|
+
* @returns A Tempo Transaction Envelope.
|
|
421
421
|
*/
|
|
422
422
|
export function from<
|
|
423
423
|
const envelope extends
|
|
424
|
-
| UnionPartialBy<
|
|
424
|
+
| UnionPartialBy<TransactionEnvelopeTempo, 'type'>
|
|
425
425
|
| Serialized,
|
|
426
426
|
const signature extends
|
|
427
427
|
| SignatureEnvelope.SignatureEnvelope
|
|
@@ -429,7 +429,7 @@ export function from<
|
|
|
429
429
|
>(
|
|
430
430
|
envelope:
|
|
431
431
|
| envelope
|
|
432
|
-
| UnionPartialBy<
|
|
432
|
+
| UnionPartialBy<TransactionEnvelopeTempo, 'type'>
|
|
433
433
|
| Serialized,
|
|
434
434
|
options: from.Options<signature> = {},
|
|
435
435
|
): from.ReturnValue<envelope, signature> {
|
|
@@ -437,7 +437,7 @@ export function from<
|
|
|
437
437
|
|
|
438
438
|
const envelope_ = (
|
|
439
439
|
typeof envelope === 'string' ? deserialize(envelope) : envelope
|
|
440
|
-
) as
|
|
440
|
+
) as TransactionEnvelopeTempo
|
|
441
441
|
|
|
442
442
|
assert(envelope_)
|
|
443
443
|
|
|
@@ -447,7 +447,7 @@ export function from<
|
|
|
447
447
|
...(feePayerSignature
|
|
448
448
|
? { feePayerSignature: Signature.from(feePayerSignature) }
|
|
449
449
|
: {}),
|
|
450
|
-
type: '
|
|
450
|
+
type: 'tempo',
|
|
451
451
|
} as never
|
|
452
452
|
}
|
|
453
453
|
|
|
@@ -462,21 +462,21 @@ export declare namespace from {
|
|
|
462
462
|
}
|
|
463
463
|
|
|
464
464
|
type ReturnValue<
|
|
465
|
-
envelope extends
|
|
466
|
-
|
|
|
467
|
-
| Hex.Hex,
|
|
465
|
+
envelope extends
|
|
466
|
+
| UnionPartialBy<TransactionEnvelopeTempo, 'type'>
|
|
467
|
+
| Hex.Hex = TransactionEnvelopeTempo | Hex.Hex,
|
|
468
468
|
signature extends
|
|
469
469
|
| SignatureEnvelope.SignatureEnvelope
|
|
470
470
|
| undefined = undefined,
|
|
471
471
|
> = Compute<
|
|
472
472
|
envelope extends Hex.Hex
|
|
473
|
-
?
|
|
473
|
+
? TransactionEnvelopeTempo
|
|
474
474
|
: Assign<
|
|
475
475
|
envelope,
|
|
476
476
|
(signature extends SignatureEnvelope.SignatureEnvelope
|
|
477
477
|
? { signature: SignatureEnvelope.from.ReturnValue<signature> }
|
|
478
478
|
: {}) & {
|
|
479
|
-
readonly type: '
|
|
479
|
+
readonly type: 'tempo'
|
|
480
480
|
}
|
|
481
481
|
>
|
|
482
482
|
>
|
|
@@ -488,21 +488,21 @@ export declare namespace from {
|
|
|
488
488
|
}
|
|
489
489
|
|
|
490
490
|
/**
|
|
491
|
-
* Serializes a {@link ox#
|
|
491
|
+
* Serializes a {@link ox#TransactionEnvelopeTempo.TransactionEnvelopeTempo}.
|
|
492
492
|
*
|
|
493
493
|
* @example
|
|
494
494
|
* ```ts twoslash
|
|
495
495
|
* // @noErrors
|
|
496
496
|
* import { Value } from 'ox'
|
|
497
|
-
* import {
|
|
497
|
+
* import { TransactionEnvelopeTempo } from 'ox/tempo'
|
|
498
498
|
*
|
|
499
|
-
* const envelope =
|
|
499
|
+
* const envelope = TransactionEnvelopeTempo.from({
|
|
500
500
|
* chainId: 1,
|
|
501
501
|
* calls: [{ to: '0x0000000000000000000000000000000000000000', value: Value.fromEther('1') }],
|
|
502
502
|
* maxFeePerGas: Value.fromGwei('10'),
|
|
503
503
|
* })
|
|
504
504
|
*
|
|
505
|
-
* const serialized =
|
|
505
|
+
* const serialized = TransactionEnvelopeTempo.serialize(envelope) // [!code focus]
|
|
506
506
|
* ```
|
|
507
507
|
*
|
|
508
508
|
* @example
|
|
@@ -513,20 +513,20 @@ export declare namespace from {
|
|
|
513
513
|
* ```ts twoslash
|
|
514
514
|
* // @noErrors
|
|
515
515
|
* import { Secp256k1, Value } from 'ox'
|
|
516
|
-
* import {
|
|
516
|
+
* import { TransactionEnvelopeTempo } from 'ox/tempo'
|
|
517
517
|
*
|
|
518
|
-
* const envelope =
|
|
518
|
+
* const envelope = TransactionEnvelopeTempo.from({
|
|
519
519
|
* chainId: 1,
|
|
520
520
|
* calls: [{ to: '0x0000000000000000000000000000000000000000', value: Value.fromEther('1') }],
|
|
521
521
|
* maxFeePerGas: Value.fromGwei('10'),
|
|
522
522
|
* })
|
|
523
523
|
*
|
|
524
524
|
* const signature = Secp256k1.sign({
|
|
525
|
-
* payload:
|
|
525
|
+
* payload: TransactionEnvelopeTempo.getSignPayload(envelope),
|
|
526
526
|
* privateKey: '0x...',
|
|
527
527
|
* })
|
|
528
528
|
*
|
|
529
|
-
* const serialized =
|
|
529
|
+
* const serialized = TransactionEnvelopeTempo.serialize(envelope, { // [!code focus]
|
|
530
530
|
* signature, // [!code focus]
|
|
531
531
|
* }) // [!code focus]
|
|
532
532
|
*
|
|
@@ -538,7 +538,7 @@ export declare namespace from {
|
|
|
538
538
|
* @returns The serialized Transaction Envelope.
|
|
539
539
|
*/
|
|
540
540
|
export function serialize(
|
|
541
|
-
envelope: PartialBy<
|
|
541
|
+
envelope: PartialBy<TransactionEnvelopeTempo, 'type'>,
|
|
542
542
|
options: serialize.Options = {},
|
|
543
543
|
): Serialized {
|
|
544
544
|
const {
|
|
@@ -649,7 +649,7 @@ export declare namespace serialize {
|
|
|
649
649
|
}
|
|
650
650
|
|
|
651
651
|
/**
|
|
652
|
-
* Returns the payload to sign for a {@link ox#
|
|
652
|
+
* Returns the payload to sign for a {@link ox#TransactionEnvelopeTempo.TransactionEnvelopeTempo}.
|
|
653
653
|
*
|
|
654
654
|
* @example
|
|
655
655
|
* The example below demonstrates how to compute the sign payload which can be used
|
|
@@ -658,9 +658,9 @@ export declare namespace serialize {
|
|
|
658
658
|
* ```ts twoslash
|
|
659
659
|
* // @noErrors
|
|
660
660
|
* import { Secp256k1 } from 'ox'
|
|
661
|
-
* import {
|
|
661
|
+
* import { TransactionEnvelopeTempo } from 'ox/tempo'
|
|
662
662
|
*
|
|
663
|
-
* const envelope =
|
|
663
|
+
* const envelope = TransactionEnvelopeTempo.from({
|
|
664
664
|
* chainId: 1,
|
|
665
665
|
* calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n }],
|
|
666
666
|
* nonce: 0n,
|
|
@@ -668,7 +668,7 @@ export declare namespace serialize {
|
|
|
668
668
|
* gas: 21000n,
|
|
669
669
|
* })
|
|
670
670
|
*
|
|
671
|
-
* const payload =
|
|
671
|
+
* const payload = TransactionEnvelopeTempo.getSignPayload(envelope) // [!code focus]
|
|
672
672
|
* // @log: '0x...'
|
|
673
673
|
*
|
|
674
674
|
* const signature = Secp256k1.sign({ payload, privateKey: '0x...' })
|
|
@@ -678,7 +678,7 @@ export declare namespace serialize {
|
|
|
678
678
|
* @returns The sign payload.
|
|
679
679
|
*/
|
|
680
680
|
export function getSignPayload(
|
|
681
|
-
envelope:
|
|
681
|
+
envelope: TransactionEnvelopeTempo,
|
|
682
682
|
): getSignPayload.ReturnValue {
|
|
683
683
|
return hash(envelope, { presign: true })
|
|
684
684
|
}
|
|
@@ -690,15 +690,15 @@ export declare namespace getSignPayload {
|
|
|
690
690
|
}
|
|
691
691
|
|
|
692
692
|
/**
|
|
693
|
-
* Hashes a {@link ox#
|
|
693
|
+
* Hashes a {@link ox#TransactionEnvelopeTempo.TransactionEnvelopeTempo}. This is the "transaction hash".
|
|
694
694
|
*
|
|
695
695
|
* @example
|
|
696
696
|
* ```ts twoslash
|
|
697
697
|
* // @noErrors
|
|
698
698
|
* import { Secp256k1 } from 'ox'
|
|
699
|
-
* import {
|
|
699
|
+
* import { TransactionEnvelopeTempo } from 'ox/tempo'
|
|
700
700
|
*
|
|
701
|
-
* const envelope =
|
|
701
|
+
* const envelope = TransactionEnvelopeTempo.from({
|
|
702
702
|
* chainId: 1,
|
|
703
703
|
* calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n }],
|
|
704
704
|
* nonce: 0n,
|
|
@@ -707,21 +707,21 @@ export declare namespace getSignPayload {
|
|
|
707
707
|
* })
|
|
708
708
|
*
|
|
709
709
|
* const signature = Secp256k1.sign({
|
|
710
|
-
* payload:
|
|
710
|
+
* payload: TransactionEnvelopeTempo.getSignPayload(envelope),
|
|
711
711
|
* privateKey: '0x...'
|
|
712
712
|
* })
|
|
713
713
|
*
|
|
714
|
-
* const envelope_signed =
|
|
714
|
+
* const envelope_signed = TransactionEnvelopeTempo.from(envelope, { signature })
|
|
715
715
|
*
|
|
716
|
-
* const hash =
|
|
716
|
+
* const hash = TransactionEnvelopeTempo.hash(envelope_signed) // [!code focus]
|
|
717
717
|
* ```
|
|
718
718
|
*
|
|
719
|
-
* @param envelope - The
|
|
719
|
+
* @param envelope - The Tempo Transaction Envelope to hash.
|
|
720
720
|
* @param options - Options.
|
|
721
721
|
* @returns The hash of the transaction envelope.
|
|
722
722
|
*/
|
|
723
723
|
export function hash<presign extends boolean = false>(
|
|
724
|
-
envelope:
|
|
724
|
+
envelope: TransactionEnvelopeTempo<presign extends true ? false : true>,
|
|
725
725
|
options: hash.Options<presign> = {},
|
|
726
726
|
): hash.ReturnValue {
|
|
727
727
|
const serialized = serialize({
|
|
@@ -754,15 +754,15 @@ export declare namespace hash {
|
|
|
754
754
|
}
|
|
755
755
|
|
|
756
756
|
/**
|
|
757
|
-
* Returns the fee payer payload to sign for a {@link ox#
|
|
757
|
+
* Returns the fee payer payload to sign for a {@link ox#TransactionEnvelopeTempo.TransactionEnvelopeTempo}.
|
|
758
758
|
*
|
|
759
759
|
* @example
|
|
760
760
|
* ```ts twoslash
|
|
761
761
|
* // @noErrors
|
|
762
762
|
* import { Secp256k1 } from 'ox'
|
|
763
|
-
* import {
|
|
763
|
+
* import { TransactionEnvelopeTempo } from 'ox/tempo'
|
|
764
764
|
*
|
|
765
|
-
* const envelope =
|
|
765
|
+
* const envelope = TransactionEnvelopeTempo.from({
|
|
766
766
|
* chainId: 1,
|
|
767
767
|
* calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n }],
|
|
768
768
|
* nonce: 0n,
|
|
@@ -770,7 +770,7 @@ export declare namespace hash {
|
|
|
770
770
|
* gas: 21000n,
|
|
771
771
|
* })
|
|
772
772
|
*
|
|
773
|
-
* const payload =
|
|
773
|
+
* const payload = TransactionEnvelopeTempo.getFeePayerSignPayload(envelope, {
|
|
774
774
|
* sender: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045'
|
|
775
775
|
* }) // [!code focus]
|
|
776
776
|
* // @log: '0x...'
|
|
@@ -783,7 +783,7 @@ export declare namespace hash {
|
|
|
783
783
|
* @returns The fee payer sign payload.
|
|
784
784
|
*/
|
|
785
785
|
export function getFeePayerSignPayload(
|
|
786
|
-
envelope:
|
|
786
|
+
envelope: TransactionEnvelopeTempo,
|
|
787
787
|
options: getFeePayerSignPayload.Options,
|
|
788
788
|
): getFeePayerSignPayload.ReturnValue {
|
|
789
789
|
const { sender } = options
|
|
@@ -811,13 +811,13 @@ export declare namespace getFeePayerSignPayload {
|
|
|
811
811
|
}
|
|
812
812
|
|
|
813
813
|
/**
|
|
814
|
-
* Validates a {@link ox#
|
|
814
|
+
* Validates a {@link ox#TransactionEnvelopeTempo.TransactionEnvelopeTempo}. Returns `true` if the envelope is valid, `false` otherwise.
|
|
815
815
|
*
|
|
816
816
|
* @example
|
|
817
817
|
* ```ts twoslash
|
|
818
|
-
* import {
|
|
818
|
+
* import { TransactionEnvelopeTempo } from 'ox/tempo'
|
|
819
819
|
*
|
|
820
|
-
* const valid =
|
|
820
|
+
* const valid = TransactionEnvelopeTempo.validate({
|
|
821
821
|
* calls: [{ to: '0x0000000000000000000000000000000000000000', value: 0n }],
|
|
822
822
|
* chainId: 1,
|
|
823
823
|
* maxFeePerGas: 1000000000n,
|
|
@@ -827,7 +827,9 @@ export declare namespace getFeePayerSignPayload {
|
|
|
827
827
|
*
|
|
828
828
|
* @param envelope - The transaction envelope to validate.
|
|
829
829
|
*/
|
|
830
|
-
export function validate(
|
|
830
|
+
export function validate(
|
|
831
|
+
envelope: PartialBy<TransactionEnvelopeTempo, 'type'>,
|
|
832
|
+
) {
|
|
831
833
|
try {
|
|
832
834
|
assert(envelope)
|
|
833
835
|
return true
|
|
@@ -845,17 +847,17 @@ export declare namespace validate {
|
|
|
845
847
|
*
|
|
846
848
|
* @example
|
|
847
849
|
* ```ts twoslash
|
|
848
|
-
* import {
|
|
850
|
+
* import { TransactionEnvelopeTempo } from 'ox/tempo'
|
|
849
851
|
*
|
|
850
|
-
*
|
|
852
|
+
* TransactionEnvelopeTempo.assert({
|
|
851
853
|
* calls: [],
|
|
852
854
|
* chainId: 1,
|
|
853
855
|
* })
|
|
854
|
-
* // @error:
|
|
856
|
+
* // @error: TransactionEnvelopeTempo.CallsEmptyError: Calls list cannot be empty.
|
|
855
857
|
* ```
|
|
856
858
|
*/
|
|
857
859
|
export class CallsEmptyError extends Errors.BaseError {
|
|
858
|
-
override readonly name = '
|
|
860
|
+
override readonly name = 'TransactionEnvelopeTempo.CallsEmptyError'
|
|
859
861
|
constructor() {
|
|
860
862
|
super('Calls list cannot be empty.')
|
|
861
863
|
}
|
|
@@ -866,19 +868,19 @@ export class CallsEmptyError extends Errors.BaseError {
|
|
|
866
868
|
*
|
|
867
869
|
* @example
|
|
868
870
|
* ```ts twoslash
|
|
869
|
-
* import {
|
|
871
|
+
* import { TransactionEnvelopeTempo } from 'ox/tempo'
|
|
870
872
|
*
|
|
871
|
-
*
|
|
873
|
+
* TransactionEnvelopeTempo.assert({
|
|
872
874
|
* calls: [{ to: '0x0000000000000000000000000000000000000000' }],
|
|
873
875
|
* chainId: 1,
|
|
874
876
|
* validBefore: 100n,
|
|
875
877
|
* validAfter: 200n,
|
|
876
878
|
* })
|
|
877
|
-
* // @error:
|
|
879
|
+
* // @error: TransactionEnvelopeTempo.InvalidValidityWindowError: validBefore (100) must be greater than validAfter (200).
|
|
878
880
|
* ```
|
|
879
881
|
*/
|
|
880
882
|
export class InvalidValidityWindowError extends Errors.BaseError {
|
|
881
|
-
override readonly name = '
|
|
883
|
+
override readonly name = 'TransactionEnvelopeTempo.InvalidValidityWindowError'
|
|
882
884
|
constructor({
|
|
883
885
|
validBefore,
|
|
884
886
|
validAfter,
|
|
@@ -29,7 +29,7 @@ export type Rpc = TransactionReceipt<
|
|
|
29
29
|
Hex.Hex
|
|
30
30
|
>
|
|
31
31
|
|
|
32
|
-
export type Type = '
|
|
32
|
+
export type Type = 'tempo' | ox_TransactionReceipt.Type
|
|
33
33
|
|
|
34
34
|
export type RpcType = '0x76' | ox_TransactionReceipt.RpcType
|
|
35
35
|
|
|
@@ -40,13 +40,13 @@ export type RpcStatus = ox_TransactionReceipt.RpcStatus
|
|
|
40
40
|
/** RPC type to type mapping. */
|
|
41
41
|
export const fromRpcType = {
|
|
42
42
|
...ox_TransactionReceipt.fromRpcType,
|
|
43
|
-
'0x76': '
|
|
43
|
+
'0x76': 'tempo',
|
|
44
44
|
} as const
|
|
45
45
|
|
|
46
46
|
/** Type to RPC type mapping. */
|
|
47
47
|
export const toRpcType = {
|
|
48
48
|
...ox_TransactionReceipt.toRpcType,
|
|
49
|
-
|
|
49
|
+
tempo: '0x76',
|
|
50
50
|
} as const
|
|
51
51
|
|
|
52
52
|
/**
|
|
@@ -6,7 +6,7 @@ import type { Compute } from '../internal/types.js'
|
|
|
6
6
|
import * as KeyAuthorization from './KeyAuthorization.js'
|
|
7
7
|
import * as TokenId from './TokenId.js'
|
|
8
8
|
import * as Transaction from './Transaction.js'
|
|
9
|
-
import type { Call } from './
|
|
9
|
+
import type { Call } from './TransactionEnvelopeTempo.js'
|
|
10
10
|
|
|
11
11
|
type KeyType = 'secp256k1' | 'p256' | 'webAuthn'
|
|
12
12
|
|
|
@@ -113,9 +113,9 @@ export function toRpc(request: TransactionRequest): Rpc {
|
|
|
113
113
|
typeof request.feeToken !== 'undefined' ||
|
|
114
114
|
typeof request.validBefore !== 'undefined' ||
|
|
115
115
|
typeof request.validAfter !== 'undefined' ||
|
|
116
|
-
request.type === '
|
|
116
|
+
request.type === 'tempo'
|
|
117
117
|
) {
|
|
118
|
-
request_rpc.type = Transaction.toRpcType.
|
|
118
|
+
request_rpc.type = Transaction.toRpcType.tempo
|
|
119
119
|
delete request_rpc.data
|
|
120
120
|
delete request_rpc.input
|
|
121
121
|
delete request_rpc.to
|