eosplayer
Eosplayer is a bonding layer of eosjs, which is based on eosjs and provides better usability for the application layer. It can be used on both the node.js server and in a browser or Dapp wallet that already has Scatter installed.
frontd releases : https://github.com/bagaking/eosplayer/releases
LICENSE : Apache 2.0
structure
build (for broswer)
npm run build
or yarn run build
play
- clone the repo
- cd into the folder
- install hserve :
npm i -g hserve
- serve the play folder :
hserve play
- open the test site in your chrome :
http://localhost:3000
by default - test it in your chrome console
or using the online play ground: https://play.eosplayer.pro
api documents :
Doc site:
doc.eosplayer.pro
or
Docs in playground
you can using
help
commond to show api documents on chrome console
log
there are 4 levels of log
- verbose
- info
- warning
- error
in the initial situation, the level verbose
is closed, and info|warning|error
are opened.
if you would like to disable all level, set the level filter to
'-'
.when enable called, origin setting will be override (not append).
Enable/Disable Log Level in Browser
- open specific level of log :
localStorage.debug = 'warning:*,info:*'
- open all :
localStorage.debug = '*'
then, refresh the broswer
Enable/Disable Log Level in Prompt
Unix
DEBUG=error:* node test.js
CMD
set DEBUG=error:* & node app.js
PowerShell
$env:DEBUG = "error:*"
Enable/Disable Log Level in program dynamically
const debug = ;debug;
(temporary in beta.11) these code should be placed after the require operation of eosplayer.
Usage of eosplayer (cli)
you can use call methods of eosplayer.chain by cli
install: npm i -g eosplayer
use: eosplayer --help
Usage of eosplayer (for browser)
Log
Events
ERR_TRANSCAL_FAILED
ERR_TRANSFER_FAILED
ERR_TRANSEND_FAILED
APIs
String get help // get help info of usageString get version // get the version infoChain get chain // get the chain Void eosplayerevent //listen to a event Eos get eosplayereosClient // get eos instanceIdentity async eosplayer // get identity AccountInfo async eosplayer // get account info for any user String async eosplayer // get balance string of a account. ex. "1.0000 EOS", null means that the account dosen't have any token, String async eosplayer // get balances array of a account. ex. ["1.0000 CT"] String async eosplayer // get balance structure of a account. ex. {val:1, sym:"EOS", decimal:4} Tx async eosplayer // transfer tokens to target Tx async eosplayer // send a action of transcal to contract Tx async eosplayer // send a action of trancal (quantity value = 0.0001) to contract Contract async eosplayer // get contract object Tx async eosplayer // send a action to contract Tx async eosplayer // create a account with public key
Chain API
Object async // get info of the chain connectedObject async // get specific block of the chain Contract async // get contractObject async // get abi of contractObject async // get table abi of contractObject async Object async // get account info of any userstring async // get the first public key of an accountArray async // get public keys of an accountstring async // recover sign and to the public keystring async // validate if signed data is signed by a account. it returns the matched public key Number async // get a account's action countNumber async // get a account's max action seqArray async // get recent actionsArray async // get all actions of an accountArray async // get all actions in bulk String async // get balance of specific accountArray<String> async // get all balance of specific accountTx async // the format of account should be {name, authority} Tx async // check a transaction info, retry once per sec until success Tx async // send action to a contract Array async // get all items in a tableArray async // check a tableArray async Array async // check range in tableObject async // check a item in a table Object async // update auth
Usage of eosplayer (for broswer)
Events
ERR_GET_SCATTER_FAILED ERR_GET_IDENTITY_FAILEDERR_LOGOUT_FAILED
APIs
void eosplayer // switch networkvoid eosplayer // add a network config at runtime get Scatter eosplayerscatter // get scatter instanceget Scatter async // get scatter instance get string eosplayernetName // get current network nameget string eosplayernetConf // get current network config async Identity eosplayer // let user allow you using identityasync void eosplayer // return back the identity async // sign a message with current identity
Imported libs
windoweosjs = Eos; /** the eosjs lib @see {@url https://www.npmjs.com/package/eosjs} */windoweosjs_ecc = Ecc; /** the eosjs-ecc lib @see {@url https://www.npmjs.com/package/eosjs-ecc} */windowBigNumber = BigNumber; /** big number library @see {@url https://www.npmjs.com/package/bignumber.js} */windowenv = env; /** */windowidb = idb; /** idb lib for browser storage @see {@url https://www.npmjs.com/package/idb } */windoweosplayer = networks;
Usage of eosplayer (for node.js)
- install eosplayer
npm i eosplayer --save
oryarn add eosplayer
- import eosplayer
import * from 'eosplayer'
orconst Player = require('eosplayer')
- extend Player to create the glue layer, implement methods : eosClient and getIdentity
see scatterPlayer{if !this_eosClientthis_eosClient = myAwsomeConf;return this_eosClient;}async {return name: "myawsomename" authority: "active"}
- there some out-of-box implementation of player
- if you wanna reading data of the chain or signing and sending messages to the chain.
- if you need the player automatic fuse and switch node, readingPlayer is a good choice
- have fun
Updates
0.4.0
add
- Class: src/signPlayer
- Class: src/readingPlayer
0.3.0
add
- Class: helper/kh.js
- Class: utils/log.js
- Event: ERR_TRANSFER_FAILED
- Event: ERR_TRANSEND_FAILED
- Event: ERR_LOGOUT_FAILED
- Method: get eosplayer.kh
- Method: chain.getTable
- Method: chain.getActionCount
- Method: chain.getRecentActions
- Method: chain.getBalances
- Method: chain.getActions
- Method: chain.getAllActionsBatch
- Method: chain.checkTableMore
- Method: chain.transfer
- Method: chain.getPubKey
- Method: chain.getPubKeys
- Method: chain.recoverSign
- Method: chain.validateSign
- Method: player.getBalances
- Method: player.getAuth
- Method: player.newAccount
modify
- Method: the checkTableRange methods deals with 'more' now
- Method: chain.getBalance add param symbolName
Export
- Scatter: bigNumber
Deprecated
- eosplayer.waitTx (eosplayer.chain.waitTx instead)
- eosplayer.checkTable (eosplayer.chain.checkTable instead)
- eosplayer.checkTableRange (eosplayer.chain.checkTableRange instead)
- eosplayer.checkTableItem (eosplayer.chain.checkTableItem instead)
0.2.0 (no release)
add
- Class: chain.js
- Method: get eosplayer.chain
0.1.2
in this version, scatter are split from the Player.
add
- Module: scatterBinder
- Class: src/eosProvider
- Class: scatterBinder/scatterPlayer
- Method: void eventHandler.enableEvents(eventKeys)
remove
- Player.EventNames
modify
- Rename events :
- ERR_TRANSCAL_FAILED
- ERR_GET_SCATTER_FAILED
- ERR_GET_IDENTITY_FAILED
0.1.1
add
- async eosplayer.transfer(target, quantity, memo)
- async eosplayer.contract(code)
Contact
email : kinghand@tonarts.org
issue : https://github.com/bagaking/eosplayer/issues