UNPKG

@portis/web3

Version:

Portis Web3 SDK

299 lines (294 loc) 7.99 kB
// Generated by dts-bundle-generator v5.8.0 import { AsyncMethodReturns } from 'penpal'; export interface INetwork { nodeUrl: string; chainId?: string; gasRelayHubAddress?: string; } export interface IConnectionMethods { getAccounts: (config: ISDKConfig) => Promise<{ error: string; result: string[]; }>; signTransaction: (txParams: ITransactionRequest, config: ISDKConfig) => Promise<{ error: string; result: string; }>; signMessage: (msgParams: IMessageParams, config: ISDKConfig) => Promise<{ error: string; result: string; }>; relay: (payload: IPayload, config: ISDKConfig) => Promise<{ error: string; result: any; }>; showPortis: (config: ISDKConfig) => Promise<void>; importWallet: (mnemonicOrPrivateKey: string, config: ISDKConfig) => Promise<void>; getExtendedPublicKey: (path: string, coin: string, config: ISDKConfig) => Promise<{ error: string; result: string; }>; logout: () => Promise<{ error: string; result: boolean; }>; getCampaignInfo: (campaignId: string) => Promise<{ error: string; result: any; }>; claimVoucher: (voucherId: string, config: ISDKConfig) => Promise<{ error: string; result: any; }>; isLoggedIn: () => Promise<{ error: string; result: boolean; }>; signBitcoinTransaction: (params: { coin: string; inputs: BTCSignTxInput[]; outputs: BTCSignTxOutput[]; version?: number; locktime?: number; }, config: ISDKConfig) => Promise<{ error: string; result: { serializedTx: string; txid: string; }; }>; showBitcoinWallet: (path: string, config: ISDKConfig) => Promise<void>; setSdkConfig: (config: ISDKConfig) => Promise<void>; purchaseERC20: (params: IPurchaseERC20Params, config: ISDKConfig) => Promise<void>; } export interface IWidget { communication: AsyncMethodReturns<IConnectionMethods>; widgetFrame: HTMLDivElement; } export interface ISDKConfig { dappId: string; network: INetwork; version: string; defaultEmail?: string; scope?: Scope[]; registerPageByDefault?: boolean; staging?: boolean; feature?: boolean; } export declare type Scope = "email"; export interface IOptions { scope?: Scope[]; gasRelay?: boolean; registerPageByDefault?: boolean; pocketDevId?: string; staging?: boolean; feature?: boolean; } export interface ITransactionRequest { to?: string; from?: string; nonce?: string; gas?: string; gasPrice?: string; data?: string; value?: string; chainId?: number; } export interface IMessageParams { from: string; data: string | ITypedDataMessage[]; messageStandard: "signMessage" | "signPersonalMessage" | "signTypedMessage"; } export interface ITypedDataMessage { name: string; type: string; value: string; } export interface IPayload { id: number; jsonrpc: string; method: string; params: any[]; } export declare type BIP32Path = Array<number>; export interface BTCSignTxInput { addressNList: BIP32Path; scriptType?: BTCInputScriptType; sequence?: number; amount: string; vout: number; txid: string; tx?: BitcoinTx; hex: string; } export interface BTCSignTxOutput { addressNList?: BIP32Path; scriptType?: BTCOutputScriptType; address?: string; addressType: BTCOutputAddressType; amount: string; isChange: boolean; } export interface BitcoinTx { version: number; locktime: number; vin: Array<BitcoinInput>; vout: Array<BitcoinOutput>; } export interface BitcoinInput { vout?: number; valueSat?: number; sequence?: number; scriptSig?: BitcoinScriptSig; txid?: string; coinbase?: string; } export interface BitcoinOutput { value: string; scriptPubKey: BitcoinScriptSig; } export interface BitcoinScriptSig { hex: string; } export interface BTCSignTxSDKInput { coin: string; inputs: BTCSignTxInput[]; outputs: BTCSignTxOutput[]; locktime?: number; version?: number; } export declare type BTCInputScriptType = "p2pkh" | "p2sh" | "external" | "p2wpkh" | "p2sh-p2wpkh"; export declare type BTCOutputScriptType = "p2pkh" | "p2sh" | "p2wpkh" | "p2sh-p2wpkh"; export declare type BTCOutputAddressType = "spend" | "transfer" | "change" | "exchange"; export interface IPurchaseERC20Params { tokenAddress: string; amount: string; tokenSymbol: string; logoURL?: string | undefined; } declare class WidgetManager { private _widgetConfig; private _clearProviderSession; private widgetPromise?; private widgetInstance?; private _widgetUrl; private _onLoginCallback; private _onLogoutCallback; private _onActiveWalletChangedCallback?; private _onErrorCallback; constructor(_widgetConfig: ISDKConfig, _clearProviderSession: () => void); getWidget(): Promise<IWidget>; setDefaultEmail(email: string): void; setOnLoginCallback(callback: (walletAddress: string, email?: string, reputation?: string) => void): void; setOnLogoutCallback(callback: () => void): void; setOnActiveWalletChangedCallback(callback: (walletAddress: string) => void): void; setOnErrorCallback(callback: (error: Error) => void): void; showPortis(): Promise<void>; getCampaignInfo(campaignId: string): Promise<{ error: string; result: any; }>; claimVoucher(voucherId: string): Promise<{ error: string; result: any; }>; logout(): Promise<{ error: string; result: boolean; }>; getExtendedPublicKey(path?: string, coin?: string): Promise<{ error: string; result: string; }>; importWallet(mnemonicOrPrivateKey: string): Promise<void>; isLoggedIn(): Promise<{ error: string; result: boolean; }>; signBitcoinTransaction(params: BTCSignTxSDKInput): Promise<{ error: string; result: { serializedTx: string; txid: string; }; }>; showBitcoinWallet(path?: string): Promise<void>; purchaseERC20(params: IPurchaseERC20Params): Promise<void>; private static _checkIfWidgetAlreadyInitialized; private _initWidget; private _setHeight; private static _getWindowSize; private _onLogin; private _onLogout; private _onActiveWalletChanged; private hasOnActiveWalletChanged; private _onError; } declare const ProviderEngine: any; declare class Web3Manager { private config; private _getWidgetCommunication; private engine; provider: typeof ProviderEngine; private _selectedAddress?; private _network?; constructor(config: ISDKConfig, _getWidgetCommunication: () => Promise<AsyncMethodReturns<IConnectionMethods>>); setSelectedAddress(selectedAddress: string): void; changeNetwork(network: string | INetwork, gasRelay?: boolean): void; private _initProvider; private clearSubprovider; } declare class Portis { private _widgetManagerInstance?; private _web3ManagerInstance?; private _config?; constructor(dappId: string, network: string | INetwork, options?: IOptions); readonly _widgetManager: WidgetManager; readonly _web3Manager: Web3Manager; readonly config: ISDKConfig; private _clearProviderSession; private _getWidgetCommunication; readonly web3Provider: any; readonly provider: any; changeNetwork(network: string | INetwork, gasRelay?: boolean): void; setDefaultEmail(email: string): void; getWidget(): Promise<IWidget>; onLogin(callback: (walletAddress: string, email?: string, reputation?: string) => void): void; onLogout(callback: () => void): void; onActiveWalletChanged(callback: (walletAddress: string) => void): void; onError(callback: (error: Error) => void): void; showPortis(): Promise<void>; getCampaignInfo(campaignId: string): Promise<{ error: string; result: any; }>; claimVoucher(voucherId: string): Promise<{ error: string; result: any; }>; logout(): Promise<{ error: string; result: boolean; }>; getExtendedPublicKey(path?: string, coin?: string): Promise<{ error: string; result: string; }>; importWallet(mnemonicOrPrivateKey: string): Promise<void>; isLoggedIn(): Promise<{ error: string; result: boolean; }>; signBitcoinTransaction(params: BTCSignTxSDKInput): Promise<{ error: string; result: { serializedTx: string; txid: string; }; }>; showBitcoinWallet(path?: string): Promise<void>; private _validateParams; } export default Portis; export as namespace portis; export {};