New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@broxus/js-core

Package Overview
Dependencies
Maintainers
6
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@broxus/js-core

MobX-based JavaScript Core library

0.11.0
npm
Version published
Maintainers
6
Created
Source

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', // min version that suppurts delayed messages sending
    networks: [
        {
            chainId: '42',
            currency: {
                decimals: 9,
                icon: '...',
                name: 'Native currency',
                symbol: 'EVER',
                wrappedCurrencyAddress: new AddressLiteral( '0:a49cd4e158a9a15555e624759e2e4e766d22600b7800d891e46f9291f044a93d'), // WEVER
            },
            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)

Keywords

everscale

FAQs

Package last updated on 26 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts