Attention: This Class was not exported from the module. You must use module method load to get an instance.


Constructor

constructor()

Property

extension

Type: ExtensionWrapper
Description: ExtensionWrapper instance, transfer by module method load

status

Type: Status
Description: Proxy status.


Methods

async link(param)

Description

Connect user to the extension.

Parameters :

param - Any:

Additional data required by extension.

Returns :

Promise<Result<String, Status>>:

Account loaded in the extension will be set into the data field of Result if success.

async unlink()

Description

Disconnect user from the web extension.

Returns :

Promise<Result<Bool, Status>>:

Boolean value true will be set into the data field of Result if success.

isLogin

async isLogin()

Description

Check if extension is logged in.

extra - Any:

Additional data to accommodate the transaction requirements of different blockchains.

Returns :

Promise<Result<Bool, Status>>:

Boolean value true will be set into the data field of Result if success.

isMainnet

async isMainnet()

Description

Check if extension's network is on mainnet.

Returns :

Promise<Result<Bool, Status>>:

Boolean value true will be set into the data field of Result if success.

onChainCall

async onChainCall(wrapper, method, param, amount, extra)

Description

Invoke a smart contract's method to do some operation on blockchain. This method may change the state of blockchain.

Parameters :

wrapper - ContractWrapper:

A ContractWrapper instance returned by loadContract method.

method - String:

Which method in the contract will be called.

param - Any:

Data for the contract method's parameter.

amount - Number:

How much original token will send to the contract in this call.

extra - Any:

Additional data required by extension.

Returns :

Promise<Result<String, Status>>:

Transaction hash will be set into the data field of Result if success.

offChainCall

async offChainCall(wrapper, method, param)

Description

Disconnect user and the web extension.
Parameters : wrapper - ContractWrapper:

A ContractWrapper instance returned by loadContract method.

method - String:

Which method in the contract will be called.

param - Any:

Data for the contract method's parameter.

Returns :

Promise<Result<Any, Status>>:

Value returned by the contract will be set into the data field of Result if success.

loadContract

async loacContract(abi, address)

Description

Load smart contract to a ContractWrapper instance.

Parameters :

abi - Any:

Contract ABI Array, Object or any other types required by the blockchain.

address - String:

Contract Address passed by the constructor.

Returns :

Promise<Result<ContractWrapper, Status>>:

ContractWrapper instance will be set into the data field of Result if success.

transfer

async transfer(to, amount, memo, extra)

Description

Transfer original token of the block. Original token is the base assets of a blockchain, like ETH on Ethereum.

Parameters :

to - String:

Assets transfer target address.

amount - Number:

How many tokens will be transferred.

memo - String:

Transaction's memo.

extra - Any:

Additional data to accommodate the transaction requirements of different blockchains.

Returns :

Promise<Result<ContractWrapper, Status>>:

Transaction hash will be set into the data field of Result if success.

transferToken

async transferToken(wrapper, to, amount, extra)

Description

Transfer contract based token. These tokens are issued by smart contract, like ERC 20 token etc.

Parameters :

wrapper - ContractWrapper:

A ContractWrapper instance returned by loadContract method.

to - String:

Token transfer target address.

amount - Number |  String:

How many tokens will be transferred. Some of the blockchain accept number with token symbol in the amount string, like "1.000 EOS".

extra - Any:

Additional data to accommodate the transaction requirements of different blockchains.

Returns :

Promise<Result<ContractWrapper, Status>>:

Transaction hash will be set into the data field of Result if success.

getAccount

async getAccount()

Description

Get the account loaded in extension.

Returns :

Promise<Result<ContractWrapper, Status>>:

Account string will be set into the data field of Result if success.