viem 2.13.8 → 2.13.10
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +24 -0
- package/_cjs/actions/index.js +4 -2
- package/_cjs/actions/index.js.map +1 -1
- package/_cjs/actions/public/getEip712Domain.js +54 -0
- package/_cjs/actions/public/getEip712Domain.js.map +1 -0
- package/_cjs/celo/formatters.js +1 -2
- package/_cjs/celo/formatters.js.map +1 -1
- package/_cjs/chains/definitions/ham.js +27 -0
- package/_cjs/chains/definitions/ham.js.map +1 -0
- package/_cjs/chains/definitions/kakarotSepolia.js +1 -1
- package/_cjs/chains/definitions/kakarotSepolia.js.map +1 -1
- package/_cjs/chains/definitions/redbellyTestnet.js +27 -0
- package/_cjs/chains/definitions/redbellyTestnet.js.map +1 -0
- package/_cjs/chains/definitions/xai.js +28 -0
- package/_cjs/chains/definitions/xai.js.map +1 -0
- package/_cjs/chains/definitions/xaiTestnet.js +22 -0
- package/_cjs/chains/definitions/xaiTestnet.js.map +1 -0
- package/_cjs/chains/index.js +12 -4
- 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/errors/base.js +1 -1
- package/_cjs/errors/base.js.map +1 -1
- package/_cjs/errors/eip712.js +24 -0
- package/_cjs/errors/eip712.js.map +1 -0
- package/_cjs/errors/version.js +1 -1
- package/_cjs/errors/version.js.map +1 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/op-stack/actions/estimateDepositTransactionGas.js +4 -3
- package/_cjs/op-stack/actions/estimateDepositTransactionGas.js.map +1 -1
- package/_cjs/op-stack/actions/estimateFinalizeWithdrawalGas.js +4 -3
- package/_cjs/op-stack/actions/estimateFinalizeWithdrawalGas.js.map +1 -1
- package/_cjs/op-stack/actions/estimateInitiateWithdrawalGas.js +4 -3
- package/_cjs/op-stack/actions/estimateInitiateWithdrawalGas.js.map +1 -1
- package/_cjs/op-stack/actions/estimateProveWithdrawalGas.js +4 -3
- package/_cjs/op-stack/actions/estimateProveWithdrawalGas.js.map +1 -1
- package/_cjs/utils/abi/encodeDeployData.js.map +1 -1
- package/_cjs/utils/transaction/serializeTransaction.js +8 -5
- package/_cjs/utils/transaction/serializeTransaction.js.map +1 -1
- package/_cjs/zksync/actions/sendEip712Transaction.js +7 -7
- package/_cjs/zksync/actions/sendEip712Transaction.js.map +1 -1
- package/_cjs/zksync/actions/sendTransaction.js +4 -4
- package/_cjs/zksync/actions/sendTransaction.js.map +1 -1
- package/_cjs/zksync/decorators/eip712.js.map +1 -1
- package/_esm/actions/index.js +1 -0
- package/_esm/actions/index.js.map +1 -1
- package/_esm/actions/public/getEip712Domain.js +82 -0
- package/_esm/actions/public/getEip712Domain.js.map +1 -0
- package/_esm/celo/formatters.js +1 -2
- package/_esm/celo/formatters.js.map +1 -1
- package/_esm/chains/definitions/ham.js +24 -0
- package/_esm/chains/definitions/ham.js.map +1 -0
- package/_esm/chains/definitions/kakarotSepolia.js +1 -1
- package/_esm/chains/definitions/kakarotSepolia.js.map +1 -1
- package/_esm/chains/definitions/redbellyTestnet.js +24 -0
- package/_esm/chains/definitions/redbellyTestnet.js.map +1 -0
- package/_esm/chains/definitions/xai.js +25 -0
- package/_esm/chains/definitions/xai.js.map +1 -0
- package/_esm/chains/definitions/xaiTestnet.js +19 -0
- package/_esm/chains/definitions/xaiTestnet.js.map +1 -0
- package/_esm/chains/index.js +4 -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/errors/base.js +1 -1
- package/_esm/errors/base.js.map +1 -1
- package/_esm/errors/eip712.js +20 -0
- package/_esm/errors/eip712.js.map +1 -0
- package/_esm/errors/version.js +1 -1
- package/_esm/errors/version.js.map +1 -1
- package/_esm/index.js +1 -0
- package/_esm/index.js.map +1 -1
- package/_esm/op-stack/actions/estimateDepositTransactionGas.js +7 -3
- package/_esm/op-stack/actions/estimateDepositTransactionGas.js.map +1 -1
- package/_esm/op-stack/actions/estimateFinalizeWithdrawalGas.js +7 -3
- package/_esm/op-stack/actions/estimateFinalizeWithdrawalGas.js.map +1 -1
- package/_esm/op-stack/actions/estimateInitiateWithdrawalGas.js +7 -3
- package/_esm/op-stack/actions/estimateInitiateWithdrawalGas.js.map +1 -1
- package/_esm/op-stack/actions/estimateProveWithdrawalGas.js +7 -3
- package/_esm/op-stack/actions/estimateProveWithdrawalGas.js.map +1 -1
- package/_esm/utils/abi/encodeDeployData.js.map +1 -1
- package/_esm/utils/transaction/serializeTransaction.js +8 -5
- package/_esm/utils/transaction/serializeTransaction.js.map +1 -1
- package/_esm/zksync/actions/sendEip712Transaction.js +7 -7
- package/_esm/zksync/actions/sendEip712Transaction.js.map +1 -1
- package/_esm/zksync/actions/sendTransaction.js +6 -6
- package/_esm/zksync/actions/sendTransaction.js.map +1 -1
- package/_esm/zksync/decorators/eip712.js.map +1 -1
- package/_types/actions/index.d.ts +1 -0
- package/_types/actions/index.d.ts.map +1 -1
- package/_types/actions/public/getEip712Domain.d.ts +50 -0
- package/_types/actions/public/getEip712Domain.d.ts.map +1 -0
- package/_types/celo/formatters.d.ts.map +1 -1
- package/_types/chains/definitions/ham.d.ts +37 -0
- package/_types/chains/definitions/ham.d.ts.map +1 -0
- package/_types/chains/definitions/kakarotSepolia.d.ts +1 -1
- package/_types/chains/definitions/redbellyTestnet.d.ts +36 -0
- package/_types/chains/definitions/redbellyTestnet.d.ts.map +1 -0
- package/_types/chains/definitions/xai.d.ts +33 -0
- package/_types/chains/definitions/xai.d.ts.map +1 -0
- package/_types/chains/definitions/xaiTestnet.d.ts +35 -0
- package/_types/chains/definitions/xaiTestnet.d.ts.map +1 -0
- package/_types/chains/index.d.ts +4 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/clients/decorators/public.d.ts +34 -0
- package/_types/clients/decorators/public.d.ts.map +1 -1
- package/_types/errors/base.d.ts +1 -0
- package/_types/errors/base.d.ts.map +1 -1
- package/_types/errors/eip712.d.ts +12 -0
- package/_types/errors/eip712.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 +1 -0
- package/_types/index.d.ts.map +1 -1
- package/_types/op-stack/actions/estimateDepositTransactionGas.d.ts +2 -2
- package/_types/op-stack/actions/estimateDepositTransactionGas.d.ts.map +1 -1
- package/_types/op-stack/actions/estimateFinalizeWithdrawalGas.d.ts +1 -1
- package/_types/op-stack/actions/estimateFinalizeWithdrawalGas.d.ts.map +1 -1
- package/_types/op-stack/actions/estimateInitiateWithdrawalGas.d.ts +1 -1
- package/_types/op-stack/actions/estimateInitiateWithdrawalGas.d.ts.map +1 -1
- package/_types/op-stack/actions/estimateProveWithdrawalGas.d.ts +1 -1
- package/_types/op-stack/actions/estimateProveWithdrawalGas.d.ts.map +1 -1
- package/_types/types/chain.d.ts +7 -7
- package/_types/types/chain.d.ts.map +1 -1
- package/_types/utils/abi/encodeDeployData.d.ts +4 -2
- package/_types/utils/abi/encodeDeployData.d.ts.map +1 -1
- package/_types/utils/transaction/serializeTransaction.d.ts +1 -1
- package/_types/utils/transaction/serializeTransaction.d.ts.map +1 -1
- package/_types/zksync/actions/sendEip712Transaction.d.ts +3 -3
- package/_types/zksync/actions/sendEip712Transaction.d.ts.map +1 -1
- package/_types/zksync/actions/sendTransaction.d.ts +5 -5
- package/_types/zksync/actions/sendTransaction.d.ts.map +1 -1
- package/_types/zksync/decorators/eip712.d.ts +2 -1
- package/_types/zksync/decorators/eip712.d.ts.map +1 -1
- package/_types/zksync/types/chain.d.ts +2 -2
- package/_types/zksync/types/chain.d.ts.map +1 -1
- package/actions/index.ts +6 -0
- package/actions/public/getEip712Domain.ts +124 -0
- package/celo/formatters.ts +1 -3
- package/chains/definitions/ham.ts +24 -0
- package/chains/definitions/kakarotSepolia.ts +1 -1
- package/chains/definitions/redbellyTestnet.ts +24 -0
- package/chains/definitions/xai.ts +25 -0
- package/chains/definitions/xaiTestnet.ts +19 -0
- package/chains/index.ts +4 -0
- package/clients/decorators/public.ts +42 -1
- package/clients/decorators/wallet.ts +1 -1
- package/errors/base.ts +2 -1
- package/errors/eip712.ts +19 -0
- package/errors/version.ts +1 -1
- package/index.ts +5 -0
- package/op-stack/actions/estimateDepositTransactionGas.ts +18 -7
- package/op-stack/actions/estimateFinalizeWithdrawalGas.ts +11 -4
- package/op-stack/actions/estimateInitiateWithdrawalGas.ts +11 -4
- package/op-stack/actions/estimateProveWithdrawalGas.ts +11 -4
- package/package.json +1 -1
- package/types/chain.ts +7 -7
- package/utils/abi/encodeDeployData.ts +6 -5
- package/utils/transaction/serializeTransaction.ts +11 -5
- package/zksync/actions/sendEip712Transaction.ts +27 -16
- package/zksync/actions/sendTransaction.ts +34 -18
- package/zksync/decorators/eip712.ts +7 -2
- package/zksync/types/chain.ts +9 -9
@@ -0,0 +1,24 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
export const ham = /*#__PURE__*/ defineChain({
|
4
|
+
id: 5112,
|
5
|
+
name: 'Ham',
|
6
|
+
nativeCurrency: {
|
7
|
+
decimals: 18,
|
8
|
+
name: 'Ham',
|
9
|
+
symbol: 'ETH',
|
10
|
+
},
|
11
|
+
rpcUrls: {
|
12
|
+
default: {
|
13
|
+
http: ['https://rpc.ham.fun'],
|
14
|
+
webSocket: ['wss://rpc.ham.fun'],
|
15
|
+
},
|
16
|
+
},
|
17
|
+
blockExplorers: {
|
18
|
+
default: {
|
19
|
+
name: 'Ham Chain Explorer',
|
20
|
+
url: 'https://explorer.ham.fun',
|
21
|
+
apiUrl: 'https://explorer.ham.fun/api/v2',
|
22
|
+
},
|
23
|
+
},
|
24
|
+
})
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
export const redbellyTestnet = /*#__PURE__*/ defineChain({
|
4
|
+
id: 153,
|
5
|
+
name: 'Redbelly Network Testnet',
|
6
|
+
nativeCurrency: {
|
7
|
+
name: 'Redbelly Native Coin',
|
8
|
+
symbol: 'RBNT',
|
9
|
+
decimals: 18,
|
10
|
+
},
|
11
|
+
rpcUrls: {
|
12
|
+
default: {
|
13
|
+
http: ['https://governors.testnet.redbelly.network'],
|
14
|
+
},
|
15
|
+
},
|
16
|
+
blockExplorers: {
|
17
|
+
default: {
|
18
|
+
name: 'Ethernal',
|
19
|
+
url: 'https://explorer.testnet.redbelly.network',
|
20
|
+
apiUrl: 'https://ethernal.fly.dev/api',
|
21
|
+
},
|
22
|
+
},
|
23
|
+
testnet: true,
|
24
|
+
})
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
export const xai = /*#__PURE__*/ defineChain({
|
4
|
+
id: 660279,
|
5
|
+
name: 'Xai Mainnet',
|
6
|
+
nativeCurrency: { name: 'Xai', symbol: 'XAI', decimals: 18 },
|
7
|
+
rpcUrls: {
|
8
|
+
default: {
|
9
|
+
http: ['https://xai-chain.net/rpc'],
|
10
|
+
},
|
11
|
+
},
|
12
|
+
blockExplorers: {
|
13
|
+
default: {
|
14
|
+
name: 'Blockscout',
|
15
|
+
url: 'https://explorer.xai-chain.net',
|
16
|
+
},
|
17
|
+
},
|
18
|
+
contracts: {
|
19
|
+
multicall3: {
|
20
|
+
address: '0xca11bde05977b3631167028862be2a173976ca11',
|
21
|
+
blockCreated: 222549,
|
22
|
+
},
|
23
|
+
},
|
24
|
+
testnet: false,
|
25
|
+
})
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
export const xaiTestnet = /*#__PURE__*/ defineChain({
|
4
|
+
id: 37714555429,
|
5
|
+
name: 'Xai Testnet',
|
6
|
+
nativeCurrency: { name: 'sXai', symbol: 'sXAI', decimals: 18 },
|
7
|
+
rpcUrls: {
|
8
|
+
default: {
|
9
|
+
http: ['https://testnet-v2.xai-chain.net/rpc'],
|
10
|
+
},
|
11
|
+
},
|
12
|
+
blockExplorers: {
|
13
|
+
default: {
|
14
|
+
name: 'Blockscout',
|
15
|
+
url: 'https://testnet-explorer-v2.xai-chain.net',
|
16
|
+
},
|
17
|
+
},
|
18
|
+
testnet: true,
|
19
|
+
})
|
package/chains/index.ts
CHANGED
@@ -108,6 +108,7 @@ export { gobi } from './definitions/gobi.js'
|
|
108
108
|
export { goerli } from './definitions/goerli.js'
|
109
109
|
export { gnosis } from './definitions/gnosis.js'
|
110
110
|
export { gnosisChiado } from './definitions/gnosisChiado.js'
|
111
|
+
export { ham } from './definitions/ham.js'
|
111
112
|
export { hardhat } from './definitions/hardhat.js'
|
112
113
|
export { harmonyOne } from './definitions/harmonyOne.js'
|
113
114
|
export { haqqMainnet } from './definitions/haqqMainnet.js'
|
@@ -202,6 +203,7 @@ export { pulsechain } from './definitions/pulsechain.js'
|
|
202
203
|
export { pulsechainV4 } from './definitions/pulsechainV4.js'
|
203
204
|
export { qMainnet } from './definitions/qMainnet.js'
|
204
205
|
export { qTestnet } from './definitions/qTestnet.js'
|
206
|
+
export { redbellyTestnet } from './definitions/redbellyTestnet.js'
|
205
207
|
export { redstone } from './definitions/redstone.js'
|
206
208
|
export { reyaNetwork } from './definitions/reyaNetwork.js'
|
207
209
|
export { rollux } from './definitions/rollux.js'
|
@@ -269,6 +271,8 @@ export {
|
|
269
271
|
x1Testnet,
|
270
272
|
} from './definitions/xLayerTestnet.js'
|
271
273
|
export { xLayer } from './definitions/xLayer.js'
|
274
|
+
export { xai } from './definitions/xai.js'
|
275
|
+
export { xaiTestnet } from './definitions/xaiTestnet.js'
|
272
276
|
export { xdc } from './definitions/xdc.js'
|
273
277
|
export { xdcTestnet } from './definitions/xdcTestnet.js'
|
274
278
|
export { yooldoVerse } from './definitions/yooldoVerse.js'
|
@@ -106,6 +106,11 @@ import {
|
|
106
106
|
type GetContractEventsReturnType,
|
107
107
|
getContractEvents,
|
108
108
|
} from '../../actions/public/getContractEvents.js'
|
109
|
+
import {
|
110
|
+
type GetEip712DomainParameters,
|
111
|
+
type GetEip712DomainReturnType,
|
112
|
+
getEip712Domain,
|
113
|
+
} from '../../actions/public/getEip712Domain.js'
|
109
114
|
import {
|
110
115
|
type GetFeeHistoryParameters,
|
111
116
|
type GetFeeHistoryReturnType,
|
@@ -703,6 +708,41 @@ export type PublicActions<
|
|
703
708
|
) => Promise<
|
704
709
|
GetContractEventsReturnType<abi, eventName, strict, fromBlock, toBlock>
|
705
710
|
>
|
711
|
+
/**
|
712
|
+
* Reads the EIP-712 domain from a contract, based on the ERC-5267 specification.
|
713
|
+
*
|
714
|
+
* @param client - A {@link Client} instance.
|
715
|
+
* @param parameters - The parameters of the action. {@link GetEip712DomainParameters}
|
716
|
+
* @returns The EIP-712 domain, fields, and extensions. {@link GetEip712DomainReturnType}
|
717
|
+
*
|
718
|
+
* @example
|
719
|
+
* ```ts
|
720
|
+
* import { createPublicClient, http } from 'viem'
|
721
|
+
* import { mainnet } from 'viem/chains'
|
722
|
+
*
|
723
|
+
* const client = createPublicClient({
|
724
|
+
* chain: mainnet,
|
725
|
+
* transport: http(),
|
726
|
+
* })
|
727
|
+
*
|
728
|
+
* const domain = await client.getEip712Domain({
|
729
|
+
* address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
730
|
+
* })
|
731
|
+
* // {
|
732
|
+
* // domain: {
|
733
|
+
* // name: 'ExampleContract',
|
734
|
+
* // version: '1',
|
735
|
+
* // chainId: 1,
|
736
|
+
* // verifyingContract: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
737
|
+
* // },
|
738
|
+
* // fields: '0x0f',
|
739
|
+
* // extensions: [],
|
740
|
+
* // }
|
741
|
+
* ```
|
742
|
+
*/
|
743
|
+
getEip712Domain: (
|
744
|
+
args: GetEip712DomainParameters,
|
745
|
+
) => Promise<GetEip712DomainReturnType>
|
706
746
|
/**
|
707
747
|
* Gets address for ENS name.
|
708
748
|
*
|
@@ -1816,6 +1856,7 @@ export function publicActions<
|
|
1816
1856
|
getBytecode: (args) => getBytecode(client, args),
|
1817
1857
|
getChainId: () => getChainId(client),
|
1818
1858
|
getContractEvents: (args) => getContractEvents(client, args),
|
1859
|
+
getEip712Domain: (args) => getEip712Domain(client, args),
|
1819
1860
|
getEnsAddress: (args) => getEnsAddress(client, args),
|
1820
1861
|
getEnsAvatar: (args) => getEnsAvatar(client, args),
|
1821
1862
|
getEnsName: (args) => getEnsName(client, args),
|
@@ -1838,7 +1879,7 @@ export function publicActions<
|
|
1838
1879
|
getTransactionReceipt: (args) => getTransactionReceipt(client, args),
|
1839
1880
|
multicall: (args) => multicall(client, args),
|
1840
1881
|
prepareTransactionRequest: (args) =>
|
1841
|
-
prepareTransactionRequest(client as any, args as any),
|
1882
|
+
prepareTransactionRequest(client as any, args as any) as any,
|
1842
1883
|
readContract: (args) => readContract(client, args),
|
1843
1884
|
sendRawTransaction: (args) => sendRawTransaction(client, args),
|
1844
1885
|
simulateContract: (args) => simulateContract(client, args),
|
@@ -703,7 +703,7 @@ export function walletActions<
|
|
703
703
|
getChainId: () => getChainId(client),
|
704
704
|
getPermissions: () => getPermissions(client),
|
705
705
|
prepareTransactionRequest: (args) =>
|
706
|
-
prepareTransactionRequest(client as any, args as any),
|
706
|
+
prepareTransactionRequest(client as any, args as any) as any,
|
707
707
|
requestAddresses: () => requestAddresses(client),
|
708
708
|
requestPermissions: (args) => requestPermissions(client, args),
|
709
709
|
sendRawTransaction: (args) => sendRawTransaction(client, args),
|
package/errors/base.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { getVersion } from './utils.js'
|
2
2
|
|
3
3
|
type BaseErrorParameters = {
|
4
|
+
docsBaseUrl?: string | undefined
|
4
5
|
docsPath?: string | undefined
|
5
6
|
docsSlug?: string | undefined
|
6
7
|
metaMessages?: string[] | undefined
|
@@ -45,7 +46,7 @@ export class BaseError extends Error {
|
|
45
46
|
...(args.metaMessages ? [...args.metaMessages, ''] : []),
|
46
47
|
...(docsPath
|
47
48
|
? [
|
48
|
-
`Docs: https://viem.sh${docsPath}${
|
49
|
+
`Docs: ${args.docsBaseUrl ?? 'https://viem.sh'}${docsPath}${
|
49
50
|
args.docsSlug ? `#${args.docsSlug}` : ''
|
50
51
|
}`,
|
51
52
|
]
|
package/errors/eip712.ts
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
import type { Address } from 'abitype'
|
2
|
+
import { BaseError } from './base.js'
|
3
|
+
|
4
|
+
export type Eip712DomainNotFoundErrorType = Eip712DomainNotFoundError & {
|
5
|
+
name: 'Eip712DomainNotFoundError'
|
6
|
+
}
|
7
|
+
export class Eip712DomainNotFoundError extends BaseError {
|
8
|
+
override name = 'Eip712DomainNotFoundError'
|
9
|
+
constructor({ address }: { address: Address }) {
|
10
|
+
super(`No EIP-712 domain found on contract "${address}".`, {
|
11
|
+
metaMessages: [
|
12
|
+
'Ensure that:',
|
13
|
+
`- The contract is deployed at the address "${address}".`,
|
14
|
+
'- `eip712Domain()` function exists on the contract.',
|
15
|
+
'- `eip712Domain()` function matches signature to ERC-5267 specification.',
|
16
|
+
],
|
17
|
+
})
|
18
|
+
}
|
19
|
+
}
|
package/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '2.13.
|
1
|
+
export const version = '2.13.10'
|
package/index.ts
CHANGED
@@ -48,6 +48,11 @@ export {
|
|
48
48
|
type GetContractEventsParameters,
|
49
49
|
type GetContractEventsReturnType,
|
50
50
|
} from './actions/public/getContractEvents.js'
|
51
|
+
export {
|
52
|
+
type GetEip712DomainErrorType,
|
53
|
+
type GetEip712DomainParameters,
|
54
|
+
type GetEip712DomainReturnType,
|
55
|
+
} from './actions/public/getEip712Domain.js'
|
51
56
|
export {
|
52
57
|
type AddChainErrorType,
|
53
58
|
type AddChainParameters,
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import type { Address } from 'abitype'
|
2
|
+
|
2
3
|
import {
|
3
4
|
type EstimateContractGasErrorType,
|
4
5
|
type EstimateContractGasParameters,
|
@@ -24,10 +25,11 @@ export type EstimateDepositTransactionGasParameters<
|
|
24
25
|
chain extends Chain | undefined = Chain | undefined,
|
25
26
|
account extends Account | undefined = Account | undefined,
|
26
27
|
chainOverride extends Chain | undefined = Chain | undefined,
|
27
|
-
|
28
|
+
///
|
29
|
+
derivedChain extends Chain | undefined = DeriveChain<chain, chainOverride>,
|
28
30
|
> = UnionEvaluate<
|
29
31
|
UnionOmit<
|
30
|
-
FormattedTransactionRequest<
|
32
|
+
FormattedTransactionRequest<derivedChain>,
|
31
33
|
| 'accessList'
|
32
34
|
| 'data'
|
33
35
|
| 'from'
|
@@ -40,13 +42,15 @@ export type EstimateDepositTransactionGasParameters<
|
|
40
42
|
> &
|
41
43
|
GetAccountParameter<account, Account | Address> &
|
42
44
|
GetChainParameter<chain, chainOverride> &
|
43
|
-
GetContractAddressParameter<
|
45
|
+
GetContractAddressParameter<derivedChain, 'portal'> & {
|
44
46
|
/** L2 transaction request. */
|
45
47
|
request: DepositRequest
|
46
48
|
/** Gas limit for transaction execution on the L1. */
|
47
|
-
gas?: bigint |
|
49
|
+
gas?: bigint | undefined
|
48
50
|
}
|
51
|
+
|
49
52
|
export type EstimateDepositTransactionGasReturnType = bigint
|
53
|
+
|
50
54
|
export type EstimateDepositTransactionGasErrorType =
|
51
55
|
| EstimateContractGasErrorType
|
52
56
|
| ErrorType
|
@@ -116,11 +120,10 @@ export async function estimateDepositTransactionGas<
|
|
116
120
|
return Object.values(targetChain!.contracts.portal)[0].address
|
117
121
|
})()
|
118
122
|
|
119
|
-
|
123
|
+
const params = {
|
120
124
|
account,
|
121
125
|
abi: portalAbi,
|
122
126
|
address: portalAddress,
|
123
|
-
chain,
|
124
127
|
functionName: 'depositTransaction',
|
125
128
|
args: [
|
126
129
|
isCreation ? zeroAddress : to,
|
@@ -134,5 +137,13 @@ export async function estimateDepositTransactionGas<
|
|
134
137
|
maxPriorityFeePerGas,
|
135
138
|
nonce,
|
136
139
|
value: mint,
|
137
|
-
|
140
|
+
// TODO: Not sure `chain` is necessary since it's not used downstream
|
141
|
+
// in `estimateContractGas` or `estimateGas`
|
142
|
+
// @ts-ignore
|
143
|
+
chain,
|
144
|
+
} satisfies EstimateContractGasParameters<
|
145
|
+
typeof portalAbi,
|
146
|
+
'depositTransaction'
|
147
|
+
>
|
148
|
+
return estimateContractGas(client, params as any)
|
138
149
|
}
|
@@ -41,7 +41,7 @@ export type EstimateFinalizeWithdrawalGasParameters<
|
|
41
41
|
GetChainParameter<chain, chainOverride> &
|
42
42
|
GetContractAddressParameter<_derivedChain, 'portal'> & {
|
43
43
|
/** Gas limit for transaction execution on the L2. */
|
44
|
-
gas?: bigint |
|
44
|
+
gas?: bigint | undefined
|
45
45
|
withdrawal: Withdrawal
|
46
46
|
}
|
47
47
|
export type EstimateFinalizeWithdrawalGasReturnType = bigint
|
@@ -103,16 +103,23 @@ export async function estimateFinalizeWithdrawalGas<
|
|
103
103
|
return Object.values(targetChain!.contracts.portal)[0].address
|
104
104
|
})()
|
105
105
|
|
106
|
-
|
106
|
+
const params = {
|
107
107
|
account,
|
108
108
|
abi: portalAbi,
|
109
109
|
address: portalAddress,
|
110
|
-
chain,
|
111
110
|
functionName: 'finalizeWithdrawalTransaction',
|
112
111
|
args: [withdrawal],
|
113
112
|
gas,
|
114
113
|
maxFeePerGas,
|
115
114
|
maxPriorityFeePerGas,
|
116
115
|
nonce,
|
117
|
-
|
116
|
+
// TODO: Not sure `chain` is necessary since it's not used downstream
|
117
|
+
// in `estimateContractGas` or `estimateGas`
|
118
|
+
// @ts-ignore
|
119
|
+
chain,
|
120
|
+
} satisfies EstimateContractGasParameters<
|
121
|
+
typeof portalAbi,
|
122
|
+
'finalizeWithdrawalTransaction'
|
123
|
+
>
|
124
|
+
return estimateContractGas(client, params as any)
|
118
125
|
}
|
@@ -40,7 +40,7 @@ export type EstimateInitiateWithdrawalGasParameters<
|
|
40
40
|
GetAccountParameter<account, Account | Address> &
|
41
41
|
GetChainParameter<chain, chainOverride> & {
|
42
42
|
/** Gas limit for transaction execution on the L2. */
|
43
|
-
gas?: bigint |
|
43
|
+
gas?: bigint | undefined
|
44
44
|
/**
|
45
45
|
* Withdrawal request.
|
46
46
|
* Supplied to the L2ToL1MessagePasser `initiateWithdrawal` method.
|
@@ -102,11 +102,10 @@ export async function estimateInitiateWithdrawalGas<
|
|
102
102
|
request: { data = '0x', gas: l1Gas, to, value },
|
103
103
|
} = parameters
|
104
104
|
|
105
|
-
|
105
|
+
const params = {
|
106
106
|
account,
|
107
107
|
abi: l2ToL1MessagePasserAbi,
|
108
108
|
address: contracts.l2ToL1MessagePasser.address,
|
109
|
-
chain,
|
110
109
|
functionName: 'initiateWithdrawal',
|
111
110
|
args: [to, l1Gas, data],
|
112
111
|
gas,
|
@@ -114,5 +113,13 @@ export async function estimateInitiateWithdrawalGas<
|
|
114
113
|
maxPriorityFeePerGas,
|
115
114
|
nonce,
|
116
115
|
value,
|
117
|
-
|
116
|
+
// TODO: Not sure `chain` is necessary since it's not used downstream
|
117
|
+
// in `estimateContractGas` or `estimateGas`
|
118
|
+
// @ts-ignore
|
119
|
+
chain,
|
120
|
+
} satisfies EstimateContractGasParameters<
|
121
|
+
typeof l2ToL1MessagePasserAbi,
|
122
|
+
'initiateWithdrawal'
|
123
|
+
>
|
124
|
+
return estimateContractGas(client, params as any)
|
118
125
|
}
|
@@ -41,7 +41,7 @@ export type EstimateProveWithdrawalGasParameters<
|
|
41
41
|
GetChainParameter<chain, chainOverride> &
|
42
42
|
GetContractAddressParameter<_derivedChain, 'portal'> & {
|
43
43
|
/** Gas limit for transaction execution on the L2. */
|
44
|
-
gas?: bigint |
|
44
|
+
gas?: bigint | undefined
|
45
45
|
l2OutputIndex: bigint
|
46
46
|
outputRootProof: {
|
47
47
|
version: Hex
|
@@ -124,16 +124,23 @@ export async function estimateProveWithdrawalGas<
|
|
124
124
|
return Object.values(targetChain!.contracts.portal)[0].address
|
125
125
|
})()
|
126
126
|
|
127
|
-
|
127
|
+
const params = {
|
128
128
|
account,
|
129
129
|
abi: portalAbi,
|
130
130
|
address: portalAddress,
|
131
|
-
chain,
|
132
131
|
functionName: 'proveWithdrawalTransaction',
|
133
132
|
args: [withdrawal, l2OutputIndex, outputRootProof, withdrawalProof],
|
134
133
|
gas,
|
135
134
|
maxFeePerGas,
|
136
135
|
maxPriorityFeePerGas,
|
137
136
|
nonce,
|
138
|
-
|
137
|
+
// TODO: Not sure `chain` is necessary since it's not used downstream
|
138
|
+
// in `estimateContractGas` or `estimateGas`
|
139
|
+
// @ts-ignore
|
140
|
+
chain,
|
141
|
+
} satisfies EstimateContractGasParameters<
|
142
|
+
typeof portalAbi,
|
143
|
+
'proveWithdrawalTransaction'
|
144
|
+
>
|
145
|
+
return estimateContractGas(client, params as any)
|
139
146
|
}
|
package/package.json
CHANGED
package/types/chain.ts
CHANGED
@@ -169,7 +169,7 @@ export type ChainEstimateFeesPerGasFnParameters<
|
|
169
169
|
formatters extends ChainFormatters | undefined = ChainFormatters | undefined,
|
170
170
|
> = {
|
171
171
|
/** A function to multiply the base fee based on the `baseFeeMultiplier` value. */
|
172
|
-
multiply(x: bigint)
|
172
|
+
multiply: (x: bigint) => bigint
|
173
173
|
/** The type of fees to return. */
|
174
174
|
type: FeeValuesType
|
175
175
|
} & ChainFeesFnParameters<formatters>
|
@@ -180,9 +180,9 @@ export type ChainEstimateFeesPerGasFnParameters<
|
|
180
180
|
export type ExtractChainFormatterExclude<
|
181
181
|
chain extends Chain | undefined,
|
182
182
|
type extends keyof ChainFormatters,
|
183
|
-
> = chain extends { formatters?: infer
|
184
|
-
?
|
185
|
-
? Extract<
|
183
|
+
> = chain extends { formatters?: infer formatters extends ChainFormatters }
|
184
|
+
? formatters[type] extends { exclude: infer exclude }
|
185
|
+
? Extract<exclude, readonly string[]>[number]
|
186
186
|
: ''
|
187
187
|
: ''
|
188
188
|
|
@@ -190,9 +190,9 @@ export type ExtractChainFormatterParameters<
|
|
190
190
|
chain extends Chain | undefined,
|
191
191
|
type extends keyof ChainFormatters,
|
192
192
|
fallback,
|
193
|
-
> = chain extends { formatters?: infer
|
194
|
-
?
|
195
|
-
? Parameters<
|
193
|
+
> = chain extends { formatters?: infer formatters extends ChainFormatters }
|
194
|
+
? formatters[type] extends ChainFormatter
|
195
|
+
? Parameters<formatters[type]['format']>[0]
|
196
196
|
: fallback
|
197
197
|
: fallback
|
198
198
|
|
@@ -32,11 +32,12 @@ export type EncodeDeployDataParameters<
|
|
32
32
|
abi: abi
|
33
33
|
bytecode: Hex
|
34
34
|
} & UnionEvaluate<
|
35
|
-
|
36
|
-
? { args?:
|
37
|
-
:
|
38
|
-
|
39
|
-
|
35
|
+
hasConstructor extends false
|
36
|
+
? { args?: undefined }
|
37
|
+
: readonly [] extends allArgs
|
38
|
+
? { args?: allArgs | undefined }
|
39
|
+
: { args: allArgs }
|
40
|
+
>
|
40
41
|
|
41
42
|
export type EncodeDeployDataReturnType = Hex
|
42
43
|
|
@@ -370,13 +370,18 @@ function serializeTransactionLegacy(
|
|
370
370
|
|
371
371
|
export function toYParitySignatureArray(
|
372
372
|
transaction: TransactionSerializableGeneric,
|
373
|
-
|
373
|
+
signature_?: Signature | undefined,
|
374
374
|
) {
|
375
|
-
const
|
376
|
-
|
377
|
-
|
375
|
+
const signature = signature_ ?? transaction
|
376
|
+
const { v, yParity } = signature
|
377
|
+
|
378
|
+
if (typeof signature.r === 'undefined') return []
|
379
|
+
if (typeof signature.s === 'undefined') return []
|
378
380
|
if (typeof v === 'undefined' && typeof yParity === 'undefined') return []
|
379
381
|
|
382
|
+
const r = trim(signature.r)
|
383
|
+
const s = trim(signature.s)
|
384
|
+
|
380
385
|
const yParity_ = (() => {
|
381
386
|
if (typeof yParity === 'number') return yParity ? toHex(1) : '0x'
|
382
387
|
if (v === 0n) return '0x'
|
@@ -384,5 +389,6 @@ export function toYParitySignatureArray(
|
|
384
389
|
|
385
390
|
return v === 27n ? '0x' : toHex(1)
|
386
391
|
})()
|
387
|
-
|
392
|
+
|
393
|
+
return [yParity_, r === '0x00' ? '0x' : r, s === '0x00' ? '0x' : s]
|
388
394
|
}
|
@@ -5,7 +5,8 @@ import { prepareTransactionRequest } from '../../actions/wallet/prepareTransacti
|
|
5
5
|
import { sendRawTransaction } from '../../actions/wallet/sendRawTransaction.js'
|
6
6
|
import type {
|
7
7
|
SendTransactionErrorType,
|
8
|
-
SendTransactionParameters
|
8
|
+
SendTransactionParameters,
|
9
|
+
SendTransactionRequest,
|
9
10
|
SendTransactionReturnType,
|
10
11
|
} from '../../actions/wallet/sendTransaction.js'
|
11
12
|
import type { Client } from '../../clients/createClient.js'
|
@@ -24,10 +25,14 @@ import { assertEip712Request } from '../utils/assertEip712Request.js'
|
|
24
25
|
import { signTransaction } from './signTransaction.js'
|
25
26
|
|
26
27
|
export type SendEip712TransactionParameters<
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
chain extends ChainEIP712 | undefined = ChainEIP712 | undefined,
|
29
|
+
account extends Account | undefined = Account | undefined,
|
30
|
+
chainOverride extends ChainEIP712 | undefined = ChainEIP712 | undefined,
|
31
|
+
request extends SendTransactionRequest<
|
32
|
+
chain,
|
33
|
+
chainOverride
|
34
|
+
> = SendTransactionRequest<chain, chainOverride>,
|
35
|
+
> = SendTransactionParameters<chain, account, chainOverride, request>
|
31
36
|
|
32
37
|
export type SendEip712TransactionReturnType = SendTransactionReturnType
|
33
38
|
|
@@ -74,27 +79,33 @@ export type SendEip712TransactionErrorType = SendTransactionErrorType
|
|
74
79
|
* })
|
75
80
|
*/
|
76
81
|
export async function sendEip712Transaction<
|
77
|
-
|
78
|
-
|
79
|
-
|
82
|
+
chain extends ChainEIP712 | undefined,
|
83
|
+
account extends Account | undefined,
|
84
|
+
const request extends SendTransactionRequest<chain, chainOverride>,
|
85
|
+
chainOverride extends ChainEIP712 | undefined = undefined,
|
80
86
|
>(
|
81
|
-
client: Client<Transport,
|
82
|
-
|
87
|
+
client: Client<Transport, chain, account>,
|
88
|
+
parameters: SendEip712TransactionParameters<
|
89
|
+
chain,
|
90
|
+
account,
|
91
|
+
chainOverride,
|
92
|
+
request
|
93
|
+
>,
|
83
94
|
): Promise<SendEip712TransactionReturnType> {
|
84
|
-
const { chain = client.chain } =
|
95
|
+
const { chain = client.chain } = parameters
|
85
96
|
|
86
|
-
if (!
|
97
|
+
if (!parameters.account)
|
87
98
|
throw new AccountNotFoundError({
|
88
99
|
docsPath: '/docs/actions/wallet/sendTransaction',
|
89
100
|
})
|
90
|
-
const account = parseAccount(
|
101
|
+
const account = parseAccount(parameters.account)
|
91
102
|
|
92
103
|
try {
|
93
|
-
assertEip712Request(
|
104
|
+
assertEip712Request(parameters)
|
94
105
|
|
95
106
|
// Prepare the request for signing (assign appropriate fees, etc.)
|
96
107
|
const request = await prepareTransactionRequest(client, {
|
97
|
-
...
|
108
|
+
...parameters,
|
98
109
|
parameters: ['gas', 'nonce', 'fees'],
|
99
110
|
} as any)
|
100
111
|
|
@@ -121,7 +132,7 @@ export async function sendEip712Transaction<
|
|
121
132
|
})
|
122
133
|
} catch (err) {
|
123
134
|
throw getTransactionError(err as BaseError, {
|
124
|
-
...(
|
135
|
+
...(parameters as GetTransactionErrorParameters),
|
125
136
|
account,
|
126
137
|
chain: chain as Chain,
|
127
138
|
})
|