tempo.ts 0.10.5 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/README.md +0 -41
- package/dist/viem/Account.d.ts +8 -3
- package/dist/viem/Account.d.ts.map +1 -1
- package/dist/viem/Account.js +9 -2
- package/dist/viem/Account.js.map +1 -1
- package/dist/viem/Actions/account.d.ts.map +1 -1
- package/dist/viem/Actions/account.js +1 -1
- package/dist/viem/Actions/account.js.map +1 -1
- package/dist/viem/Actions/amm.d.ts +1 -1
- package/dist/viem/Actions/amm.d.ts.map +1 -1
- package/dist/viem/Actions/amm.js +1 -2
- package/dist/viem/Actions/amm.js.map +1 -1
- package/dist/viem/Actions/dex.d.ts +0 -35
- package/dist/viem/Actions/dex.d.ts.map +1 -1
- package/dist/viem/Actions/dex.js +0 -43
- package/dist/viem/Actions/dex.js.map +1 -1
- package/dist/viem/Actions/fee.d.ts +1 -1
- package/dist/viem/Actions/fee.d.ts.map +1 -1
- package/dist/viem/Actions/fee.js +1 -1
- package/dist/viem/Actions/fee.js.map +1 -1
- package/dist/viem/Actions/nonce.d.ts.map +1 -1
- package/dist/viem/Actions/nonce.js +6 -4
- package/dist/viem/Actions/nonce.js.map +1 -1
- package/dist/viem/Actions/token.d.ts +1 -2
- package/dist/viem/Actions/token.d.ts.map +1 -1
- package/dist/viem/Actions/token.js +1 -2
- package/dist/viem/Actions/token.js.map +1 -1
- package/dist/viem/Chain.d.ts +34 -34
- package/dist/viem/Chain.d.ts.map +1 -1
- package/dist/viem/Chain.js +2 -0
- package/dist/viem/Chain.js.map +1 -1
- package/dist/viem/Decorator.d.ts +0 -27
- package/dist/viem/Decorator.d.ts.map +1 -1
- package/dist/viem/Decorator.js +0 -1
- package/dist/viem/Decorator.js.map +1 -1
- package/dist/viem/Formatters.d.ts.map +1 -1
- package/dist/viem/Formatters.js +5 -3
- package/dist/viem/Formatters.js.map +1 -1
- package/dist/viem/Transaction.d.ts +8 -5
- package/dist/viem/Transaction.d.ts.map +1 -1
- package/dist/viem/Transaction.js +13 -3
- package/dist/viem/Transaction.js.map +1 -1
- package/dist/viem/index.d.ts +10 -1
- package/dist/viem/index.d.ts.map +1 -1
- package/dist/viem/index.js +1 -1
- package/dist/viem/index.js.map +1 -1
- package/dist/viem/internal/types.d.ts +1 -1
- package/dist/viem/internal/types.d.ts.map +1 -1
- package/dist/wagmi/Actions/dex.d.ts +1 -45
- package/dist/wagmi/Actions/dex.d.ts.map +1 -1
- package/dist/wagmi/Actions/dex.js +0 -55
- package/dist/wagmi/Actions/dex.js.map +1 -1
- package/dist/wagmi/Connector.d.ts +1 -1
- package/dist/wagmi/Connector.d.ts.map +1 -1
- package/dist/wagmi/Connector.js +1 -2
- package/dist/wagmi/Connector.js.map +1 -1
- package/dist/wagmi/Hooks/dex.d.ts +3 -46
- package/dist/wagmi/Hooks/dex.d.ts.map +1 -1
- package/dist/wagmi/Hooks/dex.js +2 -54
- package/dist/wagmi/Hooks/dex.js.map +1 -1
- package/dist/wagmi/index.d.ts +1 -1
- package/dist/wagmi/index.d.ts.map +1 -1
- package/dist/wagmi/index.js +1 -1
- package/dist/wagmi/index.js.map +1 -1
- package/package.json +5 -13
- package/src/viem/Account.test.ts +1 -1
- package/src/viem/Account.ts +11 -2
- package/src/viem/Actions/account.ts +1 -1
- package/src/viem/Actions/amm.ts +1 -2
- package/src/viem/Actions/dex.test.ts +1 -195
- package/src/viem/Actions/dex.ts +0 -53
- package/src/viem/Actions/fee.test.ts +2 -2
- package/src/viem/Actions/fee.ts +1 -1
- package/src/viem/Actions/nonce.test.ts +27 -14
- package/src/viem/Actions/nonce.ts +6 -4
- package/src/viem/Actions/token.test.ts +18 -52
- package/src/viem/Actions/token.ts +1 -2
- package/src/viem/Chain.ts +3 -1
- package/src/viem/Decorator.ts +0 -30
- package/src/viem/Formatters.ts +9 -3
- package/src/viem/Transaction.ts +23 -7
- package/src/viem/e2e.test.ts +19 -0
- package/src/viem/index.ts +12 -1
- package/src/viem/internal/types.ts +1 -1
- package/src/wagmi/Actions/dex.test.ts +0 -26
- package/src/wagmi/Actions/dex.ts +1 -111
- package/src/wagmi/Actions/nonce.test.ts +8 -4
- package/src/wagmi/Actions/token.test.ts +2 -2
- package/src/wagmi/Connector.ts +1 -2
- package/src/wagmi/Hooks/dex.test.ts +0 -26
- package/src/wagmi/Hooks/dex.ts +1 -88
- package/src/wagmi/Hooks/nonce.test.ts +3 -3
- package/src/wagmi/index.ts +4 -1
- package/dist/ox/AuthorizationTempo.d.ts +0 -450
- package/dist/ox/AuthorizationTempo.d.ts.map +0 -1
- package/dist/ox/AuthorizationTempo.js +0 -433
- package/dist/ox/AuthorizationTempo.js.map +0 -1
- package/dist/ox/KeyAuthorization.d.ts +0 -356
- package/dist/ox/KeyAuthorization.d.ts.map +0 -1
- package/dist/ox/KeyAuthorization.js +0 -359
- package/dist/ox/KeyAuthorization.js.map +0 -1
- package/dist/ox/Order.d.ts +0 -92
- package/dist/ox/Order.d.ts.map +0 -1
- package/dist/ox/Order.js +0 -88
- package/dist/ox/Order.js.map +0 -1
- package/dist/ox/OrdersFilters.d.ts +0 -72
- package/dist/ox/OrdersFilters.d.ts.map +0 -1
- package/dist/ox/OrdersFilters.js +0 -100
- package/dist/ox/OrdersFilters.js.map +0 -1
- package/dist/ox/Pagination.d.ts +0 -128
- package/dist/ox/Pagination.d.ts.map +0 -1
- package/dist/ox/Pagination.js +0 -78
- package/dist/ox/Pagination.js.map +0 -1
- package/dist/ox/PoolId.d.ts +0 -18
- package/dist/ox/PoolId.d.ts.map +0 -1
- package/dist/ox/PoolId.js +0 -13
- package/dist/ox/PoolId.js.map +0 -1
- package/dist/ox/RpcSchema.d.ts +0 -32
- package/dist/ox/RpcSchema.d.ts.map +0 -1
- package/dist/ox/RpcSchema.js +0 -2
- package/dist/ox/RpcSchema.js.map +0 -1
- package/dist/ox/SignatureEnvelope.d.ts +0 -260
- package/dist/ox/SignatureEnvelope.d.ts.map +0 -1
- package/dist/ox/SignatureEnvelope.js +0 -477
- package/dist/ox/SignatureEnvelope.js.map +0 -1
- package/dist/ox/Tick.d.ts +0 -115
- package/dist/ox/Tick.d.ts.map +0 -1
- package/dist/ox/Tick.js +0 -127
- package/dist/ox/Tick.js.map +0 -1
- package/dist/ox/TokenId.d.ts +0 -25
- package/dist/ox/TokenId.d.ts.map +0 -1
- package/dist/ox/TokenId.js +0 -41
- package/dist/ox/TokenId.js.map +0 -1
- package/dist/ox/TokenRole.d.ts +0 -11
- package/dist/ox/TokenRole.d.ts.map +0 -1
- package/dist/ox/TokenRole.js +0 -22
- package/dist/ox/TokenRole.js.map +0 -1
- package/dist/ox/Transaction.d.ts +0 -201
- package/dist/ox/Transaction.d.ts.map +0 -1
- package/dist/ox/Transaction.js +0 -167
- package/dist/ox/Transaction.js.map +0 -1
- package/dist/ox/TransactionEnvelopeTempo.d.ts +0 -470
- package/dist/ox/TransactionEnvelopeTempo.d.ts.map +0 -1
- package/dist/ox/TransactionEnvelopeTempo.js +0 -547
- package/dist/ox/TransactionEnvelopeTempo.js.map +0 -1
- package/dist/ox/TransactionReceipt.d.ts +0 -155
- package/dist/ox/TransactionReceipt.d.ts.map +0 -1
- package/dist/ox/TransactionReceipt.js +0 -136
- package/dist/ox/TransactionReceipt.js.map +0 -1
- package/dist/ox/TransactionRequest.d.ts +0 -76
- package/dist/ox/TransactionRequest.d.ts.map +0 -1
- package/dist/ox/TransactionRequest.js +0 -93
- package/dist/ox/TransactionRequest.js.map +0 -1
- package/dist/ox/index.d.ts +0 -14
- package/dist/ox/index.d.ts.map +0 -1
- package/dist/ox/index.js +0 -14
- package/dist/ox/index.js.map +0 -1
- package/dist/prool/Instance.d.ts +0 -101
- package/dist/prool/Instance.d.ts.map +0 -1
- package/dist/prool/Instance.js +0 -136
- package/dist/prool/Instance.js.map +0 -1
- package/dist/prool/chain.json +0 -238
- package/dist/prool/index.d.ts +0 -2
- package/dist/prool/index.d.ts.map +0 -1
- package/dist/prool/index.js +0 -2
- package/dist/prool/index.js.map +0 -1
- package/src/ox/AuthorizationTempo.test.ts +0 -1256
- package/src/ox/AuthorizationTempo.ts +0 -648
- package/src/ox/KeyAuthorization.test.ts +0 -1332
- package/src/ox/KeyAuthorization.ts +0 -540
- package/src/ox/Order.test.ts +0 -78
- package/src/ox/Order.ts +0 -125
- package/src/ox/OrdersFilters.test.ts +0 -182
- package/src/ox/OrdersFilters.ts +0 -125
- package/src/ox/Pagination.test.ts +0 -162
- package/src/ox/Pagination.ts +0 -164
- package/src/ox/PoolId.test.ts +0 -33
- package/src/ox/PoolId.ts +0 -27
- package/src/ox/RpcSchema.ts +0 -35
- package/src/ox/SignatureEnvelope.test.ts +0 -1876
- package/src/ox/SignatureEnvelope.ts +0 -791
- package/src/ox/Tick.test.ts +0 -281
- package/src/ox/Tick.ts +0 -181
- package/src/ox/TokenId.test.ts +0 -40
- package/src/ox/TokenId.ts +0 -50
- package/src/ox/TokenRole.test.ts +0 -16
- package/src/ox/TokenRole.ts +0 -27
- package/src/ox/Transaction.test.ts +0 -523
- package/src/ox/Transaction.ts +0 -332
- package/src/ox/TransactionEnvelopeTempo.test.ts +0 -1352
- package/src/ox/TransactionEnvelopeTempo.ts +0 -905
- package/src/ox/TransactionReceipt.ts +0 -190
- package/src/ox/TransactionRequest.ts +0 -147
- package/src/ox/e2e.test.ts +0 -1393
- package/src/ox/index.ts +0 -13
- package/src/prool/Instance.test.ts +0 -43
- package/src/prool/Instance.ts +0 -247
- package/src/prool/chain.json +0 -238
- package/src/prool/index.ts +0 -1
- package/src/viem/Actions/__snapshots__/dex.test.ts.snap +0 -850
- package/src/wagmi/Actions/__snapshots__/dex.test.ts.snap +0 -310
- package/src/wagmi/Hooks/__snapshots__/dex.test.ts.snap +0 -457
package/src/ox/Transaction.ts
DELETED
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
import type * as AccessList from 'ox/AccessList'
|
|
2
|
-
import type * as Address from 'ox/Address'
|
|
3
|
-
import type * as Errors from 'ox/Errors'
|
|
4
|
-
import * as Hex from 'ox/Hex'
|
|
5
|
-
import * as Signature from 'ox/Signature'
|
|
6
|
-
import * as ox_Transaction from 'ox/Transaction'
|
|
7
|
-
import type { Compute, OneOf, UnionCompute } from '../internal/types.js'
|
|
8
|
-
import * as AuthorizationTempo from './AuthorizationTempo.js'
|
|
9
|
-
import * as KeyAuthorization from './KeyAuthorization.js'
|
|
10
|
-
import * as SignatureEnvelope from './SignatureEnvelope.js'
|
|
11
|
-
import type { Call } from './TransactionEnvelopeTempo.js'
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* A Transaction as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/transaction.yaml).
|
|
15
|
-
*/
|
|
16
|
-
export type Transaction<
|
|
17
|
-
pending extends boolean = false,
|
|
18
|
-
bigintType = bigint,
|
|
19
|
-
numberType = number,
|
|
20
|
-
> = UnionCompute<
|
|
21
|
-
OneOf<
|
|
22
|
-
| Tempo<pending, bigintType, numberType>
|
|
23
|
-
| ox_Transaction.Transaction<pending, bigintType, numberType>
|
|
24
|
-
>
|
|
25
|
-
>
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* An RPC Transaction as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/transaction.yaml).
|
|
29
|
-
*/
|
|
30
|
-
export type Rpc<pending extends boolean = false> = UnionCompute<
|
|
31
|
-
OneOf<TempoRpc<pending> | ox_Transaction.Rpc<pending>>
|
|
32
|
-
>
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Native account abstraction transaction.
|
|
36
|
-
*/
|
|
37
|
-
export type Tempo<
|
|
38
|
-
pending extends boolean = false,
|
|
39
|
-
bigintType = bigint,
|
|
40
|
-
numberType = number,
|
|
41
|
-
type extends string = 'tempo',
|
|
42
|
-
> = Compute<
|
|
43
|
-
Omit<
|
|
44
|
-
ox_Transaction.Base<type, pending, bigintType, numberType>,
|
|
45
|
-
// Tempo transactions don't have these properties.
|
|
46
|
-
'input' | 'to' | 'value' | 'v' | 'r' | 's' | 'yParity'
|
|
47
|
-
> & {
|
|
48
|
-
/** EIP-2930 Access List. */
|
|
49
|
-
accessList: AccessList.AccessList
|
|
50
|
-
/** EIP-7702 Authorization list for the transaction. */
|
|
51
|
-
authorizationList?:
|
|
52
|
-
| AuthorizationTempo.ListSigned<bigintType, numberType>
|
|
53
|
-
| undefined
|
|
54
|
-
/** Array of calls to execute. */
|
|
55
|
-
calls: readonly Call<bigintType>[]
|
|
56
|
-
/** Fee payer signature. */
|
|
57
|
-
feePayerSignature?:
|
|
58
|
-
| {
|
|
59
|
-
/** ECDSA signature r. */
|
|
60
|
-
r: bigintType
|
|
61
|
-
/** ECDSA signature s. */
|
|
62
|
-
s: bigintType
|
|
63
|
-
/** ECDSA signature yParity. */
|
|
64
|
-
yParity: numberType
|
|
65
|
-
/** @deprecated ECDSA signature v (for backwards compatibility). */
|
|
66
|
-
v?: numberType | undefined
|
|
67
|
-
}
|
|
68
|
-
| undefined
|
|
69
|
-
/** Fee token preference. */
|
|
70
|
-
feeToken: Address.Address
|
|
71
|
-
/** Effective gas price paid by the sender in wei. */
|
|
72
|
-
gasPrice?: bigintType | undefined
|
|
73
|
-
/** Key authorization for provisioning a new access key. */
|
|
74
|
-
keyAuthorization?:
|
|
75
|
-
| KeyAuthorization.KeyAuthorization<true, bigintType, numberType>
|
|
76
|
-
| undefined
|
|
77
|
-
/** Total fee per gas in wei (gasPrice/baseFeePerGas + maxPriorityFeePerGas). */
|
|
78
|
-
maxFeePerGas: bigintType
|
|
79
|
-
/** Max priority fee per gas (in wei). */
|
|
80
|
-
maxPriorityFeePerGas: bigintType
|
|
81
|
-
/** Nonce key for 2D nonce system (192 bits). */
|
|
82
|
-
nonceKey?: bigintType | undefined
|
|
83
|
-
/** Sender signature. */
|
|
84
|
-
signature: SignatureEnvelope.SignatureEnvelope<bigintType, numberType>
|
|
85
|
-
/** Transaction can only be included in a block before this timestamp. */
|
|
86
|
-
validBefore?: numberType | undefined
|
|
87
|
-
/** Transaction can only be included in a block after this timestamp. */
|
|
88
|
-
validAfter?: numberType | undefined
|
|
89
|
-
}
|
|
90
|
-
>
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Native account abstraction transaction in RPC format.
|
|
94
|
-
*/
|
|
95
|
-
export type TempoRpc<pending extends boolean = false> = Compute<
|
|
96
|
-
Omit<
|
|
97
|
-
Tempo<pending, Hex.Hex, Hex.Hex, ToRpcType['tempo']>,
|
|
98
|
-
'authorizationList' | 'calls' | 'keyAuthorization' | 'signature'
|
|
99
|
-
> & {
|
|
100
|
-
aaAuthorizationList?: AuthorizationTempo.ListRpc | undefined
|
|
101
|
-
calls:
|
|
102
|
-
| readonly {
|
|
103
|
-
input?: Hex.Hex | undefined
|
|
104
|
-
to?: Hex.Hex | undefined
|
|
105
|
-
value?: Hex.Hex | undefined
|
|
106
|
-
}[]
|
|
107
|
-
| undefined
|
|
108
|
-
keyAuthorization?: KeyAuthorization.Rpc | undefined
|
|
109
|
-
signature: SignatureEnvelope.SignatureEnvelopeRpc
|
|
110
|
-
}
|
|
111
|
-
>
|
|
112
|
-
|
|
113
|
-
/** Type to RPC Type mapping. */
|
|
114
|
-
export const toRpcType = {
|
|
115
|
-
...ox_Transaction.toRpcType,
|
|
116
|
-
tempo: '0x76',
|
|
117
|
-
} as const
|
|
118
|
-
|
|
119
|
-
/** Type to RPC Type mapping. */
|
|
120
|
-
export type ToRpcType = typeof toRpcType & {
|
|
121
|
-
[type: string]: `0x${string}`
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/** RPC Type to Type mapping. */
|
|
125
|
-
export const fromRpcType = {
|
|
126
|
-
...ox_Transaction.fromRpcType,
|
|
127
|
-
'0x76': 'tempo',
|
|
128
|
-
} as const
|
|
129
|
-
|
|
130
|
-
/** RPC Type to Type mapping. */
|
|
131
|
-
|
|
132
|
-
export type FromRpcType = typeof fromRpcType & {
|
|
133
|
-
[type: `0x${string}`]: string
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Converts an {@link ox#Transaction.Rpc} to an {@link ox#Transaction.Transaction}.
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* ```ts twoslash
|
|
141
|
-
* import { Transaction } from 'ox/tempo'
|
|
142
|
-
*
|
|
143
|
-
* const transaction = Transaction.fromRpc({
|
|
144
|
-
* hash: '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
|
|
145
|
-
* nonce: '0x357',
|
|
146
|
-
* blockHash:
|
|
147
|
-
* '0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
|
|
148
|
-
* blockNumber: '0x12f296f',
|
|
149
|
-
* calls: [
|
|
150
|
-
* {
|
|
151
|
-
* input: '0xdeadbeef',
|
|
152
|
-
* to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
|
|
153
|
-
* value: '0x9b6e64a8ec60000',
|
|
154
|
-
* },
|
|
155
|
-
* ],
|
|
156
|
-
* feeToken: '0x20c0000000000000000000000000000000000000',
|
|
157
|
-
* transactionIndex: '0x2',
|
|
158
|
-
* from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
|
|
159
|
-
* value: '0x9b6e64a8ec60000',
|
|
160
|
-
* gas: '0x43f5d',
|
|
161
|
-
* maxFeePerGas: '0x2ca6ae494',
|
|
162
|
-
* maxPriorityFeePerGas: '0x41cc3c0',
|
|
163
|
-
* input:
|
|
164
|
-
* '0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006643504700000000000000000000000000000000000000000000000000000000000000040b080604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec600000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec60000000000000000000000000000000000000000000000000000019124bb5ae978c000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b80000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b8000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c00000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000190240001b9872b',
|
|
165
|
-
* signature: {
|
|
166
|
-
* r: '0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d',
|
|
167
|
-
* s: '0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540',
|
|
168
|
-
* type: 'secp256k1',
|
|
169
|
-
* yParity: '0x0',
|
|
170
|
-
* },
|
|
171
|
-
* chainId: '0x1',
|
|
172
|
-
* accessList: [],
|
|
173
|
-
* type: '0x76',
|
|
174
|
-
* })
|
|
175
|
-
* ```
|
|
176
|
-
*
|
|
177
|
-
* @param transaction - The RPC transaction to convert.
|
|
178
|
-
* @returns An instantiated {@link ox#Transaction.Transaction}.
|
|
179
|
-
*/
|
|
180
|
-
export function fromRpc<
|
|
181
|
-
const transaction extends Rpc | null,
|
|
182
|
-
pending extends boolean = false,
|
|
183
|
-
>(
|
|
184
|
-
transaction: transaction | Rpc<pending> | null,
|
|
185
|
-
_options: fromRpc.Options<pending> = {},
|
|
186
|
-
): transaction extends Rpc<pending> ? Transaction<pending> : null {
|
|
187
|
-
if (!transaction) return null as never
|
|
188
|
-
|
|
189
|
-
const transaction_ = ox_Transaction.fromRpc(
|
|
190
|
-
transaction as ox_Transaction.Rpc<pending>,
|
|
191
|
-
) as Transaction<pending>
|
|
192
|
-
|
|
193
|
-
transaction_.type = fromRpcType[transaction.type as keyof typeof fromRpcType]
|
|
194
|
-
|
|
195
|
-
if (transaction.aaAuthorizationList) {
|
|
196
|
-
transaction_.authorizationList = AuthorizationTempo.fromRpcList(
|
|
197
|
-
transaction.aaAuthorizationList,
|
|
198
|
-
)
|
|
199
|
-
delete (transaction_ as any).aaAuthorizationList
|
|
200
|
-
}
|
|
201
|
-
if (transaction.calls)
|
|
202
|
-
transaction_.calls = transaction.calls.map((call) => ({
|
|
203
|
-
to: call.to,
|
|
204
|
-
value: call.value && call.value !== '0x' ? BigInt(call.value) : undefined,
|
|
205
|
-
// @ts-expect-error
|
|
206
|
-
data: call.input || call.data || '0x',
|
|
207
|
-
}))
|
|
208
|
-
if (transaction.feeToken) transaction_.feeToken = transaction.feeToken
|
|
209
|
-
if (transaction.nonceKey) transaction_.nonceKey = BigInt(transaction.nonceKey)
|
|
210
|
-
if (transaction.signature)
|
|
211
|
-
transaction_.signature = SignatureEnvelope.fromRpc(transaction.signature)
|
|
212
|
-
if (transaction.validAfter)
|
|
213
|
-
transaction_.validAfter = Number(transaction.validAfter)
|
|
214
|
-
if (transaction.validBefore)
|
|
215
|
-
transaction_.validBefore = Number(transaction.validBefore)
|
|
216
|
-
if (transaction.keyAuthorization)
|
|
217
|
-
transaction_.keyAuthorization = KeyAuthorization.fromRpc(
|
|
218
|
-
transaction.keyAuthorization,
|
|
219
|
-
)
|
|
220
|
-
if (transaction.feePayerSignature) {
|
|
221
|
-
transaction_.feePayerSignature = Signature.fromRpc(
|
|
222
|
-
transaction.feePayerSignature,
|
|
223
|
-
)
|
|
224
|
-
;(transaction_.feePayerSignature as any).v = Signature.yParityToV(
|
|
225
|
-
transaction_.feePayerSignature.yParity,
|
|
226
|
-
)
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
return transaction_ as never
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export declare namespace fromRpc {
|
|
233
|
-
type Options<pending extends boolean = false> = {
|
|
234
|
-
pending?: pending | boolean | undefined
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
type ErrorType = ox_Transaction.fromRpc.ErrorType | Errors.GlobalErrorType
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Converts an {@link ox#Transaction.Transaction} to an {@link ox#Transaction.Rpc}.
|
|
242
|
-
*
|
|
243
|
-
* @example
|
|
244
|
-
* ```ts twoslash
|
|
245
|
-
* import { Transaction } from 'ox/tempo'
|
|
246
|
-
*
|
|
247
|
-
* const transaction = Transaction.toRpc({
|
|
248
|
-
* accessList: [],
|
|
249
|
-
* blockHash:
|
|
250
|
-
* '0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
|
|
251
|
-
* blockNumber: 19868015n,
|
|
252
|
-
* calls: [
|
|
253
|
-
* {
|
|
254
|
-
* data: '0xdeadbeef',
|
|
255
|
-
* to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
|
|
256
|
-
* value: 700000000000000000n,
|
|
257
|
-
* },
|
|
258
|
-
* ],
|
|
259
|
-
* chainId: 1,
|
|
260
|
-
* feeToken: '0x20c0000000000000000000000000000000000000',
|
|
261
|
-
* from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
|
|
262
|
-
* gas: 278365n,
|
|
263
|
-
* hash: '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
|
|
264
|
-
* input:
|
|
265
|
-
* '0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006643504700000000000000000000000000000000000000000000000000000000000000040b080604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec600000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec60000000000000000000000000000000000000000000000000000019124bb5ae978c000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b80000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b8000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c00000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000190240001b9872b',
|
|
266
|
-
* maxFeePerGas: 11985937556n,
|
|
267
|
-
* maxPriorityFeePerGas: 68993984n,
|
|
268
|
-
* nonce: 855n,
|
|
269
|
-
* signature: {
|
|
270
|
-
* signature: {
|
|
271
|
-
* r: 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
|
|
272
|
-
* s: 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
|
|
273
|
-
* yParity: 0,
|
|
274
|
-
* },
|
|
275
|
-
* type: 'secp256k1',
|
|
276
|
-
* },
|
|
277
|
-
* transactionIndex: 2,
|
|
278
|
-
* type: 'tempo',
|
|
279
|
-
* })
|
|
280
|
-
* ```
|
|
281
|
-
*
|
|
282
|
-
* @param transaction - The transaction to convert.
|
|
283
|
-
* @returns An RPC-formatted transaction.
|
|
284
|
-
*/
|
|
285
|
-
export function toRpc<pending extends boolean = false>(
|
|
286
|
-
transaction: Transaction<pending>,
|
|
287
|
-
_options?: toRpc.Options<pending>,
|
|
288
|
-
): Rpc<pending> {
|
|
289
|
-
const rpc = ox_Transaction.toRpc(
|
|
290
|
-
transaction as ox_Transaction.Transaction<pending>,
|
|
291
|
-
) as Rpc<pending>
|
|
292
|
-
|
|
293
|
-
rpc.type = toRpcType[transaction.type as keyof typeof toRpcType]
|
|
294
|
-
|
|
295
|
-
if (transaction.authorizationList)
|
|
296
|
-
rpc.aaAuthorizationList = AuthorizationTempo.toRpcList(
|
|
297
|
-
transaction.authorizationList as AuthorizationTempo.ListSigned,
|
|
298
|
-
)
|
|
299
|
-
if (transaction.calls)
|
|
300
|
-
rpc.calls = transaction.calls.map((call) => ({
|
|
301
|
-
to: call.to,
|
|
302
|
-
value: call.value ? Hex.fromNumber(call.value) : undefined,
|
|
303
|
-
data: call.data,
|
|
304
|
-
}))
|
|
305
|
-
if (transaction.feeToken) rpc.feeToken = transaction.feeToken
|
|
306
|
-
if (transaction.keyAuthorization)
|
|
307
|
-
rpc.keyAuthorization = KeyAuthorization.toRpc(transaction.keyAuthorization)
|
|
308
|
-
if (transaction.feePayerSignature) {
|
|
309
|
-
rpc.feePayerSignature = Signature.toRpc(
|
|
310
|
-
transaction.feePayerSignature,
|
|
311
|
-
) as any
|
|
312
|
-
;(rpc.feePayerSignature as any).v = Hex.fromNumber(
|
|
313
|
-
Signature.yParityToV(transaction.feePayerSignature?.yParity),
|
|
314
|
-
)
|
|
315
|
-
}
|
|
316
|
-
if (transaction.signature)
|
|
317
|
-
rpc.signature = SignatureEnvelope.toRpc(transaction.signature)
|
|
318
|
-
if (typeof transaction.validAfter === 'number')
|
|
319
|
-
rpc.validAfter = Hex.fromNumber(transaction.validAfter)
|
|
320
|
-
if (typeof transaction.validBefore === 'number')
|
|
321
|
-
rpc.validBefore = Hex.fromNumber(transaction.validBefore)
|
|
322
|
-
|
|
323
|
-
return rpc as Rpc<pending>
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
export declare namespace toRpc {
|
|
327
|
-
type Options<pending extends boolean = false> = {
|
|
328
|
-
pending?: pending | boolean | undefined
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
type ErrorType = ox_Transaction.toRpc.ErrorType | Errors.GlobalErrorType
|
|
332
|
-
}
|