Skip to content

Latest commit

 

History

History
226 lines (180 loc) · 8.05 KB

API.md

File metadata and controls

226 lines (180 loc) · 8.05 KB

Constants

TESTING_PUBLIC_KEY

This public key is used to initialize all accounts in the local blockchain and via createAccount It should be used as the active and owner keys when updating auth on accounts you create

eosjs : object

This is the standard eosjs library at the core of this library. You have access to the rpc and api members.

Functions

setupTestChain()

Sets up the test chain docker image. Must be the first function called in your suite. Only call once

sleep(milliseconds)Promise

Sleeps for the given milliseconds duration

randomWamAccount()string

Generates a random *.wam account name

createAccount(account, [bytes])Promise.<TransactionReceipt>

Create an account on the blockchain

setContract(account, wasmFile, abiFile)Promise.<TransactionReceipt>

Set a contract on a blockchain account

updateAuth(account, permission, parent)Promise.<TransactionReceipt>

Update permissions and keys on an account

linkauth(account, requirement, permission, type)Promise.<TransactionReceipt>

Link actions to an account permission

transfer(from, to, quantity, memo)Promise.<TransactionReceipt>

Transfer WAX

getTableRows(code, table, scope, [limit])Promise.<Array>

Get rows from a smart contract table

genericAction(account, name, data, authorization)Promise.<authorization>

Run a generic blockchain action

dedupeTapos()Tapos

Generates the tapos fields for a transaction such that the expireSecods field is randomly generated. This allows for a weak way to deduplicate repeated transactions, which can happen a lot in testing.

TESTING_PUBLIC_KEY

This public key is used to initialize all accounts in the local blockchain and via createAccount It should be used as the active and owner keys when updating auth on accounts you create

Kind: global constant

eosjs : object

This is the standard eosjs library at the core of this library. You have access to the rpc and api members.

Kind: global constant
Example

eosjs.rpc.get_table_rows(...)
eosjs.api.transact(...)

setupTestChain()

Sets up the test chain docker image. Must be the first function called in your suite. Only call once

Kind: global function
Api: public
Example

beforeAll(async () => {
  await setupTestChain():
});

sleep(milliseconds) ⇒ Promise

Sleeps for the given milliseconds duration

Kind: global function
Api: public

Param Type Description
milliseconds Number number of milliseconds to sleep

randomWamAccount() ⇒ string

Generates a random *.wam account name

Kind: global function
Returns: string - a random wam account
Api: public

createAccount(account, [bytes]) ⇒ Promise.<TransactionReceipt>

Create an account on the blockchain

Kind: global function
Returns: Promise.<TransactionReceipt> - transaction receipt
Api: public

Param Type Default Description
account string accouunt name to generate
[bytes] Number 1000000 number of RAM bytes to initialize the account with. Default 1000000

setContract(account, wasmFile, abiFile) ⇒ Promise.<TransactionReceipt>

Set a contract on a blockchain account

Kind: global function
Returns: Promise.<TransactionReceipt> - transaction receipt
Api: public

Param Type Description
account string accouunt to set the contract on
wasmFile string wasm file path to set
abiFile string abi file path to set

updateAuth(account, permission, parent) ⇒ Promise.<TransactionReceipt>

Update permissions and keys on an account

Kind: global function
Returns: Promise.<TransactionReceipt> - transaction receipt
Api: public

Param Type Description
account string accouunt to update
permission string permission to affect. Ex. 'active'
parent string parent of the above permission. Ex. 'owner'

linkauth(account, requirement, permission, type) ⇒ Promise.<TransactionReceipt>

Link actions to an account permission

Kind: global function
Returns: Promise.<TransactionReceipt> - transaction receipt
Api: public

Param Type Description
account string accouunt to update
requirement string permission required
permission string contract to associate
type string action to assocate on the code above

transfer(from, to, quantity, memo) ⇒ Promise.<TransactionReceipt>

Transfer WAX

Kind: global function
Returns: Promise.<TransactionReceipt> - transaction receipt
Api: public

Param Type Description
from string accouunt to send from
to string account to send to
quantity string amount of WAX to send. Ex: '1.00000000 WAX'
memo string arbitrary message

getTableRows(code, table, scope, [limit]) ⇒ Promise.<Array>

Get rows from a smart contract table

Kind: global function
Returns: Promise.<Array> - array of table entries
Api: public

Param Type Default Description
code string contract account to query
table string table in the contract to query
scope string scope for the table
[limit] Number 100 max rows to return. Default 100

genericAction(account, name, data, authorization) ⇒ Promise.<authorization>

Run a generic blockchain action

Kind: global function
Returns: Promise.<authorization> - transaction receipt
Api: public

Param Type Description
account string contract account
name string action to fire
data Object action data json
authorization Authorization authorization object. Ie the actor executing the action

dedupeTapos() ⇒ Tapos

Generates the tapos fields for a transaction such that the expireSecods field is randomly generated. This allows for a weak way to deduplicate repeated transactions, which can happen a lot in testing.

Kind: global function
Returns: Tapos - tapos object
Api: public
Example

eosjs.api.transact({
  actions: [...],
},
dedupeTapos());