viem 2.10.9 → 2.10.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/CHANGELOG.md +18 -0
- package/_cjs/actions/public/call.js +3 -60
- package/_cjs/actions/public/call.js.map +1 -1
- package/_cjs/actions/public/estimateGas.js +8 -2
- package/_cjs/actions/public/estimateGas.js.map +1 -1
- package/_cjs/chains/definitions/bob.js +33 -0
- package/_cjs/chains/definitions/bob.js.map +1 -0
- package/_cjs/chains/definitions/funkiSepolia.js +34 -0
- package/_cjs/chains/definitions/funkiSepolia.js.map +1 -0
- package/_cjs/chains/definitions/lisk.js +34 -0
- package/_cjs/chains/definitions/lisk.js.map +1 -0
- package/_cjs/chains/definitions/metalL2.js +53 -0
- package/_cjs/chains/definitions/metalL2.js.map +1 -0
- package/_cjs/chains/index.js +14 -6
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/errors/version.js.map +1 -1
- package/_cjs/op-stack/chains.js +3 -1
- package/_cjs/op-stack/chains.js.map +1 -1
- package/_cjs/utils/stateOverride.js +63 -0
- package/_cjs/utils/stateOverride.js.map +1 -0
- package/_esm/actions/public/call.js +2 -56
- package/_esm/actions/public/call.js.map +1 -1
- package/_esm/actions/public/estimateGas.js +8 -2
- package/_esm/actions/public/estimateGas.js.map +1 -1
- package/_esm/chains/definitions/bob.js +30 -0
- package/_esm/chains/definitions/bob.js.map +1 -0
- package/_esm/chains/definitions/funkiSepolia.js +31 -0
- package/_esm/chains/definitions/funkiSepolia.js.map +1 -0
- package/_esm/chains/definitions/lisk.js +31 -0
- package/_esm/chains/definitions/lisk.js.map +1 -0
- package/_esm/chains/definitions/metalL2.js +50 -0
- package/_esm/chains/definitions/metalL2.js.map +1 -0
- package/_esm/chains/index.js +4 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/errors/version.js.map +1 -1
- package/_esm/op-stack/chains.js +1 -0
- package/_esm/op-stack/chains.js.map +1 -1
- package/_esm/utils/stateOverride.js +57 -0
- package/_esm/utils/stateOverride.js.map +1 -0
- package/_types/actions/public/call.d.ts +3 -12
- package/_types/actions/public/call.d.ts.map +1 -1
- package/_types/actions/public/estimateGas.d.ts +2 -0
- package/_types/actions/public/estimateGas.d.ts.map +1 -1
- package/_types/celo/types.d.ts +2 -2
- package/_types/celo/types.d.ts.map +1 -1
- package/_types/chains/definitions/bob.d.ts +34 -0
- package/_types/chains/definitions/bob.d.ts.map +1 -0
- package/_types/chains/definitions/funkiSepolia.d.ts +1064 -0
- package/_types/chains/definitions/funkiSepolia.d.ts.map +1 -0
- package/_types/chains/definitions/lisk.d.ts +1453 -0
- package/_types/chains/definitions/lisk.d.ts.map +1 -0
- package/_types/chains/definitions/metalL2.d.ts +1080 -0
- package/_types/chains/definitions/metalL2.d.ts.map +1 -0
- package/_types/chains/index.d.ts +4 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/errors/version.d.ts.map +1 -1
- package/_types/op-stack/chains.d.ts +1 -0
- package/_types/op-stack/chains.d.ts.map +1 -1
- package/_types/op-stack/types/transaction.d.ts +2 -2
- package/_types/op-stack/types/transaction.d.ts.map +1 -1
- package/_types/types/eip1193.d.ts +11 -3
- package/_types/types/eip1193.d.ts.map +1 -1
- package/_types/utils/stateOverride.d.ts +16 -0
- package/_types/utils/stateOverride.d.ts.map +1 -0
- package/_types/zksync/types/transaction.d.ts +1 -1
- package/_types/zksync/types/transaction.d.ts.map +1 -1
- package/actions/public/call.ts +8 -91
- package/actions/public/estimateGas.ts +11 -1
- package/celo/types.ts +3 -3
- package/chains/definitions/bob.ts +30 -0
- package/chains/definitions/funkiSepolia.ts +32 -0
- package/chains/definitions/lisk.ts +31 -0
- package/chains/definitions/metalL2.ts +51 -0
- package/chains/index.ts +4 -0
- package/errors/version.ts +1 -1
- package/op-stack/chains.ts +1 -0
- package/op-stack/types/transaction.ts +2 -2
- package/package.json +1 -1
- package/types/eip1193.ts +11 -1
- package/utils/stateOverride.ts +98 -0
- package/zksync/types/transaction.ts +2 -2
@@ -0,0 +1,32 @@
|
|
1
|
+
import { chainConfig } from '../../op-stack/chainConfig.js'
|
2
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
3
|
+
|
4
|
+
const sourceId = 11_155_111 // sepolia
|
5
|
+
|
6
|
+
export const funkiSepolia = defineChain({
|
7
|
+
...chainConfig,
|
8
|
+
id: 3397901,
|
9
|
+
network: 'funkiSepolia',
|
10
|
+
name: 'Funki Sepolia Sandbox',
|
11
|
+
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
|
12
|
+
rpcUrls: {
|
13
|
+
default: {
|
14
|
+
http: ['https://funki-testnet.alt.technology'],
|
15
|
+
},
|
16
|
+
},
|
17
|
+
blockExplorers: {
|
18
|
+
default: {
|
19
|
+
name: 'Funki Sepolia Sandbox Explorer',
|
20
|
+
url: 'https://sepolia-sandbox.funkichain.com/',
|
21
|
+
},
|
22
|
+
},
|
23
|
+
testnet: true,
|
24
|
+
contracts: {
|
25
|
+
...chainConfig.contracts,
|
26
|
+
multicall3: {
|
27
|
+
address: '0xca11bde05977b3631167028862be2a173976ca11',
|
28
|
+
blockCreated: 1620204,
|
29
|
+
},
|
30
|
+
},
|
31
|
+
sourceId,
|
32
|
+
})
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
import { chainConfig } from '../../zksync/chainConfig.js'
|
3
|
+
|
4
|
+
export const lisk = /*#__PURE__*/ defineChain({
|
5
|
+
...chainConfig,
|
6
|
+
id: 1135,
|
7
|
+
name: 'Lisk',
|
8
|
+
network: 'lisk',
|
9
|
+
nativeCurrency: {
|
10
|
+
decimals: 18,
|
11
|
+
name: 'Ether',
|
12
|
+
symbol: 'ETH',
|
13
|
+
},
|
14
|
+
rpcUrls: {
|
15
|
+
default: {
|
16
|
+
http: ['https://rpc.api.lisk.com'],
|
17
|
+
},
|
18
|
+
},
|
19
|
+
blockExplorers: {
|
20
|
+
default: {
|
21
|
+
name: 'Blockscout',
|
22
|
+
url: 'https://blockscout.lisk.com',
|
23
|
+
apiUrl: 'https://blockscout.lisk.com/api',
|
24
|
+
},
|
25
|
+
},
|
26
|
+
contracts: {
|
27
|
+
multicall3: {
|
28
|
+
address: '0xA9d71E1dd7ca26F26e656E66d6AA81ed7f745bf0',
|
29
|
+
},
|
30
|
+
},
|
31
|
+
})
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import { chainConfig } from '../../op-stack/chainConfig.js'
|
2
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
3
|
+
|
4
|
+
const sourceId = 1 // mainnet
|
5
|
+
|
6
|
+
export const metalL2 = /*#__PURE__*/ defineChain({
|
7
|
+
...chainConfig,
|
8
|
+
id: 1750,
|
9
|
+
name: 'Metal L2',
|
10
|
+
nativeCurrency: {
|
11
|
+
decimals: 18,
|
12
|
+
name: 'Ether',
|
13
|
+
symbol: 'ETH',
|
14
|
+
},
|
15
|
+
rpcUrls: {
|
16
|
+
default: {
|
17
|
+
http: ['https://rpc.metall2.com'],
|
18
|
+
webSocket: ['wss://rpc.metall2.com'],
|
19
|
+
},
|
20
|
+
},
|
21
|
+
blockExplorers: {
|
22
|
+
default: {
|
23
|
+
name: 'Explorer',
|
24
|
+
url: 'https://explorer.metall2.com',
|
25
|
+
apiUrl: 'https://explorer.metall2.com/api',
|
26
|
+
},
|
27
|
+
},
|
28
|
+
contracts: {
|
29
|
+
...chainConfig.contracts,
|
30
|
+
l2OutputOracle: {
|
31
|
+
[sourceId]: {
|
32
|
+
address: '0x3B1F7aDa0Fcc26B13515af752Dd07fB1CAc11426',
|
33
|
+
},
|
34
|
+
},
|
35
|
+
multicall3: {
|
36
|
+
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
37
|
+
blockCreated: 0,
|
38
|
+
},
|
39
|
+
portal: {
|
40
|
+
[sourceId]: {
|
41
|
+
address: '0x3F37aBdE2C6b5B2ed6F8045787Df1ED1E3753956',
|
42
|
+
},
|
43
|
+
},
|
44
|
+
l1StandardBridge: {
|
45
|
+
[sourceId]: {
|
46
|
+
address: '0x6d0f65D59b55B0FEC5d2d15365154DcADC140BF3',
|
47
|
+
},
|
48
|
+
},
|
49
|
+
},
|
50
|
+
sourceId,
|
51
|
+
})
|
package/chains/index.ts
CHANGED
@@ -33,6 +33,7 @@ export { bitTorrent } from './definitions/bitTorrent.js'
|
|
33
33
|
export { bitTorrentTestnet } from './definitions/bitTorrentTestnet.js'
|
34
34
|
export { blast } from './definitions/blast.js'
|
35
35
|
export { blastSepolia } from './definitions/blastSepolia.js'
|
36
|
+
export { bob } from './definitions/bob.js'
|
36
37
|
export { boba } from './definitions/boba.js'
|
37
38
|
export { bronos } from './definitions/bronos.js'
|
38
39
|
export { bronosTestnet } from './definitions/bronosTestnet.js'
|
@@ -92,6 +93,7 @@ export { flowTestnet } from './definitions/flowTestnet.js'
|
|
92
93
|
export { foundry } from './definitions/foundry.js'
|
93
94
|
export { fraxtal } from './definitions/fraxtal.js'
|
94
95
|
export { fraxtalTestnet } from './definitions/fraxtalTestnet.js'
|
96
|
+
export { funkiSepolia } from './definitions/funkiSepolia.js'
|
95
97
|
export { fuse } from './definitions/fuse.js'
|
96
98
|
export { fuseSparknet } from './definitions/fuseSparknet.js'
|
97
99
|
export { iotex } from './definitions/iotex.js'
|
@@ -129,6 +131,7 @@ export { lineaGoerli } from './definitions/lineaGoerli.js'
|
|
129
131
|
export { lineaSepolia } from './definitions/lineaSepolia.js'
|
130
132
|
/** @deprecated Use `lineaGoerli` instead. */
|
131
133
|
export { lineaTestnet } from './definitions/lineaTestnet.js'
|
134
|
+
export { lisk } from './definitions/lisk.js'
|
132
135
|
export { liskSepolia } from './definitions/liskSepolia.js'
|
133
136
|
export { localhost } from './definitions/localhost.js'
|
134
137
|
export { lukso } from './definitions/lukso.js'
|
@@ -144,6 +147,7 @@ export { mantleTestnet } from './definitions/mantleTestnet.js'
|
|
144
147
|
export { merlin } from './definitions/merlin.js'
|
145
148
|
export { metachain } from './definitions/metachain.js'
|
146
149
|
export { metachainIstanbul } from './definitions/metachainIstanbul.js'
|
150
|
+
export { metalL2 } from './definitions/metalL2.js'
|
147
151
|
export { meter } from './definitions/meter.js'
|
148
152
|
export { meterTestnet } from './definitions/meterTestnet.js'
|
149
153
|
export { metis } from './definitions/metis.js'
|
package/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '2.10.
|
1
|
+
export const version = '2.10.11'
|
package/op-stack/chains.ts
CHANGED
@@ -5,6 +5,7 @@ export { baseGoerli } from '../chains/definitions/baseGoerli.js'
|
|
5
5
|
export { baseSepolia } from '../chains/definitions/baseSepolia.js'
|
6
6
|
export { fraxtal } from '../chains/definitions/fraxtal.js'
|
7
7
|
export { fraxtalTestnet } from '../chains/definitions/fraxtalTestnet.js'
|
8
|
+
export { metalL2 } from '../chains/definitions/metalL2.js'
|
8
9
|
export { optimism } from '../chains/definitions/optimism.js'
|
9
10
|
export { optimismGoerli } from '../chains/definitions/optimismGoerli.js'
|
10
11
|
export { optimismSepolia } from '../chains/definitions/optimismSepolia.js'
|
@@ -3,17 +3,17 @@ import type { Hex } from '../../types/misc.js'
|
|
3
3
|
import type {
|
4
4
|
Index,
|
5
5
|
Quantity,
|
6
|
-
RpcTransaction as RpcTransaction_,
|
7
6
|
RpcTransactionReceipt,
|
7
|
+
RpcTransaction as RpcTransaction_,
|
8
8
|
} from '../../types/rpc.js'
|
9
9
|
import type {
|
10
|
-
Transaction as Transaction_,
|
11
10
|
TransactionBase,
|
12
11
|
TransactionReceipt,
|
13
12
|
TransactionSerializable,
|
14
13
|
TransactionSerializableBase,
|
15
14
|
TransactionSerialized,
|
16
15
|
TransactionType,
|
16
|
+
Transaction as Transaction_,
|
17
17
|
} from '../../types/transaction.js'
|
18
18
|
import type { OneOf } from '../../types/utils.js'
|
19
19
|
|
package/package.json
CHANGED
package/types/eip1193.ts
CHANGED
@@ -4,13 +4,13 @@ import type { BlockTag } from './block.js'
|
|
4
4
|
import type { Hash, Hex, LogTopic } from './misc.js'
|
5
5
|
import type { RpcStateOverride } from './rpc.js'
|
6
6
|
import type {
|
7
|
-
Quantity,
|
8
7
|
RpcBlock as Block,
|
9
8
|
RpcBlockIdentifier as BlockIdentifier,
|
10
9
|
RpcBlockNumber as BlockNumber,
|
11
10
|
RpcFeeHistory as FeeHistory,
|
12
11
|
RpcLog as Log,
|
13
12
|
RpcProof as Proof,
|
13
|
+
Quantity,
|
14
14
|
RpcTransaction as Transaction,
|
15
15
|
RpcTransactionReceipt as TransactionReceipt,
|
16
16
|
RpcTransactionRequest as TransactionRequest,
|
@@ -331,6 +331,11 @@ export type PublicRpcSchema = [
|
|
331
331
|
Parameters:
|
332
332
|
| [transaction: TransactionRequest]
|
333
333
|
| [transaction: TransactionRequest, block: BlockNumber | BlockTag]
|
334
|
+
| [
|
335
|
+
transaction: TransactionRequest,
|
336
|
+
block: BlockNumber | BlockTag,
|
337
|
+
RpcStateOverride,
|
338
|
+
]
|
334
339
|
ReturnType: Quantity
|
335
340
|
},
|
336
341
|
/**
|
@@ -1197,6 +1202,11 @@ export type WalletRpcSchema = [
|
|
1197
1202
|
Parameters:
|
1198
1203
|
| [transaction: TransactionRequest]
|
1199
1204
|
| [transaction: TransactionRequest, block: BlockNumber | BlockTag]
|
1205
|
+
| [
|
1206
|
+
transaction: TransactionRequest,
|
1207
|
+
block: BlockNumber | BlockTag,
|
1208
|
+
RpcStateOverride,
|
1209
|
+
]
|
1200
1210
|
ReturnType: Quantity
|
1201
1211
|
},
|
1202
1212
|
/**
|
@@ -0,0 +1,98 @@
|
|
1
|
+
import {
|
2
|
+
InvalidAddressError,
|
3
|
+
type InvalidAddressErrorType,
|
4
|
+
} from '../errors/address.js'
|
5
|
+
import {
|
6
|
+
InvalidBytesLengthError,
|
7
|
+
type InvalidBytesLengthErrorType,
|
8
|
+
} from '../errors/data.js'
|
9
|
+
import {
|
10
|
+
AccountStateConflictError,
|
11
|
+
type AccountStateConflictErrorType,
|
12
|
+
StateAssignmentConflictError,
|
13
|
+
type StateAssignmentConflictErrorType,
|
14
|
+
} from '../errors/stateOverride.js'
|
15
|
+
import type {
|
16
|
+
RpcAccountStateOverride,
|
17
|
+
RpcStateMapping,
|
18
|
+
RpcStateOverride,
|
19
|
+
} from '../types/rpc.js'
|
20
|
+
import type { StateMapping, StateOverride } from '../types/stateOverride.js'
|
21
|
+
import { isAddress } from './address/isAddress.js'
|
22
|
+
import { type NumberToHexErrorType, numberToHex } from './encoding/toHex.js'
|
23
|
+
|
24
|
+
export type SerializeStateMappingParameters = StateMapping | undefined
|
25
|
+
|
26
|
+
export type SerializeStateMappingErrorType = InvalidBytesLengthErrorType
|
27
|
+
|
28
|
+
export function serializeStateMapping(
|
29
|
+
stateMapping: SerializeStateMappingParameters,
|
30
|
+
): RpcStateMapping | undefined {
|
31
|
+
if (!stateMapping || stateMapping.length === 0) return undefined
|
32
|
+
return stateMapping.reduce((acc, { slot, value }) => {
|
33
|
+
if (slot.length !== 66)
|
34
|
+
throw new InvalidBytesLengthError({
|
35
|
+
size: slot.length,
|
36
|
+
targetSize: 66,
|
37
|
+
type: 'hex',
|
38
|
+
})
|
39
|
+
if (value.length !== 66)
|
40
|
+
throw new InvalidBytesLengthError({
|
41
|
+
size: value.length,
|
42
|
+
targetSize: 66,
|
43
|
+
type: 'hex',
|
44
|
+
})
|
45
|
+
acc[slot] = value
|
46
|
+
return acc
|
47
|
+
}, {} as RpcStateMapping)
|
48
|
+
}
|
49
|
+
|
50
|
+
export type SerializeAccountStateOverrideParameters = Omit<
|
51
|
+
StateOverride[number],
|
52
|
+
'address'
|
53
|
+
>
|
54
|
+
|
55
|
+
export type SerializeAccountStateOverrideErrorType =
|
56
|
+
| NumberToHexErrorType
|
57
|
+
| StateAssignmentConflictErrorType
|
58
|
+
| SerializeStateMappingErrorType
|
59
|
+
|
60
|
+
export function serializeAccountStateOverride(
|
61
|
+
parameters: SerializeAccountStateOverrideParameters,
|
62
|
+
): RpcAccountStateOverride {
|
63
|
+
const { balance, nonce, state, stateDiff, code } = parameters
|
64
|
+
const rpcAccountStateOverride: RpcAccountStateOverride = {}
|
65
|
+
if (code !== undefined) rpcAccountStateOverride.code = code
|
66
|
+
if (balance !== undefined)
|
67
|
+
rpcAccountStateOverride.balance = numberToHex(balance)
|
68
|
+
if (nonce !== undefined) rpcAccountStateOverride.nonce = numberToHex(nonce)
|
69
|
+
if (state !== undefined)
|
70
|
+
rpcAccountStateOverride.state = serializeStateMapping(state)
|
71
|
+
if (stateDiff !== undefined) {
|
72
|
+
if (rpcAccountStateOverride.state) throw new StateAssignmentConflictError()
|
73
|
+
rpcAccountStateOverride.stateDiff = serializeStateMapping(stateDiff)
|
74
|
+
}
|
75
|
+
return rpcAccountStateOverride
|
76
|
+
}
|
77
|
+
|
78
|
+
export type SerializeStateOverrideParameters = StateOverride | undefined
|
79
|
+
|
80
|
+
export type SerializeStateOverrideErrorType =
|
81
|
+
| InvalidAddressErrorType
|
82
|
+
| AccountStateConflictErrorType
|
83
|
+
| SerializeAccountStateOverrideErrorType
|
84
|
+
|
85
|
+
export function serializeStateOverride(
|
86
|
+
parameters?: SerializeStateOverrideParameters,
|
87
|
+
): RpcStateOverride | undefined {
|
88
|
+
if (!parameters) return undefined
|
89
|
+
const rpcStateOverride: RpcStateOverride = {}
|
90
|
+
for (const { address, ...accountState } of parameters) {
|
91
|
+
if (!isAddress(address, { strict: false }))
|
92
|
+
throw new InvalidAddressError({ address })
|
93
|
+
if (rpcStateOverride[address])
|
94
|
+
throw new AccountStateConflictError({ address: address })
|
95
|
+
rpcStateOverride[address] = serializeAccountStateOverride(accountState)
|
96
|
+
}
|
97
|
+
return rpcStateOverride
|
98
|
+
}
|
@@ -7,18 +7,18 @@ import type {
|
|
7
7
|
RpcTransactionRequest as RpcTransactionRequest_,
|
8
8
|
} from '../../types/rpc.js'
|
9
9
|
import type {
|
10
|
-
Transaction as Transaction_,
|
11
10
|
TransactionBase,
|
12
11
|
TransactionEIP1559 as TransactionEIP1559_,
|
13
12
|
TransactionEIP2930 as TransactionEIP2930_,
|
14
13
|
TransactionLegacy as TransactionLegacy_,
|
15
14
|
TransactionReceipt,
|
16
|
-
TransactionRequest as TransactionRequest_,
|
17
15
|
TransactionRequestBase,
|
16
|
+
TransactionRequest as TransactionRequest_,
|
18
17
|
TransactionSerializable,
|
19
18
|
TransactionSerializableEIP1559,
|
20
19
|
TransactionSerialized,
|
21
20
|
TransactionType,
|
21
|
+
Transaction as Transaction_,
|
22
22
|
} from '../../types/transaction.js'
|
23
23
|
import type { ExactPartial, OneOf, UnionOmit } from '../../types/utils.js'
|
24
24
|
import type { ZkSyncEip712Meta } from './eip712.js'
|