viem 0.0.0-w-20230810183250 → 0.0.0-w-20230816150015
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/dist/cjs/actions/getContract.js.map +1 -1
- package/dist/cjs/actions/public/multicall.js +3 -4
- package/dist/cjs/actions/public/multicall.js.map +1 -1
- package/dist/cjs/actions/public/readContract.js +2 -1
- package/dist/cjs/actions/public/readContract.js.map +1 -1
- package/dist/cjs/actions/wallet/writeContract.js +2 -1
- package/dist/cjs/actions/wallet/writeContract.js.map +1 -1
- package/dist/cjs/chains/index.js +2 -1
- package/dist/cjs/chains/index.js.map +1 -1
- package/dist/cjs/clients/decorators/public.js.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/abi/decodeAbiParameters.js.map +1 -1
- package/dist/cjs/utils/abi/decodeDeployData.js.map +1 -1
- package/dist/cjs/utils/abi/decodeErrorResult.js.map +1 -1
- package/dist/cjs/utils/abi/decodeFunctionResult.js.map +1 -1
- package/dist/cjs/utils/abi/encodeAbiParameters.js.map +1 -1
- package/dist/cjs/utils/abi/encodeDeployData.js.map +1 -1
- package/dist/cjs/utils/abi/encodeEventTopics.js.map +1 -1
- package/dist/cjs/utils/abi/encodePacked.js.map +1 -1
- package/dist/cjs/utils/poll.js +1 -1
- package/dist/cjs/utils/poll.js.map +1 -1
- package/dist/cjs/utils/typedData.js +2 -2
- package/dist/cjs/utils/typedData.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/actions/getContract.js.map +1 -1
- package/dist/esm/actions/public/multicall.js +3 -5
- package/dist/esm/actions/public/multicall.js.map +1 -1
- package/dist/esm/actions/public/readContract.js +2 -1
- package/dist/esm/actions/public/readContract.js.map +1 -1
- package/dist/esm/actions/wallet/writeContract.js +2 -1
- package/dist/esm/actions/wallet/writeContract.js.map +1 -1
- package/dist/esm/chains/index.js +1 -0
- package/dist/esm/chains/index.js.map +1 -1
- package/dist/esm/clients/decorators/public.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/abi/decodeAbiParameters.js.map +1 -1
- package/dist/esm/utils/abi/decodeDeployData.js.map +1 -1
- package/dist/esm/utils/abi/decodeErrorResult.js.map +1 -1
- package/dist/esm/utils/abi/decodeFunctionResult.js.map +1 -1
- package/dist/esm/utils/abi/encodeAbiParameters.js.map +1 -1
- package/dist/esm/utils/abi/encodeDeployData.js.map +1 -1
- package/dist/esm/utils/abi/encodeEventTopics.js.map +1 -1
- package/dist/esm/utils/abi/encodePacked.js.map +1 -1
- package/dist/esm/utils/poll.js +1 -1
- package/dist/esm/utils/poll.js.map +1 -1
- package/dist/esm/utils/typedData.js +2 -2
- package/dist/esm/utils/typedData.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/actions/getContract.d.ts +5 -5
- package/dist/types/actions/getContract.d.ts.map +1 -1
- package/dist/types/actions/public/createContractEventFilter.d.ts +3 -3
- package/dist/types/actions/public/createContractEventFilter.d.ts.map +1 -1
- package/dist/types/actions/public/createEventFilter.d.ts +5 -5
- package/dist/types/actions/public/createEventFilter.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/getFilterChanges.d.ts +1 -1
- package/dist/types/actions/public/getFilterChanges.d.ts.map +1 -1
- package/dist/types/actions/public/getFilterLogs.d.ts +1 -1
- package/dist/types/actions/public/getFilterLogs.d.ts.map +1 -1
- package/dist/types/actions/public/getLogs.d.ts +4 -4
- package/dist/types/actions/public/getLogs.d.ts.map +1 -1
- package/dist/types/actions/public/multicall.d.ts +14 -11
- package/dist/types/actions/public/multicall.d.ts.map +1 -1
- package/dist/types/actions/public/readContract.d.ts +4 -4
- package/dist/types/actions/public/readContract.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/watchContractEvent.d.ts +3 -3
- package/dist/types/actions/public/watchContractEvent.d.ts.map +1 -1
- package/dist/types/actions/public/watchEvent.d.ts +4 -4
- package/dist/types/actions/public/watchEvent.d.ts.map +1 -1
- package/dist/types/actions/wallet/deployContract.d.ts +3 -3
- package/dist/types/actions/wallet/deployContract.d.ts.map +1 -1
- package/dist/types/actions/wallet/writeContract.d.ts +4 -4
- package/dist/types/actions/wallet/writeContract.d.ts.map +1 -1
- package/dist/types/chains/index.d.ts +154 -36
- package/dist/types/chains/index.d.ts.map +1 -1
- package/dist/types/clients/decorators/public.d.ts +11 -11
- package/dist/types/clients/decorators/public.d.ts.map +1 -1
- package/dist/types/clients/decorators/wallet.d.ts +3 -3
- package/dist/types/clients/decorators/wallet.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/contract.d.ts +13 -2
- package/dist/types/types/contract.d.ts.map +1 -1
- package/dist/types/types/multicall.d.ts +35 -35
- package/dist/types/types/multicall.d.ts.map +1 -1
- package/dist/types/types/typedData.d.ts +1 -1
- package/dist/types/types/typedData.d.ts.map +1 -1
- package/dist/types/utils/abi/decodeAbiParameters.d.ts +2 -2
- package/dist/types/utils/abi/decodeAbiParameters.d.ts.map +1 -1
- package/dist/types/utils/abi/decodeDeployData.d.ts +3 -3
- package/dist/types/utils/abi/decodeDeployData.d.ts.map +1 -1
- package/dist/types/utils/abi/decodeErrorResult.d.ts +3 -3
- package/dist/types/utils/abi/decodeErrorResult.d.ts.map +1 -1
- package/dist/types/utils/abi/decodeEventLog.d.ts +3 -3
- package/dist/types/utils/abi/decodeEventLog.d.ts.map +1 -1
- package/dist/types/utils/abi/decodeFunctionResult.d.ts +4 -4
- package/dist/types/utils/abi/decodeFunctionResult.d.ts.map +1 -1
- package/dist/types/utils/abi/encodeAbiParameters.d.ts +2 -2
- package/dist/types/utils/abi/encodeAbiParameters.d.ts.map +1 -1
- package/dist/types/utils/abi/encodeDeployData.d.ts +3 -3
- package/dist/types/utils/abi/encodeDeployData.d.ts.map +1 -1
- package/dist/types/utils/abi/encodeErrorResult.d.ts +4 -4
- package/dist/types/utils/abi/encodeErrorResult.d.ts.map +1 -1
- package/dist/types/utils/abi/encodeEventTopics.d.ts +4 -4
- package/dist/types/utils/abi/encodeEventTopics.d.ts.map +1 -1
- package/dist/types/utils/abi/encodeFunctionData.d.ts +4 -4
- package/dist/types/utils/abi/encodeFunctionData.d.ts.map +1 -1
- package/dist/types/utils/abi/encodeFunctionResult.d.ts +4 -4
- package/dist/types/utils/abi/encodeFunctionResult.d.ts.map +1 -1
- package/dist/types/utils/abi/encodePacked.d.ts +3 -3
- package/dist/types/utils/abi/encodePacked.d.ts.map +1 -1
- package/dist/types/utils/abi/getAbiItem.d.ts +3 -3
- package/dist/types/utils/abi/getAbiItem.d.ts.map +1 -1
- package/dist/types/utils/typedData.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/actions/getContract.ts +6 -5
- package/src/actions/public/createContractEventFilter.ts +3 -3
- package/src/actions/public/createEventFilter.ts +6 -6
- package/src/actions/public/estimateContractGas.ts +1 -1
- package/src/actions/public/getFilterChanges.ts +1 -1
- package/src/actions/public/getFilterLogs.ts +1 -1
- package/src/actions/public/getLogs.ts +5 -5
- package/src/actions/public/multicall.ts +41 -27
- package/src/actions/public/readContract.ts +19 -21
- package/src/actions/public/simulateContract.ts +1 -1
- package/src/actions/public/watchContractEvent.ts +3 -3
- package/src/actions/public/watchEvent.ts +5 -5
- package/src/actions/wallet/deployContract.ts +3 -3
- package/src/actions/wallet/writeContract.ts +35 -37
- package/src/chains/index.ts +1 -0
- package/src/clients/decorators/public.ts +20 -15
- package/src/clients/decorators/wallet.ts +3 -3
- package/src/index.ts +3 -0
- package/src/types/contract.ts +56 -2
- package/src/types/multicall.ts +84 -75
- package/src/types/typedData.ts +2 -1
- package/src/utils/abi/decodeAbiParameters.ts +7 -8
- package/src/utils/abi/decodeDeployData.ts +3 -3
- package/src/utils/abi/decodeErrorResult.ts +3 -8
- package/src/utils/abi/decodeEventLog.ts +3 -3
- package/src/utils/abi/decodeFunctionResult.ts +4 -6
- package/src/utils/abi/encodeAbiParameters.ts +8 -9
- package/src/utils/abi/encodeDeployData.ts +3 -3
- package/src/utils/abi/encodeErrorResult.ts +4 -4
- package/src/utils/abi/encodeEventTopics.ts +4 -9
- package/src/utils/abi/encodeFunctionData.ts +4 -4
- package/src/utils/abi/encodeFunctionResult.ts +4 -4
- package/src/utils/abi/encodePacked.ts +6 -8
- package/src/utils/abi/getAbiItem.ts +3 -3
- package/src/utils/poll.ts +1 -1
- package/src/utils/typedData.ts +1 -2
- package/src/version.ts +1 -1
@@ -1,12 +1,12 @@
|
|
1
|
-
import type { Abi } from 'abitype'
|
1
|
+
import type { Abi, ExtractAbiFunctionNames } from 'abitype'
|
2
2
|
|
3
3
|
import type { Client } from '../../clients/createClient.js'
|
4
4
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
5
5
|
import type { BaseError } from '../../errors/base.js'
|
6
6
|
import type { Chain } from '../../types/chain.js'
|
7
7
|
import type {
|
8
|
-
ContractFunctionConfig,
|
9
8
|
ContractFunctionResult,
|
9
|
+
ContractParameters,
|
10
10
|
} from '../../types/contract.js'
|
11
11
|
import {
|
12
12
|
type DecodeFunctionResultParameters,
|
@@ -21,10 +21,13 @@ import { getContractError } from '../../utils/errors/getContractError.js'
|
|
21
21
|
import { type CallParameters, call } from './call.js'
|
22
22
|
|
23
23
|
export type ReadContractParameters<
|
24
|
-
|
25
|
-
|
24
|
+
abi extends Abi | readonly unknown[] = Abi,
|
25
|
+
functionName extends ExtractAbiFunctionNames<
|
26
|
+
abi extends Abi ? abi : Abi,
|
27
|
+
'view' | 'pure'
|
28
|
+
> = string,
|
26
29
|
> = Pick<CallParameters, 'account' | 'blockNumber' | 'blockTag'> &
|
27
|
-
|
30
|
+
ContractParameters<abi, 'view' | 'pure', functionName>
|
28
31
|
|
29
32
|
export type ReadContractReturnType<
|
30
33
|
TAbi extends Abi | readonly unknown[] = Abi,
|
@@ -63,24 +66,19 @@ export type ReadContractReturnType<
|
|
63
66
|
* // 424122n
|
64
67
|
*/
|
65
68
|
export async function readContract<
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
+
chain extends Chain | undefined,
|
70
|
+
const abi extends Abi | readonly unknown[],
|
71
|
+
functionName extends string,
|
69
72
|
>(
|
70
|
-
client: Client<Transport,
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
args,
|
75
|
-
functionName,
|
76
|
-
...callRequest
|
77
|
-
}: ReadContractParameters<TAbi, TFunctionName>,
|
78
|
-
): Promise<ReadContractReturnType<TAbi, TFunctionName>> {
|
73
|
+
client: Client<Transport, chain>,
|
74
|
+
parameters: ReadContractParameters<abi, functionName>,
|
75
|
+
): Promise<ReadContractReturnType<abi, functionName>> {
|
76
|
+
const { abi, address, args, functionName, ...callRequest } = parameters
|
79
77
|
const calldata = encodeFunctionData({
|
80
78
|
abi,
|
81
79
|
args,
|
82
80
|
functionName,
|
83
|
-
} as unknown as EncodeFunctionDataParameters<
|
81
|
+
} as unknown as EncodeFunctionDataParameters<abi, functionName>)
|
84
82
|
try {
|
85
83
|
const { data } = await call(client, {
|
86
84
|
data: calldata,
|
@@ -93,9 +91,9 @@ export async function readContract<
|
|
93
91
|
functionName,
|
94
92
|
data: data || '0x',
|
95
93
|
} as DecodeFunctionResultParameters<
|
96
|
-
|
97
|
-
|
98
|
-
>) as ReadContractReturnType<
|
94
|
+
abi,
|
95
|
+
functionName
|
96
|
+
>) as ReadContractReturnType<abi, functionName>
|
99
97
|
} catch (err) {
|
100
98
|
throw getContractError(err as BaseError, {
|
101
99
|
abi: abi as Abi,
|
@@ -102,7 +102,7 @@ export type SimulateContractReturnType<
|
|
102
102
|
*/
|
103
103
|
export async function simulateContract<
|
104
104
|
TChain extends Chain | undefined,
|
105
|
-
TAbi extends Abi | readonly unknown[],
|
105
|
+
const TAbi extends Abi | readonly unknown[],
|
106
106
|
TFunctionName extends string,
|
107
107
|
TChainOverride extends Chain | undefined,
|
108
108
|
>(
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { Abi, AbiEvent, Address, ExtractAbiEvent
|
1
|
+
import type { Abi, AbiEvent, Address, ExtractAbiEvent } from 'abitype'
|
2
2
|
|
3
3
|
import type { Client } from '../../clients/createClient.js'
|
4
4
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
@@ -68,7 +68,7 @@ export type WatchContractEventParameters<
|
|
68
68
|
/** The address of the contract. */
|
69
69
|
address?: Address | Address[]
|
70
70
|
/** Contract ABI. */
|
71
|
-
abi:
|
71
|
+
abi: TAbi
|
72
72
|
args?: GetEventArgs<TAbi, TEventName>
|
73
73
|
/** Contract event. */
|
74
74
|
eventName?: InferEventName<TAbi, TEventName>
|
@@ -137,7 +137,7 @@ export type WatchContractEventReturnType = () => void
|
|
137
137
|
*/
|
138
138
|
export function watchContractEvent<
|
139
139
|
TChain extends Chain | undefined,
|
140
|
-
TAbi extends Abi | readonly unknown[],
|
140
|
+
const TAbi extends Abi | readonly unknown[],
|
141
141
|
TEventName extends string,
|
142
142
|
TStrict extends boolean | undefined = undefined,
|
143
143
|
>(
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { Abi, AbiEvent, Address
|
1
|
+
import type { Abi, AbiEvent, Address } from 'abitype'
|
2
2
|
|
3
3
|
import type { Client } from '../../clients/createClient.js'
|
4
4
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
@@ -107,7 +107,7 @@ export type WatchEventParameters<
|
|
107
107
|
}) &
|
108
108
|
(
|
109
109
|
| {
|
110
|
-
event:
|
110
|
+
event: TAbiEvent
|
111
111
|
events?: never
|
112
112
|
args?: MaybeExtractEventArgsFromAbi<TAbiEvents, _EventName>
|
113
113
|
/**
|
@@ -118,7 +118,7 @@ export type WatchEventParameters<
|
|
118
118
|
}
|
119
119
|
| {
|
120
120
|
event?: never
|
121
|
-
events?:
|
121
|
+
events?: TAbiEvents
|
122
122
|
args?: never
|
123
123
|
/**
|
124
124
|
* Whether or not the logs must match the indexed/non-indexed arguments on `event`.
|
@@ -170,8 +170,8 @@ export type WatchEventReturnType = () => void
|
|
170
170
|
*/
|
171
171
|
export function watchEvent<
|
172
172
|
TChain extends Chain | undefined,
|
173
|
-
TAbiEvent extends AbiEvent | undefined = undefined,
|
174
|
-
TAbiEvents extends
|
173
|
+
const TAbiEvent extends AbiEvent | undefined = undefined,
|
174
|
+
const TAbiEvents extends
|
175
175
|
| readonly AbiEvent[]
|
176
176
|
| readonly unknown[]
|
177
177
|
| undefined = TAbiEvent extends AbiEvent ? [TAbiEvent] : undefined,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { Abi
|
1
|
+
import type { Abi } from 'abitype'
|
2
2
|
|
3
3
|
import type { Account } from '../../accounts/types.js'
|
4
4
|
import type { Client } from '../../clients/createClient.js'
|
@@ -24,7 +24,7 @@ export type DeployContractParameters<
|
|
24
24
|
SendTransactionParameters<TChain, TAccount, TChainOverride>,
|
25
25
|
'accessList' | 'chain' | 'to' | 'data'
|
26
26
|
> & {
|
27
|
-
abi:
|
27
|
+
abi: TAbi
|
28
28
|
bytecode: Hex
|
29
29
|
} & GetChain<TChain, TChainOverride> &
|
30
30
|
GetConstructorArgs<TAbi>
|
@@ -59,7 +59,7 @@ export type DeployContractReturnType = SendTransactionReturnType
|
|
59
59
|
* })
|
60
60
|
*/
|
61
61
|
export function deployContract<
|
62
|
-
TAbi extends Abi | readonly unknown[],
|
62
|
+
const TAbi extends Abi | readonly unknown[],
|
63
63
|
TChain extends Chain | undefined,
|
64
64
|
TAccount extends Account | undefined,
|
65
65
|
TChainOverride extends Chain | undefined,
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import type { Abi } from 'abitype'
|
1
|
+
import type { Abi, ExtractAbiFunctionNames } from 'abitype'
|
2
2
|
|
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
6
|
import type { GetAccountParameter } from '../../types/account.js'
|
7
7
|
import type { Chain, GetChain } from '../../types/chain.js'
|
8
|
-
import type {
|
8
|
+
import type { ContractParameters, GetValue } from '../../types/contract.js'
|
9
9
|
import type { Hex } from '../../types/misc.js'
|
10
10
|
import type { UnionOmit } from '../../types/utils.js'
|
11
11
|
import {
|
@@ -20,29 +20,32 @@ import {
|
|
20
20
|
} from './sendTransaction.js'
|
21
21
|
|
22
22
|
export type WriteContractParameters<
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
abi extends Abi | readonly unknown[] = Abi,
|
24
|
+
functionName extends ExtractAbiFunctionNames<
|
25
|
+
abi extends Abi ? abi : Abi,
|
26
|
+
'payable' | 'nonpayable'
|
27
|
+
> = string,
|
28
|
+
chain extends Chain | undefined = Chain,
|
29
|
+
account extends Account | undefined = Account | undefined,
|
30
|
+
chainOverride extends Chain | undefined = Chain | undefined,
|
31
|
+
> = ContractParameters<abi, 'payable' | 'nonpayable', functionName> &
|
31
32
|
UnionOmit<
|
32
33
|
FormattedTransactionRequest<
|
33
|
-
|
34
|
+
chainOverride extends Chain ? chainOverride : chain
|
34
35
|
>,
|
35
|
-
'
|
36
|
+
'data' | 'from' | 'to' | 'value'
|
36
37
|
> &
|
38
|
+
GetAccountParameter<account> &
|
39
|
+
GetChain<chain, chainOverride> &
|
37
40
|
GetValue<
|
38
|
-
|
39
|
-
|
41
|
+
abi,
|
42
|
+
functionName,
|
40
43
|
SendTransactionParameters<
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
+
chain,
|
45
|
+
account,
|
46
|
+
chainOverride
|
44
47
|
> extends SendTransactionParameters
|
45
|
-
? SendTransactionParameters<
|
48
|
+
? SendTransactionParameters<chain, account, chainOverride>['value']
|
46
49
|
: SendTransactionParameters['value']
|
47
50
|
> & {
|
48
51
|
/** Data to append to the end of the calldata. Useful for adding a ["domain" tag](https://opensea.notion.site/opensea/Seaport-Order-Attributions-ec2d69bf455041a5baa490941aad307f). */
|
@@ -102,37 +105,32 @@ export type WriteContractReturnType = SendTransactionReturnType
|
|
102
105
|
* const hash = await writeContract(client, request)
|
103
106
|
*/
|
104
107
|
export async function writeContract<
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
108
|
+
chain extends Chain | undefined,
|
109
|
+
account extends Account | undefined,
|
110
|
+
const abi extends Abi | readonly unknown[],
|
111
|
+
functionName extends string,
|
112
|
+
chainOverride extends Chain | undefined,
|
110
113
|
>(
|
111
|
-
client: Client<Transport,
|
112
|
-
|
114
|
+
client: Client<Transport, chain, account>,
|
115
|
+
parameters: WriteContractParameters<
|
113
116
|
abi,
|
114
|
-
address,
|
115
|
-
args,
|
116
|
-
dataSuffix,
|
117
117
|
functionName,
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
TFunctionName,
|
122
|
-
TChain,
|
123
|
-
TAccount,
|
124
|
-
TChainOverride
|
118
|
+
chain,
|
119
|
+
account,
|
120
|
+
chainOverride
|
125
121
|
>,
|
126
122
|
): Promise<WriteContractReturnType> {
|
123
|
+
const { abi, address, args, dataSuffix, functionName, ...request } =
|
124
|
+
parameters
|
127
125
|
const data = encodeFunctionData({
|
128
126
|
abi,
|
129
127
|
args,
|
130
128
|
functionName,
|
131
|
-
} as unknown as EncodeFunctionDataParameters<
|
129
|
+
} as unknown as EncodeFunctionDataParameters<abi, functionName>)
|
132
130
|
const hash = await sendTransaction(client, {
|
133
131
|
data: `${data}${dataSuffix ? dataSuffix.replace('0x', '') : ''}`,
|
134
132
|
to: address,
|
135
133
|
...request,
|
136
|
-
} as unknown as SendTransactionParameters<
|
134
|
+
} as unknown as SendTransactionParameters<chain, account, chainOverride>)
|
137
135
|
return hash
|
138
136
|
}
|
package/src/chains/index.ts
CHANGED
@@ -94,6 +94,7 @@ export const polygonZkEvmTestnet = /*#__PURE__*/ defineChain(
|
|
94
94
|
)
|
95
95
|
export const pulsechain = /*#__PURE__*/ defineChain(chains.pulsechain)
|
96
96
|
export const pulsechainV4 = /*#__PURE__*/ defineChain(chains.pulsechainV4)
|
97
|
+
export const scrollSepolia = /*#__PURE__*/ defineChain(chains.scrollSepolia)
|
97
98
|
export const scrollTestnet = /*#__PURE__*/ defineChain(chains.scrollTestnet)
|
98
99
|
export const sepolia = /*#__PURE__*/ defineChain(chains.sepolia)
|
99
100
|
export const skaleBlockBrawlers = /*#__PURE__*/ defineChain(
|
@@ -278,7 +278,7 @@ export type PublicActions<
|
|
278
278
|
* })
|
279
279
|
*/
|
280
280
|
createContractEventFilter: <
|
281
|
-
TAbi extends Abi | readonly unknown[],
|
281
|
+
const TAbi extends Abi | readonly unknown[],
|
282
282
|
TEventName extends string | undefined,
|
283
283
|
TArgs extends MaybeExtractEventArgsFromAbi<TAbi, TEventName> | undefined,
|
284
284
|
TStrict extends boolean | undefined = undefined,
|
@@ -325,8 +325,8 @@ export type PublicActions<
|
|
325
325
|
* })
|
326
326
|
*/
|
327
327
|
createEventFilter: <
|
328
|
-
TAbiEvent extends AbiEvent | undefined = undefined,
|
329
|
-
TAbiEvents extends
|
328
|
+
const TAbiEvent extends AbiEvent | undefined = undefined,
|
329
|
+
const TAbiEvents extends
|
330
330
|
| readonly AbiEvent[]
|
331
331
|
| readonly unknown[]
|
332
332
|
| undefined = TAbiEvent extends AbiEvent ? [TAbiEvent] : undefined,
|
@@ -406,7 +406,7 @@ export type PublicActions<
|
|
406
406
|
*/
|
407
407
|
estimateContractGas: <
|
408
408
|
TChain extends Chain | undefined,
|
409
|
-
TAbi extends Abi | readonly unknown[],
|
409
|
+
const TAbi extends Abi | readonly unknown[],
|
410
410
|
TFunctionName extends string,
|
411
411
|
>(
|
412
412
|
args: EstimateContractGasParameters<TAbi, TFunctionName, TChain, TAccount>,
|
@@ -844,7 +844,7 @@ export type PublicActions<
|
|
844
844
|
*/
|
845
845
|
getFilterChanges: <
|
846
846
|
TFilterType extends FilterType,
|
847
|
-
TAbi extends Abi | readonly unknown[] | undefined,
|
847
|
+
const TAbi extends Abi | readonly unknown[] | undefined,
|
848
848
|
TEventName extends string | undefined,
|
849
849
|
TStrict extends boolean | undefined = undefined,
|
850
850
|
TFromBlock extends BlockNumber | BlockTag | undefined = undefined,
|
@@ -895,7 +895,7 @@ export type PublicActions<
|
|
895
895
|
* const logs = await client.getFilterLogs({ filter })
|
896
896
|
*/
|
897
897
|
getFilterLogs: <
|
898
|
-
TAbi extends Abi | readonly unknown[] | undefined,
|
898
|
+
const TAbi extends Abi | readonly unknown[] | undefined,
|
899
899
|
TEventName extends string | undefined,
|
900
900
|
TStrict extends boolean | undefined = undefined,
|
901
901
|
TFromBlock extends BlockNumber | BlockTag | undefined = undefined,
|
@@ -951,8 +951,8 @@ export type PublicActions<
|
|
951
951
|
* const logs = await client.getLogs()
|
952
952
|
*/
|
953
953
|
getLogs: <
|
954
|
-
TAbiEvent extends AbiEvent | undefined = undefined,
|
955
|
-
TAbiEvents extends
|
954
|
+
const TAbiEvent extends AbiEvent | undefined = undefined,
|
955
|
+
const TAbiEvents extends
|
956
956
|
| readonly AbiEvent[]
|
957
957
|
| readonly unknown[]
|
958
958
|
| undefined = TAbiEvent extends AbiEvent ? [TAbiEvent] : undefined,
|
@@ -1133,7 +1133,12 @@ export type PublicActions<
|
|
1133
1133
|
* // [{ result: 424122n, status: 'success' }, { result: 1000000n, status: 'success' }]
|
1134
1134
|
*/
|
1135
1135
|
multicall: <
|
1136
|
-
|
1136
|
+
const TAbi extends Abi | readonly unknown[],
|
1137
|
+
TFunctionName extends string,
|
1138
|
+
const TContracts extends readonly ContractFunctionConfig<
|
1139
|
+
TAbi,
|
1140
|
+
TFunctionName
|
1141
|
+
>[],
|
1137
1142
|
TAllowFailure extends boolean = true,
|
1138
1143
|
>(
|
1139
1144
|
args: MulticallParameters<TContracts, TAllowFailure>,
|
@@ -1170,7 +1175,7 @@ export type PublicActions<
|
|
1170
1175
|
* // 424122n
|
1171
1176
|
*/
|
1172
1177
|
readContract: <
|
1173
|
-
TAbi extends Abi | readonly unknown[],
|
1178
|
+
const TAbi extends Abi | readonly unknown[],
|
1174
1179
|
TFunctionName extends string,
|
1175
1180
|
>(
|
1176
1181
|
args: ReadContractParameters<TAbi, TFunctionName>,
|
@@ -1206,7 +1211,7 @@ export type PublicActions<
|
|
1206
1211
|
* })
|
1207
1212
|
*/
|
1208
1213
|
simulateContract: <
|
1209
|
-
TAbi extends Abi | readonly unknown[],
|
1214
|
+
const TAbi extends Abi | readonly unknown[],
|
1210
1215
|
TFunctionName extends string,
|
1211
1216
|
TChainOverride extends Chain | undefined,
|
1212
1217
|
>(
|
@@ -1383,7 +1388,7 @@ export type PublicActions<
|
|
1383
1388
|
* })
|
1384
1389
|
*/
|
1385
1390
|
watchContractEvent: <
|
1386
|
-
TAbi extends Abi | readonly unknown[],
|
1391
|
+
const TAbi extends Abi | readonly unknown[],
|
1387
1392
|
TEventName extends string,
|
1388
1393
|
TStrict extends boolean | undefined = undefined,
|
1389
1394
|
>(
|
@@ -1421,8 +1426,8 @@ export type PublicActions<
|
|
1421
1426
|
* })
|
1422
1427
|
*/
|
1423
1428
|
watchEvent: <
|
1424
|
-
TAbiEvent extends AbiEvent | undefined = undefined,
|
1425
|
-
TAbiEvents extends
|
1429
|
+
const TAbiEvent extends AbiEvent | undefined = undefined,
|
1430
|
+
const TAbiEvents extends
|
1426
1431
|
| readonly AbiEvent[]
|
1427
1432
|
| readonly unknown[]
|
1428
1433
|
| undefined = TAbiEvent extends AbiEvent ? [TAbiEvent] : undefined,
|
@@ -1502,7 +1507,7 @@ export function publicActions<
|
|
1502
1507
|
getTransactionConfirmations(client, args),
|
1503
1508
|
getTransactionCount: (args) => getTransactionCount(client, args),
|
1504
1509
|
getTransactionReceipt: (args) => getTransactionReceipt(client, args),
|
1505
|
-
multicall: (args) => multicall(client, args),
|
1510
|
+
multicall: (args) => multicall(client, args as any) as any,
|
1506
1511
|
readContract: (args) => readContract(client, args),
|
1507
1512
|
simulateContract: (args) => simulateContract(client, args),
|
1508
1513
|
verifyMessage: (args) => verifyMessage(client, args),
|
@@ -112,7 +112,7 @@ export type WalletActions<
|
|
112
112
|
* })
|
113
113
|
*/
|
114
114
|
deployContract: <
|
115
|
-
TAbi extends Abi | readonly unknown[],
|
115
|
+
const TAbi extends Abi | readonly unknown[],
|
116
116
|
TChainOverride extends Chain | undefined,
|
117
117
|
>(
|
118
118
|
args: DeployContractParameters<TAbi, TChain, TAccount, TChainOverride>,
|
@@ -410,7 +410,7 @@ export type WalletActions<
|
|
410
410
|
* })
|
411
411
|
*/
|
412
412
|
signTypedData: <
|
413
|
-
TTypedData extends TypedData | { [key: string]: unknown },
|
413
|
+
const TTypedData extends TypedData | { [key: string]: unknown },
|
414
414
|
TPrimaryType extends string,
|
415
415
|
>(
|
416
416
|
args: SignTypedDataParameters<TTypedData, TPrimaryType, TAccount>,
|
@@ -509,7 +509,7 @@ export type WalletActions<
|
|
509
509
|
* const hash = await client.writeContract(request)
|
510
510
|
*/
|
511
511
|
writeContract: <
|
512
|
-
TAbi extends Abi | readonly unknown[],
|
512
|
+
const TAbi extends Abi | readonly unknown[],
|
513
513
|
TFunctionName extends string,
|
514
514
|
TChainOverride extends Chain | undefined,
|
515
515
|
>(
|
package/src/index.ts
CHANGED
@@ -514,6 +514,8 @@ export { SizeExceedsPaddingSizeError } from './errors/data.js'
|
|
514
514
|
export { UrlRequiredError } from './errors/transport.js'
|
515
515
|
export type {
|
516
516
|
AbiItem,
|
517
|
+
ContractParameters,
|
518
|
+
ContractReturnType,
|
517
519
|
ContractFunctionConfig,
|
518
520
|
ContractFunctionResult,
|
519
521
|
GetConstructorArgs,
|
@@ -633,6 +635,7 @@ export type { GetTransportConfig } from './types/transport.js'
|
|
633
635
|
export type { HDKey } from '@scure/bip32'
|
634
636
|
export type { Log } from './types/log.js'
|
635
637
|
export type {
|
638
|
+
MulticallContract,
|
636
639
|
MulticallContracts,
|
637
640
|
MulticallResult,
|
638
641
|
MulticallResults,
|
package/src/types/contract.ts
CHANGED
@@ -15,7 +15,6 @@ import type {
|
|
15
15
|
ExtractAbiEventNames,
|
16
16
|
ExtractAbiFunction,
|
17
17
|
ExtractAbiFunctionNames,
|
18
|
-
Narrow,
|
19
18
|
} from 'abitype'
|
20
19
|
|
21
20
|
import type { Hex, LogTopic } from './misc.js'
|
@@ -32,13 +31,68 @@ export type AbiItem = Abi[number]
|
|
32
31
|
|
33
32
|
export type EventDefinition = `${string}(${string})`
|
34
33
|
|
34
|
+
export type ContractParameters<
|
35
|
+
abi extends Abi | readonly unknown[] = readonly unknown[],
|
36
|
+
stateMutability extends AbiStateMutability = AbiStateMutability,
|
37
|
+
functionName extends ExtractAbiFunctionNames<
|
38
|
+
abi extends Abi ? abi : Abi,
|
39
|
+
stateMutability
|
40
|
+
> = string,
|
41
|
+
///
|
42
|
+
functionNames extends string = abi extends Abi
|
43
|
+
? ExtractAbiFunctionNames<abi, stateMutability>
|
44
|
+
: string,
|
45
|
+
abiFunction extends AbiFunction = abi extends Abi
|
46
|
+
? ExtractAbiFunction<abi, functionName, stateMutability>
|
47
|
+
: AbiFunction,
|
48
|
+
types = AbiParametersToPrimitiveTypes<abiFunction['inputs'], 'inputs'>,
|
49
|
+
args =
|
50
|
+
| types // show all values
|
51
|
+
| (Abi extends abi ? readonly unknown[] | undefined : never) // `abi` declared as `Abi`
|
52
|
+
| (readonly [] extends types ? undefined : never), // `abiFunction` has no inputs
|
53
|
+
isArgsOptional extends boolean = Abi extends abi
|
54
|
+
? true
|
55
|
+
: readonly [] extends types
|
56
|
+
? true
|
57
|
+
: false,
|
58
|
+
> = {
|
59
|
+
abi: abi
|
60
|
+
address: Address
|
61
|
+
functionName:
|
62
|
+
| functionNames // show all values
|
63
|
+
| (functionName extends functionNames ? functionName : never) // validate `functionName`
|
64
|
+
| ([functionNames] extends [never] ? string : never) // `abi` declared as `Abi`
|
65
|
+
} & (isArgsOptional extends true ? { args?: args | undefined } : { args: args })
|
66
|
+
|
67
|
+
export type ContractReturnType<
|
68
|
+
abi extends Abi | readonly unknown[] = readonly unknown[],
|
69
|
+
stateMutability extends AbiStateMutability = AbiStateMutability,
|
70
|
+
functionName extends ExtractAbiFunctionNames<
|
71
|
+
abi extends Abi ? abi : Abi,
|
72
|
+
stateMutability
|
73
|
+
> = string,
|
74
|
+
///
|
75
|
+
abiFunction extends AbiFunction = abi extends Abi
|
76
|
+
? ExtractAbiFunction<abi, functionName, stateMutability>
|
77
|
+
: AbiFunction,
|
78
|
+
types = AbiParametersToPrimitiveTypes<abiFunction['outputs'], 'outputs'>,
|
79
|
+
> = [abiFunction] extends [never]
|
80
|
+
? unknown // `abiFunction` was not inferrable (e.g. `abi` declared as `Abi`)
|
81
|
+
: readonly unknown[] extends types
|
82
|
+
? unknown // `abiFunction` was not inferrable (e.g. `abi` not const asserted)
|
83
|
+
: types extends readonly [] // unwrap `types`
|
84
|
+
? void // no outputs
|
85
|
+
: types extends readonly [infer type]
|
86
|
+
? type // single output
|
87
|
+
: types
|
88
|
+
|
35
89
|
export type ContractFunctionConfig<
|
36
90
|
TAbi extends Abi | readonly unknown[] = Abi,
|
37
91
|
TFunctionName extends string = string,
|
38
92
|
TAbiStateMutability extends AbiStateMutability = AbiStateMutability,
|
39
93
|
> = {
|
40
94
|
/** Contract ABI */
|
41
|
-
abi:
|
95
|
+
abi: TAbi
|
42
96
|
/** Contract address */
|
43
97
|
address: Address
|
44
98
|
/** Function to invoke on the contract */
|