debeem-wallet

get the default supported chain list, get the specified chain information, add, delete and update chain information

Example

get the current chain/network list:

//
// get the current chain/network list
//
const chainStorageService = new ChainStorageService();

// flush the default chains into database
await chainStorageService.flushDefault();

// query all items
const chainList : Array<ChainEntityItem | null > | null = await chainStorageService.getAll();

// should return:
[
{
name: 'Ethereum Mainnet',
chainId: 1,
token: 'ETH',
rpcs: [ [Object] ],
explorers: [ 'https://etherscan.io' ]
},
{
name: 'Ethereum Testnet Sepolia',
chainId: 11155111,
token: 'ETH',
rpcs: [ [Object] ],
explorers: [ 'https://sepolia.etherscan.io' ]
}
]

//
// get the logo url of a specified chain/network
//
const chainId = 1;
const contractAddress : string = new TokenService( chainId ).nativeTokenAddress;
const logoUrl = await new TokenService( chainId ).getItemLogo( contractAddress );

// should return:
'https://tokens.1inch.io/0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.png'

Implements

Constructors

Methods

Basic Methods

Extended Methods

  • Get the default data by the this.getDefault() method and flush the data into the database

    Returns Promise<boolean>

    Remark

    Data is stored in a key-value structure. If a key with the same name already exists, the original data will be overwritten instead of inserting a new record.