diff --git a/package.json b/package.json index b4c2817b6..023823b95 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "turbo": "^2.5.4", "typescript": "5.8.3" }, - "packageManager": "pnpm@10.11.0", + "packageManager": "pnpm@10.14.0", "engines": { "node": ">=18" } diff --git a/packages/wallet/core/package.json b/packages/wallet/core/package.json index 9fbd86a8a..23e95617e 100644 --- a/packages/wallet/core/package.json +++ b/packages/wallet/core/package.json @@ -12,6 +12,7 @@ "dev": "tsc --watch", "test": "vitest run", "test:coverage": "vitest run --coverage", + "typecheck": "tsc --noEmit", "clean": "rimraf dist" }, "exports": { diff --git a/packages/wallet/dapp-client/package.json b/packages/wallet/dapp-client/package.json index 254de4719..5d3373009 100644 --- a/packages/wallet/dapp-client/package.json +++ b/packages/wallet/dapp-client/package.json @@ -10,6 +10,7 @@ "scripts": { "build": "tsc", "dev": "tsc --watch", + "typecheck": "tsc --noEmit", "clean": "rimraf dist" }, "exports": { @@ -29,7 +30,6 @@ "vitest": "^3.2.1" }, "dependencies": { - "@0xsequence/network": "^2.3.23", "@0xsequence/wallet-core": "workspace:^", "@0xsequence/wallet-primitives": "workspace:^", "ox": "^0.7.2" diff --git a/packages/wallet/dapp-client/src/ChainSessionManager.ts b/packages/wallet/dapp-client/src/ChainSessionManager.ts index cfec423fb..cf7a7bbc0 100644 --- a/packages/wallet/dapp-client/src/ChainSessionManager.ts +++ b/packages/wallet/dapp-client/src/ChainSessionManager.ts @@ -1,10 +1,9 @@ import { Envelope, Relayer, Signers, State, Wallet } from '@0xsequence/wallet-core' -import { Attestation, Constants, Extensions, Payload, SessionConfig } from '@0xsequence/wallet-primitives' +import { Attestation, Constants, Extensions, Network, Payload, SessionConfig } from '@0xsequence/wallet-primitives' import { AbiFunction, Address, Hex, Provider, RpcTransport, Secp256k1 } from 'ox' import { DappTransport } from './DappTransport.js' -import { ChainId } from '@0xsequence/network' import { AddExplicitSessionError, FeeOptionError, @@ -67,7 +66,7 @@ export class ChainSessionManager { private wallet: Wallet | null = null private provider: Provider.Provider | null = null private relayer: Relayer.Standard.Rpc.RpcRelayer - private readonly chainId: ChainId + private readonly chainId: bigint public transport: DappTransport | null = null private sequenceStorage: SequenceStorage public isInitialized: boolean = false @@ -85,7 +84,7 @@ export class ChainSessionManager { * @param canUseIndexedDb (Optional) A flag to enable or disable IndexedDB for caching. */ constructor( - chainId: ChainId, + chainId: bigint, keyMachineUrl: string, transport: DappTransport, sequenceStorage: SequenceStorage, diff --git a/packages/wallet/dapp-client/src/DappClient.ts b/packages/wallet/dapp-client/src/DappClient.ts index 9a1c47196..6aab54246 100644 --- a/packages/wallet/dapp-client/src/DappClient.ts +++ b/packages/wallet/dapp-client/src/DappClient.ts @@ -1,5 +1,4 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import { ChainId } from '@0xsequence/network' import { Relayer, Signers } from '@0xsequence/wallet-core' import { Address, Hex } from 'ox' @@ -57,7 +56,7 @@ export class DappClient { public readonly origin: string - private chainSessionManagers: Map = new Map() + private chainSessionManagers: Map = new Map() private transport: DappTransport private keymachineUrl: string private walletUrl: string @@ -235,7 +234,7 @@ export class DappClient { this.userEmail = implicitSession.userEmail ?? null const explicitSessions = await this.sequenceStorage.getExplicitSessions() - const chainIdsToInitialize = new Set([ + const chainIdsToInitialize = new Set([ implicitSession.chainId, ...explicitSessions.filter((s) => Address.isEqual(s.walletAddress, this.walletAddress!)).map((s) => s.chainId), ]) @@ -328,7 +327,7 @@ export class DappClient { /** * Initiates a connection with the wallet and creates a new session. - * @param chainId The primary chain ID for the new session. {@link ChainId} + * @param chainId The primary chain ID for the new session. * @param permissions (Optional) Permissions to request for an initial explicit session. {@link Signers.Session.ExplicitParams} * @param options (Optional) Connection options, such as a preferred login method or email for social or email logins. * @throws If the connection process fails. {@link ConnectionError} @@ -345,7 +344,7 @@ export class DappClient { * }); */ async connect( - chainId: ChainId, + chainId: bigint, permissions?: Signers.Session.ExplicitParams, options: { preferredLoginMethod?: 'google' | 'apple' | 'email' | 'passkey' | 'mnemonic' @@ -375,7 +374,7 @@ export class DappClient { * Adds a new explicit session for a given chain to an existing wallet. * @remarks * An `explicit session` is a session that can interact with any contract, subject to user-approved permissions. - * @param chainId The chain ID on which to add the explicit session. {@link ChainId} + * @param chainId The chain ID on which to add the explicit session. * @param permissions The permissions to request for the new session. {@link Signers.Session.ExplicitParams} * * @throws If the session cannot be added. {@link AddExplicitSessionError} @@ -408,7 +407,7 @@ export class DappClient { * await dappClient.addExplicitSession(1, permissions); * } */ - async addExplicitSession(chainId: ChainId, permissions: Signers.Session.ExplicitParams): Promise { + async addExplicitSession(chainId: bigint, permissions: Signers.Session.ExplicitParams): Promise { if (!this.isInitialized || !this.walletAddress) throw new InitializationError('Cannot add an explicit session without an existing wallet.') @@ -425,7 +424,7 @@ export class DappClient { /** * Modifies the permissions of an existing explicit session for a given chain and session address. - * @param chainId The chain ID on which the explicit session exists. {@link ChainId} + * @param chainId The chain ID on which the explicit session exists. * @param sessionAddress The address of the explicit session to modify. {@link Address.Address} * @param permissions The new permissions to set for the session. {@link Signers.Session.ExplicitParams} * @@ -454,7 +453,7 @@ export class DappClient { * } */ async modifyExplicitSession( - chainId: ChainId, + chainId: bigint, sessionAddress: Address.Address, permissions: Signers.Session.ExplicitParams, ): Promise { @@ -474,7 +473,7 @@ export class DappClient { /** * Gets the gas fee options for an array of transactions. - * @param chainId The chain ID on which to get the fee options. {@link ChainId} + * @param chainId The chain ID on which to get the fee options. * @param transactions An array of transactions to get fee options for. These transactions will not be sent. * @throws If the fee options cannot be fetched. {@link FeeOptionError} * @throws If the client or relevant chain is not initialized. {@link InitializationError} @@ -501,7 +500,7 @@ export class DappClient { * const txHash = await dappClient.sendTransaction(1, transactions, feeOption); * } */ - async getFeeOptions(chainId: ChainId, transactions: Transaction[]): Promise { + async getFeeOptions(chainId: bigint, transactions: Transaction[]): Promise { if (!this.isInitialized) throw new InitializationError('Not initialized') const chainSessionManager = this.getChainSessionManager(chainId) if (!chainSessionManager.isInitialized) @@ -511,7 +510,7 @@ export class DappClient { /** * Signs and sends a transaction using an available session signer. - * @param chainId The chain ID on which to send the transaction. {@link ChainId} + * @param chainId The chain ID on which to send the transaction. * @param transactions An array of transactions to be executed atomically in a single batch. {@link Transaction} * @param feeOption (Optional) The selected fee option to sponsor the transaction. {@link Relayer.FeeOption} * @throws {TransactionError} If the transaction fails to send or confirm. @@ -534,11 +533,7 @@ export class DappClient { * * const txHash = await dappClient.sendTransaction(1, [transaction]); */ - async sendTransaction( - chainId: ChainId, - transactions: Transaction[], - feeOption?: Relayer.FeeOption, - ): Promise { + async sendTransaction(chainId: bigint, transactions: Transaction[], feeOption?: Relayer.FeeOption): Promise { if (!this.isInitialized) throw new InitializationError('Not initialized') const chainSessionManager = this.getChainSessionManager(chainId) if (!chainSessionManager.isInitialized) @@ -548,7 +543,7 @@ export class DappClient { /** * Signs a standard message (EIP-191) using an available session signer. - * @param chainId The chain ID on which to sign the message. {@link ChainId} + * @param chainId The chain ID on which to sign the message. * @param message The message to sign. * @throws If the message cannot be signed. {@link SigningError} * @throws If the client or relevant chain is not initialized. {@link InitializationError} @@ -566,7 +561,7 @@ export class DappClient { * await dappClient.signMessage(1, message); * } */ - async signMessage(chainId: ChainId, message: string): Promise { + async signMessage(chainId: bigint, message: string): Promise { if (!this.isInitialized) throw new InitializationError('Not initialized') const chainSessionManager = this.getChainSessionManager(chainId) if (!chainSessionManager.isInitialized) @@ -576,7 +571,7 @@ export class DappClient { /** * Signs a typed data object (EIP-712) using an available session signer. - * @param chainId The chain ID on which to sign the typed data. {@link ChainId} + * @param chainId The chain ID on which to sign the typed data. * @param typedData The typed data object to sign. * @throws If the typed data cannot be signed. {@link SigningError} * @throws If the client or relevant chain is not initialized. {@link InitializationError} @@ -594,7 +589,7 @@ export class DappClient { * await dappClient.signTypedData(1, typedData); * } */ - async signTypedData(chainId: ChainId, typedData: TypedData): Promise { + async signTypedData(chainId: bigint, typedData: TypedData): Promise { if (!this.isInitialized) throw new InitializationError('Not initialized') const chainSessionManager = this.getChainSessionManager(chainId) if (!chainSessionManager.isInitialized) @@ -652,10 +647,10 @@ export class DappClient { /** * @private Retrieves or creates a ChainSessionManager for a given chain ID. - * @param chainId The chain ID to get the ChainSessionManager for. {@link ChainId} + * @param chainId The chain ID to get the ChainSessionManager for. * @returns The ChainSessionManager for the given chain ID. {@link ChainSessionManager} */ - private getChainSessionManager(chainId: ChainId): ChainSessionManager { + private getChainSessionManager(chainId: bigint): ChainSessionManager { let chainSessionManager = this.chainSessionManagers.get(chainId) if (!chainSessionManager) { chainSessionManager = new ChainSessionManager( diff --git a/packages/wallet/dapp-client/src/types/index.ts b/packages/wallet/dapp-client/src/types/index.ts index 1601cff1a..da26ba252 100644 --- a/packages/wallet/dapp-client/src/types/index.ts +++ b/packages/wallet/dapp-client/src/types/index.ts @@ -1,7 +1,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { Attestation, Payload } from '@0xsequence/wallet-primitives' import { Signers } from '@0xsequence/wallet-core' -import { ChainId } from '@0xsequence/network' import { Address, Hex } from 'ox' import type { TypedData } from 'ox/TypedData' @@ -43,13 +42,13 @@ export interface AddImplicitSessionPayload { export interface SignMessagePayload { address: Address.Address message: string - chainId: ChainId + chainId: bigint } export interface SignTypedDataPayload { address: Address.Address typedData: TypedData - chainId: ChainId + chainId: bigint } export interface ConnectSuccessResponsePayload { @@ -91,7 +90,7 @@ export type Session = { address: Address.Address isImplicit: boolean permissions?: Signers.Session.ExplicitParams - chainId?: ChainId + chainId?: bigint } // --- Event Types --- @@ -117,14 +116,14 @@ export type DappClientSignatureEventListener = (data: { action: (typeof RequestActionType)['SIGN_MESSAGE' | 'SIGN_TYPED_DATA'] response?: SignatureResponse error?: any - chainId: number + chainId: bigint }) => void export type DappClientExplicitSessionEventListener = (data: { action: (typeof RequestActionType)['ADD_EXPLICIT_SESSION' | 'MODIFY_EXPLICIT_SESSION'] response?: ExplicitSessionResponsePayload error?: any - chainId: number + chainId: bigint }) => void // --- DappTransport Types --- @@ -169,14 +168,14 @@ export interface MessageSignatureRequest extends BaseRequest { type: 'message_signature' message: string address: Address.Address - chainId: number + chainId: bigint } export interface TypedDataSignatureRequest extends BaseRequest { type: 'typed_data_signature' typedData: unknown address: Address.Address - chainId: number + chainId: bigint } export const WalletSize = { diff --git a/packages/wallet/dapp-client/src/utils/index.ts b/packages/wallet/dapp-client/src/utils/index.ts index c8a2b4c57..5e8cd02f1 100644 --- a/packages/wallet/dapp-client/src/utils/index.ts +++ b/packages/wallet/dapp-client/src/utils/index.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import { allNetworks } from '@0xsequence/network' +import { Network } from '@0xsequence/wallet-primitives' import { Bytes, Hex } from 'ox' import { NODES_URL, RELAYER_URL } from './constants.js' @@ -117,8 +117,8 @@ function applyTemplate(template: string, values: Record) { }) } -export const getNetwork = (chainId: number) => { - const network = allNetworks.find((network) => network.chainId === chainId) +export const getNetwork = (chainId: Network.ChainId | bigint | number) => { + const network = Network.getNetworkFromChainId(chainId) if (!network) { throw new Error(`Network with chainId ${chainId} not found`) @@ -127,7 +127,7 @@ export const getNetwork = (chainId: number) => { return network } -export const getRpcUrl = (chainId: number) => { +export const getRpcUrl = (chainId: Network.ChainId | bigint | number) => { const network = getNetwork(chainId) const url = applyTemplate(NODES_URL, { network: network.name }) @@ -135,7 +135,7 @@ export const getRpcUrl = (chainId: number) => { return url } -export const getRelayerUrl = (chainId: number) => { +export const getRelayerUrl = (chainId: Network.ChainId | bigint | number) => { const network = getNetwork(chainId) const url = applyTemplate(RELAYER_URL, { network: network.name }) @@ -143,9 +143,9 @@ export const getRelayerUrl = (chainId: number) => { return url } -export const getExplorerUrl = (chainId: number, txHash: string) => { +export const getExplorerUrl = (chainId: Network.ChainId | bigint | number, txHash: string) => { const network = getNetwork(chainId) - const explorerUrl = network.blockExplorer?.rootUrl + const explorerUrl = network.blockExplorer?.url if (!explorerUrl) { throw new Error(`Explorer URL not found for chainId ${chainId}`) } diff --git a/packages/wallet/dapp-client/src/utils/storage.ts b/packages/wallet/dapp-client/src/utils/storage.ts index 91e5efef0..1de6e6a37 100644 --- a/packages/wallet/dapp-client/src/utils/storage.ts +++ b/packages/wallet/dapp-client/src/utils/storage.ts @@ -1,6 +1,5 @@ import { Attestation } from '@0xsequence/wallet-primitives' import { Address, Hex } from 'ox' -import { ChainId } from '@0xsequence/network' import { jsonReplacers, jsonRevivers } from './index.js' import { AddExplicitSessionPayload, @@ -14,7 +13,7 @@ import { export interface ExplicitSessionData { pk: Hex.Hex walletAddress: Address.Address - chainId: ChainId + chainId: bigint loginMethod?: PreferredLoginMethod userEmail?: string } @@ -24,7 +23,7 @@ export interface ImplicitSessionData { walletAddress: Address.Address attestation: Attestation.Attestation identitySignature: Hex.Hex - chainId: ChainId + chainId: bigint loginMethod?: PreferredLoginMethod userEmail?: string } @@ -37,7 +36,7 @@ export type PendingPayload = | SignTypedDataPayload export interface PendingRequestContext { - chainId: ChainId + chainId: bigint action: string payload: PendingPayload } diff --git a/packages/wallet/primitives-cli/package.json b/packages/wallet/primitives-cli/package.json index aea18efeb..21046e62a 100644 --- a/packages/wallet/primitives-cli/package.json +++ b/packages/wallet/primitives-cli/package.json @@ -8,6 +8,7 @@ "dev:esbuild": "esbuild src/index.ts --bundle --platform=node --target=node16 --outfile=dist/index.js --watch --sourcemap", "start": "tsc && node dist/index.js", "lint": "eslint . --max-warnings 0", + "typecheck": "tsc --noEmit", "clean": "rimraf dist" }, "exports": { diff --git a/packages/wallet/primitives/package.json b/packages/wallet/primitives/package.json index c50d7dd2b..ead0a7823 100644 --- a/packages/wallet/primitives/package.json +++ b/packages/wallet/primitives/package.json @@ -12,6 +12,7 @@ "dev": "tsc --watch", "test": "vitest run", "test:coverage": "vitest run --coverage", + "typecheck": "tsc --noEmit", "clean": "rimraf dist" }, "exports": { diff --git a/packages/wallet/primitives/src/extensions/recovery.ts b/packages/wallet/primitives/src/extensions/recovery.ts index 8760aae07..f6552a416 100644 --- a/packages/wallet/primitives/src/extensions/recovery.ts +++ b/packages/wallet/primitives/src/extensions/recovery.ts @@ -1,7 +1,8 @@ import { Abi, AbiFunction, Address, Bytes, Hex, Provider } from 'ox' -import * as Payload from '../payload.js' import * as GenericTree from '../generic-tree.js' import { Signature } from '../index.js' +import * as Network from '../network.js' +import * as Payload from '../payload.js' import { packRSY } from '../utils.js' export const FLAG_RECOVERY_LEAF = 1 diff --git a/packages/wallet/primitives/src/network.ts b/packages/wallet/primitives/src/network.ts index 3b4db8919..b2ab62f6a 100644 --- a/packages/wallet/primitives/src/network.ts +++ b/packages/wallet/primitives/src/network.ts @@ -1,630 +1,1009 @@ -export type Network = { - name: string - rpc: string - chainId: bigint - explorer: string - nativeCurrency: { - name: string - symbol: string - decimals: number - } -} - -// Helper function to create RPC URL for a network -function getRpcUrl(networkName: string): string { - return `https://nodes.sequence.app/${networkName}` -} - -export const Mainnet: Network = { - name: 'mainnet', - rpc: getRpcUrl('mainnet'), - chainId: 1n, - explorer: 'https://etherscan.io/', - nativeCurrency: { - name: 'Ether', - symbol: 'ETH', - decimals: 18, - }, -} - -export const Sepolia: Network = { - name: 'sepolia', - rpc: getRpcUrl('sepolia'), - chainId: 11155111n, - explorer: 'https://sepolia.etherscan.io/', - nativeCurrency: { - name: 'Sepolia Ether', - symbol: 'sETH', - decimals: 18, - }, -} - -export const Polygon: Network = { - name: 'polygon', - rpc: getRpcUrl('polygon'), - chainId: 137n, - explorer: 'https://polygonscan.com/', - nativeCurrency: { - name: 'POL', - symbol: 'POL', - decimals: 18, - }, -} - -export const PolygonAmoy: Network = { - name: 'amoy', - rpc: getRpcUrl('amoy'), - chainId: 80002n, - explorer: 'https://www.oklink.com/amoy/', - nativeCurrency: { - name: 'Amoy POL', - symbol: 'aPOL', - decimals: 18, - }, -} - -export const PolygonZkEVM: Network = { - name: 'polygon-zkevm', - rpc: getRpcUrl('polygon-zkevm'), - chainId: 1101n, - explorer: 'https://zkevm.polygonscan.com/', - nativeCurrency: { - name: 'Ether', - symbol: 'ETH', - decimals: 18, - }, -} - -export const BSC: Network = { - name: 'bsc', - rpc: getRpcUrl('bsc'), - chainId: 56n, - explorer: 'https://bscscan.com/', - nativeCurrency: { - name: 'BNB', - symbol: 'BNB', - decimals: 18, - }, -} - -export const BSCTestnet: Network = { - name: 'bsc-testnet', - rpc: getRpcUrl('bsc-testnet'), - chainId: 97n, - explorer: 'https://testnet.bscscan.com/', - nativeCurrency: { - name: 'Testnet BNB', - symbol: 'tBNB', - decimals: 18, - }, -} - -export const Optimism: Network = { - name: 'optimism', - rpc: getRpcUrl('optimism'), - chainId: 10n, - explorer: 'https://optimistic.etherscan.io/', - nativeCurrency: { - name: 'Ether', - symbol: 'ETH', - decimals: 18, - }, -} - -export const OptimismSepolia: Network = { - name: 'optimism-sepolia', - rpc: getRpcUrl('optimism-sepolia'), - chainId: 11155420n, - explorer: 'https://sepolia-optimistic.etherscan.io/', - nativeCurrency: { - name: 'Sepolia Ether', - symbol: 'sETH', - decimals: 18, - }, -} - -export const Arbitrum: Network = { - name: 'arbitrum', - rpc: getRpcUrl('arbitrum'), - chainId: 42161n, - explorer: 'https://arbiscan.io/', - nativeCurrency: { - name: 'Ether', - symbol: 'ETH', - decimals: 18, - }, -} - -export const ArbitrumSepolia: Network = { - name: 'arbitrum-sepolia', - rpc: getRpcUrl('arbitrum-sepolia'), - chainId: 421614n, - explorer: 'https://sepolia.arbiscan.io/', - nativeCurrency: { - name: 'Sepolia Ether', - symbol: 'sETH', - decimals: 18, - }, -} - -export const ArbitrumNova: Network = { - name: 'arbitrum-nova', - rpc: getRpcUrl('arbitrum-nova'), - chainId: 42170n, - explorer: 'https://nova.arbiscan.io/', - nativeCurrency: { - name: 'Ether', - symbol: 'ETH', - decimals: 18, - }, -} - -export const Avalanche: Network = { - name: 'avalanche', - rpc: getRpcUrl('avalanche'), - chainId: 43114n, - explorer: 'https://subnets.avax.network/c-chain/', - nativeCurrency: { - name: 'AVAX', - symbol: 'AVAX', - decimals: 18, - }, -} - -export const AvalancheTestnet: Network = { - name: 'avalanche-testnet', - rpc: getRpcUrl('avalanche-testnet'), - chainId: 43113n, - explorer: 'https://subnets-test.avax.network/c-chain/', - nativeCurrency: { - name: 'Testnet AVAX', - symbol: 'tAVAX', - decimals: 18, - }, -} - -export const Gnosis: Network = { - name: 'gnosis', - rpc: getRpcUrl('gnosis'), - chainId: 100n, - explorer: 'https://blockscout.com/xdai/mainnet/', - nativeCurrency: { - name: 'XDAI', - symbol: 'XDAI', - decimals: 18, - }, -} - -export const Base: Network = { - name: 'base', - rpc: getRpcUrl('base'), - chainId: 8453n, - explorer: 'https://basescan.org/', - nativeCurrency: { - name: 'Ether', - symbol: 'ETH', - decimals: 18, - }, -} - -export const BaseSepolia: Network = { - name: 'base-sepolia', - rpc: getRpcUrl('base-sepolia'), - chainId: 84532n, - explorer: 'https://base-sepolia.blockscout.com/', - nativeCurrency: { - name: 'Sepolia Ether', - symbol: 'sETH', - decimals: 18, - }, -} - -export const Homeverse: Network = { - name: 'homeverse', - rpc: getRpcUrl('homeverse'), - chainId: 19011n, - explorer: 'https://explorer.oasys.homeverse.games/', - nativeCurrency: { - name: 'OAS', - symbol: 'OAS', - decimals: 18, - }, -} - -export const HomeverseTestnet: Network = { - name: 'homeverse-testnet', - rpc: getRpcUrl('homeverse-testnet'), - chainId: 40875n, - explorer: 'https://explorer.testnet.oasys.homeverse.games/', - nativeCurrency: { - name: 'Testnet OAS', - symbol: 'tOAS', - decimals: 18, - }, -} - -export const Xai: Network = { - name: 'xai', - rpc: getRpcUrl('xai'), - chainId: 660279n, - explorer: 'https://explorer.xai-chain.net/', - nativeCurrency: { - name: 'XAI', - symbol: 'XAI', - decimals: 18, - }, +export enum NetworkType { + MAINNET = 'mainnet', + TESTNET = 'testnet', } -export const XaiSepolia: Network = { - name: 'xai-sepolia', - rpc: getRpcUrl('xai-sepolia'), - chainId: 37714555429n, - explorer: 'https://testnet-explorer-v2.xai-chain.net/', - nativeCurrency: { - name: 'Sepolia XAI', - symbol: 'sXAI', - decimals: 18, - }, +export type BlockExplorerConfig = { + name?: string + url: string } -export const Telos: Network = { - name: 'telos', - rpc: getRpcUrl('telos'), - chainId: 40n, - explorer: 'https://explorer.telos.net/network/', - nativeCurrency: { - name: 'TLOS', - symbol: 'TLOS', - decimals: 18, - }, -} - -export const TelosTestnet: Network = { - name: 'telos-testnet', - rpc: getRpcUrl('telos-testnet'), - chainId: 41n, - explorer: 'https://explorer-test.telos.net/network', - nativeCurrency: { - name: 'TLOS', - symbol: 'TLOS', - decimals: 18, - }, -} - -export const B3: Network = { - name: 'b3', - rpc: getRpcUrl('b3'), - chainId: 8333n, - explorer: 'https://explorer.b3.fun/', - nativeCurrency: { - name: 'Ether', - symbol: 'ETH', - decimals: 18, - }, -} - -export const B3Sepolia: Network = { - name: 'b3-sepolia', - rpc: getRpcUrl('b3-sepolia'), - chainId: 1993n, - explorer: 'https://sepolia.explorer.b3.fun/', - nativeCurrency: { - name: 'Ether', - symbol: 'ETH', - decimals: 18, - }, -} - -export const ApeChain: Network = { - name: 'apechain', - rpc: getRpcUrl('apechain'), - chainId: 33139n, - explorer: 'https://apechain.calderaexplorer.xyz/', - nativeCurrency: { - name: 'ApeCoin', - symbol: 'APE', - decimals: 18, - }, -} - -export const ApeChainTestnet: Network = { - name: 'apechain-testnet', - rpc: getRpcUrl('apechain-testnet'), - chainId: 33111n, - explorer: 'https://curtis.explorer.caldera.xyz/', - nativeCurrency: { - name: 'ApeCoin', - symbol: 'APE', - decimals: 18, - }, -} - -export const Blast: Network = { - name: 'blast', - rpc: getRpcUrl('blast'), - chainId: 81457n, - explorer: 'https://blastscan.io/', - nativeCurrency: { - name: 'Ether', - symbol: 'ETH', - decimals: 18, - }, -} - -export const BlastSepolia: Network = { - name: 'blast-sepolia', - rpc: getRpcUrl('blast-sepolia'), - chainId: 168587773n, - explorer: 'https://sepolia.blastexplorer.io/', - nativeCurrency: { - name: 'Ether', - symbol: 'ETH', - decimals: 18, - }, -} - -export const SkaleNebula: Network = { - name: 'skale-nebula', - rpc: getRpcUrl('skale-nebula'), - chainId: 1482601649n, - explorer: 'https://green-giddy-denebola.explorer.mainnet.skalenodes.com/', - nativeCurrency: { - name: 'SKALE Fuel', - symbol: 'sFUEL', - decimals: 18, - }, -} - -export const SkaleNebulaTestnet: Network = { - name: 'skale-nebula-testnet', - rpc: getRpcUrl('skale-nebula-testnet'), - chainId: 37084624n, - explorer: 'https://lanky-ill-funny-testnet.explorer.testnet.skalenodes.com/', - nativeCurrency: { - name: 'SKALE Fuel', - symbol: 'sFUEL', - decimals: 18, - }, -} - -export const Soneium: Network = { - name: 'soneium', - rpc: getRpcUrl('soneium'), - chainId: 1868n, - explorer: 'https://soneium.blockscout.com/', - nativeCurrency: { - name: 'Ether', - symbol: 'ETH', - decimals: 18, - }, -} - -export const SoneiumMinato: Network = { - name: 'soneium-minato', - rpc: getRpcUrl('soneium-minato'), - chainId: 1946n, - explorer: 'https://explorer-testnet.soneium.org/', - nativeCurrency: { - name: 'Ether', - symbol: 'ETH', - decimals: 18, - }, -} - -export const ToyTestnet: Network = { - name: 'toy-testnet', - rpc: getRpcUrl('toy-testnet'), - chainId: 21000000n, - explorer: 'https://toy-chain-testnet.explorer.caldera.xyz/', - nativeCurrency: { - name: 'TOY', - symbol: 'TOY', - decimals: 18, - }, -} - -export const ImmutableZkEVM: Network = { - name: 'immutable-zkevm', - rpc: getRpcUrl('immutable-zkevm'), - chainId: 13371n, - explorer: 'https://explorer.immutable.com/', +export interface Network { + chainId: bigint + type: NetworkType + name: string + title?: string + rpcUrl: string + logoUrl?: string + blockExplorer?: BlockExplorerConfig nativeCurrency: { - name: 'IMX', - symbol: 'IMX', - decimals: 18, - }, + symbol: string + name: string + decimals: number + } + ensAddress?: string + deprecated?: true } -export const ImmutableZkEVMTestnet: Network = { - name: 'immutable-zkevm-testnet', - rpc: getRpcUrl('immutable-zkevm-testnet'), - chainId: 13473n, - explorer: 'https://explorer.testnet.immutable.com/', - nativeCurrency: { - name: 'IMX', - symbol: 'IMX', - decimals: 18, - }, -} +export const ChainId = { + // Ethereum + MAINNET: 1n, + SEPOLIA: 11155111n, -export const RootNetwork: Network = { - name: 'rootnet', - rpc: getRpcUrl('rootnet'), - chainId: 7668n, - explorer: 'https://rootscan.io/', - nativeCurrency: { - name: 'XRP', - symbol: 'XRP', - decimals: 18, - }, -} + // Polygon + POLYGON: 137n, + POLYGON_ZKEVM: 1101n, + POLYGON_AMOY: 80002n, -export const RootNetworkPorcini: Network = { - name: 'rootnet-porcini', - rpc: getRpcUrl('rootnet-porcini'), - chainId: 7672n, - explorer: 'https://porcini.rootscan.io/', - nativeCurrency: { - name: 'XRP', - symbol: 'XRP', - decimals: 18, - }, -} + // BSC + BSC: 56n, + BSC_TESTNET: 97n, -export const Laos: Network = { - name: 'laos', - rpc: getRpcUrl('laos'), - chainId: 6283n, - explorer: 'https://blockscout.laos.laosfoundation.io/', - nativeCurrency: { - name: 'LAOS', - symbol: 'LAOS', - decimals: 18, - }, -} + // Optimism + OPTIMISM: 10n, + OPTIMISM_SEPOLIA: 11155420n, -export const LaosSigmaTestnet: Network = { - name: 'laos-sigma-testnet', - rpc: getRpcUrl('laos-sigma-testnet'), - chainId: 62850n, - explorer: 'https://sigma.explorer.laosnetwork.io/', - nativeCurrency: { - name: 'SIGMA', - symbol: 'SIGMA', - decimals: 18, + // Arbitrum One + ARBITRUM: 42161n, + ARBITRUM_SEPOLIA: 421614n, + + // Arbitrum Nova + ARBITRUM_NOVA: 42170n, + + // Avalanche + AVALANCHE: 43114n, + AVALANCHE_TESTNET: 43113n, + + // Gnosis Chain (XDAI) + GNOSIS: 100n, + + // BASE + BASE: 8453n, + BASE_SEPOLIA: 84532n, + + // HOMEVERSE + HOMEVERSE_TESTNET: 40875n, + HOMEVERSE: 19011n, + + // Xai + XAI: 660279n, + XAI_SEPOLIA: 37714555429n, + + // TELOS + TELOS: 40n, + TELOS_TESTNET: 41n, + + // B3 Sepolia + B3: 8333n, + B3_SEPOLIA: 1993n, + + // APE Chain + APECHAIN: 33139n, + APECHAIN_TESTNET: 33111n, + + // Blast + BLAST: 81457n, + BLAST_SEPOLIA: 168587773n, + + // SKALE Nebula + SKALE_NEBULA: 1482601649n, + SKALE_NEBULA_TESTNET: 37084624n, + + // Soneium Minato + SONEIUM_MINATO: 1946n, + SONEIUM: 1868n, + + // TOY Testnet + TOY_TESTNET: 21000000n, + + // Immutable zkEVM + IMMUTABLE_ZKEVM: 13371n, + IMMUTABLE_ZKEVM_TESTNET: 13473n, + + // The Root Network + ROOT_NETWORK: 7668n, + ROOT_NETWORK_PORCINI: 7672n, + + // LAOS + LAOS: 6283n, + LAOS_SIGMA_TESTNET: 62850n, + + // ETHERLINK + ETHERLINK: 42793n, + ETHERLINK_TESTNET: 128123n, + + // MOONBEAM + MOONBEAM: 1284n, + MOONBASE_ALPHA: 1287n, + + // MONAD + MONAD_TESTNET: 10143n, + + // SOMNIA + SOMNIA_TESTNET: 50312n, + SOMNIA: 5031n, + + // INCENTIV + INCENTIV_TESTNET: 11690n, + + // SEI + SEI: 1329n, + SEI_TESTNET: 1328n, +} as const + +export type ChainId = (typeof ChainId)[keyof typeof ChainId] + +export const ALL: Network[] = [ + { + chainId: ChainId.MAINNET, + type: NetworkType.MAINNET, + name: 'mainnet', + title: 'Ethereum', + rpcUrl: getRpcUrl('mainnet'), + logoUrl: getLogoUrl(ChainId.MAINNET), + blockExplorer: { + name: 'Etherscan', + url: 'https://etherscan.io/', + }, + nativeCurrency: { + symbol: 'ETH', + name: 'Ether', + decimals: 18, + }, + ensAddress: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e', + }, + { + chainId: ChainId.SEPOLIA, + type: NetworkType.TESTNET, + name: 'sepolia', + title: 'Sepolia', + rpcUrl: getRpcUrl('sepolia'), + logoUrl: getLogoUrl(ChainId.SEPOLIA), + blockExplorer: { + name: 'Etherscan (Sepolia)', + url: 'https://sepolia.etherscan.io/', + }, + nativeCurrency: { + symbol: 'sETH', + name: 'Sepolia Ether', + decimals: 18, + }, + }, + { + chainId: ChainId.POLYGON, + type: NetworkType.MAINNET, + name: 'polygon', + title: 'Polygon', + rpcUrl: getRpcUrl('polygon'), + logoUrl: getLogoUrl(ChainId.POLYGON), + blockExplorer: { + name: 'Polygonscan', + url: 'https://polygonscan.com/', + }, + nativeCurrency: { + symbol: 'POL', + name: 'POL', + decimals: 18, + }, + }, + { + chainId: ChainId.POLYGON_AMOY, + type: NetworkType.TESTNET, + name: 'amoy', + title: 'Polygon Amoy', + rpcUrl: getRpcUrl('amoy'), + logoUrl: getLogoUrl(ChainId.POLYGON_AMOY), + blockExplorer: { + name: 'OKLink (Amoy)', + url: 'https://www.oklink.com/amoy/', + }, + nativeCurrency: { + symbol: 'aPOL', + name: 'Amoy POL', + decimals: 18, + }, + }, + { + chainId: ChainId.POLYGON_ZKEVM, + type: NetworkType.MAINNET, + name: 'polygon-zkevm', + title: 'Polygon zkEVM', + rpcUrl: getRpcUrl('polygon-zkevm'), + logoUrl: getLogoUrl(ChainId.POLYGON_ZKEVM), + blockExplorer: { + name: 'Polygonscan (zkEVM)', + url: 'https://zkevm.polygonscan.com/', + }, + nativeCurrency: { + symbol: 'ETH', + name: 'Ether', + decimals: 18, + }, + }, + { + chainId: ChainId.BSC, + type: NetworkType.MAINNET, + name: 'bsc', + title: 'BNB Smart Chain', + rpcUrl: getRpcUrl('bsc'), + logoUrl: getLogoUrl(ChainId.BSC), + blockExplorer: { + name: 'BSCScan', + url: 'https://bscscan.com/', + }, + nativeCurrency: { + symbol: 'BNB', + name: 'BNB', + decimals: 18, + }, + }, + { + chainId: ChainId.BSC_TESTNET, + type: NetworkType.TESTNET, + name: 'bsc-testnet', + title: 'BNB Smart Chain Testnet', + rpcUrl: getRpcUrl('bsc-testnet'), + logoUrl: getLogoUrl(ChainId.BSC_TESTNET), + blockExplorer: { + name: 'BSCScan (Testnet)', + url: 'https://testnet.bscscan.com/', + }, + nativeCurrency: { + symbol: 'tBNB', + name: 'Testnet BNB', + decimals: 18, + }, + }, + { + chainId: ChainId.OPTIMISM, + type: NetworkType.MAINNET, + name: 'optimism', + title: 'Optimism', + rpcUrl: getRpcUrl('optimism'), + logoUrl: getLogoUrl(ChainId.OPTIMISM), + blockExplorer: { + name: 'Etherscan (Optimism)', + url: 'https://optimistic.etherscan.io/', + }, + nativeCurrency: { + symbol: 'ETH', + name: 'Ether', + decimals: 18, + }, + }, + { + chainId: ChainId.OPTIMISM_SEPOLIA, + type: NetworkType.TESTNET, + name: 'optimism-sepolia', + title: 'Optimism Sepolia', + rpcUrl: getRpcUrl('optimism-sepolia'), + logoUrl: getLogoUrl(ChainId.OPTIMISM_SEPOLIA), + blockExplorer: { + name: 'Etherscan (Optimism Sepolia)', + url: 'https://sepolia-optimistic.etherscan.io/', + }, + nativeCurrency: { + symbol: 'sETH', + name: 'Sepolia Ether', + decimals: 18, + }, + }, + { + chainId: ChainId.ARBITRUM, + type: NetworkType.MAINNET, + name: 'arbitrum', + title: 'Arbitrum One', + rpcUrl: getRpcUrl('arbitrum'), + logoUrl: getLogoUrl(ChainId.ARBITRUM), + blockExplorer: { + name: 'Arbiscan', + url: 'https://arbiscan.io/', + }, + nativeCurrency: { + symbol: 'ETH', + name: 'Ether', + decimals: 18, + }, + }, + { + chainId: ChainId.ARBITRUM_SEPOLIA, + type: NetworkType.TESTNET, + name: 'arbitrum-sepolia', + title: 'Arbitrum Sepolia', + rpcUrl: getRpcUrl('arbitrum-sepolia'), + logoUrl: getLogoUrl(ChainId.ARBITRUM_SEPOLIA), + blockExplorer: { + name: 'Arbiscan (Sepolia Testnet)', + url: 'https://sepolia.arbiscan.io/', + }, + nativeCurrency: { + symbol: 'sETH', + name: 'Sepolia Ether', + decimals: 18, + }, + }, + { + chainId: ChainId.ARBITRUM_NOVA, + type: NetworkType.MAINNET, + name: 'arbitrum-nova', + title: 'Arbitrum Nova', + rpcUrl: getRpcUrl('arbitrum-nova'), + logoUrl: getLogoUrl(ChainId.ARBITRUM_NOVA), + blockExplorer: { + name: 'Arbiscan Nova', + url: 'https://nova.arbiscan.io/', + }, + nativeCurrency: { + symbol: 'ETH', + name: 'Ether', + decimals: 18, + }, + }, + { + chainId: ChainId.AVALANCHE, + type: NetworkType.MAINNET, + name: 'avalanche', + title: 'Avalanche', + rpcUrl: getRpcUrl('avalanche'), + logoUrl: getLogoUrl(ChainId.AVALANCHE), + blockExplorer: { + name: 'Snowtrace', + url: 'https://subnets.avax.network/c-chain/', + }, + nativeCurrency: { + symbol: 'AVAX', + name: 'AVAX', + decimals: 18, + }, + }, + { + chainId: ChainId.AVALANCHE_TESTNET, + type: NetworkType.TESTNET, + name: 'avalanche-testnet', + title: 'Avalanche Testnet', + rpcUrl: getRpcUrl('avalanche-testnet'), + logoUrl: getLogoUrl(ChainId.AVALANCHE_TESTNET), + blockExplorer: { + name: 'Snowtrace (Testnet)', + url: 'https://subnets-test.avax.network/c-chain/', + }, + nativeCurrency: { + symbol: 'tAVAX', + name: 'Testnet AVAX', + decimals: 18, + }, + }, + { + chainId: ChainId.GNOSIS, + type: NetworkType.MAINNET, + name: 'gnosis', + title: 'Gnosis Chain', + rpcUrl: getRpcUrl('gnosis'), + logoUrl: getLogoUrl(ChainId.GNOSIS), + blockExplorer: { + name: 'Gnosis Chain Explorer', + url: 'https://blockscout.com/xdai/mainnet/', + }, + nativeCurrency: { + symbol: 'XDAI', + name: 'XDAI', + decimals: 18, + }, + }, + { + chainId: ChainId.BASE, + type: NetworkType.MAINNET, + name: 'base', + title: 'Base (Coinbase)', + rpcUrl: getRpcUrl('base'), + logoUrl: getLogoUrl(ChainId.BASE), + blockExplorer: { + name: 'Base Explorer', + url: 'https://basescan.org/', + }, + nativeCurrency: { + symbol: 'ETH', + name: 'Ether', + decimals: 18, + }, + }, + { + chainId: ChainId.BASE_SEPOLIA, + type: NetworkType.TESTNET, + name: 'base-sepolia', + title: 'Base Sepolia', + rpcUrl: getRpcUrl('base-sepolia'), + logoUrl: getLogoUrl(ChainId.BASE_SEPOLIA), + blockExplorer: { + name: 'Base Sepolia Explorer', + url: 'https://base-sepolia.blockscout.com/', + }, + nativeCurrency: { + symbol: 'sETH', + name: 'Sepolia Ether', + decimals: 18, + }, + }, + { + chainId: ChainId.HOMEVERSE, + type: NetworkType.MAINNET, + name: 'homeverse', + title: 'Oasys Homeverse', + rpcUrl: getRpcUrl('homeverse'), + logoUrl: getLogoUrl(ChainId.HOMEVERSE), + blockExplorer: { + name: 'Oasys Homeverse Explorer', + url: 'https://explorer.oasys.homeverse.games/', + }, + nativeCurrency: { + symbol: 'OAS', + name: 'OAS', + decimals: 18, + }, + }, + { + chainId: ChainId.HOMEVERSE_TESTNET, + type: NetworkType.TESTNET, + name: 'homeverse-testnet', + title: 'Oasys Homeverse Testnet', + rpcUrl: getRpcUrl('homeverse-testnet'), + logoUrl: getLogoUrl(ChainId.HOMEVERSE_TESTNET), + blockExplorer: { + name: 'Oasys Homeverse Explorer (Testnet)', + url: 'https://explorer.testnet.oasys.homeverse.games/', + }, + nativeCurrency: { + symbol: 'tOAS', + name: 'Testnet OAS', + decimals: 18, + }, + }, + { + chainId: ChainId.XAI, + type: NetworkType.MAINNET, + name: 'xai', + title: 'Xai', + rpcUrl: getRpcUrl('xai'), + logoUrl: getLogoUrl(ChainId.XAI), + blockExplorer: { + name: 'Xai Explorer', + url: 'https://explorer.xai-chain.net/', + }, + nativeCurrency: { + symbol: 'XAI', + name: 'XAI', + decimals: 18, + }, + }, + { + chainId: ChainId.XAI_SEPOLIA, + type: NetworkType.TESTNET, + name: 'xai-sepolia', + title: 'Xai Sepolia', + rpcUrl: getRpcUrl('xai-sepolia'), + logoUrl: getLogoUrl(ChainId.XAI_SEPOLIA), + blockExplorer: { + name: 'Xai Sepolia Explorer', + url: 'https://testnet-explorer-v2.xai-chain.net/', + }, + nativeCurrency: { + symbol: 'sXAI', + name: 'Sepolia XAI', + decimals: 18, + }, + }, + { + chainId: ChainId.B3, + type: NetworkType.MAINNET, + name: 'b3', + title: 'B3', + rpcUrl: getRpcUrl('b3'), + logoUrl: getLogoUrl(ChainId.B3), + blockExplorer: { + name: 'B3 Explorer', + url: 'https://explorer.b3.fun/', + }, + nativeCurrency: { + symbol: 'ETH', + name: 'Ether', + decimals: 18, + }, + }, + { + chainId: ChainId.B3_SEPOLIA, + type: NetworkType.TESTNET, + name: 'b3-sepolia', + title: 'B3 Sepolia', + rpcUrl: getRpcUrl('b3-sepolia'), + logoUrl: getLogoUrl(ChainId.B3_SEPOLIA), + blockExplorer: { + name: 'B3 Sepolia Explorer', + url: 'https://sepolia.explorer.b3.fun/', + }, + nativeCurrency: { + symbol: 'ETH', + name: 'Ether', + decimals: 18, + }, + }, + { + chainId: ChainId.APECHAIN, + type: NetworkType.MAINNET, + name: 'apechain', + title: 'APE Chain', + rpcUrl: getRpcUrl('apechain'), + logoUrl: getLogoUrl(ChainId.APECHAIN), + blockExplorer: { + name: 'APE Chain Explorer', + url: 'https://apechain.calderaexplorer.xyz/', + }, + nativeCurrency: { + symbol: 'APE', + name: 'ApeCoin', + decimals: 18, + }, + }, + { + chainId: ChainId.APECHAIN_TESTNET, + type: NetworkType.TESTNET, + name: 'apechain-testnet', + title: 'APE Chain Testnet', + rpcUrl: getRpcUrl('apechain-testnet'), + logoUrl: getLogoUrl(ChainId.APECHAIN_TESTNET), + blockExplorer: { + name: 'APE Chain Explorer', + url: 'https://curtis.explorer.caldera.xyz/', + }, + nativeCurrency: { + symbol: 'APE', + name: 'ApeCoin', + decimals: 18, + }, + }, + { + chainId: ChainId.BLAST, + type: NetworkType.MAINNET, + name: 'blast', + title: 'Blast', + rpcUrl: getRpcUrl('blast'), + logoUrl: getLogoUrl(ChainId.BLAST), + blockExplorer: { + name: 'Blast Explorer', + url: 'https://blastscan.io/', + }, + nativeCurrency: { + symbol: 'ETH', + name: 'Ether', + decimals: 18, + }, + }, + { + chainId: ChainId.BLAST_SEPOLIA, + type: NetworkType.TESTNET, + name: 'blast-sepolia', + title: 'Blast Sepolia', + rpcUrl: getRpcUrl('blast-sepolia'), + logoUrl: getLogoUrl(ChainId.BLAST_SEPOLIA), + blockExplorer: { + name: 'Blast Sepolia Explorer', + url: 'https://sepolia.blastexplorer.io/', + }, + nativeCurrency: { + symbol: 'ETH', + name: 'Ether', + decimals: 18, + }, + }, + { + chainId: ChainId.TELOS, + type: NetworkType.MAINNET, + name: 'telos', + title: 'Telos', + rpcUrl: getRpcUrl('telos'), + logoUrl: getLogoUrl(ChainId.TELOS), + blockExplorer: { + name: 'Telos Explorer', + url: 'https://explorer.telos.net/network/', + }, + nativeCurrency: { + symbol: 'TLOS', + name: 'TLOS', + decimals: 18, + }, + }, + { + chainId: ChainId.TELOS_TESTNET, + type: NetworkType.TESTNET, + name: 'telos-testnet', + title: 'Telos Testnet', + rpcUrl: getRpcUrl('telos-testnet'), + logoUrl: getLogoUrl(ChainId.TELOS_TESTNET), + blockExplorer: { + name: 'Telos Testnet Explorer', + url: 'https://explorer-test.telos.net/network', + }, + nativeCurrency: { + symbol: 'TLOS', + name: 'TLOS', + decimals: 18, + }, + }, + { + chainId: ChainId.SKALE_NEBULA, + type: NetworkType.MAINNET, + name: 'skale-nebula', + title: 'SKALE Nebula Gaming Hub', + rpcUrl: getRpcUrl('skale-nebula'), + logoUrl: getLogoUrl(ChainId.SKALE_NEBULA), + blockExplorer: { + name: 'SKALE Nebula Gaming Hub Explorer', + url: 'https://green-giddy-denebola.explorer.mainnet.skalenodes.com/', + }, + nativeCurrency: { + symbol: 'sFUEL', + name: 'SKALE Fuel', + decimals: 18, + }, + }, + { + chainId: ChainId.SKALE_NEBULA_TESTNET, + type: NetworkType.TESTNET, + name: 'skale-nebula-testnet', + title: 'SKALE Nebula Gaming Hub Testnet', + rpcUrl: getRpcUrl('skale-nebula-testnet'), + logoUrl: getLogoUrl(ChainId.SKALE_NEBULA_TESTNET), + blockExplorer: { + name: 'SKALE Nebula Gaming Hub Testnet Explorer', + url: 'https://lanky-ill-funny-testnet.explorer.testnet.skalenodes.com/', + }, + nativeCurrency: { + symbol: 'sFUEL', + name: 'SKALE Fuel', + decimals: 18, + }, + }, + { + chainId: ChainId.SONEIUM, + type: NetworkType.MAINNET, + name: 'soneium', + title: 'Soneium', + rpcUrl: getRpcUrl('soneium'), + logoUrl: getLogoUrl(ChainId.SONEIUM), + blockExplorer: { + name: 'Soneium Explorer', + url: 'https://soneium.blockscout.com/', + }, + nativeCurrency: { + symbol: 'ETH', + name: 'Ether', + decimals: 18, + }, + }, + { + chainId: ChainId.SONEIUM_MINATO, + type: NetworkType.TESTNET, + name: 'soneium-minato', + title: 'Soneium Minato (Testnet)', + rpcUrl: getRpcUrl('soneium-minato'), + logoUrl: getLogoUrl(ChainId.SONEIUM_MINATO), + blockExplorer: { + name: 'Soneium Minato Explorer', + url: 'https://explorer-testnet.soneium.org/', + }, + nativeCurrency: { + symbol: 'ETH', + name: 'Ether', + decimals: 18, + }, + }, + { + chainId: ChainId.TOY_TESTNET, + type: NetworkType.TESTNET, + name: 'toy-testnet', + title: 'TOY (Testnet)', + rpcUrl: getRpcUrl('toy-testnet'), + logoUrl: getLogoUrl(ChainId.TOY_TESTNET), + blockExplorer: { + name: 'TOY Testnet Explorer', + url: 'https://toy-chain-testnet.explorer.caldera.xyz/', + }, + nativeCurrency: { + symbol: 'TOY', + name: 'TOY', + decimals: 18, + }, + }, + { + chainId: ChainId.IMMUTABLE_ZKEVM, + type: NetworkType.MAINNET, + name: 'immutable-zkevm', + title: 'Immutable zkEVM', + rpcUrl: getRpcUrl('immutable-zkevm'), + logoUrl: getLogoUrl(ChainId.IMMUTABLE_ZKEVM), + blockExplorer: { + name: 'Immutable zkEVM Explorer', + url: 'https://explorer.immutable.com/', + }, + nativeCurrency: { + symbol: 'IMX', + name: 'IMX', + decimals: 18, + }, + }, + { + chainId: ChainId.IMMUTABLE_ZKEVM_TESTNET, + type: NetworkType.TESTNET, + name: 'immutable-zkevm-testnet', + title: 'Immutable zkEVM Testnet', + rpcUrl: getRpcUrl('immutable-zkevm-testnet'), + logoUrl: getLogoUrl(ChainId.IMMUTABLE_ZKEVM_TESTNET), + blockExplorer: { + name: 'Immutable zkEVM Testnet Explorer', + url: 'https://explorer.testnet.immutable.com/', + }, + nativeCurrency: { + symbol: 'IMX', + name: 'IMX', + decimals: 18, + }, + }, + { + chainId: ChainId.ROOT_NETWORK, + type: NetworkType.MAINNET, + name: 'rootnet', + title: 'The Root Network', + rpcUrl: getRpcUrl('rootnet'), + logoUrl: getLogoUrl(ChainId.ROOT_NETWORK), + blockExplorer: { + name: 'The Root Network Explorer', + url: 'https://rootscan.io/', + }, + nativeCurrency: { + symbol: 'XRP', + name: 'XRP', + decimals: 18, + }, + }, + { + chainId: ChainId.ROOT_NETWORK_PORCINI, + type: NetworkType.TESTNET, + name: 'rootnet-porcini', + title: 'The Root Network Porcini Testnet', + rpcUrl: getRpcUrl('rootnet-porcini'), + logoUrl: getLogoUrl(ChainId.ROOT_NETWORK_PORCINI), + blockExplorer: { + name: 'The Root Network Porcini Testnet Explorer', + url: 'https://porcini.rootscan.io/', + }, + nativeCurrency: { + symbol: 'XRP', + name: 'XRP', + decimals: 18, + }, + }, + { + chainId: ChainId.LAOS, + type: NetworkType.MAINNET, + name: 'laos', + title: 'LAOS', + rpcUrl: getRpcUrl('laos'), + logoUrl: getLogoUrl(ChainId.LAOS), + blockExplorer: { + name: 'LAOS Explorer', + url: 'https://blockscout.laos.laosfoundation.io/', + }, + nativeCurrency: { + symbol: 'LAOS', + name: 'LAOS', + decimals: 18, + }, + }, + { + chainId: ChainId.LAOS_SIGMA_TESTNET, + type: NetworkType.TESTNET, + name: 'laos-sigma-testnet', + title: 'LAOS Sigma Testnet', + rpcUrl: getRpcUrl('laos-sigma-testnet'), + logoUrl: getLogoUrl(ChainId.LAOS_SIGMA_TESTNET), + blockExplorer: { + name: 'LAOS Sigma Testnet Explorer', + url: 'https://sigma.explorer.laosnetwork.io/', + }, + nativeCurrency: { + symbol: 'SIGMA', + name: 'SIGMA', + decimals: 18, + }, + }, + { + chainId: ChainId.MOONBEAM, + type: NetworkType.MAINNET, + name: 'moonbeam', + title: 'Moonbeam', + rpcUrl: getRpcUrl('moonbeam'), + logoUrl: getLogoUrl(ChainId.MOONBEAM), + blockExplorer: { + name: 'Moonscan', + url: 'https://moonscan.io/', + }, + nativeCurrency: { + symbol: 'GLMR', + name: 'GLMR', + decimals: 18, + }, + }, + { + chainId: ChainId.MOONBASE_ALPHA, + type: NetworkType.TESTNET, + name: 'moonbase-alpha', + title: 'Moonbase Alpha', + rpcUrl: getRpcUrl('moonbase-alpha'), + logoUrl: getLogoUrl(ChainId.MOONBASE_ALPHA), + blockExplorer: { + name: 'Moonscan (Moonbase Alpha)', + url: 'https://moonbase.moonscan.io/', + }, + nativeCurrency: { + symbol: 'GLMR', + name: 'GLMR', + decimals: 18, + }, + }, + { + chainId: ChainId.ETHERLINK, + type: NetworkType.MAINNET, + name: 'etherlink', + title: 'Etherlink', + rpcUrl: getRpcUrl('etherlink'), + logoUrl: getLogoUrl(ChainId.ETHERLINK), + blockExplorer: { + name: 'Etherlink Explorer', + url: 'https://explorer.etherlink.com/', + }, + nativeCurrency: { + symbol: 'XTZ', + name: 'Tez', + decimals: 18, + }, + }, + { + chainId: ChainId.ETHERLINK_TESTNET, + type: NetworkType.TESTNET, + name: 'etherlink-testnet', + title: 'Etherlink Testnet', + rpcUrl: getRpcUrl('etherlink-testnet'), + logoUrl: getLogoUrl(ChainId.ETHERLINK_TESTNET), + blockExplorer: { + name: 'Etherlink Testnet Explorer', + url: 'https://testnet.explorer.etherlink.com/', + }, + nativeCurrency: { + symbol: 'XTZ', + name: 'Tez', + decimals: 18, + }, + }, + { + chainId: ChainId.MONAD_TESTNET, + type: NetworkType.TESTNET, + name: 'monad-testnet', + title: 'Monad Testnet', + rpcUrl: getRpcUrl('monad-testnet'), + logoUrl: getLogoUrl(ChainId.MONAD_TESTNET), + blockExplorer: { + name: 'Monad Testnet Explorer', + url: 'https://testnet.monadexplorer.com/', + }, + nativeCurrency: { + symbol: 'MON', + name: 'MON', + decimals: 18, + }, + }, + + { + chainId: ChainId.SOMNIA_TESTNET, + type: NetworkType.TESTNET, + name: 'somnia-testnet', + title: 'Somnia Testnet', + rpcUrl: getRpcUrl('somnia-testnet'), + logoUrl: getLogoUrl(ChainId.SOMNIA_TESTNET), + blockExplorer: { + name: 'Somnia Testnet Explorer', + url: 'https://somnia-testnet.socialscan.io/', + }, + nativeCurrency: { + symbol: 'STT', + name: 'STT', + decimals: 18, + }, + }, + + { + chainId: ChainId.INCENTIV_TESTNET, + type: NetworkType.TESTNET, + name: 'incentiv-testnet', + title: 'Incentiv Testnet', + rpcUrl: getRpcUrl('incentiv-testnet'), + logoUrl: getLogoUrl(ChainId.INCENTIV_TESTNET), + blockExplorer: { + name: 'Incentiv Testnet Explorer', + url: 'https://explorer.testnet.incentiv.net/', + }, + nativeCurrency: { + symbol: 'CENT', + name: 'CENT', + decimals: 18, + }, + }, + + { + chainId: ChainId.SEI, + type: NetworkType.MAINNET, + name: 'sei', + title: 'Sei', + rpcUrl: getRpcUrl('sei'), + logoUrl: getLogoUrl(ChainId.SEI), + blockExplorer: { + name: 'SEI Explorer', + url: 'https://seitrace.com/?chain=pacific-1', + }, + nativeCurrency: { + symbol: 'SEI', + name: 'SEI', + decimals: 18, + }, + }, + + { + chainId: ChainId.SEI_TESTNET, + type: NetworkType.TESTNET, + name: 'sei-testnet', + title: 'Sei Testnet', + rpcUrl: getRpcUrl('sei-testnet'), + logoUrl: getLogoUrl(ChainId.SEI_TESTNET), + blockExplorer: { + name: 'Sei Testnet Explorer', + url: 'https://seitrace.com/?chain=atlantic-2', + }, + nativeCurrency: { + symbol: 'SEI', + name: 'SEI', + decimals: 18, + }, + }, + + { + chainId: ChainId.SOMNIA, + type: NetworkType.MAINNET, + name: 'somnia', + title: 'Somnia', + rpcUrl: getRpcUrl('somnia'), + logoUrl: getLogoUrl(ChainId.SOMNIA), + blockExplorer: { + name: 'Somnia Explorer', + url: 'https://mainnet.somnia.w3us.site/', + }, + nativeCurrency: { + symbol: 'SOMI', + name: 'SOMI', + decimals: 18, + }, }, -} - -export const Moonbeam: Network = { - name: 'moonbeam', - rpc: getRpcUrl('moonbeam'), - chainId: 1284n, - explorer: 'https://moonscan.io/', - nativeCurrency: { - name: 'GLMR', - symbol: 'GLMR', - decimals: 18, - }, -} - -export const MoonbaseAlpha: Network = { - name: 'moonbase-alpha', - rpc: getRpcUrl('moonbase-alpha'), - chainId: 1287n, - explorer: 'https://moonbase.moonscan.io/', - nativeCurrency: { - name: 'GLMR', - symbol: 'GLMR', - decimals: 18, - }, -} - -export const Etherlink: Network = { - name: 'etherlink', - rpc: getRpcUrl('etherlink'), - chainId: 42793n, - explorer: 'https://explorer.etherlink.com/', - nativeCurrency: { - name: 'Tez', - symbol: 'XTZ', - decimals: 18, - }, -} +] -export const EtherlinkTestnet: Network = { - name: 'etherlink-testnet', - rpc: getRpcUrl('etherlink-testnet'), - chainId: 128123n, - explorer: 'https://testnet.explorer.etherlink.com/', - nativeCurrency: { - name: 'Tez', - symbol: 'XTZ', - decimals: 18, - }, +function getRpcUrl(networkName: string): string { + return `https://nodes.sequence.app/${networkName}` } -export const MonadTestnet: Network = { - name: 'monad-testnet', - rpc: getRpcUrl('monad-testnet'), - chainId: 10143n, - explorer: 'https://testnet.monadexplorer.com/', - nativeCurrency: { - name: 'MON', - symbol: 'MON', - decimals: 18, - }, +function getLogoUrl(chainId: ChainId): string { + return `https://assets.sequence.info/images/networks/medium/${chainId}.webp` } -export const Somnia: Network = { - name: 'somnia', - rpc: getRpcUrl('somnia'), - chainId: 5031n, - explorer: 'https://mainnet.somnia.w3us.site/', - nativeCurrency: { - name: 'SOMI', - symbol: 'SOMI', - decimals: 18, - }, +export function getNetworkFromName(networkName: string): Network | undefined { + return ALL.find((network) => network.name === networkName) } -export const SomniaTestnet: Network = { - name: 'somnia-testnet', - rpc: getRpcUrl('somnia-testnet'), - chainId: 50312n, - explorer: 'https://somnia-testnet.socialscan.io/', - nativeCurrency: { - name: 'STT', - symbol: 'STT', - decimals: 18, - }, +export function getNetworkFromChainId(chainId: ChainId | bigint | number | string): Network | undefined { + return ALL.find((network) => network.chainId === BigInt(chainId)) } - -export const All = [ - Mainnet, - Sepolia, - Polygon, - PolygonAmoy, - PolygonZkEVM, - BSC, - BSCTestnet, - Optimism, - OptimismSepolia, - Arbitrum, - ArbitrumSepolia, - ArbitrumNova, - Avalanche, - AvalancheTestnet, - Gnosis, - Base, - BaseSepolia, - Homeverse, - HomeverseTestnet, - Xai, - XaiSepolia, - Telos, - TelosTestnet, - B3, - B3Sepolia, - ApeChain, - ApeChainTestnet, - Blast, - BlastSepolia, - SkaleNebula, - SkaleNebulaTestnet, - Soneium, - SoneiumMinato, - ToyTestnet, - ImmutableZkEVM, - ImmutableZkEVMTestnet, - RootNetwork, - RootNetworkPorcini, - Laos, - LaosSigmaTestnet, - Moonbeam, - MoonbaseAlpha, - Etherlink, - EtherlinkTestnet, - MonadTestnet, - Somnia, - SomniaTestnet, -] diff --git a/packages/wallet/primitives/src/payload.ts b/packages/wallet/primitives/src/payload.ts index 84030f107..f426905f7 100644 --- a/packages/wallet/primitives/src/payload.ts +++ b/packages/wallet/primitives/src/payload.ts @@ -1,7 +1,7 @@ import { AbiFunction, AbiParameters, Address, Bytes, Hash, Hex } from 'ox' import { getSignPayload } from 'ox/TypedData' import { EXECUTE_USER_OP, RECOVER_SAPIENT_SIGNATURE } from './constants.js' -import { Attestation } from './index.js' +import { Attestation, Network } from './index.js' import { minBytesFor } from './utils.js' import { UserOperation } from 'ox/erc4337' diff --git a/packages/wallet/primitives/src/signature.ts b/packages/wallet/primitives/src/signature.ts index 9c8f8d39e..485618011 100644 --- a/packages/wallet/primitives/src/signature.ts +++ b/packages/wallet/primitives/src/signature.ts @@ -22,7 +22,7 @@ import { RECOVER_SAPIENT_SIGNATURE, RECOVER_SAPIENT_SIGNATURE_COMPACT, IS_VALID_ import { wrap, decode } from './erc-6492.js' import { fromConfigUpdate, hash, Parented } from './payload.js' import { minBytesFor, packRSY, unpackRSY } from './utils.js' -import { Constants } from './index.js' +import { Constants, Network } from './index.js' export const FLAG_SIGNATURE_HASH = 0 export const FLAG_ADDRESS = 1 diff --git a/packages/wallet/wdk/package.json b/packages/wallet/wdk/package.json index d9f0cd090..437a37a74 100644 --- a/packages/wallet/wdk/package.json +++ b/packages/wallet/wdk/package.json @@ -12,6 +12,7 @@ "dev": "tsc --watch", "test": "vitest run", "test:coverage": "vitest run --coverage", + "typecheck": "tsc --noEmit", "clean": "rimraf dist" }, "exports": { diff --git a/packages/wallet/wdk/src/sequence/manager.ts b/packages/wallet/wdk/src/sequence/manager.ts index 9064d9b55..9e30088a4 100644 --- a/packages/wallet/wdk/src/sequence/manager.ts +++ b/packages/wallet/wdk/src/sequence/manager.ts @@ -100,7 +100,7 @@ export const ManagerOptionsDefaults = { dbPruningInterval: 1000 * 60 * 60 * 24, // 24 hours stateProvider: new State.Sequence.Provider(), - networks: Network.All, + networks: Network.ALL, relayers: () => [Relayer.Standard.LocalRelayer.createFromWindow(window)].filter((r) => r !== undefined), bundlers: [], diff --git a/packages/wallet/wdk/src/sequence/messages.ts b/packages/wallet/wdk/src/sequence/messages.ts index afd34912b..a72342261 100644 --- a/packages/wallet/wdk/src/sequence/messages.ts +++ b/packages/wallet/wdk/src/sequence/messages.ts @@ -1,6 +1,6 @@ import { Envelope, Wallet } from '@0xsequence/wallet-core' import { Payload } from '@0xsequence/wallet-primitives' -import { Address, Bytes, Hex, Provider, RpcTransport } from 'ox' +import { Address, Hex, Provider, RpcTransport } from 'ox' import { v7 as uuidv7 } from 'uuid' import { Shared } from './manager.js' import { Message, MessageRequest, MessageRequested, MessageSigned } from './types/message-request.js' @@ -195,7 +195,7 @@ export class Messages implements MessagesInterface { if (!network) { throw new Error(`Network not found for ${message.envelope.chainId}`) } - const transport = RpcTransport.fromHttp(network.rpc) + const transport = RpcTransport.fromHttp(network.rpcUrl) provider = Provider.from(transport) } diff --git a/packages/wallet/wdk/src/sequence/recovery.ts b/packages/wallet/wdk/src/sequence/recovery.ts index 46f00ebac..758b3f355 100644 --- a/packages/wallet/wdk/src/sequence/recovery.ts +++ b/packages/wallet/wdk/src/sequence/recovery.ts @@ -1,11 +1,11 @@ +import { Envelope } from '@0xsequence/wallet-core' import { Config, Constants, Extensions, GenericTree, Payload } from '@0xsequence/wallet-primitives' -import { Shared } from './manager.js' import { Address, Hex, Provider, RpcTransport } from 'ox' -import { Kinds, RecoverySigner } from './types/signer.js' -import { Envelope } from '@0xsequence/wallet-core' -import { QueuedRecoveryPayload } from './types/recovery.js' -import { Actions } from './types/index.js' import { MnemonicHandler } from './handlers/mnemonic.js' +import { Shared } from './manager.js' +import { Actions } from './types/index.js' +import { QueuedRecoveryPayload } from './types/recovery.js' +import { Kinds, RecoverySigner } from './types/signer.js' export interface RecoveryInterface { /** @@ -468,7 +468,7 @@ export class Recovery implements RecoveryInterface { // Create providers for each network const providers = this.shared.sequence.networks.map((network) => ({ chainId: network.chainId, - provider: Provider.from(RpcTransport.fromHttp(network.rpc)), + provider: Provider.from(RpcTransport.fromHttp(network.rpcUrl)), })) const seenInThisRun = new Set() diff --git a/packages/wallet/wdk/src/sequence/transactions.ts b/packages/wallet/wdk/src/sequence/transactions.ts index 26d7f0977..251f36734 100644 --- a/packages/wallet/wdk/src/sequence/transactions.ts +++ b/packages/wallet/wdk/src/sequence/transactions.ts @@ -1,5 +1,5 @@ -import { Constants, Payload } from '@0xsequence/wallet-primitives' import { Envelope, Relayer, Wallet } from '@0xsequence/wallet-core' +import { Constants, Payload } from '@0xsequence/wallet-primitives' import { Abi, AbiFunction, Address, Hex, Provider, RpcTransport } from 'ox' import { v7 as uuidv7 } from 'uuid' import { Shared } from './manager.js' @@ -258,7 +258,7 @@ export class Transactions implements TransactionsInterface { throw new Error(`Network not found for ${chainId}`) } - const transport = RpcTransport.fromHttp(network.rpc) + const transport = RpcTransport.fromHttp(network.rpcUrl) const provider = Provider.from(transport) const wallet = new Wallet(from, { stateProvider: this.shared.sequence.stateProvider }) @@ -327,11 +327,11 @@ export class Transactions implements TransactionsInterface { } const wallet = new Wallet(tx.wallet, { stateProvider: this.shared.sequence.stateProvider }) - const provider = Provider.from( - RpcTransport.fromHttp( - this.shared.sequence.networks.find((network) => network.chainId === tx.envelope.chainId)!.rpc, - ), - ) + const network = this.shared.sequence.networks.find((network) => network.chainId === tx.envelope.chainId) + if (!network) { + throw new Error(`Network not found for ${tx.envelope.chainId}`) + } + const provider = Provider.from(RpcTransport.fromHttp(network.rpcUrl)) // Get relayer and relayer options const [allRelayerOptions, allBundlerOptions] = await Promise.all([ @@ -523,7 +523,7 @@ export class Transactions implements TransactionsInterface { throw new Error(`Network not found for ${tx.envelope.chainId}`) } - const transport = RpcTransport.fromHttp(network.rpc) + const transport = RpcTransport.fromHttp(network.rpcUrl) const provider = Provider.from(transport) const wallet = new Wallet(tx.wallet, { stateProvider: this.shared.sequence.stateProvider }) diff --git a/packages/wallet/wdk/src/sequence/wallets.ts b/packages/wallet/wdk/src/sequence/wallets.ts index 2580e3ce9..13d25cf42 100644 --- a/packages/wallet/wdk/src/sequence/wallets.ts +++ b/packages/wallet/wdk/src/sequence/wallets.ts @@ -2,14 +2,14 @@ import { Wallet as CoreWallet, Envelope, Signers, State } from '@0xsequence/wall import { Config, Constants, GenericTree, Payload, SessionConfig } from '@0xsequence/wallet-primitives' import { Address, Hex, Provider, RpcTransport } from 'ox' import { AuthCommitment } from '../dbs/auth-commitments.js' +import { AuthCodeHandler } from './handlers/authcode.js' import { MnemonicHandler } from './handlers/mnemonic.js' import { OtpHandler } from './handlers/otp.js' import { ManagerOptionsDefaults, Shared } from './manager.js' +import { Device } from './types/device.js' import { Action } from './types/index.js' import { Kinds, SignerWithKind, WitnessExtraSignerKind } from './types/signer.js' import { Wallet, WalletSelectionUiHandler } from './types/wallet.js' -import { AuthCodeHandler } from './handlers/authcode.js' -import { Device } from './types/device.js' export type StartSignUpWithRedirectArgs = { kind: 'google-pkce' | 'apple' @@ -1114,7 +1114,7 @@ export class Wallets implements WalletsInterface { throw new Error('network-not-found') } - const provider = Provider.from(RpcTransport.fromHttp(network.rpc)) + const provider = Provider.from(RpcTransport.fromHttp(network.rpcUrl)) return wallet.getNonce(provider, space) } @@ -1129,7 +1129,7 @@ export class Wallets implements WalletsInterface { throw new Error('network-not-found') } - const provider = Provider.from(RpcTransport.fromHttp(network.rpc)) + const provider = Provider.from(RpcTransport.fromHttp(network.rpcUrl)) const status = await walletObject.getStatus(provider) const onchainConfiguration = await this.shared.sequence.stateProvider.getConfiguration(status.onChainImageHash) @@ -1174,7 +1174,7 @@ export class Wallets implements WalletsInterface { throw new Error('network-not-found') } - const provider = Provider.from(RpcTransport.fromHttp(network.rpc)) + const provider = Provider.from(RpcTransport.fromHttp(network.rpcUrl)) const onchainStatus = await walletObject.getStatus(provider) return onchainStatus.imageHash === onchainStatus.onChainImageHash } diff --git a/packages/wallet/wdk/test/constants.ts b/packages/wallet/wdk/test/constants.ts index 889a71937..c6ba2a3f2 100644 --- a/packages/wallet/wdk/test/constants.ts +++ b/packages/wallet/wdk/test/constants.ts @@ -4,6 +4,7 @@ import { Manager, ManagerOptions, ManagerOptionsDefaults } from '../src/sequence import { mockEthereum } from './setup' import { Signers as CoreSigners, State, Relayer } from '@0xsequence/wallet-core' import * as Db from '../src/dbs' +import { Network } from '@0xsequence/wallet-primitives' const envFile = process.env.CI ? '.env.test' : '.env.test.local' dotenvConfig({ path: envFile }) @@ -37,9 +38,10 @@ export function newManager(options?: ManagerOptions, noEthereumMock?: boolean, t networks: [ { name: 'Arbitrum (local fork)', - rpc: LOCAL_RPC_URL, + type: Network.NetworkType.MAINNET, + rpcUrl: LOCAL_RPC_URL, chainId: 42161n, - explorer: 'https://arbiscan.io/', + blockExplorer: { url: 'https://arbiscan.io/' }, nativeCurrency: { name: 'Ether', symbol: 'ETH', @@ -109,9 +111,10 @@ export function newRemoteManager( networks: [ { name: 'Remote Test Network', - rpc: remoteManagerOptions.network.rpcUrl, + type: Network.NetworkType.MAINNET, + rpcUrl: remoteManagerOptions.network.rpcUrl, chainId: remoteManagerOptions.network.chainId, - explorer: 'https://undefined/', + blockExplorer: { url: 'https://undefined/' }, nativeCurrency: { name: 'Ether', symbol: 'ETH', diff --git a/packages/wallet/wdk/test/identity-auth-dbs.test.ts b/packages/wallet/wdk/test/identity-auth-dbs.test.ts index 60fbee1c8..7e92d3475 100644 --- a/packages/wallet/wdk/test/identity-auth-dbs.test.ts +++ b/packages/wallet/wdk/test/identity-auth-dbs.test.ts @@ -5,6 +5,7 @@ import { IdentityInstrument } from '@0xsequence/identity-instrument' import * as Db from '../src/dbs' import { LOCAL_RPC_URL } from './constants' import { State } from '@0xsequence/wallet-core' +import { Network } from '@0xsequence/wallet-primitives' describe('Identity Authentication Databases', () => { let manager: Manager | undefined @@ -328,9 +329,10 @@ describe('Identity Authentication Databases', () => { networks: [ { name: 'Test Network', - rpc: LOCAL_RPC_URL, + type: Network.NetworkType.MAINNET, + rpcUrl: LOCAL_RPC_URL, chainId: 42161n, - explorer: 'https://arbiscan.io', + blockExplorer: { url: 'https://arbiscan.io' }, nativeCurrency: { name: 'Ether', symbol: 'ETH', @@ -362,9 +364,10 @@ describe('Identity Authentication Databases', () => { networks: [ { name: 'Test Network', - rpc: LOCAL_RPC_URL, + type: Network.NetworkType.MAINNET, + rpcUrl: LOCAL_RPC_URL, chainId: 42161n, - explorer: 'https://arbiscan.io', + blockExplorer: { url: 'https://arbiscan.io' }, nativeCurrency: { name: 'Ether', symbol: 'ETH', @@ -395,9 +398,10 @@ describe('Identity Authentication Databases', () => { networks: [ { name: 'Test Network', - rpc: LOCAL_RPC_URL, + type: Network.NetworkType.MAINNET, + rpcUrl: LOCAL_RPC_URL, chainId: 42161n, - explorer: 'https://arbiscan.io', + blockExplorer: { url: 'https://arbiscan.io' }, nativeCurrency: { name: 'Ether', symbol: 'ETH', diff --git a/packages/wallet/wdk/test/sessions.test.ts b/packages/wallet/wdk/test/sessions.test.ts index cd92517dd..3984dd795 100644 --- a/packages/wallet/wdk/test/sessions.test.ts +++ b/packages/wallet/wdk/test/sessions.test.ts @@ -1,7 +1,7 @@ import { AbiFunction, Address, Bytes, Hex, Mnemonic, Provider, RpcTransport } from 'ox' import { beforeEach, describe, expect, it, vi } from 'vitest' import { Signers as CoreSigners, Wallet as CoreWallet, Envelope, Relayer, State } from '../../core/src/index.js' -import { Attestation, Constants, Extensions, Payload, Permission } from '../../primitives/src/index.js' +import { Attestation, Constants, Extensions, Network, Payload, Permission } from '../../primitives/src/index.js' import { Sequence } from '../src/index.js' import { CAN_RUN_LIVE, EMITTER_ABI, EMITTER_ADDRESS, PRIVATE_KEY, RPC_URL } from './constants' @@ -81,9 +81,10 @@ describe('Sessions (via Manager)', () => { networks: [ { chainId, - rpc: RPC_URL ?? 'XXX', + type: Network.NetworkType.MAINNET, + rpcUrl: RPC_URL ?? 'XXX', name: 'XXX', - explorer: 'XXX', + blockExplorer: { url: 'XXX' }, nativeCurrency: { name: 'Ether', symbol: 'ETH', diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cba9a88c9..9e39bc239 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -258,9 +258,6 @@ importers: packages/wallet/dapp-client: dependencies: - '@0xsequence/network': - specifier: ^2.3.23 - version: 2.3.23(ethers@6.15.0) '@0xsequence/wallet-core': specifier: workspace:^ version: link:../core @@ -475,38 +472,9 @@ importers: packages: - '@0xsequence/abi@2.3.23': - resolution: {integrity: sha512-N5bVeCAKaHQ6+M8lKVlPfNcbmp3s10BBLNiqM1XzIGuzl5BKxBj0S9h4Vb7cd//3ALxgqYjwRvxi760wIDnyCA==} - - '@0xsequence/core@2.3.23': - resolution: {integrity: sha512-0y6TidFNJFYQF2yqGXScWYZTuGy651qwBH+9fQKRjzGSa0eXpe3zkccqiNuTtOXpR5QHBVGJ2U69SbK3ajzKEA==} - peerDependencies: - ethers: '>=6' - - '@0xsequence/indexer@2.3.23': - resolution: {integrity: sha512-wYOPGDucEB+h4qujS4TqZ25pehdhByDLxsMLVDA4VFH0AFZlAt7Pq9hQznbQNnLwRPm+DHE/QB//qcPRvCiEFQ==} - - '@0xsequence/network@2.3.23': - resolution: {integrity: sha512-7p0iTcFpkzQvh5saainlD95MZmUlMkZ+BiGzu/qT1gXYhUHEm5soq9wcII1JztgHaXgb+naS6PVTKB+z9eijYg==} - peerDependencies: - ethers: '>=6' - - '@0xsequence/relayer@2.3.23': - resolution: {integrity: sha512-6b+ZjS2PWBM46awtPunfudCuvNUok7AUuuQiP5cukgTV949t5heoL9sY+FnJCVNEGayuqyghqMP4pyBmGgpo1w==} - peerDependencies: - ethers: '>=6' - '@0xsequence/tee-verifier@0.1.2': resolution: {integrity: sha512-7sKr8/T4newknx6LAukjlRI3siGiGhBnZohz2Z3jX0zb0EBQdKUq0L//A7CPSckHFPxTg/QvQU2v8e9x9GfkDw==} - '@0xsequence/utils@2.3.23': - resolution: {integrity: sha512-Ak4/QuginegFw/tnpyb9u0aw8fA6XHdLH9JjM0jsRrPyM5v6KqKFQoCrCssQfXeBxuHaWs+ABxf5gL9TKpDBng==} - peerDependencies: - ethers: '>=6' - - '@adraffy/ens-normalize@1.10.1': - resolution: {integrity: sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw==} - '@adraffy/ens-normalize@1.11.0': resolution: {integrity: sha512-/3DDPKHqqIqxUULp8yP4zODUY1i+2xvVWsv8A79xGWdCAG+8sb0hRh0Rk2QyOJUnnbyPUAZYcpBuRe3nS2OIUg==} @@ -1037,9 +1005,6 @@ packages: resolution: {integrity: sha512-2I0gnIVPtfnMw9ee9h1dJG7tp81+8Ob3OJb3Mv37rx5L40/b0i7djjCVvGOVqc9AEIQyvyu1i6ypKdFw8R8gQw==} engines: {node: ^14.21.3 || >=16} - '@noble/curves@1.2.0': - resolution: {integrity: sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==} - '@noble/curves@1.9.2': resolution: {integrity: sha512-HxngEd2XUcg9xi20JkwlLCtYwfoFw4JGkuZpT+WlsPD4gB/cxkvTD8fSsoAnphGZhFdZYKeQIPCuFlWPm1uE0g==} engines: {node: ^14.21.3 || >=16} @@ -1048,10 +1013,6 @@ packages: resolution: {integrity: sha512-2bKONnuM53lINoDrSmK8qP8W271ms7pygDhZt4SiLOoLwBtoHqeCFi6RG42V8zd3mLHuJFhU/Bmaqo4nX0/kBw==} engines: {node: ^14.21.3 || >=16} - '@noble/hashes@1.3.2': - resolution: {integrity: sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==} - engines: {node: '>= 16'} - '@noble/hashes@1.8.0': resolution: {integrity: sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==} engines: {node: ^14.21.3 || >=16} @@ -1238,9 +1199,6 @@ packages: '@types/node@22.16.5': resolution: {integrity: sha512-bJFoMATwIGaxxx8VJPeM8TonI8t579oRvgAuT8zFugJsJZgzqv0Fu8Mhp68iecjzG7cnN3mO2dJQ5uUM2EFrgQ==} - '@types/node@22.7.5': - resolution: {integrity: sha512-jML7s2NAzMWc//QSJ1a3prpk78cOPchGvXJsC3C6R6PSMoooztvRVQEz89gmBTBY1SPMaqo5teB4uNHPdetShQ==} - '@types/prop-types@15.7.15': resolution: {integrity: sha512-F6bEyamV9jKGAFBEmlQnesRPGOQqS2+Uwi0Em15xenOxHaf2hv6L8YCVn3rPdPJOiJfPiCnLIRyvwVaqMY3MIw==} @@ -1390,9 +1348,6 @@ packages: engines: {node: '>=0.4.0'} hasBin: true - aes-js@4.0.0-beta.5: - resolution: {integrity: sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q==} - agent-base@7.1.4: resolution: {integrity: sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==} engines: {node: '>= 14'} @@ -1919,10 +1874,6 @@ packages: resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} engines: {node: '>=0.10.0'} - ethers@6.15.0: - resolution: {integrity: sha512-Kf/3ZW54L4UT0pZtsY/rf+EkBU7Qi5nnhonjUb8yTXcxH3cdcWrV2cRyk0Xk/4jK6OoHhxxZHriyhje20If2hQ==} - engines: {node: '>=14.0.0'} - eventemitter3@5.0.1: resolution: {integrity: sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==} @@ -2425,9 +2376,6 @@ packages: resolution: {integrity: sha512-zptv57P3GpL+O0I7VdMJNBZCu+BPHVQUk55Ft8/QCJjTVxrnJHuVuX/0Bl2A6/+2oyR/ZMEuFKwmzqqZ/U5nPQ==} engines: {node: 20 || >=22} - js-base64@3.7.7: - resolution: {integrity: sha512-7rCnleh0z2CkXhH67J8K1Ytz0b2Y+yxTPL+/KOJoa20hfnVQ/3/T6W/KflYI4bRHRagNeXeU2bkNGI3v1oS/lw==} - js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} @@ -3369,9 +3317,6 @@ packages: tslib@1.14.1: resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} - tslib@2.7.0: - resolution: {integrity: sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==} - tslib@2.8.1: resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} @@ -3462,9 +3407,6 @@ packages: undefsafe@2.0.5: resolution: {integrity: sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==} - undici-types@6.19.8: - resolution: {integrity: sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==} - undici-types@6.21.0: resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==} @@ -3642,18 +3584,6 @@ packages: wrappy@1.0.2: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} - ws@8.17.1: - resolution: {integrity: sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==} - engines: {node: '>=10.0.0'} - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: '>=5.0.2' - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - ws@8.18.2: resolution: {integrity: sha512-DMricUmwGZUVr++AEAe2uiVM7UoO9MAVZMDu05UQOaUII0lp+zOzLLU4Xqh/JvTqklB1T4uELaaPBKyjE1r4fQ==} engines: {node: '>=10.0.0'} @@ -3688,43 +3618,11 @@ packages: snapshots: - '@0xsequence/abi@2.3.23': {} - - '@0xsequence/core@2.3.23(ethers@6.15.0)': - dependencies: - '@0xsequence/abi': 2.3.23 - '@0xsequence/utils': 2.3.23(ethers@6.15.0) - ethers: 6.15.0 - - '@0xsequence/indexer@2.3.23': {} - - '@0xsequence/network@2.3.23(ethers@6.15.0)': - dependencies: - '@0xsequence/core': 2.3.23(ethers@6.15.0) - '@0xsequence/indexer': 2.3.23 - '@0xsequence/relayer': 2.3.23(ethers@6.15.0) - '@0xsequence/utils': 2.3.23(ethers@6.15.0) - ethers: 6.15.0 - - '@0xsequence/relayer@2.3.23(ethers@6.15.0)': - dependencies: - '@0xsequence/abi': 2.3.23 - '@0xsequence/core': 2.3.23(ethers@6.15.0) - '@0xsequence/utils': 2.3.23(ethers@6.15.0) - ethers: 6.15.0 - '@0xsequence/tee-verifier@0.1.2': dependencies: cbor2: 1.12.0 pkijs: 3.2.5 - '@0xsequence/utils@2.3.23(ethers@6.15.0)': - dependencies: - ethers: 6.15.0 - js-base64: 3.7.7 - - '@adraffy/ens-normalize@1.10.1': {} - '@adraffy/ens-normalize@1.11.0': {} '@ampproject/remapping@2.3.0': @@ -4209,10 +4107,6 @@ snapshots: '@noble/ciphers@1.3.0': {} - '@noble/curves@1.2.0': - dependencies: - '@noble/hashes': 1.3.2 - '@noble/curves@1.9.2': dependencies: '@noble/hashes': 1.8.0 @@ -4221,8 +4115,6 @@ snapshots: dependencies: '@noble/hashes': 1.8.0 - '@noble/hashes@1.3.2': {} - '@noble/hashes@1.8.0': {} '@nodelib/fs.scandir@2.1.5': @@ -4396,10 +4288,6 @@ snapshots: dependencies: undici-types: 6.21.0 - '@types/node@22.7.5': - dependencies: - undici-types: 6.19.8 - '@types/prop-types@15.7.15': {} '@types/react-dom@18.3.0': @@ -4600,8 +4488,6 @@ snapshots: acorn@8.15.0: {} - aes-js@4.0.0-beta.5: {} - agent-base@7.1.4: {} aggregate-error@3.1.0: @@ -5306,19 +5192,6 @@ snapshots: esutils@2.0.3: {} - ethers@6.15.0: - dependencies: - '@adraffy/ens-normalize': 1.10.1 - '@noble/curves': 1.2.0 - '@noble/hashes': 1.3.2 - '@types/node': 22.7.5 - aes-js: 4.0.0-beta.5 - tslib: 2.7.0 - ws: 8.17.1 - transitivePeerDependencies: - - bufferutil - - utf-8-validate - eventemitter3@5.0.1: {} execa@5.1.1: @@ -5890,8 +5763,6 @@ snapshots: dependencies: '@isaacs/cliui': 8.0.2 - js-base64@3.7.7: {} - js-tokens@4.0.0: {} js-tokens@9.0.1: {} @@ -6932,8 +6803,6 @@ snapshots: tslib@1.14.1: {} - tslib@2.7.0: {} - tslib@2.8.1: {} turbo-darwin-64@2.5.5: @@ -7029,8 +6898,6 @@ snapshots: undefsafe@2.0.5: {} - undici-types@6.19.8: {} - undici-types@6.21.0: {} universalify@0.1.2: {} @@ -7234,8 +7101,6 @@ snapshots: wrappy@1.0.2: {} - ws@8.17.1: {} - ws@8.18.2: {} y18n@5.0.8: {}