viem 2.13.1 → 2.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/_cjs/chains/definitions/avalanche.js +3 -3
- package/_cjs/chains/definitions/avalanche.js.map +1 -1
- package/_cjs/chains/definitions/avalancheFuji.js +3 -3
- package/_cjs/chains/definitions/avalancheFuji.js.map +1 -1
- package/_cjs/chains/definitions/lycan.js +40 -0
- package/_cjs/chains/definitions/lycan.js.map +1 -0
- package/_cjs/chains/index.js +6 -4
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/experimental/eip5792/actions/writeContracts.js +2 -1
- package/_cjs/experimental/eip5792/actions/writeContracts.js.map +1 -1
- package/_cjs/experimental/index.js.map +1 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/utils/index.js.map +1 -1
- package/_esm/chains/definitions/avalanche.js +3 -3
- package/_esm/chains/definitions/avalanche.js.map +1 -1
- package/_esm/chains/definitions/avalancheFuji.js +3 -3
- package/_esm/chains/definitions/avalancheFuji.js.map +1 -1
- package/_esm/chains/definitions/lycan.js +37 -0
- package/_esm/chains/definitions/lycan.js.map +1 -0
- package/_esm/chains/index.js +1 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/experimental/eip5792/actions/writeContracts.js +2 -1
- package/_esm/experimental/eip5792/actions/writeContracts.js.map +1 -1
- package/_esm/experimental/index.js.map +1 -1
- package/_esm/index.js.map +1 -1
- package/_esm/utils/index.js.map +1 -1
- package/_types/chains/definitions/avalanche.d.ts +3 -3
- package/_types/chains/definitions/avalancheFuji.d.ts +3 -3
- package/_types/chains/definitions/lycan.d.ts +36 -0
- package/_types/chains/definitions/lycan.d.ts.map +1 -0
- package/_types/chains/index.d.ts +1 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/experimental/eip5792/actions/writeContracts.d.ts +11 -3
- package/_types/experimental/eip5792/actions/writeContracts.d.ts.map +1 -1
- package/_types/experimental/index.d.ts +1 -1
- package/_types/experimental/index.d.ts.map +1 -1
- package/_types/index.d.ts +1 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/types/contract.d.ts +1 -1
- package/_types/types/contract.d.ts.map +1 -1
- package/_types/utils/index.d.ts +1 -1
- package/_types/utils/index.d.ts.map +1 -1
- package/chains/definitions/avalanche.ts +3 -3
- package/chains/definitions/avalancheFuji.ts +3 -3
- package/chains/definitions/lycan.ts +37 -0
- package/chains/index.ts +1 -0
- package/errors/version.ts +1 -1
- package/experimental/eip5792/actions/writeContracts.ts +44 -5
- package/experimental/index.ts +1 -0
- package/index.ts +1 -0
- package/package.json +4 -3
- package/types/contract.ts +1 -3
- package/utils/index.ts +1 -0
@@ -1,16 +1,23 @@
|
|
1
|
-
import type { AbiStateMutability, Narrow } from 'abitype'
|
1
|
+
import type { Abi, AbiStateMutability, Address, Narrow } 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 { ErrorType } from '../../../errors/utils.js'
|
6
6
|
import type { Account, GetAccountParameter } from '../../../types/account.js'
|
7
7
|
import type { Chain, GetChainParameter } from '../../../types/chain.js'
|
8
|
-
import type {
|
8
|
+
import type {
|
9
|
+
ContractFunctionArgs,
|
10
|
+
ContractFunctionName,
|
11
|
+
GetValue,
|
12
|
+
UnionWiden,
|
13
|
+
Widen,
|
14
|
+
} from '../../../types/contract.js'
|
9
15
|
import type { MulticallContracts } from '../../../types/multicall.js'
|
10
16
|
import {
|
11
17
|
type EncodeFunctionDataErrorType,
|
12
18
|
encodeFunctionData,
|
13
19
|
} from '../../../utils/abi/encodeFunctionData.js'
|
20
|
+
import { getAction } from '../../../utils/getAction.js'
|
14
21
|
import {
|
15
22
|
type SendCallsErrorType,
|
16
23
|
type SendCallsParameters,
|
@@ -19,7 +26,8 @@ import {
|
|
19
26
|
} from './sendCalls.js'
|
20
27
|
|
21
28
|
export type WriteContractsParameters<
|
22
|
-
contracts extends
|
29
|
+
contracts extends
|
30
|
+
readonly unknown[] = readonly WriteContractFunctionParameters[],
|
23
31
|
chain extends Chain | undefined = Chain | undefined,
|
24
32
|
account extends Account | undefined = Account | undefined,
|
25
33
|
chainOverride extends Chain | undefined = Chain | undefined,
|
@@ -98,7 +106,7 @@ export async function writeContracts<
|
|
98
106
|
chainOverride
|
99
107
|
>,
|
100
108
|
): Promise<WriteContractsReturnType> {
|
101
|
-
const contracts = parameters.contracts as
|
109
|
+
const contracts = parameters.contracts as WriteContractFunctionParameters[]
|
102
110
|
const calls = contracts.map((contract) => {
|
103
111
|
const { address, abi, functionName, args, value } = contract
|
104
112
|
return {
|
@@ -111,5 +119,36 @@ export async function writeContracts<
|
|
111
119
|
value,
|
112
120
|
} satisfies SendCallsParameters['calls'][number]
|
113
121
|
})
|
114
|
-
return
|
122
|
+
return getAction(
|
123
|
+
client,
|
124
|
+
sendCalls,
|
125
|
+
'sendCalls',
|
126
|
+
)({ ...parameters, calls } as SendCallsParameters)
|
115
127
|
}
|
128
|
+
|
129
|
+
export type WriteContractFunctionParameters<
|
130
|
+
abi extends Abi | readonly unknown[] = Abi,
|
131
|
+
mutability extends AbiStateMutability = AbiStateMutability,
|
132
|
+
functionName extends ContractFunctionName<
|
133
|
+
abi,
|
134
|
+
mutability
|
135
|
+
> = ContractFunctionName<abi, mutability>,
|
136
|
+
args extends ContractFunctionArgs<
|
137
|
+
abi,
|
138
|
+
mutability,
|
139
|
+
functionName
|
140
|
+
> = ContractFunctionArgs<abi, mutability, functionName>,
|
141
|
+
///
|
142
|
+
allFunctionNames = ContractFunctionName<abi, mutability>,
|
143
|
+
allArgs = ContractFunctionArgs<abi, mutability, functionName>,
|
144
|
+
// when `args` is inferred to `readonly []` ("inputs": []) or `never` (`abi` declared as `Abi` or not inferrable), allow `args` to be optional.
|
145
|
+
// important that both branches return same structural type
|
146
|
+
> = {
|
147
|
+
address: Address
|
148
|
+
abi: abi
|
149
|
+
functionName:
|
150
|
+
| allFunctionNames // show all options
|
151
|
+
| (functionName extends allFunctionNames ? functionName : never) // infer value
|
152
|
+
args?: (abi extends Abi ? UnionWiden<args> : never) | allArgs | undefined
|
153
|
+
} & (readonly [] extends allArgs ? {} : { args: Widen<args> }) &
|
154
|
+
GetValue<abi, functionName>
|
package/experimental/index.ts
CHANGED
package/index.ts
CHANGED
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "viem",
|
3
3
|
"description": "TypeScript Interface for Ethereum",
|
4
|
-
"version": "2.13.
|
4
|
+
"version": "2.13.3",
|
5
5
|
"main": "./_cjs/index.js",
|
6
6
|
"module": "./_esm/index.js",
|
7
7
|
"types": "./_types/index.d.ts",
|
@@ -9,11 +9,12 @@
|
|
9
9
|
"sideEffects": false,
|
10
10
|
"files": [
|
11
11
|
"*",
|
12
|
-
"!**/*.
|
12
|
+
"!**/*.bench.ts",
|
13
|
+
"!**/*.bench-d.ts",
|
13
14
|
"!**/*.test.ts",
|
14
15
|
"!**/*.test.ts.snap",
|
15
16
|
"!**/*.test-d.ts",
|
16
|
-
"!**/*.
|
17
|
+
"!**/*.tsbuildinfo",
|
17
18
|
"!tsconfig.build.json",
|
18
19
|
"!jsr.json"
|
19
20
|
],
|
package/types/contract.ts
CHANGED
@@ -209,9 +209,7 @@ export type ContractFunctionParameters<
|
|
209
209
|
| allFunctionNames // show all options
|
210
210
|
| (functionName extends allFunctionNames ? functionName : never) // infer value
|
211
211
|
args?: (abi extends Abi ? UnionWiden<args> : never) | allArgs | undefined
|
212
|
-
} & (readonly [] extends allArgs ? {} : { args: Widen<args> })
|
213
|
-
// TODO: Remove `GetValue` from here (should be applied to top-level type as separate utility)
|
214
|
-
GetValue<abi, functionName>
|
212
|
+
} & (readonly [] extends allArgs ? {} : { args: Widen<args> })
|
215
213
|
|
216
214
|
export type ContractFunctionReturnType<
|
217
215
|
abi extends Abi | readonly unknown[] = Abi,
|