viem 1.0.7 → 1.1.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/chains/package.json +3 -3
- package/dist/cjs/accounts/privateKeyToAccount.js +2 -2
- package/dist/cjs/accounts/privateKeyToAccount.js.map +1 -1
- package/dist/cjs/accounts/utils/signTransaction.js +3 -3
- package/dist/cjs/accounts/utils/signTransaction.js.map +1 -1
- package/dist/cjs/actions/getContract.js.map +1 -1
- package/dist/cjs/actions/public/call.js +4 -6
- package/dist/cjs/actions/public/call.js.map +1 -1
- package/dist/cjs/actions/public/estimateContractGas.js.map +1 -1
- package/dist/cjs/actions/public/estimateGas.js +4 -6
- package/dist/cjs/actions/public/estimateGas.js.map +1 -1
- package/dist/cjs/actions/public/getBlock.js +2 -4
- package/dist/cjs/actions/public/getBlock.js.map +1 -1
- package/dist/cjs/actions/public/getTransaction.js +2 -4
- package/dist/cjs/actions/public/getTransaction.js.map +1 -1
- package/dist/cjs/actions/public/getTransactionConfirmations.js.map +1 -1
- package/dist/cjs/actions/public/getTransactionReceipt.js +3 -4
- package/dist/cjs/actions/public/getTransactionReceipt.js.map +1 -1
- package/dist/cjs/actions/public/simulateContract.js.map +1 -1
- package/dist/cjs/actions/public/watchBlocks.js +3 -1
- package/dist/cjs/actions/public/watchBlocks.js.map +1 -1
- package/dist/cjs/actions/test/sendUnsignedTransaction.js +4 -6
- package/dist/cjs/actions/test/sendUnsignedTransaction.js.map +1 -1
- package/dist/cjs/actions/wallet/sendTransaction.js +5 -7
- package/dist/cjs/actions/wallet/sendTransaction.js.map +1 -1
- package/dist/cjs/actions/wallet/writeContract.js.map +1 -1
- package/dist/cjs/chains/formatters/celo.js +62 -0
- package/dist/cjs/chains/formatters/celo.js.map +1 -0
- package/dist/cjs/chains/formatters/optimism.js +42 -0
- package/dist/cjs/chains/formatters/optimism.js.map +1 -0
- package/dist/cjs/{chains.js → chains/index.js} +16 -50
- package/dist/cjs/chains/index.js.map +1 -0
- package/dist/cjs/errors/version.js +1 -1
- package/dist/cjs/index.js +7 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/serializer.js +3 -0
- package/dist/cjs/types/serializer.js.map +1 -0
- package/dist/cjs/utils/chain.js +6 -2
- package/dist/cjs/utils/chain.js.map +1 -1
- package/dist/cjs/utils/formatters/block.js +2 -4
- package/dist/cjs/utils/formatters/block.js.map +1 -1
- package/dist/cjs/utils/formatters/extract.js +3 -3
- package/dist/cjs/utils/formatters/extract.js.map +1 -1
- package/dist/cjs/utils/formatters/formatter.js +24 -0
- package/dist/cjs/utils/formatters/formatter.js.map +1 -0
- package/dist/cjs/utils/formatters/transaction.js +3 -4
- package/dist/cjs/utils/formatters/transaction.js.map +1 -1
- package/dist/cjs/utils/formatters/transactionReceipt.js +3 -5
- package/dist/cjs/utils/formatters/transactionReceipt.js.map +1 -1
- package/dist/cjs/utils/formatters/transactionRequest.js +2 -4
- package/dist/cjs/utils/formatters/transactionRequest.js.map +1 -1
- package/dist/cjs/utils/index.js +8 -5
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/transaction/getTransactionType.js.map +1 -1
- package/dist/cjs/utils/transaction/serializeAccessList.js +26 -0
- package/dist/cjs/utils/transaction/serializeAccessList.js.map +1 -0
- package/dist/cjs/utils/transaction/serializeTransaction.js +3 -22
- package/dist/cjs/utils/transaction/serializeTransaction.js.map +1 -1
- package/dist/cjs/wallet.js.map +1 -1
- package/dist/esm/accounts/privateKeyToAccount.js +2 -2
- package/dist/esm/accounts/privateKeyToAccount.js.map +1 -1
- package/dist/esm/accounts/utils/signTransaction.js +4 -4
- package/dist/esm/accounts/utils/signTransaction.js.map +1 -1
- package/dist/esm/actions/getContract.js.map +1 -1
- package/dist/esm/actions/public/call.js +4 -6
- package/dist/esm/actions/public/call.js.map +1 -1
- package/dist/esm/actions/public/estimateContractGas.js.map +1 -1
- package/dist/esm/actions/public/estimateGas.js +4 -6
- package/dist/esm/actions/public/estimateGas.js.map +1 -1
- package/dist/esm/actions/public/getBlock.js +2 -4
- package/dist/esm/actions/public/getBlock.js.map +1 -1
- package/dist/esm/actions/public/getTransaction.js +2 -4
- package/dist/esm/actions/public/getTransaction.js.map +1 -1
- package/dist/esm/actions/public/getTransactionConfirmations.js.map +1 -1
- package/dist/esm/actions/public/getTransactionReceipt.js +3 -4
- package/dist/esm/actions/public/getTransactionReceipt.js.map +1 -1
- package/dist/esm/actions/public/simulateContract.js.map +1 -1
- package/dist/esm/actions/public/watchBlocks.js +3 -1
- package/dist/esm/actions/public/watchBlocks.js.map +1 -1
- package/dist/esm/actions/test/sendUnsignedTransaction.js +4 -6
- package/dist/esm/actions/test/sendUnsignedTransaction.js.map +1 -1
- package/dist/esm/actions/wallet/sendTransaction.js +5 -7
- package/dist/esm/actions/wallet/sendTransaction.js.map +1 -1
- package/dist/esm/actions/wallet/writeContract.js.map +1 -1
- package/dist/esm/chains/formatters/celo.js +60 -0
- package/dist/esm/chains/formatters/celo.js.map +1 -0
- package/dist/esm/chains/formatters/optimism.js +40 -0
- package/dist/esm/chains/formatters/optimism.js.map +1 -0
- package/dist/esm/{chains.js → chains/index.js} +13 -47
- package/dist/esm/chains/index.js.map +1 -0
- package/dist/esm/errors/version.js +1 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/serializer.js +2 -0
- package/dist/esm/types/serializer.js.map +1 -0
- package/dist/esm/utils/chain.js +6 -2
- package/dist/esm/utils/chain.js.map +1 -1
- package/dist/esm/utils/formatters/block.js +2 -5
- package/dist/esm/utils/formatters/block.js.map +1 -1
- package/dist/esm/utils/formatters/extract.js +3 -3
- package/dist/esm/utils/formatters/extract.js.map +1 -1
- package/dist/esm/utils/formatters/formatter.js +20 -0
- package/dist/esm/utils/formatters/formatter.js.map +1 -0
- package/dist/esm/utils/formatters/transaction.js +3 -4
- package/dist/esm/utils/formatters/transaction.js.map +1 -1
- package/dist/esm/utils/formatters/transactionReceipt.js +3 -5
- package/dist/esm/utils/formatters/transactionReceipt.js.map +1 -1
- package/dist/esm/utils/formatters/transactionRequest.js +2 -4
- package/dist/esm/utils/formatters/transactionRequest.js.map +1 -1
- package/dist/esm/utils/index.js +4 -2
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/transaction/getTransactionType.js.map +1 -1
- package/dist/esm/utils/transaction/serializeAccessList.js +32 -0
- package/dist/esm/utils/transaction/serializeAccessList.js.map +1 -0
- package/dist/esm/utils/transaction/serializeTransaction.js +2 -21
- package/dist/esm/utils/transaction/serializeTransaction.js.map +1 -1
- package/dist/esm/wallet.js.map +1 -1
- package/dist/types/accounts/types.d.ts +7 -2
- package/dist/types/accounts/types.d.ts.map +1 -1
- package/dist/types/accounts/utils/signTransaction.d.ts +5 -3
- package/dist/types/accounts/utils/signTransaction.d.ts.map +1 -1
- package/dist/types/actions/public/call.d.ts +3 -7
- package/dist/types/actions/public/call.d.ts.map +1 -1
- package/dist/types/actions/public/estimateContractGas.d.ts +1 -1
- package/dist/types/actions/public/estimateContractGas.d.ts.map +1 -1
- package/dist/types/actions/public/estimateGas.d.ts +3 -7
- package/dist/types/actions/public/estimateGas.d.ts.map +1 -1
- package/dist/types/actions/public/getBlock.d.ts +2 -2
- package/dist/types/actions/public/getBlock.d.ts.map +1 -1
- package/dist/types/actions/public/getTransaction.d.ts +2 -2
- package/dist/types/actions/public/getTransaction.d.ts.map +1 -1
- package/dist/types/actions/public/getTransactionConfirmations.d.ts +2 -2
- package/dist/types/actions/public/getTransactionConfirmations.d.ts.map +1 -1
- package/dist/types/actions/public/getTransactionReceipt.d.ts +3 -3
- package/dist/types/actions/public/getTransactionReceipt.d.ts.map +1 -1
- package/dist/types/actions/public/simulateContract.d.ts +1 -1
- package/dist/types/actions/public/simulateContract.d.ts.map +1 -1
- package/dist/types/actions/public/verifyHash.d.ts +1 -1
- package/dist/types/actions/public/verifyHash.d.ts.map +1 -1
- package/dist/types/actions/public/verifyMessage.d.ts +1 -1
- package/dist/types/actions/public/verifyMessage.d.ts.map +1 -1
- package/dist/types/actions/public/verifyTypedData.d.ts +1 -1
- package/dist/types/actions/public/verifyTypedData.d.ts.map +1 -1
- package/dist/types/actions/public/watchBlocks.d.ts.map +1 -1
- package/dist/types/actions/test/sendUnsignedTransaction.d.ts +2 -8
- package/dist/types/actions/test/sendUnsignedTransaction.d.ts.map +1 -1
- package/dist/types/actions/wallet/sendTransaction.d.ts +3 -7
- package/dist/types/actions/wallet/sendTransaction.d.ts.map +1 -1
- package/dist/types/actions/wallet/writeContract.d.ts +1 -1
- package/dist/types/actions/wallet/writeContract.d.ts.map +1 -1
- package/dist/types/chains/formatters/celo.d.ts +247 -0
- package/dist/types/chains/formatters/celo.d.ts.map +1 -0
- package/dist/types/chains/formatters/optimism.d.ts +286 -0
- package/dist/types/chains/formatters/optimism.d.ts.map +1 -0
- package/dist/types/chains/index.d.ts +5278 -0
- package/dist/types/chains/index.d.ts.map +1 -0
- package/dist/types/errors/version.d.ts +1 -1
- package/dist/types/index.d.ts +8 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/chain.d.ts +3 -1
- package/dist/types/types/chain.d.ts.map +1 -1
- package/dist/types/types/fee.d.ts +1 -0
- package/dist/types/types/fee.d.ts.map +1 -1
- package/dist/types/types/formatter.d.ts +11 -10
- package/dist/types/types/formatter.d.ts.map +1 -1
- package/dist/types/types/rpc.d.ts +1 -1
- package/dist/types/types/rpc.d.ts.map +1 -1
- package/dist/types/types/serializer.d.ts +7 -0
- package/dist/types/types/serializer.d.ts.map +1 -0
- package/dist/types/types/transaction.d.ts +14 -3
- package/dist/types/types/transaction.d.ts.map +1 -1
- package/dist/types/types/utils.d.ts +5 -5
- package/dist/types/types/utils.d.ts.map +1 -1
- package/dist/types/utils/chain.d.ts +4 -1
- package/dist/types/utils/chain.d.ts.map +1 -1
- package/dist/types/utils/formatters/block.d.ts +8 -11
- package/dist/types/utils/formatters/block.d.ts.map +1 -1
- package/dist/types/utils/formatters/extract.d.ts +2 -2
- package/dist/types/utils/formatters/extract.d.ts.map +1 -1
- package/dist/types/utils/formatters/formatter.d.ts +9 -0
- package/dist/types/utils/formatters/formatter.d.ts.map +1 -0
- package/dist/types/utils/formatters/transaction.d.ts +8 -11
- package/dist/types/utils/formatters/transaction.d.ts.map +1 -1
- package/dist/types/utils/formatters/transactionReceipt.d.ts +8 -11
- package/dist/types/utils/formatters/transactionReceipt.d.ts.map +1 -1
- package/dist/types/utils/formatters/transactionRequest.d.ts +8 -11
- package/dist/types/utils/formatters/transactionRequest.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +8 -6
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/transaction/getTransactionType.d.ts +2 -2
- package/dist/types/utils/transaction/getTransactionType.d.ts.map +1 -1
- package/dist/types/utils/transaction/serializeAccessList.d.ts +5 -0
- package/dist/types/utils/transaction/serializeAccessList.d.ts.map +1 -0
- package/dist/types/utils/transaction/serializeTransaction.d.ts +1 -0
- package/dist/types/utils/transaction/serializeTransaction.d.ts.map +1 -1
- package/dist/types/wallet.d.ts +1 -1
- package/dist/types/wallet.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/accounts/privateKeyToAccount.ts +2 -2
- package/src/accounts/types.ts +20 -2
- package/src/accounts/utils/signTransaction.ts +9 -6
- package/src/actions/getContract.ts +1 -1
- package/src/actions/public/call.ts +21 -30
- package/src/actions/public/estimateContractGas.ts +7 -1
- package/src/actions/public/estimateGas.ts +22 -31
- package/src/actions/public/getBlock.ts +3 -6
- package/src/actions/public/getTransaction.ts +4 -6
- package/src/actions/public/getTransactionConfirmations.ts +2 -7
- package/src/actions/public/getTransactionReceipt.ts +5 -7
- package/src/actions/public/simulateContract.ts +7 -1
- package/src/actions/public/verifyHash.ts +1 -1
- package/src/actions/public/verifyMessage.ts +1 -1
- package/src/actions/public/verifyTypedData.ts +1 -1
- package/src/actions/public/watchBlocks.ts +4 -1
- package/src/actions/test/sendUnsignedTransaction.ts +19 -32
- package/src/actions/wallet/sendTransaction.ts +33 -36
- package/src/actions/wallet/writeContract.ts +11 -1
- package/src/chains/formatters/celo.ts +103 -0
- package/src/chains/formatters/optimism.ts +91 -0
- package/src/{chains.ts → chains/index.ts} +13 -56
- package/src/errors/version.ts +1 -1
- package/src/index.ts +7 -9
- package/src/types/chain.ts +8 -1
- package/src/types/fee.ts +1 -0
- package/src/types/formatter.ts +29 -19
- package/src/types/rpc.ts +1 -1
- package/src/types/serializer.ts +19 -0
- package/src/types/transaction.ts +24 -4
- package/src/types/utils.ts +5 -5
- package/src/utils/chain.ts +11 -4
- package/src/utils/formatters/block.ts +5 -17
- package/src/utils/formatters/extract.ts +3 -3
- package/src/utils/formatters/formatter.ts +36 -0
- package/src/utils/formatters/transaction.ts +9 -21
- package/src/utils/formatters/transactionReceipt.ts +11 -22
- package/src/utils/formatters/transactionRequest.ts +8 -22
- package/src/utils/index.ts +7 -11
- package/src/utils/transaction/getTransactionType.ts +10 -9
- package/src/utils/transaction/serializeAccessList.ts +39 -0
- package/src/utils/transaction/serializeTransaction.ts +11 -34
- package/src/wallet.ts +0 -1
- package/dist/cjs/chains.js.map +0 -1
- package/dist/cjs/utils/formatters/format.js +0 -23
- package/dist/cjs/utils/formatters/format.js.map +0 -1
- package/dist/esm/chains.js.map +0 -1
- package/dist/esm/utils/formatters/format.js +0 -21
- package/dist/esm/utils/formatters/format.js.map +0 -1
- package/dist/types/chains.d.ts +0 -2834
- package/dist/types/chains.d.ts.map +0 -1
- package/dist/types/utils/formatters/format.d.ts +0 -38
- package/dist/types/utils/formatters/format.d.ts.map +0 -1
- package/src/utils/formatters/format.ts +0 -99
@@ -3,6 +3,7 @@ import type { Transport } from '../../clients/transports/createTransport.js'
|
|
3
3
|
import type { BlockTag } from '../../types/block.js'
|
4
4
|
import type { Chain } from '../../types/chain.js'
|
5
5
|
import type { GetTransportConfig } from '../../types/transport.js'
|
6
|
+
import { formatBlock } from '../../utils/formatters/block.js'
|
6
7
|
import { observe } from '../../utils/observe.js'
|
7
8
|
import { poll } from '../../utils/poll.js'
|
8
9
|
import { stringify } from '../../utils/stringify.js'
|
@@ -170,7 +171,9 @@ export function watchBlocks<
|
|
170
171
|
params: ['newHeads'],
|
171
172
|
onData(data: any) {
|
172
173
|
if (!active) return
|
173
|
-
const
|
174
|
+
const format =
|
175
|
+
client.chain?.formatters?.block?.format || formatBlock
|
176
|
+
const block = format(data.result)
|
174
177
|
onBlock(block, prevBlock)
|
175
178
|
prevBlock = block
|
176
179
|
},
|
@@ -4,27 +4,17 @@ import type {
|
|
4
4
|
} from '../../clients/createTestClient.js'
|
5
5
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
6
6
|
import type { Chain } from '../../types/chain.js'
|
7
|
-
import type { Formatter } from '../../types/formatter.js'
|
8
7
|
import type { Hash } from '../../types/misc.js'
|
9
8
|
import type { TransactionRequest } from '../../types/transaction.js'
|
10
|
-
import type { MergeIntersectionProperties } from '../../types/utils.js'
|
11
9
|
import { extract } from '../../utils/formatters/extract.js'
|
12
|
-
import { type Formatted, format } from '../../utils/formatters/format.js'
|
13
10
|
import {
|
14
|
-
type
|
11
|
+
type FormattedTransactionRequest,
|
15
12
|
formatTransactionRequest,
|
16
13
|
} from '../../utils/formatters/transactionRequest.js'
|
17
14
|
|
18
|
-
type FormattedTransactionRequest<
|
19
|
-
TFormatter extends Formatter | undefined = Formatter,
|
20
|
-
> = MergeIntersectionProperties<
|
21
|
-
Formatted<TFormatter, TransactionRequest, true>,
|
22
|
-
TransactionRequest
|
23
|
-
>
|
24
|
-
|
25
15
|
export type SendUnsignedTransactionParameters<
|
26
16
|
TChain extends Chain | undefined = Chain | undefined,
|
27
|
-
> = FormattedTransactionRequest<
|
17
|
+
> = FormattedTransactionRequest<TChain>
|
28
18
|
|
29
19
|
export type SendUnsignedTransactionReturnType = Hash
|
30
20
|
|
@@ -73,26 +63,23 @@ export async function sendUnsignedTransaction<
|
|
73
63
|
...rest
|
74
64
|
} = args
|
75
65
|
|
76
|
-
const
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
formatter: formatter || formatTransactionRequest,
|
94
|
-
},
|
95
|
-
)
|
66
|
+
const format =
|
67
|
+
client.chain?.formatters?.transactionRequest?.format ||
|
68
|
+
formatTransactionRequest
|
69
|
+
const request = format({
|
70
|
+
// Pick out extra data that might exist on the chain's transaction request type.
|
71
|
+
...extract(rest, { format }),
|
72
|
+
accessList,
|
73
|
+
data,
|
74
|
+
from,
|
75
|
+
gas,
|
76
|
+
gasPrice,
|
77
|
+
maxFeePerGas,
|
78
|
+
maxPriorityFeePerGas,
|
79
|
+
nonce,
|
80
|
+
to,
|
81
|
+
value,
|
82
|
+
} as TransactionRequest)
|
96
83
|
const hash = await client.request({
|
97
84
|
method: 'eth_sendUnsignedTransaction',
|
98
85
|
params: [request],
|
@@ -6,37 +6,33 @@ import { AccountNotFoundError } from '../../errors/account.js'
|
|
6
6
|
import type { BaseError } from '../../errors/base.js'
|
7
7
|
import type { GetAccountParameter } from '../../types/account.js'
|
8
8
|
import type { Chain, GetChain } from '../../types/chain.js'
|
9
|
-
import type { Formatter } from '../../types/formatter.js'
|
10
9
|
import type { Hash } from '../../types/misc.js'
|
11
10
|
import type {
|
12
11
|
TransactionRequest,
|
13
12
|
TransactionSerializable,
|
14
13
|
} from '../../types/transaction.js'
|
15
|
-
import type {
|
14
|
+
import type { IsUndefined } from '../../types/utils.js'
|
16
15
|
import { assertCurrentChain } from '../../utils/chain.js'
|
17
16
|
import { getTransactionError } from '../../utils/errors/getTransactionError.js'
|
18
17
|
import { extract } from '../../utils/formatters/extract.js'
|
19
|
-
import { type Formatted, format } from '../../utils/formatters/format.js'
|
20
18
|
import {
|
21
|
-
type
|
19
|
+
type FormattedTransactionRequest,
|
22
20
|
formatTransactionRequest,
|
23
21
|
} from '../../utils/formatters/transactionRequest.js'
|
24
22
|
import { assertRequest } from '../../utils/transaction/assertRequest.js'
|
25
23
|
import { prepareRequest } from '../../utils/transaction/prepareRequest.js'
|
26
24
|
import { getChainId } from '../public/getChainId.js'
|
27
25
|
|
28
|
-
export type FormattedTransactionRequest<
|
29
|
-
TFormatter extends Formatter | undefined = Formatter,
|
30
|
-
> = MergeIntersectionProperties<
|
31
|
-
Omit<Formatted<TFormatter, TransactionRequest, true>, 'from'>,
|
32
|
-
TransactionRequest
|
33
|
-
>
|
34
|
-
|
35
26
|
export type SendTransactionParameters<
|
36
27
|
TChain extends Chain | undefined = Chain | undefined,
|
37
28
|
TAccount extends Account | undefined = Account | undefined,
|
38
29
|
TChainOverride extends Chain | undefined = Chain,
|
39
|
-
> =
|
30
|
+
> = Omit<
|
31
|
+
FormattedTransactionRequest<
|
32
|
+
IsUndefined<TChain> extends true ? TChainOverride : TChain
|
33
|
+
>,
|
34
|
+
'from'
|
35
|
+
> &
|
40
36
|
GetAccountParameter<TAccount> &
|
41
37
|
GetChain<TChain, TChainOverride>
|
42
38
|
|
@@ -146,36 +142,37 @@ export async function sendTransaction<
|
|
146
142
|
})
|
147
143
|
|
148
144
|
if (!chainId) chainId = await getChainId(client)
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
145
|
+
|
146
|
+
const serializer = chain?.serializers?.transaction
|
147
|
+
const signedRequest = (await account.signTransaction(
|
148
|
+
{
|
149
|
+
...request,
|
150
|
+
chainId,
|
151
|
+
} as TransactionSerializable,
|
152
|
+
{ serializer },
|
153
|
+
)) as Hash
|
153
154
|
return await client.request({
|
154
155
|
method: 'eth_sendRawTransaction',
|
155
156
|
params: [signedRequest],
|
156
157
|
})
|
157
158
|
}
|
158
159
|
|
159
|
-
const
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
{
|
176
|
-
formatter: formatter || formatTransactionRequest,
|
177
|
-
},
|
178
|
-
)
|
160
|
+
const format =
|
161
|
+
chain?.formatters?.transactionRequest?.format || formatTransactionRequest
|
162
|
+
const request = format({
|
163
|
+
// Pick out extra data that might exist on the chain's transaction request type.
|
164
|
+
...extract(rest, { format }),
|
165
|
+
accessList,
|
166
|
+
data,
|
167
|
+
from: account.address,
|
168
|
+
gas,
|
169
|
+
gasPrice,
|
170
|
+
maxFeePerGas,
|
171
|
+
maxPriorityFeePerGas,
|
172
|
+
nonce,
|
173
|
+
to,
|
174
|
+
value,
|
175
|
+
} as TransactionRequest)
|
179
176
|
return await client.request({
|
180
177
|
method: 'eth_sendTransaction',
|
181
178
|
params: [request],
|
@@ -29,7 +29,17 @@ export type WriteContractParameters<
|
|
29
29
|
'chain' | 'to' | 'data' | 'value'
|
30
30
|
> &
|
31
31
|
GetChain<TChain, TChainOverride> &
|
32
|
-
GetValue<
|
32
|
+
GetValue<
|
33
|
+
TAbi,
|
34
|
+
TFunctionName,
|
35
|
+
SendTransactionParameters<
|
36
|
+
TChain,
|
37
|
+
TAccount,
|
38
|
+
TChainOverride
|
39
|
+
> extends SendTransactionParameters
|
40
|
+
? SendTransactionParameters<TChain, TAccount, TChainOverride>['value']
|
41
|
+
: SendTransactionParameters['value']
|
42
|
+
> & {
|
33
43
|
/** Data to append to the end of the calldata. Useful for adding a ["domain" tag](https://opensea.notion.site/opensea/Seaport-Order-Attributions-ec2d69bf455041a5baa490941aad307f). */
|
34
44
|
dataSuffix?: Hex
|
35
45
|
}
|
@@ -0,0 +1,103 @@
|
|
1
|
+
import type { Address } from 'abitype'
|
2
|
+
|
3
|
+
import { type Formatters } from '../../types/formatter.js'
|
4
|
+
import type { Hash, Hex } from '../../types/misc.js'
|
5
|
+
import type { RpcTransaction } from '../../types/rpc.js'
|
6
|
+
import type { Transaction } from '../../types/transaction.js'
|
7
|
+
import { hexToBigInt } from '../../utils/encoding/fromHex.js'
|
8
|
+
import { numberToHex } from '../../utils/encoding/toHex.js'
|
9
|
+
import { defineBlock } from '../../utils/formatters/block.js'
|
10
|
+
import {
|
11
|
+
defineTransaction,
|
12
|
+
formatTransaction,
|
13
|
+
} from '../../utils/formatters/transaction.js'
|
14
|
+
import { defineTransactionReceipt } from '../../utils/formatters/transactionReceipt.js'
|
15
|
+
import { defineTransactionRequest } from '../../utils/formatters/transactionRequest.js'
|
16
|
+
|
17
|
+
export type CeloOverrides = {
|
18
|
+
RpcBlock: {
|
19
|
+
randomness: {
|
20
|
+
committed: Hex
|
21
|
+
revealed: Hex
|
22
|
+
}
|
23
|
+
transactions:
|
24
|
+
| Hash[]
|
25
|
+
| (RpcTransaction & {
|
26
|
+
feeCurrency: Address | null
|
27
|
+
gatewayFee: Hex | null
|
28
|
+
gatewayFeeRecipient: Address | null
|
29
|
+
})[]
|
30
|
+
}
|
31
|
+
RpcTransaction: {
|
32
|
+
feeCurrency: Address | null
|
33
|
+
gatewayFee: Hex | null
|
34
|
+
gatewayFeeRecipient: Address | null
|
35
|
+
}
|
36
|
+
RpcTransactionReceipt: {
|
37
|
+
feeCurrency: Address | null
|
38
|
+
gatewayFee: Hex | null
|
39
|
+
gatewayFeeRecipient: Address | null
|
40
|
+
}
|
41
|
+
TransactionRequest: {
|
42
|
+
feeCurrency?: Address
|
43
|
+
gatewayFee?: bigint
|
44
|
+
gatewayFeeRecipient?: Address
|
45
|
+
}
|
46
|
+
Transaction: {
|
47
|
+
feeCurrency: Address | null
|
48
|
+
gatewayFee: bigint | null
|
49
|
+
gatewayFeeRecipient: Address | null
|
50
|
+
}
|
51
|
+
}
|
52
|
+
export const celoFormatters = {
|
53
|
+
block: /*#__PURE__*/ defineBlock({
|
54
|
+
exclude: ['difficulty', 'gasLimit', 'mixHash', 'nonce', 'uncles'],
|
55
|
+
format(args: CeloOverrides['RpcBlock']) {
|
56
|
+
const transactions = args.transactions?.map((transaction) => {
|
57
|
+
if (typeof transaction === 'string') return transaction
|
58
|
+
return {
|
59
|
+
...formatTransaction(transaction),
|
60
|
+
feeCurrency: transaction.feeCurrency,
|
61
|
+
gatewayFee: transaction.gatewayFee
|
62
|
+
? hexToBigInt(transaction.gatewayFee)
|
63
|
+
: null,
|
64
|
+
gatewayFeeRecipient: transaction.gatewayFeeRecipient,
|
65
|
+
}
|
66
|
+
}) as Hash[] | (Transaction & CeloOverrides['Transaction'])[]
|
67
|
+
return {
|
68
|
+
randomness: args.randomness,
|
69
|
+
transactions,
|
70
|
+
}
|
71
|
+
},
|
72
|
+
}),
|
73
|
+
transaction: /*#__PURE__*/ defineTransaction({
|
74
|
+
format(args: CeloOverrides['RpcTransaction']) {
|
75
|
+
return {
|
76
|
+
feeCurrency: args.feeCurrency,
|
77
|
+
gatewayFee: args.gatewayFee ? hexToBigInt(args.gatewayFee) : null,
|
78
|
+
gatewayFeeRecipient: args.gatewayFeeRecipient,
|
79
|
+
}
|
80
|
+
},
|
81
|
+
}),
|
82
|
+
transactionReceipt: /*#__PURE__*/ defineTransactionReceipt({
|
83
|
+
format(args: CeloOverrides['RpcTransactionReceipt']) {
|
84
|
+
return {
|
85
|
+
feeCurrency: args.feeCurrency,
|
86
|
+
gatewayFee: args.gatewayFee ? hexToBigInt(args.gatewayFee) : null,
|
87
|
+
gatewayFeeRecipient: args.gatewayFeeRecipient,
|
88
|
+
}
|
89
|
+
},
|
90
|
+
}),
|
91
|
+
transactionRequest: /*#__PURE__*/ defineTransactionRequest({
|
92
|
+
format(args: CeloOverrides['TransactionRequest']) {
|
93
|
+
return {
|
94
|
+
feeCurrency: args.feeCurrency,
|
95
|
+
gatewayFee:
|
96
|
+
typeof args.gatewayFee !== 'undefined'
|
97
|
+
? numberToHex(args.gatewayFee)
|
98
|
+
: undefined,
|
99
|
+
gatewayFeeRecipient: args.gatewayFeeRecipient,
|
100
|
+
}
|
101
|
+
},
|
102
|
+
}),
|
103
|
+
} as const satisfies Formatters
|
@@ -0,0 +1,91 @@
|
|
1
|
+
import type { FeeValuesEIP1559 } from '../../types/fee.js'
|
2
|
+
import { type Formatters } from '../../types/formatter.js'
|
3
|
+
import type { Hash, Hex } from '../../types/misc.js'
|
4
|
+
import type {
|
5
|
+
Index,
|
6
|
+
Quantity,
|
7
|
+
RpcTransaction as RpcTransaction_,
|
8
|
+
} from '../../types/rpc.js'
|
9
|
+
import type {
|
10
|
+
Transaction as Transaction_,
|
11
|
+
TransactionBase,
|
12
|
+
} from '../../types/transaction.js'
|
13
|
+
import { hexToBigInt } from '../../utils/encoding/fromHex.js'
|
14
|
+
import { defineBlock } from '../../utils/formatters/block.js'
|
15
|
+
import {
|
16
|
+
defineTransaction,
|
17
|
+
formatTransaction,
|
18
|
+
} from '../../utils/formatters/transaction.js'
|
19
|
+
|
20
|
+
type RpcTransaction = RpcTransaction_ & {
|
21
|
+
isSystemTx?: undefined
|
22
|
+
mint?: undefined
|
23
|
+
sourceHash?: undefined
|
24
|
+
}
|
25
|
+
|
26
|
+
export type RpcDepositTransaction = TransactionBase<Quantity, Index> &
|
27
|
+
FeeValuesEIP1559<Quantity> & {
|
28
|
+
isSystemTx?: boolean
|
29
|
+
mint?: Hex
|
30
|
+
sourceHash: Hex
|
31
|
+
type: '0x7e'
|
32
|
+
}
|
33
|
+
|
34
|
+
type Transaction = Transaction_ & {
|
35
|
+
isSystemTx?: undefined
|
36
|
+
mint?: undefined
|
37
|
+
sourceHash?: undefined
|
38
|
+
}
|
39
|
+
|
40
|
+
export type DepositTransaction = TransactionBase &
|
41
|
+
FeeValuesEIP1559 & {
|
42
|
+
isSystemTx?: boolean
|
43
|
+
mint?: bigint
|
44
|
+
sourceHash: Hex
|
45
|
+
type: 'deposit'
|
46
|
+
}
|
47
|
+
|
48
|
+
type OptimismOverrides = {
|
49
|
+
RpcBlock: {
|
50
|
+
transactions: Hash[] | OptimismOverrides['RpcTransaction'][]
|
51
|
+
}
|
52
|
+
RpcTransaction: RpcTransaction | RpcDepositTransaction
|
53
|
+
Transaction: Transaction | DepositTransaction
|
54
|
+
}
|
55
|
+
|
56
|
+
export const optimismFormatters = {
|
57
|
+
block: /*#__PURE__*/ defineBlock({
|
58
|
+
format(args: OptimismOverrides['RpcBlock']) {
|
59
|
+
const transactions = args.transactions?.map((transaction) => {
|
60
|
+
if (typeof transaction === 'string') return transaction
|
61
|
+
const formatted = formatTransaction(
|
62
|
+
transaction as RpcTransaction,
|
63
|
+
) as OptimismOverrides['Transaction']
|
64
|
+
if (formatted.typeHex === '0x7e') {
|
65
|
+
formatted.isSystemTx = transaction.isSystemTx
|
66
|
+
formatted.mint = transaction.mint
|
67
|
+
? hexToBigInt(transaction.mint)
|
68
|
+
: undefined
|
69
|
+
formatted.sourceHash = transaction.sourceHash
|
70
|
+
formatted.type = 'deposit'
|
71
|
+
}
|
72
|
+
return formatted
|
73
|
+
}) as Hash[] | OptimismOverrides['Transaction'][]
|
74
|
+
return {
|
75
|
+
transactions,
|
76
|
+
}
|
77
|
+
},
|
78
|
+
}),
|
79
|
+
transaction: /*#__PURE__*/ defineTransaction({
|
80
|
+
format(args: OptimismOverrides['RpcTransaction']) {
|
81
|
+
const transaction = {} as OptimismOverrides['Transaction']
|
82
|
+
if (args.type === '0x7e') {
|
83
|
+
transaction.isSystemTx = args.isSystemTx
|
84
|
+
transaction.mint = args.mint ? hexToBigInt(args.mint) : undefined
|
85
|
+
transaction.sourceHash = args.sourceHash
|
86
|
+
transaction.type = 'deposit'
|
87
|
+
}
|
88
|
+
return transaction
|
89
|
+
},
|
90
|
+
}),
|
91
|
+
} as const satisfies Formatters
|
@@ -1,53 +1,9 @@
|
|
1
1
|
import * as chains from '@wagmi/chains'
|
2
2
|
|
3
|
-
import
|
3
|
+
import { defineChain } from '../utils/chain.js'
|
4
|
+
import { celoFormatters } from './formatters/celo.js'
|
5
|
+
import { optimismFormatters } from './formatters/optimism.js'
|
4
6
|
|
5
|
-
import type { Hex } from './types/misc.js'
|
6
|
-
import type { Quantity } from './types/rpc.js'
|
7
|
-
import { defineChain } from './utils/chain.js'
|
8
|
-
import { defineBlock } from './utils/formatters/block.js'
|
9
|
-
import { defineTransaction } from './utils/formatters/transaction.js'
|
10
|
-
import { defineTransactionReceipt } from './utils/formatters/transactionReceipt.js'
|
11
|
-
import { defineTransactionRequest } from './utils/formatters/transactionRequest.js'
|
12
|
-
|
13
|
-
const celoFormatters = {
|
14
|
-
block: /*#__PURE__*/ defineBlock({
|
15
|
-
exclude: ['difficulty', 'gasLimit', 'mixHash', 'nonce', 'uncles'],
|
16
|
-
format: (block) => ({
|
17
|
-
randomness: block.randomness as {
|
18
|
-
committed: Hex
|
19
|
-
revealed: Hex
|
20
|
-
},
|
21
|
-
}),
|
22
|
-
}),
|
23
|
-
transaction: /*#__PURE__*/ defineTransaction({
|
24
|
-
format: (transaction) => ({
|
25
|
-
feeCurrency: transaction.feeCurrency as Address | null,
|
26
|
-
gatewayFee: transaction.gatewayFee
|
27
|
-
? BigInt(transaction.gatewayFee as Quantity)
|
28
|
-
: null,
|
29
|
-
gatewayFeeRecipient: transaction.gatewayFeeRecipient as Address | null,
|
30
|
-
}),
|
31
|
-
}),
|
32
|
-
transactionReceipt: /*#__PURE__*/ defineTransactionReceipt({
|
33
|
-
format: (transaction) => ({
|
34
|
-
feeCurrency: transaction.feeCurrency as Address | null,
|
35
|
-
gatewayFee: transaction.gatewayFee
|
36
|
-
? BigInt(transaction.gatewayFee as Quantity)
|
37
|
-
: null,
|
38
|
-
gatewayFeeRecipient: transaction.gatewayFeeRecipient as Address | null,
|
39
|
-
}),
|
40
|
-
}),
|
41
|
-
transactionRequest: /*#__PURE__*/ defineTransactionRequest({
|
42
|
-
format: (transactionRequest) => ({
|
43
|
-
feeCurrency: transactionRequest.feeCurrency as Address | undefined,
|
44
|
-
gatewayFee: transactionRequest.gatewayFee as Quantity | undefined,
|
45
|
-
gatewayFeeRecipient: transactionRequest.gatewayFeeRecipient as
|
46
|
-
| Address
|
47
|
-
| undefined,
|
48
|
-
}),
|
49
|
-
}),
|
50
|
-
}
|
51
7
|
export const arbitrum = /*#__PURE__*/ defineChain(chains.arbitrum)
|
52
8
|
export const arbitrumGoerli = /*#__PURE__*/ defineChain(chains.arbitrumGoerli)
|
53
9
|
export const aurora = /*#__PURE__*/ defineChain(chains.aurora)
|
@@ -61,16 +17,13 @@ export const bronosTestnet = /*#__PURE__*/ defineChain(chains.bronosTestnet)
|
|
61
17
|
export const bsc = /*#__PURE__*/ defineChain(chains.bsc)
|
62
18
|
export const bscTestnet = /*#__PURE__*/ defineChain(chains.bscTestnet)
|
63
19
|
export const canto = /*#__PURE__*/ defineChain(chains.canto)
|
64
|
-
export const celo = /*#__PURE__*/ defineChain({
|
65
|
-
...chains.celo,
|
20
|
+
export const celo = /*#__PURE__*/ defineChain(chains.celo, {
|
66
21
|
formatters: celoFormatters,
|
67
22
|
})
|
68
|
-
export const celoAlfajores = /*#__PURE__*/ defineChain({
|
69
|
-
...chains.celoAlfajores,
|
23
|
+
export const celoAlfajores = /*#__PURE__*/ defineChain(chains.celoAlfajores, {
|
70
24
|
formatters: celoFormatters,
|
71
25
|
})
|
72
|
-
export const celoCannoli = /*#__PURE__*/ defineChain({
|
73
|
-
...chains.celoCannoli,
|
26
|
+
export const celoCannoli = /*#__PURE__*/ defineChain(chains.celoCannoli, {
|
74
27
|
formatters: celoFormatters,
|
75
28
|
})
|
76
29
|
export const cronos = /*#__PURE__*/ defineChain(chains.cronos)
|
@@ -111,8 +64,12 @@ export const moonbeam = /*#__PURE__*/ defineChain(chains.moonbeam)
|
|
111
64
|
export const moonriver = /*#__PURE__*/ defineChain(chains.moonriver)
|
112
65
|
export const nexi = /*#__PURE__*/ defineChain(chains.nexi)
|
113
66
|
export const okc = /*#__PURE__*/ defineChain(chains.okc)
|
114
|
-
export const optimism = /*#__PURE__*/ defineChain(chains.optimism
|
115
|
-
|
67
|
+
export const optimism = /*#__PURE__*/ defineChain(chains.optimism, {
|
68
|
+
formatters: optimismFormatters,
|
69
|
+
})
|
70
|
+
export const optimismGoerli = /*#__PURE__*/ defineChain(chains.optimismGoerli, {
|
71
|
+
formatters: optimismFormatters,
|
72
|
+
})
|
116
73
|
export const polygon = /*#__PURE__*/ defineChain(chains.polygon)
|
117
74
|
export const polygonMumbai = /*#__PURE__*/ defineChain(chains.polygonMumbai)
|
118
75
|
export const polygonZkEvm = /*#__PURE__*/ defineChain(chains.polygonZkEvm)
|
@@ -174,4 +131,4 @@ export const zkSync = /*#__PURE__*/ defineChain(chains.zkSync)
|
|
174
131
|
export const zkSyncTestnet = /*#__PURE__*/ defineChain(chains.zkSyncTestnet)
|
175
132
|
export const zoraTestnet = /*#__PURE__*/ defineChain(chains.zoraTestnet)
|
176
133
|
|
177
|
-
export type { Chain } from '
|
134
|
+
export type { Chain } from '../types/chain.js'
|
package/src/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '1.
|
1
|
+
export const version = '1.1.1'
|
package/src/index.ts
CHANGED
@@ -476,6 +476,7 @@ export type {
|
|
476
476
|
Formatter,
|
477
477
|
Formatters,
|
478
478
|
} from './types/formatter.js'
|
479
|
+
export type { Serializers } from './types/serializer.js'
|
479
480
|
export type {
|
480
481
|
GetTypedDataDomain,
|
481
482
|
GetTypedDataMessage,
|
@@ -507,11 +508,11 @@ export type {
|
|
507
508
|
export { labelhash } from './utils/ens/labelhash.js'
|
508
509
|
export { namehash } from './utils/ens/namehash.js'
|
509
510
|
export {
|
510
|
-
type BlockFormatter,
|
511
511
|
type FormattedBlock,
|
512
512
|
defineBlock,
|
513
513
|
formatBlock,
|
514
514
|
} from './utils/formatters/block.js'
|
515
|
+
export { formatLog } from './utils/formatters/log.js'
|
515
516
|
export {
|
516
517
|
type DecodeAbiParametersReturnType,
|
517
518
|
decodeAbiParameters,
|
@@ -559,25 +560,18 @@ export {
|
|
559
560
|
type EncodeFunctionResultParameters,
|
560
561
|
encodeFunctionResult,
|
561
562
|
} from './utils/abi/encodeFunctionResult.js'
|
562
|
-
export type {
|
563
|
-
ExtractFormatter,
|
564
|
-
Formatted,
|
565
|
-
} from './utils/formatters/format.js'
|
566
563
|
export {
|
567
564
|
type FormattedTransaction,
|
568
|
-
type TransactionFormatter,
|
569
565
|
defineTransaction,
|
570
566
|
formatTransaction,
|
571
567
|
transactionType,
|
572
568
|
} from './utils/formatters/transaction.js'
|
573
569
|
export {
|
574
570
|
type FormattedTransactionReceipt,
|
575
|
-
type TransactionReceiptFormatter,
|
576
571
|
defineTransactionReceipt,
|
577
572
|
} from './utils/formatters/transactionReceipt.js'
|
578
573
|
export {
|
579
574
|
type FormattedTransactionRequest,
|
580
|
-
type TransactionRequestFormatter,
|
581
575
|
defineTransactionRequest,
|
582
576
|
formatTransactionRequest,
|
583
577
|
} from './utils/formatters/transactionRequest.js'
|
@@ -701,7 +695,11 @@ export { parseGwei } from './utils/unit/parseGwei.js'
|
|
701
695
|
export { parseTransaction } from './utils/transaction/parseTransaction.js'
|
702
696
|
export { parseUnits } from './utils/unit/parseUnits.js'
|
703
697
|
export { prepareRequest } from './utils/transaction/prepareRequest.js'
|
704
|
-
export {
|
698
|
+
export { serializeAccessList } from './utils/transaction/serializeAccessList.js'
|
699
|
+
export {
|
700
|
+
serializeTransaction,
|
701
|
+
type SerializeTransactionFn,
|
702
|
+
} from './utils/transaction/serializeTransaction.js'
|
705
703
|
export { size } from './utils/data/size.js'
|
706
704
|
export { slice, sliceBytes, sliceHex } from './utils/data/slice.js'
|
707
705
|
export { stringify } from './utils/stringify.js'
|
package/src/types/chain.ts
CHANGED
@@ -2,10 +2,17 @@ import type { Chain as Chain_ } from '@wagmi/chains'
|
|
2
2
|
import type { Address } from 'abitype'
|
3
3
|
|
4
4
|
import type { Formatters } from './formatter.js'
|
5
|
+
import type { Serializers } from './serializer.js'
|
5
6
|
import type { IsUndefined } from './utils.js'
|
6
7
|
|
7
|
-
export type Chain<
|
8
|
+
export type Chain<
|
9
|
+
TFormatters extends Formatters | undefined = Formatters | undefined,
|
10
|
+
TSerializers extends Serializers<TFormatters> | undefined =
|
11
|
+
| Serializers<TFormatters>
|
12
|
+
| undefined,
|
13
|
+
> = Chain_ & {
|
8
14
|
formatters?: TFormatters
|
15
|
+
serializers?: TSerializers
|
9
16
|
}
|
10
17
|
|
11
18
|
export type ChainContract = {
|
package/src/types/fee.ts
CHANGED
@@ -20,6 +20,7 @@ export type FeeValuesLegacy<TQuantity = bigint> = {
|
|
20
20
|
}
|
21
21
|
|
22
22
|
export type FeeValuesEIP1559<TQuantity = bigint> = {
|
23
|
+
/** Base fee per gas. */
|
23
24
|
gasPrice?: never
|
24
25
|
/** Total fee per gas in wei (gasPrice/baseFeePerGas + maxPriorityFeePerGas). */
|
25
26
|
maxFeePerGas: TQuantity
|
package/src/types/formatter.ts
CHANGED
@@ -1,23 +1,33 @@
|
|
1
|
-
import type {
|
2
|
-
import type {
|
3
|
-
RpcBlock,
|
4
|
-
RpcTransaction,
|
5
|
-
RpcTransactionReceipt,
|
6
|
-
RpcTransactionRequest,
|
7
|
-
} from './rpc.js'
|
8
|
-
import type {
|
9
|
-
Transaction,
|
10
|
-
TransactionReceipt,
|
11
|
-
TransactionRequest,
|
12
|
-
} from './transaction.js'
|
1
|
+
import type { Chain } from './chain.js'
|
13
2
|
|
14
|
-
export type Formatter<
|
15
|
-
|
16
|
-
|
3
|
+
export type Formatter<TType extends string = string> = {
|
4
|
+
format: (args: any) => any
|
5
|
+
type: TType
|
6
|
+
}
|
17
7
|
|
18
8
|
export type Formatters = {
|
19
|
-
block?: Formatter<
|
20
|
-
transaction?: Formatter<
|
21
|
-
transactionReceipt?: Formatter<
|
22
|
-
transactionRequest?: Formatter<
|
9
|
+
block?: Formatter<'block'>
|
10
|
+
transaction?: Formatter<'transaction'>
|
11
|
+
transactionReceipt?: Formatter<'transactionReceipt'>
|
12
|
+
transactionRequest?: Formatter<'transactionRequest'>
|
23
13
|
}
|
14
|
+
|
15
|
+
export type ExtractFormatterParameters<
|
16
|
+
TChain extends Chain | undefined,
|
17
|
+
TType extends keyof Formatters,
|
18
|
+
TFallback,
|
19
|
+
> = TChain extends Chain<infer _Formatters extends Formatters>
|
20
|
+
? _Formatters[TType] extends Formatter
|
21
|
+
? Parameters<_Formatters[TType]['format']>[0]
|
22
|
+
: TFallback
|
23
|
+
: TFallback
|
24
|
+
|
25
|
+
export type ExtractFormatterReturnType<
|
26
|
+
TChain extends Chain | undefined,
|
27
|
+
TType extends keyof Formatters,
|
28
|
+
TFallback,
|
29
|
+
> = TChain extends Chain<infer _Formatters extends Formatters>
|
30
|
+
? _Formatters[TType] extends Formatter
|
31
|
+
? ReturnType<_Formatters[TType]['format']>
|
32
|
+
: TFallback
|
33
|
+
: TFallback
|
package/src/types/rpc.ts
CHANGED
@@ -12,7 +12,7 @@ import type {
|
|
12
12
|
export type Index = `0x${string}`
|
13
13
|
export type Quantity = `0x${string}`
|
14
14
|
export type Status = '0x0' | '0x1'
|
15
|
-
export type TransactionType = '0x0' | '0x1' | '0x2'
|
15
|
+
export type TransactionType = '0x0' | '0x1' | '0x2' | (string & {})
|
16
16
|
|
17
17
|
export type RpcBlock = Block<Quantity, RpcTransaction>
|
18
18
|
export type RpcBlockNumber = BlockNumber<Quantity>
|