viem 2.24.2 → 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 +20 -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/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/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/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/op-stack/actions/estimateL1Fee.ts +11 -21
- package/op-stack/actions/estimateL1Gas.ts +11 -21
- package/package.json +1 -1
@@ -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'
|
@@ -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, {
|