UNPKG

@hydro-protocol/swap-sdk

Version:
37 lines (36 loc) 1.61 kB
import { Tx } from "web3/eth/types"; /** * A handler for a custom wallet definition. */ export default class CustomWallet { private data; private functions; /** * @param name The name of your wallet in the dropdown. * @param iconURL URL of an icon for the dropdown. * Can be anything that would go into an img tag as src, e.g. url or data:image. */ constructor(name: string, iconURL?: string); readonly name: string; readonly iconURL: string; approveTransaction(txData: Tx): Promise<boolean>; getAccounts(): Promise<string[]>; signTransaction(txData: Tx): Promise<string>; /** * A handler for approving a transaction. * @param approveTransaction A function which takes in web3 transaction data and returns a promise. * The promise should resolve to true if the transaction is approved, and false otherwise. */ handleApproveTransaction(approveTransaction: (txData: Tx) => Promise<boolean>): this; /** * A handler for getting account addresses associated with this wallet * @param getAccounts A function that returns a promise. The promise should resolve to an array of addresses. */ handleGetAccounts(getAccounts: () => Promise<string[]>): this; /** * A handler for signing transaction data * @param signTransaction A function which takes in web3 transaction data and returns a promise. * The promise should resolve to a string representing the signed transaction data in hex format. */ handleSignTransaction(signTransaction: (txData: Tx) => Promise<string>): this; }