viem 2.0.0-alpha.1 → 2.0.0-alpha.11
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/_cjs/{abi.js → abi/index.js} +9 -9
- package/_cjs/abi/index.js.map +1 -0
- package/_cjs/actions/getContract.js +16 -0
- package/_cjs/actions/getContract.js.map +1 -1
- package/_cjs/actions/public/estimateFeesPerGas.js +3 -2
- package/_cjs/actions/public/estimateFeesPerGas.js.map +1 -1
- package/_cjs/actions/public/getContractEvents.js +26 -0
- package/_cjs/actions/public/getContractEvents.js.map +1 -0
- package/_cjs/actions/public/multicall.js.map +1 -1
- package/_cjs/actions/public/readContract.js.map +1 -1
- package/_cjs/actions/public/waitForTransactionReceipt.js +9 -4
- package/_cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_cjs/actions/public/watchContractEvent.js +4 -7
- package/_cjs/actions/public/watchContractEvent.js.map +1 -1
- package/_cjs/actions/wallet/signTypedData.js.map +1 -1
- package/_cjs/actions/wallet/writeContract.js.map +1 -1
- package/_cjs/chains/definitions/holesky.js +21 -0
- package/_cjs/chains/definitions/holesky.js.map +1 -0
- package/_cjs/chains/definitions/kroma.js +26 -0
- package/_cjs/chains/definitions/kroma.js.map +1 -0
- package/_cjs/chains/definitions/kromaSepolia.js +26 -0
- package/_cjs/chains/definitions/kromaSepolia.js.map +1 -0
- package/_cjs/chains/definitions/moonbeamDev.js +25 -0
- package/_cjs/chains/definitions/moonbeamDev.js.map +1 -0
- package/_cjs/chains/definitions/optimismSepolia.js +39 -0
- package/_cjs/chains/definitions/optimismSepolia.js.map +1 -0
- package/_cjs/chains/definitions/sepolia.js +1 -1
- package/_cjs/chains/definitions/sepolia.js.map +1 -1
- package/_cjs/chains/index.js +12 -2
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/clients/decorators/public.js +2 -0
- package/_cjs/clients/decorators/public.js.map +1 -1
- package/_cjs/clients/decorators/wallet.js.map +1 -1
- package/_cjs/{contract.js → contract/index.js} +25 -25
- package/_cjs/contract/index.js.map +1 -0
- package/_cjs/{ens.js → ens/index.js} +9 -9
- package/_cjs/ens/index.js.map +1 -0
- package/_cjs/errors/version.js +1 -1
- package/_cjs/errors/version.js.map +1 -1
- package/_cjs/index.js +5 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/{public.js → public/index.js} +29 -29
- package/_cjs/public/index.js.map +1 -0
- package/_cjs/{test.js → test/index.js} +29 -29
- package/_cjs/test/index.js.map +1 -0
- package/_cjs/types/eip1193.js.map +1 -1
- package/_cjs/utils/hash/getEventSelector.js +5 -6
- package/_cjs/utils/hash/getEventSelector.js.map +1 -1
- package/_cjs/utils/hash/getEventSignature.js +9 -0
- package/_cjs/utils/hash/getEventSignature.js.map +1 -0
- package/_cjs/utils/hash/getFunctionSelector.js +5 -6
- package/_cjs/utils/hash/getFunctionSelector.js.map +1 -1
- package/_cjs/utils/hash/getFunctionSignature.js +15 -0
- package/_cjs/utils/hash/getFunctionSignature.js.map +1 -0
- package/_cjs/utils/hash/hashFunction.js +2 -4
- package/_cjs/utils/hash/hashFunction.js.map +1 -1
- package/_cjs/utils/rpc.js +6 -3
- package/_cjs/utils/rpc.js.map +1 -1
- package/_cjs/{wallet.js → wallet/index.js} +11 -11
- package/_cjs/wallet/index.js.map +1 -0
- package/_cjs/{window.js → window/index.js} +2 -2
- package/_cjs/window/index.js.map +1 -0
- package/_esm/abi/index.js +7 -0
- package/_esm/abi/index.js.map +1 -0
- package/_esm/actions/getContract.js +16 -0
- package/_esm/actions/getContract.js.map +1 -1
- package/_esm/actions/public/estimateFeesPerGas.js +3 -2
- package/_esm/actions/public/estimateFeesPerGas.js.map +1 -1
- package/_esm/actions/public/getContractEvents.js +48 -0
- package/_esm/actions/public/getContractEvents.js.map +1 -0
- package/_esm/actions/public/multicall.js.map +1 -1
- package/_esm/actions/public/readContract.js.map +1 -1
- package/_esm/actions/public/waitForTransactionReceipt.js +9 -4
- package/_esm/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_esm/actions/public/watchContractEvent.js +4 -7
- package/_esm/actions/public/watchContractEvent.js.map +1 -1
- package/_esm/actions/wallet/signTypedData.js.map +1 -1
- package/_esm/actions/wallet/writeContract.js.map +1 -1
- package/_esm/chains/definitions/holesky.js +18 -0
- package/_esm/chains/definitions/holesky.js.map +1 -0
- package/_esm/chains/definitions/kroma.js +23 -0
- package/_esm/chains/definitions/kroma.js.map +1 -0
- package/_esm/chains/definitions/kromaSepolia.js +23 -0
- package/_esm/chains/definitions/kromaSepolia.js.map +1 -0
- package/_esm/chains/definitions/moonbeamDev.js +22 -0
- package/_esm/chains/definitions/moonbeamDev.js.map +1 -0
- package/_esm/chains/definitions/optimismSepolia.js +36 -0
- package/_esm/chains/definitions/optimismSepolia.js.map +1 -0
- package/_esm/chains/definitions/sepolia.js +1 -1
- package/_esm/chains/definitions/sepolia.js.map +1 -1
- package/_esm/chains/index.js +5 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/clients/decorators/public.js +2 -0
- package/_esm/clients/decorators/public.js.map +1 -1
- package/_esm/clients/decorators/wallet.js.map +1 -1
- package/_esm/contract/index.js +26 -0
- package/_esm/contract/index.js.map +1 -0
- package/_esm/ens/index.js +9 -0
- package/_esm/ens/index.js.map +1 -0
- package/_esm/errors/version.js +1 -1
- package/_esm/errors/version.js.map +1 -1
- package/_esm/index.js +2 -0
- package/_esm/index.js.map +1 -1
- package/_esm/public/index.js +30 -0
- package/_esm/public/index.js.map +1 -0
- package/_esm/test/index.js +30 -0
- package/_esm/test/index.js.map +1 -0
- package/_esm/types/eip1193.js.map +1 -1
- package/_esm/utils/hash/getEventSelector.js +5 -6
- package/_esm/utils/hash/getEventSelector.js.map +1 -1
- package/_esm/utils/hash/getEventSignature.js +5 -0
- package/_esm/utils/hash/getEventSignature.js.map +1 -0
- package/_esm/utils/hash/getFunctionSelector.js +5 -6
- package/_esm/utils/hash/getFunctionSelector.js.map +1 -1
- package/_esm/utils/hash/getFunctionSignature.js +11 -0
- package/_esm/utils/hash/getFunctionSignature.js.map +1 -0
- package/_esm/utils/hash/hashFunction.js +2 -4
- package/_esm/utils/hash/hashFunction.js.map +1 -1
- package/_esm/utils/rpc.js +6 -2
- package/_esm/utils/rpc.js.map +1 -1
- package/_esm/wallet/index.js +12 -0
- package/_esm/wallet/index.js.map +1 -0
- package/_esm/window/index.js +2 -0
- package/_esm/window/index.js.map +1 -0
- package/_types/{abi.d.ts → abi/index.d.ts} +5 -5
- package/_types/abi/index.d.ts.map +1 -0
- package/_types/actions/getContract.d.ts +29 -0
- package/_types/actions/getContract.d.ts.map +1 -1
- package/_types/actions/public/createContractEventFilter.d.ts +1 -1
- package/_types/actions/public/createContractEventFilter.d.ts.map +1 -1
- package/_types/actions/public/estimateFeesPerGas.d.ts.map +1 -1
- package/_types/actions/public/getContractEvents.d.ts +62 -0
- package/_types/actions/public/getContractEvents.d.ts.map +1 -0
- package/_types/actions/public/multicall.d.ts +1 -1
- package/_types/actions/public/multicall.d.ts.map +1 -1
- package/_types/actions/public/readContract.d.ts +2 -1
- package/_types/actions/public/readContract.d.ts.map +1 -1
- package/_types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
- package/_types/actions/public/watchContractEvent.d.ts +1 -1
- package/_types/actions/public/watchContractEvent.d.ts.map +1 -1
- package/_types/actions/wallet/signTypedData.d.ts +1 -1
- package/_types/actions/wallet/signTypedData.d.ts.map +1 -1
- package/_types/actions/wallet/writeContract.d.ts +3 -3
- package/_types/actions/wallet/writeContract.d.ts.map +1 -1
- package/_types/chains/celo/formatters.d.ts +57 -57
- package/_types/chains/definitions/base.d.ts +171 -171
- package/_types/chains/definitions/baseGoerli.d.ts +171 -171
- package/_types/chains/definitions/celo.d.ts +171 -171
- package/_types/chains/definitions/celoAlfajores.d.ts +171 -171
- package/_types/chains/definitions/celoCannoli.d.ts +171 -171
- package/_types/chains/definitions/holesky.d.ts +24 -0
- package/_types/chains/definitions/holesky.d.ts.map +1 -0
- package/_types/chains/definitions/kroma.d.ts +29 -0
- package/_types/chains/definitions/kroma.d.ts.map +1 -0
- package/_types/chains/definitions/kromaSepolia.d.ts +29 -0
- package/_types/chains/definitions/kromaSepolia.d.ts.map +1 -0
- package/_types/chains/definitions/moonbeamDev.d.ts +24 -0
- package/_types/chains/definitions/moonbeamDev.d.ts.map +1 -0
- package/_types/chains/definitions/optimism.d.ts +171 -171
- package/_types/chains/definitions/optimismGoerli.d.ts +171 -171
- package/_types/chains/definitions/optimismSepolia.d.ts +1524 -0
- package/_types/chains/definitions/optimismSepolia.d.ts.map +1 -0
- package/_types/chains/definitions/sepolia.d.ts +1 -1
- package/_types/chains/definitions/zora.d.ts +171 -171
- package/_types/chains/definitions/zoraTestnet.d.ts +171 -171
- package/_types/chains/index.d.ts +6 -1
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/chains/optimism/formatters.d.ts +57 -57
- package/_types/clients/decorators/public.d.ts +27 -0
- package/_types/clients/decorators/public.d.ts.map +1 -1
- package/_types/clients/transports/webSocket.d.ts +2 -1
- package/_types/clients/transports/webSocket.d.ts.map +1 -1
- package/_types/{contract.d.ts → contract/index.d.ts} +26 -26
- package/_types/contract/index.d.ts.map +1 -0
- package/_types/ens/index.d.ts +9 -0
- package/_types/ens/index.d.ts.map +1 -0
- package/_types/errors/version.d.ts +1 -1
- package/_types/errors/version.d.ts.map +1 -1
- package/_types/index.d.ts +3 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/public/index.d.ts +33 -0
- package/_types/public/index.d.ts.map +1 -0
- package/_types/test/index.d.ts +29 -0
- package/_types/test/index.d.ts.map +1 -0
- package/_types/types/contract.d.ts +1 -1
- package/_types/types/contract.d.ts.map +1 -1
- package/_types/types/eip1193.d.ts +2 -2
- package/_types/types/eip1193.d.ts.map +1 -1
- package/_types/types/multicall.d.ts +10 -4
- package/_types/types/multicall.d.ts.map +1 -1
- package/_types/types/typedData.d.ts +2 -2
- package/_types/types/typedData.d.ts.map +1 -1
- package/_types/types/utils.d.ts +12 -8
- package/_types/types/utils.d.ts.map +1 -1
- package/_types/utils/abi/decodeEventLog.d.ts +2 -2
- package/_types/utils/abi/decodeEventLog.d.ts.map +1 -1
- package/_types/utils/formatters/transaction.d.ts +3 -3
- package/_types/utils/formatters/transaction.d.ts.map +1 -1
- package/_types/utils/formatters/transactionRequest.d.ts +1 -1
- package/_types/utils/hash/getEventSelector.d.ts +1 -2
- package/_types/utils/hash/getEventSelector.d.ts.map +1 -1
- package/_types/utils/hash/getEventSignature.d.ts +3 -0
- package/_types/utils/hash/getEventSignature.d.ts.map +1 -0
- package/_types/utils/hash/getFunctionSelector.d.ts.map +1 -1
- package/_types/utils/hash/getFunctionSignature.d.ts +3 -0
- package/_types/utils/hash/getFunctionSignature.d.ts.map +1 -0
- package/_types/utils/hash/hashFunction.d.ts.map +1 -1
- package/_types/utils/rpc.d.ts +3 -3
- package/_types/utils/rpc.d.ts.map +1 -1
- package/_types/wallet/index.d.ts +11 -0
- package/_types/wallet/index.d.ts.map +1 -0
- package/_types/window/index.d.ts +2 -0
- package/_types/window/index.d.ts.map +1 -0
- package/{abi.ts → abi/index.ts} +15 -13
- package/abi/package.json +6 -0
- package/accounts/package.json +6 -0
- package/actions/getContract.ts +95 -0
- package/actions/package.json +6 -0
- package/actions/public/createContractEventFilter.ts +1 -1
- package/actions/public/estimateFeesPerGas.ts +3 -2
- package/actions/public/getContractEvents.ts +155 -0
- package/actions/public/multicall.ts +2 -2
- package/actions/public/readContract.ts +4 -1
- package/actions/public/waitForTransactionReceipt.ts +13 -4
- package/actions/public/watchContractEvent.ts +10 -13
- package/actions/wallet/signTypedData.ts +4 -2
- package/actions/wallet/writeContract.ts +30 -23
- package/chains/definitions/holesky.ts +18 -0
- package/chains/definitions/kroma.ts +23 -0
- package/chains/definitions/kromaSepolia.ts +23 -0
- package/chains/definitions/moonbeamDev.ts +22 -0
- package/chains/definitions/optimismSepolia.ts +39 -0
- package/chains/definitions/sepolia.ts +1 -1
- package/chains/index.ts +6 -1
- package/chains/package.json +6 -0
- package/chains/utils/package.json +6 -0
- package/clients/decorators/public.ts +48 -0
- package/clients/decorators/wallet.ts +1 -1
- package/clients/package.json +6 -0
- package/clients/transports/webSocket.ts +1 -1
- package/{contract.ts → contract/index.ts} +27 -25
- package/contract/package.json +6 -0
- package/{ens.ts → ens/index.ts} +8 -8
- package/ens/package.json +6 -0
- package/errors/version.ts +1 -1
- package/index.ts +4 -0
- package/package.json +32 -31
- package/{public.ts → public/index.ts} +30 -28
- package/public/package.json +6 -0
- package/test/index.ts +85 -0
- package/test/package.json +6 -0
- package/types/contract.ts +1 -1
- package/types/eip1193.ts +5 -3
- package/types/multicall.ts +41 -22
- package/types/typedData.ts +3 -2
- package/types/utils.ts +32 -11
- package/utils/abi/decodeEventLog.ts +2 -2
- package/utils/formatters/transaction.ts +2 -2
- package/utils/hash/getEventSelector.ts +7 -6
- package/utils/hash/getEventSignature.ts +7 -0
- package/utils/hash/getFunctionSelector.ts +7 -5
- package/utils/hash/getFunctionSignature.ts +17 -0
- package/utils/hash/hashFunction.ts +2 -7
- package/utils/package.json +6 -0
- package/utils/rpc.ts +6 -3
- package/{wallet.ts → wallet/index.ts} +15 -10
- package/wallet/package.json +6 -0
- package/window/index.ts +1 -0
- package/window/package.json +6 -0
- package/_cjs/abi.js.map +0 -1
- package/_cjs/contract.js.map +0 -1
- package/_cjs/ens.js.map +0 -1
- package/_cjs/public.js.map +0 -1
- package/_cjs/test.js.map +0 -1
- package/_cjs/wallet.js.map +0 -1
- package/_cjs/window.js.map +0 -1
- package/_esm/abi.js +0 -6
- package/_esm/abi.js.map +0 -1
- package/_esm/contract.js +0 -25
- package/_esm/contract.js.map +0 -1
- package/_esm/ens.js +0 -9
- package/_esm/ens.js.map +0 -1
- package/_esm/public.js +0 -29
- package/_esm/public.js.map +0 -1
- package/_esm/test.js +0 -29
- package/_esm/test.js.map +0 -1
- package/_esm/wallet.js +0 -11
- package/_esm/wallet.js.map +0 -1
- package/_esm/window.js +0 -2
- package/_esm/window.js.map +0 -1
- package/_types/abi.d.ts.map +0 -1
- package/_types/contract.d.ts.map +0 -1
- package/_types/ens.d.ts +0 -9
- package/_types/ens.d.ts.map +0 -1
- package/_types/public.d.ts +0 -33
- package/_types/public.d.ts.map +0 -1
- package/_types/test.d.ts +0 -29
- package/_types/test.d.ts.map +0 -1
- package/_types/wallet.d.ts +0 -11
- package/_types/wallet.d.ts.map +0 -1
- package/_types/window.d.ts +0 -2
- package/_types/window.d.ts.map +0 -1
- package/test.ts +0 -83
- package/window.ts +0 -1
package/_types/utils/rpc.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import
|
1
|
+
import WebSocket from 'isomorphic-ws';
|
2
2
|
type SuccessResult<T> = {
|
3
3
|
method?: never;
|
4
4
|
result: T;
|
@@ -46,8 +46,8 @@ export type Socket = WebSocket & {
|
|
46
46
|
requests: CallbackMap;
|
47
47
|
subscriptions: CallbackMap;
|
48
48
|
};
|
49
|
-
export declare const socketsCache: Map<string,
|
50
|
-
export declare function getSocket(url: string): Promise<
|
49
|
+
export declare const socketsCache: Map<string, any>;
|
50
|
+
export declare function getSocket(url: string): Promise<any>;
|
51
51
|
export type WebSocketOptions = {
|
52
52
|
/** The RPC request body. */
|
53
53
|
body: RpcRequest;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["../../utils/rpc.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["../../utils/rpc.ts"],"names":[],"mappings":"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"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
export { addChain, type AddChainParameters, } from '../actions/wallet/addChain.js';
|
2
|
+
export { getAddresses, type GetAddressesReturnType, } from '../actions/wallet/getAddresses.js';
|
3
|
+
export { getPermissions, type GetPermissionsReturnType, } from '../actions/wallet/getPermissions.js';
|
4
|
+
export { requestAddresses, type RequestAddressesReturnType, } from '../actions/wallet/requestAddresses.js';
|
5
|
+
export { requestPermissions, type RequestPermissionsReturnType, } from '../actions/wallet/requestPermissions.js';
|
6
|
+
export { sendTransaction, type SendTransactionParameters, type SendTransactionReturnType, } from '../actions/wallet/sendTransaction.js';
|
7
|
+
export { signMessage, type SignMessageParameters, type SignMessageReturnType, } from '../actions/wallet/signMessage.js';
|
8
|
+
export { signTypedData, type SignTypedDataParameters, type SignTypedDataReturnType, } from '../actions/wallet/signTypedData.js';
|
9
|
+
export { switchChain, type SwitchChainParameters, } from '../actions/wallet/switchChain.js';
|
10
|
+
export { watchAsset, type WatchAssetParameters, type WatchAssetReturnType, } from '../actions/wallet/watchAsset.js';
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../wallet/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,QAAQ,EACR,KAAK,kBAAkB,GACxB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EACL,YAAY,EACZ,KAAK,sBAAsB,GAC5B,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EACL,cAAc,EACd,KAAK,wBAAwB,GAC9B,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EACL,gBAAgB,EAChB,KAAK,0BAA0B,GAChC,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EACL,kBAAkB,EAClB,KAAK,4BAA4B,GAClC,MAAM,yCAAyC,CAAA;AAChD,OAAO,EACL,eAAe,EACf,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,GAC/B,MAAM,sCAAsC,CAAA;AAC7C,OAAO,EACL,WAAW,EACX,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,GAC3B,MAAM,kCAAkC,CAAA;AACzC,OAAO,EACL,aAAa,EACb,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,GAC7B,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EACL,WAAW,EACX,KAAK,qBAAqB,GAC3B,MAAM,kCAAkC,CAAA;AACzC,OAAO,EACL,UAAU,EACV,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,GAC1B,MAAM,iCAAiC,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../window/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAA"}
|
package/{abi.ts → abi/index.ts}
RENAMED
@@ -1,15 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
decodeAbiParameters,
|
4
|
-
} from './utils/abi/decodeAbiParameters.js'
|
5
|
-
export {
|
6
|
-
type EncodeAbiParametersReturnType,
|
7
|
-
encodeAbiParameters,
|
8
|
-
} from './utils/abi/encodeAbiParameters.js'
|
9
|
-
export {
|
10
|
-
type GetAbiItemParameters,
|
11
|
-
getAbiItem,
|
12
|
-
} from './utils/abi/getAbiItem.js'
|
1
|
+
// TODO(v2): Remove this entrypoint. Favor importing from root entrypoint (`viem`).
|
2
|
+
|
13
3
|
export {
|
14
4
|
type ParseAbi,
|
15
5
|
type ParseAbiItem,
|
@@ -20,4 +10,16 @@ export {
|
|
20
10
|
parseAbiParameter,
|
21
11
|
parseAbiParameters,
|
22
12
|
} from 'abitype'
|
23
|
-
export {
|
13
|
+
export {
|
14
|
+
type DecodeAbiParametersReturnType,
|
15
|
+
decodeAbiParameters,
|
16
|
+
} from '../utils/abi/decodeAbiParameters.js'
|
17
|
+
export {
|
18
|
+
type EncodeAbiParametersReturnType,
|
19
|
+
encodeAbiParameters,
|
20
|
+
} from '../utils/abi/encodeAbiParameters.js'
|
21
|
+
export {
|
22
|
+
type GetAbiItemParameters,
|
23
|
+
getAbiItem,
|
24
|
+
} from '../utils/abi/getAbiItem.js'
|
25
|
+
export { encodePacked } from '../utils/abi/encodePacked.js'
|
package/abi/package.json
ADDED
package/actions/getContract.ts
CHANGED
@@ -41,6 +41,11 @@ import {
|
|
41
41
|
type EstimateContractGasReturnType,
|
42
42
|
estimateContractGas,
|
43
43
|
} from './public/estimateContractGas.js'
|
44
|
+
import {
|
45
|
+
type GetContractEventsParameters,
|
46
|
+
type GetContractEventsReturnType,
|
47
|
+
getContractEvents,
|
48
|
+
} from './public/getContractEvents.js'
|
44
49
|
import {
|
45
50
|
type ReadContractParameters,
|
46
51
|
type ReadContractReturnType,
|
@@ -84,6 +89,7 @@ export type GetContractParameters<
|
|
84
89
|
*
|
85
90
|
* - [`createEventFilter`](https://viem.sh/docs/contract/createContractEventFilter.html)
|
86
91
|
* - [`estimateGas`](https://viem.sh/docs/contract/estimateContractGas.html)
|
92
|
+
* - [`getEvents`](https://viem.sh/docs/contract/getContractEvents.html)
|
87
93
|
* - [`read`](https://viem.sh/docs/contract/readContract.html)
|
88
94
|
* - [`simulate`](https://viem.sh/docs/contract/simulateContract.html)
|
89
95
|
* - [`watchEvent`](https://viem.sh/docs/contract/watchContractEvent.html)
|
@@ -270,6 +276,33 @@ export type GetContractReturnType<
|
|
270
276
|
: never
|
271
277
|
>
|
272
278
|
}
|
279
|
+
/**
|
280
|
+
* Creates a Filter to retrieve event logs that can be used with [`getFilterChanges`](https://viem.sh/docs/actions/public/getFilterChanges.html) or [`getFilterLogs`](https://viem.sh/docs/actions/public/getFilterLogs.html).
|
281
|
+
*
|
282
|
+
* @example
|
283
|
+
* import { createPublicClient, getContract, http, parseAbi } from 'viem'
|
284
|
+
* import { mainnet } from 'viem/chains'
|
285
|
+
*
|
286
|
+
* const publicClient = createPublicClient({
|
287
|
+
* chain: mainnet,
|
288
|
+
* transport: http(),
|
289
|
+
* })
|
290
|
+
* const contract = getContract({
|
291
|
+
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
292
|
+
* abi: parseAbi(['event Transfer(address indexed, address indexed, uint256)']),
|
293
|
+
* publicClient,
|
294
|
+
* })
|
295
|
+
* const filter = await contract.createEventFilter.Transfer()
|
296
|
+
*/
|
297
|
+
getEvents: {
|
298
|
+
[EventName in _EventNames]: GetEventsFunction<
|
299
|
+
_Narrowable,
|
300
|
+
TAbi,
|
301
|
+
EventName extends ContractEventName<TAbi>
|
302
|
+
? EventName
|
303
|
+
: never
|
304
|
+
>
|
305
|
+
}
|
273
306
|
/**
|
274
307
|
* Watches and returns emitted contract event logs.
|
275
308
|
*
|
@@ -450,6 +483,7 @@ export function getContract<
|
|
450
483
|
| 'address'
|
451
484
|
| 'createEventFilter'
|
452
485
|
| 'estimateGas'
|
486
|
+
| 'getEvents'
|
453
487
|
| 'read'
|
454
488
|
| 'simulate'
|
455
489
|
| 'watchEvent'
|
@@ -556,6 +590,37 @@ export function getContract<
|
|
556
590
|
},
|
557
591
|
},
|
558
592
|
)
|
593
|
+
contract.getEvents = new Proxy(
|
594
|
+
{},
|
595
|
+
{
|
596
|
+
get(_, eventName: string) {
|
597
|
+
return (
|
598
|
+
...parameters: [
|
599
|
+
args?: readonly unknown[] | object,
|
600
|
+
options?: Omit<
|
601
|
+
GetContractEventsParameters,
|
602
|
+
'abi' | 'address' | 'eventName'
|
603
|
+
>,
|
604
|
+
]
|
605
|
+
) => {
|
606
|
+
const abiEvent = (abi as readonly AbiEvent[]).find(
|
607
|
+
(x: AbiEvent) => x.type === 'event' && x.name === eventName,
|
608
|
+
)
|
609
|
+
const { args, options } = getEventParameters(
|
610
|
+
parameters,
|
611
|
+
abiEvent!,
|
612
|
+
)
|
613
|
+
return getContractEvents(publicClient, {
|
614
|
+
abi,
|
615
|
+
address,
|
616
|
+
eventName,
|
617
|
+
args,
|
618
|
+
...options,
|
619
|
+
} as unknown as GetContractEventsParameters)
|
620
|
+
}
|
621
|
+
},
|
622
|
+
},
|
623
|
+
)
|
559
624
|
contract.watchEvent = new Proxy(
|
560
625
|
{},
|
561
626
|
{
|
@@ -952,6 +1017,36 @@ type GetEventFilter<
|
|
952
1017
|
]
|
953
1018
|
) => Promise<CreateContractEventFilterReturnType>
|
954
1019
|
|
1020
|
+
type GetEventsFunction<
|
1021
|
+
Narrowable extends boolean,
|
1022
|
+
TAbi extends Abi | readonly unknown[],
|
1023
|
+
TEventName extends ContractEventName<TAbi>,
|
1024
|
+
TAbiEvent extends AbiEvent = TAbi extends Abi
|
1025
|
+
? ExtractAbiEvent<TAbi, TEventName>
|
1026
|
+
: AbiEvent,
|
1027
|
+
Args = AbiEventParametersToPrimitiveTypes<TAbiEvent['inputs']>,
|
1028
|
+
Options = Prettify<
|
1029
|
+
Omit<
|
1030
|
+
GetContractEventsParameters<TAbi, TEventName>,
|
1031
|
+
'abi' | 'address' | 'args' | 'eventName'
|
1032
|
+
>
|
1033
|
+
>,
|
1034
|
+
IndexedInputs = Extract<TAbiEvent['inputs'][number], { indexed: true }>,
|
1035
|
+
> = Narrowable extends true
|
1036
|
+
? (
|
1037
|
+
...parameters: IsNever<IndexedInputs> extends true
|
1038
|
+
? [options?: Options]
|
1039
|
+
: [args?: Args, options?: Options]
|
1040
|
+
) => Promise<GetContractEventsReturnType<TAbi, TEventName>>
|
1041
|
+
: (
|
1042
|
+
...parameters:
|
1043
|
+
| [options?: Options]
|
1044
|
+
| [
|
1045
|
+
args?: readonly unknown[] | WatchContractEventOptions,
|
1046
|
+
options?: Options,
|
1047
|
+
]
|
1048
|
+
) => Promise<GetContractEventsReturnType<TAbi, TEventName>>
|
1049
|
+
|
955
1050
|
type GetWatchEvent<
|
956
1051
|
Narrowable extends boolean,
|
957
1052
|
TAbi extends Abi | readonly unknown[],
|
@@ -35,7 +35,7 @@ export type CreateContractEventFilterParameters<
|
|
35
35
|
* Whether or not the logs must match the indexed/non-indexed arguments in the event ABI item.
|
36
36
|
* @default false
|
37
37
|
*/
|
38
|
-
strict?: strict
|
38
|
+
strict?: strict | boolean | undefined
|
39
39
|
toBlock?: toBlock | BlockNumber | BlockTag
|
40
40
|
} & (undefined extends eventName
|
41
41
|
? {
|
@@ -106,10 +106,11 @@ export async function internal_estimateFeesPerGas<
|
|
106
106
|
})()
|
107
107
|
if (baseFeeMultiplier < 1) throw new BaseFeeScalarError()
|
108
108
|
|
109
|
-
const decimals = baseFeeMultiplier.toString().split('.')[1]
|
109
|
+
const decimals = baseFeeMultiplier.toString().split('.')[1]?.length ?? 0
|
110
110
|
const denominator = 10 ** decimals
|
111
111
|
const multiply = (base: bigint) =>
|
112
|
-
(base * BigInt(baseFeeMultiplier * denominator)) /
|
112
|
+
(base * BigInt(Math.ceil(baseFeeMultiplier * denominator))) /
|
113
|
+
BigInt(denominator)
|
113
114
|
|
114
115
|
const block = block_ ? block_ : await getBlock(client)
|
115
116
|
|
@@ -0,0 +1,155 @@
|
|
1
|
+
import type { Abi, Address } from 'abitype'
|
2
|
+
|
3
|
+
import type { Client } from '../../clients/createClient.js'
|
4
|
+
import type { Transport } from '../../clients/transports/createTransport.js'
|
5
|
+
import type { BlockNumber, BlockTag } from '../../types/block.js'
|
6
|
+
import type { Chain } from '../../types/chain.js'
|
7
|
+
import type {
|
8
|
+
ContractEventArgs,
|
9
|
+
ContractEventName,
|
10
|
+
} from '../../types/contract.js'
|
11
|
+
import type { Log } from '../../types/log.js'
|
12
|
+
import type { Hash } from '../../types/misc.js'
|
13
|
+
import {
|
14
|
+
type GetAbiItemParameters,
|
15
|
+
getAbiItem,
|
16
|
+
} from '../../utils/abi/getAbiItem.js'
|
17
|
+
import { getLogs } from './getLogs.js'
|
18
|
+
import type { GetLogsParameters } from './getLogs.js'
|
19
|
+
|
20
|
+
export type GetContractEventsParameters<
|
21
|
+
abi extends Abi | readonly unknown[] = Abi,
|
22
|
+
eventName extends ContractEventName<abi> | undefined =
|
23
|
+
| ContractEventName<abi>
|
24
|
+
| undefined,
|
25
|
+
strict extends boolean | undefined = undefined,
|
26
|
+
fromBlock extends BlockNumber | BlockTag | undefined = undefined,
|
27
|
+
toBlock extends BlockNumber | BlockTag | undefined = undefined,
|
28
|
+
> = {
|
29
|
+
/** The address of the contract. */
|
30
|
+
address?: Address | Address[]
|
31
|
+
/** Contract ABI. */
|
32
|
+
abi: abi
|
33
|
+
args?:
|
34
|
+
| ContractEventArgs<
|
35
|
+
abi,
|
36
|
+
eventName extends ContractEventName<abi>
|
37
|
+
? eventName
|
38
|
+
: ContractEventName<abi>
|
39
|
+
>
|
40
|
+
| undefined
|
41
|
+
/** Contract event. */
|
42
|
+
eventName?: eventName | ContractEventName<abi> | undefined
|
43
|
+
/**
|
44
|
+
* Whether or not the logs must match the indexed/non-indexed arguments on `event`.
|
45
|
+
* @default false
|
46
|
+
*/
|
47
|
+
strict?: strict | boolean | undefined
|
48
|
+
} & (
|
49
|
+
| {
|
50
|
+
/** Block number or tag after which to include logs */
|
51
|
+
fromBlock?: fromBlock | BlockNumber | BlockTag
|
52
|
+
/** Block number or tag before which to include logs */
|
53
|
+
toBlock?: toBlock | BlockNumber | BlockTag
|
54
|
+
blockHash?: undefined
|
55
|
+
}
|
56
|
+
| {
|
57
|
+
fromBlock?: undefined
|
58
|
+
toBlock?: undefined
|
59
|
+
/** Hash of block to include logs from */
|
60
|
+
blockHash?: Hash
|
61
|
+
}
|
62
|
+
)
|
63
|
+
|
64
|
+
export type GetContractEventsReturnType<
|
65
|
+
abi extends Abi | readonly unknown[] = readonly unknown[],
|
66
|
+
eventName extends ContractEventName<abi> | undefined =
|
67
|
+
| ContractEventName<abi>
|
68
|
+
| undefined,
|
69
|
+
strict extends boolean | undefined = undefined,
|
70
|
+
fromBlock extends BlockNumber | BlockTag | undefined = undefined,
|
71
|
+
toBlock extends BlockNumber | BlockTag | undefined = undefined,
|
72
|
+
///
|
73
|
+
isPending extends boolean =
|
74
|
+
| (fromBlock extends 'pending' ? true : false)
|
75
|
+
| (toBlock extends 'pending' ? true : false),
|
76
|
+
> = Log<bigint, number, isPending, undefined, strict, abi, eventName>[]
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Returns a list of event logs emitted by a contract.
|
80
|
+
*
|
81
|
+
* - Docs: https://viem.sh/docs/actions/public/getContractEvents.html
|
82
|
+
* - JSON-RPC Methods: [`eth_getLogs`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getlogs)
|
83
|
+
*
|
84
|
+
* @param client - Client to use
|
85
|
+
* @param parameters - {@link GetContractEventsParameters}
|
86
|
+
* @returns A list of event logs. {@link GetContractEventsReturnType}
|
87
|
+
*
|
88
|
+
* @example
|
89
|
+
* import { createClient, http } from 'viem'
|
90
|
+
* import { mainnet } from 'viem/chains'
|
91
|
+
* import { getContractEvents } from 'viem/public'
|
92
|
+
* import { wagmiAbi } from './abi'
|
93
|
+
*
|
94
|
+
* const client = createClient({
|
95
|
+
* chain: mainnet,
|
96
|
+
* transport: http(),
|
97
|
+
* })
|
98
|
+
* const logs = await getContractEvents(client, {
|
99
|
+
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
100
|
+
* abi: wagmiAbi,
|
101
|
+
* eventName: 'Transfer'
|
102
|
+
* })
|
103
|
+
*/
|
104
|
+
export async function getContractEvents<
|
105
|
+
chain extends Chain | undefined,
|
106
|
+
const abi extends Abi | readonly unknown[],
|
107
|
+
eventName extends ContractEventName<abi> | undefined = undefined,
|
108
|
+
TStrict extends boolean | undefined = undefined,
|
109
|
+
TFromBlock extends BlockNumber | BlockTag | undefined = undefined,
|
110
|
+
TToBlock extends BlockNumber | BlockTag | undefined = undefined,
|
111
|
+
>(
|
112
|
+
client: Client<Transport, chain>,
|
113
|
+
parameters: GetContractEventsParameters<
|
114
|
+
abi,
|
115
|
+
eventName,
|
116
|
+
TStrict,
|
117
|
+
TFromBlock,
|
118
|
+
TToBlock
|
119
|
+
>,
|
120
|
+
): Promise<
|
121
|
+
GetContractEventsReturnType<abi, eventName, TStrict, TFromBlock, TToBlock>
|
122
|
+
> {
|
123
|
+
const {
|
124
|
+
abi,
|
125
|
+
address,
|
126
|
+
args,
|
127
|
+
blockHash,
|
128
|
+
eventName,
|
129
|
+
fromBlock,
|
130
|
+
toBlock,
|
131
|
+
strict,
|
132
|
+
} = parameters
|
133
|
+
const event = eventName
|
134
|
+
? getAbiItem({ abi, name: eventName } as GetAbiItemParameters)
|
135
|
+
: undefined
|
136
|
+
const events = !event
|
137
|
+
? (abi as Abi).filter((x) => x.type === 'event')
|
138
|
+
: undefined
|
139
|
+
return getLogs(client, {
|
140
|
+
address,
|
141
|
+
args,
|
142
|
+
blockHash,
|
143
|
+
event,
|
144
|
+
events,
|
145
|
+
fromBlock,
|
146
|
+
toBlock,
|
147
|
+
strict,
|
148
|
+
} as {} as GetLogsParameters) as unknown as GetContractEventsReturnType<
|
149
|
+
abi,
|
150
|
+
eventName,
|
151
|
+
TStrict,
|
152
|
+
TFromBlock,
|
153
|
+
TToBlock
|
154
|
+
>
|
155
|
+
}
|
@@ -28,7 +28,7 @@ export type MulticallParameters<
|
|
28
28
|
properties?: Record<string, any>
|
29
29
|
} = {},
|
30
30
|
> = Pick<CallParameters, 'blockNumber' | 'blockTag'> & {
|
31
|
-
allowFailure?: allowFailure | undefined
|
31
|
+
allowFailure?: allowFailure | boolean | undefined
|
32
32
|
batchSize?: number | undefined
|
33
33
|
contracts: MulticallContracts<
|
34
34
|
Narrow<contracts>,
|
@@ -254,5 +254,5 @@ export async function multicall<
|
|
254
254
|
|
255
255
|
if (results.length !== contracts.length)
|
256
256
|
throw new BaseError('multicall results mismatch')
|
257
|
-
return results as
|
257
|
+
return results as MulticallReturnType<contracts, allowFailure>
|
258
258
|
}
|
@@ -10,6 +10,7 @@ import type {
|
|
10
10
|
ContractFunctionParameters,
|
11
11
|
ContractFunctionReturnType,
|
12
12
|
} from '../../types/contract.js'
|
13
|
+
import type { UnionEvaluate } from '../../types/utils.js'
|
13
14
|
import { decodeFunctionResult } from '../../utils/abi/decodeFunctionResult.js'
|
14
15
|
import { encodeFunctionData } from '../../utils/abi/encodeFunctionData.js'
|
15
16
|
import { getContractError } from '../../utils/errors/getContractError.js'
|
@@ -26,7 +27,9 @@ export type ReadContractParameters<
|
|
26
27
|
'pure' | 'view',
|
27
28
|
functionName
|
28
29
|
> = ContractFunctionArgs<abi, 'pure' | 'view', functionName>,
|
29
|
-
> =
|
30
|
+
> = UnionEvaluate<
|
31
|
+
Pick<CallParameters, 'account' | 'blockNumber' | 'blockTag'>
|
32
|
+
> &
|
30
33
|
ContractFunctionParameters<abi, 'pure' | 'view', functionName, args>
|
31
34
|
|
32
35
|
export type ReadContractReturnType<
|
@@ -146,7 +146,11 @@ export async function waitForTransactionReceipt<
|
|
146
146
|
// If we already have a valid receipt, let's check if we have enough
|
147
147
|
// confirmations. If we do, then we can resolve.
|
148
148
|
if (receipt) {
|
149
|
-
if (
|
149
|
+
if (
|
150
|
+
confirmations > 1 &&
|
151
|
+
(!receipt.blockNumber ||
|
152
|
+
blockNumber - receipt.blockNumber + 1n < confirmations)
|
153
|
+
)
|
150
154
|
return
|
151
155
|
|
152
156
|
done(() => emit.resolve(receipt))
|
@@ -178,8 +182,9 @@ export async function waitForTransactionReceipt<
|
|
178
182
|
|
179
183
|
// Check if we have enough confirmations. If not, continue polling.
|
180
184
|
if (
|
181
|
-
confirmations >
|
182
|
-
|
185
|
+
confirmations > 1 &&
|
186
|
+
(!receipt.blockNumber ||
|
187
|
+
blockNumber - receipt.blockNumber + 1n < confirmations)
|
183
188
|
)
|
184
189
|
return
|
185
190
|
|
@@ -218,7 +223,11 @@ export async function waitForTransactionReceipt<
|
|
218
223
|
})
|
219
224
|
|
220
225
|
// Check if we have enough confirmations. If not, continue polling.
|
221
|
-
if (
|
226
|
+
if (
|
227
|
+
confirmations > 1 &&
|
228
|
+
(!receipt.blockNumber ||
|
229
|
+
blockNumber - receipt.blockNumber + 1n < confirmations)
|
230
|
+
)
|
222
231
|
return
|
223
232
|
|
224
233
|
let reason: ReplacementReason = 'replaced'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { Abi,
|
1
|
+
import type { Abi, 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'
|
@@ -21,18 +21,17 @@ import {
|
|
21
21
|
type EncodeEventTopicsParameters,
|
22
22
|
encodeEventTopics,
|
23
23
|
} from '../../utils/abi/encodeEventTopics.js'
|
24
|
-
import {
|
25
|
-
type GetAbiItemParameters,
|
26
|
-
getAbiItem,
|
27
|
-
} from '../../utils/abi/getAbiItem.js'
|
28
24
|
import { formatLog } from '../../utils/formatters/log.js'
|
29
25
|
import { observe } from '../../utils/observe.js'
|
30
26
|
import { poll } from '../../utils/poll.js'
|
31
27
|
import { stringify } from '../../utils/stringify.js'
|
32
28
|
import { createContractEventFilter } from './createContractEventFilter.js'
|
33
29
|
import { getBlockNumber } from './getBlockNumber.js'
|
30
|
+
import {
|
31
|
+
type GetContractEventsParameters,
|
32
|
+
getContractEvents,
|
33
|
+
} from './getContractEvents.js'
|
34
34
|
import { getFilterChanges } from './getFilterChanges.js'
|
35
|
-
import { getLogs } from './getLogs.js'
|
36
35
|
import { uninstallFilter } from './uninstallFilter.js'
|
37
36
|
|
38
37
|
export type WatchContractEventOnLogsParameter<
|
@@ -85,7 +84,7 @@ export type WatchContractEventParameters<
|
|
85
84
|
* Whether or not the logs must match the indexed/non-indexed arguments on `event`.
|
86
85
|
* @default false
|
87
86
|
*/
|
88
|
-
strict?: strict | undefined
|
87
|
+
strict?: strict | boolean | undefined
|
89
88
|
} & GetPollOptions<transport>
|
90
89
|
|
91
90
|
export type WatchContractEventReturnType = () => void
|
@@ -194,16 +193,14 @@ export function watchContractEvent<
|
|
194
193
|
// If the block number doesn't exist, we are yet to reach the first poll interval,
|
195
194
|
// so do not emit any logs.
|
196
195
|
if (previousBlockNumber && previousBlockNumber !== blockNumber) {
|
197
|
-
logs = await
|
196
|
+
logs = await getContractEvents(client, {
|
197
|
+
abi,
|
198
198
|
address,
|
199
199
|
args: args as any,
|
200
200
|
fromBlock: previousBlockNumber + 1n,
|
201
201
|
toBlock: blockNumber,
|
202
|
-
|
203
|
-
|
204
|
-
name: eventName,
|
205
|
-
} as unknown as GetAbiItemParameters) as AbiEvent,
|
206
|
-
})
|
202
|
+
strict,
|
203
|
+
} as {} as GetContractEventsParameters)
|
207
204
|
} else {
|
208
205
|
logs = []
|
209
206
|
}
|
@@ -20,8 +20,10 @@ export type SignTypedDataParameters<
|
|
20
20
|
typedData extends TypedData | Record<string, unknown> = TypedData,
|
21
21
|
primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData,
|
22
22
|
account extends Account | undefined = undefined,
|
23
|
-
|
24
|
-
|
23
|
+
///
|
24
|
+
primaryTypes = typedData extends TypedData ? keyof typedData : string,
|
25
|
+
> = TypedDataDefinition<typedData, primaryType, primaryTypes> &
|
26
|
+
GetAccountParameter<account>
|
25
27
|
|
26
28
|
export type SignTypedDataReturnType = Hex
|
27
29
|
|
@@ -12,7 +12,7 @@ import type {
|
|
12
12
|
GetValue,
|
13
13
|
} from '../../types/contract.js'
|
14
14
|
import type { Hex } from '../../types/misc.js'
|
15
|
-
import type { UnionOmit } from '../../types/utils.js'
|
15
|
+
import type { Prettify, UnionEvaluate, UnionOmit } from '../../types/utils.js'
|
16
16
|
import { encodeFunctionData } from '../../utils/abi/encodeFunctionData.js'
|
17
17
|
import type { FormattedTransactionRequest } from '../../utils/formatters/transactionRequest.js'
|
18
18
|
import {
|
@@ -35,34 +35,41 @@ export type WriteContractParameters<
|
|
35
35
|
chain extends Chain | undefined = Chain,
|
36
36
|
account extends Account | undefined = Account | undefined,
|
37
37
|
chainOverride extends Chain | undefined = Chain | undefined,
|
38
|
+
///
|
39
|
+
allFunctionNames = ContractFunctionName<abi, 'nonpayable' | 'payable'>,
|
38
40
|
> = ContractFunctionParameters<
|
39
41
|
abi,
|
40
42
|
'nonpayable' | 'payable',
|
41
43
|
functionName,
|
42
|
-
args
|
44
|
+
args,
|
45
|
+
allFunctionNames
|
43
46
|
> &
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
47
|
+
Prettify<
|
48
|
+
GetAccountParameter<account> &
|
49
|
+
GetChain<chain, chainOverride> &
|
50
|
+
GetValue<
|
51
|
+
abi,
|
52
|
+
functionName,
|
53
|
+
SendTransactionParameters<
|
54
|
+
chain,
|
55
|
+
account,
|
56
|
+
chainOverride
|
57
|
+
> extends SendTransactionParameters
|
58
|
+
? SendTransactionParameters<chain, account, chainOverride>['value']
|
59
|
+
: SendTransactionParameters['value']
|
60
|
+
> & {
|
61
|
+
/** Data to append to the end of the calldata. Useful for adding a ["domain" tag](https://opensea.notion.site/opensea/Seaport-Order-Attributions-ec2d69bf455041a5baa490941aad307f). */
|
62
|
+
dataSuffix?: Hex
|
63
|
+
}
|
49
64
|
> &
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
chainOverride
|
59
|
-
> extends SendTransactionParameters
|
60
|
-
? SendTransactionParameters<chain, account, chainOverride>['value']
|
61
|
-
: SendTransactionParameters['value']
|
62
|
-
> & {
|
63
|
-
/** Data to append to the end of the calldata. Useful for adding a ["domain" tag](https://opensea.notion.site/opensea/Seaport-Order-Attributions-ec2d69bf455041a5baa490941aad307f). */
|
64
|
-
dataSuffix?: Hex
|
65
|
-
}
|
65
|
+
UnionEvaluate<
|
66
|
+
UnionOmit<
|
67
|
+
FormattedTransactionRequest<
|
68
|
+
chainOverride extends Chain ? chainOverride : chain
|
69
|
+
>,
|
70
|
+
'data' | 'from' | 'to' | 'value'
|
71
|
+
>
|
72
|
+
>
|
66
73
|
|
67
74
|
export type WriteContractReturnType = SendTransactionReturnType
|
68
75
|
|