UNPKG

@safik/fk-plug-controller

Version:

Internet Computer Plug wallet's controller

101 lines (100 loc) 3.27 kB
import { PublicKey } from '@dfinity/agent'; import { BinaryBlob } from '@dfinity/candid'; import { NFTCollection, NFTDetails } from '@safik/fk-dab-js'; import { StandardToken } from '../interfaces/ext'; import { SendResponse } from '../utils/dfx/token'; import { SendOpts } from '../utils/dfx/ledger/methods'; import { GetTransactionsResponse } from '../utils/dfx/history/rosetta'; import { ConnectedApp } from '../interfaces/account'; export interface TokenBalance { name: string; symbol: string; amount: string; canisterId: string | null; } interface PlugWalletArgs { name?: string; walletNumber: number; mnemonic: string; icon?: string; registeredTokens?: { [canisterId: string]: StandardToken; }; connectedApps?: Array<ConnectedApp>; assets?: Array<TokenBalance>; collections?: Array<NFTCollection>; fetch: any; } interface JSONWallet { name: string; walletNumber: number; principal: string; accountId: string; icon?: string; registeredTokens: { [canisterId: string]: StandardToken; }; connectedApps: Array<ConnectedApp>; assets?: Array<{ name: string; symbol: string; amount: string; canisterId: string | null; }>; nftCollections?: Array<{ name: string; canisterId: string; standard: string; tokens: Array<{ index: number; canister: string; id?: string; name?: string; url: string; metadata: any; collection?: string; }>; }>; } declare class PlugWallet { name: string; icon?: string; walletNumber: number; accountId: string; principal: string; fetch: any; registeredTokens: { [key: string]: StandardToken; }; connectedApps: Array<ConnectedApp>; assets: Array<TokenBalance>; collections: Array<NFTCollection>; private identity; private lock; constructor({ name, icon, walletNumber, mnemonic, registeredTokens, connectedApps, assets, collections, fetch, }: PlugWalletArgs); setName(val: string): void; sign(payload: BinaryBlob): Promise<BinaryBlob>; setIcon(val: string): void; getNFTs: (refresh?: boolean | undefined) => Promise<NFTCollection[] | null>; transferNFT: (args: { token: NFTDetails; to: string; }) => Promise<NFTCollection[]>; registerToken: (canisterId: string, standard?: string) => Promise<StandardToken[]>; toJSON: () => JSONWallet; burnXTC: (to: string, amount: string) => Promise<import("../interfaces/xtc").BurnResult>; getBalance: () => Promise<Array<TokenBalance>>; getTokenInfo: (canisterId: string, standard?: string) => Promise<{ token: StandardToken; amount: string; }>; getTransactions: () => Promise<GetTransactionsResponse>; send: (to: string, amount: string, canisterId?: string | undefined, opts?: SendOpts | undefined) => Promise<SendResponse>; addConnectedApp: (app: ConnectedApp) => Array<ConnectedApp>; deleteConnectedApp: (url: string) => Array<ConnectedApp>; get publicKey(): PublicKey; get pemFile(): string; private sendICP; private sendCustomToken; } export default PlugWallet;