@aptos-labs/wallet-adapter-core
Version:
Aptos Wallet Adapter Core
111 lines • 6.21 kB
TypeScript
import { AvailableWallets, WalletInfo } from "./types";
import { AdapterNotDetectedWallet, AdapterWallet } from "../WalletCore";
/**
* A function that will partition the provided wallets into two list — `defaultWallets` and `moreWallets`.
* By default, the wallets will be partitioned by whether or not they are installed or loadable.
* You can pass your own partition function if you wish to customize this behavior.
*/
export declare function partitionWallets(wallets: ReadonlyArray<AdapterWallet | AdapterNotDetectedWallet>, partitionFunction?: (wallet: AdapterWallet | AdapterNotDetectedWallet) => boolean): {
defaultWallets: AdapterWallet[];
moreWallets: AdapterNotDetectedWallet[];
};
/** Returns true if the wallet is installed or loadable. */
export declare function isInstalledOrLoadable(wallet: AdapterWallet | AdapterNotDetectedWallet): wallet is AdapterWallet;
/**
* Returns true if the user is on desktop and the provided wallet requires installation of a browser extension.
* This can be used to decide whether to show a "Connect" button or "Install" link in the UI.
*/
export declare function isInstallRequired(wallet: AdapterWallet | AdapterNotDetectedWallet): boolean;
export declare function shouldUseFallbackWallet(wallet: AdapterWallet | AdapterNotDetectedWallet): boolean;
/** Truncates the provided wallet address at the middle with an ellipsis. */
export declare function truncateAddress(address: string | undefined): string | undefined;
/**
* Returns `true` if the provided wallet is an Aptos Connect wallet.
*
* @deprecated Use {@link isPetraWebWallet} instead.
*/
export declare function isAptosConnectWallet(wallet: WalletInfo | AdapterWallet): boolean;
/** Returns `true` if the provided wallet is a Petra Web wallet. This will automatically exclude the generic wallet. */
export declare function isPetraWebWallet(wallet: WalletInfo | AdapterWallet, ignoreGenericWallet?: boolean): boolean;
/** Returns true if the wallet is a generic wallet. */
export declare function isPetraWebGenericWallet(wallet: AdapterWallet | AdapterNotDetectedWallet | WalletInfo): boolean;
/**
* Partitions the `wallets` array so that Aptos Connect wallets are grouped separately from the rest.
* Petra Web is a web wallet that uses social login to create accounts on the blockchain.
*
* @deprecated Use {@link getPetraWebWallets} instead.
*/
export declare function getAptosConnectWallets(wallets: ReadonlyArray<AdapterWallet | AdapterNotDetectedWallet>): {
aptosConnectWallets: AdapterWallet[];
otherWallets: AdapterNotDetectedWallet[];
};
/**
* Partitions the `wallets` array so that Petra Web wallets are grouped separately from the rest.
* Petra Web is a web wallet that uses social login to create accounts on the blockchain.
*/
export declare function getPetraWebWallets(wallets: ReadonlyArray<AdapterWallet | AdapterNotDetectedWallet>): {
petraWebWallets: AdapterWallet[];
otherWallets: AdapterNotDetectedWallet[];
};
export interface WalletSortingOptions {
/**
* An optional function for sorting Aptos Connect wallets.
*
* @deprecated Use {@link sortPetraWebWallets} instead.
*/
sortAptosConnectWallets?: (a: AdapterWallet, b: AdapterWallet) => number;
/** An optional function for sorting Petra Web wallets. */
sortPetraWebWallets?: (a: AdapterWallet, b: AdapterWallet) => number;
/** An optional function for sorting wallets that are currently installed or loadable. */
sortAvailableWallets?: (a: AdapterWallet | AdapterNotDetectedWallet, b: AdapterWallet | AdapterNotDetectedWallet) => number;
/** An optional function for sorting wallets that are NOT currently installed or loadable. */
sortInstallableWallets?: (a: AdapterWallet | AdapterNotDetectedWallet, b: AdapterWallet | AdapterNotDetectedWallet) => number;
/**
* A map of wallet names to fallback wallet names.
* If a wallet is not installed and has a fallback wallet that IS installed,
* the fallback wallet will be attached to the not-installed wallet and it will
* be moved to the available wallets list.
*
* @example
* ```ts
* // Override the default fallbacks
* fallbacks: { connections: { "Petra": "Petra Web", "OtherWallet": "OtherFallback" } }
* ```
*/
fallbacks?: {
/** A map of wallet names to fallback wallet names. */
connections: Record<string | AvailableWallets, string | AvailableWallets>;
/** An optional array of wallets that are available but not intended for display. These wallets will only be shown if there is logic to explicitly show them (e.g. `fallbacks`) */
additionalFallbackWallets?: ReadonlyArray<AdapterWallet>;
};
}
/**
* Partitions the `wallets` array into three distinct groups:
*
* `aptosConnectWallets` - Use {@link petraWebWallets} instead.
*
* `petraWebWallets` - Wallets that use social login to create accounts on
* the blockchain via Petra Web.
*
* `availableWallets` - Wallets that are currently installed or loadable by the client.
*
* `availableWalletsWithFallbacks` - Wallets that are currently uninstalled that have a fallback wallet.
*
* `installableWallets` - Wallets that are NOT current installed or loadable and
* require the client to install a browser extension first.
*
* Additionally, these wallet groups can be sorted by passing sort functions via the `options` argument.
*/
export declare function groupAndSortWallets(wallets: ReadonlyArray<AdapterWallet | AdapterNotDetectedWallet>, options?: WalletSortingOptions): {
/** @deprecated Use {@link petraWebWallets} instead. */
aptosConnectWallets: AdapterWallet[];
/** Wallets that use social login to create an account on the blockchain */
petraWebWallets: AdapterWallet[];
/** Wallets that are currently installed or loadable. */
availableWallets: AdapterWallet[];
/** Wallets that are currently uninstalled that have a fallback wallet. */
availableWalletsWithFallbacks: (AdapterWallet | AdapterNotDetectedWallet)[];
/** Wallets that are NOT currently installed or loadable. */
installableWallets: AdapterNotDetectedWallet[];
};
//# sourceMappingURL=walletSelector.d.ts.map