import EventEmitter from "eventemitter3"; import { AccountAuthenticator, AnyRawTransaction, InputSubmitTransactionData, Network, PendingTransactionResponse, TransactionSubmitter } from "@moveindustries/ts-sdk"; import { MovementWallet, MovementSignAndSubmitTransactionOutput, NetworkInfo, AccountInfo, MovementSignMessageInput, MovementSignMessageOutput, MovementChangeNetworkOutput, MovementSignInInput, MovementSignInOutput } from "@moveindustries/wallet-standard"; export type { NetworkInfo, AccountInfo, MovementSignAndSubmitTransactionOutput, MovementSignTransactionOutputV1_1, MovementSignMessageInput, MovementSignMessageOutput, MovementChangeNetworkOutput, } from "@moveindustries/wallet-standard"; export type { AccountAuthenticator, AnyRawTransaction, InputGenerateTransactionOptions, PendingTransactionResponse, InputSubmitTransactionData, Network, AnyPublicKey, AccountAddress, TransactionSubmitter, } from "@moveindustries/ts-sdk"; import { WalletReadyState } from "./constants"; import { AvailableWallets, InputTransactionData } from "./utils/types"; export type AdapterWallet = MovementWallet & { readyState?: WalletReadyState; isMovementNativeWallet?: boolean; }; export type AdapterNotDetectedWallet = Omit & { readyState: WalletReadyState.NotDetected; }; export interface DappConfig { network: Network; /** * If provided, the wallet adapter will submit transactions using the provided * transaction submitter rather than via the wallet. */ transactionSubmitter?: TransactionSubmitter; movementApiKeys?: Partial>; /** * @deprecated will be removed in a future version */ mizuwallet?: { manifestURL: string; appId?: string; }; /** * @deprecated will be removed in a future version */ msafeWalletConfig?: { appId?: string; appUrl?: string; }; crossChainWallets?: boolean; } export declare interface WalletCoreEvents { connect(account: AccountInfo | null): void; disconnect(): void; standardWalletsAdded(wallets: AdapterWallet): void; standardNotDetectedWalletAdded(wallets: AdapterNotDetectedWallet): void; networkChange(network: NetworkInfo | null): void; accountChange(account: AccountInfo | null): void; } export type AdapterAccountInfo = Omit & { mnsName?: string; }; export declare class WalletCore extends EventEmitter { private _wallet; private readonly _sdkWallets; private _standard_wallets; private _standard_not_detected_wallets; private _network; private _connected; private _connecting; private _account; private _dappConfig; private _optInWallets; private _disableTelemetry; private readonly ga4; constructor(optInWallets?: ReadonlyArray, dappConfig?: DappConfig, disableTelemetry?: boolean); private fetchExtensionAIP62MovementWallets; /** * Set AIP-62 extension wallets * * @param extensionwWallets */ private setExtensionAIP62Wallets; /** * Set AIP-62 SDK wallets */ private fetchSDKAIP62MovementWallets; private isMovementNativeWallet; private appendNotDetectedStandardSupportedWallets; /** * A function that excludes an AIP-62 compatible wallet the dapp doesnt want to include * * @param wallet AdapterWallet | AdapterNotDetectedWallet * @returns boolean */ excludeWallet(wallet: AdapterWallet | AdapterNotDetectedWallet): boolean; private recordEvent; /** * Helper function to ensure wallet exists * * @param wallet A wallet */ private ensureWalletExists; /** * Helper function to ensure account exists * * @param account An account */ private ensureAccountExists; /** * Queries and sets MNS name for the current connected wallet account */ private setMnsName; /** * Re-fetches the MNS name for the current connected wallet account. * Clears the cached name and queries MNS again, emitting an accountChange * event with the updated name. * * Useful for dapps that allow users to set or change their primary MNS name * and want the adapter to reflect the update without requiring a reconnect. */ refetchMnsName(): Promise; /** * Function to cleat wallet adapter data. * * - Removes current connected wallet state * - Removes current connected account state * - Removes current connected network state * - Removes autoconnect local storage value */ private clearData; /** * Sets the connected wallet * * @param wallet A wallet */ setWallet(wallet: MovementWallet | null): void; /** * Sets the connected account * * @param account An account */ setAccount(account: AccountInfo | null): void; /** * Sets the connected network * * @param network A network */ setNetwork(network: NetworkInfo | null): void; /** * Helper function to detect whether a wallet is connected * * @returns boolean */ isConnected(): boolean; /** * Getter to fetch all detected wallets */ get wallets(): ReadonlyArray; get notDetectedWallets(): ReadonlyArray; /** * Getter for the current connected wallet * * @return wallet info * @throws WalletNotSelectedError */ get wallet(): MovementWallet | null; /** * Getter for the current connected account * * @return account info * @throws WalletAccountError */ get account(): AccountInfo | null; /** * Getter for the current wallet network * * @return network info * @throws WalletGetNetworkError */ get network(): NetworkInfo | null; /** * Helper function to run some checks before we connect with a wallet. * * @param walletName. The wallet name we want to connect with. */ connect(walletName: string): Promise; /** * Signs into the wallet by connecting and signing an authentication messages. * * For more information, visit: https://siwa.aptos.dev * * @param args * @param args.input The MovementSignInInput which defines how the SIWA Message should be constructed * @param args.walletName The name of the wallet to sign into * @returns The MovementSignInOutput which contains the account and signature information */ signIn(args: { input: MovementSignInInput; walletName: string; }): Promise; /** * Connects a wallet to the dapp. * On connect success, we set the current account and the network, and keeping the selected wallet * name in LocalStorage to support autoConnect function. * * @param selectedWallet. The wallet we want to connect. * @emit emits "connect" event * @throws WalletConnectionError */ private connectWallet; /** * Disconnect the current connected wallet. On success, we clear the * current account, current network and LocalStorage data. * * @emit emits "disconnect" event * @throws WalletDisconnectionError */ disconnect(): Promise; /** * Signs and submits a transaction to chain * * @param transactionInput InputTransactionData * @returns MovementSignAndSubmitTransactionOutput */ signAndSubmitTransaction(transactionInput: InputTransactionData): Promise; /** * Signs a transaction * * This method supports 2 input types - * 1. A raw transaction that was already built by the dapp, * 2. A transaction data input as JSON. This is for the wallet to be able to simulate before signing * * @param transactionOrPayload AnyRawTransaction | InputTransactionData * @param asFeePayer optional. A flag indicates to sign the transaction as the fee payer * @param options optional. Transaction options * * @returns AccountAuthenticator */ signTransaction(args: { transactionOrPayload: AnyRawTransaction | InputTransactionData; asFeePayer?: boolean; }): Promise<{ authenticator: AccountAuthenticator; rawTransaction: Uint8Array; }>; /** * Sign a message (doesnt submit to chain). * * @param message - MovementSignMessageInput * * @return response from the wallet's signMessage function * @throws WalletSignMessageError */ signMessage(message: MovementSignMessageInput): Promise; /** * Submits transaction to chain * * @param transaction - InputSubmitTransactionData * @returns PendingTransactionResponse */ submitTransaction(transaction: InputSubmitTransactionData): Promise; /** Event for when account has changed on the wallet @return the new account info @throws WalletAccountChangeError */ onAccountChange(): Promise; /** Event for when network has changed on the wallet @return the new network info @throws WalletNetworkChangeError */ onNetworkChange(): Promise; /** * Sends a change network request to the wallet to change the connected network * * @param network - Network * @returns MovementChangeNetworkOutput */ changeNetwork(network: Network): Promise; /** * Signs a message and verifies the signer * @param message - MovementSignMessageInput * @returns boolean */ signMessageAndVerify(message: MovementSignMessageInput): Promise; } //# sourceMappingURL=WalletCore.d.ts.map