viem 2.14.0 → 2.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/_cjs/actions/index.js +5 -4
- package/_cjs/actions/index.js.map +1 -1
- package/_cjs/actions/public/call.js +33 -12
- package/_cjs/actions/public/call.js.map +1 -1
- package/_cjs/actions/public/{getBytecode.js → getCode.js} +4 -4
- package/_cjs/actions/public/getCode.js.map +1 -0
- package/_cjs/actions/public/readContract.js.map +1 -1
- package/_cjs/actions/public/simulateContract.js.map +1 -1
- package/_cjs/actions/wallet/writeContract.js.map +1 -1
- package/_cjs/clients/decorators/public.js +3 -2
- package/_cjs/clients/decorators/public.js.map +1 -1
- package/_cjs/constants/contracts.js +3 -2
- package/_cjs/constants/contracts.js.map +1 -1
- package/_cjs/errors/contract.js +1 -1
- package/_cjs/errors/contract.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/index.js.map +1 -1
- package/_esm/actions/index.js +3 -1
- package/_esm/actions/index.js.map +1 -1
- package/_esm/actions/public/call.js +36 -17
- package/_esm/actions/public/call.js.map +1 -1
- package/_esm/actions/public/{getBytecode.js → getCode.js} +7 -7
- package/_esm/actions/public/getCode.js.map +1 -0
- package/_esm/actions/public/readContract.js.map +1 -1
- package/_esm/actions/public/simulateContract.js.map +1 -1
- package/_esm/actions/wallet/writeContract.js.map +1 -1
- package/_esm/clients/decorators/public.js +3 -2
- package/_esm/clients/decorators/public.js.map +1 -1
- package/_esm/constants/contracts.js +2 -1
- package/_esm/constants/contracts.js.map +1 -1
- package/_esm/errors/contract.js +1 -1
- package/_esm/errors/contract.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/index.js.map +1 -1
- package/_types/actions/index.d.ts +9 -1
- package/_types/actions/index.d.ts.map +1 -1
- package/_types/actions/public/call.d.ts +8 -2
- package/_types/actions/public/call.d.ts.map +1 -1
- package/_types/actions/public/{getBytecode.d.ts → getCode.d.ts} +10 -10
- package/_types/actions/public/getCode.d.ts.map +1 -0
- package/_types/actions/public/readContract.d.ts +1 -1
- package/_types/actions/public/readContract.d.ts.map +1 -1
- package/_types/actions/public/simulateContract.d.ts +1 -1
- package/_types/actions/public/simulateContract.d.ts.map +1 -1
- package/_types/actions/wallet/writeContract.d.ts +1 -1
- package/_types/actions/wallet/writeContract.d.ts.map +1 -1
- package/_types/clients/decorators/public.d.ts +19 -17
- package/_types/clients/decorators/public.d.ts.map +1 -1
- package/_types/constants/contracts.d.ts +2 -1
- package/_types/constants/contracts.d.ts.map +1 -1
- package/_types/errors/contract.d.ts +1 -1
- package/_types/errors/contract.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/index.d.ts +8 -2
- package/_types/index.d.ts.map +1 -1
- package/_types/types/contract.d.ts +6 -2
- package/_types/types/contract.d.ts.map +1 -1
- package/actions/index.ts +14 -6
- package/actions/public/call.ts +61 -18
- package/actions/public/{getBytecode.ts → getCode.ts} +11 -11
- package/actions/public/readContract.ts +2 -2
- package/actions/public/simulateContract.ts +8 -1
- package/actions/wallet/writeContract.ts +1 -0
- package/clients/decorators/public.ts +25 -22
- package/constants/contracts.ts +4 -1
- package/errors/contract.ts +4 -2
- package/errors/version.ts +1 -1
- package/index.ts +12 -4
- package/package.json +1 -1
- package/types/contract.ts +5 -2
- package/_cjs/actions/public/getBytecode.js.map +0 -1
- package/_esm/actions/public/getBytecode.js.map +0 -1
- package/_types/actions/public/getBytecode.d.ts.map +0 -1
@@ -66,7 +66,14 @@ export type SimulateContractParameters<
|
|
66
66
|
> &
|
67
67
|
UnionOmit<
|
68
68
|
CallParameters<derivedChain>,
|
69
|
-
|
69
|
+
| 'account'
|
70
|
+
| 'batch'
|
71
|
+
| 'code'
|
72
|
+
| 'to'
|
73
|
+
| 'data'
|
74
|
+
| 'factory'
|
75
|
+
| 'factoryData'
|
76
|
+
| 'value'
|
70
77
|
> &
|
71
78
|
GetValue<
|
72
79
|
abi,
|
@@ -92,15 +92,15 @@ import {
|
|
92
92
|
type GetBlockTransactionCountReturnType,
|
93
93
|
getBlockTransactionCount,
|
94
94
|
} from '../../actions/public/getBlockTransactionCount.js'
|
95
|
-
import {
|
96
|
-
type GetBytecodeParameters,
|
97
|
-
type GetBytecodeReturnType,
|
98
|
-
getBytecode,
|
99
|
-
} from '../../actions/public/getBytecode.js'
|
100
95
|
import {
|
101
96
|
type GetChainIdReturnType,
|
102
97
|
getChainId,
|
103
98
|
} from '../../actions/public/getChainId.js'
|
99
|
+
import {
|
100
|
+
type GetCodeParameters,
|
101
|
+
type GetCodeReturnType,
|
102
|
+
getCode,
|
103
|
+
} from '../../actions/public/getCode.js'
|
104
104
|
import {
|
105
105
|
type GetContractEventsParameters,
|
106
106
|
type GetContractEventsReturnType,
|
@@ -624,14 +624,15 @@ export type PublicActions<
|
|
624
624
|
getBlockTransactionCount: (
|
625
625
|
args?: GetBlockTransactionCountParameters | undefined,
|
626
626
|
) => Promise<GetBlockTransactionCountReturnType>
|
627
|
+
/** @deprecated Use `getCode` instead. */
|
628
|
+
getBytecode: (args: GetCodeParameters) => Promise<GetCodeReturnType>
|
627
629
|
/**
|
628
|
-
*
|
630
|
+
* Returns the chain ID associated with the current network.
|
629
631
|
*
|
630
|
-
* - Docs: https://viem.sh/docs/
|
631
|
-
* - JSON-RPC Methods: [`
|
632
|
+
* - Docs: https://viem.sh/docs/actions/public/getChainId
|
633
|
+
* - JSON-RPC Methods: [`eth_chainId`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_chainid)
|
632
634
|
*
|
633
|
-
* @
|
634
|
-
* @returns The contract's bytecode. {@link GetBytecodeReturnType}
|
635
|
+
* @returns The current chain ID. {@link GetChainIdReturnType}
|
635
636
|
*
|
636
637
|
* @example
|
637
638
|
* import { createPublicClient, http } from 'viem'
|
@@ -641,18 +642,18 @@ export type PublicActions<
|
|
641
642
|
* chain: mainnet,
|
642
643
|
* transport: http(),
|
643
644
|
* })
|
644
|
-
* const
|
645
|
-
*
|
646
|
-
* })
|
645
|
+
* const chainId = await client.getChainId()
|
646
|
+
* // 1
|
647
647
|
*/
|
648
|
-
|
648
|
+
getChainId: () => Promise<GetChainIdReturnType>
|
649
649
|
/**
|
650
|
-
*
|
650
|
+
* Retrieves the bytecode at an address.
|
651
651
|
*
|
652
|
-
* - Docs: https://viem.sh/docs/
|
653
|
-
* - JSON-RPC Methods: [`
|
652
|
+
* - Docs: https://viem.sh/docs/contract/getCode
|
653
|
+
* - JSON-RPC Methods: [`eth_getCode`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getcode)
|
654
654
|
*
|
655
|
-
* @
|
655
|
+
* @param args - {@link GetBytecodeParameters}
|
656
|
+
* @returns The contract's bytecode. {@link GetBytecodeReturnType}
|
656
657
|
*
|
657
658
|
* @example
|
658
659
|
* import { createPublicClient, http } from 'viem'
|
@@ -662,10 +663,11 @@ export type PublicActions<
|
|
662
663
|
* chain: mainnet,
|
663
664
|
* transport: http(),
|
664
665
|
* })
|
665
|
-
* const
|
666
|
-
*
|
666
|
+
* const code = await client.getCode({
|
667
|
+
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
668
|
+
* })
|
667
669
|
*/
|
668
|
-
|
670
|
+
getCode: (args: GetCodeParameters) => Promise<GetCodeReturnType>
|
669
671
|
/**
|
670
672
|
* Returns a list of event logs emitted by a contract.
|
671
673
|
*
|
@@ -1853,8 +1855,9 @@ export function publicActions<
|
|
1853
1855
|
getBlock: (args) => getBlock(client, args),
|
1854
1856
|
getBlockNumber: (args) => getBlockNumber(client, args),
|
1855
1857
|
getBlockTransactionCount: (args) => getBlockTransactionCount(client, args),
|
1856
|
-
getBytecode: (args) =>
|
1858
|
+
getBytecode: (args) => getCode(client, args),
|
1857
1859
|
getChainId: () => getChainId(client),
|
1860
|
+
getCode: (args) => getCode(client, args),
|
1858
1861
|
getContractEvents: (args) => getContractEvents(client, args),
|
1859
1862
|
getEip712Domain: (args) => getEip712Domain(client, args),
|
1860
1863
|
getEnsAddress: (args) => getEnsAddress(client, args),
|
package/constants/contracts.ts
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
export const
|
1
|
+
export const deploylessCallViaBytecodeBytecode =
|
2
|
+
'0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe'
|
3
|
+
|
4
|
+
export const deploylessCallViaFactoryBytecode =
|
2
5
|
'0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe'
|
3
6
|
|
4
7
|
export const universalSignatureValidatorByteCode =
|
package/errors/contract.ts
CHANGED
@@ -284,9 +284,11 @@ export type CounterfactualDeploymentFailedErrorType =
|
|
284
284
|
}
|
285
285
|
export class CounterfactualDeploymentFailedError extends BaseError {
|
286
286
|
override name = 'CounterfactualDeploymentFailedError'
|
287
|
-
constructor({ factory }: { factory
|
287
|
+
constructor({ factory }: { factory?: Address | undefined }) {
|
288
288
|
super(
|
289
|
-
`Deployment for counterfactual contract call failed
|
289
|
+
`Deployment for counterfactual contract call failed${
|
290
|
+
factory ? ` for factory "${factory}".` : ''
|
291
|
+
}`,
|
290
292
|
{
|
291
293
|
metaMessages: [
|
292
294
|
'Please ensure:',
|
package/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '2.14.
|
1
|
+
export const version = '2.14.1'
|
package/index.ts
CHANGED
@@ -146,10 +146,16 @@ export type {
|
|
146
146
|
GetBlockTransactionCountReturnType,
|
147
147
|
} from './actions/public/getBlockTransactionCount.js'
|
148
148
|
export type {
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
149
|
+
/** @deprecated Use `GetCodeErrorType` instead */
|
150
|
+
GetCodeErrorType as GetBytecodeErrorType,
|
151
|
+
/** @deprecated Use `GetCodeParameters` instead */
|
152
|
+
GetCodeParameters as GetBytecodeParameters,
|
153
|
+
/** @deprecated Use `GetCodeReturnType` instead */
|
154
|
+
GetCodeReturnType as GetBytecodeReturnType,
|
155
|
+
GetCodeErrorType,
|
156
|
+
GetCodeParameters,
|
157
|
+
GetCodeReturnType,
|
158
|
+
} from './actions/public/getCode.js'
|
153
159
|
export type {
|
154
160
|
GetChainIdErrorType,
|
155
161
|
GetChainIdReturnType,
|
@@ -923,6 +929,8 @@ export type {
|
|
923
929
|
LogTopicType,
|
924
930
|
MaybeAbiEventName,
|
925
931
|
MaybeExtractEventArgsFromAbi,
|
932
|
+
UnionWiden,
|
933
|
+
Widen,
|
926
934
|
} from './types/contract.js'
|
927
935
|
export type {
|
928
936
|
AccessList,
|
package/package.json
CHANGED
package/types/contract.ts
CHANGED
@@ -197,19 +197,22 @@ export type ContractFunctionParameters<
|
|
197
197
|
mutability,
|
198
198
|
functionName
|
199
199
|
> = ContractFunctionArgs<abi, mutability, functionName>,
|
200
|
+
deployless extends boolean = false,
|
200
201
|
///
|
201
202
|
allFunctionNames = ContractFunctionName<abi, mutability>,
|
202
203
|
allArgs = ContractFunctionArgs<abi, mutability, functionName>,
|
203
204
|
// when `args` is inferred to `readonly []` ("inputs": []) or `never` (`abi` declared as `Abi` or not inferrable), allow `args` to be optional.
|
204
205
|
// important that both branches return same structural type
|
205
206
|
> = {
|
206
|
-
address: Address
|
207
207
|
abi: abi
|
208
208
|
functionName:
|
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> })
|
212
|
+
} & (readonly [] extends allArgs ? {} : { args: Widen<args> }) &
|
213
|
+
(deployless extends true
|
214
|
+
? { address?: undefined; code: Hex }
|
215
|
+
: { address: Address })
|
213
216
|
|
214
217
|
export type ContractFunctionReturnType<
|
215
218
|
abi extends Abi | readonly unknown[] = Abi,
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"getBytecode.js","sourceRoot":"","sources":["../../../actions/public/getBytecode.ts"],"names":[],"mappings":";;;AASA,4DAGsC;AA6C/B,KAAK,UAAU,WAAW,CAC/B,MAAiC,EACjC,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,GAAG,QAAQ,EAAyB;IAEpE,MAAM,cAAc,GAClB,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,IAAA,sBAAW,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAClE,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAC/B,MAAM,EAAE,aAAa;QACrB,MAAM,EAAE,CAAC,OAAO,EAAE,cAAc,IAAI,QAAQ,CAAC;KAC9C,CAAC,CAAA;IACF,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,SAAS,CAAA;IAClC,OAAO,GAAG,CAAA;AACZ,CAAC;AAZD,kCAYC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"getBytecode.js","sourceRoot":"","sources":["../../../actions/public/getBytecode.ts"],"names":[],"mappings":"AASA,OAAO,EAEL,WAAW,GACZ,MAAM,+BAA+B,CAAA;AAsBtC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAiC,EACjC,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,GAAG,QAAQ,EAAyB;IAEpE,MAAM,cAAc,GAClB,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAClE,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAC/B,MAAM,EAAE,aAAa;QACrB,MAAM,EAAE,CAAC,OAAO,EAAE,cAAc,IAAI,QAAQ,CAAC;KAC9C,CAAC,CAAA;IACF,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,SAAS,CAAA;IAClC,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"getBytecode.d.ts","sourceRoot":"","sources":["../../../actions/public/getBytecode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAA;AAC5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,EACL,KAAK,oBAAoB,EAE1B,MAAM,+BAA+B,CAAA;AAEtC,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,OAAO,CAAA;CACjB,GAAG,CACA;IACE,WAAW,CAAC,EAAE,SAAS,CAAA;IACvB,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAA;CAChC,GACD;IACE,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB,CACJ,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG,GAAG,GAAG,SAAS,CAAA;AAEnD,MAAM,MAAM,oBAAoB,GAC5B,oBAAoB,GACpB,gBAAgB,GAChB,SAAS,CAAA;AAEb;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,WAAW,CAAC,MAAM,SAAS,KAAK,GAAG,SAAS,EAChE,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,EACjC,EAAE,OAAO,EAAE,WAAW,EAAE,QAAmB,EAAE,EAAE,qBAAqB,GACnE,OAAO,CAAC,qBAAqB,CAAC,CAShC"}
|