UNPKG

@reown/appkit-controllers

Version:

The full stack toolkit to build onchain app UX.

64 lines 2.19 kB
import { vi } from 'vitest'; import { ChainController } from '../exports/index.js'; export const extendedMainnet = { id: 1, caipNetworkId: 'eip155:1', chainNamespace: 'eip155', name: 'Ethereum Mainnet', nativeCurrency: { decimals: 18, name: 'Ether', symbol: 'ETH' }, rpcUrls: { default: { http: [], webSocket: undefined } } }; export const solanaCaipNetwork = { id: '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp', caipNetworkId: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp', name: 'Solana', chainNamespace: 'solana', nativeCurrency: { name: 'Solana', symbol: 'SOL', decimals: 9 }, rpcUrls: { default: { http: [] } }, blockExplorers: { default: { name: 'Solscan', url: 'https://solscan.io' } } }; export function mockChainControllerState(state) { // @ts-expect-error - we need to mock the state vi.spyOn(ChainController, 'state', 'get').mockReturnValue({ ...ChainController.state, ...state }); } export function updateChainsMap(namespace, state) { const currentState = ChainController.state.chains.get(namespace); // @ts-expect-error - we need to mock the state ChainController.state.chains.set(namespace, { ...currentState, ...state }); } export function mockAccountState(state) { vi.spyOn(ChainController, 'getAccountData').mockReturnValue({ ...ChainController.getAccountData(), ...state }); } export function mockSession(replaces = { data: {}, message: '', signature: '' }) { return { data: { domain: 'example.com', accountAddress: '0xb3F068DCc2f92ED42E0417d4f2C2191f743fBfdA', statement: 'This is a statement', chainId: 'eip155:1', uri: 'siwx://example.com', version: '1', nonce: '123', ...replaces.data }, message: replaces.message || 'Hello AppKit!', signature: replaces.signature || '0x3c70e0a2d87f677dc0c3faf98fdf6313e99a3d9191bb79f7ecfce0c2cf46b7b33fd4c4bb83bca82fe872e35963382027d0d18018342d7dc36a675918cb73e9061c' }; } //# sourceMappingURL=testing.js.map