Helper Functions

getCreateKeys | Code​

The getCreateKeys function is intended to create a new key pair in ~/.zeus/networks/development/accounts if a key pair does not already exist for the account provided. The sub directory to ~/.zeus/network can be any chain that you are developing on as well, e.g., kylin, jungle, mainnet. If an account name has a contract deployed to it with the deploy function, then a key pair will automatically be assigned during the deployment.
1
/**
2
* @param account - account name to generate or fetch keys for
3
*/
4
​
5
const { requireBox } = require('@liquidapps/box-utils');
6
const { getCreateKeys } = requireBox('eos-keystore/helpers/key-utils');
7
var keys = await getCreateKeys(account);
Copied!

artifacts | Code​

The artifacts helper pulls the relevant contract files, such as the wasm / ABI, to be used within the unit test.
1
/**
2
* @param f - contract name within the /contracts/eos directory
3
*/
4
​
5
const { requireBox } = require('@liquidapps/box-utils');
6
const artifacts =requireBox('seed-eos/tools/eos/artifacts');
7
var contractCode = 'mycontract';
8
var ctrt = artifacts.require(`./${contractCode}/`);
Copied!

deployer | Code​

The deployer function deploys a contract to an account based on the contract files and the account name passed. You may also pass your own args, if not specified, the getDefaultArgs() function will be passed.
1
/**
2
* @param contract - contract file name to deploy
3
* @param account - account name to deploy contract to
4
* @param [args=getDefaultArgs()] - arguments to be used for configuring the network's settings
5
*/
6
​
7
const { requireBox } = require('@liquidapps/box-utils');
8
const deployer = requireBox('seed-eos/tools/eos/deployer');
9
var ctrt = artifacts.require(`./${contractCode}/`);
10
const code = 'airairairair';
11
var deployedContract = await deployer.deploy(ctrt, code);
Copied!

genAllocateDAPPTokens | Code​

The genAllocateDAPPTokens function allocates DAPP tokens to the specified contract provided. It also issues, selects a package, stakes, and updates auth to include eosio.code.
1
/**
2
* @param deployedContract - deployed contract
3
* @param serviceName - DAPP Services name as determined in the groups/boxes/groups/services/SELECTED_SERVICE/models/dapp-services/SELECTED_SERVICE.json model file under the "name" key
4
* @param [provider=''] - DAPP Services Provider name, if non provided, 'pprovider1', 'pprovider2' will be used
5
* @param [selectedPackage='default'] - package name to select, defaults to "default"
6
*/
7
​
8
const { requireBox } = require('@liquidapps/box-utils');
9
const { genAllocateDAPPTokens } = requireBox('dapp-services/tools/eos/dapp-services');
10
await genAllocateDAPPTokens(deployedContract, 'ipfs');
Copied!

readVRAMData | Code​

The readVRAMData function makes a vRAM get table row call by providing the contract, key, table, and scope arguments.
1
/**
2
* @param contract - account name contract was deployed to
3
* @param key - primary key of the dapp::multi_index container
4
* @param table - table name as specified in the ABI
5
* @param scope - scope of dapp::multi_index container to read from
6
*/
7
​
8
const { requireBox } = require('@liquidapps/box-utils');
9
const { readVRAMData } = requireBox('dapp-services/tools/eos/dapp-services');
10
var tableRes = await readVRAMData({
11
contract: 'airairairair',
12
key: `AIRU`,
13
table: "accounts",
14
scope: 'tt11'
15
});
Copied!

getTestContract | Code​

The getTestContract function creates an EOSJS instance to be used for sending EOS transactions.
1
/**
2
* @param code - account name to use in setting up
3
*/
4
​
5
const { requireBox } = require('@liquidapps/box-utils');
6
const code = 'airairairair';
7
const { getTestContract } = requireBox('seed-eos/tools/eos/utils');
8
testcontract = await getTestContract(code);
9
await testcontract.create({
10
issuer: code,
11
maximum_supply: `1000000000.0000 ${symbol}`
12
}, {
13
authorization: `${code}@active`,
14
broadcast: true,
15
sign: true
16
});
Copied!
Last modified 1yr ago
Copy link
Contents