UNPKG

@particle-network/wallet

Version:

A wallet component that can be easily injected into the developer's website to provide rich custom styles.

138 lines (137 loc) 4.25 kB
import type { PublicKey, Transaction, VersionedTransaction } from '@solana/web3.js'; import type { CurrencyUnit } from './currency'; import type { Theme } from './theme'; export declare const IframeWalletMessageType = "particle-auth-core-iframe-wallet-message"; export declare const walletIframeId = "particle-auth-core-iframe-wallet"; export declare const walletIframeMask = "particle-auth-core-iframe-wallet-mask"; export type ERC4337Options = { name: string; version: string; }; export declare enum EntryPosition { /** * Bottom right */ BR = "bottom-right", /** * Bottom left */ BL = "bottom-left", /** * Top right */ TR = "top-right", /** * Top left */ TL = "top-left", /** * Middle Center */ MC = "middle-center" } export interface ModeStyle { colorAccent?: string; colorPrimary?: string; colorOnPrimary?: string; primaryButtonBackgroundColors?: [string, string]; primaryIconButtonBackgroundColors?: [string, string]; primaryIconTextColor?: string; primaryButtonTextColor?: string; cancelButtonBackgroundColor?: string; backgroundColors?: [string, [[string, string], [string, string]]]; messageColors?: string[]; borderGlowColors?: string[]; modalMaskBackgroundColor?: string; cardBorderRadius?: number; } export type SupportChain = { id: number; name?: string; chainType?: 'evm' | 'solana'; }; export interface WalletCustomStyle { supportChains?: SupportChain[]; supportAddToken?: boolean; displayTokenAddresses?: string[]; displayNFTContractAddresses?: string[]; priorityTokenAddresses?: string[]; priorityNFTContractAddresses?: string[]; fiatCoin?: CurrencyUnit; evmSupportWalletConnect?: boolean; supportUIModeSwitch?: boolean; supportLanguageSwitch?: boolean; light?: ModeStyle; dark?: ModeStyle; } export interface WalletOption { themeType?: Theme; language?: string; erc4337?: ERC4337Options; topMenuType?: 'close' | 'fullscreen'; customStyle?: WalletCustomStyle; widgetIntegration?: 'embedded' | 'modal'; walletUrl?: string; entryPosition?: EntryPosition; visible?: boolean; preload?: boolean; } export interface WalletConfig { topMenuType?: 'close' | 'fullscreen'; pathName?: string; query?: { [key: string]: unknown; }; } export interface ProjectConfig { projectId: string; clientKey: string; appId: string; } export interface WalletCore { ethereum?: EthereumProvider; solana?: SolanaWallet; customEventHandler?: CustomEventHandler; } export interface EthereumProvider { request(payload: { method: string; params?: unknown[]; chainId?: number; }): Promise<any>; on(event: string, listener: (...args: any[]) => void): this; removeListener?(event: string, listener: (...args: any[]) => void): this; } export interface SolanaWallet { chainId: number; selectedAddress?: string | null | undefined; publicKey?: PublicKey | null | undefined; on?(event: string, listener: (...args: any[]) => void): this; removeListener?(event: string, listener: (...args: any[]) => void): this; connect(): Promise<void>; signTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<T>; signAllTransactions<T extends Transaction | VersionedTransaction>(transactions: T[]): Promise<T[]>; signAndSendTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<{ signature: string; }>; signMessage(message: Uint8Array): Promise<{ signature: Uint8Array; }>; switchChain?: (chainId: number) => Promise<void>; } export declare enum MessageType { EthereumRpc = "ethereum-rpc", EthereumEvent = "ethereum-event", SolanaRpc = "solana-rpc", SolanaEvent = "solana-event" } export type CustomMessageType = 'open-account-and-security' | 'get-user-info' | 'get-passkey-option'; export interface MessageResponse<T> { id: string; messageType: MessageType; data: T; } export type CustomEventHandler = { (messageType: CustomMessageType, data?: unknown): Promise<any>; type?: string; };