Broxus JavaScript Core
Introduction
This library provides MobX-based services, models and helpers
to build JavaScript Applications with any popular frameworks or
libraries (e.g. React, Angular, Vue, etc.)
Services
Collection of the services to manage states of the wallets connections - TVM-compatible Wallets (e.g. EVER Wallet).
Services to manage tokens list, tokens wallets cache and tokens prices etc.
TvmWalletService
Service to connect to a TVM-compatible Wallet like EVER Wallet or Venom Wallet. It has connect
and disconnect
methods for manually connect
and disconnect to the wallet.
import { TvmWalletService } from '@broxus/js-core'
const tvmWalletService = new TvmWalletService({
defaultNetworkId: 42,
minWalletVersion: '2.31.0',
networks: [
{
chainId: '42',
currency: {
decimals: 9,
icon: '...',
name: 'Native currency',
symbol: 'EVER',
wrappedCurrencyAddress: new AddressLiteral( '0:a49cd4e158a9a15555e624759e2e4e766d22600b7800d891e46f9291f044a93d'),
},
explorer: {
accountsSubPath: 'accounts',
baseUrl: 'https://everscan.io',
title: 'EVER Scan',
transactionsSubPath: 'transactions',
},
id: 'tvm-42',
name: 'Everscale',
rpcUrl: 'https://jrpc.everwallet.net/rpc',
shortName: 'Everscale',
type: 'tvm',
},
],
providerId: 'ever'
})
await tvmWalletService.connect()
For add a custom token asset to the wallet extension tokens assets use method addAsset
.
await tvmWalletService.addAsset('0:a49cd4e158a9a15555e624759e2e4e766d22600b7800d891e46f9291f044a93d', 'tip3_token')
When you add network with some chainId
- this network config should be described in the networks
option
TokensListService
Service for load and manage list of the Everscale tokens.
import { TokensListService } from '@broxus/js-core'
import { ProviderRpcClient } from 'everscale-inpage-provider'
const tokensListService = new TokensListService(
'https://raw.githubusercontent.com/broxus/flatqube-assets/master/manifest.json',
connection: ProviderRpcClient
)
await tokensListService.init()
Models
TvmToken
Model for the TVM-based token
import { TvmToken } from '@broxus/js-core'
const token = new TvmToken(tvmWalletService.connection, {
name: 'Wrapped EVER',
symbol: 'WEVER',
decimals: 9,
address: '0:a49cd4e158a9a15555e624759e2e4e766d22600b7800d891e46f9291f044a93d',
logoURI: 'https://raw.githubusercontent.com/broxus/flatqube-assets/master/icons/WEVER/logo.svg',
version: 5,
verified: true,
}, [tvmWalletService.provider])
await token.sync({ force: true, silent: true })
const userWallet = await token.wallet(ownerAddress: Address | string)
Misc
AbstractStore
Abstract class AbstractStore
is a primary way to create any services or stores that provides API
to manage state and data:
@observable
protected _data: {}
@observable
protected _state: {}
@action.bound
public setData(keyOrData: string | object | (prevData) => nextData): this
@action.bound
public setState(keyOrState: string | object | (prevState) => nextState): this
@computed
public toJSON(): object
TvmContractWrapper
Abstract class TvmContractWrapper
is a primary way to create models (wrapper for contract)