viem 2.24.1 → 2.24.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 +26 -0
- package/_cjs/celo/fees.js +2 -13
- package/_cjs/celo/fees.js.map +1 -1
- package/_cjs/chains/definitions/confluxESpace.js +1 -1
- package/_cjs/chains/definitions/confluxESpace.js.map +1 -1
- package/_cjs/chains/definitions/confluxESpaceTestnet.js +1 -1
- package/_cjs/chains/definitions/confluxESpaceTestnet.js.map +1 -1
- package/_cjs/chains/definitions/megaethTestnet.js +5 -0
- package/_cjs/chains/definitions/megaethTestnet.js.map +1 -1
- package/_cjs/chains/definitions/swellchainTestnet.js +31 -0
- package/_cjs/chains/definitions/swellchainTestnet.js.map +1 -0
- package/_cjs/chains/definitions/westendAssetHub.js +24 -0
- package/_cjs/chains/definitions/westendAssetHub.js.map +1 -0
- package/_cjs/chains/index.js +7 -3
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/clients/transports/webSocket.js +4 -6
- package/_cjs/clients/transports/webSocket.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/experimental/index.js +15 -1
- package/_cjs/experimental/index.js.map +1 -1
- package/_cjs/op-stack/actions/estimateL1Fee.js +7 -5
- package/_cjs/op-stack/actions/estimateL1Fee.js.map +1 -1
- package/_cjs/op-stack/actions/estimateL1Gas.js +7 -5
- package/_cjs/op-stack/actions/estimateL1Gas.js.map +1 -1
- package/_esm/celo/fees.js +3 -13
- package/_esm/celo/fees.js.map +1 -1
- package/_esm/chains/definitions/confluxESpace.js +1 -1
- package/_esm/chains/definitions/confluxESpace.js.map +1 -1
- package/_esm/chains/definitions/confluxESpaceTestnet.js +1 -1
- package/_esm/chains/definitions/confluxESpaceTestnet.js.map +1 -1
- package/_esm/chains/definitions/megaethTestnet.js +5 -0
- package/_esm/chains/definitions/megaethTestnet.js.map +1 -1
- package/_esm/chains/definitions/swellchainTestnet.js +28 -0
- package/_esm/chains/definitions/swellchainTestnet.js.map +1 -0
- package/_esm/chains/definitions/westendAssetHub.js +21 -0
- package/_esm/chains/definitions/westendAssetHub.js.map +1 -0
- package/_esm/chains/index.js +2 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/clients/transports/webSocket.js +4 -6
- package/_esm/clients/transports/webSocket.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/experimental/index.js +23 -0
- package/_esm/experimental/index.js.map +1 -1
- package/_esm/op-stack/actions/estimateL1Fee.js +10 -6
- package/_esm/op-stack/actions/estimateL1Fee.js.map +1 -1
- package/_esm/op-stack/actions/estimateL1Gas.js +10 -6
- package/_esm/op-stack/actions/estimateL1Gas.js.map +1 -1
- package/_types/celo/fees.d.ts.map +1 -1
- package/_types/chains/definitions/confluxESpace.d.ts +1 -1
- package/_types/chains/definitions/confluxESpaceTestnet.d.ts +1 -1
- package/_types/chains/definitions/megaethTestnet.d.ts +5 -9
- package/_types/chains/definitions/megaethTestnet.d.ts.map +1 -1
- package/_types/chains/definitions/swellchainTestnet.d.ts +284 -0
- package/_types/chains/definitions/swellchainTestnet.d.ts.map +1 -0
- package/_types/chains/definitions/westendAssetHub.d.ts +36 -0
- package/_types/chains/definitions/westendAssetHub.d.ts.map +1 -0
- package/_types/chains/index.d.ts +2 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/clients/transports/webSocket.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/experimental/index.d.ts +75 -0
- package/_types/experimental/index.d.ts.map +1 -1
- package/_types/op-stack/actions/estimateL1Fee.d.ts +1 -3
- package/_types/op-stack/actions/estimateL1Fee.d.ts.map +1 -1
- package/_types/op-stack/actions/estimateL1Gas.d.ts +1 -3
- package/_types/op-stack/actions/estimateL1Gas.d.ts.map +1 -1
- package/celo/fees.ts +4 -14
- package/chains/definitions/confluxESpace.ts +1 -1
- package/chains/definitions/confluxESpaceTestnet.ts +1 -1
- package/chains/definitions/megaethTestnet.ts +5 -0
- package/chains/definitions/swellchainTestnet.ts +28 -0
- package/chains/definitions/westendAssetHub.ts +21 -0
- package/chains/index.ts +2 -0
- package/clients/transports/webSocket.ts +4 -6
- package/errors/version.ts +1 -1
- package/experimental/index.ts +85 -0
- package/op-stack/actions/estimateL1Fee.ts +11 -21
- package/op-stack/actions/estimateL1Gas.ts +11 -21
- package/package.json +1 -1
@@ -1,6 +1,5 @@
|
|
1
1
|
import type { Address } from 'abitype';
|
2
2
|
import { type ReadContractErrorType } from '../../actions/public/readContract.js';
|
3
|
-
import { type PrepareTransactionRequestErrorType } from '../../actions/wallet/prepareTransactionRequest.js';
|
4
3
|
import type { Client } from '../../clients/createClient.js';
|
5
4
|
import type { Transport } from '../../clients/transports/createTransport.js';
|
6
5
|
import type { ErrorType } from '../../errors/utils.js';
|
@@ -9,14 +8,13 @@ import type { Chain, GetChainParameter } from '../../types/chain.js';
|
|
9
8
|
import type { TransactionRequestEIP1559 } from '../../types/transaction.js';
|
10
9
|
import type { RequestErrorType } from '../../utils/buildRequest.js';
|
11
10
|
import type { HexToNumberErrorType } from '../../utils/encoding/fromHex.js';
|
12
|
-
import { type AssertRequestErrorType } from '../../utils/transaction/assertRequest.js';
|
13
11
|
import { type SerializeTransactionErrorType } from '../../utils/transaction/serializeTransaction.js';
|
14
12
|
export type EstimateL1GasParameters<chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined, chainOverride extends Chain | undefined = Chain | undefined> = Omit<TransactionRequestEIP1559, 'from'> & GetAccountParameter<account> & GetChainParameter<chain, chainOverride> & {
|
15
13
|
/** Gas price oracle address. */
|
16
14
|
gasPriceOracleAddress?: Address | undefined;
|
17
15
|
};
|
18
16
|
export type EstimateL1GasReturnType = bigint;
|
19
|
-
export type EstimateL1GasErrorType = RequestErrorType |
|
17
|
+
export type EstimateL1GasErrorType = RequestErrorType | SerializeTransactionErrorType | HexToNumberErrorType | ReadContractErrorType | ErrorType;
|
20
18
|
/**
|
21
19
|
* Estimates the L1 data gas required to execute an L2 transaction.
|
22
20
|
*
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"estimateL1Gas.d.ts","sourceRoot":"","sources":["../../../op-stack/actions/estimateL1Gas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEtC,OAAO,EACL,KAAK,qBAAqB,EAE3B,MAAM,sCAAsC,CAAA;AAC7C,OAAO,
|
1
|
+
{"version":3,"file":"estimateL1Gas.d.ts","sourceRoot":"","sources":["../../../op-stack/actions/estimateL1Gas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEtC,OAAO,EACL,KAAK,qBAAqB,EAE3B,MAAM,sCAAsC,CAAA;AAC7C,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,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC1E,OAAO,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACpE,OAAO,KAAK,EACV,yBAAyB,EAE1B,MAAM,4BAA4B,CAAA;AACnC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAEnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAA;AAC3E,OAAO,EACL,KAAK,6BAA6B,EAEnC,MAAM,iDAAiD,CAAA;AAKxD,MAAM,MAAM,uBAAuB,CACjC,KAAK,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EACnD,OAAO,SAAS,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,EACzD,aAAa,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,IACzD,IAAI,CAAC,yBAAyB,EAAE,MAAM,CAAC,GACzC,mBAAmB,CAAC,OAAO,CAAC,GAC5B,iBAAiB,CAAC,KAAK,EAAE,aAAa,CAAC,GAAG;IACxC,gCAAgC;IAChC,qBAAqB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC5C,CAAA;AAEH,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAA;AAE5C,MAAM,MAAM,sBAAsB,GAC9B,gBAAgB,GAChB,6BAA6B,GAC7B,oBAAoB,GACpB,qBAAqB,GACrB,SAAS,CAAA;AAEb;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,aAAa,CACjC,KAAK,SAAS,KAAK,GAAG,SAAS,EAC/B,OAAO,SAAS,OAAO,GAAG,SAAS,EACnC,aAAa,SAAS,KAAK,GAAG,SAAS,GAAG,SAAS,EAEnD,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,EACzC,IAAI,EAAE,uBAAuB,CAAC,KAAK,EAAE,OAAO,EAAE,aAAa,CAAC,GAC3D,OAAO,CAAC,uBAAuB,CAAC,CAoClC"}
|
package/celo/fees.ts
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import { getCode } from '../actions/public/getCode.js'
|
2
1
|
import type { Client } from '../clients/createClient.js'
|
3
2
|
import type {
|
4
3
|
Address,
|
@@ -23,20 +22,17 @@ export const fees: ChainFees<typeof formatters> = {
|
|
23
22
|
) => {
|
24
23
|
if (!params.request?.feeCurrency) return null
|
25
24
|
|
26
|
-
const [gasPrice, maxPriorityFeePerGas
|
25
|
+
const [gasPrice, maxPriorityFeePerGas] = await Promise.all([
|
27
26
|
estimateFeePerGasInFeeCurrency(params.client, params.request.feeCurrency),
|
28
27
|
estimateMaxPriorityFeePerGasInFeeCurrency(
|
29
28
|
params.client,
|
30
29
|
params.request.feeCurrency,
|
31
30
|
),
|
32
|
-
isCel2(params.client),
|
33
31
|
])
|
34
32
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
: // eth_gasPrice for Celo L1 returns (baseFeePerGas * multiplier), where the multiplier is 2 by default.
|
39
|
-
gasPrice + maxPriorityFeePerGas
|
33
|
+
// eth_gasPrice for cel2 returns baseFeePerGas + maxPriorityFeePerGas
|
34
|
+
const maxFeePerGas =
|
35
|
+
params.multiply(gasPrice - maxPriorityFeePerGas) + maxPriorityFeePerGas
|
40
36
|
|
41
37
|
return {
|
42
38
|
maxFeePerGas,
|
@@ -97,9 +93,3 @@ async function estimateMaxPriorityFeePerGasInFeeCurrency(
|
|
97
93
|
})
|
98
94
|
return BigInt(feesPerGas)
|
99
95
|
}
|
100
|
-
|
101
|
-
async function isCel2(client: Client) {
|
102
|
-
const proxyAdminAddress = '0x4200000000000000000000000000000000000018'
|
103
|
-
const code = await getCode(client, { address: proxyAdminAddress })
|
104
|
-
return Boolean(code)
|
105
|
-
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { chainConfig } from '../../op-stack/chainConfig.js'
|
2
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
3
|
+
|
4
|
+
export const swellchainTestnet = /*#__PURE__*/ defineChain({
|
5
|
+
...chainConfig,
|
6
|
+
id: 1924,
|
7
|
+
name: 'Swellchain Testnet',
|
8
|
+
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
|
9
|
+
rpcUrls: {
|
10
|
+
default: {
|
11
|
+
http: ['https://swell-testnet.alt.technology'],
|
12
|
+
},
|
13
|
+
},
|
14
|
+
blockExplorers: {
|
15
|
+
default: {
|
16
|
+
name: 'Swellchain Testnet Explorer',
|
17
|
+
url: 'https://swell-testnet-explorer.alt.technology',
|
18
|
+
apiUrl: 'https://swell-testnet-explorer.alt.technology/api',
|
19
|
+
},
|
20
|
+
},
|
21
|
+
contracts: {
|
22
|
+
...chainConfig.contracts,
|
23
|
+
multicall3: {
|
24
|
+
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
25
|
+
blockCreated: 1,
|
26
|
+
},
|
27
|
+
},
|
28
|
+
})
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
export const westendAssetHub = /*#__PURE__*/ defineChain({
|
4
|
+
id: 420_420_421,
|
5
|
+
name: 'Westend Asset Hub',
|
6
|
+
nativeCurrency: {
|
7
|
+
decimals: 18,
|
8
|
+
name: 'Westies',
|
9
|
+
symbol: 'WND',
|
10
|
+
},
|
11
|
+
rpcUrls: {
|
12
|
+
default: { http: ['https://westend-asset-hub-eth-rpc.polkadot.io'] },
|
13
|
+
},
|
14
|
+
blockExplorers: {
|
15
|
+
default: {
|
16
|
+
name: 'subscan',
|
17
|
+
url: 'https://westend-asset-hub-eth-explorer.parity.io',
|
18
|
+
},
|
19
|
+
},
|
20
|
+
testnet: true,
|
21
|
+
})
|
package/chains/index.ts
CHANGED
@@ -504,6 +504,7 @@ export { swan } from './definitions/swan.js'
|
|
504
504
|
export { swanProximaTestnet } from './definitions/swanProximaTestnet.js'
|
505
505
|
export { swanSaturnTestnet } from './definitions/swanSaturnTestnet.js'
|
506
506
|
export { swellchain } from './definitions/swellchain.js'
|
507
|
+
export { swellchainTestnet } from './definitions/swellchainTestnet.js'
|
507
508
|
export { swissdlt } from './definitions/swissdlt.js'
|
508
509
|
export { syscoin } from './definitions/syscoin.js'
|
509
510
|
export { syscoinTestnet } from './definitions/syscoinTestnet.js'
|
@@ -553,6 +554,7 @@ export { wanchainTestnet } from './definitions/wanchainTestnet.js'
|
|
553
554
|
export { weaveVMAlphanet } from './definitions/weavevmAlphanet.js'
|
554
555
|
export { wemix } from './definitions/wemix.js'
|
555
556
|
export { wemixTestnet } from './definitions/wemixTestnet.js'
|
557
|
+
export { westendAssetHub } from './definitions/westendAssetHub.js'
|
556
558
|
export { whitechain } from './definitions/whitechain.js'
|
557
559
|
export { whitechainTestnet } from './definitions/whitechainTestnet.js'
|
558
560
|
export { wmcTestnet } from './definitions/wmcTestnet.js'
|
@@ -103,6 +103,7 @@ export function webSocket(
|
|
103
103
|
const retryCount = config.retryCount ?? retryCount_
|
104
104
|
const timeout = timeout_ ?? config.timeout ?? 10_000
|
105
105
|
const url_ = url || chain?.rpcUrls.default.webSocket?.[0]
|
106
|
+
const wsRpcClientOpts = { keepAlive, reconnect }
|
106
107
|
if (!url_) throw new UrlRequiredError()
|
107
108
|
return createTransport(
|
108
109
|
{
|
@@ -111,10 +112,7 @@ export function webSocket(
|
|
111
112
|
name,
|
112
113
|
async request({ method, params }) {
|
113
114
|
const body = { method, params }
|
114
|
-
const rpcClient = await getWebSocketRpcClient(url_,
|
115
|
-
keepAlive,
|
116
|
-
reconnect,
|
117
|
-
})
|
115
|
+
const rpcClient = await getWebSocketRpcClient(url_, wsRpcClientOpts)
|
118
116
|
const { error, result } = await rpcClient.requestAsync({
|
119
117
|
body,
|
120
118
|
timeout,
|
@@ -137,10 +135,10 @@ export function webSocket(
|
|
137
135
|
return getSocket(url_)
|
138
136
|
},
|
139
137
|
getRpcClient() {
|
140
|
-
return getWebSocketRpcClient(url_)
|
138
|
+
return getWebSocketRpcClient(url_, wsRpcClientOpts)
|
141
139
|
},
|
142
140
|
async subscribe({ params, onData, onError }: any) {
|
143
|
-
const rpcClient = await getWebSocketRpcClient(url_)
|
141
|
+
const rpcClient = await getWebSocketRpcClient(url_, wsRpcClientOpts)
|
144
142
|
const { result: subscriptionId } = await new Promise<any>(
|
145
143
|
(resolve, reject) =>
|
146
144
|
rpcClient.request({
|
package/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '2.24.
|
1
|
+
export const version = '2.24.3'
|
package/experimental/index.ts
CHANGED
@@ -43,6 +43,91 @@ export {
|
|
43
43
|
eip5792Actions,
|
44
44
|
} from './eip5792/decorators/eip5792.js'
|
45
45
|
|
46
|
+
export {
|
47
|
+
/** @deprecated This is no longer experimental – use `import type { WalletActions } from 'viem'` instead. */
|
48
|
+
type WalletActions as Eip7702Actions,
|
49
|
+
/** @deprecated This is no longer experimental – use `import { createWalletClient } from 'viem'` or `import { walletActions } from 'viem'` instead. */
|
50
|
+
walletActions as eip7702Actions,
|
51
|
+
} from '../clients/decorators/wallet.js'
|
52
|
+
export {
|
53
|
+
/** @deprecated This is no longer experimental – use `import type { PrepareAuthorizationParameters } from 'viem/actions'` instead. */
|
54
|
+
type PrepareAuthorizationParameters,
|
55
|
+
/** @deprecated This is no longer experimental – use `import type { PrepareAuthorizationReturnType } from 'viem/actions'` instead. */
|
56
|
+
type PrepareAuthorizationReturnType,
|
57
|
+
/** @deprecated This is no longer experimental – use `import type { PrepareAuthorizationErrorType } from 'viem/actions'` instead. */
|
58
|
+
type PrepareAuthorizationErrorType,
|
59
|
+
/** @deprecated This is no longer experimental – use `import { prepareAuthorization } from 'viem/actions'` instead. */
|
60
|
+
prepareAuthorization,
|
61
|
+
} from '../actions/wallet/prepareAuthorization.js'
|
62
|
+
export {
|
63
|
+
/** @deprecated This is no longer experimental – use `import type { SignAuthorizationParameters } from 'viem/actions'` instead. */
|
64
|
+
type SignAuthorizationParameters,
|
65
|
+
/** @deprecated This is no longer experimental – use `import type { SignAuthorizationReturnType } from 'viem/actions'` instead. */
|
66
|
+
type SignAuthorizationReturnType,
|
67
|
+
/** @deprecated This is no longer experimental – use `import type { SignAuthorizationErrorType } from 'viem/actions'` instead. */
|
68
|
+
type SignAuthorizationErrorType,
|
69
|
+
/** @deprecated This is no longer experimental – use `import { signAuthorization } from 'viem/actions'` instead. */
|
70
|
+
signAuthorization,
|
71
|
+
} from '../actions/wallet/signAuthorization.js'
|
72
|
+
export {
|
73
|
+
/** @deprecated This is no longer experimental – use `import type { Authorization } from 'viem'` instead. */
|
74
|
+
type Authorization,
|
75
|
+
/** @deprecated This is no longer experimental – use `import type { SignedAuthorization } from 'viem'` instead. */
|
76
|
+
type SignedAuthorization,
|
77
|
+
/** @deprecated This is no longer experimental – use `import type { AuthorizationList } from 'viem'` instead. */
|
78
|
+
type AuthorizationList,
|
79
|
+
/** @deprecated This is no longer experimental – use `import type { SignedAuthorizationList } from 'viem'` instead. */
|
80
|
+
type SignedAuthorizationList,
|
81
|
+
/** @deprecated This is no longer experimental – use `import type { SerializedAuthorization } from 'viem'` instead. */
|
82
|
+
type SerializedAuthorization,
|
83
|
+
/** @deprecated This is no longer experimental – use `import type { SerializedAuthorizationList } from 'viem'` instead. */
|
84
|
+
type SerializedAuthorizationList,
|
85
|
+
} from '../types/authorization.js'
|
86
|
+
export {
|
87
|
+
/** @deprecated This is no longer experimental – use `import type { RpcAuthorizationList } from 'viem'` instead. */
|
88
|
+
type RpcAuthorizationList,
|
89
|
+
/** @deprecated This is no longer experimental – use `import type { RpcAuthorization } from 'viem'` instead. */
|
90
|
+
type RpcAuthorization,
|
91
|
+
} from '../types/rpc.js'
|
92
|
+
export {
|
93
|
+
/** @deprecated This is no longer experimental – use `import type { HashAuthorizationParameters } from 'viem/utils'` instead. */
|
94
|
+
type HashAuthorizationParameters,
|
95
|
+
/** @deprecated This is no longer experimental – use `import type { HashAuthorizationReturnType } from 'viem/utils'` instead. */
|
96
|
+
type HashAuthorizationReturnType,
|
97
|
+
/** @deprecated This is no longer experimental – use `import type { HashAuthorizationErrorType } from 'viem/utils'` instead. */
|
98
|
+
type HashAuthorizationErrorType,
|
99
|
+
/** @deprecated This is no longer experimental – use `import { hashAuthorization } from 'viem/utils'` instead. */
|
100
|
+
hashAuthorization,
|
101
|
+
} from '../utils/authorization/hashAuthorization.js'
|
102
|
+
export {
|
103
|
+
/** @deprecated This is no longer experimental – use `import type { RecoverAuthorizationAddressParameters } from 'viem/utils'` instead. */
|
104
|
+
type RecoverAuthorizationAddressParameters,
|
105
|
+
/** @deprecated This is no longer experimental – use `import type { RecoverAuthorizationAddressReturnType } from 'viem/utils'` instead. */
|
106
|
+
type RecoverAuthorizationAddressReturnType,
|
107
|
+
/** @deprecated This is no longer experimental – use `import type { RecoverAuthorizationAddressErrorType } from 'viem/utils'` instead. */
|
108
|
+
type RecoverAuthorizationAddressErrorType,
|
109
|
+
/** @deprecated This is no longer experimental – use `import { recoverAuthorizationAddress } from 'viem/utils'` instead. */
|
110
|
+
recoverAuthorizationAddress,
|
111
|
+
} from '../utils/authorization/recoverAuthorizationAddress.js'
|
112
|
+
export {
|
113
|
+
/** @deprecated This is no longer experimental – use `import type { SerializeAuthorizationListReturnType } from 'viem/utils'` instead. */
|
114
|
+
type SerializeAuthorizationListReturnType,
|
115
|
+
/** @deprecated This is no longer experimental – use `import type { SerializeAuthorizationListErrorType } from 'viem/utils'` instead. */
|
116
|
+
type SerializeAuthorizationListErrorType,
|
117
|
+
/** @deprecated This is no longer experimental – use `import { serializeAuthorizationList } from 'viem/utils'` instead. */
|
118
|
+
serializeAuthorizationList,
|
119
|
+
} from '../utils/authorization/serializeAuthorizationList.js'
|
120
|
+
export {
|
121
|
+
/** @deprecated This is no longer experimental – use `import type { VerifyAuthorizationParameters } from 'viem/utils'` instead. */
|
122
|
+
type VerifyAuthorizationParameters,
|
123
|
+
/** @deprecated This is no longer experimental – use `import type { VerifyAuthorizationReturnType } from 'viem/utils'` instead. */
|
124
|
+
type VerifyAuthorizationReturnType,
|
125
|
+
/** @deprecated This is no longer experimental – use `import type { VerifyAuthorizationErrorType } from 'viem/utils'` instead. */
|
126
|
+
type VerifyAuthorizationErrorType,
|
127
|
+
/** @deprecated This is no longer experimental – use `import { verifyAuthorization } from 'viem/utils'` instead. */
|
128
|
+
verifyAuthorization,
|
129
|
+
} from '../utils/authorization/verifyAuthorization.js'
|
130
|
+
|
46
131
|
export {
|
47
132
|
type GrantPermissionsParameters,
|
48
133
|
type GrantPermissionsReturnType,
|
@@ -4,11 +4,6 @@ import {
|
|
4
4
|
type ReadContractErrorType,
|
5
5
|
readContract,
|
6
6
|
} from '../../actions/public/readContract.js'
|
7
|
-
import {
|
8
|
-
type PrepareTransactionRequestErrorType,
|
9
|
-
type PrepareTransactionRequestParameters,
|
10
|
-
prepareTransactionRequest,
|
11
|
-
} from '../../actions/wallet/prepareTransactionRequest.js'
|
12
7
|
import type { Client } from '../../clients/createClient.js'
|
13
8
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
14
9
|
import type { ErrorType } from '../../errors/utils.js'
|
@@ -21,15 +16,11 @@ import type {
|
|
21
16
|
import type { RequestErrorType } from '../../utils/buildRequest.js'
|
22
17
|
import { getChainContractAddress } from '../../utils/chain/getChainContractAddress.js'
|
23
18
|
import type { HexToNumberErrorType } from '../../utils/encoding/fromHex.js'
|
24
|
-
import {
|
25
|
-
type AssertRequestErrorType,
|
26
|
-
type AssertRequestParameters,
|
27
|
-
assertRequest,
|
28
|
-
} from '../../utils/transaction/assertRequest.js'
|
29
19
|
import {
|
30
20
|
type SerializeTransactionErrorType,
|
31
21
|
serializeTransaction,
|
32
22
|
} from '../../utils/transaction/serializeTransaction.js'
|
23
|
+
import { parseGwei } from '../../utils/unit/parseGwei.js'
|
33
24
|
import { gasPriceOracleAbi } from '../abis.js'
|
34
25
|
import { contracts } from '../contracts.js'
|
35
26
|
|
@@ -48,8 +39,6 @@ export type EstimateL1FeeReturnType = bigint
|
|
48
39
|
|
49
40
|
export type EstimateL1FeeErrorType =
|
50
41
|
| RequestErrorType
|
51
|
-
| PrepareTransactionRequestErrorType
|
52
|
-
| AssertRequestErrorType
|
53
42
|
| SerializeTransactionErrorType
|
54
43
|
| HexToNumberErrorType
|
55
44
|
| ReadContractErrorType
|
@@ -100,17 +89,18 @@ export async function estimateL1Fee<
|
|
100
89
|
return contracts.gasPriceOracle.address
|
101
90
|
})()
|
102
91
|
|
103
|
-
// Populate transaction with required fields to accurately estimate gas.
|
104
|
-
const request = await prepareTransactionRequest(
|
105
|
-
client,
|
106
|
-
args as PrepareTransactionRequestParameters,
|
107
|
-
)
|
108
|
-
|
109
|
-
assertRequest(request as AssertRequestParameters)
|
110
|
-
|
111
92
|
const transaction = serializeTransaction({
|
112
|
-
...
|
93
|
+
...args,
|
94
|
+
chainId: chain?.id ?? 1,
|
113
95
|
type: 'eip1559',
|
96
|
+
|
97
|
+
// Set upper-limit-ish stub values. Shouldn't affect the estimate too much as we are
|
98
|
+
// tweaking dust bytes here (as opposed to long `data` bytes).
|
99
|
+
// See: https://github.com/ethereum-optimism/optimism/blob/54d02df55523c9e1b4b38ed082c12a42087323a0/packages/contracts-bedrock/src/L2/GasPriceOracle.sol#L242-L248.
|
100
|
+
gas: args.data ? 300_000n : 21_000n,
|
101
|
+
maxFeePerGas: parseGwei('5'),
|
102
|
+
maxPriorityFeePerGas: parseGwei('1'),
|
103
|
+
nonce: 1,
|
114
104
|
} as TransactionSerializable)
|
115
105
|
|
116
106
|
return readContract(client, {
|
@@ -4,11 +4,6 @@ import {
|
|
4
4
|
type ReadContractErrorType,
|
5
5
|
readContract,
|
6
6
|
} from '../../actions/public/readContract.js'
|
7
|
-
import {
|
8
|
-
type PrepareTransactionRequestErrorType,
|
9
|
-
type PrepareTransactionRequestParameters,
|
10
|
-
prepareTransactionRequest,
|
11
|
-
} from '../../actions/wallet/prepareTransactionRequest.js'
|
12
7
|
import type { Client } from '../../clients/createClient.js'
|
13
8
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
14
9
|
import type { ErrorType } from '../../errors/utils.js'
|
@@ -21,15 +16,11 @@ import type {
|
|
21
16
|
import type { RequestErrorType } from '../../utils/buildRequest.js'
|
22
17
|
import { getChainContractAddress } from '../../utils/chain/getChainContractAddress.js'
|
23
18
|
import type { HexToNumberErrorType } from '../../utils/encoding/fromHex.js'
|
24
|
-
import {
|
25
|
-
type AssertRequestErrorType,
|
26
|
-
type AssertRequestParameters,
|
27
|
-
assertRequest,
|
28
|
-
} from '../../utils/transaction/assertRequest.js'
|
29
19
|
import {
|
30
20
|
type SerializeTransactionErrorType,
|
31
21
|
serializeTransaction,
|
32
22
|
} from '../../utils/transaction/serializeTransaction.js'
|
23
|
+
import { parseGwei } from '../../utils/unit/parseGwei.js'
|
33
24
|
import { gasPriceOracleAbi } from '../abis.js'
|
34
25
|
import { contracts } from '../contracts.js'
|
35
26
|
|
@@ -48,8 +39,6 @@ export type EstimateL1GasReturnType = bigint
|
|
48
39
|
|
49
40
|
export type EstimateL1GasErrorType =
|
50
41
|
| RequestErrorType
|
51
|
-
| PrepareTransactionRequestErrorType
|
52
|
-
| AssertRequestErrorType
|
53
42
|
| SerializeTransactionErrorType
|
54
43
|
| HexToNumberErrorType
|
55
44
|
| ReadContractErrorType
|
@@ -100,17 +89,18 @@ export async function estimateL1Gas<
|
|
100
89
|
return contracts.gasPriceOracle.address
|
101
90
|
})()
|
102
91
|
|
103
|
-
// Populate transaction with required fields to accurately estimate gas.
|
104
|
-
const request = await prepareTransactionRequest(
|
105
|
-
client,
|
106
|
-
args as PrepareTransactionRequestParameters,
|
107
|
-
)
|
108
|
-
|
109
|
-
assertRequest(request as AssertRequestParameters)
|
110
|
-
|
111
92
|
const transaction = serializeTransaction({
|
112
|
-
...
|
93
|
+
...args,
|
94
|
+
chainId: chain?.id ?? 1,
|
113
95
|
type: 'eip1559',
|
96
|
+
|
97
|
+
// Set upper-limit-ish stub values. Shouldn't affect the estimate too much as we are
|
98
|
+
// tweaking dust bytes here (as opposed to long `data` bytes).
|
99
|
+
// See: https://github.com/ethereum-optimism/optimism/blob/54d02df55523c9e1b4b38ed082c12a42087323a0/packages/contracts-bedrock/src/L2/GasPriceOracle.sol#L242-L248.
|
100
|
+
gas: args.data ? 300_000n : 21_000n,
|
101
|
+
maxFeePerGas: parseGwei('5'),
|
102
|
+
maxPriorityFeePerGas: parseGwei('1'),
|
103
|
+
nonce: 1,
|
114
104
|
} as TransactionSerializable)
|
115
105
|
|
116
106
|
return readContract(client, {
|