THORSwap SwapKit
Ask or search…
⌃K
Links
Comment on page

@swapkit/helpers

Installation

pnpm
yarn
npm
pnpm add @swapkit/helpers
yarn add @swapkit/helpers
npm add @swapkit/helpers

Modules

AssetValue

Module for initialisation and handling asset operation in SwapKit and applications. It inherits from SwapKitNumber with change on eq method, which gives easy way of handling operations with decimals precision taken from contract or static list
import { AssetValue } from '@swapkit/helpers';

SwapKitNumber

Module for handling BigInt arithmetics gracefully with handling precision up to whatever decimal you need
import { SwapKitNumber } from '@swapkit/helpers';

SwapKitError

Helper error class to help with error identification. Check Table​
import { SwapKitError } from '@swapkit/helpers';

Helpers

Method
Description
Type reference
derivationPathToString
Converts array derivation path to string one with recognition of short paths too (4 numbers): [84, 0, 0, 0, 0] => 84'/0'/0'/0/0
[84, 0, 0, 1] => 84'/0'/'0/0
([
network,
chainId,
account,
change,
index,
]: number[]) => string
getTHORNameCost
Returns registration fee in number to be paid in RUNE - Base is 10
(year: number) => number
validateIdentifier
Validates if identifier follows <Chain>[./]<Ticker> or <Chain>[./]<Ticker>-<ContractAddress> structure
(identifier?: string) => boolean

Error code table TODO

{
/**
* Core
*/
core_wallet_connection_not_found: 10001,
core_estimated_max_spendable_chain_not_supported: 10002,
core_extend_error: 10003,
core_inbound_data_not_found: 10004,
core_approve_asset_address_or_from_not_found: 10005,
core_chain_halted: 10099,
/**
* Core - Wallet Connection
*/
core_wallet_xdefi_not_installed: 10101,
core_wallet_evmwallet_not_installed: 10102,
core_wallet_walletconnect_not_installed: 10103,
core_wallet_keystore_not_installed: 10104,
core_wallet_ledger_not_installed: 10105,
core_wallet_trezor_not_installed: 10106,
core_wallet_keplr_not_installed: 10107,
core_wallet_okx_not_installed: 10108,
/**
* Core - Swap
*/
core_swap_invalid_params: 10200,
core_swap_route_not_complete: 10201,
core_swap_asset_not_recognized: 10202,
core_swap_contract_not_found: 10203,
core_swap_route_transaction_not_found: 10204,
core_swap_contract_not_supported: 10205,
core_swap_transaction_error: 10206,
core_swap_quote_mode_not_supported: 10207,
/**
* Core - Transaction
*/
core_transaction_deposit_error: 10301,
core_transaction_create_liquidity_rune_error: 10302,
core_transaction_create_liquidity_asset_error: 10303,
core_transaction_create_liquidity_invalid_params: 10304,
core_transaction_add_liquidity_invalid_params: 10305,
core_transaction_add_liquidity_no_rune_address: 10306,
core_transaction_add_liquidity_rune_error: 10307,
core_transaction_add_liquidity_asset_error: 10308,
core_transaction_withdraw_error: 10309,
core_transaction_deposit_to_pool_error: 10310,
core_transaction_deposit_insufficient_funds_error: 10311,
core_transaction_deposit_gas_error: 10312,
core_transaction_deposit_server_error: 10313,
​
/**
* Wallets
*/
wallet_ledger_connection_error: 20001,
​
/**
* Helpers
*/
helpers_number_different_decimals: 99101,
}