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.

/**
 * @param account - account name to generate or fetch keys for
 */

const { requireBox } = require('@liquidapps/box-utils');
const { getCreateKeys } = requireBox('eos-keystore/helpers/key-utils');
var keys = await getCreateKeys(account);

artifacts | Code

The artifacts helper pulls the relevant contract files, such as the wasm / ABI, to be used within the unit test.

/**
 * @param f - contract name within the /contracts/eos directory
 */

const { requireBox } = require('@liquidapps/box-utils');
const artifacts =requireBox('seed-eos/tools/eos/artifacts');
var contractCode = 'mycontract';
var ctrt = artifacts.require(`./${contractCode}/`);

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.

/**
 * @param contract - contract file name to deploy
 * @param account - account name to deploy contract to
 * @param [args=getDefaultArgs()] - arguments to be used for configuring the network's settings
 */

const { requireBox } = require('@liquidapps/box-utils');
const deployer = requireBox('seed-eos/tools/eos/deployer');
var ctrt = artifacts.require(`./${contractCode}/`);
const code = 'airairairair';
var deployedContract = await deployer.deploy(ctrt, code);

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.

/**
 * @param deployedContract - deployed contract
 * @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
 * @param [provider=''] - DAPP Services Provider name, if non provided, 'pprovider1', 'pprovider2' will be used
 * @param [selectedPackage='default'] - package name to select, defaults to "default"
 */

const { requireBox } = require('@liquidapps/box-utils');
const { genAllocateDAPPTokens } = requireBox('dapp-services/tools/eos/dapp-services');
await genAllocateDAPPTokens(deployedContract, 'ipfs');

readVRAMData | Code

The readVRAMData function makes a vRAM get table row call by providing the contract, key, table, and scope arguments.

/**
 * @param contract - account name contract was deployed to
 * @param key - primary key of the dapp::multi_index container
 * @param table - table name as specified in the ABI
 * @param scope - scope of dapp::multi_index container to read from
 */

const { requireBox } = require('@liquidapps/box-utils');
const { readVRAMData } = requireBox('dapp-services/tools/eos/dapp-services');
var tableRes = await readVRAMData({
    contract: 'airairairair',
    key: `AIRU`,
    table: "accounts",
    scope: 'tt11'
});

getTestContract | Code

The getTestContract function creates an EOSJS instance to be used for sending EOS transactions.

/**
 * @param code - account name to use in setting up 
 */

const { requireBox } = require('@liquidapps/box-utils');
const code = 'airairairair';
const { getTestContract } = requireBox('seed-eos/tools/eos/utils');
testcontract = await getTestContract(code);
await testcontract.create({
    issuer: code,
    maximum_supply: `1000000000.0000 ${symbol}`
}, {
    authorization: `${code}@active`,
    broadcast: true,
    sign: true
});

Last updated