viem 2.7.16 → 2.7.19
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/chains/celo/utils.js +2 -2
- package/_cjs/chains/celo/utils.js.map +1 -1
- package/_cjs/chains/definitions/ancient8.js +46 -0
- package/_cjs/chains/definitions/ancient8.js.map +1 -0
- package/_cjs/chains/definitions/ancient8Sepolia.js +46 -0
- package/_cjs/chains/definitions/ancient8Sepolia.js.map +1 -0
- package/_cjs/chains/definitions/auroria.js +27 -0
- package/_cjs/chains/definitions/auroria.js.map +1 -0
- package/_cjs/chains/definitions/avalancheFuji.js +3 -3
- package/_cjs/chains/definitions/avalancheFuji.js.map +1 -1
- package/_cjs/chains/definitions/blast.js +28 -0
- package/_cjs/chains/definitions/blast.js.map +1 -0
- package/_cjs/chains/definitions/merlin.js +24 -0
- package/_cjs/chains/definitions/merlin.js.map +1 -0
- package/_cjs/chains/index.js +15 -5
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/chains/opStack/actions/getL1BaseFee.js +27 -0
- package/_cjs/chains/opStack/actions/getL1BaseFee.js.map +1 -0
- package/_cjs/chains/opStack/chains.js +5 -1
- package/_cjs/chains/opStack/chains.js.map +1 -1
- package/_cjs/chains/opStack/decorators/publicL2.js +2 -0
- package/_cjs/chains/opStack/decorators/publicL2.js.map +1 -1
- package/_cjs/chains/opStack/index.js +3 -1
- package/_cjs/chains/opStack/index.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/utils/abi/encodeAbiParameters.js.map +1 -1
- package/_esm/chains/celo/utils.js +2 -2
- package/_esm/chains/celo/utils.js.map +1 -1
- package/_esm/chains/definitions/ancient8.js +43 -0
- package/_esm/chains/definitions/ancient8.js.map +1 -0
- package/_esm/chains/definitions/ancient8Sepolia.js +43 -0
- package/_esm/chains/definitions/ancient8Sepolia.js.map +1 -0
- package/_esm/chains/definitions/auroria.js +24 -0
- package/_esm/chains/definitions/auroria.js.map +1 -0
- package/_esm/chains/definitions/avalancheFuji.js +3 -3
- package/_esm/chains/definitions/avalancheFuji.js.map +1 -1
- package/_esm/chains/definitions/blast.js +25 -0
- package/_esm/chains/definitions/blast.js.map +1 -0
- package/_esm/chains/definitions/merlin.js +21 -0
- package/_esm/chains/definitions/merlin.js.map +1 -0
- package/_esm/chains/index.js +5 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/chains/opStack/actions/getL1BaseFee.js +44 -0
- package/_esm/chains/opStack/actions/getL1BaseFee.js.map +1 -0
- package/_esm/chains/opStack/chains.js +2 -0
- package/_esm/chains/opStack/chains.js.map +1 -1
- package/_esm/chains/opStack/decorators/publicL2.js +2 -0
- package/_esm/chains/opStack/decorators/publicL2.js.map +1 -1
- package/_esm/chains/opStack/index.js +1 -0
- package/_esm/chains/opStack/index.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/utils/abi/encodeAbiParameters.js +32 -0
- package/_esm/utils/abi/encodeAbiParameters.js.map +1 -1
- package/_types/chains/definitions/ancient8.d.ts +813 -0
- package/_types/chains/definitions/ancient8.d.ts.map +1 -0
- package/_types/chains/definitions/ancient8Sepolia.d.ts +813 -0
- package/_types/chains/definitions/ancient8Sepolia.d.ts.map +1 -0
- package/_types/chains/definitions/auroria.d.ts +36 -0
- package/_types/chains/definitions/auroria.d.ts.map +1 -0
- package/_types/chains/definitions/avalancheFuji.d.ts +3 -3
- package/_types/chains/definitions/blast.d.ts +33 -0
- package/_types/chains/definitions/blast.d.ts.map +1 -0
- package/_types/chains/definitions/merlin.d.ts +36 -0
- package/_types/chains/definitions/merlin.d.ts.map +1 -0
- package/_types/chains/index.d.ts +5 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/chains/opStack/actions/getL1BaseFee.d.ts +35 -0
- package/_types/chains/opStack/actions/getL1BaseFee.d.ts.map +1 -0
- package/_types/chains/opStack/chains.d.ts +2 -0
- package/_types/chains/opStack/chains.d.ts.map +1 -1
- package/_types/chains/opStack/decorators/publicL2.d.ts +21 -0
- package/_types/chains/opStack/decorators/publicL2.d.ts.map +1 -1
- package/_types/chains/opStack/index.d.ts +1 -0
- package/_types/chains/opStack/index.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/utils/abi/encodeAbiParameters.d.ts +32 -0
- package/_types/utils/abi/encodeAbiParameters.d.ts.map +1 -1
- package/chains/celo/utils.ts +2 -2
- package/chains/definitions/ancient8.ts +44 -0
- package/chains/definitions/ancient8Sepolia.ts +44 -0
- package/chains/definitions/auroria.ts +24 -0
- package/chains/definitions/avalancheFuji.ts +3 -3
- package/chains/definitions/blast.ts +26 -0
- package/chains/definitions/merlin.ts +21 -0
- package/chains/index.ts +5 -0
- package/chains/opStack/actions/getL1BaseFee.ts +81 -0
- package/chains/opStack/chains.ts +2 -0
- package/chains/opStack/decorators/publicL2.ts +29 -0
- package/chains/opStack/index.ts +6 -0
- package/errors/version.ts +1 -1
- package/package.json +1 -1
- package/utils/abi/encodeAbiParameters.ts +32 -0
package/chains/index.ts
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
export type { Chain } from '../types/chain.js'
|
2
2
|
|
3
3
|
export { acala } from './definitions/acala.js'
|
4
|
+
export { ancient8 } from './definitions/ancient8.js'
|
5
|
+
export { ancient8Sepolia } from './definitions/ancient8Sepolia.js'
|
4
6
|
export { anvil } from './definitions/anvil.js'
|
5
7
|
export { apexTestnet } from './definitions/apexTestnet.js'
|
6
8
|
export { arbitrum } from './definitions/arbitrum.js'
|
@@ -11,6 +13,7 @@ export { arbitrumSepolia } from './definitions/arbitrumSepolia.js'
|
|
11
13
|
export { astarZkatana } from './definitions/astarZkatana.js'
|
12
14
|
export { aurora } from './definitions/aurora.js'
|
13
15
|
export { auroraTestnet } from './definitions/auroraTestnet.js'
|
16
|
+
export { auroria } from './definitions/auroria.js'
|
14
17
|
export { avalanche } from './definitions/avalanche.js'
|
15
18
|
export { avalancheFuji } from './definitions/avalancheFuji.js'
|
16
19
|
export { bahamut } from './definitions/bahamut.js'
|
@@ -22,6 +25,7 @@ export { bearNetworkChainTestnet } from './definitions/bearNetworkChainTestnet.j
|
|
22
25
|
export { berachainTestnet } from './definitions/berachainTestnet.js'
|
23
26
|
export { bitTorrent } from './definitions/bitTorrent.js'
|
24
27
|
export { bitTorrentTestnet } from './definitions/bitTorrentTestnet.js'
|
28
|
+
export { blast } from './definitions/blast.js'
|
25
29
|
export { blastSepolia } from './definitions/blastSepolia.js'
|
26
30
|
export { boba } from './definitions/boba.js'
|
27
31
|
export { bronos } from './definitions/bronos.js'
|
@@ -107,6 +111,7 @@ export { manta } from './definitions/manta.js'
|
|
107
111
|
export { mantaTestnet } from './definitions/mantaTestnet.js'
|
108
112
|
export { mantle } from './definitions/mantle.js'
|
109
113
|
export { mantleTestnet } from './definitions/mantleTestnet.js'
|
114
|
+
export { merlin } from './definitions/merlin.js'
|
110
115
|
export { metachain } from './definitions/metachain.js'
|
111
116
|
export { metachainIstanbul } from './definitions/metachainIstanbul.js'
|
112
117
|
export { meter } from './definitions/meter.js'
|
@@ -0,0 +1,81 @@
|
|
1
|
+
import type { Address } from 'abitype'
|
2
|
+
|
3
|
+
import {
|
4
|
+
type ReadContractErrorType,
|
5
|
+
readContract,
|
6
|
+
} from '../../../actions/public/readContract.js'
|
7
|
+
import { type PrepareTransactionRequestErrorType } from '../../../actions/wallet/prepareTransactionRequest.js'
|
8
|
+
import type { Client } from '../../../clients/createClient.js'
|
9
|
+
import type { Transport } from '../../../clients/transports/createTransport.js'
|
10
|
+
import type { ErrorType } from '../../../errors/utils.js'
|
11
|
+
import { type Chain, type GetChainParameter } from '../../../types/chain.js'
|
12
|
+
import type { RequestErrorType } from '../../../utils/buildRequest.js'
|
13
|
+
import { getChainContractAddress } from '../../../utils/chain/getChainContractAddress.js'
|
14
|
+
import { type HexToNumberErrorType } from '../../../utils/encoding/fromHex.js'
|
15
|
+
|
16
|
+
import { gasPriceOracleAbi } from '../abis.js'
|
17
|
+
import { contracts } from '../contracts.js'
|
18
|
+
|
19
|
+
export type GetL1BaseFeeParameters<
|
20
|
+
TChain extends Chain | undefined = Chain | undefined,
|
21
|
+
TChainOverride extends Chain | undefined = undefined,
|
22
|
+
> = GetChainParameter<TChain, TChainOverride> & {
|
23
|
+
/** Gas price oracle address. */
|
24
|
+
gasPriceOracleAddress?: Address
|
25
|
+
}
|
26
|
+
|
27
|
+
export type GetL1BaseFeeReturnType = bigint
|
28
|
+
|
29
|
+
export type GetL1BaseFeeErrorType =
|
30
|
+
| RequestErrorType
|
31
|
+
| PrepareTransactionRequestErrorType
|
32
|
+
| HexToNumberErrorType
|
33
|
+
| ReadContractErrorType
|
34
|
+
| ErrorType
|
35
|
+
|
36
|
+
/**
|
37
|
+
* get the L1 base fee
|
38
|
+
*
|
39
|
+
* @param client - Client to use
|
40
|
+
* @param parameters - {@link GetL1BaseFeeParameters}
|
41
|
+
* @returns The basefee (in wei). {@link GetL1BaseFeeReturnType}
|
42
|
+
*
|
43
|
+
* @example
|
44
|
+
* import { createPublicClient, http, parseEther } from 'viem'
|
45
|
+
* import { optimism } from 'viem/chains'
|
46
|
+
* import { getL1BaseFee } from 'viem/chains/optimism'
|
47
|
+
*
|
48
|
+
* const client = createPublicClient({
|
49
|
+
* chain: optimism,
|
50
|
+
* transport: http(),
|
51
|
+
* })
|
52
|
+
* const l1BaseFee = await getL1BaseFee(client)
|
53
|
+
*/
|
54
|
+
export async function getL1BaseFee<
|
55
|
+
TChain extends Chain | undefined,
|
56
|
+
TChainOverride extends Chain | undefined = undefined,
|
57
|
+
>(
|
58
|
+
client: Client<Transport, TChain>,
|
59
|
+
args?: GetL1BaseFeeParameters<TChain, TChainOverride>,
|
60
|
+
): Promise<GetL1BaseFeeReturnType> {
|
61
|
+
const {
|
62
|
+
chain = client.chain,
|
63
|
+
gasPriceOracleAddress: gasPriceOracleAddress_,
|
64
|
+
} = args || {}
|
65
|
+
|
66
|
+
const gasPriceOracleAddress = (() => {
|
67
|
+
if (gasPriceOracleAddress_) return gasPriceOracleAddress_
|
68
|
+
if (chain)
|
69
|
+
return getChainContractAddress({
|
70
|
+
chain,
|
71
|
+
contract: 'gasPriceOracle',
|
72
|
+
})
|
73
|
+
return contracts.gasPriceOracle.address
|
74
|
+
})()
|
75
|
+
|
76
|
+
return readContract(client, {
|
77
|
+
abi: gasPriceOracleAbi,
|
78
|
+
address: gasPriceOracleAddress,
|
79
|
+
functionName: 'l1BaseFee',
|
80
|
+
})
|
81
|
+
}
|
package/chains/opStack/chains.ts
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
export { ancient8 } from '../definitions/ancient8.js'
|
2
|
+
export { ancient8Sepolia } from '../definitions/ancient8Sepolia.js'
|
1
3
|
export { base } from '../definitions/base.js'
|
2
4
|
export { baseGoerli } from '../definitions/baseGoerli.js'
|
3
5
|
export { baseSepolia } from '../definitions/baseSepolia.js'
|
@@ -62,6 +62,11 @@ import {
|
|
62
62
|
type EstimateTotalGasReturnType,
|
63
63
|
estimateTotalGas,
|
64
64
|
} from '../actions/estimateTotalGas.js'
|
65
|
+
import {
|
66
|
+
type GetL1BaseFeeParameters,
|
67
|
+
type GetL1BaseFeeReturnType,
|
68
|
+
getL1BaseFee,
|
69
|
+
} from '../actions/getL1BaseFee.js'
|
65
70
|
|
66
71
|
export type PublicActionsL2<
|
67
72
|
chain extends Chain | undefined = Chain | undefined,
|
@@ -364,6 +369,29 @@ export type PublicActionsL2<
|
|
364
369
|
estimateL1Fee: <chainOverride extends Chain | undefined = undefined>(
|
365
370
|
parameters: EstimateL1FeeParameters<chain, account, chainOverride>,
|
366
371
|
) => Promise<EstimateL1FeeReturnType>
|
372
|
+
|
373
|
+
/**
|
374
|
+
* Get the L1 basefee
|
375
|
+
*
|
376
|
+
* @param client - Client to use
|
377
|
+
* @param parameters - {@link GetL1BaseFeeParameters}
|
378
|
+
* @returns The fee (in wei). {@link GetL1BaseFeeReturnType}
|
379
|
+
*
|
380
|
+
* @example
|
381
|
+
* import { createPublicClient, http, parseEther } from 'viem'
|
382
|
+
* import { optimism } from 'viem/chains'
|
383
|
+
* import { publicActionsL2 } from 'viem/op-stack'
|
384
|
+
*
|
385
|
+
* const client = createPublicClient({
|
386
|
+
* chain: optimism,
|
387
|
+
* transport: http(),
|
388
|
+
* }).extend(publicActionsL2())
|
389
|
+
*
|
390
|
+
* const l1BaseFee = await client.getL1BaseFee()
|
391
|
+
*/
|
392
|
+
getL1BaseFee: <chainOverride extends Chain | undefined = undefined>(
|
393
|
+
parameters?: GetL1BaseFeeParameters<chain, chainOverride>,
|
394
|
+
) => Promise<GetL1BaseFeeReturnType>
|
367
395
|
/**
|
368
396
|
* Estimates the amount of L1 data gas required to execute an L2 transaction.
|
369
397
|
*
|
@@ -479,6 +507,7 @@ export function publicActionsL2() {
|
|
479
507
|
estimateInitiateWithdrawalGas: (args) =>
|
480
508
|
estimateInitiateWithdrawalGas(client, args),
|
481
509
|
estimateL1Fee: (args) => estimateL1Fee(client, args),
|
510
|
+
getL1BaseFee: (args) => getL1BaseFee(client, args),
|
482
511
|
estimateL1Gas: (args) => estimateL1Gas(client, args),
|
483
512
|
estimateTotalFee: (args) => estimateTotalFee(client, args),
|
484
513
|
estimateTotalGas: (args) => estimateTotalGas(client, args),
|
package/chains/opStack/index.ts
CHANGED
@@ -52,6 +52,12 @@ export {
|
|
52
52
|
type EstimateL1FeeParameters,
|
53
53
|
type EstimateL1FeeReturnType,
|
54
54
|
} from './actions/estimateL1Fee.js'
|
55
|
+
export {
|
56
|
+
getL1BaseFee,
|
57
|
+
type GetL1BaseFeeErrorType,
|
58
|
+
type GetL1BaseFeeParameters,
|
59
|
+
type GetL1BaseFeeReturnType,
|
60
|
+
} from './actions/getL1BaseFee.js'
|
55
61
|
export {
|
56
62
|
estimateL1Gas,
|
57
63
|
type EstimateL1GasErrorType,
|
package/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '2.7.
|
1
|
+
export const version = '2.7.19'
|
package/package.json
CHANGED
@@ -46,6 +46,38 @@ export type EncodeAbiParametersErrorType =
|
|
46
46
|
|
47
47
|
/**
|
48
48
|
* @description Encodes a list of primitive values into an ABI-encoded hex value.
|
49
|
+
*
|
50
|
+
* - Docs: https://viem.sh/docs/abi/encodeAbiParameters#encodeabiparameters
|
51
|
+
*
|
52
|
+
* Generates ABI encoded data using the [ABI specification](https://docs.soliditylang.org/en/latest/abi-spec), given a set of ABI parameters (inputs/outputs) and their corresponding values.
|
53
|
+
*
|
54
|
+
* @param params - a set of ABI Parameters (params), that can be in the shape of the inputs or outputs attribute of an ABI Item.
|
55
|
+
* @param values - a set of values (values) that correspond to the given params.
|
56
|
+
* @example
|
57
|
+
* ```typescript
|
58
|
+
* import { encodeAbiParameters } from 'viem'
|
59
|
+
*
|
60
|
+
* const encodedData = encodeAbiParameters(
|
61
|
+
* [
|
62
|
+
* { name: 'x', type: 'string' },
|
63
|
+
* { name: 'y', type: 'uint' },
|
64
|
+
* { name: 'z', type: 'bool' }
|
65
|
+
* ],
|
66
|
+
* ['wagmi', 420n, true]
|
67
|
+
* )
|
68
|
+
* ```
|
69
|
+
*
|
70
|
+
* You can also pass in Human Readable parameters with the parseAbiParameters utility.
|
71
|
+
*
|
72
|
+
* @example
|
73
|
+
* ```typescript
|
74
|
+
* import { encodeAbiParameters, parseAbiParameters } from 'viem'
|
75
|
+
*
|
76
|
+
* const encodedData = encodeAbiParameters(
|
77
|
+
* parseAbiParameters('string x, uint y, bool z'),
|
78
|
+
* ['wagmi', 420n, true]
|
79
|
+
* )
|
80
|
+
* ```
|
49
81
|
*/
|
50
82
|
export function encodeAbiParameters<
|
51
83
|
const TParams extends readonly AbiParameter[] | readonly unknown[],
|