viem 0.0.0-main.20230809T141837 → 0.0.0-main.20230810T034510
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/utils/package.json +5 -0
- package/dist/cjs/actions/public/estimateGas.js +3 -1
- package/dist/cjs/actions/public/estimateGas.js.map +1 -1
- package/dist/cjs/actions/wallet/sendTransaction.js.map +1 -1
- package/dist/cjs/actions/wallet/writeContract.js.map +1 -1
- package/dist/cjs/chains/celo/formatters.js.map +1 -1
- package/dist/cjs/chains/celo/serializers.js.map +1 -1
- package/dist/cjs/chains/index.js +19 -4
- package/dist/cjs/chains/index.js.map +1 -1
- package/dist/cjs/chains/optimism/fees.js +7 -0
- package/dist/cjs/chains/optimism/fees.js.map +1 -0
- package/dist/cjs/chains/optimism/formatters.js.map +1 -1
- package/dist/cjs/chains/utils.js +11 -0
- package/dist/cjs/chains/utils.js.map +1 -0
- package/dist/cjs/errors/version.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/chain.js +5 -3
- package/dist/cjs/utils/chain.js.map +1 -1
- package/dist/cjs/utils/formatters/block.js.map +1 -1
- package/dist/cjs/utils/formatters/extract.js.map +1 -1
- package/dist/cjs/utils/formatters/transaction.js.map +1 -1
- package/dist/cjs/utils/formatters/transactionReceipt.js.map +1 -1
- package/dist/cjs/utils/formatters/transactionRequest.js.map +1 -1
- package/dist/cjs/utils/transaction/prepareRequest.js +15 -6
- package/dist/cjs/utils/transaction/prepareRequest.js.map +1 -1
- package/dist/esm/actions/public/estimateGas.js +4 -2
- package/dist/esm/actions/public/estimateGas.js.map +1 -1
- package/dist/esm/actions/wallet/sendTransaction.js +1 -1
- package/dist/esm/actions/wallet/sendTransaction.js.map +1 -1
- package/dist/esm/actions/wallet/writeContract.js.map +1 -1
- package/dist/esm/chains/celo/formatters.js +1 -1
- package/dist/esm/chains/celo/formatters.js.map +1 -1
- package/dist/esm/chains/celo/serializers.js.map +1 -1
- package/dist/esm/chains/index.js +19 -4
- package/dist/esm/chains/index.js.map +1 -1
- package/dist/esm/chains/optimism/fees.js +4 -0
- package/dist/esm/chains/optimism/fees.js.map +1 -0
- package/dist/esm/chains/optimism/formatters.js +1 -1
- package/dist/esm/chains/optimism/formatters.js.map +1 -1
- package/dist/esm/chains/utils.js +4 -0
- package/dist/esm/chains/utils.js.map +1 -0
- package/dist/esm/errors/version.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/chain.js +5 -3
- package/dist/esm/utils/chain.js.map +1 -1
- package/dist/esm/utils/formatters/block.js.map +1 -1
- package/dist/esm/utils/formatters/extract.js.map +1 -1
- package/dist/esm/utils/formatters/transaction.js.map +1 -1
- package/dist/esm/utils/formatters/transactionReceipt.js.map +1 -1
- package/dist/esm/utils/formatters/transactionRequest.js.map +1 -1
- package/dist/esm/utils/transaction/prepareRequest.js +14 -5
- package/dist/esm/utils/transaction/prepareRequest.js.map +1 -1
- package/dist/types/actions/public/estimateGas.d.ts.map +1 -1
- package/dist/types/actions/public/getTransactionReceipt.d.ts +1 -1
- package/dist/types/actions/public/getTransactionReceipt.d.ts.map +1 -1
- package/dist/types/actions/public/simulateContract.d.ts +2 -2
- package/dist/types/actions/public/simulateContract.d.ts.map +1 -1
- package/dist/types/actions/wallet/deployContract.d.ts +1 -1
- package/dist/types/actions/wallet/deployContract.d.ts.map +1 -1
- package/dist/types/actions/wallet/sendTransaction.d.ts +2 -2
- package/dist/types/actions/wallet/sendTransaction.d.ts.map +1 -1
- package/dist/types/actions/wallet/writeContract.d.ts +4 -2
- package/dist/types/actions/wallet/writeContract.d.ts.map +1 -1
- package/dist/types/chains/celo/formatters.d.ts.map +1 -1
- package/dist/types/chains/celo/serializers.d.ts.map +1 -1
- package/dist/types/chains/index.d.ts +2527 -2798
- package/dist/types/chains/index.d.ts.map +1 -1
- package/dist/types/chains/optimism/fees.d.ts +4 -0
- package/dist/types/chains/optimism/fees.d.ts.map +1 -0
- package/dist/types/chains/optimism/formatters.d.ts.map +1 -1
- package/dist/types/chains/utils.d.ts +6 -0
- package/dist/types/chains/utils.d.ts.map +1 -0
- package/dist/types/clients/decorators/public.d.ts +1 -1
- package/dist/types/clients/decorators/public.d.ts.map +1 -1
- package/dist/types/errors/version.d.ts +1 -1
- package/dist/types/index.d.ts +13 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/chain.d.ts +52 -8
- package/dist/types/types/chain.d.ts.map +1 -1
- package/dist/types/utils/chain.d.ts +3 -6
- package/dist/types/utils/chain.d.ts.map +1 -1
- package/dist/types/utils/formatters/block.d.ts +6 -2
- 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/transaction.d.ts +7 -3
- package/dist/types/utils/formatters/transaction.d.ts.map +1 -1
- package/dist/types/utils/formatters/transactionReceipt.d.ts +2 -3
- package/dist/types/utils/formatters/transactionReceipt.d.ts.map +1 -1
- package/dist/types/utils/formatters/transactionRequest.d.ts +3 -4
- package/dist/types/utils/formatters/transactionRequest.d.ts.map +1 -1
- package/dist/types/utils/transaction/prepareRequest.d.ts +6 -11
- package/dist/types/utils/transaction/prepareRequest.d.ts.map +1 -1
- package/package.json +6 -12
- package/src/actions/public/estimateGas.ts +11 -2
- package/src/actions/public/simulateContract.ts +2 -2
- package/src/actions/wallet/deployContract.ts +1 -1
- package/src/actions/wallet/sendTransaction.ts +9 -6
- package/src/actions/wallet/writeContract.ts +11 -7
- package/src/chains/celo/formatters.ts +2 -2
- package/src/chains/celo/serializers.ts +2 -2
- package/src/chains/index.ts +19 -4
- package/src/chains/optimism/fees.ts +5 -0
- package/src/chains/optimism/formatters.ts +2 -2
- package/src/chains/{celo/index.ts → utils.ts} +19 -7
- package/src/clients/decorators/public.ts +3 -3
- package/src/errors/version.ts +1 -1
- package/src/index.ts +24 -8
- package/src/types/chain.ts +91 -14
- package/src/utils/chain.ts +21 -10
- package/src/utils/formatters/block.ts +8 -6
- package/src/utils/formatters/extract.ts +2 -2
- package/src/utils/formatters/transaction.ts +8 -6
- package/src/utils/formatters/transactionReceipt.ts +9 -3
- package/src/utils/formatters/transactionRequest.ts +9 -3
- package/src/utils/transaction/prepareRequest.ts +48 -22
- package/chains/celo/package.json +0 -5
- package/chains/optimism/package.json +0 -5
- package/dist/cjs/chains/celo/index.js +0 -13
- package/dist/cjs/chains/celo/index.js.map +0 -1
- package/dist/cjs/chains/optimism/index.js +0 -13
- package/dist/cjs/chains/optimism/index.js.map +0 -1
- package/dist/cjs/types/formatter.js +0 -3
- package/dist/cjs/types/formatter.js.map +0 -1
- package/dist/cjs/types/serializer.js +0 -3
- package/dist/cjs/types/serializer.js.map +0 -1
- package/dist/esm/chains/celo/index.js +0 -4
- package/dist/esm/chains/celo/index.js.map +0 -1
- package/dist/esm/chains/optimism/index.js +0 -3
- package/dist/esm/chains/optimism/index.js.map +0 -1
- package/dist/esm/types/formatter.js +0 -2
- package/dist/esm/types/formatter.js.map +0 -1
- package/dist/esm/types/serializer.js +0 -2
- package/dist/esm/types/serializer.js.map +0 -1
- package/dist/types/chains/celo/index.d.ts +0 -5
- package/dist/types/chains/celo/index.d.ts.map +0 -1
- package/dist/types/chains/optimism/index.d.ts +0 -4
- package/dist/types/chains/optimism/index.d.ts.map +0 -1
- package/dist/types/types/formatter.d.ts +0 -17
- package/dist/types/types/formatter.d.ts.map +0 -1
- package/dist/types/types/serializer.d.ts +0 -7
- package/dist/types/types/serializer.d.ts.map +0 -1
- package/src/chains/optimism/index.ts +0 -25
- package/src/types/formatter.ts +0 -42
- package/src/types/serializer.ts +0 -19
@@ -20,7 +20,10 @@ import {
|
|
20
20
|
type AssertRequestParameters,
|
21
21
|
assertRequest,
|
22
22
|
} from '../../utils/transaction/assertRequest.js'
|
23
|
-
import {
|
23
|
+
import {
|
24
|
+
type PrepareRequestParameters,
|
25
|
+
prepareRequest,
|
26
|
+
} from '../../utils/transaction/prepareRequest.js'
|
24
27
|
|
25
28
|
export type FormattedEstimateGas<
|
26
29
|
TChain extends Chain | undefined = Chain | undefined,
|
@@ -102,7 +105,13 @@ export async function estimateGas<
|
|
102
105
|
to,
|
103
106
|
value,
|
104
107
|
...rest
|
105
|
-
} =
|
108
|
+
} =
|
109
|
+
account.type === 'local'
|
110
|
+
? ((await prepareRequest(
|
111
|
+
client,
|
112
|
+
args as PrepareRequestParameters,
|
113
|
+
)) as EstimateGasParameters)
|
114
|
+
: args
|
106
115
|
|
107
116
|
const blockNumberHex = blockNumber ? numberToHex(blockNumber) : undefined
|
108
117
|
const block = blockNumberHex || blockTag
|
@@ -29,7 +29,7 @@ export type SimulateContractParameters<
|
|
29
29
|
TAbi extends Abi | readonly unknown[] = Abi,
|
30
30
|
TFunctionName extends string = any,
|
31
31
|
TChain extends Chain | undefined = Chain | undefined,
|
32
|
-
TChainOverride extends Chain | undefined = undefined,
|
32
|
+
TChainOverride extends Chain | undefined = Chain | undefined,
|
33
33
|
> = {
|
34
34
|
chain?: TChainOverride
|
35
35
|
/** Data to append to the end of the calldata. Useful for adding a ["domain" tag](https://opensea.notion.site/opensea/Seaport-Order-Attributions-ec2d69bf455041a5baa490941aad307f). */
|
@@ -51,7 +51,7 @@ export type SimulateContractReturnType<
|
|
51
51
|
TAbi extends Abi | readonly unknown[] = Abi,
|
52
52
|
TFunctionName extends string = string,
|
53
53
|
TChain extends Chain | undefined = Chain | undefined,
|
54
|
-
TChainOverride extends Chain | undefined = undefined,
|
54
|
+
TChainOverride extends Chain | undefined = Chain | undefined,
|
55
55
|
> = {
|
56
56
|
result: ContractFunctionResult<TAbi, TFunctionName>
|
57
57
|
request: UnionOmit<
|
@@ -19,7 +19,7 @@ export type DeployContractParameters<
|
|
19
19
|
TAbi extends Abi | readonly unknown[] = Abi,
|
20
20
|
TChain extends Chain | undefined = Chain | undefined,
|
21
21
|
TAccount extends Account | undefined = Account | undefined,
|
22
|
-
TChainOverride extends Chain | undefined = undefined,
|
22
|
+
TChainOverride extends Chain | undefined = Chain | undefined,
|
23
23
|
> = UnionOmit<
|
24
24
|
SendTransactionParameters<TChain, TAccount, TChainOverride>,
|
25
25
|
'accessList' | 'chain' | 'to' | 'data'
|
@@ -11,7 +11,7 @@ import type {
|
|
11
11
|
TransactionRequest,
|
12
12
|
TransactionSerializable,
|
13
13
|
} from '../../types/transaction.js'
|
14
|
-
import type {
|
14
|
+
import type { UnionOmit } from '../../types/utils.js'
|
15
15
|
import { assertCurrentChain } from '../../utils/chain.js'
|
16
16
|
import { getTransactionError } from '../../utils/errors/getTransactionError.js'
|
17
17
|
import { extract } from '../../utils/formatters/extract.js'
|
@@ -19,17 +19,20 @@ import {
|
|
19
19
|
type FormattedTransactionRequest,
|
20
20
|
formatTransactionRequest,
|
21
21
|
} from '../../utils/formatters/transactionRequest.js'
|
22
|
-
import {
|
22
|
+
import {
|
23
|
+
type AssertRequestParameters,
|
24
|
+
assertRequest,
|
25
|
+
} from '../../utils/transaction/assertRequest.js'
|
23
26
|
import { prepareRequest } from '../../utils/transaction/prepareRequest.js'
|
24
27
|
import { getChainId } from '../public/getChainId.js'
|
25
28
|
|
26
29
|
export type SendTransactionParameters<
|
27
30
|
TChain extends Chain | undefined = Chain | undefined,
|
28
31
|
TAccount extends Account | undefined = Account | undefined,
|
29
|
-
TChainOverride extends Chain | undefined = Chain,
|
32
|
+
TChainOverride extends Chain | undefined = Chain | undefined,
|
30
33
|
> = UnionOmit<
|
31
34
|
FormattedTransactionRequest<
|
32
|
-
|
35
|
+
TChainOverride extends Chain ? TChainOverride : TChain
|
33
36
|
>,
|
34
37
|
'from'
|
35
38
|
> &
|
@@ -113,7 +116,7 @@ export async function sendTransaction<
|
|
113
116
|
const account = parseAccount(account_)
|
114
117
|
|
115
118
|
try {
|
116
|
-
assertRequest(args)
|
119
|
+
assertRequest(args as AssertRequestParameters)
|
117
120
|
|
118
121
|
let chainId
|
119
122
|
if (chain !== null) {
|
@@ -139,7 +142,7 @@ export async function sendTransaction<
|
|
139
142
|
to,
|
140
143
|
value,
|
141
144
|
...rest,
|
142
|
-
})
|
145
|
+
} as any)
|
143
146
|
|
144
147
|
if (!chainId) chainId = await getChainId(client)
|
145
148
|
|
@@ -3,6 +3,7 @@ import type { Abi } from 'abitype'
|
|
3
3
|
import type { Account } from '../../accounts/types.js'
|
4
4
|
import type { Client } from '../../clients/createClient.js'
|
5
5
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
6
|
+
import type { GetAccountParameter } from '../../types/account.js'
|
6
7
|
import type { Chain, GetChain } from '../../types/chain.js'
|
7
8
|
import type { ContractFunctionConfig, GetValue } from '../../types/contract.js'
|
8
9
|
import type { Hex } from '../../types/misc.js'
|
@@ -11,7 +12,7 @@ import {
|
|
11
12
|
type EncodeFunctionDataParameters,
|
12
13
|
encodeFunctionData,
|
13
14
|
} from '../../utils/abi/encodeFunctionData.js'
|
14
|
-
|
15
|
+
import type { FormattedTransactionRequest } from '../../utils/formatters/transactionRequest.js'
|
15
16
|
import {
|
16
17
|
type SendTransactionParameters,
|
17
18
|
type SendTransactionReturnType,
|
@@ -22,14 +23,17 @@ export type WriteContractParameters<
|
|
22
23
|
TAbi extends Abi | readonly unknown[] = Abi,
|
23
24
|
TFunctionName extends string = string,
|
24
25
|
TChain extends Chain | undefined = Chain,
|
25
|
-
TAccount extends Account | undefined = undefined,
|
26
|
-
TChainOverride extends Chain | undefined = undefined,
|
26
|
+
TAccount extends Account | undefined = Account | undefined,
|
27
|
+
TChainOverride extends Chain | undefined = Chain | undefined,
|
27
28
|
> = ContractFunctionConfig<TAbi, TFunctionName, 'payable' | 'nonpayable'> &
|
29
|
+
GetAccountParameter<TAccount> &
|
30
|
+
GetChain<TChain, TChainOverride> &
|
28
31
|
UnionOmit<
|
29
|
-
|
30
|
-
|
32
|
+
FormattedTransactionRequest<
|
33
|
+
TChainOverride extends Chain ? TChainOverride : TChain
|
34
|
+
>,
|
35
|
+
'from' | 'to' | 'data' | 'value'
|
31
36
|
> &
|
32
|
-
GetChain<TChain, TChainOverride> &
|
33
37
|
GetValue<
|
34
38
|
TAbi,
|
35
39
|
TFunctionName,
|
@@ -102,7 +106,7 @@ export async function writeContract<
|
|
102
106
|
TAccount extends Account | undefined,
|
103
107
|
TAbi extends Abi | readonly unknown[],
|
104
108
|
TFunctionName extends string,
|
105
|
-
TChainOverride extends Chain | undefined
|
109
|
+
TChainOverride extends Chain | undefined,
|
106
110
|
>(
|
107
111
|
client: Client<Transport, TChain, TAccount>,
|
108
112
|
{
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { type
|
1
|
+
import { type ChainFormatters } from '../../types/chain.js'
|
2
2
|
import type { Hash } from '../../types/misc.js'
|
3
3
|
import { hexToBigInt } from '../../utils/encoding/fromHex.js'
|
4
4
|
import { numberToHex } from '../../utils/encoding/toHex.js'
|
@@ -82,4 +82,4 @@ export const formattersCelo = {
|
|
82
82
|
}
|
83
83
|
},
|
84
84
|
}),
|
85
|
-
} as const satisfies
|
85
|
+
} as const satisfies ChainFormatters
|
@@ -4,9 +4,9 @@ import { InvalidAddressError } from '../../errors/address.js'
|
|
4
4
|
import { BaseError } from '../../errors/base.js'
|
5
5
|
import { InvalidChainIdError } from '../../errors/chain.js'
|
6
6
|
import { FeeCapTooHighError, TipAboveFeeCapError } from '../../errors/node.js'
|
7
|
+
import type { ChainSerializers } from '../../types/chain.js'
|
7
8
|
import type { FeeValuesEIP1559 } from '../../types/fee.js'
|
8
9
|
import type { Signature } from '../../types/misc.js'
|
9
|
-
import type { Serializers } from '../../types/serializer.js'
|
10
10
|
import type {
|
11
11
|
AccessList,
|
12
12
|
TransactionSerializable,
|
@@ -39,7 +39,7 @@ export const serializeTransactionCelo: SerializeTransactionFn<
|
|
39
39
|
|
40
40
|
export const serializersCelo = {
|
41
41
|
transaction: serializeTransactionCelo,
|
42
|
-
} as const satisfies
|
42
|
+
} as const satisfies ChainSerializers
|
43
43
|
|
44
44
|
//////////////////////////////////////////////////////////////////////////////
|
45
45
|
// Types
|
package/src/chains/index.ts
CHANGED
@@ -3,6 +3,7 @@ import * as chains from '@wagmi/chains'
|
|
3
3
|
import { defineChain } from '../utils/chain.js'
|
4
4
|
import { formattersCelo } from './celo/formatters.js'
|
5
5
|
import { serializersCelo } from './celo/serializers.js'
|
6
|
+
import { feesOptimism } from './optimism/fees.js'
|
6
7
|
import { formattersOptimism } from './optimism/formatters.js'
|
7
8
|
|
8
9
|
export const arbitrum = /*#__PURE__*/ defineChain(chains.arbitrum)
|
@@ -11,8 +12,14 @@ export const aurora = /*#__PURE__*/ defineChain(chains.aurora)
|
|
11
12
|
export const auroraTestnet = /*#__PURE__*/ defineChain(chains.auroraTestnet)
|
12
13
|
export const avalanche = /*#__PURE__*/ defineChain(chains.avalanche)
|
13
14
|
export const avalancheFuji = /*#__PURE__*/ defineChain(chains.avalancheFuji)
|
14
|
-
export const base = /*#__PURE__*/ defineChain(chains.base
|
15
|
-
|
15
|
+
export const base = /*#__PURE__*/ defineChain(chains.base, {
|
16
|
+
fees: feesOptimism,
|
17
|
+
formatters: formattersOptimism,
|
18
|
+
})
|
19
|
+
export const baseGoerli = /*#__PURE__*/ defineChain(chains.baseGoerli, {
|
20
|
+
fees: feesOptimism,
|
21
|
+
formatters: formattersOptimism,
|
22
|
+
})
|
16
23
|
export const boba = /*#__PURE__*/ defineChain(chains.boba)
|
17
24
|
export const bronos = /*#__PURE__*/ defineChain(chains.bronos)
|
18
25
|
export const bronosTestnet = /*#__PURE__*/ defineChain(chains.bronosTestnet)
|
@@ -72,9 +79,11 @@ export const moonriver = /*#__PURE__*/ defineChain(chains.moonriver)
|
|
72
79
|
export const nexi = /*#__PURE__*/ defineChain(chains.nexi)
|
73
80
|
export const okc = /*#__PURE__*/ defineChain(chains.okc)
|
74
81
|
export const optimism = /*#__PURE__*/ defineChain(chains.optimism, {
|
82
|
+
fees: feesOptimism,
|
75
83
|
formatters: formattersOptimism,
|
76
84
|
})
|
77
85
|
export const optimismGoerli = /*#__PURE__*/ defineChain(chains.optimismGoerli, {
|
86
|
+
fees: feesOptimism,
|
78
87
|
formatters: formattersOptimism,
|
79
88
|
})
|
80
89
|
export const polygon = /*#__PURE__*/ defineChain(chains.polygon)
|
@@ -136,7 +145,13 @@ export const xdcTestnet = /*#__PURE__*/ defineChain(chains.xdcTestnet)
|
|
136
145
|
export const zhejiang = /*#__PURE__*/ defineChain(chains.zhejiang)
|
137
146
|
export const zkSync = /*#__PURE__*/ defineChain(chains.zkSync)
|
138
147
|
export const zkSyncTestnet = /*#__PURE__*/ defineChain(chains.zkSyncTestnet)
|
139
|
-
export const zora = /*#__PURE__*/ defineChain(chains.zora
|
140
|
-
|
148
|
+
export const zora = /*#__PURE__*/ defineChain(chains.zora, {
|
149
|
+
fees: feesOptimism,
|
150
|
+
formatters: formattersOptimism,
|
151
|
+
})
|
152
|
+
export const zoraTestnet = /*#__PURE__*/ defineChain(chains.zoraTestnet, {
|
153
|
+
fees: feesOptimism,
|
154
|
+
formatters: formattersOptimism,
|
155
|
+
})
|
141
156
|
|
142
157
|
export type { Chain } from '../types/chain.js'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { type
|
1
|
+
import { type ChainFormatters } from '../../types/chain.js'
|
2
2
|
import type { Hash } from '../../types/misc.js'
|
3
3
|
import { type RpcTransaction } from '../../types/rpc.js'
|
4
4
|
import { hexToBigInt } from '../../utils/encoding/fromHex.js'
|
@@ -71,4 +71,4 @@ export const formattersOptimism = {
|
|
71
71
|
}
|
72
72
|
},
|
73
73
|
}),
|
74
|
-
} as const satisfies
|
74
|
+
} as const satisfies ChainFormatters
|
@@ -1,14 +1,10 @@
|
|
1
|
-
export {
|
2
|
-
|
3
|
-
export { formattersCelo } from './formatters.js'
|
4
|
-
|
1
|
+
export { formattersCelo } from './celo/formatters.js'
|
5
2
|
export {
|
6
3
|
type CeloTransactionSerializable,
|
7
4
|
type TransactionSerializableCIP42,
|
8
5
|
serializeTransactionCelo,
|
9
6
|
serializersCelo,
|
10
|
-
} from './serializers.js'
|
11
|
-
|
7
|
+
} from './celo/serializers.js'
|
12
8
|
export type {
|
13
9
|
CeloBlock,
|
14
10
|
CeloBlockOverrides,
|
@@ -26,4 +22,20 @@ export type {
|
|
26
22
|
CeloTransactionReceiptOverrides,
|
27
23
|
CeloTransactionRequest,
|
28
24
|
CeloTransactionRequestOverrides,
|
29
|
-
} from './types.js'
|
25
|
+
} from './celo/types.js'
|
26
|
+
|
27
|
+
export { formattersOptimism } from './optimism/formatters.js'
|
28
|
+
export type {
|
29
|
+
OptimismBlock,
|
30
|
+
OptimismBlockOverrides,
|
31
|
+
OptimismDepositTransaction,
|
32
|
+
OptimismRpcBlock,
|
33
|
+
OptimismRpcBlockOverrides,
|
34
|
+
OptimismRpcDepositTransaction,
|
35
|
+
OptimismRpcTransaction,
|
36
|
+
OptimismRpcTransactionReceipt,
|
37
|
+
OptimismRpcTransactionReceiptOverrides,
|
38
|
+
OptimismTransaction,
|
39
|
+
OptimismTransactionReceipt,
|
40
|
+
OptimismTransactionReceiptOverrides,
|
41
|
+
} from './optimism/types.js'
|
@@ -1206,9 +1206,9 @@ export type PublicActions<
|
|
1206
1206
|
* })
|
1207
1207
|
*/
|
1208
1208
|
simulateContract: <
|
1209
|
-
TAbi extends Abi | readonly unknown[]
|
1210
|
-
TFunctionName extends string
|
1211
|
-
TChainOverride extends Chain | undefined
|
1209
|
+
TAbi extends Abi | readonly unknown[],
|
1210
|
+
TFunctionName extends string,
|
1211
|
+
TChainOverride extends Chain | undefined,
|
1212
1212
|
>(
|
1213
1213
|
args: SimulateContractParameters<
|
1214
1214
|
TAbi,
|
package/src/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '0.0.0-main.
|
1
|
+
export const version = '0.0.0-main.20230810T034510'
|
package/src/index.ts
CHANGED
@@ -571,7 +571,30 @@ export type {
|
|
571
571
|
Signature,
|
572
572
|
SignableMessage,
|
573
573
|
} from './types/misc.js'
|
574
|
-
export type {
|
574
|
+
export type {
|
575
|
+
Chain,
|
576
|
+
ChainContract,
|
577
|
+
ChainFees,
|
578
|
+
ChainFormatter,
|
579
|
+
/** @deprecated use `ChainFormatter` instead. */
|
580
|
+
ChainFormatter as Formatter,
|
581
|
+
ChainFormatters,
|
582
|
+
/** @deprecated use `ChainFormatters` instead. */
|
583
|
+
ChainFormatters as Formatters,
|
584
|
+
ChainSerializers,
|
585
|
+
/** @deprecated use `ChainSerializers` instead. */
|
586
|
+
ChainSerializers as Serializers,
|
587
|
+
ExtractChainFormatterExclude,
|
588
|
+
/** @deprecated use `ExtractChainFormatterExclude` instead. */
|
589
|
+
ExtractChainFormatterExclude as ExtractFormatterExclude,
|
590
|
+
ExtractChainFormatterParameters,
|
591
|
+
/** @deprecated use `ExtractChainFormatterParameters` instead. */
|
592
|
+
ExtractChainFormatterParameters as ExtractFormatterParameters,
|
593
|
+
ExtractChainFormatterReturnType,
|
594
|
+
/** @deprecated use `ExtractChainFormatterReturnType` instead. */
|
595
|
+
ExtractChainFormatterReturnType as ExtractFormatterReturnType,
|
596
|
+
GetChain,
|
597
|
+
} from './types/chain.js'
|
575
598
|
export type {
|
576
599
|
AddEthereumChainParameter,
|
577
600
|
EIP1193Events,
|
@@ -599,13 +622,6 @@ export type {
|
|
599
622
|
FeeValuesLegacy,
|
600
623
|
} from './types/fee.js'
|
601
624
|
export type { Filter } from './types/filter.js'
|
602
|
-
export type {
|
603
|
-
Formatter,
|
604
|
-
Formatters,
|
605
|
-
ExtractFormatterParameters,
|
606
|
-
ExtractFormatterReturnType,
|
607
|
-
} from './types/formatter.js'
|
608
|
-
export type { Serializers } from './types/serializer.js'
|
609
625
|
export type {
|
610
626
|
GetTypedDataDomain,
|
611
627
|
GetTypedDataMessage,
|
package/src/types/chain.ts
CHANGED
@@ -1,17 +1,24 @@
|
|
1
1
|
import type { Address } from 'abitype'
|
2
2
|
|
3
|
-
import type {
|
4
|
-
import type {
|
5
|
-
import type {
|
3
|
+
import type { FormattedBlock } from '../utils/formatters/block.js'
|
4
|
+
import type { PrepareRequestParameters } from '../utils/transaction/prepareRequest.js'
|
5
|
+
import type { SerializeTransactionFn } from '../utils/transaction/serializeTransaction.js'
|
6
|
+
import type {
|
7
|
+
TransactionSerializable,
|
8
|
+
TransactionSerializableGeneric,
|
9
|
+
} from './transaction.js'
|
10
|
+
import type { IsUndefined, Prettify } from './utils.js'
|
6
11
|
|
7
12
|
export type Chain<
|
8
|
-
formatters extends
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
+
formatters extends ChainFormatters | undefined = ChainFormatters | undefined,
|
14
|
+
> = import('@wagmi/chains').Chain & ChainConfig<formatters>
|
15
|
+
|
16
|
+
export type ChainConfig<
|
17
|
+
formatters extends ChainFormatters | undefined = ChainFormatters | undefined,
|
18
|
+
> = {
|
13
19
|
formatters?: formatters | undefined
|
14
|
-
serializers?:
|
20
|
+
serializers?: ChainSerializers<formatters> | undefined
|
21
|
+
fees?: ChainFees<formatters> | undefined
|
15
22
|
}
|
16
23
|
|
17
24
|
export type ChainContract = {
|
@@ -19,9 +26,79 @@ export type ChainContract = {
|
|
19
26
|
blockCreated?: number
|
20
27
|
}
|
21
28
|
|
29
|
+
export type ChainFees<
|
30
|
+
formatters extends ChainFormatters | undefined = ChainFormatters | undefined,
|
31
|
+
> = {
|
32
|
+
defaultPriorityFee:
|
33
|
+
| bigint
|
34
|
+
| ((args: {
|
35
|
+
block: Prettify<FormattedBlock<{ formatters: formatters }>>
|
36
|
+
request: PrepareRequestParameters<
|
37
|
+
Omit<Chain, 'formatters'> & { formatters: formatters }
|
38
|
+
>
|
39
|
+
}) => Promise<bigint> | bigint)
|
40
|
+
}
|
41
|
+
|
42
|
+
export type ChainFormatters = {
|
43
|
+
block?: ChainFormatter<'block'>
|
44
|
+
transaction?: ChainFormatter<'transaction'>
|
45
|
+
transactionReceipt?: ChainFormatter<'transactionReceipt'>
|
46
|
+
transactionRequest?: ChainFormatter<'transactionRequest'>
|
47
|
+
}
|
48
|
+
|
49
|
+
export type ChainFormatter<type extends string = string> = {
|
50
|
+
format: (args: any) => any
|
51
|
+
type: type
|
52
|
+
}
|
53
|
+
|
54
|
+
export type ChainSerializers<
|
55
|
+
formatters extends ChainFormatters | undefined = undefined,
|
56
|
+
> = {
|
57
|
+
transaction?: SerializeTransactionFn<
|
58
|
+
formatters extends ChainFormatters
|
59
|
+
? formatters['transactionRequest'] extends ChainFormatter
|
60
|
+
? TransactionSerializableGeneric &
|
61
|
+
Parameters<formatters['transactionRequest']['format']>[0]
|
62
|
+
: TransactionSerializable
|
63
|
+
: TransactionSerializable
|
64
|
+
>
|
65
|
+
}
|
66
|
+
|
67
|
+
/////////////////////////////////////////////////////////////////////
|
68
|
+
// Utils
|
69
|
+
|
70
|
+
export type ExtractChainFormatterExclude<
|
71
|
+
chain extends { formatters?: Chain['formatters'] } | undefined,
|
72
|
+
type extends keyof ChainFormatters,
|
73
|
+
> = chain extends { formatters?: infer _Formatters extends ChainFormatters }
|
74
|
+
? _Formatters[type] extends { exclude: infer Exclude }
|
75
|
+
? Extract<Exclude, string[]>[number]
|
76
|
+
: ''
|
77
|
+
: ''
|
78
|
+
|
79
|
+
export type ExtractChainFormatterParameters<
|
80
|
+
chain extends { formatters?: Chain['formatters'] } | undefined,
|
81
|
+
type extends keyof ChainFormatters,
|
82
|
+
fallback,
|
83
|
+
> = chain extends { formatters?: infer _Formatters extends ChainFormatters }
|
84
|
+
? _Formatters[type] extends ChainFormatter
|
85
|
+
? Parameters<_Formatters[type]['format']>[0]
|
86
|
+
: fallback
|
87
|
+
: fallback
|
88
|
+
|
89
|
+
export type ExtractChainFormatterReturnType<
|
90
|
+
chain extends { formatters?: Chain['formatters'] } | undefined,
|
91
|
+
type extends keyof ChainFormatters,
|
92
|
+
fallback,
|
93
|
+
> = chain extends { formatters?: infer _Formatters extends ChainFormatters }
|
94
|
+
? _Formatters[type] extends ChainFormatter
|
95
|
+
? ReturnType<_Formatters[type]['format']>
|
96
|
+
: fallback
|
97
|
+
: fallback
|
98
|
+
|
22
99
|
export type GetChain<
|
23
|
-
|
24
|
-
|
25
|
-
> = IsUndefined<
|
26
|
-
? { chain:
|
27
|
-
: { chain?:
|
100
|
+
chain extends Chain | undefined,
|
101
|
+
chainOverride extends Chain | undefined = undefined,
|
102
|
+
> = IsUndefined<chain> extends true
|
103
|
+
? { chain: chainOverride | null }
|
104
|
+
: { chain?: chainOverride | null }
|
package/src/utils/chain.ts
CHANGED
@@ -3,8 +3,13 @@ import {
|
|
3
3
|
ChainMismatchError,
|
4
4
|
ChainNotFoundError,
|
5
5
|
} from '../errors/chain.js'
|
6
|
-
import type {
|
7
|
-
|
6
|
+
import type {
|
7
|
+
Chain,
|
8
|
+
ChainConfig,
|
9
|
+
ChainContract,
|
10
|
+
ChainFormatters,
|
11
|
+
} from '../types/chain.js'
|
12
|
+
import type { Assign } from '../types/utils.js'
|
8
13
|
|
9
14
|
export type AssertCurrentChainParameters = {
|
10
15
|
chain?: Chain
|
@@ -21,17 +26,23 @@ export function assertCurrentChain({
|
|
21
26
|
}
|
22
27
|
|
23
28
|
export function defineChain<
|
24
|
-
|
25
|
-
|
29
|
+
chain extends Chain,
|
30
|
+
formatters extends ChainFormatters,
|
26
31
|
>(
|
27
|
-
chain:
|
28
|
-
config
|
29
|
-
) {
|
32
|
+
chain: chain,
|
33
|
+
config: ChainConfig<formatters> = {},
|
34
|
+
): Assign<chain, ChainConfig<formatters>> {
|
35
|
+
const {
|
36
|
+
fees = chain.fees,
|
37
|
+
formatters = chain.formatters,
|
38
|
+
serializers = chain.serializers,
|
39
|
+
} = config
|
30
40
|
return {
|
31
41
|
...chain,
|
32
|
-
|
33
|
-
|
34
|
-
|
42
|
+
fees,
|
43
|
+
formatters,
|
44
|
+
serializers,
|
45
|
+
} as unknown as Assign<chain, ChainConfig<formatters>>
|
35
46
|
}
|
36
47
|
|
37
48
|
export function getChainContractAddress({
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import type { Block, BlockTag } from '../../types/block.js'
|
2
2
|
import type { Chain } from '../../types/chain.js'
|
3
3
|
import type {
|
4
|
-
|
5
|
-
|
6
|
-
} from '../../types/
|
4
|
+
ExtractChainFormatterExclude,
|
5
|
+
ExtractChainFormatterReturnType,
|
6
|
+
} from '../../types/chain.js'
|
7
7
|
import type { Hash } from '../../types/misc.js'
|
8
8
|
import type { RpcBlock } from '../../types/rpc.js'
|
9
9
|
import type { Prettify } from '../../types/utils.js'
|
@@ -14,16 +14,18 @@ import { type FormattedTransaction, formatTransaction } from './transaction.js'
|
|
14
14
|
type BlockPendingDependencies = 'hash' | 'logsBloom' | 'nonce' | 'number'
|
15
15
|
|
16
16
|
export type FormattedBlock<
|
17
|
-
TChain extends Chain | undefined =
|
17
|
+
TChain extends { formatters?: Chain['formatters'] } | undefined =
|
18
|
+
| { formatters?: Chain['formatters'] }
|
19
|
+
| undefined,
|
18
20
|
TIncludeTransactions extends boolean = boolean,
|
19
21
|
TBlockTag extends BlockTag = BlockTag,
|
20
|
-
_FormatterReturnType =
|
22
|
+
_FormatterReturnType = ExtractChainFormatterReturnType<
|
21
23
|
TChain,
|
22
24
|
'block',
|
23
25
|
Block<bigint, TIncludeTransactions>
|
24
26
|
>,
|
25
27
|
_ExcludedPendingDependencies extends string = BlockPendingDependencies &
|
26
|
-
|
28
|
+
ExtractChainFormatterExclude<TChain, 'block'>,
|
27
29
|
_Formatted = Omit<_FormatterReturnType, BlockPendingDependencies> & {
|
28
30
|
[K in _ExcludedPendingDependencies]: never
|
29
31
|
} & Pick<
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import type {
|
1
|
+
import type { ChainFormatter } from '../../types/chain.js'
|
2
2
|
|
3
3
|
/**
|
4
4
|
* @description Picks out the keys from `value` that exist in the formatter.
|
5
5
|
*/
|
6
6
|
export function extract(
|
7
7
|
value: Record<string, unknown>,
|
8
|
-
{ format }: { format?:
|
8
|
+
{ format }: { format?: ChainFormatter['format'] },
|
9
9
|
) {
|
10
10
|
if (!format) return {}
|
11
11
|
const keys = Object.keys(format({}))
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import type { BlockTag } from '../../types/block.js'
|
2
2
|
import type { Chain } from '../../types/chain.js'
|
3
3
|
import type {
|
4
|
-
|
5
|
-
|
6
|
-
} from '../../types/
|
4
|
+
ExtractChainFormatterExclude,
|
5
|
+
ExtractChainFormatterReturnType,
|
6
|
+
} from '../../types/chain.js'
|
7
7
|
import type { RpcTransaction } from '../../types/rpc.js'
|
8
8
|
import type { Transaction } from '../../types/transaction.js'
|
9
9
|
import type { UnionOmit } from '../../types/utils.js'
|
@@ -16,15 +16,17 @@ type TransactionPendingDependencies =
|
|
16
16
|
| 'transactionIndex'
|
17
17
|
|
18
18
|
export type FormattedTransaction<
|
19
|
-
TChain extends Chain | undefined =
|
19
|
+
TChain extends { formatters?: Chain['formatters'] } | undefined =
|
20
|
+
| { formatters?: Chain['formatters'] }
|
21
|
+
| undefined,
|
20
22
|
TBlockTag extends BlockTag = BlockTag,
|
21
|
-
_FormatterReturnType =
|
23
|
+
_FormatterReturnType = ExtractChainFormatterReturnType<
|
22
24
|
TChain,
|
23
25
|
'transaction',
|
24
26
|
Transaction
|
25
27
|
>,
|
26
28
|
_ExcludedPendingDependencies extends string = TransactionPendingDependencies &
|
27
|
-
|
29
|
+
ExtractChainFormatterExclude<TChain, 'transaction'>,
|
28
30
|
> = UnionOmit<_FormatterReturnType, TransactionPendingDependencies> & {
|
29
31
|
[K in _ExcludedPendingDependencies]: never
|
30
32
|
} & Pick<
|
@@ -1,5 +1,7 @@
|
|
1
|
-
import type {
|
2
|
-
|
1
|
+
import type {
|
2
|
+
Chain,
|
3
|
+
ExtractChainFormatterReturnType,
|
4
|
+
} from '../../types/chain.js'
|
3
5
|
import type { RpcTransactionReceipt } from '../../types/rpc.js'
|
4
6
|
import type { TransactionReceipt } from '../../types/transaction.js'
|
5
7
|
import { hexToNumber } from '../encoding/fromHex.js'
|
@@ -10,7 +12,11 @@ import { transactionType } from './transaction.js'
|
|
10
12
|
|
11
13
|
export type FormattedTransactionReceipt<
|
12
14
|
TChain extends Chain | undefined = Chain | undefined,
|
13
|
-
> =
|
15
|
+
> = ExtractChainFormatterReturnType<
|
16
|
+
TChain,
|
17
|
+
'transactionReceipt',
|
18
|
+
TransactionReceipt
|
19
|
+
>
|
14
20
|
|
15
21
|
const statuses = {
|
16
22
|
'0x0': 'reverted',
|