@salmonw/provider-base

0.0.8 • Public • Published

Salmon logo

Provider Base

This module provides tools to implement a blockchain provider.

For example:


Table of Contents


Instalation and usage

Yarn

$ yarn add @salmon/provider-base.js

npm

$ npm install --save @salmon/provider-base.js

Contributing

Requirements

  • node version 16
  • yarn

Testing and Linting

Run yarn test to run the tests once.

Run yarn lint to run the linter


Extending account

To create a new blockchain provider is necesary to extend the class account and implement the basic functions.


Account definition

https://github.com/salmonw/salmon-provider-base/blob/main/src/Account.ts

getTokens()

Returns all available tokens for this blockchain.

getBalance()

Returns the full balance for this account including the total balance

getReceiveAddress()

Returns the public key of the account

validateDestinationAccount(address)

Checks if the destination account exists and is valid. It could return an error if the account address is wrong

A warning it the address is right but it has no funds or some other issue

Success if the account is right and have funds

example:

const INVALID_ADDRESS = {
  type: 'ERROR',
  code: 'INVALID_ADDRESS',
};
const EMPTY_ACCOUNT = {
  type: 'WARNING',
  code: 'EMPTY_ACCOUNT',
};
const NO_FUNDS = {
  type: 'WARNING',
  code: 'NO_FUNDS',
};

const VALID_ACCOUNT = {
  type: 'SUCCESS',
  code: 'VALID_ACCOUNT',
};

transfer(destination, token, amount, opts)

Transfer tokens to another account. The field opts could be used to send specific parameters depending on the blockchain.

setNetwork(networkId)

Set the current network for the account.

example: devnet, mainnet

getCurrentNetork()

Returns the current network for the account

getChain()

Returns the account blockchain. example: SOLANA, NEAR

getRecentTransactions(lastSignature)

Returns the list of transaction parsed for display.

If lastSignature if provided the function will return transactions previous to this transaction.

Common services

License

The project adopts the license GNU GPL v3.0.

Dependencies (4)

Dev Dependencies (17)

Package Sidebar

Install

npm i @salmonw/provider-base

Weekly Downloads

0

Version

0.0.8

License

GPL-3.0-only

Unpacked Size

144 kB

Total Files

46

Last publish

Collaborators

  • salmon-wallet