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
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import type * as Address from 'ox/Address'
|
|
2
|
-
import type * as Hex from 'ox/Hex'
|
|
3
|
-
import * as ox_TransactionReceipt from 'ox/TransactionReceipt'
|
|
4
|
-
import type { Compute } from '../internal/types.js'
|
|
5
|
-
|
|
6
|
-
export type TransactionReceipt<
|
|
7
|
-
status = ox_TransactionReceipt.Status,
|
|
8
|
-
type = ox_TransactionReceipt.Type,
|
|
9
|
-
bigintType = bigint,
|
|
10
|
-
numberType = number,
|
|
11
|
-
> = Compute<
|
|
12
|
-
ox_TransactionReceipt.TransactionReceipt<
|
|
13
|
-
status,
|
|
14
|
-
type,
|
|
15
|
-
bigintType,
|
|
16
|
-
numberType
|
|
17
|
-
> & {
|
|
18
|
-
/** Address of the fee payer. */
|
|
19
|
-
feePayer?: Address.Address | undefined
|
|
20
|
-
/** Address of the fee token. */
|
|
21
|
-
feeToken?: Address.Address | undefined
|
|
22
|
-
}
|
|
23
|
-
>
|
|
24
|
-
|
|
25
|
-
export type Rpc = TransactionReceipt<
|
|
26
|
-
ox_TransactionReceipt.RpcStatus,
|
|
27
|
-
ox_TransactionReceipt.RpcType,
|
|
28
|
-
Hex.Hex,
|
|
29
|
-
Hex.Hex
|
|
30
|
-
>
|
|
31
|
-
|
|
32
|
-
export type Type = 'tempo' | ox_TransactionReceipt.Type
|
|
33
|
-
|
|
34
|
-
export type RpcType = '0x76' | ox_TransactionReceipt.RpcType
|
|
35
|
-
|
|
36
|
-
export type Status = ox_TransactionReceipt.Status
|
|
37
|
-
|
|
38
|
-
export type RpcStatus = ox_TransactionReceipt.RpcStatus
|
|
39
|
-
|
|
40
|
-
/** RPC type to type mapping. */
|
|
41
|
-
export const fromRpcType = {
|
|
42
|
-
...ox_TransactionReceipt.fromRpcType,
|
|
43
|
-
'0x76': 'tempo',
|
|
44
|
-
} as const
|
|
45
|
-
|
|
46
|
-
/** Type to RPC type mapping. */
|
|
47
|
-
export const toRpcType = {
|
|
48
|
-
...ox_TransactionReceipt.toRpcType,
|
|
49
|
-
tempo: '0x76',
|
|
50
|
-
} as const
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Converts an RPC receipt to a TransactionReceipt.
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* ```ts twoslash
|
|
57
|
-
* import { TransactionReceipt } from 'ox/tempo'
|
|
58
|
-
*
|
|
59
|
-
* const receipt = TransactionReceipt.fromRpc({
|
|
60
|
-
* blobGasPrice: '0x42069',
|
|
61
|
-
* blobGasUsed: '0x1337',
|
|
62
|
-
* blockHash:
|
|
63
|
-
* '0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
|
|
64
|
-
* blockNumber: '0x12f296f',
|
|
65
|
-
* contractAddress: null,
|
|
66
|
-
* cumulativeGasUsed: '0x82515',
|
|
67
|
-
* effectiveGasPrice: '0x21c2f6c09',
|
|
68
|
-
* feePayer: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
|
|
69
|
-
* feeToken: '0x20c0000000000000000000000000000000000001',
|
|
70
|
-
* from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
|
|
71
|
-
* gasUsed: '0x2abba',
|
|
72
|
-
* logs: [],
|
|
73
|
-
* logsBloom:
|
|
74
|
-
* '0x00200000000000000000008080000000000000000040000000000000000000000000000000000000000000000000000022000000080000000000000000000000000000080000000000000008000000200000000000000000000200008020400000000000000000280000000000100000000000000000000000000010000000000000000000020000000000000020000000000001000000080000004000000000000000000000000000000000000000000000400000000000001000000000000000000002000000000000000020000000000000000000001000000000000000000000200000000000000000000000000000001000000000c00000000000000000',
|
|
75
|
-
* status: '0x1',
|
|
76
|
-
* to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
|
|
77
|
-
* transactionHash:
|
|
78
|
-
* '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
|
|
79
|
-
* transactionIndex: '0x2',
|
|
80
|
-
* type: '0x2',
|
|
81
|
-
* })
|
|
82
|
-
* // @log: {
|
|
83
|
-
* // @log: blobGasPrice: 270441n,
|
|
84
|
-
* // @log: blobGasUsed: 4919n,
|
|
85
|
-
* // @log: blockHash: "0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b",
|
|
86
|
-
* // @log: blockNumber: 19868015n,
|
|
87
|
-
* // @log: contractAddress: null,
|
|
88
|
-
* // @log: cumulativeGasUsed: 533781n,
|
|
89
|
-
* // @log: effectiveGasPrice: 9062804489n,
|
|
90
|
-
* // @log: feePayer: "0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6",
|
|
91
|
-
* // @log: feeToken: "0x20c0000000000000000000000000000000000001",
|
|
92
|
-
* // @log: from: "0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6",
|
|
93
|
-
* // @log: gasUsed: 175034n,
|
|
94
|
-
* // @log: logs: [],
|
|
95
|
-
* // @log: logsBloom: "0x00200000000000000000008080000000000000000040000000000000000000000000000000000000000000000000000022000000080000000000000000000000000000080000000000000008000000200000000000000000000200008020400000000000000000280000000000100000000000000000000000000010000000000000000000020000000000000020000000000001000000080000004000000000000000000000000000000000000000000000400000000000001000000000000000000002000000000000000020000000000000000000001000000000000000000000200000000000000000000000000000001000000000c00000000000000000",
|
|
96
|
-
* // @log: root: undefined,
|
|
97
|
-
* // @log: status: "success",
|
|
98
|
-
* // @log: to: "0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad",
|
|
99
|
-
* // @log: transactionHash: "0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0",
|
|
100
|
-
* // @log: transactionIndex: 2,
|
|
101
|
-
* // @log: type: "eip1559",
|
|
102
|
-
* // @log: }
|
|
103
|
-
* ```
|
|
104
|
-
*
|
|
105
|
-
* @param receipt - The RPC receipt to convert.
|
|
106
|
-
* @returns A TransactionReceipt.
|
|
107
|
-
*/
|
|
108
|
-
export function fromRpc<const receipt extends Rpc | null>(
|
|
109
|
-
receipt: receipt | Rpc | null,
|
|
110
|
-
): receipt extends Rpc ? TransactionReceipt : null {
|
|
111
|
-
return ox_TransactionReceipt.fromRpc(
|
|
112
|
-
receipt as ox_TransactionReceipt.Rpc,
|
|
113
|
-
) as never
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export declare namespace fromRpc {
|
|
117
|
-
export type ErrorType = ox_TransactionReceipt.fromRpc.ErrorType
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Converts a TransactionReceipt to an RPC receipt.
|
|
122
|
-
*
|
|
123
|
-
* @example
|
|
124
|
-
* ```ts twoslash
|
|
125
|
-
* import { TransactionReceipt } from 'ox/tempo'
|
|
126
|
-
*
|
|
127
|
-
* const receipt = TransactionReceipt.toRpc({
|
|
128
|
-
* blobGasPrice: 270441n,
|
|
129
|
-
* blobGasUsed: 4919n,
|
|
130
|
-
* blockHash:
|
|
131
|
-
* '0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
|
|
132
|
-
* blockNumber: 19868015n,
|
|
133
|
-
* contractAddress: null,
|
|
134
|
-
* cumulativeGasUsed: 533781n,
|
|
135
|
-
* effectiveGasPrice: 9062804489n,
|
|
136
|
-
* feePayer: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
|
|
137
|
-
* feeToken: '0x20c0000000000000000000000000000000000001',
|
|
138
|
-
* from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
|
|
139
|
-
* gasUsed: 175034n,
|
|
140
|
-
* logs: [],
|
|
141
|
-
* logsBloom:
|
|
142
|
-
* '0x00200000000000000000008080000000000000000040000000000000000000000000000000000000000000000000000022000000080000000000000000000000000000080000000000000008000000200000000000000000000200008020400000000000000000280000000000100000000000000000000000000010000000000000000000020000000000000020000000000001000000080000004000000000000000000000000000000000000000000000400000000000001000000000000000000002000000000000000020000000000000000000001000000000000000000000200000000000000000000000000000001000000000c00000000000000000',
|
|
143
|
-
* root: undefined,
|
|
144
|
-
* status: 'success',
|
|
145
|
-
* to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
|
|
146
|
-
* transactionHash:
|
|
147
|
-
* '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
|
|
148
|
-
* transactionIndex: 2,
|
|
149
|
-
* type: 'eip1559',
|
|
150
|
-
* })
|
|
151
|
-
* // @log: {
|
|
152
|
-
* // @log: blobGasPrice: "0x042069",
|
|
153
|
-
* // @log: blobGasUsed: "0x1337",
|
|
154
|
-
* // @log: blockHash: "0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b",
|
|
155
|
-
* // @log: blockNumber: "0x012f296f",
|
|
156
|
-
* // @log: contractAddress: null,
|
|
157
|
-
* // @log: cumulativeGasUsed: "0x082515",
|
|
158
|
-
* // @log: effectiveGasPrice: "0x021c2f6c09",
|
|
159
|
-
* // @log: feePayer: "0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6",
|
|
160
|
-
* // @log: feeToken: "0x20c0000000000000000000000000000000000001",
|
|
161
|
-
* // @log: from: "0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6",
|
|
162
|
-
* // @log: gasUsed: "0x02abba",
|
|
163
|
-
* // @log: logs: [],
|
|
164
|
-
* // @log: logsBloom: "0x00200000000000000000008080000000000000000040000000000000000000000000000000000000000000000000000022000000080000000000000000000000000000080000000000000008000000200000000000000000000200008020400000000000000000280000000000100000000000000000000000000010000000000000000000020000000000000020000000000001000000080000004000000000000000000000000000000000000000000000400000000000001000000000000000000002000000000000000020000000000000000000001000000000000000000000200000000000000000000000000000001000000000c00000000000000000",
|
|
165
|
-
* // @log: root: undefined,
|
|
166
|
-
* // @log: status: "0x1",
|
|
167
|
-
* // @log: to: "0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad",
|
|
168
|
-
* // @log: transactionHash: "0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0",
|
|
169
|
-
* // @log: transactionIndex: "0x02",
|
|
170
|
-
* // @log: type: "eip1559",
|
|
171
|
-
* // @log: }
|
|
172
|
-
* ```
|
|
173
|
-
*
|
|
174
|
-
* @param receipt - The receipt to convert.
|
|
175
|
-
* @returns An RPC receipt.
|
|
176
|
-
*/
|
|
177
|
-
export function toRpc(receipt: TransactionReceipt): Rpc {
|
|
178
|
-
const rpc = ox_TransactionReceipt.toRpc(
|
|
179
|
-
receipt as ox_TransactionReceipt.TransactionReceipt,
|
|
180
|
-
) as Rpc
|
|
181
|
-
return {
|
|
182
|
-
...rpc,
|
|
183
|
-
feePayer: receipt.feePayer,
|
|
184
|
-
feeToken: receipt.feeToken,
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export declare namespace toRpc {
|
|
189
|
-
export type ErrorType = ox_TransactionReceipt.toRpc.ErrorType
|
|
190
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import type * as Errors from 'ox/Errors'
|
|
2
|
-
import * as Hex from 'ox/Hex'
|
|
3
|
-
import * as ox_TransactionRequest from 'ox/TransactionRequest'
|
|
4
|
-
import type { Compute } from '../internal/types.js'
|
|
5
|
-
import * as AuthorizationTempo from './AuthorizationTempo.js'
|
|
6
|
-
import * as KeyAuthorization from './KeyAuthorization.js'
|
|
7
|
-
import * as TokenId from './TokenId.js'
|
|
8
|
-
import * as Transaction from './Transaction.js'
|
|
9
|
-
import type { Call } from './TransactionEnvelopeTempo.js'
|
|
10
|
-
|
|
11
|
-
type KeyType = 'secp256k1' | 'p256' | 'webAuthn'
|
|
12
|
-
|
|
13
|
-
/** A Transaction Request that is generic to all transaction types, as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/4aca1d7a3e5aab24c8f6437131289ad386944eaa/src/schemas/transaction.yaml#L358-L423). */
|
|
14
|
-
export type TransactionRequest<
|
|
15
|
-
bigintType = bigint,
|
|
16
|
-
numberType = number,
|
|
17
|
-
type extends string = string,
|
|
18
|
-
> = Compute<
|
|
19
|
-
Omit<
|
|
20
|
-
ox_TransactionRequest.TransactionRequest<bigintType, numberType, type>,
|
|
21
|
-
'authorizationList'
|
|
22
|
-
> & {
|
|
23
|
-
authorizationList?:
|
|
24
|
-
| AuthorizationTempo.ListSigned<bigintType, numberType>
|
|
25
|
-
| undefined
|
|
26
|
-
calls?: readonly Call<bigintType>[] | undefined
|
|
27
|
-
keyAuthorization?: KeyAuthorization.KeyAuthorization<true> | undefined
|
|
28
|
-
keyData?: Hex.Hex | undefined
|
|
29
|
-
keyType?: KeyType | undefined
|
|
30
|
-
feeToken?: TokenId.TokenIdOrAddress | undefined
|
|
31
|
-
nonceKey?: 'random' | bigintType | undefined
|
|
32
|
-
validBefore?: numberType | undefined
|
|
33
|
-
validAfter?: numberType | undefined
|
|
34
|
-
}
|
|
35
|
-
>
|
|
36
|
-
|
|
37
|
-
/** RPC representation of a {@link ox#TransactionRequest.TransactionRequest}. */
|
|
38
|
-
export type Rpc = Omit<
|
|
39
|
-
TransactionRequest<Hex.Hex, Hex.Hex, string>,
|
|
40
|
-
'authorizationList' | 'keyAuthorization'
|
|
41
|
-
> & {
|
|
42
|
-
authorizationList?: AuthorizationTempo.ListRpc | undefined
|
|
43
|
-
keyAuthorization?: KeyAuthorization.Rpc | undefined
|
|
44
|
-
nonceKey?: Hex.Hex | undefined
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Converts a {@link ox#TransactionRequest.TransactionRequest} to a {@link ox#TransactionRequest.Rpc}.
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```ts twoslash
|
|
52
|
-
* import { Value } from 'ox'
|
|
53
|
-
* import { TransactionRequest } from 'ox/tempo'
|
|
54
|
-
*
|
|
55
|
-
* const request = TransactionRequest.toRpc({
|
|
56
|
-
* feeToken: '0x20c0000000000000000000000000000000000000',
|
|
57
|
-
* to: '0x0000000000000000000000000000000000000000',
|
|
58
|
-
* value: Value.fromEther('0.01'),
|
|
59
|
-
* })
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* ### Using with a Provider
|
|
64
|
-
*
|
|
65
|
-
* You can use {@link ox#Provider.(from:function)} to instantiate an EIP-1193 Provider and
|
|
66
|
-
* send a transaction to the Wallet using the `eth_sendTransaction` method.
|
|
67
|
-
*
|
|
68
|
-
* ```ts twoslash
|
|
69
|
-
* import 'ox/window'
|
|
70
|
-
* import { Provider, Value } from 'ox'
|
|
71
|
-
* import { TransactionRequest } from 'ox/tempo'
|
|
72
|
-
*
|
|
73
|
-
* const provider = Provider.from(window.ethereum!)
|
|
74
|
-
*
|
|
75
|
-
* const request = TransactionRequest.toRpc({
|
|
76
|
-
* feeToken: '0x20c0000000000000000000000000000000000000',
|
|
77
|
-
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
78
|
-
* value: Value.fromEther('0.01'),
|
|
79
|
-
* })
|
|
80
|
-
*
|
|
81
|
-
* const hash = await provider.request({ // [!code focus]
|
|
82
|
-
* method: 'eth_sendTransaction', // [!code focus]
|
|
83
|
-
* params: [request], // [!code focus]
|
|
84
|
-
* }) // [!code focus]
|
|
85
|
-
* ```
|
|
86
|
-
*
|
|
87
|
-
* @param request - The request to convert.
|
|
88
|
-
* @returns An RPC request.
|
|
89
|
-
*/
|
|
90
|
-
export function toRpc(request: TransactionRequest): Rpc {
|
|
91
|
-
const request_rpc = ox_TransactionRequest.toRpc({
|
|
92
|
-
...request,
|
|
93
|
-
authorizationList: undefined,
|
|
94
|
-
}) as Rpc
|
|
95
|
-
|
|
96
|
-
if (request.authorizationList)
|
|
97
|
-
request_rpc.authorizationList = AuthorizationTempo.toRpcList(
|
|
98
|
-
request.authorizationList,
|
|
99
|
-
)
|
|
100
|
-
if (request.calls)
|
|
101
|
-
request_rpc.calls = request.calls.map((call) => ({
|
|
102
|
-
to: call.to ?? '0x',
|
|
103
|
-
value: call.value ? Hex.fromNumber(call.value) : '0x',
|
|
104
|
-
data: call.data ?? '0x',
|
|
105
|
-
}))
|
|
106
|
-
if (typeof request.feeToken !== 'undefined')
|
|
107
|
-
request_rpc.feeToken = TokenId.toAddress(request.feeToken)
|
|
108
|
-
if (request.keyAuthorization)
|
|
109
|
-
request_rpc.keyAuthorization = KeyAuthorization.toRpc(
|
|
110
|
-
request.keyAuthorization,
|
|
111
|
-
)
|
|
112
|
-
if (typeof request.validBefore !== 'undefined')
|
|
113
|
-
request_rpc.validBefore = Hex.fromNumber(request.validBefore)
|
|
114
|
-
if (typeof request.validAfter !== 'undefined')
|
|
115
|
-
request_rpc.validAfter = Hex.fromNumber(request.validAfter)
|
|
116
|
-
|
|
117
|
-
const nonceKey = (() => {
|
|
118
|
-
if (request.nonceKey === 'random') return Hex.random(6)
|
|
119
|
-
if (typeof request.nonceKey === 'bigint')
|
|
120
|
-
return Hex.fromNumber(request.nonceKey)
|
|
121
|
-
return undefined
|
|
122
|
-
})()
|
|
123
|
-
if (nonceKey) request_rpc.nonceKey = nonceKey
|
|
124
|
-
|
|
125
|
-
if (
|
|
126
|
-
request.calls ||
|
|
127
|
-
typeof request.feeToken !== 'undefined' ||
|
|
128
|
-
typeof request.validBefore !== 'undefined' ||
|
|
129
|
-
typeof request.validAfter !== 'undefined' ||
|
|
130
|
-
request.type === 'tempo'
|
|
131
|
-
) {
|
|
132
|
-
request_rpc.type = Transaction.toRpcType.tempo
|
|
133
|
-
delete request_rpc.data
|
|
134
|
-
delete request_rpc.input
|
|
135
|
-
delete request_rpc.to
|
|
136
|
-
delete request_rpc.value
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return request_rpc
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export declare namespace toRpc {
|
|
143
|
-
export type ErrorType =
|
|
144
|
-
| AuthorizationTempo.toRpcList.ErrorType
|
|
145
|
-
| Hex.fromNumber.ErrorType
|
|
146
|
-
| Errors.GlobalErrorType
|
|
147
|
-
}
|