WalletProvider

Top level component for the Aleo Hook library

All compents that will aleo-hooks must reside under WalletProvider component.

WalletProvider props:

export interface WalletProviderProps {
    children: any;
    wallets: Adapter[]; // list of supported wallet adapters
    decryptPermission?: DecryptPermission; // allow app decrypting data
    programs?: string[]; // programs that app can execute
    network?: WalletAdapterNetwork; // network to connect to
    autoConnect?: boolean; // if true, connect on refresh
    onError?: (error: WalletError) => void; // error callback
    localStorageKey?: string; // key to save a selected wallet in a storage
}
export declare enum DecryptPermission {
    NoDecrypt = "NO_DECRYPT",
    UponRequest = "DECRYPT_UPON_REQUEST",
    AutoDecrypt = "AUTO_DECRYPT",
    OnChainHistory = "ON_CHAIN_HISTORY"
}

export declare enum WalletAdapterNetwork {
    Testnet = "testnet3"
}
export const Provider: FC<{ children: React.ReactNode }> = ({
    children,
}) => {
    const wallets = useMemo(
        () => [
            new LeoWalletAdapter({
                appName: 'Leo Wallet',
            }),
        ],
        [],
    );

    return (
        <WalletProvider
            wallets={wallets}
            decryptPermission={DecryptPermission.UponRequest}
            network={WalletAdapterNetwork.Testnet}
            autoConnect
        >
            {children}
        </WalletProvider>
    );
};

Last updated