This module provides tools to implement a blockchain provider.
For example:
- Solana - https://github.com/salmonw/salmon-provider-solana
- NEAR - https://github.com/salmonw/salmon-provider-near
$ yarn add @salmon/provider-base.js
$ npm install --save @salmon/provider-base.js
- node version 16
- yarn
Run yarn test
to run the tests once.
Run yarn lint
to run the linter
To create a new blockchain provider is necesary to extend the class account and implement the basic functions.
https://github.com/salmonw/salmon-provider-base/blob/main/src/Account.ts
Returns all available tokens for this blockchain.
Returns the full balance for this account including the total balance
Returns the public key of the account
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 tokens to another account. The field opts could be used to send specific parameters depending on the blockchain.
Set the current network for the account.
example: devnet, mainnet
Returns the current network for the account
Returns the account blockchain. example: SOLANA, NEAR
Returns the list of transaction parsed for display.
If lastSignature if provided the function will return transactions previous to this transaction.
The project adopts the license GNU GPL v3.0.