import { SignTypedDataOptions, CompressedBlockDetail, ThorClient, TypedDataDomain as TypedDataDomain$1, TypedDataParameter as TypedDataParameter$1, VeChainAbstractSigner, AvailableVeChainProviders, TransactionRequestInput, SignTransactionOptions } from '@vechain/sdk-network'; import { CertificateData } from '@vechain/sdk-core'; import { SignClient } from '@walletconnect/sign-client'; import { SignClientTypes } from '@walletconnect/types'; import { TypedDataDomain as TypedDataDomain$2 } from 'viem'; interface TransactionMessage { to: string | null; value: string | number; data?: string; comment?: string; abi?: object; } interface TransactionOptions { signer?: string | null; gas?: number; dependsOn?: string; link?: string; comment?: string; delegator?: { url: string; signer?: string; }; onAccepted?: () => void; } interface TransactionResponse { txid: string; signer: string; } interface CertificateMessage { purpose: 'identification' | 'agreement'; payload: { type: 'text'; content: string; }; } interface CertificateOptions { signer?: string; link?: string; onAccepted?: () => void; } interface CertificateResponse { annex: { domain: string; timestamp: number; signer: string; }; signature: string; } declare global { interface Window { vechain?: { newConnexSigner: (genesisId: string) => WalletSigner; isInAppBrowser?: boolean; } & WalletProvider; connex?: { vendor: { sign: (type: string) => any; }; }; } } type WalletSource = 'wallet-connect' | 'veworld' | 'sync' | 'sync2'; type TypedDataDomain = { chainId?: number | bigint | string | undefined; name?: string | undefined; salt?: `0x${string}` | undefined; verifyingContract?: string | undefined; version?: string | undefined; }; type TypedDataParameter = { name: string; type: string; }; interface WalletConfig { requiresCertificate: boolean; } type Genesis = 'main' | 'test' | CompressedBlockDetail; type TypedDataMessage = { domain: TypedDataDomain; types: Record; value: Record; }; /** * Simple Certificate Args */ type CertificateArgs = { message: CertificateMessage; options?: CertificateOptions; }; /** * Callback used by the DAppKit `connect` function */ type ConnectCallback = ( _certificate?: CertificateArgs, ) => Promise; type ConnectV2Response< TValue extends null | CertificateMessage | TypedDataMessage, > = TValue extends null ? { signer: string; accounts?: string[] } : TValue extends { purpose: string } ? CertificateResponse & { accounts?: string[] } : { signer: string; signature: string; accounts?: string[] }; /** * Callback used by the DAppKit `newConnect` function */ type ConnectV2Callback$1 = < TValue extends null | CertificateMessage | TypedDataMessage, >( value: TValue, /** * Indicate that the dApp uses an external authentication service. * Keep me logged in toggle will be disabled when this option is set to true */ external?: boolean, ) => Promise>; interface WalletSigner { signTx: ( msg: TransactionMessage[], options: TransactionOptions, ) => Promise; signCert: ( msg: CertificateMessage, options: CertificateOptions, ) => Promise; signTypedData?: ( domain: TypedDataDomain, types: Record, message: Record, options?: SignTypedDataOptions, ) => Promise; } interface WalletProvider { send?(args: { method: 'thor_connect'; params: { value: TypedDataMessage | CertificateMessage | null; external?: boolean; }; genesisId: string; }): Promise< | (CertificateResponse & { accounts?: string[] }) | { signer: string; signature: string; accounts?: string[] } | { signer: string; accounts?: string[] } >; send?(args: { method: 'thor_wallet'; params?: undefined; genesisId: string; }): Promise; send?(args: { method: 'thor_disconnect'; params?: undefined; genesisId: string; }): Promise; send?(args: { method: 'wallet_revokeAccountPermission'; params: [{ eth_accounts: { addresses: string[] } }]; genesisId: string; }): Promise; send?(args: { method: 'wallet_requestPermissions'; params?: unknown; genesisId: string; }): Promise; send?(args: { method: 'thor_switchWallet'; params?: undefined; genesisId: string; }): Promise; send?(args: { method: 'thor_methods'; params?: undefined; genesisId: string; }): Promise; send?(args: { method: 'thor_signTypedData'; params: { domain: TypedDataDomain; types: Record; value: Record; options?: SignTypedDataOptions; }; genesisId: string; }): Promise; send?(args: { method: 'thor_signCertificate'; params: { message: CertificateMessage; options: CertificateOptions; }; genesisId: string; }): Promise; send?(args: { method: 'thor_sendTransaction'; params: { clauses: TransactionMessage; options?: TransactionOptions; }; genesisId: string; }): Promise; } /** * Modifies the WalletSigner interface to include a disconnect method */ type VeChainWallet = WalletSigner & { connect: ConnectCallback; disconnect?: () => void | Promise; getAddress: () => string | null | Promise; getAvailableMethods: () => string[] | null | Promise; connectV2: ConnectV2Callback$1; switchWallet: () => string | null | Promise; /** * Ask the wallet to (re-)display the account approval picker. Returns * the new approved address set. Only implemented by VeWorld in v2 mode. */ requestPermissions?: () => Promise; revokeAccount?: (address: string) => Promise; }; interface ConnectResponse { account: string; verified: boolean; connectionCertificate?: CertificateData; } interface WalletManagerState { source: WalletSource | null; address: string | null; /** * Full set of addresses the user has approved for this dApp in the * connected wallet (currently only populated by VeWorld v2). The first * entry is the active `address` when present. Empty array if not known. */ addresses: string[]; accountDomain: string | null; accountDomains: Record; isAccountDomainLoading: boolean; availableSources: WalletSource[]; connectionCertificate: CertificateData | null; availableMethods: string[] | null; } type ResolvedSignClient = Awaited>; /** * WCSigner is a {@link WalletSigner} with an additional disconnect method * */ type WCSigner = WalletSigner & { /** * Disconnects and cleans up the WalletConnect session */ disconnect: () => Promise; /** * Connects to the Wallet and return the account address */ connect: () => Promise; /** * * @returns The current selected address */ getAddress: () => string | null | Promise; /** * * @returns null. Always */ getAvailableMethods: () => string[] | null | Promise; /** * @throws Error. This method is not implemented for WC */ connectV2: ConnectV2Callback; /** * @throws Error. This method is not implemented for WC */ switchWallet: () => string | null | Promise; }; interface WCClient { /** * Gets the initialized WalletConnect SignClient */ get: () => Promise; } /** * WCModal is a modal that can be used to display a WalletConnect QR code/ URI * @param openModal - A function to open the modal * @param closeModal - A function to close the modal * @param subscribeModal - A function to subscribe to modal state changes */ interface WCModal { openModal: (options: OpenOptions) => Promise; closeModal: () => void; subscribeModal: ( callback: (newState: SubscribeModalState) => void, ) => () => void; askForConnectionCertificate?: () => void; onConnectionCertificateSigned?: () => void; /** * Called after a successful WalletConnect connection that did NOT * require signing a connection certificate. Should close both the * QR view and the surrounding wallet modal. */ onConnected?: () => void; } /** * Options for the createWcClient function * @param projectId - Your WalletConnect project ID * @param relayUrl - The URL of your WalletConnect relay server * @param metadata - The metadata of your WalletConnect dApp * @param logger - The logger or log level to use * @param modal - {@link WCModal} can be used to provide a custom modal */ interface WalletConnectOptions { projectId: string; metadata: SignClientTypes.Options['metadata']; modal?: WCModal; } /** * Options for the {@link WCModal} * @param open - Whether the modal is open */ interface SubscribeModalState { open: boolean; } /** * Options for opening the {@link WCModal} * @param uri - The WalletConnect URI to display / open */ interface OpenOptions { uri: string; } /** * Options for the {@link WCSigner} * @param wcClient - See {@link WCClient} * @param web3Modal - See {@link WCModal} * @param onDisconnected - (optional) A callback that will be called when the session is disconnected * @param genesisId - The genesis ID of the VeChain network you want to connect to */ interface WCSignerOptions { wcClient: WCClient; web3Modal: WCModal; onDisconnected: () => void; genesisId: string; } /** * Options for the DAppKit class */ interface DAppKitOptions { /** * The URL of the Node, or the {@link HttpClient} instance */ node: string | HttpClient; /** * Options for the WalletConnect integration */ walletConnectOptions?: WalletConnectOptions; /** * Whether to persist the wallet source/ account * @default false */ usePersistence?: boolean; /** * Whether to use the first detected wallet source. * @default false */ useFirstDetectedSource?: boolean; /** * The log level to use for the DAppKitUI logger * @default LogLevel.NONE */ logLevel?: LogLevel; /** * Whether to require a connection certificate * @default true */ requireCertificate?: boolean; /** * Options for the connection certificate */ connectionCertificate?: CertificateArgs; /** * An array of wallet sources to allow */ allowedWallets?: WalletSource[]; /** * V2 APIs */ v2Api?: DAppKitV2ApiOptions; } type DAppKitV2ApiOptions = { /** * Whether to support the new methods. * @default true */ enabled?: boolean; /** * Whether the dapp uses external authentication * @default false */ external?: boolean; }; type NormalizedDAppKitOptions = Omit & { v2Api: DAppKitV2ApiOptions & { enabled: boolean }; }; declare class WalletManager { private readonly options; private readonly thor; state: WalletManagerState; private wallets; constructor(options: NormalizedDAppKitOptions, thor: ThorClient); private getWallet; private withWallet; get availableMethods(): string[]; /** * Set the account domain */ setAccountDomain: (address: string | null) => void; /** * Set the address */ setAddress: (address: string | null) => void; /** * Set the full set of approved addresses. The first entry is treated as * the primary (active) signer when populated by v2 `thor_connect`. */ setAddresses: (addresses: string[]) => void; private resolveAccountDomains; /** * Switch the active address to one already present in `state.addresses` * WITHOUT reopening the wallet picker (cf. `switchWallet`). Throws if the * given address has not been approved by the user in this session. */ setActiveAccount: (address: string) => void; /** * Set the address and check for the vechain domain, if present set it as well */ setAddressAndDomain: (address: string | null) => void; private recoverTypedDataSigner; private getTypedDataOptions; /** * Sign a connection certificate * this is needed for wallet connect connections when a connection certificate is required */ signConnectionCertificate: (_certificate?: CertificateArgs) => Promise; connect: (_certificate?: CertificateArgs) => Promise; connectV2: (value: TValue) => Promise>; /** * Ask the wallet to (re-)display its account approval picker so the * user can approve additional accounts without first disconnecting. * Uses EIP-2255 `wallet_requestPermissions` when the connected wallet * advertises it (VeWorld v2). Updates `state.addresses` (and * `state.address` if it was unset) with the new approved set. */ requestPermissions: () => Promise; revokeAccount: (address: string) => Promise; switchWallet: () => Promise; disconnect: (remote?: boolean) => void; /** * Best-effort silent re-fetch of the approved accounts list after a sign * operation on the VeWorld desktop extension. When the user authorizes * additional accounts via the extension's permission prompt at sign * time, the wallet returns only the signer in the sign response — * `state.addresses` stays stale unless we round-trip through * `thor_connect`, which on the v2 EIP-1193 adapter resolves to * `eth_requestAccounts` (EIP-1102, silent when already authorized). * * Restricted to the desktop extension (detected via * `window.vechain.request`) because veworld-mobile's in-app browser * exposes a Connex-style `send` channel where `thor_connect` with * `value: null` is interpreted as a fresh connect intent and re-opens * the account picker. * * Failures are non-fatal: the sign result is already returned to the * caller and any error here is logged only. */ private refreshApprovedAccounts; signTx: (msg: TransactionMessage[], options?: TransactionOptions) => Promise; signCert: (msg: CertificateMessage, options?: CertificateOptions) => Promise; signTypedData: (domain: TypedDataDomain$1, types: Record, message: Record, options?: SignTypedDataOptions) => Promise; setSource: (src: WalletSource) => void; subscribe: (listener: (state: WalletManagerState) => void) => (() => void); subscribeToKey: (key: T, listener: (value: WalletManagerState[T]) => void) => (() => void); private initializeStateSync; initializeStateAsync: () => Promise; private initFromPersistentStore; private initPersistence; private getAvailableSources; private getFirstDetectedSource; private setFirstDetectedSource; getAddress: () => Promise; populateAvailableMethods: () => Promise; } /** * A `VechainWallet` for wallet's that use a certificate connection */ declare class CertificateBasedWallet implements VeChainWallet { private readonly wallet; private readonly walletProvider; private readonly genesisId; private readonly certificateData; constructor(wallet: WalletSigner, walletProvider: WalletProvider | null, genesisId: string, connectionCertificateData?: CertificateArgs); switchWallet: () => Promise; /** * EIP-2255 style: ask the wallet to (re-)display its account approval * picker so the user can grant access to additional accounts without * first revoking the existing ones. Returns the full approved address * list. Throws if the underlying provider doesn't expose `send`. */ requestPermissions: () => Promise; revokeAccount: (address: string) => Promise; connectV2: (value: TValue, external?: boolean) => Promise>; getAvailableMethods: () => Promise; getAddress: () => Promise; connect: (_certificate?: CertificateArgs) => Promise; signCert: (msg: CertificateMessage, options: CertificateOptions) => Promise; signTx: (msg: TransactionMessage[], options: TransactionOptions) => Promise; signTypedData: (domain: TypedDataDomain$1, types: Record, message: Record, options?: SignTypedDataOptions) => Promise; disconnect: () => Promise; } declare class VeChainSignerDAppKit extends VeChainAbstractSigner { private readonly walletManager; constructor(walletManager: WalletManager, provider: AvailableVeChainProviders); get address(): string | null; connect(provider: AvailableVeChainProviders): this; getAddress(): Promise; signTransaction(transactionToSign: TransactionRequestInput): Promise; sendTransaction(transactionToSend: TransactionRequestInput): Promise; signMessage(_message: string | Uint8Array): Promise; signTypedData(domain: TypedDataDomain$1, types: Record, message: Record, unused?: string, options?: SignTypedDataOptions): Promise; signPayload(): Promise; _signFlow(transaction: TransactionRequestInput, delegator: SignTransactionOptions | null): Promise; } declare class DAppKit { readonly thor: ThorClient; readonly wallet: WalletManager; readonly signer: VeChainSignerDAppKit; readonly options: NormalizedDAppKitOptions; constructor(options: DAppKitOptions); initialize(): Promise; } declare const DEFAULT_CONNECT_CERT_MESSAGE: CertificateMessage; type NetworkType = 'main' | 'test'; declare const genesisBlocks: Record; /** * The VNS resolver addresses and ABI */ declare const VNS_RESOLVER: { readonly main: "0xA11413086e163e41901bb81fdc5617c975Fa5a1A"; readonly test: "0xc403b8EA53F707d7d4de095f0A20bC491Cf2bc94"; readonly abi: readonly [{ readonly inputs: readonly [{ readonly internalType: "string[]"; readonly name: "names"; readonly type: "string[]"; }]; readonly name: "getAddresses"; readonly outputs: readonly [{ readonly internalType: "address[]"; readonly name: "addresses"; readonly type: "address[]"; }]; readonly stateMutability: "view"; readonly type: "function"; }, { readonly inputs: readonly [{ readonly internalType: "address[]"; readonly name: "addresses"; readonly type: "address[]"; }]; readonly name: "getNames"; readonly outputs: readonly [{ readonly internalType: "string[]"; readonly name: "names"; readonly type: "string[]"; }]; readonly stateMutability: "view"; readonly type: "function"; }, { readonly inputs: readonly [{ readonly internalType: "string[]"; readonly name: "names"; readonly type: "string[]"; }]; readonly name: "getNamehashes"; readonly outputs: readonly [{ readonly internalType: "bytes32[]"; readonly name: "nodes"; readonly type: "bytes32[]"; }]; readonly stateMutability: "pure"; readonly type: "function"; }]; }; /** * Wallet types */ declare const WalletMapping: Record; declare const WalletSources: WalletSource[]; /** * The methods supported by the WalletConnect integration * @param RequestTransaction - Request the wallet to send a transaction * @param SignCertificate - Request the wallet to sign a certificate */ declare enum DefaultMethods { RequestTransaction = "thor_sendTransaction", SignCertificate = "thor_signCertificate", SignTypedData = "thor_signTypedData" } type ICreateWallet = DAppKitOptions & { source: WalletSource; onDisconnected: () => void; thor: ThorClient; }; declare const createWallet: ({ source, thor, walletConnectOptions, onDisconnected, connectionCertificate, v2Api, }: ICreateWallet) => Promise; /** * Create a new wallet connect sign client. Clients are cached by project id. * @param projectId - wallet connect dApp project id * @param metadata - dApp metadata */ declare const createWcClient: ({ projectId, metadata, }: WalletConnectOptions) => WCClient; /** * Creates a new WalletConnectModal instance * @param projectId - Your WalletConnect project ID */ declare const createWcModal: (projectId: string) => WCModal; /** * Creates a new WalletConnect signer * @param options - The signer options. See {@link WCSignerOptions} * @returns A new {@link WCSigner} */ declare const createWcSigner: ({ genesisId, wcClient, web3Modal, onDisconnected, }: WCSignerOptions) => WCSigner; declare const normalizeGenesisId: (genesis?: Genesis) => string; declare const normalizeGenesisBlock: (genesis?: Genesis) => CompressedBlockDetail; declare const Storage: { setAccount: (account: string | null) => void; setAccounts: (accounts: string[]) => void; setSource: (source: WalletSource | null) => void; setConnectionCertificate: (certificate: CertificateData | null) => void; setAccountDomain: (domain: string | null) => void; getAccountDomain: () => string | null; getAccount: () => string | null; getAccounts: () => string[]; getSource: () => WalletSource | null; getConnectionCertificate: () => CertificateData | null; wipeV1: () => void; }; declare const LogLevel$1: { NONE: number; ERROR: number; WARN: number; INFO: number; DEBUG: number; }; type LogLevel$1 = keyof typeof LogLevel$1; declare const DAppKitLogger: { configure(level: LogLevel$1): void; debug(domain: string, context: string, ...args: unknown[]): void; info(domain: string, context: string, ...args: unknown[]): void; warn(domain: string, context: string, ...args: unknown[]): void; error(domain: string, context: string, ...args: unknown[]): void; }; /** * Get the domain of an account */ declare const getAccountDomain: ({ address, thor, }: { address: string | null; thor: ThorClient; }) => Promise; declare const getAccountDomains: ({ addresses, thor, }: { addresses: string[]; thor: ThorClient; }) => Promise>; /** * If a domain name is longer than 18 characters, it shortens it to 10 leading characters and 7 trailing characters. * @param domain - The domain name to shorten. * @returns The shortened domain name. */ declare const shortenedDomain: (domain: string, leadingChars?: number, trailingChars?: number) => string; /** * * @param types Available types * @returns The primary type */ declare const getPrimaryType: (types: TypedDataMessage["types"]) => string; declare const parseChainId: (chainId: TypedDataMessage["domain"]["chainId"]) => TypedDataDomain$2["chainId"]; declare const stringifyChainId: (chainId: TypedDataMessage["domain"]["chainId"]) => string | undefined; export { type CertificateArgs, CertificateBasedWallet, type CertificateMessage, type CertificateOptions, type CertificateResponse, type ConnectCallback, type ConnectResponse, type ConnectV2Callback$1 as ConnectV2Callback, type ConnectV2Response, DAppKit, DAppKitLogger, type DAppKitOptions, type DAppKitV2ApiOptions, DEFAULT_CONNECT_CERT_MESSAGE, DefaultMethods, type Genesis, LogLevel$1 as LogLevel, type NormalizedDAppKitOptions, type OpenOptions, type ResolvedSignClient, Storage, type SubscribeModalState, type TransactionMessage, type TransactionOptions, type TransactionResponse, type TypedDataMessage, VNS_RESOLVER, VeChainSignerDAppKit, type VeChainWallet, type WCClient, type WCModal, type WCSigner, type WCSignerOptions, type WalletConfig, type WalletConnectOptions, WalletManager, type WalletManagerState, WalletMapping, type WalletProvider, type WalletSigner, type WalletSource, WalletSources, createWallet, createWcClient, createWcModal, createWcSigner, genesisBlocks, getAccountDomain, getAccountDomains, getPrimaryType, normalizeGenesisBlock, normalizeGenesisId, parseChainId, shortenedDomain, stringifyChainId };