@d13co/use-wallet 4.5.4 → 4.5.6

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.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 { SDKProvider } from '@metamask/sdk';
11
- import { EIP1193Provider } from 'viem';
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,14 +539,18 @@ 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[]): Promise<WalletAccount[]>;
546
+ protected deriveAlgorandAccounts(evmAddresses: string[], connectorInfo?: {
547
+ name?: string;
548
+ icon?: string;
549
+ }): Promise<WalletAccount[]>;
489
550
  /**
490
- * Convert bytes to hex string with 0x prefix
551
+ * Process transaction group to extract transactions that need signing
491
552
  */
492
- protected bytesToHex(bytes: Uint8Array): string;
493
- private processTxns;
553
+ protected processTxns(txnGroup: algosdk.Transaction[], indexesToSign?: number[]): SignerTransaction[];
494
554
  private processEncodedTxns;
495
555
  /**
496
556
  * Sign Algorand transactions using EVM wallet signatures
@@ -499,107 +559,90 @@ declare abstract class LiquidEvmBaseWallet extends BaseWallet {
499
559
  /**
500
560
  * Helper to compare and update accounts if needed during session resume
501
561
  */
502
- protected resumeWithAccounts(evmAddresses: string[], setAccountsFn: (accounts: WalletAccount[]) => void): Promise<void>;
503
- protected notifyConnect(evmAddress: string, algorandAddress: string): void;
504
- }
505
-
506
- interface MetaMaskWalletOptions extends LiquidEvmOptions {
507
- dappMetadata?: {
562
+ protected resumeWithAccounts(evmAddresses: string[], setAccountsFn: (accounts: WalletAccount[]) => void, connectorInfo?: {
508
563
  name?: string;
509
- url?: string;
510
- iconUrl?: string;
511
- };
512
- }
513
- declare class MetaMaskWallet extends LiquidEvmBaseWallet {
514
- private metamaskSdk;
515
- private provider;
516
- protected options: MetaMaskWalletOptions;
517
- constructor(params: WalletConstructor<WalletId.METAMASK>);
518
- static defaultMetadata: {
519
- name: string;
520
- icon: string;
521
- isLiquid: "EVM";
522
- };
523
- protected initializeProvider(): Promise<void>;
524
- getEvmProvider(): Promise<SDKProvider>;
525
- protected signWithProvider(typedData: liquid_accounts_evm.SignTypedDataParams, evmAddress: string): Promise<string>;
526
- connect: () => Promise<WalletAccount[]>;
527
- disconnect: () => Promise<void>;
528
- resumeSession: () => Promise<void>;
529
- }
530
-
531
- interface MnemonicConstructor {
532
- persistToStorage?: boolean;
533
- promptForMnemonic: () => Promise<string | null>;
534
- }
535
- type MnemonicOptions = Partial<Pick<MnemonicConstructor, 'promptForMnemonic'>> & Omit<MnemonicConstructor, 'promptForMnemonic'>;
536
- declare const LOCAL_STORAGE_MNEMONIC_KEY = "@txnlab/use-wallet:v4_mnemonic";
537
- declare class MnemonicWallet extends BaseWallet {
538
- private account;
539
- private options;
540
- protected store: Store<State>;
541
- constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.MNEMONIC>);
542
- static defaultMetadata: {
543
- name: string;
544
- icon: string;
545
- };
546
- private loadMnemonicFromStorage;
547
- private saveMnemonicToStorage;
548
- private removeMnemonicFromStorage;
549
- private checkMainnet;
550
- private initializeAccount;
551
- connect: () => Promise<WalletAccount[]>;
552
- disconnect: () => Promise<void>;
553
- resumeSession: () => Promise<void>;
554
- private processTxns;
555
- private processEncodedTxns;
556
- signTransactions: <T extends algosdk.Transaction[] | Uint8Array[]>(txnGroup: T | T[], indexesToSign?: number[]) => Promise<(Uint8Array | null)[]>;
557
- }
558
-
559
- interface PeraWalletConnectOptions {
560
- bridge?: string;
561
- shouldShowSignTxnToast?: boolean;
562
- chainId?: 416001 | 416002 | 416003 | 4160;
563
- compactMode?: boolean;
564
- }
565
- declare class PeraWallet extends BaseWallet {
566
- private client;
567
- private options;
568
- protected store: Store<State>;
569
- constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.PERA>);
570
- static defaultMetadata: {
571
- name: string;
572
- icon: string;
573
- };
574
- private initializeClient;
575
- connect: () => Promise<WalletAccount[]>;
576
- disconnect: () => Promise<void>;
577
- setActive: () => void;
578
- resumeSession: () => Promise<void>;
579
- private processTxns;
580
- private processEncodedTxns;
581
- signTransactions: <T extends algosdk.Transaction[] | Uint8Array[]>(txnGroup: T | T[], indexesToSign?: number[]) => Promise<(Uint8Array | null)[]>;
564
+ icon?: string;
565
+ }): Promise<void>;
566
+ protected notifyConnect(evmAddress: string, algorandAddress: string): void;
582
567
  }
583
568
 
584
- interface RainbowWalletOptions extends LiquidEvmOptions {
585
- dappMetadata?: {
586
- name?: string;
587
- url?: string;
588
- iconUrl?: string;
589
- };
569
+ interface RainbowKitWalletOptions extends LiquidEvmOptions {
570
+ /** wagmi Config instance, typically created with RainbowKit's getDefaultConfig() */
571
+ wagmiConfig: Config;
572
+ /**
573
+ * Optional callback to connect an EVM wallet when none is connected.
574
+ * The app can use this to open RainbowKit's connect modal.
575
+ * Should resolve once the wallet is connected (wagmi state will be read after).
576
+ */
577
+ getEvmAccounts?: () => Promise<string[]>;
590
578
  }
591
- declare class RainbowWallet extends LiquidEvmBaseWallet {
592
- private provider;
593
- protected options: RainbowWalletOptions;
594
- constructor(params: WalletConstructor<WalletId.RAINBOW>);
579
+ declare class RainbowKitWallet extends LiquidEvmBaseWallet {
580
+ protected options: RainbowKitWalletOptions;
581
+ private _connecting;
582
+ constructor(params: WalletConstructor<WalletId.RAINBOWKIT>);
595
583
  static defaultMetadata: {
596
584
  name: string;
597
585
  icon: string;
598
586
  isLiquid: "EVM";
599
587
  };
588
+ /** True while connect() is running. Prevents re-entrancy from bridge components. */
589
+ get isConnecting(): boolean;
590
+ /**
591
+ * Set the getEvmAccounts callback after construction.
592
+ *
593
+ * RainbowKit's connect modal can only be opened via React hooks (useConnectModal)
594
+ * rendered inside <RainbowKitProvider>, but WalletManager is constructed before
595
+ * any React tree renders. This method lets WalletUIProvider create the bridge
596
+ * callback internally and inject it into the wallet on mount — before any
597
+ * user-initiated connect() call.
598
+ */
599
+ setGetEvmAccounts(fn: () => Promise<string[]>): void;
600
+ private get wagmiConfig();
601
+ /**
602
+ * If the Algorand chain (4160) isn't already in the wagmi config, add it.
603
+ * This is needed so wagmi's switchChain and signTypedData work without
604
+ * falling back to raw provider calls.
605
+ */
606
+ private ensureChainRegistered;
600
607
  protected initializeProvider(): Promise<void>;
601
- getEvmProvider(): Promise<EIP1193Provider>;
602
- protected signWithProvider(typedData: liquid_accounts_evm.SignTypedDataParams, evmAddress: string): Promise<string>;
608
+ /**
609
+ * Get the raw EIP-1193 provider from the active wagmi connector.
610
+ * Used by the base class's getEvmProvider and ensureAlgorandChain.
611
+ */
612
+ private getRawProvider;
613
+ getEvmProvider(): Promise<any>;
614
+ /**
615
+ * Sign EIP-712 typed data using wagmi's signTypedData.
616
+ *
617
+ * wagmi's signTypedData does NOT validate the domain's chainId against the
618
+ * connected chain — it simply forwards the typed data to the wallet via viem.
619
+ * EIP-712 signing is chain-agnostic (the chain ID is in the typed data domain,
620
+ * not in the RPC method), so this works regardless of which chain the wallet
621
+ * reports being on.
622
+ */
623
+ protected signWithProvider(typedData: SignTypedDataParams, evmAddress: string): Promise<string>;
624
+ /**
625
+ * Build a connectorInfo object from a wagmi account, omitting undefined fields.
626
+ * Uses `any` for the parameter to avoid exactOptionalPropertyTypes conflicts
627
+ * with wagmi's discriminated union return types.
628
+ */
629
+ private static extractConnectorInfo;
630
+ /**
631
+ * Read connected EVM accounts from wagmi state.
632
+ * If not connected, tries the getEvmAccounts callback, then falls back to
633
+ * connecting with the first available connector.
634
+ *
635
+ * When getEvmAccounts is provided, it is always called (to show the wallet
636
+ * selection UI). The callback is responsible for any disconnect/reconnect
637
+ * needed to present a fresh selection.
638
+ */
639
+ private getConnectedEvmAddresses;
640
+ /**
641
+ * Apply connector info to wallet-level metadata so the UI displays
642
+ * the actual wallet name/icon (e.g., "MetaMask") instead of the generic
643
+ * "EVM Wallet". Falls back to defaults when connector info is unavailable.
644
+ */
645
+ private applyConnectorMetadata;
603
646
  connect: () => Promise<WalletAccount[]>;
604
647
  disconnect: () => Promise<void>;
605
648
  resumeSession: () => Promise<void>;
@@ -949,10 +992,9 @@ declare enum WalletId {
949
992
  KMD = "kmd",
950
993
  LUTE = "lute",
951
994
  MAGIC = "magic",
952
- METAMASK = "metamask",
953
995
  MNEMONIC = "mnemonic",
954
996
  PERA = "pera",
955
- RAINBOW = "rainbow",
997
+ RAINBOWKIT = "rainbowkit",
956
998
  WALLETCONNECT = "walletconnect",
957
999
  WEB3AUTH = "web3auth",
958
1000
  W3_WALLET = "w3-wallet"
@@ -991,10 +1033,9 @@ type WalletMap = {
991
1033
  [WalletId.KMD]: typeof KmdWallet;
992
1034
  [WalletId.LUTE]: typeof LuteWallet;
993
1035
  [WalletId.MAGIC]: typeof MagicAuth;
994
- [WalletId.METAMASK]: typeof MetaMaskWallet;
995
1036
  [WalletId.MNEMONIC]: typeof MnemonicWallet;
996
1037
  [WalletId.PERA]: typeof PeraWallet;
997
- [WalletId.RAINBOW]: typeof RainbowWallet;
1038
+ [WalletId.RAINBOWKIT]: typeof RainbowKitWallet;
998
1039
  [WalletId.WALLETCONNECT]: typeof WalletConnect;
999
1040
  [WalletId.WEB3AUTH]: typeof Web3AuthWallet;
1000
1041
  [WalletId.W3_WALLET]: typeof W3Wallet;
@@ -1009,10 +1050,9 @@ type WalletOptionsMap = {
1009
1050
  [WalletId.KMD]: KmdOptions;
1010
1051
  [WalletId.LUTE]: LuteConnectOptions;
1011
1052
  [WalletId.MAGIC]: MagicAuthOptions;
1012
- [WalletId.METAMASK]: MetaMaskWalletOptions;
1013
1053
  [WalletId.MNEMONIC]: MnemonicOptions;
1014
1054
  [WalletId.PERA]: PeraWalletConnectOptions;
1015
- [WalletId.RAINBOW]: RainbowWalletOptions;
1055
+ [WalletId.RAINBOWKIT]: RainbowKitWalletOptions;
1016
1056
  [WalletId.WALLETCONNECT]: WalletConnectOptions;
1017
1057
  [WalletId.WEB3AUTH]: Web3AuthOptions;
1018
1058
  [WalletId.W3_WALLET]: Record<string, never>;
@@ -1403,4 +1443,4 @@ declare function getSkin(skinId: string): WalletConnectSkin | undefined;
1403
1443
  */
1404
1444
  declare function resolveSkin(skinOption: WalletConnectSkinOption): WalletConnectSkin | undefined;
1405
1445
 
1406
- 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, MetaMaskWallet, type MetaMaskWalletOptions, type MnemonicOptions, MnemonicWallet, type MultisigMetadata, type NetworkConfig, NetworkConfigBuilder, NetworkId, PeraWallet, type PeraWalletConnectOptions, RainbowWallet, type RainbowWalletOptions, 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 };
1446
+ 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 { SDKProvider } from '@metamask/sdk';
11
- import { EIP1193Provider } from 'viem';
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,14 +539,18 @@ 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[]): Promise<WalletAccount[]>;
546
+ protected deriveAlgorandAccounts(evmAddresses: string[], connectorInfo?: {
547
+ name?: string;
548
+ icon?: string;
549
+ }): Promise<WalletAccount[]>;
489
550
  /**
490
- * Convert bytes to hex string with 0x prefix
551
+ * Process transaction group to extract transactions that need signing
491
552
  */
492
- protected bytesToHex(bytes: Uint8Array): string;
493
- private processTxns;
553
+ protected processTxns(txnGroup: algosdk.Transaction[], indexesToSign?: number[]): SignerTransaction[];
494
554
  private processEncodedTxns;
495
555
  /**
496
556
  * Sign Algorand transactions using EVM wallet signatures
@@ -499,107 +559,90 @@ declare abstract class LiquidEvmBaseWallet extends BaseWallet {
499
559
  /**
500
560
  * Helper to compare and update accounts if needed during session resume
501
561
  */
502
- protected resumeWithAccounts(evmAddresses: string[], setAccountsFn: (accounts: WalletAccount[]) => void): Promise<void>;
503
- protected notifyConnect(evmAddress: string, algorandAddress: string): void;
504
- }
505
-
506
- interface MetaMaskWalletOptions extends LiquidEvmOptions {
507
- dappMetadata?: {
562
+ protected resumeWithAccounts(evmAddresses: string[], setAccountsFn: (accounts: WalletAccount[]) => void, connectorInfo?: {
508
563
  name?: string;
509
- url?: string;
510
- iconUrl?: string;
511
- };
512
- }
513
- declare class MetaMaskWallet extends LiquidEvmBaseWallet {
514
- private metamaskSdk;
515
- private provider;
516
- protected options: MetaMaskWalletOptions;
517
- constructor(params: WalletConstructor<WalletId.METAMASK>);
518
- static defaultMetadata: {
519
- name: string;
520
- icon: string;
521
- isLiquid: "EVM";
522
- };
523
- protected initializeProvider(): Promise<void>;
524
- getEvmProvider(): Promise<SDKProvider>;
525
- protected signWithProvider(typedData: liquid_accounts_evm.SignTypedDataParams, evmAddress: string): Promise<string>;
526
- connect: () => Promise<WalletAccount[]>;
527
- disconnect: () => Promise<void>;
528
- resumeSession: () => Promise<void>;
529
- }
530
-
531
- interface MnemonicConstructor {
532
- persistToStorage?: boolean;
533
- promptForMnemonic: () => Promise<string | null>;
534
- }
535
- type MnemonicOptions = Partial<Pick<MnemonicConstructor, 'promptForMnemonic'>> & Omit<MnemonicConstructor, 'promptForMnemonic'>;
536
- declare const LOCAL_STORAGE_MNEMONIC_KEY = "@txnlab/use-wallet:v4_mnemonic";
537
- declare class MnemonicWallet extends BaseWallet {
538
- private account;
539
- private options;
540
- protected store: Store<State>;
541
- constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.MNEMONIC>);
542
- static defaultMetadata: {
543
- name: string;
544
- icon: string;
545
- };
546
- private loadMnemonicFromStorage;
547
- private saveMnemonicToStorage;
548
- private removeMnemonicFromStorage;
549
- private checkMainnet;
550
- private initializeAccount;
551
- connect: () => Promise<WalletAccount[]>;
552
- disconnect: () => Promise<void>;
553
- resumeSession: () => Promise<void>;
554
- private processTxns;
555
- private processEncodedTxns;
556
- signTransactions: <T extends algosdk.Transaction[] | Uint8Array[]>(txnGroup: T | T[], indexesToSign?: number[]) => Promise<(Uint8Array | null)[]>;
557
- }
558
-
559
- interface PeraWalletConnectOptions {
560
- bridge?: string;
561
- shouldShowSignTxnToast?: boolean;
562
- chainId?: 416001 | 416002 | 416003 | 4160;
563
- compactMode?: boolean;
564
- }
565
- declare class PeraWallet extends BaseWallet {
566
- private client;
567
- private options;
568
- protected store: Store<State>;
569
- constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.PERA>);
570
- static defaultMetadata: {
571
- name: string;
572
- icon: string;
573
- };
574
- private initializeClient;
575
- connect: () => Promise<WalletAccount[]>;
576
- disconnect: () => Promise<void>;
577
- setActive: () => void;
578
- resumeSession: () => Promise<void>;
579
- private processTxns;
580
- private processEncodedTxns;
581
- signTransactions: <T extends algosdk.Transaction[] | Uint8Array[]>(txnGroup: T | T[], indexesToSign?: number[]) => Promise<(Uint8Array | null)[]>;
564
+ icon?: string;
565
+ }): Promise<void>;
566
+ protected notifyConnect(evmAddress: string, algorandAddress: string): void;
582
567
  }
583
568
 
584
- interface RainbowWalletOptions extends LiquidEvmOptions {
585
- dappMetadata?: {
586
- name?: string;
587
- url?: string;
588
- iconUrl?: string;
589
- };
569
+ interface RainbowKitWalletOptions extends LiquidEvmOptions {
570
+ /** wagmi Config instance, typically created with RainbowKit's getDefaultConfig() */
571
+ wagmiConfig: Config;
572
+ /**
573
+ * Optional callback to connect an EVM wallet when none is connected.
574
+ * The app can use this to open RainbowKit's connect modal.
575
+ * Should resolve once the wallet is connected (wagmi state will be read after).
576
+ */
577
+ getEvmAccounts?: () => Promise<string[]>;
590
578
  }
591
- declare class RainbowWallet extends LiquidEvmBaseWallet {
592
- private provider;
593
- protected options: RainbowWalletOptions;
594
- constructor(params: WalletConstructor<WalletId.RAINBOW>);
579
+ declare class RainbowKitWallet extends LiquidEvmBaseWallet {
580
+ protected options: RainbowKitWalletOptions;
581
+ private _connecting;
582
+ constructor(params: WalletConstructor<WalletId.RAINBOWKIT>);
595
583
  static defaultMetadata: {
596
584
  name: string;
597
585
  icon: string;
598
586
  isLiquid: "EVM";
599
587
  };
588
+ /** True while connect() is running. Prevents re-entrancy from bridge components. */
589
+ get isConnecting(): boolean;
590
+ /**
591
+ * Set the getEvmAccounts callback after construction.
592
+ *
593
+ * RainbowKit's connect modal can only be opened via React hooks (useConnectModal)
594
+ * rendered inside <RainbowKitProvider>, but WalletManager is constructed before
595
+ * any React tree renders. This method lets WalletUIProvider create the bridge
596
+ * callback internally and inject it into the wallet on mount — before any
597
+ * user-initiated connect() call.
598
+ */
599
+ setGetEvmAccounts(fn: () => Promise<string[]>): void;
600
+ private get wagmiConfig();
601
+ /**
602
+ * If the Algorand chain (4160) isn't already in the wagmi config, add it.
603
+ * This is needed so wagmi's switchChain and signTypedData work without
604
+ * falling back to raw provider calls.
605
+ */
606
+ private ensureChainRegistered;
600
607
  protected initializeProvider(): Promise<void>;
601
- getEvmProvider(): Promise<EIP1193Provider>;
602
- protected signWithProvider(typedData: liquid_accounts_evm.SignTypedDataParams, evmAddress: string): Promise<string>;
608
+ /**
609
+ * Get the raw EIP-1193 provider from the active wagmi connector.
610
+ * Used by the base class's getEvmProvider and ensureAlgorandChain.
611
+ */
612
+ private getRawProvider;
613
+ getEvmProvider(): Promise<any>;
614
+ /**
615
+ * Sign EIP-712 typed data using wagmi's signTypedData.
616
+ *
617
+ * wagmi's signTypedData does NOT validate the domain's chainId against the
618
+ * connected chain — it simply forwards the typed data to the wallet via viem.
619
+ * EIP-712 signing is chain-agnostic (the chain ID is in the typed data domain,
620
+ * not in the RPC method), so this works regardless of which chain the wallet
621
+ * reports being on.
622
+ */
623
+ protected signWithProvider(typedData: SignTypedDataParams, evmAddress: string): Promise<string>;
624
+ /**
625
+ * Build a connectorInfo object from a wagmi account, omitting undefined fields.
626
+ * Uses `any` for the parameter to avoid exactOptionalPropertyTypes conflicts
627
+ * with wagmi's discriminated union return types.
628
+ */
629
+ private static extractConnectorInfo;
630
+ /**
631
+ * Read connected EVM accounts from wagmi state.
632
+ * If not connected, tries the getEvmAccounts callback, then falls back to
633
+ * connecting with the first available connector.
634
+ *
635
+ * When getEvmAccounts is provided, it is always called (to show the wallet
636
+ * selection UI). The callback is responsible for any disconnect/reconnect
637
+ * needed to present a fresh selection.
638
+ */
639
+ private getConnectedEvmAddresses;
640
+ /**
641
+ * Apply connector info to wallet-level metadata so the UI displays
642
+ * the actual wallet name/icon (e.g., "MetaMask") instead of the generic
643
+ * "EVM Wallet". Falls back to defaults when connector info is unavailable.
644
+ */
645
+ private applyConnectorMetadata;
603
646
  connect: () => Promise<WalletAccount[]>;
604
647
  disconnect: () => Promise<void>;
605
648
  resumeSession: () => Promise<void>;
@@ -949,10 +992,9 @@ declare enum WalletId {
949
992
  KMD = "kmd",
950
993
  LUTE = "lute",
951
994
  MAGIC = "magic",
952
- METAMASK = "metamask",
953
995
  MNEMONIC = "mnemonic",
954
996
  PERA = "pera",
955
- RAINBOW = "rainbow",
997
+ RAINBOWKIT = "rainbowkit",
956
998
  WALLETCONNECT = "walletconnect",
957
999
  WEB3AUTH = "web3auth",
958
1000
  W3_WALLET = "w3-wallet"
@@ -991,10 +1033,9 @@ type WalletMap = {
991
1033
  [WalletId.KMD]: typeof KmdWallet;
992
1034
  [WalletId.LUTE]: typeof LuteWallet;
993
1035
  [WalletId.MAGIC]: typeof MagicAuth;
994
- [WalletId.METAMASK]: typeof MetaMaskWallet;
995
1036
  [WalletId.MNEMONIC]: typeof MnemonicWallet;
996
1037
  [WalletId.PERA]: typeof PeraWallet;
997
- [WalletId.RAINBOW]: typeof RainbowWallet;
1038
+ [WalletId.RAINBOWKIT]: typeof RainbowKitWallet;
998
1039
  [WalletId.WALLETCONNECT]: typeof WalletConnect;
999
1040
  [WalletId.WEB3AUTH]: typeof Web3AuthWallet;
1000
1041
  [WalletId.W3_WALLET]: typeof W3Wallet;
@@ -1009,10 +1050,9 @@ type WalletOptionsMap = {
1009
1050
  [WalletId.KMD]: KmdOptions;
1010
1051
  [WalletId.LUTE]: LuteConnectOptions;
1011
1052
  [WalletId.MAGIC]: MagicAuthOptions;
1012
- [WalletId.METAMASK]: MetaMaskWalletOptions;
1013
1053
  [WalletId.MNEMONIC]: MnemonicOptions;
1014
1054
  [WalletId.PERA]: PeraWalletConnectOptions;
1015
- [WalletId.RAINBOW]: RainbowWalletOptions;
1055
+ [WalletId.RAINBOWKIT]: RainbowKitWalletOptions;
1016
1056
  [WalletId.WALLETCONNECT]: WalletConnectOptions;
1017
1057
  [WalletId.WEB3AUTH]: Web3AuthOptions;
1018
1058
  [WalletId.W3_WALLET]: Record<string, never>;
@@ -1403,4 +1443,4 @@ declare function getSkin(skinId: string): WalletConnectSkin | undefined;
1403
1443
  */
1404
1444
  declare function resolveSkin(skinOption: WalletConnectSkinOption): WalletConnectSkin | undefined;
1405
1445
 
1406
- 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, MetaMaskWallet, type MetaMaskWalletOptions, type MnemonicOptions, MnemonicWallet, type MultisigMetadata, type NetworkConfig, NetworkConfigBuilder, NetworkId, PeraWallet, type PeraWalletConnectOptions, RainbowWallet, type RainbowWalletOptions, 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 };
1446
+ 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 };