@d13co/use-wallet 4.5.3 → 4.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +637 -660
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +145 -108
- package/dist/index.d.ts +145 -108
- package/dist/index.js +637 -656
- package/dist/index.js.map +1 -1
- package/package.json +6 -7
package/dist/index.d.cts
CHANGED
|
@@ -4,11 +4,9 @@ import AVMWebProviderSDK from '@agoralabs-sh/avm-web-provider';
|
|
|
4
4
|
import { InstanceWithExtensions, SDKBase } from '@magic-sdk/provider';
|
|
5
5
|
import { AlgorandExtension } from '@magic-ext/algorand';
|
|
6
6
|
import { MagicUserMetadata } from 'magic-sdk';
|
|
7
|
-
import * as liquid_accounts_evm from 'liquid-accounts-evm';
|
|
8
|
-
import { LiquidEvmSdk, SignTypedDataParams } from 'liquid-accounts-evm';
|
|
9
7
|
import { AlgorandClient } from '@algorandfoundation/algokit-utils';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
8
|
+
import { LiquidEvmSdk, SignTypedDataParams } from 'liquid-accounts-evm';
|
|
9
|
+
import { Config } from '@wagmi/core';
|
|
12
10
|
import { WalletConnectModalConfig } from '@walletconnect/modal';
|
|
13
11
|
import { SignClientTypes } from '@walletconnect/types';
|
|
14
12
|
|
|
@@ -106,6 +104,11 @@ declare abstract class BaseWallet {
|
|
|
106
104
|
get isConnected(): boolean;
|
|
107
105
|
get isActive(): boolean;
|
|
108
106
|
get activeNetworkConfig(): NetworkConfig;
|
|
107
|
+
/**
|
|
108
|
+
* Dynamically update wallet metadata (e.g., after learning the actual
|
|
109
|
+
* connector name/icon during connect).
|
|
110
|
+
*/
|
|
111
|
+
protected updateMetadata(updates: Partial<WalletMetadata>): void;
|
|
109
112
|
protected onDisconnect: () => void;
|
|
110
113
|
protected manageWalletConnectSession: (action: "backup" | "restore", targetWalletKey?: WalletKey) => void;
|
|
111
114
|
}
|
|
@@ -413,6 +416,59 @@ declare class MagicAuth extends BaseWallet {
|
|
|
413
416
|
signTransactions: <T extends algosdk.Transaction[] | Uint8Array[]>(txnGroup: T | T[], indexesToSign?: number[]) => Promise<(Uint8Array | null)[]>;
|
|
414
417
|
}
|
|
415
418
|
|
|
419
|
+
interface MnemonicConstructor {
|
|
420
|
+
persistToStorage?: boolean;
|
|
421
|
+
promptForMnemonic: () => Promise<string | null>;
|
|
422
|
+
}
|
|
423
|
+
type MnemonicOptions = Partial<Pick<MnemonicConstructor, 'promptForMnemonic'>> & Omit<MnemonicConstructor, 'promptForMnemonic'>;
|
|
424
|
+
declare const LOCAL_STORAGE_MNEMONIC_KEY = "@txnlab/use-wallet:v4_mnemonic";
|
|
425
|
+
declare class MnemonicWallet extends BaseWallet {
|
|
426
|
+
private account;
|
|
427
|
+
private options;
|
|
428
|
+
protected store: Store<State>;
|
|
429
|
+
constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.MNEMONIC>);
|
|
430
|
+
static defaultMetadata: {
|
|
431
|
+
name: string;
|
|
432
|
+
icon: string;
|
|
433
|
+
};
|
|
434
|
+
private loadMnemonicFromStorage;
|
|
435
|
+
private saveMnemonicToStorage;
|
|
436
|
+
private removeMnemonicFromStorage;
|
|
437
|
+
private checkMainnet;
|
|
438
|
+
private initializeAccount;
|
|
439
|
+
connect: () => Promise<WalletAccount[]>;
|
|
440
|
+
disconnect: () => Promise<void>;
|
|
441
|
+
resumeSession: () => Promise<void>;
|
|
442
|
+
private processTxns;
|
|
443
|
+
private processEncodedTxns;
|
|
444
|
+
signTransactions: <T extends algosdk.Transaction[] | Uint8Array[]>(txnGroup: T | T[], indexesToSign?: number[]) => Promise<(Uint8Array | null)[]>;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
interface PeraWalletConnectOptions {
|
|
448
|
+
bridge?: string;
|
|
449
|
+
shouldShowSignTxnToast?: boolean;
|
|
450
|
+
chainId?: 416001 | 416002 | 416003 | 4160;
|
|
451
|
+
compactMode?: boolean;
|
|
452
|
+
}
|
|
453
|
+
declare class PeraWallet extends BaseWallet {
|
|
454
|
+
private client;
|
|
455
|
+
private options;
|
|
456
|
+
protected store: Store<State>;
|
|
457
|
+
constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.PERA>);
|
|
458
|
+
static defaultMetadata: {
|
|
459
|
+
name: string;
|
|
460
|
+
icon: string;
|
|
461
|
+
};
|
|
462
|
+
private initializeClient;
|
|
463
|
+
connect: () => Promise<WalletAccount[]>;
|
|
464
|
+
disconnect: () => Promise<void>;
|
|
465
|
+
setActive: () => void;
|
|
466
|
+
resumeSession: () => Promise<void>;
|
|
467
|
+
private processTxns;
|
|
468
|
+
private processEncodedTxns;
|
|
469
|
+
signTransactions: <T extends algosdk.Transaction[] | Uint8Array[]>(txnGroup: T | T[], indexesToSign?: number[]) => Promise<(Uint8Array | null)[]>;
|
|
470
|
+
}
|
|
471
|
+
|
|
416
472
|
interface EvmAccount {
|
|
417
473
|
evmAddress: string;
|
|
418
474
|
algorandAddress: string;
|
|
@@ -483,13 +539,14 @@ declare abstract class LiquidEvmBaseWallet extends BaseWallet {
|
|
|
483
539
|
*/
|
|
484
540
|
protected initializeEvmSdk(): Promise<LiquidEvmSdk>;
|
|
485
541
|
/**
|
|
486
|
-
* Derive Algorand accounts from EVM addresses
|
|
542
|
+
* Derive Algorand accounts from EVM addresses.
|
|
543
|
+
* @param evmAddresses - EVM addresses to derive Algorand accounts from
|
|
544
|
+
* @param connectorInfo - Optional connector name/icon to include in account metadata
|
|
487
545
|
*/
|
|
488
|
-
protected deriveAlgorandAccounts(evmAddresses: string[]
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
protected bytesToHex(bytes: Uint8Array): string;
|
|
546
|
+
protected deriveAlgorandAccounts(evmAddresses: string[], connectorInfo?: {
|
|
547
|
+
name?: string;
|
|
548
|
+
icon?: string;
|
|
549
|
+
}): Promise<WalletAccount[]>;
|
|
493
550
|
/**
|
|
494
551
|
* Process transaction group to extract transactions that need signing
|
|
495
552
|
*/
|
|
@@ -505,107 +562,90 @@ declare abstract class LiquidEvmBaseWallet extends BaseWallet {
|
|
|
505
562
|
/**
|
|
506
563
|
* Helper to compare and update accounts if needed during session resume
|
|
507
564
|
*/
|
|
508
|
-
protected resumeWithAccounts(evmAddresses: string[], setAccountsFn: (accounts: WalletAccount[]) => void
|
|
509
|
-
protected notifyConnect(evmAddress: string, algorandAddress: string): void;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
interface MetaMaskWalletOptions extends LiquidEvmOptions {
|
|
513
|
-
dappMetadata?: {
|
|
565
|
+
protected resumeWithAccounts(evmAddresses: string[], setAccountsFn: (accounts: WalletAccount[]) => void, connectorInfo?: {
|
|
514
566
|
name?: string;
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
}
|
|
519
|
-
declare class MetaMaskWallet extends LiquidEvmBaseWallet {
|
|
520
|
-
private metamaskSdk;
|
|
521
|
-
private provider;
|
|
522
|
-
protected options: MetaMaskWalletOptions;
|
|
523
|
-
constructor(params: WalletConstructor<WalletId.METAMASK>);
|
|
524
|
-
static defaultMetadata: {
|
|
525
|
-
name: string;
|
|
526
|
-
icon: string;
|
|
527
|
-
isLiquid: "EVM";
|
|
528
|
-
};
|
|
529
|
-
protected initializeProvider(): Promise<void>;
|
|
530
|
-
getEvmProvider(): Promise<SDKProvider>;
|
|
531
|
-
protected signWithProvider(typedData: liquid_accounts_evm.SignTypedDataParams, evmAddress: string): Promise<string>;
|
|
532
|
-
connect: () => Promise<WalletAccount[]>;
|
|
533
|
-
disconnect: () => Promise<void>;
|
|
534
|
-
resumeSession: () => Promise<void>;
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
interface MnemonicConstructor {
|
|
538
|
-
persistToStorage?: boolean;
|
|
539
|
-
promptForMnemonic: () => Promise<string | null>;
|
|
540
|
-
}
|
|
541
|
-
type MnemonicOptions = Partial<Pick<MnemonicConstructor, 'promptForMnemonic'>> & Omit<MnemonicConstructor, 'promptForMnemonic'>;
|
|
542
|
-
declare const LOCAL_STORAGE_MNEMONIC_KEY = "@txnlab/use-wallet:v4_mnemonic";
|
|
543
|
-
declare class MnemonicWallet extends BaseWallet {
|
|
544
|
-
private account;
|
|
545
|
-
private options;
|
|
546
|
-
protected store: Store<State>;
|
|
547
|
-
constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.MNEMONIC>);
|
|
548
|
-
static defaultMetadata: {
|
|
549
|
-
name: string;
|
|
550
|
-
icon: string;
|
|
551
|
-
};
|
|
552
|
-
private loadMnemonicFromStorage;
|
|
553
|
-
private saveMnemonicToStorage;
|
|
554
|
-
private removeMnemonicFromStorage;
|
|
555
|
-
private checkMainnet;
|
|
556
|
-
private initializeAccount;
|
|
557
|
-
connect: () => Promise<WalletAccount[]>;
|
|
558
|
-
disconnect: () => Promise<void>;
|
|
559
|
-
resumeSession: () => Promise<void>;
|
|
560
|
-
private processTxns;
|
|
561
|
-
private processEncodedTxns;
|
|
562
|
-
signTransactions: <T extends algosdk.Transaction[] | Uint8Array[]>(txnGroup: T | T[], indexesToSign?: number[]) => Promise<(Uint8Array | null)[]>;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
interface PeraWalletConnectOptions {
|
|
566
|
-
bridge?: string;
|
|
567
|
-
shouldShowSignTxnToast?: boolean;
|
|
568
|
-
chainId?: 416001 | 416002 | 416003 | 4160;
|
|
569
|
-
compactMode?: boolean;
|
|
570
|
-
}
|
|
571
|
-
declare class PeraWallet extends BaseWallet {
|
|
572
|
-
private client;
|
|
573
|
-
private options;
|
|
574
|
-
protected store: Store<State>;
|
|
575
|
-
constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.PERA>);
|
|
576
|
-
static defaultMetadata: {
|
|
577
|
-
name: string;
|
|
578
|
-
icon: string;
|
|
579
|
-
};
|
|
580
|
-
private initializeClient;
|
|
581
|
-
connect: () => Promise<WalletAccount[]>;
|
|
582
|
-
disconnect: () => Promise<void>;
|
|
583
|
-
setActive: () => void;
|
|
584
|
-
resumeSession: () => Promise<void>;
|
|
585
|
-
private processTxns;
|
|
586
|
-
private processEncodedTxns;
|
|
587
|
-
signTransactions: <T extends algosdk.Transaction[] | Uint8Array[]>(txnGroup: T | T[], indexesToSign?: number[]) => Promise<(Uint8Array | null)[]>;
|
|
567
|
+
icon?: string;
|
|
568
|
+
}): Promise<void>;
|
|
569
|
+
protected notifyConnect(evmAddress: string, algorandAddress: string): void;
|
|
588
570
|
}
|
|
589
571
|
|
|
590
|
-
interface
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
572
|
+
interface RainbowKitWalletOptions extends LiquidEvmOptions {
|
|
573
|
+
/** wagmi Config instance, typically created with RainbowKit's getDefaultConfig() */
|
|
574
|
+
wagmiConfig: Config;
|
|
575
|
+
/**
|
|
576
|
+
* Optional callback to connect an EVM wallet when none is connected.
|
|
577
|
+
* The app can use this to open RainbowKit's connect modal.
|
|
578
|
+
* Should resolve once the wallet is connected (wagmi state will be read after).
|
|
579
|
+
*/
|
|
580
|
+
getEvmAccounts?: () => Promise<string[]>;
|
|
596
581
|
}
|
|
597
|
-
declare class
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
constructor(params: WalletConstructor<WalletId.
|
|
582
|
+
declare class RainbowKitWallet extends LiquidEvmBaseWallet {
|
|
583
|
+
protected options: RainbowKitWalletOptions;
|
|
584
|
+
private _connecting;
|
|
585
|
+
constructor(params: WalletConstructor<WalletId.RAINBOWKIT>);
|
|
601
586
|
static defaultMetadata: {
|
|
602
587
|
name: string;
|
|
603
588
|
icon: string;
|
|
604
589
|
isLiquid: "EVM";
|
|
605
590
|
};
|
|
591
|
+
/** True while connect() is running. Prevents re-entrancy from bridge components. */
|
|
592
|
+
get isConnecting(): boolean;
|
|
593
|
+
/**
|
|
594
|
+
* Set the getEvmAccounts callback after construction.
|
|
595
|
+
*
|
|
596
|
+
* RainbowKit's connect modal can only be opened via React hooks (useConnectModal)
|
|
597
|
+
* rendered inside <RainbowKitProvider>, but WalletManager is constructed before
|
|
598
|
+
* any React tree renders. This method lets WalletUIProvider create the bridge
|
|
599
|
+
* callback internally and inject it into the wallet on mount — before any
|
|
600
|
+
* user-initiated connect() call.
|
|
601
|
+
*/
|
|
602
|
+
setGetEvmAccounts(fn: () => Promise<string[]>): void;
|
|
603
|
+
private get wagmiConfig();
|
|
604
|
+
/**
|
|
605
|
+
* If the Algorand chain (4160) isn't already in the wagmi config, add it.
|
|
606
|
+
* This is needed so wagmi's switchChain and signTypedData work without
|
|
607
|
+
* falling back to raw provider calls.
|
|
608
|
+
*/
|
|
609
|
+
private ensureChainRegistered;
|
|
606
610
|
protected initializeProvider(): Promise<void>;
|
|
607
|
-
|
|
608
|
-
|
|
611
|
+
/**
|
|
612
|
+
* Get the raw EIP-1193 provider from the active wagmi connector.
|
|
613
|
+
* Used by the base class's getEvmProvider and ensureAlgorandChain.
|
|
614
|
+
*/
|
|
615
|
+
private getRawProvider;
|
|
616
|
+
getEvmProvider(): Promise<any>;
|
|
617
|
+
/**
|
|
618
|
+
* Sign EIP-712 typed data using wagmi's signTypedData.
|
|
619
|
+
*
|
|
620
|
+
* wagmi's signTypedData does NOT validate the domain's chainId against the
|
|
621
|
+
* connected chain — it simply forwards the typed data to the wallet via viem.
|
|
622
|
+
* EIP-712 signing is chain-agnostic (the chain ID is in the typed data domain,
|
|
623
|
+
* not in the RPC method), so this works regardless of which chain the wallet
|
|
624
|
+
* reports being on.
|
|
625
|
+
*/
|
|
626
|
+
protected signWithProvider(typedData: SignTypedDataParams, evmAddress: string): Promise<string>;
|
|
627
|
+
/**
|
|
628
|
+
* Build a connectorInfo object from a wagmi account, omitting undefined fields.
|
|
629
|
+
* Uses `any` for the parameter to avoid exactOptionalPropertyTypes conflicts
|
|
630
|
+
* with wagmi's discriminated union return types.
|
|
631
|
+
*/
|
|
632
|
+
private static extractConnectorInfo;
|
|
633
|
+
/**
|
|
634
|
+
* Read connected EVM accounts from wagmi state.
|
|
635
|
+
* If not connected, tries the getEvmAccounts callback, then falls back to
|
|
636
|
+
* connecting with the first available connector.
|
|
637
|
+
*
|
|
638
|
+
* When getEvmAccounts is provided, it is always called (to show the wallet
|
|
639
|
+
* selection UI). The callback is responsible for any disconnect/reconnect
|
|
640
|
+
* needed to present a fresh selection.
|
|
641
|
+
*/
|
|
642
|
+
private getConnectedEvmAddresses;
|
|
643
|
+
/**
|
|
644
|
+
* Apply connector info to wallet-level metadata so the UI displays
|
|
645
|
+
* the actual wallet name/icon (e.g., "MetaMask") instead of the generic
|
|
646
|
+
* "EVM Wallet". Falls back to defaults when connector info is unavailable.
|
|
647
|
+
*/
|
|
648
|
+
private applyConnectorMetadata;
|
|
609
649
|
connect: () => Promise<WalletAccount[]>;
|
|
610
650
|
disconnect: () => Promise<void>;
|
|
611
651
|
resumeSession: () => Promise<void>;
|
|
@@ -955,10 +995,9 @@ declare enum WalletId {
|
|
|
955
995
|
KMD = "kmd",
|
|
956
996
|
LUTE = "lute",
|
|
957
997
|
MAGIC = "magic",
|
|
958
|
-
METAMASK = "metamask",
|
|
959
998
|
MNEMONIC = "mnemonic",
|
|
960
999
|
PERA = "pera",
|
|
961
|
-
|
|
1000
|
+
RAINBOWKIT = "rainbowkit",
|
|
962
1001
|
WALLETCONNECT = "walletconnect",
|
|
963
1002
|
WEB3AUTH = "web3auth",
|
|
964
1003
|
W3_WALLET = "w3-wallet"
|
|
@@ -997,10 +1036,9 @@ type WalletMap = {
|
|
|
997
1036
|
[WalletId.KMD]: typeof KmdWallet;
|
|
998
1037
|
[WalletId.LUTE]: typeof LuteWallet;
|
|
999
1038
|
[WalletId.MAGIC]: typeof MagicAuth;
|
|
1000
|
-
[WalletId.METAMASK]: typeof MetaMaskWallet;
|
|
1001
1039
|
[WalletId.MNEMONIC]: typeof MnemonicWallet;
|
|
1002
1040
|
[WalletId.PERA]: typeof PeraWallet;
|
|
1003
|
-
[WalletId.
|
|
1041
|
+
[WalletId.RAINBOWKIT]: typeof RainbowKitWallet;
|
|
1004
1042
|
[WalletId.WALLETCONNECT]: typeof WalletConnect;
|
|
1005
1043
|
[WalletId.WEB3AUTH]: typeof Web3AuthWallet;
|
|
1006
1044
|
[WalletId.W3_WALLET]: typeof W3Wallet;
|
|
@@ -1015,10 +1053,9 @@ type WalletOptionsMap = {
|
|
|
1015
1053
|
[WalletId.KMD]: KmdOptions;
|
|
1016
1054
|
[WalletId.LUTE]: LuteConnectOptions;
|
|
1017
1055
|
[WalletId.MAGIC]: MagicAuthOptions;
|
|
1018
|
-
[WalletId.METAMASK]: MetaMaskWalletOptions;
|
|
1019
1056
|
[WalletId.MNEMONIC]: MnemonicOptions;
|
|
1020
1057
|
[WalletId.PERA]: PeraWalletConnectOptions;
|
|
1021
|
-
[WalletId.
|
|
1058
|
+
[WalletId.RAINBOWKIT]: RainbowKitWalletOptions;
|
|
1022
1059
|
[WalletId.WALLETCONNECT]: WalletConnectOptions;
|
|
1023
1060
|
[WalletId.WEB3AUTH]: Web3AuthOptions;
|
|
1024
1061
|
[WalletId.W3_WALLET]: Record<string, never>;
|
|
@@ -1409,4 +1446,4 @@ declare function getSkin(skinId: string): WalletConnectSkin | undefined;
|
|
|
1409
1446
|
*/
|
|
1410
1447
|
declare function resolveSkin(skinOption: WalletConnectSkinOption): WalletConnectSkin | undefined;
|
|
1411
1448
|
|
|
1412
|
-
export { type AlgodConfig, BUILTIN_SKINS, BaseWallet, type BaseWalletConstructor, BiatecWallet, type CustomProvider, CustomWallet, type CustomWalletOptions, DEFAULT_NETWORK_CONFIG, DEFAULT_STATE, DEFLY_WEB_PROVIDER_ID, DeflyWallet, type DeflyWalletConnectOptions, DeflyWebWallet, type EnableResult, type Exodus, type ExodusOptions, ExodusWallet, ICON, type JsonRpcRequest, KIBISIS_AVM_WEB_PROVIDER_ID, KibisisWallet, type KmdOptions, KmdWallet, LOCAL_STORAGE_MNEMONIC_KEY, LiquidEvmBaseWallet, type LiquidEvmMetadata, type LiquidEvmOptions, LogLevel, type LuteConnectOptions, LuteWallet, MagicAuth, type MagicAuthClient, type MagicAuthOptions, type ManagerStatus,
|
|
1449
|
+
export { type AlgodConfig, BUILTIN_SKINS, BaseWallet, type BaseWalletConstructor, BiatecWallet, type CustomProvider, CustomWallet, type CustomWalletOptions, DEFAULT_NETWORK_CONFIG, DEFAULT_STATE, DEFLY_WEB_PROVIDER_ID, DeflyWallet, type DeflyWalletConnectOptions, DeflyWebWallet, type EnableResult, type Exodus, type ExodusOptions, ExodusWallet, ICON, type JsonRpcRequest, KIBISIS_AVM_WEB_PROVIDER_ID, KibisisWallet, type KmdOptions, KmdWallet, LOCAL_STORAGE_MNEMONIC_KEY, LiquidEvmBaseWallet, type LiquidEvmMetadata, type LiquidEvmOptions, LogLevel, type LuteConnectOptions, LuteWallet, MagicAuth, type MagicAuthClient, type MagicAuthOptions, type ManagerStatus, type MnemonicOptions, MnemonicWallet, type MultisigMetadata, type NetworkConfig, NetworkConfigBuilder, NetworkId, PeraWallet, type PeraWalletConnectOptions, RainbowKitWallet, type RainbowKitWalletOptions, ScopeType, SecureKeyContainer, SessionError, type SignData, SignDataError, type SignDataResponse, type SignMetadata, SignTxnsError, type SignTxnsResponse, type SignTxnsResult, type SignerTransaction, type Siwa, type State, StorageAdapter, type SupportedWallet, type SupportedWallets, type UIHooks, W3Wallet, type W3WalletProvider, type WalletAccount, type WalletConfig, type WalletConfigMap, WalletConnect, type WalletConnectOptions, type WalletConnectSkin, type WalletConnectSkinOption, type WalletConstructor, WalletId, type WalletIdConfig, type WalletKey, WalletManager, type WalletManagerConfig, type WalletManagerOptions, type WalletMap, type WalletMetadata, type WalletOptions, type WalletOptionsMap, type WalletState, type WalletTransaction, type Web3AuthCredentials, type Web3AuthCustomAuth, type Web3AuthOptions, Web3AuthWallet, type WindowExtended, getSkin, registerSkin, resolveSkin, webpackFallback, withSecureKey, withSecureKeySync, zeroMemory, zeroString };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,11 +4,9 @@ import AVMWebProviderSDK from '@agoralabs-sh/avm-web-provider';
|
|
|
4
4
|
import { InstanceWithExtensions, SDKBase } from '@magic-sdk/provider';
|
|
5
5
|
import { AlgorandExtension } from '@magic-ext/algorand';
|
|
6
6
|
import { MagicUserMetadata } from 'magic-sdk';
|
|
7
|
-
import * as liquid_accounts_evm from 'liquid-accounts-evm';
|
|
8
|
-
import { LiquidEvmSdk, SignTypedDataParams } from 'liquid-accounts-evm';
|
|
9
7
|
import { AlgorandClient } from '@algorandfoundation/algokit-utils';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
8
|
+
import { LiquidEvmSdk, SignTypedDataParams } from 'liquid-accounts-evm';
|
|
9
|
+
import { Config } from '@wagmi/core';
|
|
12
10
|
import { WalletConnectModalConfig } from '@walletconnect/modal';
|
|
13
11
|
import { SignClientTypes } from '@walletconnect/types';
|
|
14
12
|
|
|
@@ -106,6 +104,11 @@ declare abstract class BaseWallet {
|
|
|
106
104
|
get isConnected(): boolean;
|
|
107
105
|
get isActive(): boolean;
|
|
108
106
|
get activeNetworkConfig(): NetworkConfig;
|
|
107
|
+
/**
|
|
108
|
+
* Dynamically update wallet metadata (e.g., after learning the actual
|
|
109
|
+
* connector name/icon during connect).
|
|
110
|
+
*/
|
|
111
|
+
protected updateMetadata(updates: Partial<WalletMetadata>): void;
|
|
109
112
|
protected onDisconnect: () => void;
|
|
110
113
|
protected manageWalletConnectSession: (action: "backup" | "restore", targetWalletKey?: WalletKey) => void;
|
|
111
114
|
}
|
|
@@ -413,6 +416,59 @@ declare class MagicAuth extends BaseWallet {
|
|
|
413
416
|
signTransactions: <T extends algosdk.Transaction[] | Uint8Array[]>(txnGroup: T | T[], indexesToSign?: number[]) => Promise<(Uint8Array | null)[]>;
|
|
414
417
|
}
|
|
415
418
|
|
|
419
|
+
interface MnemonicConstructor {
|
|
420
|
+
persistToStorage?: boolean;
|
|
421
|
+
promptForMnemonic: () => Promise<string | null>;
|
|
422
|
+
}
|
|
423
|
+
type MnemonicOptions = Partial<Pick<MnemonicConstructor, 'promptForMnemonic'>> & Omit<MnemonicConstructor, 'promptForMnemonic'>;
|
|
424
|
+
declare const LOCAL_STORAGE_MNEMONIC_KEY = "@txnlab/use-wallet:v4_mnemonic";
|
|
425
|
+
declare class MnemonicWallet extends BaseWallet {
|
|
426
|
+
private account;
|
|
427
|
+
private options;
|
|
428
|
+
protected store: Store<State>;
|
|
429
|
+
constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.MNEMONIC>);
|
|
430
|
+
static defaultMetadata: {
|
|
431
|
+
name: string;
|
|
432
|
+
icon: string;
|
|
433
|
+
};
|
|
434
|
+
private loadMnemonicFromStorage;
|
|
435
|
+
private saveMnemonicToStorage;
|
|
436
|
+
private removeMnemonicFromStorage;
|
|
437
|
+
private checkMainnet;
|
|
438
|
+
private initializeAccount;
|
|
439
|
+
connect: () => Promise<WalletAccount[]>;
|
|
440
|
+
disconnect: () => Promise<void>;
|
|
441
|
+
resumeSession: () => Promise<void>;
|
|
442
|
+
private processTxns;
|
|
443
|
+
private processEncodedTxns;
|
|
444
|
+
signTransactions: <T extends algosdk.Transaction[] | Uint8Array[]>(txnGroup: T | T[], indexesToSign?: number[]) => Promise<(Uint8Array | null)[]>;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
interface PeraWalletConnectOptions {
|
|
448
|
+
bridge?: string;
|
|
449
|
+
shouldShowSignTxnToast?: boolean;
|
|
450
|
+
chainId?: 416001 | 416002 | 416003 | 4160;
|
|
451
|
+
compactMode?: boolean;
|
|
452
|
+
}
|
|
453
|
+
declare class PeraWallet extends BaseWallet {
|
|
454
|
+
private client;
|
|
455
|
+
private options;
|
|
456
|
+
protected store: Store<State>;
|
|
457
|
+
constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.PERA>);
|
|
458
|
+
static defaultMetadata: {
|
|
459
|
+
name: string;
|
|
460
|
+
icon: string;
|
|
461
|
+
};
|
|
462
|
+
private initializeClient;
|
|
463
|
+
connect: () => Promise<WalletAccount[]>;
|
|
464
|
+
disconnect: () => Promise<void>;
|
|
465
|
+
setActive: () => void;
|
|
466
|
+
resumeSession: () => Promise<void>;
|
|
467
|
+
private processTxns;
|
|
468
|
+
private processEncodedTxns;
|
|
469
|
+
signTransactions: <T extends algosdk.Transaction[] | Uint8Array[]>(txnGroup: T | T[], indexesToSign?: number[]) => Promise<(Uint8Array | null)[]>;
|
|
470
|
+
}
|
|
471
|
+
|
|
416
472
|
interface EvmAccount {
|
|
417
473
|
evmAddress: string;
|
|
418
474
|
algorandAddress: string;
|
|
@@ -483,13 +539,14 @@ declare abstract class LiquidEvmBaseWallet extends BaseWallet {
|
|
|
483
539
|
*/
|
|
484
540
|
protected initializeEvmSdk(): Promise<LiquidEvmSdk>;
|
|
485
541
|
/**
|
|
486
|
-
* Derive Algorand accounts from EVM addresses
|
|
542
|
+
* Derive Algorand accounts from EVM addresses.
|
|
543
|
+
* @param evmAddresses - EVM addresses to derive Algorand accounts from
|
|
544
|
+
* @param connectorInfo - Optional connector name/icon to include in account metadata
|
|
487
545
|
*/
|
|
488
|
-
protected deriveAlgorandAccounts(evmAddresses: string[]
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
protected bytesToHex(bytes: Uint8Array): string;
|
|
546
|
+
protected deriveAlgorandAccounts(evmAddresses: string[], connectorInfo?: {
|
|
547
|
+
name?: string;
|
|
548
|
+
icon?: string;
|
|
549
|
+
}): Promise<WalletAccount[]>;
|
|
493
550
|
/**
|
|
494
551
|
* Process transaction group to extract transactions that need signing
|
|
495
552
|
*/
|
|
@@ -505,107 +562,90 @@ declare abstract class LiquidEvmBaseWallet extends BaseWallet {
|
|
|
505
562
|
/**
|
|
506
563
|
* Helper to compare and update accounts if needed during session resume
|
|
507
564
|
*/
|
|
508
|
-
protected resumeWithAccounts(evmAddresses: string[], setAccountsFn: (accounts: WalletAccount[]) => void
|
|
509
|
-
protected notifyConnect(evmAddress: string, algorandAddress: string): void;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
interface MetaMaskWalletOptions extends LiquidEvmOptions {
|
|
513
|
-
dappMetadata?: {
|
|
565
|
+
protected resumeWithAccounts(evmAddresses: string[], setAccountsFn: (accounts: WalletAccount[]) => void, connectorInfo?: {
|
|
514
566
|
name?: string;
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
}
|
|
519
|
-
declare class MetaMaskWallet extends LiquidEvmBaseWallet {
|
|
520
|
-
private metamaskSdk;
|
|
521
|
-
private provider;
|
|
522
|
-
protected options: MetaMaskWalletOptions;
|
|
523
|
-
constructor(params: WalletConstructor<WalletId.METAMASK>);
|
|
524
|
-
static defaultMetadata: {
|
|
525
|
-
name: string;
|
|
526
|
-
icon: string;
|
|
527
|
-
isLiquid: "EVM";
|
|
528
|
-
};
|
|
529
|
-
protected initializeProvider(): Promise<void>;
|
|
530
|
-
getEvmProvider(): Promise<SDKProvider>;
|
|
531
|
-
protected signWithProvider(typedData: liquid_accounts_evm.SignTypedDataParams, evmAddress: string): Promise<string>;
|
|
532
|
-
connect: () => Promise<WalletAccount[]>;
|
|
533
|
-
disconnect: () => Promise<void>;
|
|
534
|
-
resumeSession: () => Promise<void>;
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
interface MnemonicConstructor {
|
|
538
|
-
persistToStorage?: boolean;
|
|
539
|
-
promptForMnemonic: () => Promise<string | null>;
|
|
540
|
-
}
|
|
541
|
-
type MnemonicOptions = Partial<Pick<MnemonicConstructor, 'promptForMnemonic'>> & Omit<MnemonicConstructor, 'promptForMnemonic'>;
|
|
542
|
-
declare const LOCAL_STORAGE_MNEMONIC_KEY = "@txnlab/use-wallet:v4_mnemonic";
|
|
543
|
-
declare class MnemonicWallet extends BaseWallet {
|
|
544
|
-
private account;
|
|
545
|
-
private options;
|
|
546
|
-
protected store: Store<State>;
|
|
547
|
-
constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.MNEMONIC>);
|
|
548
|
-
static defaultMetadata: {
|
|
549
|
-
name: string;
|
|
550
|
-
icon: string;
|
|
551
|
-
};
|
|
552
|
-
private loadMnemonicFromStorage;
|
|
553
|
-
private saveMnemonicToStorage;
|
|
554
|
-
private removeMnemonicFromStorage;
|
|
555
|
-
private checkMainnet;
|
|
556
|
-
private initializeAccount;
|
|
557
|
-
connect: () => Promise<WalletAccount[]>;
|
|
558
|
-
disconnect: () => Promise<void>;
|
|
559
|
-
resumeSession: () => Promise<void>;
|
|
560
|
-
private processTxns;
|
|
561
|
-
private processEncodedTxns;
|
|
562
|
-
signTransactions: <T extends algosdk.Transaction[] | Uint8Array[]>(txnGroup: T | T[], indexesToSign?: number[]) => Promise<(Uint8Array | null)[]>;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
interface PeraWalletConnectOptions {
|
|
566
|
-
bridge?: string;
|
|
567
|
-
shouldShowSignTxnToast?: boolean;
|
|
568
|
-
chainId?: 416001 | 416002 | 416003 | 4160;
|
|
569
|
-
compactMode?: boolean;
|
|
570
|
-
}
|
|
571
|
-
declare class PeraWallet extends BaseWallet {
|
|
572
|
-
private client;
|
|
573
|
-
private options;
|
|
574
|
-
protected store: Store<State>;
|
|
575
|
-
constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.PERA>);
|
|
576
|
-
static defaultMetadata: {
|
|
577
|
-
name: string;
|
|
578
|
-
icon: string;
|
|
579
|
-
};
|
|
580
|
-
private initializeClient;
|
|
581
|
-
connect: () => Promise<WalletAccount[]>;
|
|
582
|
-
disconnect: () => Promise<void>;
|
|
583
|
-
setActive: () => void;
|
|
584
|
-
resumeSession: () => Promise<void>;
|
|
585
|
-
private processTxns;
|
|
586
|
-
private processEncodedTxns;
|
|
587
|
-
signTransactions: <T extends algosdk.Transaction[] | Uint8Array[]>(txnGroup: T | T[], indexesToSign?: number[]) => Promise<(Uint8Array | null)[]>;
|
|
567
|
+
icon?: string;
|
|
568
|
+
}): Promise<void>;
|
|
569
|
+
protected notifyConnect(evmAddress: string, algorandAddress: string): void;
|
|
588
570
|
}
|
|
589
571
|
|
|
590
|
-
interface
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
572
|
+
interface RainbowKitWalletOptions extends LiquidEvmOptions {
|
|
573
|
+
/** wagmi Config instance, typically created with RainbowKit's getDefaultConfig() */
|
|
574
|
+
wagmiConfig: Config;
|
|
575
|
+
/**
|
|
576
|
+
* Optional callback to connect an EVM wallet when none is connected.
|
|
577
|
+
* The app can use this to open RainbowKit's connect modal.
|
|
578
|
+
* Should resolve once the wallet is connected (wagmi state will be read after).
|
|
579
|
+
*/
|
|
580
|
+
getEvmAccounts?: () => Promise<string[]>;
|
|
596
581
|
}
|
|
597
|
-
declare class
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
constructor(params: WalletConstructor<WalletId.
|
|
582
|
+
declare class RainbowKitWallet extends LiquidEvmBaseWallet {
|
|
583
|
+
protected options: RainbowKitWalletOptions;
|
|
584
|
+
private _connecting;
|
|
585
|
+
constructor(params: WalletConstructor<WalletId.RAINBOWKIT>);
|
|
601
586
|
static defaultMetadata: {
|
|
602
587
|
name: string;
|
|
603
588
|
icon: string;
|
|
604
589
|
isLiquid: "EVM";
|
|
605
590
|
};
|
|
591
|
+
/** True while connect() is running. Prevents re-entrancy from bridge components. */
|
|
592
|
+
get isConnecting(): boolean;
|
|
593
|
+
/**
|
|
594
|
+
* Set the getEvmAccounts callback after construction.
|
|
595
|
+
*
|
|
596
|
+
* RainbowKit's connect modal can only be opened via React hooks (useConnectModal)
|
|
597
|
+
* rendered inside <RainbowKitProvider>, but WalletManager is constructed before
|
|
598
|
+
* any React tree renders. This method lets WalletUIProvider create the bridge
|
|
599
|
+
* callback internally and inject it into the wallet on mount — before any
|
|
600
|
+
* user-initiated connect() call.
|
|
601
|
+
*/
|
|
602
|
+
setGetEvmAccounts(fn: () => Promise<string[]>): void;
|
|
603
|
+
private get wagmiConfig();
|
|
604
|
+
/**
|
|
605
|
+
* If the Algorand chain (4160) isn't already in the wagmi config, add it.
|
|
606
|
+
* This is needed so wagmi's switchChain and signTypedData work without
|
|
607
|
+
* falling back to raw provider calls.
|
|
608
|
+
*/
|
|
609
|
+
private ensureChainRegistered;
|
|
606
610
|
protected initializeProvider(): Promise<void>;
|
|
607
|
-
|
|
608
|
-
|
|
611
|
+
/**
|
|
612
|
+
* Get the raw EIP-1193 provider from the active wagmi connector.
|
|
613
|
+
* Used by the base class's getEvmProvider and ensureAlgorandChain.
|
|
614
|
+
*/
|
|
615
|
+
private getRawProvider;
|
|
616
|
+
getEvmProvider(): Promise<any>;
|
|
617
|
+
/**
|
|
618
|
+
* Sign EIP-712 typed data using wagmi's signTypedData.
|
|
619
|
+
*
|
|
620
|
+
* wagmi's signTypedData does NOT validate the domain's chainId against the
|
|
621
|
+
* connected chain — it simply forwards the typed data to the wallet via viem.
|
|
622
|
+
* EIP-712 signing is chain-agnostic (the chain ID is in the typed data domain,
|
|
623
|
+
* not in the RPC method), so this works regardless of which chain the wallet
|
|
624
|
+
* reports being on.
|
|
625
|
+
*/
|
|
626
|
+
protected signWithProvider(typedData: SignTypedDataParams, evmAddress: string): Promise<string>;
|
|
627
|
+
/**
|
|
628
|
+
* Build a connectorInfo object from a wagmi account, omitting undefined fields.
|
|
629
|
+
* Uses `any` for the parameter to avoid exactOptionalPropertyTypes conflicts
|
|
630
|
+
* with wagmi's discriminated union return types.
|
|
631
|
+
*/
|
|
632
|
+
private static extractConnectorInfo;
|
|
633
|
+
/**
|
|
634
|
+
* Read connected EVM accounts from wagmi state.
|
|
635
|
+
* If not connected, tries the getEvmAccounts callback, then falls back to
|
|
636
|
+
* connecting with the first available connector.
|
|
637
|
+
*
|
|
638
|
+
* When getEvmAccounts is provided, it is always called (to show the wallet
|
|
639
|
+
* selection UI). The callback is responsible for any disconnect/reconnect
|
|
640
|
+
* needed to present a fresh selection.
|
|
641
|
+
*/
|
|
642
|
+
private getConnectedEvmAddresses;
|
|
643
|
+
/**
|
|
644
|
+
* Apply connector info to wallet-level metadata so the UI displays
|
|
645
|
+
* the actual wallet name/icon (e.g., "MetaMask") instead of the generic
|
|
646
|
+
* "EVM Wallet". Falls back to defaults when connector info is unavailable.
|
|
647
|
+
*/
|
|
648
|
+
private applyConnectorMetadata;
|
|
609
649
|
connect: () => Promise<WalletAccount[]>;
|
|
610
650
|
disconnect: () => Promise<void>;
|
|
611
651
|
resumeSession: () => Promise<void>;
|
|
@@ -955,10 +995,9 @@ declare enum WalletId {
|
|
|
955
995
|
KMD = "kmd",
|
|
956
996
|
LUTE = "lute",
|
|
957
997
|
MAGIC = "magic",
|
|
958
|
-
METAMASK = "metamask",
|
|
959
998
|
MNEMONIC = "mnemonic",
|
|
960
999
|
PERA = "pera",
|
|
961
|
-
|
|
1000
|
+
RAINBOWKIT = "rainbowkit",
|
|
962
1001
|
WALLETCONNECT = "walletconnect",
|
|
963
1002
|
WEB3AUTH = "web3auth",
|
|
964
1003
|
W3_WALLET = "w3-wallet"
|
|
@@ -997,10 +1036,9 @@ type WalletMap = {
|
|
|
997
1036
|
[WalletId.KMD]: typeof KmdWallet;
|
|
998
1037
|
[WalletId.LUTE]: typeof LuteWallet;
|
|
999
1038
|
[WalletId.MAGIC]: typeof MagicAuth;
|
|
1000
|
-
[WalletId.METAMASK]: typeof MetaMaskWallet;
|
|
1001
1039
|
[WalletId.MNEMONIC]: typeof MnemonicWallet;
|
|
1002
1040
|
[WalletId.PERA]: typeof PeraWallet;
|
|
1003
|
-
[WalletId.
|
|
1041
|
+
[WalletId.RAINBOWKIT]: typeof RainbowKitWallet;
|
|
1004
1042
|
[WalletId.WALLETCONNECT]: typeof WalletConnect;
|
|
1005
1043
|
[WalletId.WEB3AUTH]: typeof Web3AuthWallet;
|
|
1006
1044
|
[WalletId.W3_WALLET]: typeof W3Wallet;
|
|
@@ -1015,10 +1053,9 @@ type WalletOptionsMap = {
|
|
|
1015
1053
|
[WalletId.KMD]: KmdOptions;
|
|
1016
1054
|
[WalletId.LUTE]: LuteConnectOptions;
|
|
1017
1055
|
[WalletId.MAGIC]: MagicAuthOptions;
|
|
1018
|
-
[WalletId.METAMASK]: MetaMaskWalletOptions;
|
|
1019
1056
|
[WalletId.MNEMONIC]: MnemonicOptions;
|
|
1020
1057
|
[WalletId.PERA]: PeraWalletConnectOptions;
|
|
1021
|
-
[WalletId.
|
|
1058
|
+
[WalletId.RAINBOWKIT]: RainbowKitWalletOptions;
|
|
1022
1059
|
[WalletId.WALLETCONNECT]: WalletConnectOptions;
|
|
1023
1060
|
[WalletId.WEB3AUTH]: Web3AuthOptions;
|
|
1024
1061
|
[WalletId.W3_WALLET]: Record<string, never>;
|
|
@@ -1409,4 +1446,4 @@ declare function getSkin(skinId: string): WalletConnectSkin | undefined;
|
|
|
1409
1446
|
*/
|
|
1410
1447
|
declare function resolveSkin(skinOption: WalletConnectSkinOption): WalletConnectSkin | undefined;
|
|
1411
1448
|
|
|
1412
|
-
export { type AlgodConfig, BUILTIN_SKINS, BaseWallet, type BaseWalletConstructor, BiatecWallet, type CustomProvider, CustomWallet, type CustomWalletOptions, DEFAULT_NETWORK_CONFIG, DEFAULT_STATE, DEFLY_WEB_PROVIDER_ID, DeflyWallet, type DeflyWalletConnectOptions, DeflyWebWallet, type EnableResult, type Exodus, type ExodusOptions, ExodusWallet, ICON, type JsonRpcRequest, KIBISIS_AVM_WEB_PROVIDER_ID, KibisisWallet, type KmdOptions, KmdWallet, LOCAL_STORAGE_MNEMONIC_KEY, LiquidEvmBaseWallet, type LiquidEvmMetadata, type LiquidEvmOptions, LogLevel, type LuteConnectOptions, LuteWallet, MagicAuth, type MagicAuthClient, type MagicAuthOptions, type ManagerStatus,
|
|
1449
|
+
export { type AlgodConfig, BUILTIN_SKINS, BaseWallet, type BaseWalletConstructor, BiatecWallet, type CustomProvider, CustomWallet, type CustomWalletOptions, DEFAULT_NETWORK_CONFIG, DEFAULT_STATE, DEFLY_WEB_PROVIDER_ID, DeflyWallet, type DeflyWalletConnectOptions, DeflyWebWallet, type EnableResult, type Exodus, type ExodusOptions, ExodusWallet, ICON, type JsonRpcRequest, KIBISIS_AVM_WEB_PROVIDER_ID, KibisisWallet, type KmdOptions, KmdWallet, LOCAL_STORAGE_MNEMONIC_KEY, LiquidEvmBaseWallet, type LiquidEvmMetadata, type LiquidEvmOptions, LogLevel, type LuteConnectOptions, LuteWallet, MagicAuth, type MagicAuthClient, type MagicAuthOptions, type ManagerStatus, type MnemonicOptions, MnemonicWallet, type MultisigMetadata, type NetworkConfig, NetworkConfigBuilder, NetworkId, PeraWallet, type PeraWalletConnectOptions, RainbowKitWallet, type RainbowKitWalletOptions, ScopeType, SecureKeyContainer, SessionError, type SignData, SignDataError, type SignDataResponse, type SignMetadata, SignTxnsError, type SignTxnsResponse, type SignTxnsResult, type SignerTransaction, type Siwa, type State, StorageAdapter, type SupportedWallet, type SupportedWallets, type UIHooks, W3Wallet, type W3WalletProvider, type WalletAccount, type WalletConfig, type WalletConfigMap, WalletConnect, type WalletConnectOptions, type WalletConnectSkin, type WalletConnectSkinOption, type WalletConstructor, WalletId, type WalletIdConfig, type WalletKey, WalletManager, type WalletManagerConfig, type WalletManagerOptions, type WalletMap, type WalletMetadata, type WalletOptions, type WalletOptionsMap, type WalletState, type WalletTransaction, type Web3AuthCredentials, type Web3AuthCustomAuth, type Web3AuthOptions, Web3AuthWallet, type WindowExtended, getSkin, registerSkin, resolveSkin, webpackFallback, withSecureKey, withSecureKeySync, zeroMemory, zeroString };
|