viem 2.22.8 → 2.22.10
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 +24 -0
- package/README.md +0 -12
- package/_cjs/account-abstraction/accounts/createWebAuthnCredential.js +11 -3
- package/_cjs/account-abstraction/accounts/createWebAuthnCredential.js.map +1 -1
- package/_cjs/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.js +2 -2
- package/_cjs/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.js.map +1 -1
- package/_cjs/account-abstraction/accounts/toWebAuthnAccount.js +13 -2
- package/_cjs/account-abstraction/accounts/toWebAuthnAccount.js.map +1 -1
- package/_cjs/chains/definitions/alephZeroTestnet.js +30 -0
- package/_cjs/chains/definitions/alephZeroTestnet.js.map +1 -0
- package/_cjs/chains/definitions/artheraTestnet.js +28 -0
- package/_cjs/chains/definitions/artheraTestnet.js.map +1 -0
- package/_cjs/chains/definitions/goat.js +29 -0
- package/_cjs/chains/definitions/goat.js.map +1 -0
- package/_cjs/chains/definitions/near.js +24 -0
- package/_cjs/chains/definitions/near.js.map +1 -0
- package/_cjs/chains/definitions/nearTestnet.js +24 -0
- package/_cjs/chains/definitions/nearTestnet.js.map +1 -0
- package/_cjs/chains/definitions/soneium.js +55 -0
- package/_cjs/chains/definitions/soneium.js.map +1 -0
- package/_cjs/chains/index.js +23 -10
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/clients/transports/createTransport.js +2 -2
- package/_cjs/clients/transports/createTransport.js.map +1 -1
- package/_cjs/clients/transports/custom.js +2 -1
- package/_cjs/clients/transports/custom.js.map +1 -1
- package/_cjs/clients/transports/http.js +2 -1
- package/_cjs/clients/transports/http.js.map +1 -1
- package/_cjs/clients/transports/ipc.js +2 -1
- package/_cjs/clients/transports/ipc.js.map +1 -1
- package/_cjs/clients/transports/webSocket.js +2 -1
- package/_cjs/clients/transports/webSocket.js.map +1 -1
- package/_cjs/errors/rpc.js +1 -1
- package/_cjs/errors/rpc.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/buildRequest.js +10 -1
- package/_cjs/utils/buildRequest.js.map +1 -1
- package/_cjs/zksync/actions/withdraw.js +53 -0
- package/_cjs/zksync/actions/withdraw.js.map +1 -0
- package/_cjs/zksync/constants/abis.js +246 -1
- package/_cjs/zksync/constants/abis.js.map +1 -1
- package/_cjs/zksync/constants/address.js.map +1 -1
- package/_cjs/zksync/decorators/walletL2.js +10 -0
- package/_cjs/zksync/decorators/walletL2.js.map +1 -0
- package/_cjs/zksync/index.js +9 -2
- package/_cjs/zksync/index.js.map +1 -1
- package/_esm/account-abstraction/accounts/createWebAuthnCredential.js +11 -2
- package/_esm/account-abstraction/accounts/createWebAuthnCredential.js.map +1 -1
- package/_esm/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.js +2 -2
- package/_esm/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.js.map +1 -1
- package/_esm/account-abstraction/accounts/toWebAuthnAccount.js +13 -2
- package/_esm/account-abstraction/accounts/toWebAuthnAccount.js.map +1 -1
- package/_esm/chains/definitions/alephZeroTestnet.js +27 -0
- package/_esm/chains/definitions/alephZeroTestnet.js.map +1 -0
- package/_esm/chains/definitions/artheraTestnet.js +25 -0
- package/_esm/chains/definitions/artheraTestnet.js.map +1 -0
- package/_esm/chains/definitions/goat.js +26 -0
- package/_esm/chains/definitions/goat.js.map +1 -0
- package/_esm/chains/definitions/near.js +21 -0
- package/_esm/chains/definitions/near.js.map +1 -0
- package/_esm/chains/definitions/nearTestnet.js +21 -0
- package/_esm/chains/definitions/nearTestnet.js.map +1 -0
- package/_esm/chains/definitions/soneium.js +52 -0
- package/_esm/chains/definitions/soneium.js.map +1 -0
- package/_esm/chains/index.js +6 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/clients/transports/createTransport.js +2 -2
- package/_esm/clients/transports/createTransport.js.map +1 -1
- package/_esm/clients/transports/custom.js +2 -1
- package/_esm/clients/transports/custom.js.map +1 -1
- package/_esm/clients/transports/http.js +2 -1
- package/_esm/clients/transports/http.js.map +1 -1
- package/_esm/clients/transports/ipc.js +2 -1
- package/_esm/clients/transports/ipc.js.map +1 -1
- package/_esm/clients/transports/webSocket.js +2 -1
- package/_esm/clients/transports/webSocket.js.map +1 -1
- package/_esm/errors/rpc.js +1 -1
- package/_esm/errors/rpc.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/buildRequest.js +10 -1
- package/_esm/utils/buildRequest.js.map +1 -1
- package/_esm/zksync/actions/withdraw.js +120 -0
- package/_esm/zksync/actions/withdraw.js.map +1 -0
- package/_esm/zksync/constants/abis.js +245 -0
- package/_esm/zksync/constants/abis.js.map +1 -1
- package/_esm/zksync/constants/address.js +2 -0
- package/_esm/zksync/constants/address.js.map +1 -1
- package/_esm/zksync/decorators/walletL2.js +7 -0
- package/_esm/zksync/decorators/walletL2.js.map +1 -0
- package/_esm/zksync/index.js +3 -0
- package/_esm/zksync/index.js.map +1 -1
- package/_types/account-abstraction/accounts/createWebAuthnCredential.d.ts +10 -1
- package/_types/account-abstraction/accounts/createWebAuthnCredential.d.ts.map +1 -1
- package/_types/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.d.ts +2 -2
- package/_types/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.d.ts.map +1 -1
- package/_types/account-abstraction/accounts/toWebAuthnAccount.d.ts +4 -3
- package/_types/account-abstraction/accounts/toWebAuthnAccount.d.ts.map +1 -1
- package/_types/account-abstraction/accounts/types.d.ts +6 -1
- package/_types/account-abstraction/accounts/types.d.ts.map +1 -1
- package/_types/chains/definitions/alephZeroTestnet.d.ts +35 -0
- package/_types/chains/definitions/alephZeroTestnet.d.ts.map +1 -0
- package/_types/chains/definitions/artheraTestnet.d.ts +34 -0
- package/_types/chains/definitions/artheraTestnet.d.ts.map +1 -0
- package/_types/chains/definitions/goat.d.ts +33 -0
- package/_types/chains/definitions/goat.d.ts.map +1 -0
- package/_types/chains/definitions/near.d.ts +37 -0
- package/_types/chains/definitions/near.d.ts.map +1 -0
- package/_types/chains/definitions/nearTestnet.d.ts +37 -0
- package/_types/chains/definitions/nearTestnet.d.ts.map +1 -0
- package/_types/chains/definitions/soneium.d.ts +306 -0
- package/_types/chains/definitions/soneium.d.ts.map +1 -0
- package/_types/chains/index.d.ts +6 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/clients/transports/createTransport.d.ts +8 -1
- package/_types/clients/transports/createTransport.d.ts.map +1 -1
- package/_types/clients/transports/custom.d.ts +2 -0
- package/_types/clients/transports/custom.d.ts.map +1 -1
- package/_types/clients/transports/http.d.ts +2 -0
- package/_types/clients/transports/http.d.ts.map +1 -1
- package/_types/clients/transports/ipc.d.ts +2 -0
- package/_types/clients/transports/ipc.d.ts.map +1 -1
- package/_types/clients/transports/webSocket.d.ts +2 -0
- package/_types/clients/transports/webSocket.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/types/eip1193.d.ts +9 -0
- package/_types/types/eip1193.d.ts.map +1 -1
- package/_types/utils/buildRequest.d.ts.map +1 -1
- package/_types/zksync/actions/withdraw.d.ts +94 -0
- package/_types/zksync/actions/withdraw.d.ts.map +1 -0
- package/_types/zksync/constants/abis.d.ts +191 -0
- package/_types/zksync/constants/abis.d.ts.map +1 -1
- package/_types/zksync/constants/address.d.ts +2 -0
- package/_types/zksync/constants/address.d.ts.map +1 -1
- package/_types/zksync/decorators/walletL2.d.ts +75 -0
- package/_types/zksync/decorators/walletL2.d.ts.map +1 -0
- package/_types/zksync/index.d.ts +3 -0
- package/_types/zksync/index.d.ts.map +1 -1
- package/account-abstraction/accounts/createWebAuthnCredential.ts +27 -7
- package/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.ts +4 -6
- package/account-abstraction/accounts/toWebAuthnAccount.ts +16 -4
- package/account-abstraction/accounts/types.ts +8 -1
- package/chains/definitions/alephZeroTestnet.ts +27 -0
- package/chains/definitions/artheraTestnet.ts +25 -0
- package/chains/definitions/goat.ts +26 -0
- package/chains/definitions/near.ts +21 -0
- package/chains/definitions/nearTestnet.ts +21 -0
- package/chains/definitions/soneium.ts +53 -0
- package/chains/index.ts +6 -0
- package/clients/transports/createTransport.ts +14 -1
- package/clients/transports/custom.ts +9 -1
- package/clients/transports/http.ts +4 -0
- package/clients/transports/ipc.ts +10 -1
- package/clients/transports/webSocket.ts +4 -0
- package/errors/rpc.ts +1 -1
- package/errors/version.ts +1 -1
- package/op-stack/chains.ts +1 -0
- package/package.json +2 -3
- package/types/eip1193.ts +14 -3
- package/utils/buildRequest.ts +12 -0
- package/zksync/actions/withdraw.ts +185 -0
- package/zksync/constants/abis.ts +246 -0
- package/zksync/constants/address.ts +2 -0
- package/zksync/decorators/walletL2.ts +95 -0
- package/zksync/index.ts +16 -0
@@ -1,7 +1,27 @@
|
|
1
|
-
//
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
// TODO(v3): Remove this in favor of `ox/WebAuthnP256` entirely.
|
2
|
+
import * as PublicKey from 'ox/PublicKey'
|
3
|
+
import * as WebAuthnP256 from 'ox/WebAuthnP256'
|
4
|
+
|
5
|
+
import type { Hex } from '../../types/misc.js'
|
6
|
+
|
7
|
+
export type P256Credential = {
|
8
|
+
id: WebAuthnP256.P256Credential['id']
|
9
|
+
publicKey: Hex
|
10
|
+
raw: WebAuthnP256.P256Credential['raw']
|
11
|
+
}
|
12
|
+
|
13
|
+
export type CreateWebAuthnCredentialParameters =
|
14
|
+
WebAuthnP256.createCredential.Options
|
15
|
+
|
16
|
+
export type CreateWebAuthnCredentialReturnType = P256Credential
|
17
|
+
|
18
|
+
export async function createWebAuthnCredential(
|
19
|
+
parameters: CreateWebAuthnCredentialParameters,
|
20
|
+
): Promise<CreateWebAuthnCredentialReturnType> {
|
21
|
+
const credential = await WebAuthnP256.createCredential(parameters)
|
22
|
+
return {
|
23
|
+
id: credential.id,
|
24
|
+
publicKey: PublicKey.toHex(credential.publicKey, { includePrefix: false }),
|
25
|
+
raw: credential.raw,
|
26
|
+
}
|
27
|
+
}
|
@@ -1,8 +1,6 @@
|
|
1
1
|
import type { Address, TypedData } from 'abitype'
|
2
|
-
import
|
3
|
-
|
4
|
-
parseSignature as parseP256Signature,
|
5
|
-
} from 'webauthn-p256'
|
2
|
+
import * as Signature from 'ox/Signature'
|
3
|
+
import type * as WebAuthnP256 from 'ox/WebAuthnP256'
|
6
4
|
|
7
5
|
import type { LocalAccount } from '../../../accounts/types.js'
|
8
6
|
import { readContract } from '../../../actions/public/readContract.js'
|
@@ -319,10 +317,10 @@ export function toWebAuthnSignature({
|
|
319
317
|
webauthn,
|
320
318
|
signature,
|
321
319
|
}: {
|
322
|
-
webauthn:
|
320
|
+
webauthn: WebAuthnP256.SignMetadata
|
323
321
|
signature: Hex
|
324
322
|
}) {
|
325
|
-
const { r, s } =
|
323
|
+
const { r, s } = Signature.fromHex(signature)
|
326
324
|
return encodeAbiParameters(
|
327
325
|
[
|
328
326
|
{
|
@@ -1,8 +1,10 @@
|
|
1
|
-
import
|
1
|
+
import * as Signature from 'ox/Signature'
|
2
|
+
import * as WebAuthnP256 from 'ox/WebAuthnP256'
|
2
3
|
|
3
4
|
import type { ErrorType } from '../../errors/utils.js'
|
4
5
|
import { hashMessage } from '../../utils/signature/hashMessage.js'
|
5
6
|
import { hashTypedData } from '../../utils/signature/hashTypedData.js'
|
7
|
+
import type { P256Credential } from './createWebAuthnCredential.js'
|
6
8
|
import type { WebAuthnAccount } from './types.js'
|
7
9
|
|
8
10
|
export type ToWebAuthnAccountParameters = {
|
@@ -19,11 +21,11 @@ export type ToWebAuthnAccountParameters = {
|
|
19
21
|
*
|
20
22
|
* @default window.navigator.credentials.get
|
21
23
|
*/
|
22
|
-
getFn?:
|
24
|
+
getFn?: WebAuthnP256.sign.Options['getFn'] | undefined
|
23
25
|
/**
|
24
26
|
* The relying party identifier to use.
|
25
27
|
*/
|
26
|
-
rpId?:
|
28
|
+
rpId?: WebAuthnP256.sign.Options['rpId'] | undefined
|
27
29
|
}
|
28
30
|
|
29
31
|
export type ToWebAuthnAccountReturnType = WebAuthnAccount
|
@@ -44,7 +46,17 @@ export function toWebAuthnAccount(
|
|
44
46
|
id,
|
45
47
|
publicKey,
|
46
48
|
async sign({ hash }) {
|
47
|
-
|
49
|
+
const { metadata, raw, signature } = await WebAuthnP256.sign({
|
50
|
+
credentialId: id,
|
51
|
+
getFn,
|
52
|
+
challenge: hash,
|
53
|
+
rpId,
|
54
|
+
})
|
55
|
+
return {
|
56
|
+
signature: Signature.toHex(signature),
|
57
|
+
raw,
|
58
|
+
webauthn: metadata,
|
59
|
+
}
|
48
60
|
},
|
49
61
|
async signMessage({ message }) {
|
50
62
|
return this.sign({ hash: hashMessage(message) })
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { Abi, Address, TypedData } from 'abitype'
|
2
|
-
import type
|
2
|
+
import type * as WebAuthnP256 from 'ox/WebAuthnP256'
|
3
3
|
|
4
4
|
import type { Client } from '../../clients/createClient.js'
|
5
5
|
import type { Hash, Hex, SignableMessage } from '../../types/misc.js'
|
@@ -219,6 +219,13 @@ export type SmartAccount<
|
|
219
219
|
>
|
220
220
|
>
|
221
221
|
|
222
|
+
// TODO(v3): Remove this in favor of `WebAuthnP256.sign.ReturnType` from Ox.
|
223
|
+
export type WebAuthnSignReturnType = {
|
224
|
+
signature: Hex
|
225
|
+
webauthn: WebAuthnP256.SignMetadata
|
226
|
+
raw: WebAuthnP256.sign.ReturnType['raw']
|
227
|
+
}
|
228
|
+
|
222
229
|
export type WebAuthnAccount = {
|
223
230
|
id: string
|
224
231
|
publicKey: Hex
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
export const alephZeroTestnet = /*#__PURE__*/ defineChain({
|
4
|
+
id: 2039,
|
5
|
+
name: 'Aleph Zero Testnet',
|
6
|
+
nativeCurrency: { name: 'TZERO', symbol: 'TZERO', decimals: 18 },
|
7
|
+
rpcUrls: {
|
8
|
+
default: {
|
9
|
+
http: ['https://rpc.alephzero-testnet.gelato.digital'],
|
10
|
+
webSocket: ['wss://ws.alephzero-testnet.gelato.digital'],
|
11
|
+
},
|
12
|
+
},
|
13
|
+
blockExplorers: {
|
14
|
+
default: {
|
15
|
+
name: 'Aleph Zero EVM Testnet explorer',
|
16
|
+
url: 'https://evm-explorer-testnet.alephzero.org',
|
17
|
+
apiUrl: 'https://evm-explorer-testnet.alephzero.org/api',
|
18
|
+
},
|
19
|
+
},
|
20
|
+
contracts: {
|
21
|
+
multicall3: {
|
22
|
+
address: '0xca11bde05977b3631167028862be2a173976ca11',
|
23
|
+
blockCreated: 2861745,
|
24
|
+
},
|
25
|
+
},
|
26
|
+
testnet: true,
|
27
|
+
})
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
export const artheraTestnet = /*#__PURE__*/ defineChain({
|
4
|
+
id: 10243,
|
5
|
+
name: 'Arthera Testnet',
|
6
|
+
nativeCurrency: { name: 'Arthera', symbol: 'AA', decimals: 18 },
|
7
|
+
rpcUrls: {
|
8
|
+
default: {
|
9
|
+
http: ['https://rpc-test.arthera.net'],
|
10
|
+
},
|
11
|
+
},
|
12
|
+
blockExplorers: {
|
13
|
+
default: {
|
14
|
+
name: 'Arthera EVM Explorer',
|
15
|
+
url: 'https://explorer-test.arthera.net',
|
16
|
+
apiUrl: 'https://explorer-test.arthera.net/api',
|
17
|
+
},
|
18
|
+
},
|
19
|
+
contracts: {
|
20
|
+
multicall3: {
|
21
|
+
address: '0xca11bde05977b3631167028862be2a173976ca11',
|
22
|
+
blockCreated: 22051,
|
23
|
+
},
|
24
|
+
},
|
25
|
+
})
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
export const goat = /*#__PURE__*/ defineChain({
|
4
|
+
id: 2345,
|
5
|
+
name: 'GOAT',
|
6
|
+
nativeCurrency: {
|
7
|
+
decimals: 18,
|
8
|
+
name: 'Bitcoin',
|
9
|
+
symbol: 'BTC',
|
10
|
+
},
|
11
|
+
rpcUrls: {
|
12
|
+
default: { http: ['https://rpc.goat.network'] },
|
13
|
+
},
|
14
|
+
blockExplorers: {
|
15
|
+
default: {
|
16
|
+
name: 'Goat Explorer',
|
17
|
+
url: 'https://explorer.goat.network',
|
18
|
+
},
|
19
|
+
},
|
20
|
+
contracts: {
|
21
|
+
multicall3: {
|
22
|
+
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
23
|
+
blockCreated: 0,
|
24
|
+
},
|
25
|
+
},
|
26
|
+
})
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
export const near = /*#__PURE__*/ defineChain({
|
4
|
+
id: 397,
|
5
|
+
name: 'NEAR Protocol',
|
6
|
+
nativeCurrency: {
|
7
|
+
decimals: 18,
|
8
|
+
name: 'NEAR',
|
9
|
+
symbol: 'NEAR',
|
10
|
+
},
|
11
|
+
rpcUrls: {
|
12
|
+
default: { http: ['https://eth-rpc.mainnet.near.org'] },
|
13
|
+
},
|
14
|
+
blockExplorers: {
|
15
|
+
default: {
|
16
|
+
name: 'NEAR Explorer',
|
17
|
+
url: 'https://eth-explorer.near.org',
|
18
|
+
},
|
19
|
+
},
|
20
|
+
testnet: false,
|
21
|
+
})
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
export const nearTestnet = /*#__PURE__*/ defineChain({
|
4
|
+
id: 398,
|
5
|
+
name: 'NEAR Protocol Testnet',
|
6
|
+
nativeCurrency: {
|
7
|
+
decimals: 18,
|
8
|
+
name: 'NEAR',
|
9
|
+
symbol: 'NEAR',
|
10
|
+
},
|
11
|
+
rpcUrls: {
|
12
|
+
default: { http: ['https://eth-rpc.testnet.near.org'] },
|
13
|
+
},
|
14
|
+
blockExplorers: {
|
15
|
+
default: {
|
16
|
+
name: 'NEAR Explorer',
|
17
|
+
url: 'https://eth-explorer-testnet.near.org',
|
18
|
+
},
|
19
|
+
},
|
20
|
+
testnet: true,
|
21
|
+
})
|
@@ -0,0 +1,53 @@
|
|
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 soneium = /*#__PURE__*/ defineChain({
|
7
|
+
...chainConfig,
|
8
|
+
id: 1868,
|
9
|
+
name: 'Soneium Mainnet',
|
10
|
+
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
|
11
|
+
rpcUrls: {
|
12
|
+
default: {
|
13
|
+
http: ['https://rpc.soneium.org'],
|
14
|
+
},
|
15
|
+
},
|
16
|
+
blockExplorers: {
|
17
|
+
default: {
|
18
|
+
name: 'Blockscout',
|
19
|
+
url: 'https://soneium.blockscout.com',
|
20
|
+
apiUrl: 'https://soneium.blockscout.com/api',
|
21
|
+
},
|
22
|
+
},
|
23
|
+
contracts: {
|
24
|
+
...chainConfig.contracts,
|
25
|
+
disputeGameFactory: {
|
26
|
+
[sourceId]: {
|
27
|
+
address: '0x512a3d2c7a43bd9261d2b8e8c9c70d4bd4d503c0',
|
28
|
+
},
|
29
|
+
},
|
30
|
+
l2OutputOracle: {
|
31
|
+
[sourceId]: {
|
32
|
+
address: '0x0000000000000000000000000000000000000000',
|
33
|
+
},
|
34
|
+
},
|
35
|
+
portal: {
|
36
|
+
[sourceId]: {
|
37
|
+
address: '0x88e529a6ccd302c948689cd5156c83d4614fae92',
|
38
|
+
blockCreated: 7061266,
|
39
|
+
},
|
40
|
+
},
|
41
|
+
l1StandardBridge: {
|
42
|
+
[sourceId]: {
|
43
|
+
address: '0xeb9bf100225c214efc3e7c651ebbadcf85177607',
|
44
|
+
blockCreated: 7061266,
|
45
|
+
},
|
46
|
+
},
|
47
|
+
multicall3: {
|
48
|
+
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
49
|
+
blockCreated: 1,
|
50
|
+
},
|
51
|
+
},
|
52
|
+
sourceId,
|
53
|
+
})
|
package/chains/index.ts
CHANGED
@@ -8,6 +8,7 @@ export { acria } from './definitions/acria.js'
|
|
8
8
|
export { adf } from './definitions/adf.js'
|
9
9
|
export { aioz } from './definitions/aioz.js'
|
10
10
|
export { alephZero } from './definitions/alephZero.js'
|
11
|
+
export { alephZeroTestnet } from './definitions/alephZeroTestnet.js'
|
11
12
|
export { alienx } from './definitions/alienX.js'
|
12
13
|
export { alienxHalTestnet } from './definitions/alienXHalTestnet.js'
|
13
14
|
export { ancient8 } from './definitions/ancient8.js'
|
@@ -23,6 +24,7 @@ export { areonNetwork } from './definitions/areonNetwork.js'
|
|
23
24
|
export { areonNetworkTestnet } from './definitions/areonNetworkTestnet.js'
|
24
25
|
export { artelaTestnet } from './definitions/artelaTestnet.js'
|
25
26
|
export { arthera } from './definitions/arthera.js'
|
27
|
+
export { artheraTestnet } from './definitions/artheraTestnet.js'
|
26
28
|
export { assetChain } from './definitions/assetChain.js'
|
27
29
|
export { assetChainTestnet } from './definitions/assetChainTestnet.js'
|
28
30
|
export { astar } from './definitions/astar.js'
|
@@ -182,6 +184,7 @@ export { glideL1Protocol } from './definitions/glideL1Protocol.js'
|
|
182
184
|
export { glideL2Protocol } from './definitions/glideL2Protocol.js'
|
183
185
|
export { gnosis } from './definitions/gnosis.js'
|
184
186
|
export { gnosisChiado } from './definitions/gnosisChiado.js'
|
187
|
+
export { goat } from './definitions/goat.js'
|
185
188
|
export { gobi } from './definitions/gobi.js'
|
186
189
|
export { goChain } from './definitions/goChain.js'
|
187
190
|
export { godwoken } from './definitions/godwoken.js'
|
@@ -300,6 +303,8 @@ export { morphHolesky } from './definitions/morphHolesky.js'
|
|
300
303
|
export { morphSepolia } from './definitions/morphSepolia.js'
|
301
304
|
export { nahmii } from './definitions/nahmii.js'
|
302
305
|
export { nautilus } from './definitions/nautilus.js'
|
306
|
+
export { near } from './definitions/near.js'
|
307
|
+
export { nearTestnet } from './definitions/nearTestnet.js'
|
303
308
|
export { neonDevnet } from './definitions/neonDevnet.js'
|
304
309
|
export { neonMainnet } from './definitions/neonMainnet.js'
|
305
310
|
export { neoxMainnet } from './definitions/neoxMainnet.js'
|
@@ -406,6 +411,7 @@ export { skaleTitanTestnet } from './definitions/skale/titanTestnet.js'
|
|
406
411
|
export { sketchpad } from './definitions/sketchpad.js'
|
407
412
|
export { snax } from './definitions/snax.js'
|
408
413
|
export { snaxTestnet } from './definitions/snaxTestnet.js'
|
414
|
+
export { soneium } from './definitions/soneium.js'
|
409
415
|
export { soneiumMinato } from './definitions/soneiumMinato.js'
|
410
416
|
export { sonic } from './definitions/sonic.js'
|
411
417
|
export { sonicTestnet } from './definitions/sonicTestnet.js'
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import type { ErrorType } from '../../errors/utils.js'
|
2
2
|
import type { Chain } from '../../types/chain.js'
|
3
3
|
import type { EIP1193RequestFn } from '../../types/eip1193.js'
|
4
|
+
import type { OneOf } from '../../types/utils.js'
|
4
5
|
import { buildRequest } from '../../utils/buildRequest.js'
|
5
6
|
import { uid as uid_ } from '../../utils/uid.js'
|
6
7
|
import type { ClientConfig } from '../createClient.js'
|
@@ -13,6 +14,17 @@ export type TransportConfig<
|
|
13
14
|
name: string
|
14
15
|
/** The key of the transport. */
|
15
16
|
key: string
|
17
|
+
/** Methods to include or exclude from executing RPC requests. */
|
18
|
+
methods?:
|
19
|
+
| OneOf<
|
20
|
+
| {
|
21
|
+
include?: string[] | undefined
|
22
|
+
}
|
23
|
+
| {
|
24
|
+
exclude?: string[] | undefined
|
25
|
+
}
|
26
|
+
>
|
27
|
+
| undefined
|
16
28
|
/** The JSON-RPC request function that matches the EIP-1193 request spec. */
|
17
29
|
request: eip1193RequestFn
|
18
30
|
/** The base delay (in ms) between retries. */
|
@@ -53,6 +65,7 @@ export function createTransport<
|
|
53
65
|
>(
|
54
66
|
{
|
55
67
|
key,
|
68
|
+
methods,
|
56
69
|
name,
|
57
70
|
request,
|
58
71
|
retryCount = 3,
|
@@ -73,7 +86,7 @@ export function createTransport<
|
|
73
86
|
timeout,
|
74
87
|
type,
|
75
88
|
},
|
76
|
-
request: buildRequest(request, { retryCount, retryDelay, uid }),
|
89
|
+
request: buildRequest(request, { methods, retryCount, retryDelay, uid }),
|
77
90
|
value,
|
78
91
|
}
|
79
92
|
}
|
@@ -11,6 +11,8 @@ type EthereumProvider = { request(...args: any): Promise<any> }
|
|
11
11
|
export type CustomTransportConfig = {
|
12
12
|
/** The key of the transport. */
|
13
13
|
key?: TransportConfig['key'] | undefined
|
14
|
+
/** Methods to include or exclude from executing RPC requests. */
|
15
|
+
methods?: TransportConfig['methods'] | undefined
|
14
16
|
/** The name of the transport. */
|
15
17
|
name?: TransportConfig['name'] | undefined
|
16
18
|
/** The max number of times to retry. */
|
@@ -34,10 +36,16 @@ export function custom<provider extends EthereumProvider>(
|
|
34
36
|
provider: provider,
|
35
37
|
config: CustomTransportConfig = {},
|
36
38
|
): CustomTransport {
|
37
|
-
const {
|
39
|
+
const {
|
40
|
+
key = 'custom',
|
41
|
+
methods,
|
42
|
+
name = 'Custom Provider',
|
43
|
+
retryDelay,
|
44
|
+
} = config
|
38
45
|
return ({ retryCount: defaultRetryCount }) =>
|
39
46
|
createTransport({
|
40
47
|
key,
|
48
|
+
methods,
|
41
49
|
name,
|
42
50
|
request: provider.request.bind(provider),
|
43
51
|
retryCount: config.retryCount ?? defaultRetryCount,
|
@@ -43,6 +43,8 @@ export type HttpTransportConfig = {
|
|
43
43
|
onFetchResponse?: HttpRpcClientOptions['onResponse'] | undefined
|
44
44
|
/** The key of the HTTP transport. */
|
45
45
|
key?: TransportConfig['key'] | undefined
|
46
|
+
/** Methods to include or exclude from executing RPC requests. */
|
47
|
+
methods?: TransportConfig['methods'] | undefined
|
46
48
|
/** The name of the HTTP transport. */
|
47
49
|
name?: TransportConfig['name'] | undefined
|
48
50
|
/** The max number of times to retry. */
|
@@ -78,6 +80,7 @@ export function http(
|
|
78
80
|
batch,
|
79
81
|
fetchOptions,
|
80
82
|
key = 'http',
|
83
|
+
methods,
|
81
84
|
name = 'HTTP JSON-RPC',
|
82
85
|
onFetchRequest,
|
83
86
|
onFetchResponse,
|
@@ -101,6 +104,7 @@ export function http(
|
|
101
104
|
return createTransport(
|
102
105
|
{
|
103
106
|
key,
|
107
|
+
methods,
|
104
108
|
name,
|
105
109
|
async request({ method, params }) {
|
106
110
|
const body = { method, params }
|
@@ -40,6 +40,8 @@ type IpcTransportSubscribe = {
|
|
40
40
|
export type IpcTransportConfig = {
|
41
41
|
/** The key of the Ipc transport. */
|
42
42
|
key?: TransportConfig['key'] | undefined
|
43
|
+
/** Methods to include or exclude from executing RPC requests. */
|
44
|
+
methods?: TransportConfig['methods'] | undefined
|
43
45
|
/** The name of the Ipc transport. */
|
44
46
|
name?: TransportConfig['name'] | undefined
|
45
47
|
/**
|
@@ -75,13 +77,20 @@ export function ipc(
|
|
75
77
|
path: string,
|
76
78
|
config: IpcTransportConfig = {},
|
77
79
|
): IpcTransport {
|
78
|
-
const {
|
80
|
+
const {
|
81
|
+
key = 'ipc',
|
82
|
+
methods,
|
83
|
+
name = 'IPC JSON-RPC',
|
84
|
+
reconnect,
|
85
|
+
retryDelay,
|
86
|
+
} = config
|
79
87
|
return ({ retryCount: retryCount_, timeout: timeout_ }) => {
|
80
88
|
const retryCount = config.retryCount ?? retryCount_
|
81
89
|
const timeout = timeout_ ?? config.timeout ?? 10_000
|
82
90
|
return createTransport(
|
83
91
|
{
|
84
92
|
key,
|
93
|
+
methods,
|
85
94
|
name,
|
86
95
|
async request({ method, params }) {
|
87
96
|
const body = { method, params }
|
@@ -49,6 +49,8 @@ export type WebSocketTransportConfig = {
|
|
49
49
|
keepAlive?: GetWebSocketRpcClientOptions['keepAlive'] | undefined
|
50
50
|
/** The key of the WebSocket transport. */
|
51
51
|
key?: TransportConfig['key'] | undefined
|
52
|
+
/** Methods to include or exclude from executing RPC requests. */
|
53
|
+
methods?: TransportConfig['methods'] | undefined
|
52
54
|
/** The name of the WebSocket transport. */
|
53
55
|
name?: TransportConfig['name'] | undefined
|
54
56
|
/**
|
@@ -92,6 +94,7 @@ export function webSocket(
|
|
92
94
|
const {
|
93
95
|
keepAlive,
|
94
96
|
key = 'webSocket',
|
97
|
+
methods,
|
95
98
|
name = 'WebSocket JSON-RPC',
|
96
99
|
reconnect,
|
97
100
|
retryDelay,
|
@@ -104,6 +107,7 @@ export function webSocket(
|
|
104
107
|
return createTransport(
|
105
108
|
{
|
106
109
|
key,
|
110
|
+
methods,
|
107
111
|
name,
|
108
112
|
async request({ method, params }) {
|
109
113
|
const body = { method, params }
|
package/errors/rpc.ts
CHANGED
@@ -309,7 +309,7 @@ export class MethodNotSupportedRpcError extends RpcError {
|
|
309
309
|
super(cause, {
|
310
310
|
code: MethodNotSupportedRpcError.code,
|
311
311
|
name: 'MethodNotSupportedRpcError',
|
312
|
-
shortMessage: `Method${method ? ` "${method}"` : ''} is not
|
312
|
+
shortMessage: `Method${method ? ` "${method}"` : ''} is not supported.`,
|
313
313
|
})
|
314
314
|
}
|
315
315
|
}
|
package/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '2.22.
|
1
|
+
export const version = '2.22.10'
|
package/op-stack/chains.ts
CHANGED
@@ -17,6 +17,7 @@ export { pgnTestnet } from '../chains/definitions/pgnTestnet.js'
|
|
17
17
|
export { shape } from '../chains/definitions/shape.js'
|
18
18
|
export { snax } from '../chains/definitions/snax.js'
|
19
19
|
export { snaxTestnet } from '../chains/definitions/snaxTestnet.js'
|
20
|
+
export { soneium } from '../chains/definitions/soneium.js'
|
20
21
|
export { soneiumMinato } from '../chains/definitions/soneiumMinato.js'
|
21
22
|
export { unichainSepolia } from '../chains/definitions/unichainSepolia.js'
|
22
23
|
export { worldchain } from '../chains/definitions/worldchain.js'
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "viem",
|
3
3
|
"description": "TypeScript Interface for Ethereum",
|
4
|
-
"version": "2.22.
|
4
|
+
"version": "2.22.10",
|
5
5
|
"main": "./_cjs/index.js",
|
6
6
|
"module": "./_esm/index.js",
|
7
7
|
"types": "./_types/index.d.ts",
|
@@ -180,8 +180,7 @@
|
|
180
180
|
"@scure/bip39": "1.5.0",
|
181
181
|
"abitype": "1.0.7",
|
182
182
|
"isows": "1.0.6",
|
183
|
-
"ox": "0.6.
|
184
|
-
"webauthn-p256": "0.0.10",
|
183
|
+
"ox": "0.6.5",
|
185
184
|
"ws": "8.18.0"
|
186
185
|
},
|
187
186
|
"license": "MIT",
|
package/types/eip1193.ts
CHANGED
@@ -1922,11 +1922,22 @@ export type EIP1193Parameters<
|
|
1922
1922
|
}
|
1923
1923
|
|
1924
1924
|
export type EIP1193RequestOptions = {
|
1925
|
-
|
1925
|
+
/** Deduplicate in-flight requests. */
|
1926
1926
|
dedupe?: boolean | undefined
|
1927
|
-
|
1927
|
+
/** Methods to include or exclude from executing RPC requests. */
|
1928
|
+
methods?:
|
1929
|
+
| OneOf<
|
1930
|
+
| {
|
1931
|
+
include?: string[] | undefined
|
1932
|
+
}
|
1933
|
+
| {
|
1934
|
+
exclude?: string[] | undefined
|
1935
|
+
}
|
1936
|
+
>
|
1937
|
+
| undefined
|
1938
|
+
/** The base delay (in ms) between retries. */
|
1928
1939
|
retryDelay?: number | undefined
|
1929
|
-
|
1940
|
+
/** The max number of times to retry. */
|
1930
1941
|
retryCount?: number | undefined
|
1931
1942
|
/** Unique identifier for the request. */
|
1932
1943
|
uid?: string | undefined
|
package/utils/buildRequest.ts
CHANGED
@@ -100,6 +100,7 @@ export function buildRequest<request extends (args: any) => Promise<any>>(
|
|
100
100
|
return async (args, overrideOptions = {}) => {
|
101
101
|
const {
|
102
102
|
dedupe = false,
|
103
|
+
methods,
|
103
104
|
retryDelay = 150,
|
104
105
|
retryCount = 3,
|
105
106
|
uid,
|
@@ -107,6 +108,17 @@ export function buildRequest<request extends (args: any) => Promise<any>>(
|
|
107
108
|
...options,
|
108
109
|
...overrideOptions,
|
109
110
|
}
|
111
|
+
|
112
|
+
const { method } = args
|
113
|
+
if (methods?.exclude?.includes(method))
|
114
|
+
throw new MethodNotSupportedRpcError(new Error('method not supported'), {
|
115
|
+
method,
|
116
|
+
})
|
117
|
+
if (methods?.include && !methods.include.includes(method))
|
118
|
+
throw new MethodNotSupportedRpcError(new Error('method not supported'), {
|
119
|
+
method,
|
120
|
+
})
|
121
|
+
|
110
122
|
const requestId = dedupe
|
111
123
|
? keccak256(stringToHex(`${uid}.${stringify(args)}`))
|
112
124
|
: undefined
|