UNPKG

@magicblock-labs/gum-react-sdk

Version:
49 lines (43 loc) 2.52 kB
import { AnchorWallet } from '@solana/wallet-adapter-react'; import { SendTransactionOptions } from '@solana/wallet-adapter-base'; import { PublicKey, Transaction, Connection, Cluster, ConfirmOptions } from '@solana/web3.js'; import { SDK } from '@magicblock-labs/gum-sdk'; export { GPLSESSION_PROGRAMS, SDK } from '@magicblock-labs/gum-sdk'; import * as React from 'react'; import { ReactNode } from 'react'; interface SessionWalletInterface { publicKey: PublicKey | null; ownerPublicKey: PublicKey | null; isLoading: boolean; error: string | null; sessionToken: string | null; signTransaction: (<T extends Transaction>(transaction: T, connection?: Connection, sendOptions?: SendTransactionOptions) => Promise<T>) | undefined; signAllTransactions: (<T extends Transaction>(transactions: T[], connection?: Connection, sendOptions?: SendTransactionOptions) => Promise<T[]>) | undefined; signMessage: ((message: Uint8Array) => Promise<Uint8Array>) | undefined; sendTransaction: (<T extends Transaction>(transaction: T, connection?: Connection, options?: SendTransactionOptions) => Promise<string>) | undefined; signAndSendTransaction: (<T extends Transaction>(transactions: T | T[], connection?: Connection, options?: SendTransactionOptions) => Promise<string[]>) | undefined; createSession: (targetProgram: PublicKey, topUpLamports?: number, validUntil?: number, sessionCreatedCallback?: (sessionInfo: { sessionToken: string; publicKey: string; }) => void) => Promise<SessionWalletInterface | undefined>; revokeSession: () => Promise<string | null>; getSessionToken: () => Promise<string | null>; } declare function useSessionKeyManager(wallet: AnchorWallet, connection: Connection, cluster: Cluster | "localnet"): SessionWalletInterface; declare const useGum: (wallet: AnchorWallet, connection: Connection, opts: ConfirmOptions) => SDK; interface GumContextValue { sdk: SDK; } interface GumProviderProps { children: ReactNode; sdk: SDK; } declare const GumProvider: React.FC<GumProviderProps>; declare const useGumContext: () => GumContextValue; declare const useSessionWallet: () => SessionWalletInterface; interface SessionWalletProviderProps { sessionWallet: SessionWalletInterface; children: React.ReactNode; } declare const SessionWalletProvider: React.FC<SessionWalletProviderProps>; export { GumProvider, SessionWalletInterface, SessionWalletProvider, useGum, useGumContext, useSessionKeyManager, useSessionWallet };