hive engine prep
This commit is contained in:
parent
9e0da659f8
commit
fe7ce3ed00
|
@ -1 +0,0 @@
|
|||
contracts/bootstrap/*.js
|
10
README.md
10
README.md
|
@ -1,21 +1,21 @@
|
|||
# Steem Smart Contracts [![Build Status](https://travis-ci.org/harpagon210/steemsmartcontracts.svg?branch=master)](https://travis-ci.org/harpagon210/steemsmartcontracts)[![Coverage Status](https://coveralls.io/repos/github/harpagon210/steemsmartcontracts/badge.svg?branch=master)](https://coveralls.io/github/harpagon210/steemsmartcontracts?branch=master)
|
||||
# Hive Smart Contracts [![Build Status](https://travis-ci.org/harpagon210/steemsmartcontracts.svg?branch=master)](https://travis-ci.org/harpagon210/steemsmartcontracts)[![Coverage Status](https://coveralls.io/repos/github/harpagon210/steemsmartcontracts/badge.svg?branch=master)](https://coveralls.io/github/harpagon210/steemsmartcontracts?branch=master)
|
||||
|
||||
## 1. What is it?
|
||||
|
||||
Steem Smart Contracts is a sidechain powered by Steem, it allows you to perform actions on a decentralized database via the power of Smart Contracts.
|
||||
Hive Smart Contracts is a sidechain powered by Hive, it allows you to perform actions on a decentralized database via the power of Smart Contracts.
|
||||
|
||||
## 2. How does it work?
|
||||
|
||||
This is actually pretty easy, you basically need a Steem account and that's it. To interact with the Smart Contracts you simply post a message on the Steem blockchain (formatted in a specific way), the message will then be catched by the sidechain and processed.
|
||||
This is actually pretty easy, you basically need a Hive account and that's it. To interact with the Smart Contracts you simply post a message on the Hive blockchain (formatted in a specific way), the message will then be catched by the sidechain and processed.
|
||||
|
||||
## 3. Sidechain specifications
|
||||
- run on [node.js](https://nodejs.org)
|
||||
- database layer powered by [MongoDB](https://www.mongodb.com/)
|
||||
- Smart Contracts developed in Javascript
|
||||
- Smart Contracts run in a sandboxed Javascript Virtual Machine called [VM2](https://github.com/patriksimek/vm2)
|
||||
- a block on the sidechain is produced only if transactions are being parsed in a Steem block
|
||||
- a block on the sidechain is produced only if transactions are being parsed in a Hive block
|
||||
|
||||
## 4. Setup a Steem Smart Contracts node
|
||||
## 4. Setup a Hive Smart Contracts node
|
||||
|
||||
see wiki: https://github.com/harpagon210/steemsmartcontracts/wiki/How-to-setup-a-Steem-Smart-Contracts-node
|
||||
|
||||
|
|
6
app.js
6
app.js
|
@ -128,7 +128,7 @@ const unloadPlugin = async (plugin) => {
|
|||
return res;
|
||||
};
|
||||
|
||||
// start streaming the Steem blockchain and produce the sidechain blocks accordingly
|
||||
// start streaming the Hive blockchain and produce the sidechain blocks accordingly
|
||||
const start = async () => {
|
||||
let res = await loadPlugin(blockchain);
|
||||
if (res && res.payload === null) {
|
||||
|
@ -145,7 +145,7 @@ const start = async () => {
|
|||
const stop = async () => {
|
||||
await unloadPlugin(jsonRPCServer);
|
||||
await unloadPlugin(p2p);
|
||||
// get the last Steem block parsed
|
||||
// get the last Hive block parsed
|
||||
let res = null;
|
||||
const streamerPlugin = getPlugin(streamer);
|
||||
if (streamerPlugin) {
|
||||
|
@ -162,7 +162,7 @@ const stop = async () => {
|
|||
const saveConfig = (lastBlockParsed) => {
|
||||
logger.info('Saving config');
|
||||
const config = fs.readJSONSync('./config.json');
|
||||
config.startSteemBlock = lastBlockParsed;
|
||||
config.startHiveBlock = lastBlockParsed;
|
||||
fs.writeJSONSync('./config.json', config, { spaces: 4 });
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"apps": [{
|
||||
"name": "Steem Smart Contracts",
|
||||
"name": "Hive Smart Contracts",
|
||||
"script": "app.js",
|
||||
"kill_timeout": 120000,
|
||||
"treekill": false
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
{
|
||||
"chainId": "00000000000000000002",
|
||||
"chainId": "mainnet-hive",
|
||||
"rpcNodePort": 5000,
|
||||
"dataDirectory": "./data/",
|
||||
"databaseFileName": "database.db",
|
||||
"p2pPort": 5001,
|
||||
"databaseURL": "mongodb://localhost:27017",
|
||||
"databaseName": "hsc",
|
||||
"blocksLogFilePath": "./blocks.log",
|
||||
"autosaveInterval": 1800000,
|
||||
"javascriptVMTimeout": 10000,
|
||||
"streamNodes": [
|
||||
"https://api.steemit.com",
|
||||
"https://rpc.buildteam.io",
|
||||
"https://rpc.steemviz.com",
|
||||
"https://steemd.minnowsupportproject.org"
|
||||
"https://api.openhive.network",
|
||||
"https://api.hive.blog",
|
||||
"https://anyx.io",
|
||||
"https://api.hivekings.com"
|
||||
],
|
||||
"startSteemBlock": 29056257,
|
||||
"genesisSteemBlock": 29056257
|
||||
}
|
||||
"hiveAddressPrefix": "STM",
|
||||
"hiveChainId": "0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"startHiveBlock": 38287457,
|
||||
"genesisHiveBlock": 29862600,
|
||||
"witnessEnabled": false
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ const route = (message) => {
|
|||
} else if (plugins[to]) {
|
||||
plugins[to].cp.send(message);
|
||||
} else {
|
||||
console.error('ROUTING ERROR: ', message);
|
||||
console.error('ROUTING ERROR: ', message); // eslint-disable-line no-console
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -72,8 +72,8 @@ const loadPlugin = (newPlugin) => {
|
|||
plugin.name = newPlugin.PLUGIN_NAME;
|
||||
plugin.cp = fork(newPlugin.PLUGIN_PATH, [], { silent: true, detached: true });
|
||||
plugin.cp.on('message', msg => route(msg));
|
||||
plugin.cp.stdout.on('data', data => console.log(`[${newPlugin.PLUGIN_NAME}]`, data.toString()));
|
||||
plugin.cp.stderr.on('data', data => console.error(`[${newPlugin.PLUGIN_NAME}]`, data.toString()));
|
||||
plugin.cp.stdout.on('data', data => console.log(`[${newPlugin.PLUGIN_NAME}]`, data.toString())); // eslint-disable-line no-console
|
||||
plugin.cp.stderr.on('data', data => console.error(`[${newPlugin.PLUGIN_NAME}]`, data.toString())); // eslint-disable-line no-console
|
||||
|
||||
plugins[newPlugin.PLUGIN_NAME] = plugin;
|
||||
|
||||
|
@ -92,7 +92,7 @@ const unloadPlugin = async (plugin) => {
|
|||
return res;
|
||||
};
|
||||
|
||||
// start streaming the Steem blockchain and produce the sidechain blocks accordingly
|
||||
// start streaming the Hive blockchain and produce the sidechain blocks accordingly
|
||||
async function start() {
|
||||
let res = await loadPlugin(blockchain);
|
||||
if (res && res.payload === null) {
|
||||
|
@ -112,7 +112,7 @@ async function stop(callback) {
|
|||
|
||||
function saveConfig(lastBlockParsed) {
|
||||
const config = fs.readJSONSync('./config.json');
|
||||
config.startSteemBlock = lastBlockParsed;
|
||||
config.startHiveBlock = lastBlockParsed;
|
||||
fs.writeJSONSync('./config.json', config, { spaces: 4 });
|
||||
}
|
||||
|
||||
|
|
20
config.json
20
config.json
|
@ -1,18 +1,20 @@
|
|||
{
|
||||
"chainId": "testnet1",
|
||||
"chainId": "mainnet-hive",
|
||||
"rpcNodePort": 5000,
|
||||
"p2pPort": 5001,
|
||||
"databaseURL": "mongodb://localhost:27017",
|
||||
"databaseName": "ssctestnet1",
|
||||
"databaseName": "hsc",
|
||||
"blocksLogFilePath": "./blocks.log",
|
||||
"javascriptVMTimeout": 10000,
|
||||
"streamNodes": [
|
||||
"https://api.steemit.com",
|
||||
"https://anyx.io"
|
||||
"https://api.openhive.network",
|
||||
"https://api.hive.blog",
|
||||
"https://anyx.io",
|
||||
"https://api.hivekings.com"
|
||||
],
|
||||
"steemAddressPrefix": "STM",
|
||||
"steemChainId": "0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"startSteemBlock": 38287457,
|
||||
"genesisSteemBlock": 29862600,
|
||||
"witnessEnabled": true
|
||||
"hiveAddressPrefix": "STM",
|
||||
"hiveChainId": "0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"startHiveBlock": 41945328,
|
||||
"genesisHiveBlock": 41945328,
|
||||
"witnessEnabled": false
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ const { Transaction } = require('../../libs/Transaction');
|
|||
const { CONSTANTS } = require('../../libs/Constants');
|
||||
|
||||
class Bootstrap {
|
||||
static async getBootstrapTransactions(genesisSteemBlock) {
|
||||
static async getBootstrapTransactions(genesisHiveBlock) {
|
||||
const transactions = [];
|
||||
|
||||
let contractCode;
|
||||
|
@ -15,9 +15,9 @@ class Bootstrap {
|
|||
contractCode = await fs.readFileSync('./contracts/bootstrap/tokens.js');
|
||||
contractCode = contractCode.toString();
|
||||
|
||||
contractCode = contractCode.replace(/'\$\{BP_CONSTANTS.UTILITY_TOKEN_PRECISION\}\$'/g, CONSTANTS.UTILITY_TOKEN_PRECISION);
|
||||
contractCode = contractCode.replace(/'\$\{BP_CONSTANTS.UTILITY_TOKEN_SYMBOL\}\$'/g, CONSTANTS.UTILITY_TOKEN_SYMBOL);
|
||||
contractCode = contractCode.replace(/'\$\{FORK_BLOCK_NUMBER\}\$'/g, CONSTANTS.FORK_BLOCK_NUMBER);
|
||||
contractCode = contractCode.replace(/'\$\{CONSTANTS.UTILITY_TOKEN_PRECISION\}\$'/g, CONSTANTS.UTILITY_TOKEN_PRECISION);
|
||||
contractCode = contractCode.replace(/'\$\{CONSTANTS.UTILITY_TOKEN_SYMBOL\}\$'/g, CONSTANTS.UTILITY_TOKEN_SYMBOL);
|
||||
contractCode = contractCode.replace(/'\$\{CONSTANTS.HIVE_PEGGED_SYMBOL\}\$'/g, CONSTANTS.HIVE_PEGGED_SYMBOL);
|
||||
|
||||
base64ContractCode = Base64.encode(contractCode);
|
||||
|
||||
|
@ -27,50 +27,27 @@ class Bootstrap {
|
|||
code: base64ContractCode,
|
||||
};
|
||||
|
||||
transactions.push(new Transaction(genesisSteemBlock, 0, 'steemsc', 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(genesisHiveBlock, 0, CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
|
||||
// sscstore contract
|
||||
contractCode = await fs.readFileSync('./contracts/bootstrap/sscstore.js');
|
||||
// hive-pegged asset contract
|
||||
contractCode = await fs.readFileSync('./contracts/bootstrap/hivepegged.js');
|
||||
contractCode = contractCode.toString();
|
||||
|
||||
contractCode = contractCode.replace(/'\$\{BP_CONSTANTS.UTILITY_TOKEN_PRECISION\}\$'/g, CONSTANTS.UTILITY_TOKEN_PRECISION);
|
||||
contractCode = contractCode.replace(/'\$\{BP_CONSTANTS.UTILITY_TOKEN_SYMBOL\}\$'/g, CONSTANTS.UTILITY_TOKEN_SYMBOL);
|
||||
contractCode = contractCode.replace(/'\$\{FORK_BLOCK_NUMBER\}\$'/g, CONSTANTS.FORK_BLOCK_NUMBER);
|
||||
contractCode = contractCode.replace(/'\$\{SSC_STORE_PRICE\}\$'/g, CONSTANTS.SSC_STORE_PRICE);
|
||||
contractCode = contractCode.replace(/'\$\{SSC_STORE_QTY\}\$'/g, CONSTANTS.SSC_STORE_QTY);
|
||||
contractCode = contractCode.replace(/'\$\{CONSTANTS.ACCOUNT_RECEIVING_FEES\}\$'/g, CONSTANTS.ACCOUNT_RECEIVING_FEES);
|
||||
|
||||
base64ContractCode = Base64.encode(contractCode);
|
||||
|
||||
contractPayload = {
|
||||
name: 'sscstore',
|
||||
name: 'hivepegged',
|
||||
params: '',
|
||||
code: base64ContractCode,
|
||||
};
|
||||
|
||||
transactions.push(new Transaction(genesisSteemBlock, 0, 'steemsc', 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
|
||||
// steem-pegged asset contract
|
||||
contractCode = await fs.readFileSync('./contracts/bootstrap/steempegged.js');
|
||||
contractCode = contractCode.toString();
|
||||
|
||||
contractCode = contractCode.replace(/'\$\{ACCOUNT_RECEIVING_FEES\}\$'/g, CONSTANTS.ACCOUNT_RECEIVING_FEES);
|
||||
|
||||
base64ContractCode = Base64.encode(contractCode);
|
||||
|
||||
contractPayload = {
|
||||
name: 'steempegged',
|
||||
params: '',
|
||||
code: base64ContractCode,
|
||||
};
|
||||
|
||||
transactions.push(new Transaction(genesisSteemBlock, 0, CONSTANTS.STEEM_PEGGED_ACCOUNT, 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(genesisHiveBlock, 0, CONSTANTS.HIVE_PEGGED_ACCOUNT, 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
|
||||
contractCode = await fs.readFileSync('./contracts/bootstrap/market.js');
|
||||
contractCode = contractCode.toString();
|
||||
|
||||
contractCode = contractCode.replace(/'\$\{FORK_BLOCK_NUMBER_TWO\}\$'/g, CONSTANTS.FORK_BLOCK_NUMBER_TWO);
|
||||
contractCode = contractCode.replace(/'\$\{FORK_BLOCK_NUMBER_THREE\}\$'/g, CONSTANTS.FORK_BLOCK_NUMBER_THREE);
|
||||
|
||||
base64ContractCode = Base64.encode(contractCode);
|
||||
|
||||
contractPayload = {
|
||||
|
@ -79,26 +56,60 @@ class Bootstrap {
|
|||
code: base64ContractCode,
|
||||
};
|
||||
|
||||
transactions.push(new Transaction(genesisSteemBlock, 0, 'null', 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(genesisHiveBlock, 0, 'null', 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
|
||||
contractCode = await fs.readFileSync('./contracts/bootstrap/nft.js');
|
||||
contractCode = contractCode.toString();
|
||||
contractCode = contractCode.replace(/'\$\{CONSTANTS.UTILITY_TOKEN_SYMBOL\}\$'/g, CONSTANTS.UTILITY_TOKEN_SYMBOL);
|
||||
|
||||
base64ContractCode = Base64.encode(contractCode);
|
||||
|
||||
contractPayload = {
|
||||
name: 'nft',
|
||||
params: '',
|
||||
code: base64ContractCode,
|
||||
};
|
||||
|
||||
transactions.push(new Transaction(genesisHiveBlock, 0, CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
|
||||
contractCode = await fs.readFileSync('./contracts/bootstrap/nftmarket.js');
|
||||
contractCode = contractCode.toString();
|
||||
|
||||
base64ContractCode = Base64.encode(contractCode);
|
||||
|
||||
contractPayload = {
|
||||
name: 'nftmarket',
|
||||
params: '',
|
||||
code: base64ContractCode,
|
||||
};
|
||||
|
||||
transactions.push(new Transaction(genesisHiveBlock, 0, CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
|
||||
contractCode = await fs.readFileSync('./contracts/bootstrap/inflation.js');
|
||||
contractCode = contractCode.toString();
|
||||
contractCode = contractCode.replace(/'\$\{CONSTANTS.UTILITY_TOKEN_SYMBOL\}\$'/g, CONSTANTS.UTILITY_TOKEN_SYMBOL);
|
||||
contractCode = contractCode.replace(/'\$\{CONSTANTS.HIVE_ENGINE_ACCOUNT\}\$'/g, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
|
||||
base64ContractCode = Base64.encode(contractCode);
|
||||
|
||||
contractPayload = {
|
||||
name: 'inflation',
|
||||
params: '',
|
||||
code: base64ContractCode,
|
||||
};
|
||||
|
||||
transactions.push(new Transaction(genesisHiveBlock, 0, 'null', 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
|
||||
// bootstrap transactions
|
||||
transactions.push(new Transaction(genesisSteemBlock, 0, 'null', 'tokens', 'create', `{ "name": "Steem Engine Token", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "precision": ${CONSTANTS.UTILITY_TOKEN_PRECISION}, "maxSupply": ${Number.MAX_SAFE_INTEGER} }`));
|
||||
transactions.push(new Transaction(genesisSteemBlock, 0, 'null', 'tokens', 'updateMetadata', `{"symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "metadata": { "url":"https://steem-engine.com", "icon": "https://s3.amazonaws.com/steem-engine/images/icon_steem-engine_gradient.svg", "desc": "ENG is the native token for the Steem Engine platform" }}`));
|
||||
transactions.push(new Transaction(genesisSteemBlock, 0, 'null', 'tokens', 'issue', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "steemsc", "quantity": 2000000, "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(genesisSteemBlock, 0, 'null', 'tokens', 'issue', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": 1000000, "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(genesisSteemBlock, 0, 'null', 'tokens', 'issue', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "steemmonsters", "quantity": 1000000, "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(genesisSteemBlock, 0, CONSTANTS.STEEM_PEGGED_ACCOUNT, 'tokens', 'create', '{ "name": "STEEM Pegged", "symbol": "STEEMP", "precision": 3, "maxSupply": 1000000000000 }'));
|
||||
transactions.push(new Transaction(genesisSteemBlock, 0, CONSTANTS.STEEM_PEGGED_ACCOUNT, 'tokens', 'updateMetadata', '{"symbol":"STEEMP", "metadata": { "desc": "STEEM backed by the steem-engine team" }}'));
|
||||
transactions.push(new Transaction(genesisSteemBlock, 0, 'btcpeg', 'tokens', 'create', '{ "name": "BITCOIN Pegged", "symbol": "BTCP", "precision": 8, "maxSupply": 1000000000000 }'));
|
||||
transactions.push(new Transaction(genesisSteemBlock, 0, 'btcpeg', 'tokens', 'updateMetadata', '{"symbol":"BTCP", "metadata": { "desc": "BITCOIN backed by the steem-engine team" }}'));
|
||||
transactions.push(new Transaction(genesisSteemBlock, 0, 'ltcp', 'tokens', 'create', '{ "name": "LITECOIN Pegged", "symbol": "LTCP", "precision": 8, "maxSupply": 1000000000000 }'));
|
||||
transactions.push(new Transaction(genesisSteemBlock, 0, 'ltcp', 'tokens', 'updateMetadata', '{"symbol":"LTCP", "metadata": { "desc": "LITECOIN backed by the steem-engine team" }}'));
|
||||
transactions.push(new Transaction(genesisSteemBlock, 0, 'dogep', 'tokens', 'create', '{ "name": "DOGECOIN Pegged", "symbol": "DOGEP", "precision": 8, "maxSupply": 1000000000000 }'));
|
||||
transactions.push(new Transaction(genesisSteemBlock, 0, 'dogep', 'tokens', 'updateMetadata', '{"symbol":"DOGEP", "metadata": { "desc": "DOGECOIN backed by the steem-engine team" }}'));
|
||||
transactions.push(new Transaction(genesisSteemBlock, 0, 'bchp', 'tokens', 'create', '{ "name": "BITCOIN CASH Pegged", "symbol": "BCHP", "precision": 8, "maxSupply": 1000000000000 }'));
|
||||
transactions.push(new Transaction(genesisSteemBlock, 0, 'bchp', 'tokens', 'updateMetadata', '{"symbol":"BCHP", "metadata": { "desc": "BITCOIN CASH backed by the steem-engine team" }}'));
|
||||
transactions.push(new Transaction(genesisSteemBlock, 0, 'steemsc', 'tokens', 'updateParams', `{ "tokenCreationFee": "${CONSTANTS.INITIAL_TOKEN_CREATION_FEE}" }`));
|
||||
transactions.push(new Transaction(genesisSteemBlock, 0, CONSTANTS.STEEM_PEGGED_ACCOUNT, 'tokens', 'issue', `{ "symbol": "STEEMP", "to": "${CONSTANTS.STEEM_PEGGED_ACCOUNT}", "quantity": 1000000000000, "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(genesisHiveBlock, 0, 'null', 'tokens', 'create', `{ "name": "Hive Engine Token", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "precision": ${CONSTANTS.UTILITY_TOKEN_PRECISION}, "maxSupply": "${Number.MAX_SAFE_INTEGER}", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(genesisHiveBlock, 0, 'null', 'tokens', 'enableStaking', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "unstakingCooldown": 40, "numberTransactions": 4, "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(genesisHiveBlock, 0, 'null', 'tokens', 'enableDelegation', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "undelegationCooldown": 7, "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(genesisHiveBlock, 0, 'null', 'tokens', 'updateMetadata', `{"symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "metadata": { "url":"https://hive-engine.com", "icon": "https://s3.amazonaws.com/steem-engine/images/icon_steem-engine_gradient.svg", "desc": "BEE is the native token for the Hive Engine platform" }}`));
|
||||
transactions.push(new Transaction(genesisHiveBlock, 0, 'null', 'tokens', 'issue', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "${CONSTANTS.HIVE_ENGINE_ACCOUNT}", "quantity": "1500000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(genesisHiveBlock, 0, CONSTANTS.HIVE_PEGGED_ACCOUNT, 'tokens', 'create', `{ "name": "HIVE Pegged", "symbol": "${CONSTANTS.HIVE_PEGGED_SYMBOL}", "precision": 8, "maxSupply": "${Number.MAX_SAFE_INTEGER}", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(genesisHiveBlock, 0, CONSTANTS.HIVE_PEGGED_ACCOUNT, 'tokens', 'updateMetadata', '{"symbol":"SWAP.HIVE", "metadata": { "desc": "HIVE backed by the hive-engine team" }}'));
|
||||
transactions.push(new Transaction(genesisHiveBlock, 0, CONSTANTS.HIVE_PEGGED_ACCOUNT, 'tokens', 'issue', `{ "symbol": "${CONSTANTS.HIVE_PEGGED_SYMBOL}", "to": "${CONSTANTS.HIVE_PEGGED_ACCOUNT}", "quantity": "${Number.MAX_SAFE_INTEGER}", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(genesisHiveBlock, 0, CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'updateParams', `{ "tokenCreationFee": "${CONSTANTS.INITIAL_TOKEN_CREATION_FEE}", "enableDelegationFee": "${CONSTANTS.INITIAL_DELEGATION_ENABLEMENT_FEE}", "enableStakingFee": "${CONSTANTS.INITIAL_STAKING_ENABLEMENT_FEE}" }`));
|
||||
|
||||
return transactions;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ const initiateWithdrawal = async (id, recipient, quantity, memo) => {
|
|||
const withdrawal = {};
|
||||
|
||||
withdrawal.id = id;
|
||||
withdrawal.type = 'STEEM';
|
||||
withdrawal.type = 'HIVE';
|
||||
withdrawal.recipient = recipient;
|
||||
withdrawal.memo = memo;
|
||||
withdrawal.quantity = quantity;
|
||||
|
@ -22,20 +22,20 @@ actions.createSSC = async () => {
|
|||
};
|
||||
|
||||
actions.buy = async (payload) => {
|
||||
const { recipient, amountSTEEMSBD, isSignedWithActiveKey } = payload;
|
||||
const { recipient, amountHIVEHBD, isSignedWithActiveKey } = payload;
|
||||
|
||||
if (recipient !== api.owner) return;
|
||||
|
||||
if (recipient && amountSTEEMSBD && isSignedWithActiveKey) {
|
||||
const res = amountSTEEMSBD.split(' ');
|
||||
if (recipient && amountHIVEHBD && isSignedWithActiveKey) {
|
||||
const res = amountHIVEHBD.split(' ');
|
||||
|
||||
const unit = res[1];
|
||||
|
||||
// STEEM
|
||||
if (api.assert(unit === 'STEEM', 'only STEEM can be used')) {
|
||||
// HIVE
|
||||
if (api.assert(unit === 'HIVE', 'only HIVE can be used')) {
|
||||
let quantityToSend = res[0];
|
||||
|
||||
// calculate the 1% fee (with a min of 0.001 STEEM)
|
||||
// calculate the 1% fee (with a min of 0.001 HIVE)
|
||||
let fee = api.BigNumber(quantityToSend).multipliedBy(0.01).toFixed(3);
|
||||
|
||||
if (api.BigNumber(fee).lt('0.001')) {
|
||||
|
@ -45,7 +45,7 @@ actions.buy = async (payload) => {
|
|||
quantityToSend = api.BigNumber(quantityToSend).minus(fee).toFixed(3);
|
||||
|
||||
if (api.BigNumber(quantityToSend).gt(0)) {
|
||||
await api.executeSmartContractAsOwner('tokens', 'transfer', { symbol: 'STEEMP', quantity: quantityToSend, to: api.sender });
|
||||
await api.executeSmartContractAsOwner('tokens', 'transfer', { symbol: 'SWAP.HIVE', quantity: quantityToSend, to: api.sender });
|
||||
}
|
||||
|
||||
if (api.BigNumber(fee).gt(0)) {
|
||||
|
@ -67,7 +67,7 @@ actions.withdraw = async (payload) => {
|
|||
&& api.BigNumber(quantity).dp() <= 3, 'invalid params')
|
||||
&& api.assert(api.BigNumber(quantity).gte(0.002), 'minimum withdrawal is 0.002')
|
||||
) {
|
||||
// calculate the 1% fee (with a min of 0.001 STEEM)
|
||||
// calculate the 1% fee (with a min of 0.001 HIVE)
|
||||
let fee = api.BigNumber(quantity).multipliedBy(0.01).toFixed(3);
|
||||
|
||||
if (api.BigNumber(fee).lt('0.001')) {
|
||||
|
@ -77,10 +77,10 @@ actions.withdraw = async (payload) => {
|
|||
const quantityToSend = api.BigNumber(quantity).minus(fee).toFixed(3);
|
||||
|
||||
if (api.BigNumber(quantityToSend).gt(0)) {
|
||||
const res = await api.executeSmartContract('tokens', 'transfer', { symbol: 'STEEMP', quantity, to: api.owner });
|
||||
const res = await api.executeSmartContract('tokens', 'transfer', { symbol: 'SWAP.HIVE', quantity, to: api.owner });
|
||||
|
||||
if (res.errors === undefined
|
||||
&& res.events && res.events.find(el => el.contract === 'tokens' && el.event === 'transfer' && el.data.from === api.sender && el.data.to === api.owner && el.data.quantity === quantity && el.data.symbol === 'STEEMP') !== undefined) {
|
||||
&& res.events && res.events.find(el => el.contract === 'tokens' && el.event === 'transfer' && el.data.from === api.sender && el.data.to === api.owner && el.data.quantity === quantity && el.data.symbol === 'SWAP.HIVE') !== undefined) {
|
||||
// withdrawal
|
||||
let memo = `withdrawal tx ${api.transactionId}`;
|
||||
|
||||
|
@ -102,12 +102,7 @@ actions.removeWithdrawal = async (payload) => {
|
|||
if (api.sender !== api.owner) return;
|
||||
|
||||
if (id && isSignedWithActiveKey) {
|
||||
let finalId = id;
|
||||
if (api.refSteemBlockNumber >= 31248438 && api.refSteemBlockNumber <= 31262296) {
|
||||
finalId = finalId.replace('-0', '');
|
||||
}
|
||||
|
||||
const withdrawal = await api.db.findOne('withdrawals', { id: finalId });
|
||||
const withdrawal = await api.db.findOne('withdrawals', { id });
|
||||
|
||||
if (withdrawal) {
|
||||
await api.db.remove('withdrawals', withdrawal);
|
|
@ -0,0 +1,32 @@
|
|||
/* eslint-disable no-await-in-loop */
|
||||
/* global actions, api */
|
||||
|
||||
// eslint-disable-next-line no-template-curly-in-string
|
||||
const UTILITY_TOKEN_SYMBOL = "'${CONSTANTS.UTILITY_TOKEN_SYMBOL}$'";
|
||||
// eslint-disable-next-line no-template-curly-in-string
|
||||
const HIVE_ENGINE_ACCOUNT = "'${CONSTANTS.HIVE_ENGINE_ACCOUNT}$'";
|
||||
|
||||
actions.createSSC = async () => {
|
||||
|
||||
};
|
||||
|
||||
actions.issueNewTokens = async () => {
|
||||
if (api.sender !== 'null') return;
|
||||
|
||||
// issue tokens to HIVE_ENGINE_ACCOUNT
|
||||
// 100k tokens per year = 11.41552511 tokens per hour (an hour = 1200 blocks)
|
||||
let nbTokens = '11.41552511';
|
||||
await api.executeSmartContract('tokens', 'issue',
|
||||
{ symbol: UTILITY_TOKEN_SYMBOL, quantity: nbTokens, to: HIVE_ENGINE_ACCOUNT });
|
||||
|
||||
// issue tokens to engpool
|
||||
// 100k tokens per year = 11.41552511 tokens per hour (an hour = 1200 blocks)
|
||||
nbTokens = '11.41552511';
|
||||
await api.executeSmartContract('tokens', 'issue', { symbol: UTILITY_TOKEN_SYMBOL, quantity: nbTokens, to: 'hive-miner' });
|
||||
|
||||
// issue tokens to "witnesses" contract
|
||||
// 200k tokens per year = 22.83105022 tokens per hour (an hour = 1200 blocks)
|
||||
// nbTokens = '22.83105022';
|
||||
// await api.executeSmartContract('tokens', 'issueToContract',
|
||||
// { symbol: UTILITY_TOKEN_SYMBOL, quantity: nbTokens, to: 'witnesses' });
|
||||
};
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,752 @@
|
|||
/* eslint-disable no-await-in-loop */
|
||||
/* eslint-disable max-len */
|
||||
/* eslint-disable prefer-template */
|
||||
/* eslint-disable no-underscore-dangle */
|
||||
/* global actions, api */
|
||||
|
||||
const CONTRACT_NAME = 'nftmarket';
|
||||
|
||||
// cannot buy or sell more than this number of NFT instances in one action
|
||||
const MAX_NUM_UNITS_OPERABLE = 50;
|
||||
|
||||
actions.createSSC = async () => {
|
||||
// nothing to do here
|
||||
};
|
||||
|
||||
// check that token transfers succeeded
|
||||
const isTokenTransferVerified = (result, from, to, symbol, quantity, eventStr) => {
|
||||
if (result.errors === undefined
|
||||
&& result.events && result.events.find(el => el.contract === 'tokens' && el.event === eventStr
|
||||
&& el.data.from === from && el.data.to === to && el.data.quantity === quantity && el.data.symbol === symbol) !== undefined) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
const countDecimals = value => api.BigNumber(value).dp();
|
||||
|
||||
// a valid Hive account is between 3 and 16 characters in length
|
||||
const isValidHiveAccountLength = account => account.length >= 3 && account.length <= 16;
|
||||
|
||||
// helper for buy action
|
||||
const makeMapKey = (account, type) => account + '-' + type;
|
||||
|
||||
// helper for updating open interest
|
||||
const makeGroupingKey = (grouping, groupBy) => {
|
||||
let key = '';
|
||||
groupBy.forEach((name) => {
|
||||
key = key + ':' + name + ':' + grouping[name];
|
||||
});
|
||||
return key;
|
||||
};
|
||||
|
||||
const isValidIdArray = (arr) => {
|
||||
try {
|
||||
if (!api.assert(arr && typeof arr === 'object' && Array.isArray(arr), 'invalid id list')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!api.assert(arr.length <= MAX_NUM_UNITS_OPERABLE, `cannot act on more than ${MAX_NUM_UNITS_OPERABLE} IDs at once`)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = 0; i < arr.length; i += 1) {
|
||||
const id = arr[i];
|
||||
if (!api.assert(id && typeof id === 'string' && !api.BigNumber(id).isNaN() && api.BigNumber(id).gt(0), 'invalid id list')) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
actions.enableMarket = async (payload) => {
|
||||
const {
|
||||
symbol,
|
||||
isSignedWithActiveKey,
|
||||
} = payload;
|
||||
|
||||
if (api.assert(isSignedWithActiveKey === true, 'you must use a custom_json signed with your active key')
|
||||
&& api.assert(symbol && typeof symbol === 'string', 'invalid params')) {
|
||||
// make sure NFT exists and verify ownership
|
||||
const nft = await api.db.findOneInTable('nft', 'nfts', { symbol });
|
||||
if (api.assert(nft !== null, 'symbol does not exist')
|
||||
&& api.assert(nft.issuer === api.sender, 'must be the issuer')) {
|
||||
// create a new table to hold market orders for this NFT
|
||||
// eslint-disable-next-line prefer-template
|
||||
const marketTableName = symbol + 'sellBook';
|
||||
const metricsTableName = symbol + 'openInterest';
|
||||
const historyTableName = symbol + 'tradesHistory';
|
||||
const tableExists = await api.db.tableExists(marketTableName);
|
||||
if (api.assert(tableExists === false, 'market already enabled')) {
|
||||
await api.db.createTable(marketTableName, ['ownedBy', 'account', 'nftId', 'grouping', 'priceSymbol']);
|
||||
await api.db.createTable(metricsTableName, ['side', 'priceSymbol', 'grouping']);
|
||||
await api.db.createTable(historyTableName, ['priceSymbol', 'timestamp']);
|
||||
|
||||
api.emit('enableMarket', { symbol });
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const updateOpenInterest = async (side, symbol, priceSymbol, groups, groupBy) => {
|
||||
const metricsTableName = symbol + 'openInterest';
|
||||
|
||||
// collect all the groupings to fetch
|
||||
const groupKeys = [];
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const info of Object.values(groups)) {
|
||||
groupKeys.push(info.grouping);
|
||||
}
|
||||
|
||||
if (groupKeys.length <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const openInterest = await api.db.find(
|
||||
metricsTableName,
|
||||
{
|
||||
side,
|
||||
priceSymbol,
|
||||
grouping: {
|
||||
$in: groupKeys,
|
||||
},
|
||||
},
|
||||
MAX_NUM_UNITS_OPERABLE,
|
||||
0,
|
||||
[{ index: 'side', descending: false }, { index: 'priceSymbol', descending: false }, { index: 'grouping', descending: false }],
|
||||
);
|
||||
|
||||
// update existing records...
|
||||
for (let i = 0; i < openInterest.length; i += 1) {
|
||||
const metric = openInterest[i];
|
||||
const key = makeGroupingKey(metric.grouping, groupBy);
|
||||
if (key in groups) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
groups[key].isInCollection = true;
|
||||
metric.count += groups[key].count;
|
||||
if (metric.count < 0) {
|
||||
metric.count = 0; // shouldn't happen, but need to safeguard
|
||||
}
|
||||
|
||||
await api.db.update(metricsTableName, metric);
|
||||
}
|
||||
}
|
||||
|
||||
// ...and add new ones
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const info of Object.values(groups)) {
|
||||
if (!info.isInCollection) {
|
||||
const finalCount = info.count > 0 ? info.count : 0;
|
||||
const newMetric = {
|
||||
side,
|
||||
priceSymbol,
|
||||
grouping: info.grouping,
|
||||
count: finalCount,
|
||||
};
|
||||
|
||||
await api.db.insert(metricsTableName, newMetric);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const updateTradesHistory = async (type, account, ownedBy, counterparties, symbol, priceSymbol, price, marketAccount, fee, volume) => {
|
||||
const blockDate = new Date(`${api.hiveBlockTimestamp}.000Z`);
|
||||
const timestampSec = blockDate.getTime() / 1000;
|
||||
const timestampMinus24hrs = blockDate.setDate(blockDate.getDate() - 1) / 1000;
|
||||
const historyTableName = symbol + 'tradesHistory';
|
||||
|
||||
// clean history
|
||||
let tradesToDelete = await api.db.find(
|
||||
historyTableName,
|
||||
{
|
||||
priceSymbol,
|
||||
timestamp: {
|
||||
$lt: timestampMinus24hrs,
|
||||
},
|
||||
},
|
||||
);
|
||||
let nbTradesToDelete = tradesToDelete.length;
|
||||
|
||||
while (nbTradesToDelete > 0) {
|
||||
for (let index = 0; index < nbTradesToDelete; index += 1) {
|
||||
const trade = tradesToDelete[index];
|
||||
await api.db.remove(historyTableName, trade);
|
||||
}
|
||||
tradesToDelete = await api.db.find(
|
||||
historyTableName,
|
||||
{
|
||||
priceSymbol,
|
||||
timestamp: {
|
||||
$lt: timestampMinus24hrs,
|
||||
},
|
||||
},
|
||||
);
|
||||
nbTradesToDelete = tradesToDelete.length;
|
||||
}
|
||||
// add order to the history
|
||||
const newTrade = {};
|
||||
newTrade.type = type;
|
||||
newTrade.account = account;
|
||||
newTrade.ownedBy = ownedBy;
|
||||
newTrade.counterparties = counterparties;
|
||||
newTrade.priceSymbol = priceSymbol;
|
||||
newTrade.price = price;
|
||||
newTrade.marketAccount = marketAccount;
|
||||
newTrade.fee = fee;
|
||||
newTrade.timestamp = timestampSec;
|
||||
newTrade.volume = volume;
|
||||
await api.db.insert(historyTableName, newTrade);
|
||||
};
|
||||
|
||||
actions.changePrice = async (payload) => {
|
||||
const {
|
||||
symbol,
|
||||
nfts,
|
||||
price,
|
||||
isSignedWithActiveKey,
|
||||
} = payload;
|
||||
|
||||
if (!api.assert(symbol && typeof symbol === 'string', 'invalid params')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const marketTableName = symbol + 'sellBook';
|
||||
const tableExists = await api.db.tableExists(marketTableName);
|
||||
|
||||
if (api.assert(isSignedWithActiveKey === true, 'you must use a custom_json signed with your active key')
|
||||
&& isValidIdArray(nfts)
|
||||
&& api.assert(price && typeof price === 'string' && !api.BigNumber(price).isNaN(), 'invalid params')
|
||||
&& api.assert(tableExists, 'market not enabled for symbol')) {
|
||||
// look up order info
|
||||
const orders = await api.db.find(
|
||||
marketTableName,
|
||||
{
|
||||
nftId: {
|
||||
$in: nfts,
|
||||
},
|
||||
},
|
||||
MAX_NUM_UNITS_OPERABLE,
|
||||
0,
|
||||
[{ index: 'nftId', descending: false }],
|
||||
);
|
||||
|
||||
if (orders.length > 0) {
|
||||
// need to make sure that caller is actually the owner of each order
|
||||
// and all orders have the same price symbol
|
||||
let priceSymbol = '';
|
||||
for (let i = 0; i < orders.length; i += 1) {
|
||||
const order = orders[i];
|
||||
if (priceSymbol === '') {
|
||||
({ priceSymbol } = order);
|
||||
}
|
||||
if (!api.assert(order.account === api.sender
|
||||
&& order.ownedBy === 'u', 'all orders must be your own')
|
||||
|| !api.assert(priceSymbol === order.priceSymbol, 'all orders must have the same price symbol')) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// get the price token params
|
||||
const token = await api.db.findOneInTable('tokens', 'tokens', { symbol: priceSymbol });
|
||||
if (api.assert(token
|
||||
&& api.BigNumber(price).gt(0)
|
||||
&& countDecimals(price) <= token.precision, 'invalid price')) {
|
||||
const finalPrice = api.BigNumber(price).toFixed(token.precision);
|
||||
for (let i = 0; i < orders.length; i += 1) {
|
||||
const order = orders[i];
|
||||
const oldPrice = order.price;
|
||||
order.price = finalPrice;
|
||||
order.priceDec = { $numberDecimal: finalPrice };
|
||||
|
||||
await api.db.update(marketTableName, order);
|
||||
|
||||
api.emit('changePrice', {
|
||||
symbol,
|
||||
nftId: order.nftId,
|
||||
oldPrice,
|
||||
newPrice: order.price,
|
||||
priceSymbol: order.priceSymbol,
|
||||
orderId: order._id,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
actions.cancel = async (payload) => {
|
||||
const {
|
||||
symbol,
|
||||
nfts,
|
||||
isSignedWithActiveKey,
|
||||
} = payload;
|
||||
|
||||
if (!api.assert(symbol && typeof symbol === 'string', 'invalid params')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const marketTableName = symbol + 'sellBook';
|
||||
const tableExists = await api.db.tableExists(marketTableName);
|
||||
|
||||
if (api.assert(isSignedWithActiveKey === true, 'you must use a custom_json signed with your active key')
|
||||
&& isValidIdArray(nfts)
|
||||
&& api.assert(tableExists, 'market not enabled for symbol')) {
|
||||
const nft = await api.db.findOneInTable('nft', 'nfts', { symbol });
|
||||
if (!api.assert(nft && nft.groupBy && nft.groupBy.length > 0, 'market grouping not set')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// look up order info
|
||||
const orders = await api.db.find(
|
||||
marketTableName,
|
||||
{
|
||||
nftId: {
|
||||
$in: nfts,
|
||||
},
|
||||
},
|
||||
MAX_NUM_UNITS_OPERABLE,
|
||||
0,
|
||||
[{ index: 'nftId', descending: false }],
|
||||
);
|
||||
|
||||
if (orders.length > 0) {
|
||||
// need to make sure that caller is actually the owner of each order
|
||||
const ids = [];
|
||||
const idMap = {};
|
||||
let priceSymbol = '';
|
||||
for (let i = 0; i < orders.length; i += 1) {
|
||||
const order = orders[i];
|
||||
if (priceSymbol === '') {
|
||||
({ priceSymbol } = order);
|
||||
}
|
||||
if (!api.assert(order.account === api.sender && order.ownedBy === 'u', 'all orders must be your own')
|
||||
|| !api.assert(priceSymbol === order.priceSymbol, 'all orders must have the same price symbol')) {
|
||||
return;
|
||||
}
|
||||
ids.push(order.nftId);
|
||||
idMap[order.nftId] = order;
|
||||
}
|
||||
|
||||
// move the locked NFTs back to their owner
|
||||
const nftArray = [];
|
||||
const wrappedNfts = {
|
||||
symbol,
|
||||
ids,
|
||||
};
|
||||
nftArray.push(wrappedNfts);
|
||||
const res = await api.executeSmartContract('nft', 'transfer', {
|
||||
fromType: 'contract',
|
||||
to: api.sender,
|
||||
toType: 'user',
|
||||
nfts: nftArray,
|
||||
isSignedWithActiveKey,
|
||||
});
|
||||
|
||||
// it's possible (but unlikely) that some transfers could have failed
|
||||
// due to validation errors & whatnot, so we need to loop over the
|
||||
// transfer results and only cancel orders for the transfers that succeeded
|
||||
if (res.events) {
|
||||
const groupingMap = {};
|
||||
for (let j = 0; j < res.events.length; j += 1) {
|
||||
const ev = res.events[j];
|
||||
if (ev.contract && ev.event && ev.data
|
||||
&& ev.contract === 'nft'
|
||||
&& ev.event === 'transfer'
|
||||
&& ev.data.from === CONTRACT_NAME
|
||||
&& ev.data.fromType === 'c'
|
||||
&& ev.data.to === api.sender
|
||||
&& ev.data.toType === 'u'
|
||||
&& ev.data.symbol === symbol) {
|
||||
// transfer is verified, now we can cancel the order
|
||||
const instanceId = ev.data.id;
|
||||
if (instanceId in idMap) {
|
||||
const order = idMap[instanceId];
|
||||
|
||||
await api.db.remove(marketTableName, order);
|
||||
|
||||
api.emit('cancelOrder', {
|
||||
account: order.account,
|
||||
ownedBy: order.ownedBy,
|
||||
symbol,
|
||||
nftId: order.nftId,
|
||||
timestamp: order.timestamp,
|
||||
price: order.price,
|
||||
priceSymbol: order.priceSymbol,
|
||||
fee: order.fee,
|
||||
orderId: order._id,
|
||||
});
|
||||
|
||||
const key = makeGroupingKey(order.grouping, nft.groupBy);
|
||||
const groupInfo = key in groupingMap
|
||||
? groupingMap[key]
|
||||
: {
|
||||
grouping: order.grouping,
|
||||
isInCollection: false,
|
||||
count: 0,
|
||||
};
|
||||
groupInfo.count -= 1;
|
||||
groupingMap[key] = groupInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update open interest metrics
|
||||
await updateOpenInterest('sell', symbol, priceSymbol, groupingMap, nft.groupBy);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
actions.buy = async (payload) => {
|
||||
const {
|
||||
symbol,
|
||||
nfts,
|
||||
marketAccount,
|
||||
isSignedWithActiveKey,
|
||||
} = payload;
|
||||
|
||||
if (!api.assert(symbol && typeof symbol === 'string'
|
||||
&& marketAccount && typeof marketAccount === 'string', 'invalid params')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const marketTableName = symbol + 'sellBook';
|
||||
const tableExists = await api.db.tableExists(marketTableName);
|
||||
|
||||
if (api.assert(isSignedWithActiveKey === true, 'you must use a custom_json signed with your active key')
|
||||
&& isValidIdArray(nfts)
|
||||
&& api.assert(tableExists, 'market not enabled for symbol')) {
|
||||
const finalMarketAccount = marketAccount.trim().toLowerCase();
|
||||
if (api.assert(isValidHiveAccountLength(finalMarketAccount), 'invalid market account')) {
|
||||
const nft = await api.db.findOneInTable('nft', 'nfts', { symbol });
|
||||
if (!api.assert(nft && nft.groupBy && nft.groupBy.length > 0, 'market grouping not set')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// look up order info
|
||||
const orders = await api.db.find(
|
||||
marketTableName,
|
||||
{
|
||||
nftId: {
|
||||
$in: nfts,
|
||||
},
|
||||
},
|
||||
MAX_NUM_UNITS_OPERABLE,
|
||||
0,
|
||||
[{ index: 'nftId', descending: false }],
|
||||
);
|
||||
|
||||
if (orders.length > 0) {
|
||||
// do a couple more sanity checks
|
||||
let priceSymbol = '';
|
||||
for (let i = 0; i < orders.length; i += 1) {
|
||||
const order = orders[i];
|
||||
if (priceSymbol === '') {
|
||||
({ priceSymbol } = order);
|
||||
}
|
||||
if (!api.assert(!(order.ownedBy === 'u' && order.account === api.sender), 'cannot fill your own orders')
|
||||
|| !api.assert(priceSymbol === order.priceSymbol, 'all orders must have the same price symbol')) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// get the price token params
|
||||
const token = await api.db.findOneInTable('tokens', 'tokens', { symbol: priceSymbol });
|
||||
if (!token) {
|
||||
return;
|
||||
}
|
||||
|
||||
// create order maps
|
||||
let feeTotal = api.BigNumber(0);
|
||||
let paymentTotal = api.BigNumber(0);
|
||||
let soldNfts = [];
|
||||
const sellers = [];
|
||||
const sellerMap = {};
|
||||
for (let i = 0; i < orders.length; i += 1) {
|
||||
const order = orders[i];
|
||||
const finalPrice = api.BigNumber(order.price);
|
||||
const feePercent = order.fee / 10000;
|
||||
let finalFee = finalPrice.multipliedBy(feePercent).decimalPlaces(token.precision);
|
||||
if (finalFee.gt(finalPrice)) {
|
||||
finalFee = finalPrice; // unlikely but need to be sure
|
||||
}
|
||||
let finalPayment = finalPrice.minus(finalFee).decimalPlaces(token.precision);
|
||||
if (finalPayment.lt(0)) {
|
||||
finalPayment = api.BigNumber(0); // unlikely but need to be sure
|
||||
}
|
||||
paymentTotal = paymentTotal.plus(finalPayment);
|
||||
feeTotal = feeTotal.plus(finalFee);
|
||||
|
||||
const key = makeMapKey(order.account, order.ownedBy);
|
||||
const sellerInfo = key in sellerMap
|
||||
? sellerMap[key]
|
||||
: {
|
||||
account: order.account,
|
||||
ownedBy: order.ownedBy,
|
||||
nftIds: [],
|
||||
paymentTotal: api.BigNumber(0),
|
||||
};
|
||||
|
||||
sellerInfo.paymentTotal = sellerInfo.paymentTotal.plus(finalPayment);
|
||||
sellerInfo.nftIds.push(order.nftId);
|
||||
sellerMap[key] = sellerInfo;
|
||||
}
|
||||
|
||||
// verify buyer has enough funds for payment
|
||||
const requiredBalance = paymentTotal.plus(feeTotal).toFixed(token.precision);
|
||||
const buyerBalance = await api.db.findOneInTable('tokens', 'balances', { account: api.sender, symbol: priceSymbol });
|
||||
if (!api.assert(buyerBalance
|
||||
&& api.BigNumber(buyerBalance.balance).gte(requiredBalance), 'you must have enough tokens for payment')) {
|
||||
return;
|
||||
}
|
||||
paymentTotal = paymentTotal.toFixed(token.precision);
|
||||
|
||||
// send fees to market account
|
||||
if (feeTotal.gt(0)) {
|
||||
feeTotal = feeTotal.toFixed(token.precision);
|
||||
const res = await api.executeSmartContract('tokens', 'transfer', {
|
||||
to: finalMarketAccount, symbol: priceSymbol, quantity: feeTotal, isSignedWithActiveKey,
|
||||
});
|
||||
if (!api.assert(isTokenTransferVerified(res, api.sender, finalMarketAccount, priceSymbol, feeTotal, 'transfer'), 'unable to transfer market fees')) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// send payments to sellers
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const info of Object.values(sellerMap)) {
|
||||
if (info.paymentTotal.gt(0)) {
|
||||
const contractAction = info.ownedBy === 'u' ? 'transfer' : 'transferToContract';
|
||||
info.paymentTotal = info.paymentTotal.toFixed(token.precision);
|
||||
const res = await api.executeSmartContract('tokens', contractAction, {
|
||||
to: info.account, symbol: priceSymbol, quantity: info.paymentTotal, isSignedWithActiveKey,
|
||||
});
|
||||
if (api.assert(isTokenTransferVerified(res, api.sender, info.account, priceSymbol, info.paymentTotal, contractAction), `unable to transfer payment to ${info.account}`)) {
|
||||
soldNfts = soldNfts.concat(info.nftIds);
|
||||
sellers.push(info);
|
||||
}
|
||||
} else {
|
||||
soldNfts = soldNfts.concat(info.nftIds);
|
||||
sellers.push(info);
|
||||
}
|
||||
}
|
||||
|
||||
// transfer sold NFT instances to new owner
|
||||
const nftArray = [];
|
||||
const wrappedNfts = {
|
||||
symbol,
|
||||
ids: soldNfts,
|
||||
};
|
||||
nftArray.push(wrappedNfts);
|
||||
await api.executeSmartContract('nft', 'transfer', {
|
||||
fromType: 'contract',
|
||||
to: api.sender,
|
||||
toType: 'user',
|
||||
nfts: nftArray,
|
||||
isSignedWithActiveKey,
|
||||
});
|
||||
|
||||
// delete sold market orders
|
||||
const groupingMap = {};
|
||||
const soldSet = new Set(soldNfts);
|
||||
for (let i = 0; i < orders.length; i += 1) {
|
||||
const order = orders[i];
|
||||
if (soldSet.has(order.nftId)) {
|
||||
await api.db.remove(marketTableName, order);
|
||||
|
||||
const key = makeGroupingKey(order.grouping, nft.groupBy);
|
||||
const groupInfo = key in groupingMap
|
||||
? groupingMap[key]
|
||||
: {
|
||||
grouping: order.grouping,
|
||||
isInCollection: false,
|
||||
count: 0,
|
||||
};
|
||||
groupInfo.count -= 1;
|
||||
groupingMap[key] = groupInfo;
|
||||
}
|
||||
}
|
||||
|
||||
// add the trade to the history
|
||||
await updateTradesHistory('buy', api.sender, 'u', sellers, symbol, priceSymbol, requiredBalance, finalMarketAccount, feeTotal, soldNfts.length);
|
||||
|
||||
api.emit('hitSellOrder', {
|
||||
symbol,
|
||||
priceSymbol,
|
||||
account: api.sender,
|
||||
ownedBy: 'u',
|
||||
sellers,
|
||||
paymentTotal,
|
||||
feeTotal,
|
||||
});
|
||||
|
||||
// update open interest metrics
|
||||
await updateOpenInterest('sell', symbol, priceSymbol, groupingMap, nft.groupBy);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
actions.sell = async (payload) => {
|
||||
const {
|
||||
symbol,
|
||||
nfts,
|
||||
price,
|
||||
priceSymbol,
|
||||
fee,
|
||||
isSignedWithActiveKey,
|
||||
} = payload;
|
||||
|
||||
if (!api.assert(symbol && typeof symbol === 'string', 'invalid params')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const marketTableName = symbol + 'sellBook';
|
||||
const instanceTableName = symbol + 'instances';
|
||||
const tableExists = await api.db.tableExists(marketTableName);
|
||||
|
||||
if (api.assert(isSignedWithActiveKey === true, 'you must use a custom_json signed with your active key')
|
||||
&& api.assert(nfts && typeof nfts === 'object' && Array.isArray(nfts)
|
||||
&& priceSymbol && typeof priceSymbol === 'string'
|
||||
&& price && typeof price === 'string' && !api.BigNumber(price).isNaN()
|
||||
&& fee && typeof fee === 'number' && fee >= 0 && fee <= 10000 && Number.isInteger(fee), 'invalid params')
|
||||
&& api.assert(nfts.length <= MAX_NUM_UNITS_OPERABLE, `cannot sell more than ${MAX_NUM_UNITS_OPERABLE} NFT instances at once`)
|
||||
&& api.assert(tableExists, 'market not enabled for symbol')) {
|
||||
const nft = await api.db.findOneInTable('nft', 'nfts', { symbol });
|
||||
if (!api.assert(nft && nft.groupBy && nft.groupBy.length > 0, 'market grouping not set')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// get the price token params
|
||||
const token = await api.db.findOneInTable('tokens', 'tokens', { symbol: priceSymbol });
|
||||
if (api.assert(token
|
||||
&& api.BigNumber(price).gt(0)
|
||||
&& countDecimals(price) <= token.precision, 'invalid price')) {
|
||||
// lock the NFTs to sell by moving them to this contract for safekeeping
|
||||
const nftArray = [];
|
||||
const wrappedNfts = {
|
||||
symbol,
|
||||
ids: nfts,
|
||||
};
|
||||
nftArray.push(wrappedNfts);
|
||||
const res = await api.executeSmartContract('nft', 'transfer', {
|
||||
fromType: 'user',
|
||||
to: CONTRACT_NAME,
|
||||
toType: 'contract',
|
||||
nfts: nftArray,
|
||||
isSignedWithActiveKey,
|
||||
});
|
||||
|
||||
// it's possible that some transfers could have failed due to validation
|
||||
// errors & whatnot, so we need to loop over the transfer results and
|
||||
// only create market orders for the transfers that succeeded
|
||||
if (res.events) {
|
||||
const blockDate = new Date(`${api.hiveBlockTimestamp}.000Z`);
|
||||
const timestamp = blockDate.getTime();
|
||||
const finalPrice = api.BigNumber(price).toFixed(token.precision);
|
||||
const nftIntegerIdList = [];
|
||||
const orderDataMap = {};
|
||||
|
||||
for (let i = 0; i < res.events.length; i += 1) {
|
||||
const ev = res.events[i];
|
||||
if (ev.contract && ev.event && ev.data
|
||||
&& ev.contract === 'nft'
|
||||
&& ev.event === 'transfer'
|
||||
&& ev.data.from === api.sender
|
||||
&& ev.data.fromType === 'u'
|
||||
&& ev.data.to === CONTRACT_NAME
|
||||
&& ev.data.toType === 'c'
|
||||
&& ev.data.symbol === symbol) {
|
||||
// transfer is verified, now we can add a market order
|
||||
const instanceId = ev.data.id;
|
||||
|
||||
const orderData = {
|
||||
nftId: instanceId,
|
||||
grouping: {},
|
||||
groupingKey: '',
|
||||
};
|
||||
const integerId = api.BigNumber(instanceId).toNumber();
|
||||
nftIntegerIdList.push(integerId);
|
||||
orderDataMap[integerId] = orderData;
|
||||
}
|
||||
}
|
||||
|
||||
// query NFT instances to construct the grouping
|
||||
const instances = await api.db.findInTable(
|
||||
'nft',
|
||||
instanceTableName,
|
||||
{
|
||||
_id: {
|
||||
$in: nftIntegerIdList,
|
||||
},
|
||||
},
|
||||
MAX_NUM_UNITS_OPERABLE,
|
||||
0,
|
||||
[{ index: '_id', descending: false }],
|
||||
);
|
||||
|
||||
for (let j = 0; j < instances.length; j += 1) {
|
||||
const instance = instances[j];
|
||||
const grouping = {};
|
||||
let groupingKey = '';
|
||||
nft.groupBy.forEach((name) => {
|
||||
if (instance.properties[name] !== undefined && instance.properties[name] !== null) {
|
||||
grouping[name] = instance.properties[name].toString();
|
||||
} else {
|
||||
grouping[name] = '';
|
||||
}
|
||||
groupingKey = groupingKey + ':' + name + ':' + grouping[name];
|
||||
});
|
||||
orderDataMap[instance._id].grouping = grouping;
|
||||
orderDataMap[instance._id].groupingKey = groupingKey;
|
||||
}
|
||||
|
||||
// create the orders
|
||||
const groupingMap = {};
|
||||
for (let k = 0; k < nftIntegerIdList.length; k += 1) {
|
||||
const intId = nftIntegerIdList[k];
|
||||
const orderInfo = orderDataMap[intId];
|
||||
const order = {
|
||||
account: api.sender,
|
||||
ownedBy: 'u',
|
||||
nftId: orderInfo.nftId,
|
||||
grouping: orderInfo.grouping,
|
||||
timestamp,
|
||||
price: finalPrice,
|
||||
priceDec: { $numberDecimal: finalPrice },
|
||||
priceSymbol,
|
||||
fee,
|
||||
};
|
||||
|
||||
const result = await api.db.insert(marketTableName, order);
|
||||
|
||||
api.emit('sellOrder', {
|
||||
account: order.account,
|
||||
ownedBy: order.ownedBy,
|
||||
symbol,
|
||||
nftId: order.nftId,
|
||||
timestamp,
|
||||
price: order.price,
|
||||
priceSymbol: order.priceSymbol,
|
||||
fee,
|
||||
orderId: result._id,
|
||||
});
|
||||
|
||||
const groupInfo = orderInfo.groupingKey in groupingMap
|
||||
? groupingMap[orderInfo.groupingKey]
|
||||
: {
|
||||
grouping: orderInfo.grouping,
|
||||
isInCollection: false,
|
||||
count: 0,
|
||||
};
|
||||
groupInfo.count += 1;
|
||||
groupingMap[orderInfo.groupingKey] = groupInfo;
|
||||
}
|
||||
|
||||
// update open interest metrics
|
||||
await updateOpenInterest('sell', symbol, priceSymbol, groupingMap, nft.groupBy);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1,66 +0,0 @@
|
|||
actions.createSSC = async (payload) => {
|
||||
await api.db.createTable('params');
|
||||
const params = {};
|
||||
|
||||
params.priceSBD = '1000000';
|
||||
params.priceSteem = "'${SSC_STORE_PRICE}$'";
|
||||
params.quantity = "'${SSC_STORE_QTY}$'";
|
||||
params.disabled = false;
|
||||
|
||||
await api.db.insert('params', params);
|
||||
};
|
||||
|
||||
actions.updateParams = async (payload) => {
|
||||
if (api.sender !== api.owner) return;
|
||||
|
||||
const {
|
||||
priceSBD, priceSteem, quantity, disabled,
|
||||
} = payload;
|
||||
|
||||
const params = await api.db.findOne('params', {});
|
||||
|
||||
params.priceSBD = priceSBD;
|
||||
params.priceSteem = priceSteem;
|
||||
params.quantity = quantity;
|
||||
params.disabled = disabled;
|
||||
|
||||
await api.db.update('params', params);
|
||||
};
|
||||
|
||||
actions.buy = async (payload) => {
|
||||
const { recipient, amountSTEEMSBD, isSignedWithActiveKey } = payload;
|
||||
|
||||
if (recipient !== api.owner) return;
|
||||
|
||||
if (api.assert(recipient && amountSTEEMSBD && isSignedWithActiveKey, 'invalid params')) {
|
||||
const params = await api.db.findOne('params', {});
|
||||
|
||||
if (params.disabled) return;
|
||||
|
||||
const res = amountSTEEMSBD.split(' ');
|
||||
|
||||
const amount = res[0];
|
||||
const unit = res[1];
|
||||
|
||||
let quantity = 0;
|
||||
let quantityToSend = 0;
|
||||
api.BigNumber.set({ DECIMAL_PLACES: 3 });
|
||||
|
||||
// STEEM
|
||||
if (unit === 'STEEM') {
|
||||
quantity = api.BigNumber(amount).dividedBy(params.priceSteem);
|
||||
} else { // SBD (disabled)
|
||||
// quantity = api.BigNumber(amount).dividedBy(params.priceSBD);
|
||||
}
|
||||
|
||||
if (api.refSteemBlockNumber < '${FORK_BLOCK_NUMBER}$') {
|
||||
quantityToSend = Number(api.BigNumber(quantity).multipliedBy(params.quantity).toFixed('${BP_CONSTANTS.UTILITY_TOKEN_PRECISION}$'));
|
||||
} else {
|
||||
quantityToSend = api.BigNumber(quantity).multipliedBy(params.quantity).toFixed('${BP_CONSTANTS.UTILITY_TOKEN_PRECISION}$');
|
||||
}
|
||||
|
||||
if (quantityToSend > 0) {
|
||||
await api.executeSmartContractAsOwner('tokens', 'transfer', { symbol: "'${BP_CONSTANTS.UTILITY_TOKEN_SYMBOL}$'", quantity: quantityToSend, to: api.sender });
|
||||
}
|
||||
}
|
||||
};
|
File diff suppressed because it is too large
Load Diff
|
@ -12,7 +12,7 @@ const CONTRACT_NAME = 'crittermanager';
|
|||
// to recognize the Critter app owner
|
||||
const CRITTER_CREATOR = 'cryptomancer';
|
||||
|
||||
// this placeholder represents ENG tokens on the mainnet and SSC on the testnet
|
||||
// this placeholder represents BEE tokens on the mainnet and SSC on the testnet
|
||||
// eslint-disable-next-line no-template-curly-in-string
|
||||
const UTILITY_TOKEN_SYMBOL = "'${CONSTANTS.UTILITY_TOKEN_SYMBOL}$'";
|
||||
|
||||
|
@ -72,7 +72,7 @@ actions.updateParams = async (payload) => {
|
|||
// do this through the Steem Engine web site, but we include it
|
||||
// here to illustrate programmatic NFT creation, and to make it
|
||||
// clear what data properties we need. Note: the contract owner
|
||||
// must have enough ENG/SSC to pay the creation fees. For simplicity
|
||||
// must have enough BEE/SSC to pay the creation fees. For simplicity
|
||||
// we don't do checks on the owner's balance here, but in a
|
||||
// production ready smart contract we definitely should do so
|
||||
// before taking any action that spends tokens as a side effect.
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
const STEEM_PEGGED_SYMBOL = 'STEEMP';
|
||||
/* eslint-disable no-await-in-loop */
|
||||
/* global actions, api */
|
||||
|
||||
const HIVE_PEGGED_SYMBOL = 'SWAP.HIVE';
|
||||
const CONTRACT_NAME = 'dice';
|
||||
|
||||
actions.createSSC = async (payload) => {
|
||||
actions.createSSC = async () => {
|
||||
await api.db.createTable('params');
|
||||
|
||||
const params = {};
|
||||
|
@ -23,13 +26,12 @@ actions.roll = async (payload) => {
|
|||
|
||||
// check that the amount bet is in thr allowed range
|
||||
if (api.assert(api.BigNumber(amount).gte(params.minBet) && api.BigNumber(amount).lte(params.maxBet), 'amount must be between minBet and maxBet')) {
|
||||
// request lock of amount STEEMP tokens
|
||||
const res = await api.executeSmartContract('tokens', 'transferToContract', { symbol: STEEM_PEGGED_SYMBOL, quantity: amount, to: CONTRACT_NAME });
|
||||
// request lock of amount HONEY tokens
|
||||
const res = await api.executeSmartContract('tokens', 'transferToContract', { symbol: HIVE_PEGGED_SYMBOL, quantity: amount, to: CONTRACT_NAME });
|
||||
|
||||
// check if the tokens were locked
|
||||
if (res.errors === undefined
|
||||
&& res.events && res.events.find(el => el.contract === 'tokens' && el.event === 'transferToContract' && el.data.from === api.sender && el.data.to === CONTRACT_NAME && el.data.quantity === amount && el.data.symbol === STEEM_PEGGED_SYMBOL) !== undefined) {
|
||||
|
||||
&& res.events && res.events.find(el => el.contract === 'tokens' && el.event === 'transferToContract' && el.data.from === api.sender && el.data.to === CONTRACT_NAME && el.data.quantity === amount && el.data.symbol === HIVE_PEGGED_SYMBOL) !== undefined) {
|
||||
// get a deterministic random number
|
||||
const random = api.random();
|
||||
|
||||
|
@ -49,7 +51,7 @@ actions.roll = async (payload) => {
|
|||
.toFixed(3, api.BigNumber.ROUND_DOWN);
|
||||
|
||||
// send the tokens out
|
||||
await api.transferTokens(api.sender, STEEM_PEGGED_SYMBOL, tokensWon, 'user');
|
||||
await api.transferTokens(api.sender, HIVE_PEGGED_SYMBOL, tokensWon, 'user');
|
||||
|
||||
// emit an event
|
||||
api.emit('results', { memo: `you won. roll: ${randomRoll}, your bet: ${roll}` });
|
|
@ -1,22 +1,41 @@
|
|||
actions.createSSC = async (payload) => {
|
||||
await api.db.createTable('withdrawals');
|
||||
/* eslint-disable no-await-in-loop */
|
||||
/* global actions, api */
|
||||
|
||||
const initiateWithdrawal = async (id, recipient, quantity, memo) => {
|
||||
const withdrawal = {};
|
||||
|
||||
withdrawal.id = id;
|
||||
withdrawal.type = 'HIVE';
|
||||
withdrawal.recipient = recipient;
|
||||
withdrawal.memo = memo;
|
||||
withdrawal.quantity = quantity;
|
||||
|
||||
await api.db.insert('withdrawals', withdrawal);
|
||||
};
|
||||
|
||||
actions.createSSC = async () => {
|
||||
const tableExists = await api.db.tableExists('withdrawals');
|
||||
|
||||
if (tableExists === false) {
|
||||
await api.db.createTable('withdrawals');
|
||||
}
|
||||
};
|
||||
|
||||
actions.buy = async (payload) => {
|
||||
const { recipient, amountSTEEMSBD, isSignedWithActiveKey } = payload;
|
||||
const { recipient, amountHIVEHBD, isSignedWithActiveKey } = payload;
|
||||
|
||||
if (recipient !== api.owner) return;
|
||||
|
||||
if (recipient && amountSTEEMSBD && isSignedWithActiveKey) {
|
||||
const res = amountSTEEMSBD.split(' ');
|
||||
if (recipient && amountHIVEHBD && isSignedWithActiveKey) {
|
||||
const res = amountHIVEHBD.split(' ');
|
||||
|
||||
const unit = res[1];
|
||||
|
||||
// STEEM
|
||||
if (api.assert(unit === 'STEEM', 'only STEEM can be used')) {
|
||||
// HIVE
|
||||
if (api.assert(unit === 'HIVE', 'only HIVE can be used')) {
|
||||
let quantityToSend = res[0];
|
||||
|
||||
// calculate the 1% fee (with a min of 0.001 STEEM)
|
||||
// calculate the 1% fee (with a min of 0.001 HIVE)
|
||||
let fee = api.BigNumber(quantityToSend).multipliedBy(0.01).toFixed(3);
|
||||
|
||||
if (api.BigNumber(fee).lt('0.001')) {
|
||||
|
@ -26,12 +45,13 @@ actions.buy = async (payload) => {
|
|||
quantityToSend = api.BigNumber(quantityToSend).minus(fee).toFixed(3);
|
||||
|
||||
if (api.BigNumber(quantityToSend).gt(0)) {
|
||||
await api.executeSmartContractAsOwner('tokens', 'transfer', { symbol: 'STEEMP', quantity: quantityToSend, to: api.sender })
|
||||
await api.executeSmartContractAsOwner('tokens', 'transfer', { symbol: 'SWAP.HIVE', quantity: quantityToSend, to: api.sender });
|
||||
}
|
||||
|
||||
if (api.BigNumber(fee).gt(0)) {
|
||||
const memo = `fee tx ${api.transactionId}`;
|
||||
await initiateWithdrawal(`${api.transactionId}-fee`, "'${ACCOUNT_RECEIVING_FEES}$'", fee, memo);
|
||||
// eslint-disable-next-line no-template-curly-in-string
|
||||
await initiateWithdrawal(`${api.transactionId}-fee`, "'${CONSTANTS.ACCOUNT_RECEIVING_FEES}$'", fee, memo);
|
||||
}
|
||||
} else {
|
||||
// SBD not supported
|
||||
|
@ -42,11 +62,12 @@ actions.buy = async (payload) => {
|
|||
actions.withdraw = async (payload) => {
|
||||
const { quantity, isSignedWithActiveKey } = payload;
|
||||
|
||||
if (api.assert(
|
||||
quantity && typeof quantity === 'string' && !api.BigNumber(quantity).isNaN()
|
||||
&& api.BigNumber(quantity).gt(0)
|
||||
&& isSignedWithActiveKey, 'invalid params')) {
|
||||
// calculate the 1% fee (with a min of 0.001 STEEM)
|
||||
if (api.assert(quantity && typeof quantity === 'string' && !api.BigNumber(quantity).isNaN()
|
||||
&& isSignedWithActiveKey
|
||||
&& api.BigNumber(quantity).dp() <= 3, 'invalid params')
|
||||
&& api.assert(api.BigNumber(quantity).gte(0.002), 'minimum withdrawal is 0.002')
|
||||
) {
|
||||
// calculate the 1% fee (with a min of 0.001 HIVE)
|
||||
let fee = api.BigNumber(quantity).multipliedBy(0.01).toFixed(3);
|
||||
|
||||
if (api.BigNumber(fee).lt('0.001')) {
|
||||
|
@ -56,10 +77,10 @@ actions.withdraw = async (payload) => {
|
|||
const quantityToSend = api.BigNumber(quantity).minus(fee).toFixed(3);
|
||||
|
||||
if (api.BigNumber(quantityToSend).gt(0)) {
|
||||
const res = await api.executeSmartContract('tokens', 'transfer', { symbol: 'STEEMP', quantity, to: api.owner });
|
||||
const res = await api.executeSmartContract('tokens', 'transfer', { symbol: 'SWAP.HIVE', quantity, to: api.owner });
|
||||
|
||||
if (res.errors === undefined
|
||||
&& res.events && res.events.find(el => el.contract === 'tokens' && el.event === 'transfer' && el.data.from === api.sender && el.data.to === api.owner && el.data.quantity === quantity && el.data.symbol === "STEEMP") !== undefined) {
|
||||
&& res.events && res.events.find(el => el.contract === 'tokens' && el.event === 'transfer' && el.data.from === api.sender && el.data.to === api.owner && el.data.quantity === quantity && el.data.symbol === 'SWAP.HIVE') !== undefined) {
|
||||
// withdrawal
|
||||
let memo = `withdrawal tx ${api.transactionId}`;
|
||||
|
||||
|
@ -67,8 +88,9 @@ actions.withdraw = async (payload) => {
|
|||
|
||||
if (api.BigNumber(fee).gt(0)) {
|
||||
memo = `fee tx ${api.transactionId}`;
|
||||
await initiateWithdrawal(`${api.transactionId}-fee`, "'${ACCOUNT_RECEIVING_FEES}$'", fee, memo);
|
||||
}
|
||||
// eslint-disable-next-line no-template-curly-in-string
|
||||
await initiateWithdrawal(`${api.transactionId}-fee`, "'${CONSTANTS.ACCOUNT_RECEIVING_FEES}$'", fee, memo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -80,27 +102,10 @@ actions.removeWithdrawal = async (payload) => {
|
|||
if (api.sender !== api.owner) return;
|
||||
|
||||
if (id && isSignedWithActiveKey) {
|
||||
let finalId = id;
|
||||
if (api.refSteemBlockNumber >= 31248438 && api.refSteemBlockNumber <= 31262296) {
|
||||
finalId = finalId.replace('-0', '');
|
||||
}
|
||||
|
||||
const withdrawal = await api.db.findOne('withdrawals', { id: finalId });
|
||||
const withdrawal = await api.db.findOne('withdrawals', { id });
|
||||
|
||||
if (withdrawal) {
|
||||
await api.db.remove('withdrawals', withdrawal);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const initiateWithdrawal = async (id, recipient, quantity, memo) => {
|
||||
const withdrawal = {};
|
||||
|
||||
withdrawal.id = id;
|
||||
withdrawal.type = 'STEEM';
|
||||
withdrawal.recipient = recipient;
|
||||
withdrawal.memo = memo;
|
||||
withdrawal.quantity = quantity;
|
||||
|
||||
await api.db.insert('withdrawals', withdrawal);
|
||||
};
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
// eslint-disable-next-line no-template-curly-in-string
|
||||
const UTILITY_TOKEN_SYMBOL = "'${CONSTANTS.UTILITY_TOKEN_SYMBOL}$'";
|
||||
// eslint-disable-next-line no-template-curly-in-string
|
||||
const HIVE_ENGINE_ACCOUNT = "'${CONSTANTS.HIVE_ENGINE_ACCOUNT}$'";
|
||||
|
||||
actions.createSSC = async () => {
|
||||
|
||||
|
@ -11,18 +13,20 @@ actions.createSSC = async () => {
|
|||
actions.issueNewTokens = async () => {
|
||||
if (api.sender !== 'null') return;
|
||||
|
||||
// issue tokens to steemsc
|
||||
// issue tokens to HIVE_ENGINE_ACCOUNT
|
||||
// 100k tokens per year = 11.41552511 tokens per hour (an hour = 1200 blocks)
|
||||
let nbTokens = '11.41552511';
|
||||
await api.executeSmartContract('tokens', 'issue', { symbol: UTILITY_TOKEN_SYMBOL, quantity: nbTokens, to: 'steemsc' });
|
||||
await api.executeSmartContract('tokens', 'issue',
|
||||
{ symbol: UTILITY_TOKEN_SYMBOL, quantity: nbTokens, to: HIVE_ENGINE_ACCOUNT });
|
||||
|
||||
// issue tokens to engpool
|
||||
// 100k tokens per year = 11.41552511 tokens per hour (an hour = 1200 blocks)
|
||||
nbTokens = '11.41552511';
|
||||
await api.executeSmartContract('tokens', 'issue', { symbol: UTILITY_TOKEN_SYMBOL, quantity: nbTokens, to: 'engpool' });
|
||||
await api.executeSmartContract('tokens', 'issue', { symbol: UTILITY_TOKEN_SYMBOL, quantity: nbTokens, to: 'hive-miner' });
|
||||
|
||||
// issue tokens to "witnesses" contract
|
||||
// 200k tokens per year = 22.83105022 tokens per hour (an hour = 1200 blocks)
|
||||
nbTokens = '22.83105022';
|
||||
await api.executeSmartContract('tokens', 'issueToContract', { symbol: UTILITY_TOKEN_SYMBOL, quantity: nbTokens, to: 'witnesses' });
|
||||
// nbTokens = '22.83105022';
|
||||
// await api.executeSmartContract('tokens', 'issueToContract',
|
||||
// { symbol: UTILITY_TOKEN_SYMBOL, quantity: nbTokens, to: 'witnesses' });
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* eslint-disable no-await-in-loop */
|
||||
/* global actions, api */
|
||||
const STEEM_PEGGED_SYMBOL = 'STEEMP';
|
||||
const STEEM_PEGGED_SYMBOL_PRESICION = 8;
|
||||
const HIVE_PEGGED_SYMBOL = 'SWAP.HIVE';
|
||||
const HIVE_PEGGED_SYMBOL_PRESICION = 8;
|
||||
const CONTRACT_NAME = 'market';
|
||||
|
||||
const getMetric = async (symbol) => {
|
||||
|
@ -17,7 +17,7 @@ const getMetric = async (symbol) => {
|
|||
metric.highestBid = '0';
|
||||
metric.lastDayPrice = '0';
|
||||
metric.lastDayPriceExpiration = 0;
|
||||
metric.priceChangeSteem = '0';
|
||||
metric.priceChangeHive = '0';
|
||||
metric.priceChangePercent = '0';
|
||||
|
||||
const newMetric = await api.db.insert('metrics', metric);
|
||||
|
@ -28,7 +28,7 @@ const getMetric = async (symbol) => {
|
|||
};
|
||||
|
||||
const updateVolumeMetric = async (symbol, quantity, add = true) => {
|
||||
const blockDate = new Date(`${api.steemBlockTimestamp}.000Z`);
|
||||
const blockDate = new Date(`${api.hiveBlockTimestamp}.000Z`);
|
||||
const timestampSec = blockDate.getTime() / 1000;
|
||||
const metric = await getMetric(symbol);
|
||||
|
||||
|
@ -38,12 +38,12 @@ const updateVolumeMetric = async (symbol, quantity, add = true) => {
|
|||
}
|
||||
metric.volume = api.BigNumber(metric.volume)
|
||||
.plus(quantity)
|
||||
.toFixed(STEEM_PEGGED_SYMBOL_PRESICION);
|
||||
.toFixed(HIVE_PEGGED_SYMBOL_PRESICION);
|
||||
metric.volumeExpiration = blockDate.setDate(blockDate.getDate() + 1) / 1000;
|
||||
} else {
|
||||
metric.volume = api.BigNumber(metric.volume)
|
||||
.minus(quantity)
|
||||
.toFixed(STEEM_PEGGED_SYMBOL_PRESICION);
|
||||
.toFixed(HIVE_PEGGED_SYMBOL_PRESICION);
|
||||
}
|
||||
|
||||
if (api.BigNumber(metric.volume).lt(0)) {
|
||||
|
@ -54,7 +54,7 @@ const updateVolumeMetric = async (symbol, quantity, add = true) => {
|
|||
};
|
||||
|
||||
const updatePriceMetrics = async (symbol, price) => {
|
||||
const blockDate = new Date(`${api.steemBlockTimestamp}.000Z`);
|
||||
const blockDate = new Date(`${api.hiveBlockTimestamp}.000Z`);
|
||||
const timestampSec = blockDate.getTime() / 1000;
|
||||
|
||||
const metric = await getMetric(symbol);
|
||||
|
@ -64,13 +64,13 @@ const updatePriceMetrics = async (symbol, price) => {
|
|||
if (metric.lastDayPriceExpiration < timestampSec) {
|
||||
metric.lastDayPrice = price;
|
||||
metric.lastDayPriceExpiration = blockDate.setDate(blockDate.getDate() + 1) / 1000;
|
||||
metric.priceChangeSteem = '0';
|
||||
metric.priceChangeHive = '0';
|
||||
metric.priceChangePercent = '0%';
|
||||
} else {
|
||||
metric.priceChangeSteem = api.BigNumber(price)
|
||||
metric.priceChangeHive = api.BigNumber(price)
|
||||
.minus(metric.lastDayPrice)
|
||||
.toFixed(STEEM_PEGGED_SYMBOL_PRESICION);
|
||||
metric.priceChangePercent = `${api.BigNumber(metric.priceChangeSteem).dividedBy(metric.lastDayPrice).multipliedBy(100).toFixed(2)}%`;
|
||||
.toFixed(HIVE_PEGGED_SYMBOL_PRESICION);
|
||||
metric.priceChangePercent = `${api.BigNumber(metric.priceChangeHive).dividedBy(metric.lastDayPrice).multipliedBy(100).toFixed(2)}%`;
|
||||
}
|
||||
|
||||
await api.db.update('metrics', metric);
|
||||
|
@ -118,7 +118,7 @@ const updateAskMetric = async (symbol) => {
|
|||
};
|
||||
|
||||
const updateTradesHistory = async (type, buyer, seller, symbol, quantity, price, volume) => {
|
||||
const blockDate = new Date(`${api.steemBlockTimestamp}.000Z`);
|
||||
const blockDate = new Date(`${api.hiveBlockTimestamp}.000Z`);
|
||||
const timestampSec = blockDate.getTime() / 1000;
|
||||
const timestampMinus24hrs = blockDate.setDate(blockDate.getDate() - 1) / 1000;
|
||||
// clean history
|
||||
|
@ -168,7 +168,7 @@ const updateTradesHistory = async (type, buyer, seller, symbol, quantity, price,
|
|||
const countDecimals = value => api.BigNumber(value).dp();
|
||||
|
||||
const removeExpiredOrders = async (table) => {
|
||||
const timestampSec = api.BigNumber(new Date(`${api.steemBlockTimestamp}.000Z`).getTime())
|
||||
const timestampSec = api.BigNumber(new Date(`${api.hiveBlockTimestamp}.000Z`).getTime())
|
||||
.dividedBy(1000)
|
||||
.toNumber();
|
||||
|
||||
|
@ -191,7 +191,7 @@ const removeExpiredOrders = async (table) => {
|
|||
let symbol;
|
||||
|
||||
if (table === 'buyBook') {
|
||||
symbol = STEEM_PEGGED_SYMBOL;
|
||||
symbol = HIVE_PEGGED_SYMBOL;
|
||||
quantity = order.tokensLocked;
|
||||
} else {
|
||||
// eslint-disable-next-line prefer-destructuring
|
||||
|
@ -206,8 +206,12 @@ const removeExpiredOrders = async (table) => {
|
|||
await api.db.remove(table, order);
|
||||
|
||||
if (table === 'buyBook') {
|
||||
api.emit('orderExpired', { type: 'buy', txId: order.txId });
|
||||
|
||||
await updateAskMetric(order.symbol);
|
||||
} else {
|
||||
api.emit('orderExpired', { type: 'sell', txId: order.txId });
|
||||
|
||||
await updateBidMetric(order.symbol);
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +262,7 @@ actions.cancel = async (payload) => {
|
|||
let symbol;
|
||||
|
||||
if (type === 'buy') {
|
||||
symbol = STEEM_PEGGED_SYMBOL;
|
||||
symbol = HIVE_PEGGED_SYMBOL;
|
||||
quantity = order.tokensLocked;
|
||||
} else {
|
||||
// eslint-disable-next-line prefer-destructuring
|
||||
|
@ -315,12 +319,12 @@ const findMatchingSellOrders = async (order, tokenPrecision) => {
|
|||
if (api.BigNumber(buyOrder.quantity).lte(sellOrder.quantity)) {
|
||||
let qtyTokensToSend = api.BigNumber(sellOrder.price)
|
||||
.multipliedBy(buyOrder.quantity)
|
||||
.toFixed(STEEM_PEGGED_SYMBOL_PRESICION);
|
||||
.toFixed(HIVE_PEGGED_SYMBOL_PRESICION);
|
||||
|
||||
if (api.BigNumber(qtyTokensToSend).gt(buyOrder.tokensLocked)) {
|
||||
qtyTokensToSend = api.BigNumber(sellOrder.price)
|
||||
.multipliedBy(buyOrder.quantity)
|
||||
.toFixed(STEEM_PEGGED_SYMBOL_PRESICION, api.BigNumber.ROUND_DOWN);
|
||||
.toFixed(HIVE_PEGGED_SYMBOL_PRESICION, api.BigNumber.ROUND_DOWN);
|
||||
}
|
||||
|
||||
if (api.assert(api.BigNumber(qtyTokensToSend).gt(0)
|
||||
|
@ -337,13 +341,13 @@ const findMatchingSellOrders = async (order, tokenPrecision) => {
|
|||
}
|
||||
|
||||
// transfer the tokens to the seller
|
||||
res = await api.transferTokens(sellOrder.account, STEEM_PEGGED_SYMBOL, qtyTokensToSend, 'user');
|
||||
res = await api.transferTokens(sellOrder.account, HIVE_PEGGED_SYMBOL, qtyTokensToSend, 'user');
|
||||
|
||||
if (res.errors) {
|
||||
api.debug(res.errors);
|
||||
api.debug(`TXID: ${api.transactionId}`);
|
||||
api.debug(sellOrder.account);
|
||||
api.debug(STEEM_PEGGED_SYMBOL);
|
||||
api.debug(HIVE_PEGGED_SYMBOL);
|
||||
api.debug(qtyTokensToSend);
|
||||
}
|
||||
|
||||
|
@ -353,7 +357,7 @@ const findMatchingSellOrders = async (order, tokenPrecision) => {
|
|||
.toFixed(tokenPrecision);
|
||||
const nbTokensToFillOrder = api.BigNumber(sellOrder.price)
|
||||
.multipliedBy(qtyLeftSellOrder)
|
||||
.toFixed(STEEM_PEGGED_SYMBOL_PRESICION);
|
||||
.toFixed(HIVE_PEGGED_SYMBOL_PRESICION);
|
||||
|
||||
if (api.BigNumber(qtyLeftSellOrder).gt(0)
|
||||
&& (api.BigNumber(nbTokensToFillOrder).gte('0.00000001'))) {
|
||||
|
@ -364,16 +368,17 @@ const findMatchingSellOrders = async (order, tokenPrecision) => {
|
|||
if (api.BigNumber(qtyLeftSellOrder).gt(0)) {
|
||||
await api.transferTokens(sellOrder.account, symbol, qtyLeftSellOrder, 'user');
|
||||
}
|
||||
api.emit('orderClosed', { account: sellOrder.account, type: 'sell', txId: sellOrder.txId });
|
||||
await api.db.remove('sellBook', sellOrder);
|
||||
}
|
||||
|
||||
// unlock remaining tokens, update the quantity to get and remove the buy order
|
||||
const tokensToUnlock = api.BigNumber(buyOrder.tokensLocked)
|
||||
.minus(qtyTokensToSend)
|
||||
.toFixed(STEEM_PEGGED_SYMBOL_PRESICION);
|
||||
.toFixed(HIVE_PEGGED_SYMBOL_PRESICION);
|
||||
|
||||
if (api.BigNumber(tokensToUnlock).gt(0)) {
|
||||
await api.transferTokens(account, STEEM_PEGGED_SYMBOL, tokensToUnlock, 'user');
|
||||
await api.transferTokens(account, HIVE_PEGGED_SYMBOL, tokensToUnlock, 'user');
|
||||
}
|
||||
|
||||
// add the trade to the history
|
||||
|
@ -384,16 +389,17 @@ const findMatchingSellOrders = async (order, tokenPrecision) => {
|
|||
|
||||
buyOrder.quantity = '0';
|
||||
await api.db.remove('buyBook', buyOrder);
|
||||
api.emit('orderClosed', { account: buyOrder.account, type: 'buy', txId: buyOrder.txId });
|
||||
}
|
||||
} else {
|
||||
let qtyTokensToSend = api.BigNumber(sellOrder.price)
|
||||
.multipliedBy(sellOrder.quantity)
|
||||
.toFixed(STEEM_PEGGED_SYMBOL_PRESICION);
|
||||
.toFixed(HIVE_PEGGED_SYMBOL_PRESICION);
|
||||
|
||||
if (api.BigNumber(qtyTokensToSend).gt(buyOrder.tokensLocked)) {
|
||||
qtyTokensToSend = api.BigNumber(sellOrder.price)
|
||||
.multipliedBy(sellOrder.quantity)
|
||||
.toFixed(STEEM_PEGGED_SYMBOL_PRESICION, api.BigNumber.ROUND_DOWN);
|
||||
.toFixed(HIVE_PEGGED_SYMBOL_PRESICION, api.BigNumber.ROUND_DOWN);
|
||||
}
|
||||
|
||||
if (api.assert(api.BigNumber(qtyTokensToSend).gt(0)
|
||||
|
@ -410,23 +416,24 @@ const findMatchingSellOrders = async (order, tokenPrecision) => {
|
|||
}
|
||||
|
||||
// transfer the tokens to the seller
|
||||
res = await api.transferTokens(sellOrder.account, STEEM_PEGGED_SYMBOL, qtyTokensToSend, 'user');
|
||||
res = await api.transferTokens(sellOrder.account, HIVE_PEGGED_SYMBOL, qtyTokensToSend, 'user');
|
||||
|
||||
if (res.errors) {
|
||||
api.debug(res.errors);
|
||||
api.debug(`TXID: ${api.transactionId}`);
|
||||
api.debug(sellOrder.account);
|
||||
api.debug(STEEM_PEGGED_SYMBOL);
|
||||
api.debug(HIVE_PEGGED_SYMBOL);
|
||||
api.debug(qtyTokensToSend);
|
||||
}
|
||||
|
||||
// remove the sell order
|
||||
await api.db.remove('sellBook', sellOrder);
|
||||
api.emit('orderClosed', { account: sellOrder.account, type: 'sell', txId: sellOrder.txId });
|
||||
|
||||
// update tokensLocked and the quantity to get
|
||||
buyOrder.tokensLocked = api.BigNumber(buyOrder.tokensLocked)
|
||||
.minus(qtyTokensToSend)
|
||||
.toFixed(STEEM_PEGGED_SYMBOL_PRESICION);
|
||||
.toFixed(HIVE_PEGGED_SYMBOL_PRESICION);
|
||||
buyOrder.quantity = api.BigNumber(buyOrder.quantity)
|
||||
.minus(sellOrder.quantity)
|
||||
.toFixed(tokenPrecision);
|
||||
|
@ -434,13 +441,14 @@ const findMatchingSellOrders = async (order, tokenPrecision) => {
|
|||
// check if the order can still be filled
|
||||
const nbTokensToFillOrder = api.BigNumber(buyOrder.price)
|
||||
.multipliedBy(buyOrder.quantity)
|
||||
.toFixed(STEEM_PEGGED_SYMBOL_PRESICION);
|
||||
.toFixed(HIVE_PEGGED_SYMBOL_PRESICION);
|
||||
|
||||
if (api.BigNumber(nbTokensToFillOrder).lt('0.00000001')) {
|
||||
await api.transferTokens(account, STEEM_PEGGED_SYMBOL, buyOrder.tokensLocked, 'user');
|
||||
await api.transferTokens(account, HIVE_PEGGED_SYMBOL, buyOrder.tokensLocked, 'user');
|
||||
|
||||
buyOrder.quantity = '0';
|
||||
await api.db.remove('buyBook', buyOrder);
|
||||
api.emit('orderClosed', { account: buyOrder.account, type: 'buy', txId: buyOrder.txId });
|
||||
}
|
||||
|
||||
// add the trade to the history
|
||||
|
@ -516,12 +524,12 @@ const findMatchingBuyOrders = async (order, tokenPrecision) => {
|
|||
if (api.BigNumber(sellOrder.quantity).lte(buyOrder.quantity)) {
|
||||
let qtyTokensToSend = api.BigNumber(buyOrder.price)
|
||||
.multipliedBy(sellOrder.quantity)
|
||||
.toFixed(STEEM_PEGGED_SYMBOL_PRESICION);
|
||||
.toFixed(HIVE_PEGGED_SYMBOL_PRESICION);
|
||||
|
||||
if (api.BigNumber(qtyTokensToSend).gt(buyOrder.tokensLocked)) {
|
||||
qtyTokensToSend = api.BigNumber(buyOrder.price)
|
||||
.multipliedBy(sellOrder.quantity)
|
||||
.toFixed(STEEM_PEGGED_SYMBOL_PRESICION, api.BigNumber.ROUND_DOWN);
|
||||
.toFixed(HIVE_PEGGED_SYMBOL_PRESICION, api.BigNumber.ROUND_DOWN);
|
||||
}
|
||||
|
||||
if (api.assert(api.BigNumber(qtyTokensToSend).gt(0)
|
||||
|
@ -538,13 +546,13 @@ const findMatchingBuyOrders = async (order, tokenPrecision) => {
|
|||
}
|
||||
|
||||
// transfer the tokens to the seller
|
||||
res = await api.transferTokens(account, STEEM_PEGGED_SYMBOL, qtyTokensToSend, 'user');
|
||||
res = await api.transferTokens(account, HIVE_PEGGED_SYMBOL, qtyTokensToSend, 'user');
|
||||
|
||||
if (res.errors) {
|
||||
api.debug(res.errors);
|
||||
api.debug(`TXID: ${api.transactionId}`);
|
||||
api.debug(account);
|
||||
api.debug(STEEM_PEGGED_SYMBOL);
|
||||
api.debug(HIVE_PEGGED_SYMBOL);
|
||||
api.debug(qtyTokensToSend);
|
||||
}
|
||||
|
||||
|
@ -555,10 +563,10 @@ const findMatchingBuyOrders = async (order, tokenPrecision) => {
|
|||
|
||||
const buyOrdertokensLocked = api.BigNumber(buyOrder.tokensLocked)
|
||||
.minus(qtyTokensToSend)
|
||||
.toFixed(STEEM_PEGGED_SYMBOL_PRESICION);
|
||||
.toFixed(HIVE_PEGGED_SYMBOL_PRESICION);
|
||||
const nbTokensToFillOrder = api.BigNumber(buyOrder.price)
|
||||
.multipliedBy(qtyLeftBuyOrder)
|
||||
.toFixed(STEEM_PEGGED_SYMBOL_PRESICION);
|
||||
.toFixed(HIVE_PEGGED_SYMBOL_PRESICION);
|
||||
|
||||
if (api.BigNumber(qtyLeftBuyOrder).gt(0)
|
||||
&& (api.BigNumber(nbTokensToFillOrder).gte('0.00000001'))) {
|
||||
|
@ -568,8 +576,9 @@ const findMatchingBuyOrders = async (order, tokenPrecision) => {
|
|||
await api.db.update('buyBook', buyOrder);
|
||||
} else {
|
||||
if (api.BigNumber(buyOrdertokensLocked).gt(0)) {
|
||||
await api.transferTokens(buyOrder.account, STEEM_PEGGED_SYMBOL, buyOrdertokensLocked, 'user');
|
||||
await api.transferTokens(buyOrder.account, HIVE_PEGGED_SYMBOL, buyOrdertokensLocked, 'user');
|
||||
}
|
||||
api.emit('orderClosed', { account: buyOrder.account, type: 'buy', txId: buyOrder.txId });
|
||||
await api.db.remove('buyBook', buyOrder);
|
||||
}
|
||||
|
||||
|
@ -581,16 +590,17 @@ const findMatchingBuyOrders = async (order, tokenPrecision) => {
|
|||
|
||||
sellOrder.quantity = 0;
|
||||
await api.db.remove('sellBook', sellOrder);
|
||||
api.emit('orderClosed', { account: sellOrder.account, type: 'sell', txId: sellOrder.txId });
|
||||
}
|
||||
} else {
|
||||
let qtyTokensToSend = api.BigNumber(buyOrder.price)
|
||||
.multipliedBy(buyOrder.quantity)
|
||||
.toFixed(STEEM_PEGGED_SYMBOL_PRESICION);
|
||||
.toFixed(HIVE_PEGGED_SYMBOL_PRESICION);
|
||||
|
||||
if (qtyTokensToSend > buyOrder.tokensLocked) {
|
||||
qtyTokensToSend = api.BigNumber(buyOrder.price)
|
||||
.multipliedBy(buyOrder.quantity)
|
||||
.toFixed(STEEM_PEGGED_SYMBOL_PRESICION, api.BigNumber.ROUND_DOWN);
|
||||
.toFixed(HIVE_PEGGED_SYMBOL_PRESICION, api.BigNumber.ROUND_DOWN);
|
||||
}
|
||||
|
||||
if (api.assert(api.BigNumber(qtyTokensToSend).gt(0)
|
||||
|
@ -607,26 +617,27 @@ const findMatchingBuyOrders = async (order, tokenPrecision) => {
|
|||
}
|
||||
|
||||
// transfer the tokens to the seller
|
||||
res = await api.transferTokens(account, STEEM_PEGGED_SYMBOL, qtyTokensToSend, 'user');
|
||||
res = await api.transferTokens(account, HIVE_PEGGED_SYMBOL, qtyTokensToSend, 'user');
|
||||
|
||||
if (res.errors) {
|
||||
api.debug(res.errors);
|
||||
api.debug(`TXID: ${api.transactionId}`);
|
||||
api.debug(account);
|
||||
api.debug(STEEM_PEGGED_SYMBOL);
|
||||
api.debug(HIVE_PEGGED_SYMBOL);
|
||||
api.debug(qtyTokensToSend);
|
||||
}
|
||||
|
||||
const buyOrdertokensLocked = api.BigNumber(buyOrder.tokensLocked)
|
||||
.minus(qtyTokensToSend)
|
||||
.toFixed(STEEM_PEGGED_SYMBOL_PRESICION);
|
||||
.toFixed(HIVE_PEGGED_SYMBOL_PRESICION);
|
||||
|
||||
if (api.BigNumber(buyOrdertokensLocked).gt(0)) {
|
||||
await api.transferTokens(buyOrder.account, STEEM_PEGGED_SYMBOL, buyOrdertokensLocked, 'user');
|
||||
await api.transferTokens(buyOrder.account, HIVE_PEGGED_SYMBOL, buyOrdertokensLocked, 'user');
|
||||
}
|
||||
|
||||
// remove the buy order
|
||||
await api.db.remove('buyBook', buyOrder);
|
||||
api.emit('orderClosed', { account: buyOrder.account, type: 'buy', txId: buyOrder.txId });
|
||||
|
||||
// update the quantity to get
|
||||
sellOrder.quantity = api.BigNumber(sellOrder.quantity)
|
||||
|
@ -636,13 +647,14 @@ const findMatchingBuyOrders = async (order, tokenPrecision) => {
|
|||
// check if the order can still be filled
|
||||
const nbTokensToFillOrder = api.BigNumber(sellOrder.price)
|
||||
.multipliedBy(sellOrder.quantity)
|
||||
.toFixed(STEEM_PEGGED_SYMBOL_PRESICION);
|
||||
.toFixed(HIVE_PEGGED_SYMBOL_PRESICION);
|
||||
|
||||
if (api.BigNumber(nbTokensToFillOrder).lt('0.00000001')) {
|
||||
await api.transferTokens(account, symbol, sellOrder.quantity, 'user');
|
||||
|
||||
sellOrder.quantity = '0';
|
||||
await api.db.remove('sellBook', sellOrder);
|
||||
api.emit('orderClosed', { account: sellOrder.account, type: 'sell', txId: sellOrder.txId });
|
||||
}
|
||||
|
||||
// add the trade to the history
|
||||
|
@ -694,10 +706,10 @@ actions.buy = async (payload) => {
|
|||
isSignedWithActiveKey,
|
||||
} = payload;
|
||||
|
||||
// buy (quantity) of (symbol) at (price)(STEEM_PEGGED_SYMBOL) per (symbol)
|
||||
// buy (quantity) of (symbol) at (price)(HIVE_PEGGED_SYMBOL) per (symbol)
|
||||
if (api.assert(isSignedWithActiveKey === true, 'you must use a custom_json signed with your active key')
|
||||
&& api.assert(price && typeof price === 'string' && !api.BigNumber(price).isNaN()
|
||||
&& symbol && typeof symbol === 'string' && symbol !== STEEM_PEGGED_SYMBOL
|
||||
&& symbol && typeof symbol === 'string' && symbol !== HIVE_PEGGED_SYMBOL
|
||||
&& quantity && typeof quantity === 'string' && !api.BigNumber(quantity).isNaN()
|
||||
&& (expiration === undefined || (expiration && Number.isInteger(expiration) && expiration > 0)), 'invalid params')
|
||||
) {
|
||||
|
@ -707,21 +719,21 @@ actions.buy = async (payload) => {
|
|||
// perform a few verifications
|
||||
if (api.assert(token
|
||||
&& api.BigNumber(price).gt(0)
|
||||
&& countDecimals(price) <= STEEM_PEGGED_SYMBOL_PRESICION
|
||||
&& countDecimals(price) <= HIVE_PEGGED_SYMBOL_PRESICION
|
||||
&& countDecimals(quantity) <= token.precision, 'invalid params')) {
|
||||
// initiate a transfer from api.sender to contract balance
|
||||
|
||||
const nbTokensToLock = api.BigNumber(price)
|
||||
.multipliedBy(quantity)
|
||||
.toFixed(STEEM_PEGGED_SYMBOL_PRESICION);
|
||||
.toFixed(HIVE_PEGGED_SYMBOL_PRESICION);
|
||||
|
||||
if (api.assert(api.BigNumber(nbTokensToLock).gte('0.00000001'), 'order cannot be placed as it cannot be filled')) {
|
||||
// lock STEEM_PEGGED_SYMBOL tokens
|
||||
const res = await api.executeSmartContract('tokens', 'transferToContract', { symbol: STEEM_PEGGED_SYMBOL, quantity: nbTokensToLock, to: CONTRACT_NAME });
|
||||
// lock HIVE_PEGGED_SYMBOL tokens
|
||||
const res = await api.executeSmartContract('tokens', 'transferToContract', { symbol: HIVE_PEGGED_SYMBOL, quantity: nbTokensToLock, to: CONTRACT_NAME });
|
||||
|
||||
if (res.errors === undefined
|
||||
&& res.events && res.events.find(el => el.contract === 'tokens' && el.event === 'transferToContract' && el.data.from === api.sender && el.data.to === CONTRACT_NAME && el.data.quantity === nbTokensToLock && el.data.symbol === STEEM_PEGGED_SYMBOL) !== undefined) {
|
||||
const timestampSec = api.BigNumber(new Date(`${api.steemBlockTimestamp}.000Z`).getTime())
|
||||
&& res.events && res.events.find(el => el.contract === 'tokens' && el.event === 'transferToContract' && el.data.from === api.sender && el.data.to === CONTRACT_NAME && el.data.quantity === nbTokensToLock && el.data.symbol === HIVE_PEGGED_SYMBOL) !== undefined) {
|
||||
const timestampSec = api.BigNumber(new Date(`${api.hiveBlockTimestamp}.000Z`).getTime())
|
||||
.dividedBy(1000)
|
||||
.toNumber();
|
||||
|
||||
|
@ -733,7 +745,7 @@ actions.buy = async (payload) => {
|
|||
order.account = api.sender;
|
||||
order.symbol = symbol;
|
||||
order.quantity = api.BigNumber(quantity).toFixed(token.precision);
|
||||
order.price = api.BigNumber(price).toFixed(STEEM_PEGGED_SYMBOL_PRESICION);
|
||||
order.price = api.BigNumber(price).toFixed(HIVE_PEGGED_SYMBOL_PRESICION);
|
||||
order.priceDec = { $numberDecimal: order.price };
|
||||
order.tokensLocked = nbTokensToLock;
|
||||
order.expiration = expiration === undefined || expiration > 2592000
|
||||
|
@ -757,10 +769,10 @@ actions.sell = async (payload) => {
|
|||
expiration,
|
||||
isSignedWithActiveKey,
|
||||
} = payload;
|
||||
// sell (quantity) of (symbol) at (price)(STEEM_PEGGED_SYMBOL) per (symbol)
|
||||
// sell (quantity) of (symbol) at (price)(HIVE_PEGGED_SYMBOL) per (symbol)
|
||||
if (api.assert(isSignedWithActiveKey === true, 'you must use a custom_json signed with your active key')
|
||||
&& api.assert(price && typeof price === 'string' && !api.BigNumber(price).isNaN()
|
||||
&& symbol && typeof symbol === 'string' && symbol !== STEEM_PEGGED_SYMBOL
|
||||
&& symbol && typeof symbol === 'string' && symbol !== HIVE_PEGGED_SYMBOL
|
||||
&& quantity && typeof quantity === 'string' && !api.BigNumber(quantity).isNaN()
|
||||
&& (expiration === undefined || (expiration && Number.isInteger(expiration) && expiration > 0)), 'invalid params')) {
|
||||
// get the token params
|
||||
|
@ -769,11 +781,11 @@ actions.sell = async (payload) => {
|
|||
// perform a few verifications
|
||||
if (api.assert(token
|
||||
&& api.BigNumber(price).gt(0)
|
||||
&& countDecimals(price) <= STEEM_PEGGED_SYMBOL_PRESICION
|
||||
&& countDecimals(price) <= HIVE_PEGGED_SYMBOL_PRESICION
|
||||
&& countDecimals(quantity) <= token.precision, 'invalid params')) {
|
||||
const nbTokensToFillOrder = api.BigNumber(price)
|
||||
.multipliedBy(quantity)
|
||||
.toFixed(STEEM_PEGGED_SYMBOL_PRESICION);
|
||||
.toFixed(HIVE_PEGGED_SYMBOL_PRESICION);
|
||||
|
||||
if (api.assert(api.BigNumber(nbTokensToFillOrder).gte('0.00000001'), 'order cannot be placed as it cannot be filled')) {
|
||||
// initiate a transfer from api.sender to contract balance
|
||||
|
@ -782,7 +794,7 @@ actions.sell = async (payload) => {
|
|||
|
||||
if (res.errors === undefined
|
||||
&& res.events && res.events.find(el => el.contract === 'tokens' && el.event === 'transferToContract' && el.data.from === api.sender && el.data.to === CONTRACT_NAME && el.data.quantity === quantity && el.data.symbol === symbol) !== undefined) {
|
||||
const timestampSec = api.BigNumber(new Date(`${api.steemBlockTimestamp}.000Z`).getTime())
|
||||
const timestampSec = api.BigNumber(new Date(`${api.hiveBlockTimestamp}.000Z`).getTime())
|
||||
.dividedBy(1000)
|
||||
.toNumber();
|
||||
|
||||
|
@ -794,7 +806,7 @@ actions.sell = async (payload) => {
|
|||
order.account = api.sender;
|
||||
order.symbol = symbol;
|
||||
order.quantity = api.BigNumber(quantity).toFixed(token.precision);
|
||||
order.price = api.BigNumber(price).toFixed(STEEM_PEGGED_SYMBOL_PRESICION);
|
||||
order.price = api.BigNumber(price).toFixed(HIVE_PEGGED_SYMBOL_PRESICION);
|
||||
order.priceDec = { $numberDecimal: order.price };
|
||||
order.expiration = expiration === undefined || expiration > 2592000
|
||||
? timestampSec + 2592000
|
||||
|
|
150
contracts/nft.js
150
contracts/nft.js
|
@ -28,6 +28,41 @@ const MAX_NUM_NFTS_OPERABLE = 50;
|
|||
// contained within it
|
||||
const MAX_NUM_CONTAINER_NFTS_OPERABLE = 1;
|
||||
|
||||
const RESERVED_SYMBOLS = {
|
||||
CELL: 'beggars',
|
||||
QUST: 'simplegame',
|
||||
TESTERA: 'aggroed',
|
||||
SQRL: 'stuffbyspencer',
|
||||
CRAFT: 'immanuel94',
|
||||
MUSIC: 'atomcollector',
|
||||
CGULL: 'cgull',
|
||||
NFT: 'cadawg',
|
||||
RARE: 'beggars',
|
||||
LIC: 'lictoken',
|
||||
MEMBER: 'membertoken',
|
||||
COFFEE: 'c0ff33a',
|
||||
ART: 'byo',
|
||||
ROCK: 'beggars',
|
||||
CRITTER: 'cryptomancer',
|
||||
CITY: 'gerber',
|
||||
MONSTERS: 'simplegame',
|
||||
SETS: 'lootkit.games',
|
||||
ANIME: 'animetoken',
|
||||
PHOTOFT: 'wwwiebe',
|
||||
BEER: 'detlev',
|
||||
SPIR: 'spinvest',
|
||||
IFG: 'lion200',
|
||||
GUILDS: 'simplegame',
|
||||
FCARD: 'lion200',
|
||||
PXL: 'pixelnft',
|
||||
COW: 'stuffbyspencer',
|
||||
LOOOT: 'stuffbyspencer',
|
||||
API: 'steemcityapi',
|
||||
SPORTSMOM: 'sportstester',
|
||||
SWT: 'satren',
|
||||
STAR: 'atomcollector',
|
||||
};
|
||||
|
||||
actions.createSSC = async () => {
|
||||
const tableExists = await api.db.tableExists('nfts');
|
||||
if (tableExists === false) {
|
||||
|
@ -83,7 +118,7 @@ actions.updateParams = async (payload) => {
|
|||
const isTokenTransferVerified = (result, from, to, symbol, quantity, eventStr) => {
|
||||
if (result.errors === undefined
|
||||
&& result.events && result.events.find(el => el.contract === 'tokens' && el.event === eventStr
|
||||
&& el.data.from === from && el.data.to === to && el.data.quantity === quantity && el.data.symbol === symbol) !== undefined) {
|
||||
&& el.data.from === from && el.data.to === to && el.data.quantity === quantity && el.data.symbol === symbol) !== undefined) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -98,8 +133,8 @@ const countDecimals = value => api.BigNumber(value).dp();
|
|||
// check if duplicate elements in array
|
||||
const containsDuplicates = arr => new Set(arr).size !== arr.length;
|
||||
|
||||
// a valid Steem account is between 3 and 16 characters in length
|
||||
const isValidSteemAccountLength = account => account.length >= 3 && account.length <= 16;
|
||||
// a valid Hive account is between 3 and 16 characters in length
|
||||
const isValidHiveAccountLength = account => account.length >= 3 && account.length <= 16;
|
||||
|
||||
// a valid contract name is between 3 and 50 characters in length
|
||||
const isValidContractLength = contract => contract.length >= 3 && contract.length <= 50;
|
||||
|
@ -107,7 +142,7 @@ const isValidContractLength = contract => contract.length >= 3 && contract.lengt
|
|||
const isValidAccountsArray = (arr) => {
|
||||
let validContents = true;
|
||||
arr.forEach((account) => {
|
||||
if (!(typeof account === 'string') || !isValidSteemAccountLength(account)) {
|
||||
if (!(typeof account === 'string') || !isValidHiveAccountLength(account)) {
|
||||
validContents = false;
|
||||
}
|
||||
});
|
||||
|
@ -141,10 +176,10 @@ const isValidDataProperties = (from, fromType, nft, properties) => {
|
|||
const propertySchema = nft.properties[name];
|
||||
if (api.assert(data !== undefined && data !== null
|
||||
&& (typeof data === propertySchema.type
|
||||
|| (propertySchema.type === 'number' && typeof data === 'string' && !api.BigNumber(data).isNaN())), `data property type mismatch: expected ${propertySchema.type} but got ${typeof data} for property ${name}`)
|
||||
|| (propertySchema.type === 'number' && typeof data === 'string' && !api.BigNumber(data).isNaN())), `data property type mismatch: expected ${propertySchema.type} but got ${typeof data} for property ${name}`)
|
||||
&& api.assert(typeof data !== 'string' || data.length <= MAX_DATA_PROPERTY_LENGTH, `string property max length is ${MAX_DATA_PROPERTY_LENGTH} characters`)
|
||||
&& api.assert((fromType === 'contract' && propertySchema.authorizedEditingContracts.includes(from))
|
||||
|| (fromType === 'user' && propertySchema.authorizedEditingAccounts.includes(from)), 'not allowed to set data properties')) {
|
||||
|| (fromType === 'user' && propertySchema.authorizedEditingAccounts.includes(from)), 'not allowed to set data properties')) {
|
||||
validContents = true;
|
||||
|
||||
// if we have a number type represented as a string, then need to do type conversion
|
||||
|
@ -436,7 +471,7 @@ actions.addAuthorizedIssuingAccounts = async (payload) => {
|
|||
|
||||
if (api.assert(isSignedWithActiveKey === true, 'you must use a custom_json signed with your active key')
|
||||
&& api.assert(symbol && typeof symbol === 'string'
|
||||
&& accounts && typeof accounts === 'object' && Array.isArray(accounts), 'invalid params')
|
||||
&& accounts && typeof accounts === 'object' && Array.isArray(accounts), 'invalid params')
|
||||
&& api.assert(accounts.length <= MAX_NUM_AUTHORIZED_ISSUERS, `cannot have more than ${MAX_NUM_AUTHORIZED_ISSUERS} authorized issuing accounts`)) {
|
||||
const validContents = isValidAccountsArray(accounts);
|
||||
if (api.assert(validContents, 'invalid account list')) {
|
||||
|
@ -477,7 +512,7 @@ actions.addAuthorizedIssuingContracts = async (payload) => {
|
|||
|
||||
if (api.assert(isSignedWithActiveKey === true, 'you must use a custom_json signed with your active key')
|
||||
&& api.assert(symbol && typeof symbol === 'string'
|
||||
&& contracts && typeof contracts === 'object' && Array.isArray(contracts), 'invalid params')
|
||||
&& contracts && typeof contracts === 'object' && Array.isArray(contracts), 'invalid params')
|
||||
&& api.assert(contracts.length <= MAX_NUM_AUTHORIZED_ISSUERS, `cannot have more than ${MAX_NUM_AUTHORIZED_ISSUERS} authorized issuing contracts`)) {
|
||||
const validContents = isValidContractsArray(contracts);
|
||||
if (api.assert(validContents, 'invalid contract list')) {
|
||||
|
@ -518,7 +553,7 @@ actions.removeAuthorizedIssuingAccounts = async (payload) => {
|
|||
|
||||
if (api.assert(isSignedWithActiveKey === true, 'you must use a custom_json signed with your active key')
|
||||
&& api.assert(symbol && typeof symbol === 'string'
|
||||
&& accounts && typeof accounts === 'object' && Array.isArray(accounts), 'invalid params')
|
||||
&& accounts && typeof accounts === 'object' && Array.isArray(accounts), 'invalid params')
|
||||
&& api.assert(accounts.length <= MAX_NUM_AUTHORIZED_ISSUERS, `cannot remove more than ${MAX_NUM_AUTHORIZED_ISSUERS} authorized issuing accounts`)) {
|
||||
const validContents = isValidAccountsArray(accounts);
|
||||
if (api.assert(validContents, 'invalid account list')) {
|
||||
|
@ -551,7 +586,7 @@ actions.removeAuthorizedIssuingContracts = async (payload) => {
|
|||
|
||||
if (api.assert(isSignedWithActiveKey === true, 'you must use a custom_json signed with your active key')
|
||||
&& api.assert(symbol && typeof symbol === 'string'
|
||||
&& contracts && typeof contracts === 'object' && Array.isArray(contracts), 'invalid params')
|
||||
&& contracts && typeof contracts === 'object' && Array.isArray(contracts), 'invalid params')
|
||||
&& api.assert(contracts.length <= MAX_NUM_AUTHORIZED_ISSUERS, `cannot remove more than ${MAX_NUM_AUTHORIZED_ISSUERS} authorized issuing contracts`)) {
|
||||
const validContents = isValidContractsArray(contracts);
|
||||
if (api.assert(validContents, 'invalid contract list')) {
|
||||
|
@ -584,7 +619,7 @@ actions.transferOwnership = async (payload) => {
|
|||
|
||||
if (api.assert(isSignedWithActiveKey === true, 'you must use a custom_json signed with your active key')
|
||||
&& api.assert(symbol && typeof symbol === 'string'
|
||||
&& to && typeof to === 'string', 'invalid params')) {
|
||||
&& to && typeof to === 'string', 'invalid params')) {
|
||||
// check if the NFT exists
|
||||
const nft = await api.db.findOne('nfts', { symbol });
|
||||
|
||||
|
@ -592,7 +627,7 @@ actions.transferOwnership = async (payload) => {
|
|||
if (api.assert(nft.issuer === api.sender, 'must be the issuer')) {
|
||||
const finalTo = to.trim().toLowerCase();
|
||||
|
||||
if (api.assert(isValidSteemAccountLength(finalTo), 'invalid to')) {
|
||||
if (api.assert(isValidHiveAccountLength(finalTo), 'invalid to')) {
|
||||
nft.issuer = finalTo;
|
||||
await api.db.update('nfts', nft);
|
||||
}
|
||||
|
@ -655,12 +690,12 @@ actions.updatePropertyDefinition = async (payload) => {
|
|||
|
||||
if (api.assert(isSignedWithActiveKey === true, 'you must use a custom_json signed with your active key')
|
||||
&& api.assert(symbol && typeof symbol === 'string'
|
||||
&& name && typeof name === 'string', 'invalid params')
|
||||
&& name && typeof name === 'string', 'invalid params')
|
||||
&& api.assert(api.validator.isAlphanumeric(name) && name.length > 0 && name.length <= 25, 'invalid name: letters & numbers only, max length of 25')
|
||||
&& api.assert(newName === undefined
|
||||
|| (typeof newName === 'string' && api.validator.isAlphanumeric(newName) && newName.length > 0 && newName.length <= 25), 'invalid new name: letters & numbers only, max length of 25')
|
||||
|| (typeof newName === 'string' && api.validator.isAlphanumeric(newName) && newName.length > 0 && newName.length <= 25), 'invalid new name: letters & numbers only, max length of 25')
|
||||
&& api.assert(type === undefined
|
||||
|| (typeof type === 'string' && (type === 'number' || type === 'string' || type === 'boolean')), 'invalid type: must be number, string, or boolean')
|
||||
|| (typeof type === 'string' && (type === 'number' || type === 'string' || type === 'boolean')), 'invalid type: must be number, string, or boolean')
|
||||
&& api.assert(isReadOnly === undefined || typeof isReadOnly === 'boolean', 'invalid isReadOnly: must be true or false')) {
|
||||
// check if the NFT exists
|
||||
const nft = await api.db.findOne('nfts', { symbol });
|
||||
|
@ -727,11 +762,11 @@ actions.addProperty = async (payload) => {
|
|||
|
||||
if (api.assert(isSignedWithActiveKey === true, 'you must use a custom_json signed with your active key')
|
||||
&& api.assert(symbol && typeof symbol === 'string'
|
||||
&& name && typeof name === 'string'
|
||||
&& (isReadOnly === undefined || typeof isReadOnly === 'boolean')
|
||||
&& (authorizedEditingAccounts === undefined || (authorizedEditingAccounts && typeof authorizedEditingAccounts === 'object' && Array.isArray(authorizedEditingAccounts)))
|
||||
&& (authorizedEditingContracts === undefined || (authorizedEditingContracts && typeof authorizedEditingContracts === 'object' && Array.isArray(authorizedEditingContracts)))
|
||||
&& type && typeof type === 'string', 'invalid params')
|
||||
&& name && typeof name === 'string'
|
||||
&& (isReadOnly === undefined || typeof isReadOnly === 'boolean')
|
||||
&& (authorizedEditingAccounts === undefined || (authorizedEditingAccounts && typeof authorizedEditingAccounts === 'object' && Array.isArray(authorizedEditingAccounts)))
|
||||
&& (authorizedEditingContracts === undefined || (authorizedEditingContracts && typeof authorizedEditingContracts === 'object' && Array.isArray(authorizedEditingContracts)))
|
||||
&& type && typeof type === 'string', 'invalid params')
|
||||
&& api.assert(api.validator.isAlphanumeric(name) && name.length > 0 && name.length <= 25, 'invalid name: letters & numbers only, max length of 25')
|
||||
&& api.assert(type === 'number' || type === 'string' || type === 'boolean', 'invalid type: must be number, string, or boolean')) {
|
||||
// check if the NFT exists
|
||||
|
@ -798,9 +833,9 @@ actions.setPropertyPermissions = async (payload) => {
|
|||
|
||||
if (api.assert(isSignedWithActiveKey === true, 'you must use a custom_json signed with your active key')
|
||||
&& api.assert(symbol && typeof symbol === 'string'
|
||||
&& name && typeof name === 'string'
|
||||
&& (accounts === undefined || (accounts && typeof accounts === 'object' && Array.isArray(accounts)))
|
||||
&& (contracts === undefined || (contracts && typeof contracts === 'object' && Array.isArray(contracts))), 'invalid params')
|
||||
&& name && typeof name === 'string'
|
||||
&& (accounts === undefined || (accounts && typeof accounts === 'object' && Array.isArray(accounts)))
|
||||
&& (contracts === undefined || (contracts && typeof contracts === 'object' && Array.isArray(contracts))), 'invalid params')
|
||||
&& api.assert(api.validator.isAlphanumeric(name) && name.length > 0 && name.length <= 25, 'invalid name: letters & numbers only, max length of 25')
|
||||
&& api.assert(accounts === undefined || accounts.length <= MAX_NUM_AUTHORIZED_ISSUERS, `cannot have more than ${MAX_NUM_AUTHORIZED_ISSUERS} authorized accounts`)
|
||||
&& api.assert(contracts === undefined || contracts.length <= MAX_NUM_AUTHORIZED_ISSUERS, `cannot have more than ${MAX_NUM_AUTHORIZED_ISSUERS} authorized contracts`)
|
||||
|
@ -849,7 +884,7 @@ actions.setGroupBy = async (payload) => {
|
|||
|
||||
if (api.assert(isSignedWithActiveKey === true, 'you must use a custom_json signed with your active key')
|
||||
&& api.assert(symbol && typeof symbol === 'string'
|
||||
&& properties && typeof properties === 'object' && Array.isArray(properties), 'invalid params')) {
|
||||
&& properties && typeof properties === 'object' && Array.isArray(properties), 'invalid params')) {
|
||||
// check if the NFT exists
|
||||
const nft = await api.db.findOne('nfts', { symbol });
|
||||
|
||||
|
@ -945,8 +980,8 @@ actions.burn = async (payload) => {
|
|||
|
||||
if (api.assert(isSignedWithActiveKey === true, 'you must use a custom_json signed with your active key')
|
||||
&& api.assert(finalFromType && typeof finalFromType === 'string' && types.includes(finalFromType)
|
||||
&& (callingContractInfo || (callingContractInfo === undefined && finalFromType === 'user'))
|
||||
&& nfts && typeof nfts === 'object' && Array.isArray(nfts), 'invalid params')
|
||||
&& (callingContractInfo || (callingContractInfo === undefined && finalFromType === 'user'))
|
||||
&& nfts && typeof nfts === 'object' && Array.isArray(nfts), 'invalid params')
|
||||
&& isValidNftIdArray(nfts)) {
|
||||
const finalFrom = finalFromType === 'user' ? api.sender : callingContractInfo.name;
|
||||
|
||||
|
@ -984,7 +1019,7 @@ actions.burn = async (payload) => {
|
|||
// and there is no existing delegation and container restrictions are satisfied
|
||||
if (nftInstance.account === finalFrom
|
||||
&& ((nftInstance.ownedBy === 'u' && finalFromType === 'user')
|
||||
|| (nftInstance.ownedBy === 'c' && finalFromType === 'contract'))
|
||||
|| (nftInstance.ownedBy === 'c' && finalFromType === 'contract'))
|
||||
&& nftInstance.delegatedTo === undefined
|
||||
&& isBurnAuthorized) {
|
||||
// release any locked tokens back to the owning account
|
||||
|
@ -1048,13 +1083,13 @@ actions.transfer = async (payload) => {
|
|||
|
||||
if (api.assert(isSignedWithActiveKey === true, 'you must use a custom_json signed with your active key')
|
||||
&& api.assert(finalFromType && typeof finalFromType === 'string' && types.includes(finalFromType)
|
||||
&& to && typeof to === 'string'
|
||||
&& finalToType && typeof finalToType === 'string' && types.includes(finalToType)
|
||||
&& (callingContractInfo || (callingContractInfo === undefined && finalFromType === 'user'))
|
||||
&& nfts && typeof nfts === 'object' && Array.isArray(nfts), 'invalid params')
|
||||
&& to && typeof to === 'string'
|
||||
&& finalToType && typeof finalToType === 'string' && types.includes(finalToType)
|
||||
&& (callingContractInfo || (callingContractInfo === undefined && finalFromType === 'user'))
|
||||
&& nfts && typeof nfts === 'object' && Array.isArray(nfts), 'invalid params')
|
||||
&& isValidNftIdArray(nfts)) {
|
||||
const finalTo = finalToType === 'user' ? to.trim().toLowerCase() : to.trim();
|
||||
const toValid = finalToType === 'user' ? isValidSteemAccountLength(finalTo) : isValidContractLength(finalTo);
|
||||
const toValid = finalToType === 'user' ? isValidHiveAccountLength(finalTo) : isValidContractLength(finalTo);
|
||||
const finalFrom = finalFromType === 'user' ? api.sender : callingContractInfo.name;
|
||||
|
||||
if (api.assert(toValid, 'invalid to')
|
||||
|
@ -1075,7 +1110,7 @@ actions.transfer = async (payload) => {
|
|||
// and there is no existing delegation
|
||||
if (nftInstance.account === finalFrom
|
||||
&& ((nftInstance.ownedBy === 'u' && finalFromType === 'user')
|
||||
|| (nftInstance.ownedBy === 'c' && finalFromType === 'contract'))
|
||||
|| (nftInstance.ownedBy === 'c' && finalFromType === 'contract'))
|
||||
&& nftInstance.delegatedTo === undefined) {
|
||||
const origOwnedBy = nftInstance.ownedBy;
|
||||
const newOwnedBy = finalToType === 'user' ? 'u' : 'c';
|
||||
|
@ -1110,13 +1145,13 @@ actions.delegate = async (payload) => {
|
|||
|
||||
if (api.assert(isSignedWithActiveKey === true, 'you must use a custom_json signed with your active key')
|
||||
&& api.assert(finalFromType && typeof finalFromType === 'string' && types.includes(finalFromType)
|
||||
&& to && typeof to === 'string'
|
||||
&& finalToType && typeof finalToType === 'string' && types.includes(finalToType)
|
||||
&& (callingContractInfo || (callingContractInfo === undefined && finalFromType === 'user'))
|
||||
&& nfts && typeof nfts === 'object' && Array.isArray(nfts), 'invalid params')
|
||||
&& to && typeof to === 'string'
|
||||
&& finalToType && typeof finalToType === 'string' && types.includes(finalToType)
|
||||
&& (callingContractInfo || (callingContractInfo === undefined && finalFromType === 'user'))
|
||||
&& nfts && typeof nfts === 'object' && Array.isArray(nfts), 'invalid params')
|
||||
&& isValidNftIdArray(nfts)) {
|
||||
const finalTo = finalToType === 'user' ? to.trim().toLowerCase() : to.trim();
|
||||
const toValid = finalToType === 'user' ? isValidSteemAccountLength(finalTo) : isValidContractLength(finalTo);
|
||||
const toValid = finalToType === 'user' ? isValidHiveAccountLength(finalTo) : isValidContractLength(finalTo);
|
||||
const finalFrom = finalFromType === 'user' ? api.sender : callingContractInfo.name;
|
||||
|
||||
if (api.assert(toValid, 'invalid to')
|
||||
|
@ -1138,7 +1173,7 @@ actions.delegate = async (payload) => {
|
|||
// and there is no existing delegation
|
||||
if (nftInstance.account === finalFrom
|
||||
&& ((nftInstance.ownedBy === 'u' && finalFromType === 'user')
|
||||
|| (nftInstance.ownedBy === 'c' && finalFromType === 'contract'))
|
||||
|| (nftInstance.ownedBy === 'c' && finalFromType === 'contract'))
|
||||
&& nftInstance.delegatedTo === undefined) {
|
||||
const newOwnedBy = finalToType === 'user' ? 'u' : 'c';
|
||||
|
||||
|
@ -1174,11 +1209,11 @@ actions.undelegate = async (payload) => {
|
|||
|
||||
if (api.assert(isSignedWithActiveKey === true, 'you must use a custom_json signed with your active key')
|
||||
&& api.assert(finalFromType && typeof finalFromType === 'string' && types.includes(finalFromType)
|
||||
&& (callingContractInfo || (callingContractInfo === undefined && finalFromType === 'user'))
|
||||
&& nfts && typeof nfts === 'object' && Array.isArray(nfts), 'invalid params')
|
||||
&& (callingContractInfo || (callingContractInfo === undefined && finalFromType === 'user'))
|
||||
&& nfts && typeof nfts === 'object' && Array.isArray(nfts), 'invalid params')
|
||||
&& isValidNftIdArray(nfts)) {
|
||||
const finalFrom = finalFromType === 'user' ? api.sender : callingContractInfo.name;
|
||||
const blockDate = new Date(`${api.steemBlockTimestamp}.000Z`);
|
||||
const blockDate = new Date(`${api.hiveBlockTimestamp}.000Z`);
|
||||
|
||||
for (let i = 0; i < nfts.length; i += 1) {
|
||||
const { symbol, ids } = nfts[i];
|
||||
|
@ -1206,7 +1241,7 @@ actions.undelegate = async (payload) => {
|
|||
// and there is an existing delegation that is not pending undelegation
|
||||
if (nftInstance.account === finalFrom
|
||||
&& ((nftInstance.ownedBy === 'u' && finalFromType === 'user')
|
||||
|| (nftInstance.ownedBy === 'c' && finalFromType === 'contract'))
|
||||
|| (nftInstance.ownedBy === 'c' && finalFromType === 'contract'))
|
||||
&& nftInstance.delegatedTo
|
||||
&& nftInstance.delegatedTo.undelegateAt === undefined) {
|
||||
nftInstance.delegatedTo.undelegateAt = completeTimestamp;
|
||||
|
@ -1266,7 +1301,7 @@ const processUndelegation = async (undelegation) => {
|
|||
|
||||
actions.checkPendingUndelegations = async () => {
|
||||
if (api.assert(api.sender === 'null', 'not authorized')) {
|
||||
const blockDate = new Date(`${api.steemBlockTimestamp}.000Z`);
|
||||
const blockDate = new Date(`${api.hiveBlockTimestamp}.000Z`);
|
||||
const timestamp = blockDate.getTime();
|
||||
|
||||
// get all the pending undelegations that are ready to be released
|
||||
|
@ -1317,8 +1352,8 @@ actions.create = async (payload) => {
|
|||
: utilityTokenBalance && api.BigNumber(utilityTokenBalance.balance).gte(nftCreationFee);
|
||||
|
||||
if (api.assert(authorizedCreation, 'you must have enough tokens to cover the creation fees')
|
||||
&& api.assert(isSignedWithActiveKey === true, 'you must use a custom_json signed with your active key')
|
||||
&& api.assert(name && typeof name === 'string'
|
||||
&& api.assert(isSignedWithActiveKey === true, 'you must use a custom_json signed with your active key')
|
||||
&& api.assert(name && typeof name === 'string'
|
||||
&& symbol && typeof symbol === 'string'
|
||||
&& (url === undefined || (url && typeof url === 'string'))
|
||||
&& (orgName === undefined || (orgName && typeof orgName === 'string'))
|
||||
|
@ -1327,11 +1362,12 @@ actions.create = async (payload) => {
|
|||
&& (authorizedIssuingContracts === undefined || (authorizedIssuingContracts && typeof authorizedIssuingContracts === 'object' && Array.isArray(authorizedIssuingContracts)))
|
||||
&& (maxSupply === undefined || (maxSupply && typeof maxSupply === 'string' && !api.BigNumber(maxSupply).isNaN())), 'invalid params')) {
|
||||
if (api.assert(api.validator.isAlpha(symbol) && api.validator.isUppercase(symbol) && symbol.length > 0 && symbol.length <= MAX_SYMBOL_LENGTH, `invalid symbol: uppercase letters only, max length of ${MAX_SYMBOL_LENGTH}`)
|
||||
&& api.assert(RESERVED_SYMBOLS[symbol] === undefined || api.sender === RESERVED_SYMBOLS[symbol], 'cannot use this symbol')
|
||||
&& api.assert(api.validator.isAlphanumeric(api.validator.blacklist(name, ' ')) && name.length > 0 && name.length <= 50, 'invalid name: letters, numbers, whitespaces only, max length of 50')
|
||||
&& api.assert(orgName === undefined
|
||||
|| (api.validator.isAlphanumeric(api.validator.blacklist(orgName, ' ')) && orgName.length > 0 && orgName.length <= 50), 'invalid org name: letters, numbers, whitespaces only, max length of 50')
|
||||
|| (api.validator.isAlphanumeric(api.validator.blacklist(orgName, ' ')) && orgName.length > 0 && orgName.length <= 50), 'invalid org name: letters, numbers, whitespaces only, max length of 50')
|
||||
&& api.assert(productName === undefined
|
||||
|| (api.validator.isAlphanumeric(api.validator.blacklist(productName, ' ')) && productName.length > 0 && productName.length <= 50), 'invalid product name: letters, numbers, whitespaces only, max length of 50')
|
||||
|| (api.validator.isAlphanumeric(api.validator.blacklist(productName, ' ')) && productName.length > 0 && productName.length <= 50), 'invalid product name: letters, numbers, whitespaces only, max length of 50')
|
||||
&& api.assert(url === undefined || url.length <= 255, 'invalid url: max length of 255')
|
||||
&& api.assert(maxSupply === undefined || api.BigNumber(maxSupply).gt(0), 'maxSupply must be positive')
|
||||
&& api.assert(maxSupply === undefined || api.BigNumber(maxSupply).lte(Number.MAX_SAFE_INTEGER), `maxSupply must be lower than ${Number.MAX_SAFE_INTEGER}`)) {
|
||||
|
@ -1418,17 +1454,17 @@ actions.issue = async (payload) => {
|
|||
|
||||
if (api.assert(isSignedWithActiveKey === true, 'you must use a custom_json signed with your active key')
|
||||
&& api.assert(symbol && typeof symbol === 'string'
|
||||
&& finalFromType && typeof finalFromType === 'string' && types.includes(finalFromType)
|
||||
&& (callingContractInfo || (callingContractInfo === undefined && finalFromType === 'user'))
|
||||
&& to && typeof to === 'string'
|
||||
&& finalToType && typeof finalToType === 'string' && types.includes(finalToType)
|
||||
&& feeSymbol && typeof feeSymbol === 'string' && feeSymbol in nftIssuanceFee
|
||||
&& (properties === undefined || (properties && typeof properties === 'object'))
|
||||
&& (lockTokens === undefined || (lockTokens && typeof lockTokens === 'object'))
|
||||
&& (lockNfts === undefined || (lockNfts && typeof lockNfts === 'object' && Array.isArray(lockNfts))), 'invalid params')
|
||||
&& finalFromType && typeof finalFromType === 'string' && types.includes(finalFromType)
|
||||
&& (callingContractInfo || (callingContractInfo === undefined && finalFromType === 'user'))
|
||||
&& to && typeof to === 'string'
|
||||
&& finalToType && typeof finalToType === 'string' && types.includes(finalToType)
|
||||
&& feeSymbol && typeof feeSymbol === 'string' && feeSymbol in nftIssuanceFee
|
||||
&& (properties === undefined || (properties && typeof properties === 'object'))
|
||||
&& (lockTokens === undefined || (lockTokens && typeof lockTokens === 'object'))
|
||||
&& (lockNfts === undefined || (lockNfts && typeof lockNfts === 'object' && Array.isArray(lockNfts))), 'invalid params')
|
||||
&& (lockNfts === undefined || isValidNftIdArray(lockNfts))) {
|
||||
const finalTo = finalToType === 'user' ? to.trim().toLowerCase() : to.trim();
|
||||
const toValid = finalToType === 'user' ? isValidSteemAccountLength(finalTo) : isValidContractLength(finalTo);
|
||||
const toValid = finalToType === 'user' ? isValidHiveAccountLength(finalTo) : isValidContractLength(finalTo);
|
||||
const finalFrom = finalFromType === 'user' ? api.sender : callingContractInfo.name;
|
||||
const balanceTableName = finalFromType === 'user' ? 'balances' : 'contractsBalances';
|
||||
if (api.assert(toValid, 'invalid to')) {
|
||||
|
|
|
@ -25,8 +25,8 @@ const isTokenTransferVerified = (result, from, to, symbol, quantity, eventStr) =
|
|||
|
||||
const countDecimals = value => api.BigNumber(value).dp();
|
||||
|
||||
// a valid Steem account is between 3 and 16 characters in length
|
||||
const isValidSteemAccountLength = account => account.length >= 3 && account.length <= 16;
|
||||
// a valid Hive account is between 3 and 16 characters in length
|
||||
const isValidHiveAccountLength = account => account.length >= 3 && account.length <= 16;
|
||||
|
||||
// helper for buy action
|
||||
const makeMapKey = (account, type) => account + '-' + type;
|
||||
|
@ -153,7 +153,7 @@ const updateOpenInterest = async (side, symbol, priceSymbol, groups, groupBy) =>
|
|||
};
|
||||
|
||||
const updateTradesHistory = async (type, account, ownedBy, counterparties, symbol, priceSymbol, price, marketAccount, fee, volume) => {
|
||||
const blockDate = new Date(`${api.steemBlockTimestamp}.000Z`);
|
||||
const blockDate = new Date(`${api.hiveBlockTimestamp}.000Z`);
|
||||
const timestampSec = blockDate.getTime() / 1000;
|
||||
const timestampMinus24hrs = blockDate.setDate(blockDate.getDate() - 1) / 1000;
|
||||
const historyTableName = symbol + 'tradesHistory';
|
||||
|
@ -419,7 +419,7 @@ actions.buy = async (payload) => {
|
|||
&& isValidIdArray(nfts)
|
||||
&& api.assert(tableExists, 'market not enabled for symbol')) {
|
||||
const finalMarketAccount = marketAccount.trim().toLowerCase();
|
||||
if (api.assert(isValidSteemAccountLength(finalMarketAccount), 'invalid market account')) {
|
||||
if (api.assert(isValidHiveAccountLength(finalMarketAccount), 'invalid market account')) {
|
||||
const nft = await api.db.findOneInTable('nft', 'nfts', { symbol });
|
||||
if (!api.assert(nft && nft.groupBy && nft.groupBy.length > 0, 'market grouping not set')) {
|
||||
return;
|
||||
|
@ -642,7 +642,7 @@ actions.sell = async (payload) => {
|
|||
// errors & whatnot, so we need to loop over the transfer results and
|
||||
// only create market orders for the transfers that succeeded
|
||||
if (res.events) {
|
||||
const blockDate = new Date(`${api.steemBlockTimestamp}.000Z`);
|
||||
const blockDate = new Date(`${api.hiveBlockTimestamp}.000Z`);
|
||||
const timestamp = blockDate.getTime();
|
||||
const finalPrice = api.BigNumber(price).toFixed(token.precision);
|
||||
const nftIntegerIdList = [];
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
/* eslint-disable no-await-in-loop */
|
||||
/* global actions, api */
|
||||
|
||||
actions.createSSC = async () => {
|
||||
await api.db.createTable('params');
|
||||
const params = {};
|
||||
|
||||
params.priceHBD = '1000000';
|
||||
// eslint-disable-next-line no-template-curly-in-string
|
||||
params.priceHive = "'${CONSTANTS.SSC_STORE_PRICE}$'";
|
||||
// eslint-disable-next-line no-template-curly-in-string
|
||||
params.quantity = "'${CONSTANTS.SSC_STORE_QTY}$'";
|
||||
params.disabled = false;
|
||||
|
||||
await api.db.insert('params', params);
|
||||
};
|
||||
|
||||
actions.updateParams = async (payload) => {
|
||||
if (api.sender !== api.owner) return;
|
||||
|
||||
const {
|
||||
priceHBD, priceHive, quantity, disabled,
|
||||
} = payload;
|
||||
|
||||
const params = await api.db.findOne('params', {});
|
||||
|
||||
params.priceHBD = priceHBD;
|
||||
params.priceHive = priceHive;
|
||||
params.quantity = quantity;
|
||||
params.disabled = disabled;
|
||||
|
||||
await api.db.update('params', params);
|
||||
};
|
||||
|
||||
actions.buy = async (payload) => {
|
||||
const { recipient, amountHIVEHBD, isSignedWithActiveKey } = payload;
|
||||
|
||||
if (recipient !== api.owner) return;
|
||||
|
||||
if (api.assert(recipient && amountHIVEHBD && isSignedWithActiveKey, 'invalid params')) {
|
||||
const params = await api.db.findOne('params', {});
|
||||
|
||||
if (params.disabled) return;
|
||||
|
||||
const res = amountHIVEHBD.split(' ');
|
||||
|
||||
const amount = res[0];
|
||||
const unit = res[1];
|
||||
|
||||
let quantity = 0;
|
||||
let quantityToSend = 0;
|
||||
api.BigNumber.set({ DECIMAL_PLACES: 3 });
|
||||
|
||||
// HIVE
|
||||
if (unit === 'HIVE') {
|
||||
quantity = api.BigNumber(amount).dividedBy(params.priceHive);
|
||||
} else { // HBD (disabled)
|
||||
// quantity = api.BigNumber(amount).dividedBy(params.priceHBD);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-template-curly-in-string
|
||||
quantityToSend = api.BigNumber(quantity).multipliedBy(params.quantity).toFixed('${CONSTANTS.UTILITY_TOKEN_PRECISION}$');
|
||||
|
||||
if (quantityToSend > 0) {
|
||||
// eslint-disable-next-line no-template-curly-in-string
|
||||
await api.executeSmartContractAsOwner('tokens', 'transfer', { symbol: "'${CONSTANTS.UTILITY_TOKEN_SYMBOL}$'", quantity: quantityToSend, to: api.sender });
|
||||
}
|
||||
}
|
||||
};
|
File diff suppressed because it is too large
Load Diff
|
@ -403,7 +403,7 @@ const changeCurrentWitness = async () => {
|
|||
await api.db.update('schedules', schedule);
|
||||
params.currentWitness = witness.account;
|
||||
params.lastWitnesses.push(witness.account);
|
||||
params.blockNumberWitnessChange = api.refSteemBlockNumber
|
||||
params.blockNumberWitnessChange = api.refHiveBlockNumber
|
||||
+ MAX_ROUND_PROPOSITION_WAITING_PERIOD;
|
||||
await api.db.update('params', params);
|
||||
|
||||
|
@ -458,7 +458,7 @@ const changeCurrentWitness = async () => {
|
|||
await api.db.update('schedules', sched);
|
||||
params.currentWitness = newWitness;
|
||||
params.lastWitnesses.push(newWitness);
|
||||
params.blockNumberWitnessChange = api.refSteemBlockNumber
|
||||
params.blockNumberWitnessChange = api.refHiveBlockNumber
|
||||
+ MAX_ROUND_PROPOSITION_WAITING_PERIOD;
|
||||
await api.db.update('params', params);
|
||||
|
||||
|
@ -667,17 +667,17 @@ const manageWitnessesSchedule = async () => {
|
|||
params.currentWitness = lastWitnessRoundSchedule.witness;
|
||||
lastWitnesses.push(lastWitnessRoundSchedule.witness);
|
||||
params.lastWitnesses = lastWitnesses;
|
||||
params.blockNumberWitnessChange = api.refSteemBlockNumber
|
||||
params.blockNumberWitnessChange = api.refHiveBlockNumber
|
||||
+ MAX_ROUND_PROPOSITION_WAITING_PERIOD;
|
||||
await api.db.update('params', params);
|
||||
api.emit('newSchedule', { });
|
||||
}
|
||||
} else if (api.refSteemBlockNumber >= blockNumberWitnessChange) {
|
||||
} else if (api.refHiveBlockNumber >= blockNumberWitnessChange) {
|
||||
if (api.blockNumber > lastBlockRound) {
|
||||
// otherwise we change the current witness if it has not proposed the round in time
|
||||
await changeCurrentWitness();
|
||||
} else {
|
||||
params.blockNumberWitnessChange = api.refSteemBlockNumber
|
||||
params.blockNumberWitnessChange = api.refHiveBlockNumber
|
||||
+ MAX_ROUND_PROPOSITION_WAITING_PERIOD;
|
||||
await api.db.update('params', params);
|
||||
api.emit('awaitingRoundEnd', { });
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
const SHA256 = require('crypto-js/sha256');
|
||||
const enchex = require('crypto-js/enc-hex');
|
||||
const { CONSTANTS } = require('../libs/Constants');
|
||||
|
||||
const { SmartContracts } = require('./SmartContracts');
|
||||
const { Transaction } = require('../libs/Transaction');
|
||||
|
||||
class Block {
|
||||
constructor(timestamp, refSteemBlockNumber, refSteemBlockId, prevRefSteemBlockId, transactions, previousBlockNumber, previousHash = '', previousDatabaseHash = '') {
|
||||
constructor(timestamp, refHiveBlockNumber, refHiveBlockId, prevRefHiveBlockId, transactions, previousBlockNumber, previousHash = '', previousDatabaseHash = '') {
|
||||
this.blockNumber = previousBlockNumber + 1;
|
||||
this.refSteemBlockNumber = refSteemBlockNumber;
|
||||
this.refSteemBlockId = refSteemBlockId;
|
||||
this.prevRefSteemBlockId = prevRefSteemBlockId;
|
||||
this.refHiveBlockNumber = refHiveBlockNumber;
|
||||
this.refHiveBlockId = refHiveBlockId;
|
||||
this.prevRefHiveBlockId = prevRefHiveBlockId;
|
||||
this.previousHash = previousHash;
|
||||
this.previousDatabaseHash = previousDatabaseHash;
|
||||
this.timestamp = timestamp;
|
||||
|
@ -31,10 +32,11 @@ class Block {
|
|||
this.previousHash
|
||||
+ this.previousDatabaseHash
|
||||
+ this.blockNumber.toString()
|
||||
+ this.refSteemBlockNumber.toString()
|
||||
+ this.refSteemBlockId
|
||||
+ this.prevRefSteemBlockId
|
||||
+ this.refHiveBlockNumber.toString()
|
||||
+ this.refHiveBlockId
|
||||
+ this.prevRefHiveBlockId
|
||||
+ this.timestamp
|
||||
+ this.merkleRoot
|
||||
+ JSON.stringify(this.transactions) // eslint-disable-line
|
||||
)
|
||||
.toString(enchex);
|
||||
|
@ -92,38 +94,33 @@ class Block {
|
|||
// handle virtual transactions
|
||||
const virtualTransactions = [];
|
||||
|
||||
// check the pending unstakings and undelegation
|
||||
if (this.refSteemBlockNumber >= 32713424) {
|
||||
virtualTransactions.push(new Transaction(0, '', 'null', 'tokens', 'checkPendingUnstakes', ''));
|
||||
virtualTransactions.push(new Transaction(0, '', 'null', 'tokens', 'checkPendingUndelegations', ''));
|
||||
}
|
||||
virtualTransactions.push(new Transaction(0, '', 'null', 'tokens', 'checkPendingUnstakes', ''));
|
||||
virtualTransactions.push(new Transaction(0, '', 'null', 'tokens', 'checkPendingUndelegations', ''));
|
||||
virtualTransactions.push(new Transaction(0, '', 'null', 'nft', 'checkPendingUndelegations', ''));
|
||||
|
||||
// TODO: cleanup
|
||||
// if (this.refSteemBlockNumber >= 37899120) {
|
||||
virtualTransactions.push(new Transaction(0, '', 'null', 'witnesses', 'scheduleWitnesses', ''));
|
||||
// if (this.refHiveBlockNumber >= 37899120) {
|
||||
// virtualTransactions
|
||||
// .push(new Transaction(0, '', 'null', 'witnesses', 'scheduleWitnesses', ''));
|
||||
// }
|
||||
|
||||
if (this.refSteemBlockNumber >= 38145385) {
|
||||
// issue new utility tokens every time the refSteemBlockNumber % 1200 equals 0
|
||||
if (this.refSteemBlockNumber % 1200 === 0) {
|
||||
virtualTransactions.push(new Transaction(0, '', 'null', 'inflation', 'issueNewTokens', '{ "isSignedWithActiveKey": true }'));
|
||||
/*
|
||||
if (this.refHiveBlockNumber >= 38145385) {
|
||||
// issue new utility tokens every time the refHiveBlockNumber % 1200 equals 0
|
||||
if (this.refHiveBlockNumber % 1200 === 0) {
|
||||
virtualTransactions
|
||||
.push(new Transaction(
|
||||
0, '', 'null', 'inflation', 'issueNewTokens', '{ "isSignedWithActiveKey": true }'));
|
||||
}
|
||||
|
||||
virtualTransactions.push(new Transaction(0, '', 'null', 'nft', 'checkPendingUndelegations', ''));
|
||||
}
|
||||
|
||||
// LOAD TEST - TO BE REMOVED WHEN MOVING TO MAINNET
|
||||
if (this.refSteemBlockNumber >= 40939919) {
|
||||
// create a random transaction that will generate a block on every Steem block parsed
|
||||
// basically, every 3secs
|
||||
virtualTransactions.push(new Transaction(0, '', 'whatever', 'whatever', 'whatever', ''));
|
||||
}
|
||||
*/
|
||||
|
||||
const nbVirtualTransactions = virtualTransactions.length;
|
||||
for (let i = 0; i < nbVirtualTransactions; i += 1) {
|
||||
const transaction = virtualTransactions[i];
|
||||
transaction.refSteemBlockNumber = this.refSteemBlockNumber;
|
||||
transaction.transactionId = `${this.refSteemBlockNumber}-${i}`;
|
||||
transaction.refHiveBlockNumber = this.refHiveBlockNumber;
|
||||
transaction.transactionId = `${this.refHiveBlockNumber}-${i}`;
|
||||
await this.processTransaction(database, jsVMTimeout, transaction, currentDatabaseHash); // eslint-disable-line
|
||||
currentDatabaseHash = transaction.databaseHash;
|
||||
// if there are outputs in the virtual transaction we save the transaction into the block
|
||||
|
@ -175,12 +172,12 @@ class Block {
|
|||
|
||||
if (sender && contract && action) {
|
||||
if (contract === 'contract' && (action === 'deploy' || action === 'update') && payload) {
|
||||
const authorizedAccountContractDeployment = ['null', 'steemsc', 'steem-peg'];
|
||||
const authorizedAccountContractDeployment = ['null', CONSTANTS.HIVE_ENGINE_ACCOUNT, CONSTANTS.HIVE_PEGGED_ACCOUNT];
|
||||
|
||||
if (authorizedAccountContractDeployment.includes(sender)) {
|
||||
results = await SmartContracts.deploySmartContract( // eslint-disable-line
|
||||
database, transaction, this.blockNumber, this.timestamp,
|
||||
this.refSteemBlockId, this.prevRefSteemBlockId, jsVMTimeout,
|
||||
this.refHiveBlockId, this.prevRefHiveBlockId, jsVMTimeout,
|
||||
);
|
||||
} else {
|
||||
results = { logs: { errors: ['the contract deployment is currently unavailable'] } };
|
||||
|
@ -188,7 +185,7 @@ class Block {
|
|||
} else {
|
||||
results = await SmartContracts.executeSmartContract(// eslint-disable-line
|
||||
database, transaction, this.blockNumber, this.timestamp,
|
||||
this.refSteemBlockId, this.prevRefSteemBlockId, jsVMTimeout,
|
||||
this.refHiveBlockId, this.prevRefHiveBlockId, jsVMTimeout,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
const CONSTANTS = {
|
||||
|
||||
// mainnet
|
||||
/*
|
||||
UTILITY_TOKEN_SYMBOL: 'ENG',
|
||||
STEEM_PEGGED_ACCOUNT: 'steem-peg',
|
||||
|
||||
UTILITY_TOKEN_SYMBOL: 'BEE',
|
||||
HIVE_ENGINE_ACCOUNT: 'hive-engine',
|
||||
HIVE_PEGGED_ACCOUNT: 'honey-swap',
|
||||
INITIAL_TOKEN_CREATION_FEE: '100',
|
||||
SSC_STORE_QTY: '0.001',
|
||||
*/
|
||||
INITIAL_DELEGATION_ENABLEMENT_FEE: '1000',
|
||||
INITIAL_STAKING_ENABLEMENT_FEE: '1000',
|
||||
SSC_STORE_QTY: '0.00100000',
|
||||
|
||||
// testnet
|
||||
|
||||
UTILITY_TOKEN_SYMBOL: 'SSC',
|
||||
STEEM_PEGGED_ACCOUNT: 'steemsc',
|
||||
/*
|
||||
UTILITY_TOKEN_SYMBOL: 'BEE',
|
||||
HIVE_PEGGED_ACCOUNT: 'hive-engine',
|
||||
INITIAL_TOKEN_CREATION_FEE: '0',
|
||||
INITIAL_DELEGATION_ENABLEMENT_FEE: '0',
|
||||
INITIAL_STAKING_ENABLEMENT_FEE: '0',
|
||||
SSC_STORE_QTY: '1',
|
||||
|
||||
*/
|
||||
UTILITY_TOKEN_PRECISION: 8,
|
||||
UTILITY_TOKEN_MIN_VALUE: '0.00000001',
|
||||
STEEM_PEGGED_SYMBOL: 'STEEMP',
|
||||
HIVE_PEGGED_SYMBOL: 'SWAP.HIVE',
|
||||
|
||||
// default values
|
||||
ACCOUNT_RECEIVING_FEES: 'steemsc',
|
||||
ACCOUNT_RECEIVING_FEES: 'hive-engine',
|
||||
SSC_STORE_PRICE: '0.001',
|
||||
|
||||
// forks definitions
|
||||
FORK_BLOCK_NUMBER: 30896500,
|
||||
FORK_BLOCK_NUMBER_TWO: 30983000,
|
||||
FORK_BLOCK_NUMBER_THREE: 31992326,
|
||||
};
|
||||
|
||||
module.exports.CONSTANTS = CONSTANTS;
|
||||
|
|
|
@ -8,6 +8,7 @@ const { VM, VMScript } = require('vm2');
|
|||
const BigNumber = require('bignumber.js');
|
||||
const validator = require('validator');
|
||||
const seedrandom = require('seedrandom');
|
||||
const { CONSTANTS } = require('../libs/Constants');
|
||||
|
||||
const RESERVED_CONTRACT_NAMES = ['contract', 'blockProduction', 'null'];
|
||||
const RESERVED_ACTIONS = ['createSSC'];
|
||||
|
@ -18,10 +19,10 @@ const MAXJSVMs = 5;
|
|||
class SmartContracts {
|
||||
// deploy the smart contract to the blockchain and initialize the database if needed
|
||||
static async deploySmartContract(
|
||||
database, transaction, blockNumber, timestamp, refSteemBlockId, prevRefSteemBlockId, jsVMTimeout,
|
||||
database, transaction, blockNumber, timestamp, refHiveBlockId, prevRefHiveBlockId, jsVMTimeout,
|
||||
) {
|
||||
try {
|
||||
const { transactionId, refSteemBlockNumber, sender } = transaction;
|
||||
const { transactionId, refHiveBlockNumber, sender } = transaction;
|
||||
const payload = JSON.parse(transaction.payload);
|
||||
const { name, params, code } = payload;
|
||||
|
||||
|
@ -41,8 +42,8 @@ class SmartContracts {
|
|||
|
||||
let finalSender = sender;
|
||||
|
||||
// allow "steemsc" to update contracts owned by "null"
|
||||
if (existingContract && finalSender === 'steemsc' && existingContract.owner === 'null') {
|
||||
// allow "HIVE_ENGINE_ACCOUNT" to update contracts owned by "null"
|
||||
if (existingContract && finalSender === CONSTANTS.HIVE_ENGINE_ACCOUNT && existingContract.owner === 'null') {
|
||||
finalSender = 'null';
|
||||
}
|
||||
|
||||
|
@ -130,14 +131,10 @@ class SmartContracts {
|
|||
events: [],
|
||||
};
|
||||
|
||||
const rng = seedrandom(`${prevRefSteemBlockId}${refSteemBlockId}${transactionId}`);
|
||||
const rng = seedrandom(`${prevRefHiveBlockId}${refHiveBlockId}${transactionId}`);
|
||||
|
||||
// init bignumber decimal places
|
||||
if (refSteemBlockNumber > 33719500) {
|
||||
BigNumber.set({ DECIMAL_PLACES: 20 });
|
||||
} else {
|
||||
BigNumber.set({ DECIMAL_PLACES: 3 });
|
||||
}
|
||||
BigNumber.set({ DECIMAL_PLACES: 20 });
|
||||
|
||||
const contractVersion = existingContract && existingContract.version
|
||||
? existingContract.version
|
||||
|
@ -150,8 +147,8 @@ class SmartContracts {
|
|||
payload: params ? JSON.parse(JSON.stringify(params)) : null,
|
||||
transactionId,
|
||||
blockNumber,
|
||||
refSteemBlockNumber,
|
||||
steemBlockTimestamp: timestamp,
|
||||
refHiveBlockNumber,
|
||||
hiveBlockTimestamp: timestamp,
|
||||
contractVersion,
|
||||
db,
|
||||
BigNumber,
|
||||
|
@ -189,7 +186,7 @@ class SmartContracts {
|
|||
database, logs, finalSender, params, contractName, actionName,
|
||||
JSON.stringify(parameters),
|
||||
blockNumber, timestamp,
|
||||
refSteemBlockNumber, refSteemBlockId, prevRefSteemBlockId, jsVMTimeout,
|
||||
refHiveBlockNumber, refHiveBlockId, prevRefHiveBlockId, jsVMTimeout,
|
||||
name, 'createSSC', contractVersion,
|
||||
),
|
||||
// emit an event that will be stored in the logs
|
||||
|
@ -238,14 +235,14 @@ class SmartContracts {
|
|||
}
|
||||
return { logs: { errors: ['parameters name and code are mandatory and they must be strings'] } };
|
||||
} catch (e) {
|
||||
// console.error('ERROR DURING CONTRACT DEPLOYMENT: ', e);
|
||||
// console.error('ERROR DURING CONTRACT DEPLOYMENT: ', name, e);
|
||||
return { logs: { errors: [`${e.name}: ${e.message}`] } };
|
||||
}
|
||||
}
|
||||
|
||||
// execute the smart contract and perform actions on the database if needed
|
||||
static async executeSmartContract(
|
||||
database, transaction, blockNumber, timestamp, refSteemBlockId, prevRefSteemBlockId, jsVMTimeout,
|
||||
database, transaction, blockNumber, timestamp, refHiveBlockId, prevRefHiveBlockId, jsVMTimeout,
|
||||
) {
|
||||
try {
|
||||
const {
|
||||
|
@ -254,7 +251,7 @@ class SmartContracts {
|
|||
contract,
|
||||
action,
|
||||
payload,
|
||||
refSteemBlockNumber,
|
||||
refHiveBlockNumber,
|
||||
} = transaction;
|
||||
|
||||
if (RESERVED_ACTIONS.includes(action)) return { logs: { errors: ['you cannot trigger this action'] } };
|
||||
|
@ -315,10 +312,10 @@ class SmartContracts {
|
|||
},
|
||||
};
|
||||
|
||||
const rng = seedrandom(`${prevRefSteemBlockId}${refSteemBlockId}${transactionId}`);
|
||||
const rng = seedrandom(`${prevRefHiveBlockId}${refHiveBlockId}${transactionId}`);
|
||||
|
||||
// init bignumber decimal places
|
||||
if (refSteemBlockNumber > 33719500) {
|
||||
if (refHiveBlockNumber > 33719500) {
|
||||
BigNumber.set({ DECIMAL_PLACES: 20 });
|
||||
} else {
|
||||
BigNumber.set({ DECIMAL_PLACES: 3 });
|
||||
|
@ -329,8 +326,8 @@ class SmartContracts {
|
|||
api: {
|
||||
sender,
|
||||
owner: contractOwner,
|
||||
refSteemBlockNumber,
|
||||
steemBlockTimestamp: timestamp,
|
||||
refHiveBlockNumber,
|
||||
hiveBlockTimestamp: timestamp,
|
||||
contractVersion,
|
||||
transactionId,
|
||||
blockNumber,
|
||||
|
@ -372,7 +369,7 @@ class SmartContracts {
|
|||
database, results, sender, payloadObj, contractName, actionName,
|
||||
JSON.stringify(parameters),
|
||||
blockNumber, timestamp,
|
||||
refSteemBlockNumber, refSteemBlockId, prevRefSteemBlockId, jsVMTimeout,
|
||||
refHiveBlockNumber, refHiveBlockId, prevRefHiveBlockId, jsVMTimeout,
|
||||
contract, action, contractVersion,
|
||||
),
|
||||
// execute a smart contract from the current smart contract
|
||||
|
@ -383,7 +380,7 @@ class SmartContracts {
|
|||
database, results, contractOwner, payloadObj, contractName, actionName,
|
||||
JSON.stringify(parameters),
|
||||
blockNumber, timestamp,
|
||||
refSteemBlockNumber, refSteemBlockId, prevRefSteemBlockId, jsVMTimeout,
|
||||
refHiveBlockNumber, refHiveBlockId, prevRefHiveBlockId, jsVMTimeout,
|
||||
contract, action, contractVersion,
|
||||
),
|
||||
// execute a token transfer from the contract balance
|
||||
|
@ -399,7 +396,7 @@ class SmartContracts {
|
|||
type,
|
||||
}),
|
||||
blockNumber, timestamp,
|
||||
refSteemBlockNumber, refSteemBlockId, prevRefSteemBlockId, jsVMTimeout,
|
||||
refHiveBlockNumber, refHiveBlockId, prevRefHiveBlockId, jsVMTimeout,
|
||||
contract, action, contractVersion,
|
||||
),
|
||||
verifyBlock: async (block) => {
|
||||
|
@ -434,7 +431,7 @@ class SmartContracts {
|
|||
type,
|
||||
}),
|
||||
blockNumber, timestamp,
|
||||
refSteemBlockNumber, refSteemBlockId, prevRefSteemBlockId, jsVMTimeout,
|
||||
refHiveBlockNumber, refHiveBlockId, prevRefHiveBlockId, jsVMTimeout,
|
||||
contract, contractVersion,
|
||||
);
|
||||
}
|
||||
|
@ -535,17 +532,17 @@ class SmartContracts {
|
|||
contract, action, parameters,
|
||||
blockNumber,
|
||||
timestamp,
|
||||
refSteemBlockNumber, refSteemBlockId, prevRefSteemBlockId,
|
||||
refHiveBlockNumber, refHiveBlockId, prevRefHiveBlockId,
|
||||
jsVMTimeout,
|
||||
callingContractName, callingContractAction, callingContractVersion,
|
||||
) {
|
||||
if (typeof contract !== 'string' || typeof action !== 'string' || (parameters && typeof parameters !== 'string')) return null;
|
||||
const sanitizedParams = parameters ? JSON.parse(parameters) : null;
|
||||
|
||||
// check if a recipient or amountSTEEMSBD
|
||||
// check if a recipient or amountHIVEHBD
|
||||
// or isSignedWithActiveKey were passed initially
|
||||
if (originalParameters && originalParameters.amountSTEEMSBD) {
|
||||
sanitizedParams.amountSTEEMSBD = originalParameters.amountSTEEMSBD;
|
||||
if (originalParameters && originalParameters.amountHIVEHBD) {
|
||||
sanitizedParams.amountHIVEHBD = originalParameters.amountHIVEHBD;
|
||||
}
|
||||
|
||||
if (originalParameters && originalParameters.recipient) {
|
||||
|
@ -572,12 +569,12 @@ class SmartContracts {
|
|||
contract,
|
||||
action,
|
||||
payload: JSON.stringify(sanitizedParams),
|
||||
refSteemBlockNumber,
|
||||
refHiveBlockNumber,
|
||||
},
|
||||
blockNumber,
|
||||
timestamp,
|
||||
refSteemBlockId,
|
||||
prevRefSteemBlockId,
|
||||
refHiveBlockId,
|
||||
prevRefHiveBlockId,
|
||||
jsVMTimeout,
|
||||
);
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ const SHA256 = require('crypto-js/sha256');
|
|||
const enchex = require('crypto-js/enc-hex');
|
||||
|
||||
class Transaction {
|
||||
constructor(refSteemBlockNumber, transactionId, sender, contract, action, payload) {
|
||||
this.refSteemBlockNumber = refSteemBlockNumber;
|
||||
constructor(refHiveBlockNumber, transactionId, sender, contract, action, payload) {
|
||||
this.refHiveBlockNumber = refHiveBlockNumber;
|
||||
this.transactionId = transactionId;
|
||||
this.sender = sender;
|
||||
this.contract = typeof contract === 'string' ? contract : null;
|
||||
|
@ -35,7 +35,7 @@ class Transaction {
|
|||
// calculate the hash of the transaction
|
||||
calculateHash() {
|
||||
this.hash = SHA256(
|
||||
this.refSteemBlockNumber
|
||||
this.refHiveBlockNumber
|
||||
+ this.transactionId
|
||||
+ this.sender
|
||||
+ this.contract
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -62,16 +62,16 @@ function blockchainRPC() {
|
|||
|
||||
if (block) {
|
||||
result.lastBlockNumber = block.blockNumber;
|
||||
result.lastBlockRefSteemBlockNumber = block.refSteemBlockNumber;
|
||||
result.lastBlockRefHiveBlockNumber = block.refHiveBlockNumber;
|
||||
}
|
||||
|
||||
// get the Steem block number that the streamer is currently parsing
|
||||
// get the Hive block number that the streamer is currently parsing
|
||||
const res = await ipc.send(
|
||||
{ to: STREAMER_PLUGIN_NAME, action: STREAMER_PLUGIN_ACTION.GET_CURRENT_BLOCK },
|
||||
);
|
||||
|
||||
if (res && res.payload) {
|
||||
result.lastParsedSteemBlockNumber = res.payload;
|
||||
result.lastParsedHiveBlockNumber = res.payload;
|
||||
}
|
||||
|
||||
// get the version of the SSC node
|
||||
|
|
|
@ -35,15 +35,15 @@ let sendingToSidechain = false;
|
|||
|
||||
let requestId = 1;
|
||||
|
||||
const steemClient = {
|
||||
const hiveClient = {
|
||||
account: null,
|
||||
signingKey: null,
|
||||
sidechainId: null,
|
||||
steemAddressPrefix: null,
|
||||
steemChainId: null,
|
||||
hiveAddressPrefix: null,
|
||||
hiveChainId: null,
|
||||
client: null,
|
||||
nodes: new Queue(),
|
||||
getSteemNode() {
|
||||
getHiveNode() {
|
||||
const node = this.nodes.pop();
|
||||
this.nodes.push(node);
|
||||
return node;
|
||||
|
@ -57,9 +57,9 @@ const steemClient = {
|
|||
};
|
||||
|
||||
if (this.client === null) {
|
||||
this.client = new dsteem.Client(this.getSteemNode(), {
|
||||
addressPrefix: this.steemAddressPrefix,
|
||||
chainId: this.steemChainId,
|
||||
this.client = new dsteem.Client(this.getHiveNode(), {
|
||||
addressPrefix: this.hiveAddressPrefix,
|
||||
chainId: this.hiveChainId,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ const checkSignature = (payload, signature, publicKey, isPayloadSHA256 = false)
|
|||
|
||||
return dsteem.PublicKey.fromString(publicKey).verify(buffer, sig);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.log(error); // eslint-disable-line no-console
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
@ -203,7 +203,7 @@ const verifyRoundHandler = async (witnessAccount, data) => {
|
|||
},
|
||||
};
|
||||
console.log('sending json');
|
||||
await steemClient.sendCustomJSON(json);
|
||||
await hiveClient.sendCustomJSON(json);
|
||||
lastVerifiedRoundNumber = round;
|
||||
}
|
||||
} else {
|
||||
|
@ -438,8 +438,8 @@ const init = async (conf, callback) => {
|
|||
streamNodes,
|
||||
chainId,
|
||||
witnessEnabled,
|
||||
steemAddressPrefix,
|
||||
steemChainId,
|
||||
hiveAddressPrefix,
|
||||
hiveChainId,
|
||||
databaseURL,
|
||||
databaseName,
|
||||
} = conf;
|
||||
|
@ -452,18 +452,18 @@ const init = async (conf, callback) => {
|
|||
} else {
|
||||
database = new Database();
|
||||
await database.init(databaseURL, databaseName);
|
||||
streamNodes.forEach(node => steemClient.nodes.push(node));
|
||||
steemClient.account = process.env.ACCOUNT;
|
||||
steemClient.sidechainId = chainId;
|
||||
steemClient.steemAddressPrefix = steemAddressPrefix;
|
||||
steemClient.steemChainId = steemChainId;
|
||||
streamNodes.forEach(node => hiveClient.nodes.push(node));
|
||||
hiveClient.account = process.env.ACCOUNT;
|
||||
hiveClient.sidechainId = chainId;
|
||||
hiveClient.hiveAddressPrefix = hiveAddressPrefix;
|
||||
hiveClient.hiveChainId = hiveChainId;
|
||||
|
||||
WITNESS_ACCOUNT = process.env.ACCOUNT || null;
|
||||
steemClient.witnessAccount = WITNESS_ACCOUNT;
|
||||
hiveClient.witnessAccount = WITNESS_ACCOUNT;
|
||||
SIGNING_KEY = process.env.ACTIVE_SIGNING_KEY
|
||||
? dsteem.PrivateKey.fromString(process.env.ACTIVE_SIGNING_KEY)
|
||||
: null;
|
||||
steemClient.signingKey = SIGNING_KEY;
|
||||
hiveClient.signingKey = SIGNING_KEY;
|
||||
|
||||
// enable the server
|
||||
if (SIGNING_KEY && WITNESS_ACCOUNT) {
|
||||
|
|
|
@ -2,7 +2,7 @@ const PLUGIN_NAME = 'Replay';
|
|||
|
||||
const PLUGIN_ACTIONS = {
|
||||
GET_CURRENT_BLOCK: 'getCurrentBlock',
|
||||
GET_CURRENT_STEEM_BLOCK: 'getCurrentSteemBlock',
|
||||
GET_CURRENT_HIVE_BLOCK: 'getCurrentHiveBlock',
|
||||
REPLAY_FILE: 'replayFile',
|
||||
};
|
||||
|
||||
|
|
|
@ -10,20 +10,20 @@ const { PLUGIN_NAME, PLUGIN_ACTIONS } = require('./Replay.constants');
|
|||
const PLUGIN_PATH = require.resolve(__filename);
|
||||
|
||||
const ipc = new IPC(PLUGIN_NAME);
|
||||
let steemClient = null;
|
||||
let hiveClient = null;
|
||||
|
||||
|
||||
let currentSteemBlock = 0;
|
||||
let currentHiveBlock = 0;
|
||||
let currentBlock = 0;
|
||||
let filePath = '';
|
||||
let steemNode = '';
|
||||
let hiveNode = '';
|
||||
|
||||
function getCurrentBlock() {
|
||||
return currentBlock;
|
||||
}
|
||||
|
||||
function getCurrentSteemBlock() {
|
||||
return currentSteemBlock;
|
||||
function getcurrentHiveBlock() {
|
||||
return currentHiveBlock;
|
||||
}
|
||||
|
||||
function sendBlock(block) {
|
||||
|
@ -54,32 +54,32 @@ function replayFile(callback) {
|
|||
blockNumber,
|
||||
timestamp,
|
||||
transactions,
|
||||
refSteemBlockNumber,
|
||||
refSteemBlockId,
|
||||
prevRefSteemBlockId,
|
||||
refHiveBlockNumber,
|
||||
refHiveBlockId,
|
||||
prevRefHiveBlockId,
|
||||
virtualTransactions,
|
||||
} = block;
|
||||
|
||||
let finalRefSteemBlockId = refSteemBlockId;
|
||||
let finalPrevRefSteemBlockId = prevRefSteemBlockId;
|
||||
let finalRefHiveBlockId = refHiveBlockId;
|
||||
let finalPrevRefHiveBlockId = prevRefHiveBlockId;
|
||||
|
||||
if (blockNumber !== 0) {
|
||||
currentSteemBlock = refSteemBlockNumber;
|
||||
currentHiveBlock = refHiveBlockNumber;
|
||||
currentBlock = blockNumber;
|
||||
console.log(`replaying block ${currentBlock} / ${lastBockNumber}`); // eslint-disable-line no-console
|
||||
|
||||
if (steemClient !== null && finalRefSteemBlockId === undefined) {
|
||||
const steemBlock = await steemClient.database.getBlock(refSteemBlockNumber);
|
||||
finalRefSteemBlockId = steemBlock.block_id;
|
||||
finalPrevRefSteemBlockId = steemBlock.previous;
|
||||
if (hiveClient !== null && finalRefHiveBlockId === undefined) {
|
||||
const hiveBlock = await hiveClient.database.getBlock(refHiveBlockNumber);
|
||||
finalRefHiveBlockId = hiveBlock.block_id;
|
||||
finalPrevRefHiveBlockId = hiveBlock.previous;
|
||||
}
|
||||
|
||||
await sendBlock({
|
||||
blockNumber,
|
||||
timestamp,
|
||||
refSteemBlockNumber,
|
||||
refSteemBlockId: finalRefSteemBlockId,
|
||||
prevRefSteemBlockId: finalPrevRefSteemBlockId,
|
||||
refHiveBlockNumber,
|
||||
refHiveBlockId: finalRefHiveBlockId,
|
||||
prevRefHiveBlockId: finalPrevRefHiveBlockId,
|
||||
transactions,
|
||||
virtualTransactions,
|
||||
});
|
||||
|
@ -93,7 +93,7 @@ function replayFile(callback) {
|
|||
});
|
||||
|
||||
lr.on('end', () => {
|
||||
console.log('Replay done');
|
||||
console.log('Replay done'); // eslint-disable-line no-console
|
||||
callback(null);
|
||||
});
|
||||
} else {
|
||||
|
@ -106,8 +106,8 @@ function replayFile(callback) {
|
|||
function init(payload) {
|
||||
const { blocksLogFilePath, streamNodes } = payload;
|
||||
filePath = blocksLogFilePath;
|
||||
steemNode = streamNodes[0]; // eslint-disable-line
|
||||
steemClient = new dsteem.Client(steemNode);
|
||||
hiveNode = streamNodes[0]; // eslint-disable-line
|
||||
hiveClient = new dsteem.Client(hiveNode);
|
||||
}
|
||||
|
||||
ipc.onReceiveMessage((message) => {
|
||||
|
@ -124,7 +124,7 @@ ipc.onReceiveMessage((message) => {
|
|||
console.log('successfully initialized'); // eslint-disable-line no-console
|
||||
break;
|
||||
case 'stop':
|
||||
ipc.reply(message, getCurrentSteemBlock() + 1);
|
||||
ipc.reply(message, getcurrentHiveBlock() + 1);
|
||||
console.log('successfully stopped'); // eslint-disable-line no-console
|
||||
break;
|
||||
case PLUGIN_ACTIONS.REPLAY_FILE:
|
||||
|
|
|
@ -19,8 +19,8 @@ class ForkException {
|
|||
}
|
||||
}
|
||||
|
||||
let currentSteemBlock = 0;
|
||||
let steemHeadBlockNumber = 0;
|
||||
let currentHiveBlock = 0;
|
||||
let hiveHeadBlockNumber = 0;
|
||||
let stopStream = false;
|
||||
const antiForkBufferMaxSize = 2;
|
||||
const buffer = new Queue(antiForkBufferMaxSize);
|
||||
|
@ -29,7 +29,7 @@ let blockStreamerHandler = null;
|
|||
let updaterGlobalPropsHandler = null;
|
||||
let lastBlockSentToBlockchain = 0;
|
||||
|
||||
const getCurrentBlock = () => currentSteemBlock;
|
||||
const getCurrentBlock = () => currentHiveBlock;
|
||||
|
||||
const stop = () => {
|
||||
stopStream = true;
|
||||
|
@ -39,7 +39,7 @@ const stop = () => {
|
|||
return lastBlockSentToBlockchain;
|
||||
};
|
||||
|
||||
// parse the transactions found in a Steem block
|
||||
// parse the transactions found in a Hive block
|
||||
const parseTransactions = (refBlockNumber, block) => {
|
||||
const newTransactions = [];
|
||||
const transactionsLength = block.transactions.length;
|
||||
|
@ -83,7 +83,7 @@ const parseTransactions = (refBlockNumber, block) => {
|
|||
amount = operation[1].amount; // eslint-disable-line prefer-destructuring
|
||||
const transferParams = JSON.parse(operation[1].memo);
|
||||
id = transferParams.id; // eslint-disable-line prefer-destructuring
|
||||
// multi transactions is not supported for the Steem transfers
|
||||
// multi transactions is not supported for the Hive transfers
|
||||
if (Array.isArray(transferParams.json) && transferParams.json.length === 1) {
|
||||
sscTransactions = transferParams.json;
|
||||
} else if (!Array.isArray(transferParams.json)) {
|
||||
|
@ -157,7 +157,7 @@ const parseTransactions = (refBlockNumber, block) => {
|
|||
&& contractAction && typeof contractAction === 'string'
|
||||
&& contractPayload && typeof contractPayload === 'object') {
|
||||
contractPayload.recipient = recipient;
|
||||
contractPayload.amountSTEEMSBD = amount;
|
||||
contractPayload.amountHIVEHBD = amount;
|
||||
contractPayload.isSignedWithActiveKey = isSignedWithActiveKey;
|
||||
contractPayload.permlink = permlink;
|
||||
|
||||
|
@ -166,7 +166,7 @@ const parseTransactions = (refBlockNumber, block) => {
|
|||
}
|
||||
|
||||
if (amount === null) {
|
||||
delete contractPayload.amountSTEEMSBD;
|
||||
delete contractPayload.amountHIVEHBD;
|
||||
}
|
||||
|
||||
if (isSignedWithActiveKey === null) {
|
||||
|
@ -192,7 +192,7 @@ const parseTransactions = (refBlockNumber, block) => {
|
|||
}
|
||||
|
||||
// if multi transactions
|
||||
// append the index of the transaction to the Steem transaction id
|
||||
// append the index of the transaction to the Hive transaction id
|
||||
let SSCtransactionId = block.transaction_ids[i];
|
||||
|
||||
if (nbOperations > 1) {
|
||||
|
@ -247,17 +247,17 @@ const sendBlock = block => ipc.send(
|
|||
|
||||
const getLatestBlockMetadata = () => database.getLatestBlockMetadata();
|
||||
|
||||
// process Steem block
|
||||
// process Hive block
|
||||
const processBlock = async (block) => {
|
||||
if (stopStream) return;
|
||||
|
||||
await sendBlock(
|
||||
{
|
||||
// we timestamp the block with the Steem block timestamp
|
||||
// we timestamp the block with the Hive block timestamp
|
||||
timestamp: block.timestamp,
|
||||
refSteemBlockNumber: block.blockNumber,
|
||||
refSteemBlockId: block.block_id,
|
||||
prevRefSteemBlockId: block.previous,
|
||||
refHiveBlockNumber: block.blockNumber,
|
||||
refHiveBlockId: block.block_id,
|
||||
prevRefHiveBlockId: block.previous,
|
||||
transactions: parseTransactions(
|
||||
block.blockNumber,
|
||||
block,
|
||||
|
@ -272,20 +272,20 @@ const updateGlobalProps = async () => {
|
|||
try {
|
||||
if (client !== null) {
|
||||
const globProps = await client.database.getDynamicGlobalProperties();
|
||||
steemHeadBlockNumber = globProps.head_block_number;
|
||||
const delta = steemHeadBlockNumber - currentSteemBlock;
|
||||
hiveHeadBlockNumber = globProps.head_block_number;
|
||||
const delta = hiveHeadBlockNumber - currentHiveBlock;
|
||||
// eslint-disable-next-line
|
||||
console.log(`head_block_number ${steemHeadBlockNumber}`, `currentBlock ${currentSteemBlock}`, `Steem blockchain is ${delta > 0 ? delta : 0} blocks ahead`);
|
||||
console.log(`head_block_number ${hiveHeadBlockNumber}`, `currentBlock ${currentHiveBlock}`, `Hive blockchain is ${delta > 0 ? delta : 0} blocks ahead`);
|
||||
}
|
||||
updaterGlobalPropsHandler = setTimeout(() => updateGlobalProps(), 10000);
|
||||
} catch (ex) {
|
||||
console.error('An error occured while trying to fetch the Steem blockchain global properties'); // eslint-disable-line no-console
|
||||
console.error('An error occured while trying to fetch the Hive blockchain global properties'); // eslint-disable-line no-console
|
||||
}
|
||||
};
|
||||
|
||||
const addBlockToBuffer = async (block) => {
|
||||
const finalBlock = block;
|
||||
finalBlock.blockNumber = currentSteemBlock;
|
||||
finalBlock.blockNumber = currentHiveBlock;
|
||||
|
||||
// if the buffer is full
|
||||
if (buffer.size() + 1 > antiForkBufferMaxSize) {
|
||||
|
@ -302,7 +302,7 @@ const addBlockToBuffer = async (block) => {
|
|||
const streamBlocks = async (reject) => {
|
||||
if (stopStream) return;
|
||||
try {
|
||||
const block = await client.database.getBlock(currentSteemBlock);
|
||||
const block = await client.database.getBlock(currentHiveBlock);
|
||||
let addBlockToBuf = false;
|
||||
|
||||
if (block) {
|
||||
|
@ -313,16 +313,16 @@ const streamBlocks = async (reject) => {
|
|||
addBlockToBuf = true;
|
||||
} else {
|
||||
buffer.clear();
|
||||
throw new ForkException(`a fork happened between block ${currentSteemBlock - 1} and block ${currentSteemBlock}`);
|
||||
throw new ForkException(`a fork happened between block ${currentHiveBlock - 1} and block ${currentHiveBlock}`);
|
||||
}
|
||||
} else {
|
||||
// get the previous block
|
||||
const prevBlock = await client.database.getBlock(currentSteemBlock - 1);
|
||||
const prevBlock = await client.database.getBlock(currentHiveBlock - 1);
|
||||
|
||||
if (prevBlock && prevBlock.block_id === block.previous) {
|
||||
addBlockToBuf = true;
|
||||
} else {
|
||||
throw new ForkException(`a fork happened between block ${currentSteemBlock - 1} and block ${currentSteemBlock}`);
|
||||
throw new ForkException(`a fork happened between block ${currentHiveBlock - 1} and block ${currentHiveBlock}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,7 +330,7 @@ const streamBlocks = async (reject) => {
|
|||
if (addBlockToBuf === true) {
|
||||
await addBlockToBuffer(block);
|
||||
}
|
||||
currentSteemBlock += 1;
|
||||
currentHiveBlock += 1;
|
||||
streamBlocks(reject);
|
||||
} else {
|
||||
blockStreamerHandler = setTimeout(() => {
|
||||
|
@ -342,10 +342,10 @@ const streamBlocks = async (reject) => {
|
|||
}
|
||||
};
|
||||
|
||||
const initSteemClient = (node, steemAddressPrefix, steemChainId) => {
|
||||
const initHiveClient = (node, hiveAddressPrefix, hiveChainId) => {
|
||||
client = new dsteem.Client(node, {
|
||||
addressPrefix: steemAddressPrefix,
|
||||
chainId: steemChainId,
|
||||
addressPrefix: hiveAddressPrefix,
|
||||
chainId: hiveChainId,
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -353,27 +353,27 @@ const startStreaming = (conf) => {
|
|||
const {
|
||||
streamNodes,
|
||||
chainId,
|
||||
startSteemBlock,
|
||||
steemAddressPrefix,
|
||||
steemChainId,
|
||||
startHiveBlock,
|
||||
hiveAddressPrefix,
|
||||
hiveChainId,
|
||||
} = conf;
|
||||
currentSteemBlock = startSteemBlock;
|
||||
currentHiveBlock = startHiveBlock;
|
||||
chainIdentifier = chainId;
|
||||
const node = streamNodes[0];
|
||||
initSteemClient(node, steemAddressPrefix, steemChainId);
|
||||
initHiveClient(node, hiveAddressPrefix, hiveChainId);
|
||||
|
||||
return new Promise((resolve, reject) => { // eslint-disable-line no-unused-vars
|
||||
console.log('Starting Steem streaming at ', node); // eslint-disable-line no-console
|
||||
console.log('Starting Hive streaming at ', node); // eslint-disable-line no-console
|
||||
|
||||
streamBlocks(reject);
|
||||
}).catch((err) => {
|
||||
console.error('Stream error:', err.message, 'with', node); // eslint-disable-line no-console
|
||||
streamNodes.push(streamNodes.shift());
|
||||
startStreaming(Object.assign({}, conf, { startSteemBlock: getCurrentBlock() }));
|
||||
startStreaming(Object.assign({}, conf, { startHiveBlock: getCurrentBlock() }));
|
||||
});
|
||||
};
|
||||
|
||||
// stream the Steem blockchain to find transactions related to the sidechain
|
||||
// stream the Hive blockchain to find transactions related to the sidechain
|
||||
const init = async (conf) => {
|
||||
const {
|
||||
databaseURL,
|
||||
|
@ -383,12 +383,12 @@ const init = async (conf) => {
|
|||
|
||||
database = new Database();
|
||||
await database.init(databaseURL, databaseName);
|
||||
// get latest block metadata to ensure that startSteemBlock saved in the config.json is not lower
|
||||
// get latest block metadata to ensure that startHiveBlock saved in the config.json is not lower
|
||||
const block = await getLatestBlockMetadata();
|
||||
if (block) {
|
||||
if (finalConf.startSteemBlock < block.refSteemBlockNumber) {
|
||||
console.log('adjusted startSteemBlock automatically as it was lower that the refSteemBlockNumber available');
|
||||
finalConf.startSteemBlock = block.refSteemBlockNumber + 1;
|
||||
if (finalConf.startHiveBlock < block.refHiveBlockNumber) {
|
||||
console.log('adjusted startHiveBlock automatically as it was lower that the refHiveBlockNumber available'); // eslint-disable-line no-console
|
||||
finalConf.startHiveBlock = block.refHiveBlockNumber + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,15 +27,15 @@ function sendBlock(block) {
|
|||
);
|
||||
}
|
||||
|
||||
// get a block from the Steem blockchain
|
||||
async function generateBlock(startSteemBlock) {
|
||||
// get a block from the Hive blockchain
|
||||
async function generateBlock(startHiveBlock) {
|
||||
if (stopGeneration) return;
|
||||
|
||||
if (startSteemBlock) blockNumber = startSteemBlock;
|
||||
if (startHiveBlock) blockNumber = startHiveBlock;
|
||||
|
||||
blockNumber += 1;
|
||||
const block = {
|
||||
// we timestamp the block with the Steem block timestamp
|
||||
// we timestamp the block with the Hive block timestamp
|
||||
timestamp: new Date().toISOString(),
|
||||
transactions: [],
|
||||
};
|
||||
|
@ -58,13 +58,13 @@ async function generateBlock(startSteemBlock) {
|
|||
setTimeout(() => generateBlock(), 3000);
|
||||
}
|
||||
|
||||
// stream the Steem blockchain to find transactions related to the sidechain
|
||||
// stream the Hive blockchain to find transactions related to the sidechain
|
||||
function init(conf) {
|
||||
const {
|
||||
startSteemBlock,
|
||||
startHiveBlock,
|
||||
} = conf;
|
||||
|
||||
generateBlock(startSteemBlock);
|
||||
generateBlock(startHiveBlock);
|
||||
}
|
||||
|
||||
ipc.onReceiveMessage((message) => {
|
||||
|
|
|
@ -102,6 +102,7 @@ let contractCode = fs.readFileSync('./contracts/tokens.js');
|
|||
contractCode = contractCode.toString();
|
||||
contractCode = contractCode.replace(/'\$\{CONSTANTS.UTILITY_TOKEN_PRECISION\}\$'/g, CONSTANTS.UTILITY_TOKEN_PRECISION);
|
||||
contractCode = contractCode.replace(/'\$\{CONSTANTS.UTILITY_TOKEN_SYMBOL\}\$'/g, CONSTANTS.UTILITY_TOKEN_SYMBOL);
|
||||
contractCode = contractCode.replace(/'\$\{CONSTANTS.HIVE_PEGGED_SYMBOL\}\$'/g, CONSTANTS.HIVE_PEGGED_SYMBOL);
|
||||
let base64ContractCode = Base64.encode(contractCode);
|
||||
|
||||
let tknContractPayload = {
|
||||
|
@ -133,7 +134,7 @@ let critterContractPayload = {
|
|||
params: '',
|
||||
code: base64ContractCode,
|
||||
};
|
||||
console.log(critterContractPayload);
|
||||
|
||||
|
||||
// crittermanager
|
||||
describe('crittermanager', function() {
|
||||
|
@ -190,13 +191,13 @@ describe('crittermanager', function() {
|
|||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(38145386, 'TXID1230', 'steemsc', 'contract', 'deploy', JSON.stringify(critterContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1230', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(critterContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1231', 'cryptomancer', 'crittermanager', 'updateParams', `{ "editionMapping": {"${CONSTANTS.UTILITY_TOKEN_SYMBOL}":1,"ALPHA":2,"BETA":3,"UNTAMED":4} }`));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 38145386,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 38145386,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -210,7 +211,7 @@ describe('crittermanager', function() {
|
|||
query: {}
|
||||
});
|
||||
|
||||
console.log(params);
|
||||
|
||||
|
||||
assert.equal(JSON.stringify(params.editionMapping), `{"${CONSTANTS.UTILITY_TOKEN_SYMBOL}":1,"ALPHA":2,"BETA":3,"UNTAMED":4}`);
|
||||
|
||||
|
@ -231,15 +232,15 @@ describe('crittermanager', function() {
|
|||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(38145386, 'TXID1230', 'steemsc', 'contract', 'deploy', JSON.stringify(critterContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1230', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(critterContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1231', 'aggroed', 'crittermanager', 'updateParams', `{ "editionMapping": {"${CONSTANTS.UTILITY_TOKEN_SYMBOL}":1,"ALPHA":2,"BETA":3,"UNTAMED":4} }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1232', 'cryptomancer', 'crittermanager', 'updateParams', `{ "wrongKey": {"${CONSTANTS.UTILITY_TOKEN_SYMBOL}":1,"ALPHA":2,"BETA":3,"UNTAMED":4} }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1233', 'cryptomancer', 'crittermanager', 'updateParams', `{ "editionMapping": 666 }`));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 38145386,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 38145386,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -253,7 +254,7 @@ describe('crittermanager', function() {
|
|||
query: {}
|
||||
});
|
||||
|
||||
console.log(params);
|
||||
|
||||
|
||||
assert.equal(JSON.stringify(params.editionMapping), `{"${CONSTANTS.UTILITY_TOKEN_SYMBOL}":1,"ALPHA":2,"BETA":3}`);
|
||||
|
||||
|
@ -274,17 +275,17 @@ describe('crittermanager', function() {
|
|||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(38145386, 'TXID1230', 'steemsc', 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1231', 'steemsc', 'contract', 'deploy', JSON.stringify(nftContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1232', 'steemsc', 'contract', 'deploy', JSON.stringify(critterContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1233', 'steemsc', 'nft', 'updateParams', '{ "nftCreationFee": "5", "dataPropertyCreationFee": "5" }'));
|
||||
transactions.push(new Transaction(38145386, 'TXID1234', 'steemsc', 'tokens', 'transfer', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"cryptomancer", "quantity":"100", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1230', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1231', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(nftContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1232', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(critterContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'nft', 'updateParams', '{ "nftCreationFee": "5", "dataPropertyCreationFee": "5" }'));
|
||||
transactions.push(new Transaction(38145386, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"cryptomancer", "quantity":"100", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1235', 'cryptomancer', 'crittermanager', 'createNft', '{ "isSignedWithActiveKey": true }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 38145386,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 38145386,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -298,7 +299,7 @@ describe('crittermanager', function() {
|
|||
query: { symbol: 'CRITTER' }
|
||||
});
|
||||
|
||||
console.log(token);
|
||||
|
||||
|
||||
assert.equal(token.symbol, 'CRITTER');
|
||||
assert.equal(token.issuer, 'cryptomancer');
|
||||
|
@ -344,18 +345,18 @@ describe('crittermanager', function() {
|
|||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(38145386, 'TXID1230', 'steemsc', 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1231', 'steemsc', 'contract', 'deploy', JSON.stringify(nftContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1232', 'steemsc', 'contract', 'deploy', JSON.stringify(critterContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1233', 'steemsc', 'nft', 'updateParams', '{ "nftCreationFee": "5", "dataPropertyCreationFee": "5" }'));
|
||||
transactions.push(new Transaction(38145386, 'TXID1234', 'steemsc', 'tokens', 'transfer', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"cryptomancer", "quantity":"100", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1230', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1231', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(nftContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1232', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(critterContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'nft', 'updateParams', '{ "nftCreationFee": "5", "dataPropertyCreationFee": "5" }'));
|
||||
transactions.push(new Transaction(38145386, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"cryptomancer", "quantity":"100", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1235', 'aggroed', 'crittermanager', 'createNft', '{ "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(38145386, 'TXID1236', 'cryptomancer', 'crittermanager', 'createNft', '{ "isSignedWithActiveKey": false }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 38145386,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 38145386,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -369,12 +370,12 @@ describe('crittermanager', function() {
|
|||
query: { symbol: 'CRITTER' }
|
||||
});
|
||||
|
||||
console.log(token);
|
||||
|
||||
assert.equal(token, null);
|
||||
|
||||
const block1 = await database1.getBlockInfo(1);
|
||||
const transactionsBlock1 = block1.transactions;
|
||||
console.log(transactionsBlock1[6].logs)
|
||||
|
||||
|
||||
assert.equal(JSON.parse(transactionsBlock1[6].logs).errors[0], 'you must use a custom_json signed with your active key');
|
||||
|
||||
|
@ -384,9 +385,9 @@ describe('crittermanager', function() {
|
|||
transactions.push(new Transaction(38145387, 'TXID1238', 'cryptomancer', 'crittermanager', 'createNft', '{ "isSignedWithActiveKey": true }'));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 38145387,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 38145387,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -395,7 +396,7 @@ describe('crittermanager', function() {
|
|||
|
||||
const block2 = await database1.getBlockInfo(2);
|
||||
const transactionsBlock2 = block2.transactions;
|
||||
console.log(transactionsBlock2[1].logs)
|
||||
|
||||
|
||||
assert.equal(JSON.parse(transactionsBlock2[1].logs).errors[0], 'CRITTER already exists');
|
||||
|
||||
|
@ -416,20 +417,20 @@ describe('crittermanager', function() {
|
|||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(38145386, 'TXID1230', 'steemsc', 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1231', 'steemsc', 'contract', 'deploy', JSON.stringify(nftContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1232', 'steemsc', 'contract', 'deploy', JSON.stringify(critterContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1233', 'steemsc', 'nft', 'updateParams', `{ "nftCreationFee": "5", "dataPropertyCreationFee": "5", "nftIssuanceFee": {"${CONSTANTS.UTILITY_TOKEN_SYMBOL}":"0.1"} }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1234', 'steemsc', 'tokens', 'transfer', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"cryptomancer", "quantity":"1000", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1235', 'steemsc', 'tokens', 'transfer', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"aggroed", "quantity":"1000", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1236', 'steemsc', 'tokens', 'transferToContract', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"crittermanager", "quantity":"1000", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1230', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1231', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(nftContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1232', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(critterContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'nft', 'updateParams', `{ "nftCreationFee": "5", "dataPropertyCreationFee": "5", "nftIssuanceFee": {"${CONSTANTS.UTILITY_TOKEN_SYMBOL}":"0.1"} }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"cryptomancer", "quantity":"1000", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"aggroed", "quantity":"1000", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transferToContract', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"crittermanager", "quantity":"1000", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1237', 'cryptomancer', 'crittermanager', 'createNft', '{ "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(38145386, 'TXID1238', 'aggroed', 'crittermanager', 'hatch', `{ "isSignedWithActiveKey": true, "packSymbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "packs": 10 }`));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 38145386,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 38145386,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -443,7 +444,7 @@ describe('crittermanager', function() {
|
|||
query: { symbol: 'CRITTER' }
|
||||
});
|
||||
|
||||
console.log(token);
|
||||
|
||||
|
||||
assert.equal(token.supply, 50);
|
||||
assert.equal(token.circulatingSupply, 50);
|
||||
|
@ -455,7 +456,7 @@ describe('crittermanager', function() {
|
|||
query: {},
|
||||
});
|
||||
|
||||
console.log(instances[0]);
|
||||
|
||||
|
||||
assert.equal(instances.length, 50);
|
||||
assert.equal(instances[0].account, 'aggroed');
|
||||
|
@ -469,7 +470,7 @@ describe('crittermanager', function() {
|
|||
query: { account: 'aggroed' }
|
||||
});
|
||||
|
||||
console.log(balance)
|
||||
|
||||
|
||||
assert.equal(balance.symbol, `${CONSTANTS.UTILITY_TOKEN_SYMBOL}`);
|
||||
assert.equal(balance.balance, '990.00000000');
|
||||
|
@ -481,7 +482,7 @@ describe('crittermanager', function() {
|
|||
query: { account: 'crittermanager' }
|
||||
});
|
||||
|
||||
console.log(balance)
|
||||
|
||||
|
||||
assert.equal(balance.symbol, `${CONSTANTS.UTILITY_TOKEN_SYMBOL}`);
|
||||
assert.equal(balance.balance, '960.00000000'); // 10 packs x 5 critters per pack x 0.8 fee per critter = 40 token issuance fee
|
||||
|
@ -503,13 +504,13 @@ describe('crittermanager', function() {
|
|||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(38145386, 'TXID1230', 'steemsc', 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1231', 'steemsc', 'contract', 'deploy', JSON.stringify(nftContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1232', 'steemsc', 'contract', 'deploy', JSON.stringify(critterContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1233', 'steemsc', 'nft', 'updateParams', `{ "nftCreationFee": "5", "dataPropertyCreationFee": "5", "nftIssuanceFee": {"${CONSTANTS.UTILITY_TOKEN_SYMBOL}":"0.1"} }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1234', 'steemsc', 'tokens', 'transfer', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"cryptomancer", "quantity":"1000", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1235', 'steemsc', 'tokens', 'transfer', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"aggroed", "quantity":"9", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1236', 'steemsc', 'tokens', 'transferToContract', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"crittermanager", "quantity":"39.999", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1230', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1231', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(nftContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1232', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(critterContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'nft', 'updateParams', `{ "nftCreationFee": "5", "dataPropertyCreationFee": "5", "nftIssuanceFee": {"${CONSTANTS.UTILITY_TOKEN_SYMBOL}":"0.1"} }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"cryptomancer", "quantity":"1000", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"aggroed", "quantity":"9", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transferToContract', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"crittermanager", "quantity":"39.999", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1237', 'cryptomancer', 'crittermanager', 'createNft', '{ "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(38145386, 'TXID1238', 'aggroed', 'crittermanager', 'hatch', `{ "isSignedWithActiveKey": false, "packSymbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "packs": 10 }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1239', 'aggroed', 'crittermanager', 'hatch', `{ "isSignedWithActiveKey": true, "packSymbol": "GAMMA", "packs": 10 }`));
|
||||
|
@ -518,13 +519,13 @@ describe('crittermanager', function() {
|
|||
transactions.push(new Transaction(38145386, 'TXID1242', 'aggroed', 'crittermanager', 'hatch', `{ "isSignedWithActiveKey": true, "packSymbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "packs": 3.14159 }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1243', 'aggroed', 'crittermanager', 'hatch', `{ "isSignedWithActiveKey": true, "packSymbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "packs": "notanumber" }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1244', 'aggroed', 'crittermanager', 'hatch', `{ "isSignedWithActiveKey": true, "packSymbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "packs": 10 }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1245', 'steemsc', 'tokens', 'transfer', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"aggroed", "quantity":"1", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1245', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"aggroed", "quantity":"1", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1246', 'aggroed', 'crittermanager', 'hatch', `{ "isSignedWithActiveKey": true, "packSymbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "packs": 10 }`));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 38145386,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 38145386,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -543,14 +544,14 @@ describe('crittermanager', function() {
|
|||
|
||||
const block1 = await database1.getBlockInfo(1);
|
||||
const transactionsBlock1 = block1.transactions;
|
||||
console.log(transactionsBlock1[8].logs)
|
||||
console.log(transactionsBlock1[9].logs)
|
||||
console.log(transactionsBlock1[10].logs)
|
||||
console.log(transactionsBlock1[11].logs)
|
||||
console.log(transactionsBlock1[12].logs)
|
||||
console.log(transactionsBlock1[13].logs)
|
||||
console.log(transactionsBlock1[14].logs)
|
||||
console.log(transactionsBlock1[16].logs)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
assert.equal(JSON.parse(transactionsBlock1[8].logs).errors[0], 'you must use a custom_json signed with your active key');
|
||||
assert.equal(JSON.parse(transactionsBlock1[9].logs).errors[0], 'invalid pack symbol');
|
||||
|
@ -578,21 +579,21 @@ describe('crittermanager', function() {
|
|||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(38145386, 'TXID1230', 'steemsc', 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1231', 'steemsc', 'contract', 'deploy', JSON.stringify(nftContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1232', 'steemsc', 'contract', 'deploy', JSON.stringify(critterContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1233', 'steemsc', 'nft', 'updateParams', `{ "nftCreationFee": "5", "dataPropertyCreationFee": "5", "nftIssuanceFee": {"${CONSTANTS.UTILITY_TOKEN_SYMBOL}":"0.1"} }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1234', 'steemsc', 'tokens', 'transfer', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"cryptomancer", "quantity":"1000", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1235', 'steemsc', 'tokens', 'transfer', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"aggroed", "quantity":"1000", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1236', 'steemsc', 'tokens', 'transferToContract', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"crittermanager", "quantity":"1000", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1230', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1231', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(nftContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1232', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(critterContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'nft', 'updateParams', `{ "nftCreationFee": "5", "dataPropertyCreationFee": "5", "nftIssuanceFee": {"${CONSTANTS.UTILITY_TOKEN_SYMBOL}":"0.1"} }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"cryptomancer", "quantity":"1000", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"aggroed", "quantity":"1000", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transferToContract', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"crittermanager", "quantity":"1000", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1237', 'cryptomancer', 'crittermanager', 'createNft', '{ "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(38145386, 'TXID1238', 'aggroed', 'crittermanager', 'hatch', `{ "isSignedWithActiveKey": true, "packSymbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "packs": 1 }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1239', 'aggroed', 'crittermanager', 'updateName', '{ "id": "2", "name": "Toothless" }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 38145386,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 38145386,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -616,7 +617,7 @@ describe('crittermanager', function() {
|
|||
query: { _id: 2 },
|
||||
});
|
||||
|
||||
console.log(instance);
|
||||
|
||||
|
||||
assert.equal(instance.account, 'aggroed');
|
||||
assert.equal(instance.ownedBy, 'u');
|
||||
|
@ -639,13 +640,13 @@ describe('crittermanager', function() {
|
|||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(38145386, 'TXID1230', 'steemsc', 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1231', 'steemsc', 'contract', 'deploy', JSON.stringify(nftContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1232', 'steemsc', 'contract', 'deploy', JSON.stringify(critterContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1233', 'steemsc', 'nft', 'updateParams', `{ "nftCreationFee": "5", "dataPropertyCreationFee": "5", "nftIssuanceFee": {"${CONSTANTS.UTILITY_TOKEN_SYMBOL}":"0.1"} }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1234', 'steemsc', 'tokens', 'transfer', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"cryptomancer", "quantity":"1000", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1235', 'steemsc', 'tokens', 'transfer', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"aggroed", "quantity":"1000", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1236', 'steemsc', 'tokens', 'transferToContract', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"crittermanager", "quantity":"1000", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1230', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1231', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(nftContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1232', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(critterContractPayload)));
|
||||
transactions.push(new Transaction(38145386, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'nft', 'updateParams', `{ "nftCreationFee": "5", "dataPropertyCreationFee": "5", "nftIssuanceFee": {"${CONSTANTS.UTILITY_TOKEN_SYMBOL}":"0.1"} }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"cryptomancer", "quantity":"1000", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"aggroed", "quantity":"1000", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transferToContract', `{ "symbol":"${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to":"crittermanager", "quantity":"1000", "isSignedWithActiveKey":true }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1237', 'cryptomancer', 'crittermanager', 'createNft', '{ "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(38145386, 'TXID1238', 'aggroed', 'crittermanager', 'hatch', `{ "isSignedWithActiveKey": true, "packSymbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "packs": 1 }`));
|
||||
transactions.push(new Transaction(38145386, 'TXID1239', 'aggroed', 'crittermanager', 'updateName', '{ "name": "Toothless" }'));
|
||||
|
@ -656,9 +657,9 @@ describe('crittermanager', function() {
|
|||
transactions.push(new Transaction(38145386, 'TXID1244', 'cryptomancer', 'crittermanager', 'updateName', '{ "id": "2", "name": "Mega Drive" }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 38145386,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 38145386,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -667,12 +668,12 @@ describe('crittermanager', function() {
|
|||
|
||||
const block1 = await database1.getBlockInfo(1);
|
||||
const transactionsBlock1 = block1.transactions;
|
||||
console.log(transactionsBlock1[9].logs)
|
||||
console.log(transactionsBlock1[10].logs)
|
||||
console.log(transactionsBlock1[11].logs)
|
||||
console.log(transactionsBlock1[12].logs)
|
||||
console.log(transactionsBlock1[13].logs)
|
||||
console.log(transactionsBlock1[14].logs)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
assert.equal(JSON.parse(transactionsBlock1[9].logs).errors[0], 'invalid params');
|
||||
assert.equal(JSON.parse(transactionsBlock1[10].logs).errors[0], 'invalid params');
|
||||
|
@ -697,7 +698,7 @@ describe('crittermanager', function() {
|
|||
query: { _id: 2 },
|
||||
});
|
||||
|
||||
console.log(instance);
|
||||
|
||||
|
||||
assert.equal(instance.account, 'aggroed');
|
||||
assert.equal(instance.ownedBy, 'u');
|
||||
|
|
45
test/dice.js
45
test/dice.js
|
@ -11,14 +11,14 @@ const { MongoClient } = require('mongodb');
|
|||
|
||||
const conf = {
|
||||
chainId: "test-chain-id",
|
||||
genesisSteemBlock: 2000000,
|
||||
genesisHiveBlock: 2000000,
|
||||
dataDirectory: "./test/data/",
|
||||
databaseFileName: "database.db",
|
||||
autosaveInterval: 0,
|
||||
javascriptVMTimeout: 10000,
|
||||
databaseURL: "mongodb://localhost:27017",
|
||||
databaseName: "testssc",
|
||||
streamNodes: ["https://api.steemit.com"],
|
||||
streamNodes: ["https://api.hive.com"],
|
||||
};
|
||||
|
||||
let plugins = {};
|
||||
|
@ -98,6 +98,8 @@ let contractCode = fs.readFileSync('./contracts/tokens.js');
|
|||
contractCode = contractCode.toString();
|
||||
contractCode = contractCode.replace(/'\$\{CONSTANTS.UTILITY_TOKEN_PRECISION\}\$'/g, CONSTANTS.UTILITY_TOKEN_PRECISION);
|
||||
contractCode = contractCode.replace(/'\$\{CONSTANTS.UTILITY_TOKEN_SYMBOL\}\$'/g, CONSTANTS.UTILITY_TOKEN_SYMBOL);
|
||||
contractCode = contractCode.replace(/'\$\{CONSTANTS.HIVE_PEGGED_SYMBOL\}\$'/g, CONSTANTS.HIVE_PEGGED_SYMBOL);
|
||||
|
||||
let base64ContractCode = Base64.encode(contractCode);
|
||||
|
||||
let tknContractPayload = {
|
||||
|
@ -106,20 +108,20 @@ let tknContractPayload = {
|
|||
code: base64ContractCode,
|
||||
};
|
||||
|
||||
// prepare steempegged contract for deployment
|
||||
contractCode = fs.readFileSync('./contracts/steempegged.js');
|
||||
// prepare hivepegged contract for deployment
|
||||
contractCode = fs.readFileSync('./contracts/hivepegged.js');
|
||||
contractCode = contractCode.toString();
|
||||
contractCode = contractCode.replace(/'\$\{ACCOUNT_RECEIVING_FEES\}\$'/g, CONSTANTS.ACCOUNT_RECEIVING_FEES);
|
||||
contractCode = contractCode.replace(/'\$\{CONSTANTS.ACCOUNT_RECEIVING_FEES\}\$'/g, CONSTANTS.ACCOUNT_RECEIVING_FEES);
|
||||
base64ContractCode = Base64.encode(contractCode);
|
||||
|
||||
let spContractPayload = {
|
||||
name: 'steempegged',
|
||||
name: 'hivepegged',
|
||||
params: '',
|
||||
code: base64ContractCode,
|
||||
};
|
||||
|
||||
// prepare dice contract for deployment
|
||||
contractCode = fs.readFileSync('./contracts/bootstrap/dice.js');
|
||||
contractCode = fs.readFileSync('./contracts/dice.js');
|
||||
contractCode = contractCode.toString();
|
||||
base64ContractCode = Base64.encode(contractCode);
|
||||
|
||||
|
@ -130,7 +132,7 @@ let diceContractPayload = {
|
|||
};
|
||||
|
||||
// dice
|
||||
describe('dice', function() {
|
||||
describe.skip('dice', function() {
|
||||
this.timeout(10000);
|
||||
|
||||
before((done) => {
|
||||
|
@ -183,13 +185,16 @@ describe('dice', function() {
|
|||
database = new Database();
|
||||
await database.init(conf.databaseURL, conf.databaseName);
|
||||
|
||||
const gen = await database.getBlockInfo(0);
|
||||
//console.log(gen);
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(30983000, 'TXID1230', 'steemsc', 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(30983000, 'TXID1231', CONSTANTS.STEEM_PEGGED_ACCOUNT, 'contract', 'update', JSON.stringify(spContractPayload)));
|
||||
transactions.push(new Transaction(30983000, 'TXID1232', 'steemsc', 'contract', 'update', JSON.stringify(diceContractPayload)));
|
||||
transactions.push(new Transaction(30983000, 'TXID1233', 'harpagon', 'steempegged', 'buy', `{ "recipient": "${CONSTANTS.STEEM_PEGGED_ACCOUNT}", "amountSTEEMSBD": "1100.00 STEEM", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(30983000, 'TXID1234', 'harpagon', 'tokens', 'transferToContract', '{ "symbol": "STEEMP", "to": "dice", "quantity": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(30983000, 'TXID1236', 'satoshi', 'steempegged', 'buy', `{ "recipient": "${CONSTANTS.STEEM_PEGGED_ACCOUNT}", "amountSTEEMSBD": "100.00 STEEM", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(30983000, 'TXID1230', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(30983000, 'TXID1231', CONSTANTS.HIVE_PEGGED_ACCOUNT, 'contract', 'update', JSON.stringify(spContractPayload)));
|
||||
transactions.push(new Transaction(30983000, 'TXID1232', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(diceContractPayload)));
|
||||
transactions.push(new Transaction(30983000, 'TXID1233', 'harpagon', 'hivepegged', 'buy', `{ "recipient": "${CONSTANTS.HIVE_PEGGED_ACCOUNT}", "amountHIVEHBD": "1100.00 HIVE", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(30983000, 'TXID1234', 'harpagon', 'tokens', 'transferToContract', '{ "symbol": "SWAP.HIVE", "to": "dice", "quantity": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(30983000, 'TXID1236', 'satoshi', 'hivepegged', 'buy', `{ "recipient": "${CONSTANTS.HIVE_PEGGED_ACCOUNT}", "amountHIVEHBD": "100.00 HIVE", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(30983000, 'TXID1237', 'satoshi', 'dice', 'roll', `{ "roll": 95, "amount": "33" , "isSignedWithActiveKey": true }`));
|
||||
|
||||
let block = new Block(30983000, 'ABCD2', 'ABCD1', '2018-06-01T00:00:00', transactions);
|
||||
|
@ -222,12 +227,12 @@ describe('dice', function() {
|
|||
|
||||
let transactions = [];
|
||||
|
||||
transactions.push(new Transaction(30983000, 'TXID1230', 'steemsc', 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(30983000, 'TXID1231', CONSTANTS.STEEM_PEGGED_ACCOUNT, 'contract', 'update', JSON.stringify(spContractPayload)));
|
||||
transactions.push(new Transaction(30983000, 'TXID1232', 'steemsc', 'contract', 'update', JSON.stringify(diceContractPayload)));
|
||||
transactions.push(new Transaction(30983000, 'TXID1233', 'harpagon', 'steempegged', 'buy', `{ "recipient": "${CONSTANTS.STEEM_PEGGED_ACCOUNT}", "amountSTEEMSBD": "1100.00 STEEM", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(30983000, 'TXID1234', 'harpagon', 'tokens', 'transferToContract', '{ "symbol": "STEEMP", "to": "dice", "quantity": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(30983000, 'TXID1236', 'satoshi', 'steempegged', 'buy', `{ "recipient": "${CONSTANTS.STEEM_PEGGED_ACCOUNT}", "amountSTEEMSBD": "100.00 STEEM", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(30983000, 'TXID1230', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(30983000, 'TXID1231', CONSTANTS.HIVE_PEGGED_ACCOUNT, 'contract', 'update', JSON.stringify(spContractPayload)));
|
||||
transactions.push(new Transaction(30983000, 'TXID1232', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(diceContractPayload)));
|
||||
transactions.push(new Transaction(30983000, 'TXID1233', 'harpagon', 'hivepegged', 'buy', `{ "recipient": "${CONSTANTS.HIVE_PEGGED_ACCOUNT}", "amountHIVEHBD": "1100.00 HIVE", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(30983000, 'TXID1234', 'harpagon', 'tokens', 'transferToContract', '{ "symbol": "SWAP.HIVE", "to": "dice", "quantity": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(30983000, 'TXID1236', 'satoshi', 'hivepegged', 'buy', `{ "recipient": "${CONSTANTS.HIVE_PEGGED_ACCOUNT}", "amountHIVEHBD": "100.00 HIVE", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(30983000, 'TXID1237', 'satoshi', 'dice', 'roll', `{ "roll": 2, "amount": "33" , "isSignedWithActiveKey": true }`));
|
||||
|
||||
let block = new Block(30983000, 'ABCD2', 'ABCD1', '2018-06-01T00:00:00', transactions);
|
||||
|
|
|
@ -99,6 +99,8 @@ contractCode = contractCode.toString();
|
|||
|
||||
contractCode = contractCode.replace(/'\$\{CONSTANTS.UTILITY_TOKEN_PRECISION\}\$'/g, CONSTANTS.UTILITY_TOKEN_PRECISION);
|
||||
contractCode = contractCode.replace(/'\$\{CONSTANTS.UTILITY_TOKEN_SYMBOL\}\$'/g, CONSTANTS.UTILITY_TOKEN_SYMBOL);
|
||||
contractCode = contractCode.replace(/'\$\{CONSTANTS.HIVE_PEGGED_SYMBOL\}\$'/g, CONSTANTS.HIVE_PEGGED_SYMBOL);
|
||||
|
||||
|
||||
let base64ContractCode = Base64.encode(contractCode);
|
||||
|
||||
|
@ -108,19 +110,18 @@ let tknContractPayload = {
|
|||
code: base64ContractCode,
|
||||
};
|
||||
|
||||
contractCode = fs.readFileSync('./contracts/steempegged.js');
|
||||
contractCode = fs.readFileSync('./contracts/hivepegged.js');
|
||||
contractCode = contractCode.toString();
|
||||
contractCode = contractCode.replace(/'\$\{CONSTANTS.ACCOUNT_RECEIVING_FEES\}\$'/g, CONSTANTS.ACCOUNT_RECEIVING_FEES);
|
||||
base64ContractCode = Base64.encode(contractCode);
|
||||
|
||||
let spContractPayload = {
|
||||
name: 'steempegged',
|
||||
name: 'hivepegged',
|
||||
params: '',
|
||||
code: base64ContractCode,
|
||||
};
|
||||
|
||||
// STEEMP
|
||||
describe('Steem Pegged', function () {
|
||||
describe('Hive Pegged', function () {
|
||||
this.timeout(10000);
|
||||
|
||||
before((done) => {
|
||||
|
@ -166,7 +167,7 @@ describe('Steem Pegged', function () {
|
|||
})
|
||||
});
|
||||
|
||||
it('buys STEEMP', (done) => {
|
||||
it(`buys ${CONSTANTS.HIVE_PEGGED_SYMBOL}`, (done) => {
|
||||
new Promise(async (resolve) => {
|
||||
|
||||
await loadPlugin(blockchain);
|
||||
|
@ -174,15 +175,15 @@ describe('Steem Pegged', function () {
|
|||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(CONSTANTS.FORK_BLOCK_NUMBER, 'TXID1232', 'steemsc', 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(CONSTANTS.FORK_BLOCK_NUMBER, 'TXID1233', CONSTANTS.STEEM_PEGGED_ACCOUNT, 'contract', 'update', JSON.stringify(spContractPayload)));
|
||||
transactions.push(new Transaction(CONSTANTS.FORK_BLOCK_NUMBER, 'TXID1236', 'harpagon', 'steempegged', 'buy', `{ "recipient": "${CONSTANTS.STEEM_PEGGED_ACCOUNT}", "amountSTEEMSBD": "0.002 STEEM", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(CONSTANTS.FORK_BLOCK_NUMBER, 'TXID1237', 'satoshi', 'steempegged', 'buy', `{ "recipient": "${CONSTANTS.STEEM_PEGGED_ACCOUNT}", "amountSTEEMSBD": "0.879 STEEM", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(4000000, 'TXID1232', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(4000000, 'TXID1233', CONSTANTS.HIVE_PEGGED_ACCOUNT, 'contract', 'update', JSON.stringify(spContractPayload)));
|
||||
transactions.push(new Transaction(4000000, 'TXID1236', 'harpagon', 'hivepegged', 'buy', `{ "recipient": "${CONSTANTS.HIVE_PEGGED_ACCOUNT}", "amountHIVEHBD": "0.002 HIVE", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(4000000, 'TXID1237', 'satoshi', 'hivepegged', 'buy', `{ "recipient": "${CONSTANTS.HIVE_PEGGED_ACCOUNT}", "amountHIVEHBD": "0.879 HIVE", "isSignedWithActiveKey": true }`));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 1,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 1,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -193,7 +194,7 @@ describe('Steem Pegged', function () {
|
|||
contract: 'tokens',
|
||||
table: 'balances',
|
||||
query: {
|
||||
symbol: 'STEEMP',
|
||||
symbol: CONSTANTS.HIVE_PEGGED_SYMBOL,
|
||||
account: {
|
||||
$in: ['harpagon', 'satoshi']
|
||||
}
|
||||
|
@ -203,11 +204,11 @@ describe('Steem Pegged', function () {
|
|||
let balances = res;
|
||||
assert.equal(balances[0].balance, 0.001);
|
||||
assert.equal(balances[0].account, 'harpagon');
|
||||
assert.equal(balances[0].symbol, 'STEEMP');
|
||||
assert.equal(balances[0].symbol, CONSTANTS.HIVE_PEGGED_SYMBOL);
|
||||
|
||||
assert.equal(balances[1].balance, 0.87);
|
||||
assert.equal(balances[1].account, 'satoshi');
|
||||
assert.equal(balances[1].symbol, 'STEEMP');
|
||||
assert.equal(balances[1].symbol, CONSTANTS.HIVE_PEGGED_SYMBOL);
|
||||
|
||||
resolve();
|
||||
})
|
||||
|
@ -218,7 +219,7 @@ describe('Steem Pegged', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it('withdraws STEEM', (done) => {
|
||||
it('withdraws HIVE', (done) => {
|
||||
new Promise(async (resolve) => {
|
||||
|
||||
await loadPlugin(blockchain);
|
||||
|
@ -226,17 +227,17 @@ describe('Steem Pegged', function () {
|
|||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(CONSTANTS.FORK_BLOCK_NUMBER, 'TXID1232', 'steemsc', 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(CONSTANTS.FORK_BLOCK_NUMBER, 'TXID1233', CONSTANTS.STEEM_PEGGED_ACCOUNT, 'contract', 'update', JSON.stringify(spContractPayload)));
|
||||
transactions.push(new Transaction(CONSTANTS.FORK_BLOCK_NUMBER, 'TXID1236', 'harpagon', 'steempegged', 'buy', `{ "recipient": "${CONSTANTS.STEEM_PEGGED_ACCOUNT}", "amountSTEEMSBD": "0.003 STEEM", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(CONSTANTS.FORK_BLOCK_NUMBER, 'TXID1237', 'satoshi', 'steempegged', 'buy', `{ "recipient": "${CONSTANTS.STEEM_PEGGED_ACCOUNT}", "amountSTEEMSBD": "0.879 STEEM", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(CONSTANTS.FORK_BLOCK_NUMBER, 'TXID1238', 'harpagon', 'steempegged', 'withdraw', '{ "quantity": "0.002", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(CONSTANTS.FORK_BLOCK_NUMBER, 'TXID1239', 'satoshi', 'steempegged', 'withdraw', '{ "quantity": "0.3", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(4000000, 'TXID1232', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(4000000, 'TXID1233', CONSTANTS.HIVE_PEGGED_ACCOUNT, 'contract', 'update', JSON.stringify(spContractPayload)));
|
||||
transactions.push(new Transaction(4000000, 'TXID1236', 'harpagon', 'hivepegged', 'buy', `{ "recipient": "${CONSTANTS.HIVE_PEGGED_ACCOUNT}", "amountHIVEHBD": "0.003 HIVE", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(4000000, 'TXID1237', 'satoshi', 'hivepegged', 'buy', `{ "recipient": "${CONSTANTS.HIVE_PEGGED_ACCOUNT}", "amountHIVEHBD": "0.879 HIVE", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(4000000, 'TXID1238', 'harpagon', 'hivepegged', 'withdraw', '{ "quantity": "0.002", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(4000000, 'TXID1239', 'satoshi', 'hivepegged', 'withdraw', '{ "quantity": "0.3", "isSignedWithActiveKey": true }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 1,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 1,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -247,7 +248,7 @@ describe('Steem Pegged', function () {
|
|||
contract: 'tokens',
|
||||
table: 'balances',
|
||||
query: {
|
||||
symbol: 'STEEMP',
|
||||
symbol: CONSTANTS.HIVE_PEGGED_SYMBOL,
|
||||
account: {
|
||||
$in: ['harpagon', 'satoshi']
|
||||
}
|
||||
|
@ -258,14 +259,14 @@ describe('Steem Pegged', function () {
|
|||
|
||||
assert.equal(balances[0].balance, 0);
|
||||
assert.equal(balances[0].account, 'harpagon');
|
||||
assert.equal(balances[0].symbol, 'STEEMP');
|
||||
assert.equal(balances[0].symbol, CONSTANTS.HIVE_PEGGED_SYMBOL);
|
||||
|
||||
assert.equal(balances[1].balance, 0.57);
|
||||
assert.equal(balances[1].account, 'satoshi');
|
||||
assert.equal(balances[1].symbol, 'STEEMP');
|
||||
assert.equal(balances[1].symbol, CONSTANTS.HIVE_PEGGED_SYMBOL);
|
||||
|
||||
res = await database1.find({
|
||||
contract: 'steempegged',
|
||||
contract: 'hivepegged',
|
||||
table: 'withdrawals',
|
||||
query: {
|
||||
}
|
||||
|
@ -274,38 +275,38 @@ describe('Steem Pegged', function () {
|
|||
let withdrawals = res;
|
||||
|
||||
assert.equal(withdrawals[0].id, 'TXID1236-fee');
|
||||
assert.equal(withdrawals[0].type, 'STEEM');
|
||||
assert.equal(withdrawals[0].recipient, 'steemsc');
|
||||
assert.equal(withdrawals[0].type, 'HIVE');
|
||||
assert.equal(withdrawals[0].recipient, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(withdrawals[0].memo, 'fee tx TXID1236');
|
||||
assert.equal(withdrawals[0].quantity, 0.001);
|
||||
|
||||
assert.equal(withdrawals[1].id, 'TXID1237-fee');
|
||||
assert.equal(withdrawals[1].type, 'STEEM');
|
||||
assert.equal(withdrawals[1].recipient, 'steemsc');
|
||||
assert.equal(withdrawals[1].type, 'HIVE');
|
||||
assert.equal(withdrawals[1].recipient, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(withdrawals[1].memo, 'fee tx TXID1237');
|
||||
assert.equal(withdrawals[1].quantity, 0.009);
|
||||
|
||||
assert.equal(withdrawals[2].id, 'TXID1238');
|
||||
assert.equal(withdrawals[2].type, 'STEEM');
|
||||
assert.equal(withdrawals[2].type, 'HIVE');
|
||||
assert.equal(withdrawals[2].recipient, 'harpagon');
|
||||
assert.equal(withdrawals[2].memo, 'withdrawal tx TXID1238');
|
||||
assert.equal(withdrawals[2].quantity, 0.001);
|
||||
|
||||
assert.equal(withdrawals[3].id, 'TXID1238-fee');
|
||||
assert.equal(withdrawals[3].type, 'STEEM');
|
||||
assert.equal(withdrawals[3].recipient, 'steemsc');
|
||||
assert.equal(withdrawals[3].type, 'HIVE');
|
||||
assert.equal(withdrawals[3].recipient, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(withdrawals[3].memo, 'fee tx TXID1238');
|
||||
assert.equal(withdrawals[3].quantity, 0.001);
|
||||
|
||||
assert.equal(withdrawals[4].id, 'TXID1239');
|
||||
assert.equal(withdrawals[4].type, 'STEEM');
|
||||
assert.equal(withdrawals[4].type, 'HIVE');
|
||||
assert.equal(withdrawals[4].recipient, 'satoshi');
|
||||
assert.equal(withdrawals[4].memo, 'withdrawal tx TXID1239');
|
||||
assert.equal(withdrawals[4].quantity, 0.297);
|
||||
|
||||
assert.equal(withdrawals[5].id, 'TXID1239-fee');
|
||||
assert.equal(withdrawals[5].type, 'STEEM');
|
||||
assert.equal(withdrawals[5].recipient, 'steemsc');
|
||||
assert.equal(withdrawals[5].type, 'HIVE');
|
||||
assert.equal(withdrawals[5].recipient, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(withdrawals[5].memo, 'fee tx TXID1239');
|
||||
assert.equal(withdrawals[5].quantity, 0.003);
|
||||
|
||||
|
@ -318,7 +319,7 @@ describe('Steem Pegged', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it('does not withdraw STEEM', (done) => {
|
||||
it('does not withdraw HIVE', (done) => {
|
||||
new Promise(async (resolve) => {
|
||||
|
||||
await loadPlugin(blockchain);
|
||||
|
@ -326,17 +327,17 @@ describe('Steem Pegged', function () {
|
|||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(CONSTANTS.FORK_BLOCK_NUMBER, 'TXID1232', 'steemsc', 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(CONSTANTS.FORK_BLOCK_NUMBER, 'TXID1233', CONSTANTS.STEEM_PEGGED_ACCOUNT, 'contract', 'update', JSON.stringify(spContractPayload)));
|
||||
transactions.push(new Transaction(CONSTANTS.FORK_BLOCK_NUMBER, 'TXID1236', 'harpagon', 'steempegged', 'buy', `{ "recipient": "${CONSTANTS.STEEM_PEGGED_ACCOUNT}", "amountSTEEMSBD": "0.003 STEEM", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(CONSTANTS.FORK_BLOCK_NUMBER, 'TXID1237', 'satoshi', 'steempegged', 'buy', `{ "recipient": "${CONSTANTS.STEEM_PEGGED_ACCOUNT}", "amountSTEEMSBD": "0.879 STEEM", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(CONSTANTS.FORK_BLOCK_NUMBER, 'TXID1239', 'satoshi', 'steempegged', 'withdraw', '{ "quantity": "0.001", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(CONSTANTS.FORK_BLOCK_NUMBER, 'TXID1240', 'satoshi', 'steempegged', 'withdraw', '{ "quantity": "0.0021", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(4000000, 'TXID1232', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(4000000, 'TXID1233', CONSTANTS.HIVE_PEGGED_ACCOUNT, 'contract', 'update', JSON.stringify(spContractPayload)));
|
||||
transactions.push(new Transaction(4000000, 'TXID1236', 'harpagon', 'hivepegged', 'buy', `{ "recipient": "${CONSTANTS.HIVE_PEGGED_ACCOUNT}", "amountHIVEHBD": "0.003 HIVE", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(4000000, 'TXID1237', 'satoshi', 'hivepegged', 'buy', `{ "recipient": "${CONSTANTS.HIVE_PEGGED_ACCOUNT}", "amountHIVEHBD": "0.879 HIVE", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(4000000, 'TXID1239', 'satoshi', 'hivepegged', 'withdraw', '{ "quantity": "0.001", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(4000000, 'TXID1240', 'satoshi', 'hivepegged', 'withdraw', '{ "quantity": "0.0021", "isSignedWithActiveKey": true }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 1,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 1,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -347,7 +348,7 @@ describe('Steem Pegged', function () {
|
|||
contract: 'tokens',
|
||||
table: 'balances',
|
||||
query: {
|
||||
symbol: 'STEEMP',
|
||||
symbol: CONSTANTS.HIVE_PEGGED_SYMBOL,
|
||||
account: 'satoshi'
|
||||
}
|
||||
});
|
||||
|
@ -356,10 +357,10 @@ describe('Steem Pegged', function () {
|
|||
|
||||
assert.equal(balance.balance, 0.87);
|
||||
assert.equal(balance.account, 'satoshi');
|
||||
assert.equal(balance.symbol, 'STEEMP');
|
||||
assert.equal(balance.symbol, CONSTANTS.HIVE_PEGGED_SYMBOL);
|
||||
|
||||
res = await database1.find({
|
||||
contract: 'steempegged',
|
||||
contract: 'hivepegged',
|
||||
table: 'withdrawals',
|
||||
query: {
|
||||
'recipient': 'satoshi'
|
|
@ -157,10 +157,16 @@ describe('Database', function () {
|
|||
assert.equal(genesisBlock.hash, '51b19802489567cb2669bfb37119dbe09f36c0847fe2dca2e918176422a0bcd9');
|
||||
assert.equal(genesisBlock.databaseHash, 'a3daa72622eb02abd0b1614943f45500633dc10789477e8ee538a8398e61f976');
|
||||
assert.equal(genesisBlock.merkleRoot, '8b2c7d50aadcba182e4de6140d795b6e6e4e0a64b654d6b1a3ab48a234489293');
|
||||
} else {
|
||||
} else if (configFile.chainId === 'mainnet1'
|
||||
&& CONSTANTS.UTILITY_TOKEN_SYMBOL === 'ENG') {
|
||||
assert.equal(genesisBlock.hash, 'c1dee96a6b7a0cc9408ccb407ab641f444c26f6859ba33b9c9ba2c0a368d20b2');
|
||||
assert.equal(genesisBlock.databaseHash, 'a3daa72622eb02abd0b1614943f45500633dc10789477e8ee538a8398e61f976');
|
||||
assert.equal(genesisBlock.merkleRoot, '7048315fc8861b98fe1b2a82b86a24f80aa6e6dd225223e39771807532f5fb21');
|
||||
} else if (configFile.chainId === 'mainnet-hive'
|
||||
&& CONSTANTS.UTILITY_TOKEN_SYMBOL === 'BEE') {
|
||||
assert.equal(genesisBlock.hash, 'd6310e1f360fe0061dd4527649981f70fba6d9dc65c36fd246fc4e32d834e0ce');
|
||||
assert.equal(genesisBlock.databaseHash, '43bdc779c64ec6d1c4a682c711371ecc4e40c7f51edb46993d83a5760edbf37f');
|
||||
assert.equal(genesisBlock.merkleRoot, 'e8cdd4cbfe150a73146bafa6d3116b036ac23ecbaebc5939324ff504dc028063');
|
||||
}
|
||||
|
||||
resolve();
|
||||
|
@ -180,7 +186,7 @@ describe('Database', function () {
|
|||
await database.init(conf.databaseURL, conf.databaseName);
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', 'steemsc', 'contract', 'deploy', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', ''));
|
||||
|
||||
let block = new Block(
|
||||
'2018-06-01T00:00:00',
|
||||
|
@ -195,7 +201,7 @@ describe('Database', function () {
|
|||
await database.addBlock(block);
|
||||
|
||||
transactions = [];
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', 'steemsc', 'contract', 'deploy', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', ''));
|
||||
|
||||
block = new Block(
|
||||
'2018-06-01T00:00:00',
|
||||
|
@ -284,28 +290,28 @@ describe('Smart Contracts', function () {
|
|||
const base64SmartContractCode = Base64.encode(smartContractCode);
|
||||
|
||||
const contractPayload = {
|
||||
name: 'testContract',
|
||||
name: 'testcontract',
|
||||
params: '',
|
||||
code: base64SmartContractCode,
|
||||
};
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', 'steemsc', 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 1,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 1,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
||||
await send(blockchain.PLUGIN_NAME, 'MASTER', { action: blockchain.PLUGIN_ACTIONS.PRODUCE_NEW_BLOCK_SYNC, payload: block });
|
||||
|
||||
const contract = await database.findContract({ name: 'testContract' });
|
||||
const contract = await database.findContract({ name: 'testcontract' });
|
||||
|
||||
assert.equal(contract._id, 'testContract');
|
||||
assert.equal(contract.owner, 'steemsc');
|
||||
assert.equal(contract._id, 'testcontract');
|
||||
assert.equal(contract.owner, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
resolve()
|
||||
})
|
||||
.then(() => {
|
||||
|
@ -331,30 +337,30 @@ describe('Smart Contracts', function () {
|
|||
const base64SmartContractCode = Base64.encode(smartContractCode);
|
||||
|
||||
const contractPayload = {
|
||||
name: 'testContract',
|
||||
name: 'testcontract',
|
||||
params: '',
|
||||
code: base64SmartContractCode,
|
||||
};
|
||||
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', 'steemsc', 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 1,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 1,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
||||
await send(blockchain.PLUGIN_NAME, 'MASTER', { action: blockchain.PLUGIN_ACTIONS.PRODUCE_NEW_BLOCK_SYNC, payload: block });
|
||||
|
||||
const contract = await database.findContract({ name: 'testContract' });
|
||||
const contract = await database.findContract({ name: 'testcontract' });
|
||||
|
||||
assert.notEqual(contract.tables['testContract_testTable'], undefined);
|
||||
assert.notEqual(contract.tables['testcontract_testTable'], undefined);
|
||||
|
||||
res = await database.getTableDetails({ contract: 'testContract', table: 'testTable' });
|
||||
res = await database.getTableDetails({ contract: 'testcontract', table: 'testTable' });
|
||||
|
||||
assert.notEqual(res, null);
|
||||
resolve();
|
||||
|
@ -382,26 +388,26 @@ describe('Smart Contracts', function () {
|
|||
const base64SmartContractCode = Base64.encode(smartContractCode);
|
||||
|
||||
const contractPayload = {
|
||||
name: 'testContract',
|
||||
name: 'testcontract',
|
||||
params: '',
|
||||
code: base64SmartContractCode,
|
||||
};
|
||||
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', 'steemsc', 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 1,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 1,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
||||
await send(blockchain.PLUGIN_NAME, 'MASTER', { action: blockchain.PLUGIN_ACTIONS.PRODUCE_NEW_BLOCK_SYNC, payload: block });
|
||||
|
||||
const table = await database.getTableDetails({ contract: 'testContract', table: 'testTable' });
|
||||
const table = await database.getTableDetails({ contract: 'testcontract', table: 'testTable' });
|
||||
const { indexes } = table;
|
||||
|
||||
assert.equal(indexes._id_[0][0], '_id');
|
||||
|
@ -454,22 +460,22 @@ describe('Smart Contracts', function () {
|
|||
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', 'steemsc', 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', 'steemsc', 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'usersContract', 'addUser', ''));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 1,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 1,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
||||
await send(blockchain.PLUGIN_NAME, 'MASTER', { action: blockchain.PLUGIN_ACTIONS.PRODUCE_NEW_BLOCK_SYNC, payload: block });
|
||||
|
||||
const user = await database.findOne({ contract: 'usersContract', table: 'users', query: { "id": "steemsc" } });
|
||||
const user = await database.findOne({ contract: 'usersContract', table: 'users', query: { "id": CONSTANTS.HIVE_ENGINE_ACCOUNT } });
|
||||
|
||||
assert.equal(user.id, 'steemsc');
|
||||
assert.equal(user.id, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
|
||||
resolve();
|
||||
})
|
||||
|
@ -523,23 +529,23 @@ describe('Smart Contracts', function () {
|
|||
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', 'steemsc', 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', 'steemsc', 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID1236', 'steemsc', 'usersContract', 'updateUser', '{ "username": "MyUsernameUpdated" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'usersContract', 'updateUser', '{ "username": "MyUsernameUpdated" }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 1,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 1,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
||||
await send(blockchain.PLUGIN_NAME, 'MASTER', { action: blockchain.PLUGIN_ACTIONS.PRODUCE_NEW_BLOCK_SYNC, payload: block });
|
||||
|
||||
const user = await database.findOne({ contract: 'usersContract', table: 'users', query: { "id": "steemsc" } })
|
||||
const user = await database.findOne({ contract: 'usersContract', table: 'users', query: { "id": CONSTANTS.HIVE_ENGINE_ACCOUNT } })
|
||||
|
||||
assert.equal(user.id, 'steemsc');
|
||||
assert.equal(user.id, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(user.username, 'MyUsernameUpdated');
|
||||
|
||||
resolve();
|
||||
|
@ -590,21 +596,21 @@ describe('Smart Contracts', function () {
|
|||
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', 'steemsc', 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', 'steemsc', 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID1236', 'steemsc', 'usersContract', 'removeUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'usersContract', 'removeUser', ''));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 1,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 1,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
||||
await send(blockchain.PLUGIN_NAME, 'MASTER', { action: blockchain.PLUGIN_ACTIONS.PRODUCE_NEW_BLOCK_SYNC, payload: block });
|
||||
|
||||
const user = await database.findOne({ contract: 'usersContract', table: 'users', query: { "id": "steemsc" } });
|
||||
const user = await database.findOne({ contract: 'usersContract', table: 'users', query: { "id": CONSTANTS.HIVE_ENGINE_ACCOUNT } });
|
||||
|
||||
assert.equal(user, null);
|
||||
|
||||
|
@ -650,22 +656,22 @@ describe('Smart Contracts', function () {
|
|||
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', 'steemsc', 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', 'steemsc', 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID1236', 'steemsc1', 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID1237', 'steemsc2', 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID1238', 'steemsc3', 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID1239', 'steemsc4', 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID12310', 'steemsc5', 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID12311', 'steemsc6', 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID12312', 'steemsc7', 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID12313', 'steemsc8', 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID12314', 'steemsc9', 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID1236', 'CONSTANTS.HIVE_ENGINE_ACCOUNT1', 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID1237', 'CONSTANTS.HIVE_ENGINE_ACCOUNT2', 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID1238', 'CONSTANTS.HIVE_ENGINE_ACCOUNT3', 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID1239', 'CONSTANTS.HIVE_ENGINE_ACCOUNT4', 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID12310', 'CONSTANTS.HIVE_ENGINE_ACCOUNT5', 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID12311', 'CONSTANTS.HIVE_ENGINE_ACCOUNT6', 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID12312', 'CONSTANTS.HIVE_ENGINE_ACCOUNT7', 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID12313', 'CONSTANTS.HIVE_ENGINE_ACCOUNT8', 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID12314', 'CONSTANTS.HIVE_ENGINE_ACCOUNT9', 'usersContract', 'addUser', ''));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 1,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 1,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -753,22 +759,22 @@ describe('Smart Contracts', function () {
|
|||
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', 'steemsc', 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', 'steemsc', 'usersContract', 'addUser', '{ "age": 2 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1236', 'steemsc1', 'usersContract', 'addUser', '{ "age": 10 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1237', 'steemsc2', 'usersContract', 'addUser', '{ "age": 3 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1238', 'steemsc3', 'usersContract', 'addUser', '{ "age": 199 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1239', 'steemsc4', 'usersContract', 'addUser', '{ "age": 200 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12310', 'steemsc5', 'usersContract', 'addUser', '{ "age": 1 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12311', 'steemsc6', 'usersContract', 'addUser', '{ "age": 89 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12312', 'steemsc7', 'usersContract', 'addUser', '{ "age": 2 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12313', 'steemsc8', 'usersContract', 'addUser', '{ "age": 34 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12314', 'steemsc9', 'usersContract', 'addUser', '{ "age": 20 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'usersContract', 'addUser', '{ "age": 2 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1236', 'CONSTANTS.HIVE_ENGINE_ACCOUNT1', 'usersContract', 'addUser', '{ "age": 10 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1237', 'CONSTANTS.HIVE_ENGINE_ACCOUNT2', 'usersContract', 'addUser', '{ "age": 3 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1238', 'CONSTANTS.HIVE_ENGINE_ACCOUNT3', 'usersContract', 'addUser', '{ "age": 199 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1239', 'CONSTANTS.HIVE_ENGINE_ACCOUNT4', 'usersContract', 'addUser', '{ "age": 200 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12310', 'CONSTANTS.HIVE_ENGINE_ACCOUNT5', 'usersContract', 'addUser', '{ "age": 1 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12311', 'CONSTANTS.HIVE_ENGINE_ACCOUNT6', 'usersContract', 'addUser', '{ "age": 89 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12312', 'CONSTANTS.HIVE_ENGINE_ACCOUNT7', 'usersContract', 'addUser', '{ "age": 2 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12313', 'CONSTANTS.HIVE_ENGINE_ACCOUNT8', 'usersContract', 'addUser', '{ "age": 34 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12314', 'CONSTANTS.HIVE_ENGINE_ACCOUNT9', 'usersContract', 'addUser', '{ "age": 20 }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 1,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 1,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -860,22 +866,22 @@ describe('Smart Contracts', function () {
|
|||
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', 'steemsc', 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', 'steemsc', 'usersContract', 'addUser', '{ "age": "2" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1236', 'steemsc1', 'usersContract', 'addUser', '{ "age": "10" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1237', 'steemsc2', 'usersContract', 'addUser', '{ "age": "3" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1238', 'steemsc3', 'usersContract', 'addUser', '{ "age": "199" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1239', 'steemsc4', 'usersContract', 'addUser', '{ "age": "200" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12310', 'steemsc5', 'usersContract', 'addUser', '{ "age": "1" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12311', 'steemsc6', 'usersContract', 'addUser', '{ "age": "89" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12312', 'steemsc7', 'usersContract', 'addUser', '{ "age": "2" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12313', 'steemsc8', 'usersContract', 'addUser', '{ "age": "34" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12314', 'steemsc9', 'usersContract', 'addUser', '{ "age": "20" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'usersContract', 'addUser', '{ "age": "2" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1236', 'CONSTANTS.HIVE_ENGINE_ACCOUNT1', 'usersContract', 'addUser', '{ "age": "10" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1237', 'CONSTANTS.HIVE_ENGINE_ACCOUNT2', 'usersContract', 'addUser', '{ "age": "3" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1238', 'CONSTANTS.HIVE_ENGINE_ACCOUNT3', 'usersContract', 'addUser', '{ "age": "199" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1239', 'CONSTANTS.HIVE_ENGINE_ACCOUNT4', 'usersContract', 'addUser', '{ "age": "200" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12310', 'CONSTANTS.HIVE_ENGINE_ACCOUNT5', 'usersContract', 'addUser', '{ "age": "1" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12311', 'CONSTANTS.HIVE_ENGINE_ACCOUNT6', 'usersContract', 'addUser', '{ "age": "89" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12312', 'CONSTANTS.HIVE_ENGINE_ACCOUNT7', 'usersContract', 'addUser', '{ "age": "2" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12313', 'CONSTANTS.HIVE_ENGINE_ACCOUNT8', 'usersContract', 'addUser', '{ "age": "34" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12314', 'CONSTANTS.HIVE_ENGINE_ACCOUNT9', 'usersContract', 'addUser', '{ "age": "20" }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 1,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 1,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -967,22 +973,22 @@ describe('Smart Contracts', function () {
|
|||
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', 'steemsc', 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', 'steemsc', 'usersContract', 'addUser', '{ "age": 2 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1236', 'steemsc1', 'usersContract', 'addUser', '{ "age": 10 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1237', 'steemsc2', 'usersContract', 'addUser', '{ "age": 3 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1238', 'steemsc3', 'usersContract', 'addUser', '{ "age": 199 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1239', 'steemsc4', 'usersContract', 'addUser', '{ "age": 200 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12310', 'steemsc5', 'usersContract', 'addUser', '{ "age": 1 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12311', 'steemsc6', 'usersContract', 'addUser', '{ "age": 89 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12312', 'steemsc7', 'usersContract', 'addUser', '{ "age": 2 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12313', 'steemsc8', 'usersContract', 'addUser', '{ "age": 34 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12314', 'steemsc9', 'usersContract', 'addUser', '{ "age": 20 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'usersContract', 'addUser', '{ "age": 2 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1236', 'CONSTANTS.HIVE_ENGINE_ACCOUNT1', 'usersContract', 'addUser', '{ "age": 10 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1237', 'CONSTANTS.HIVE_ENGINE_ACCOUNT2', 'usersContract', 'addUser', '{ "age": 3 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1238', 'CONSTANTS.HIVE_ENGINE_ACCOUNT3', 'usersContract', 'addUser', '{ "age": 199 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1239', 'CONSTANTS.HIVE_ENGINE_ACCOUNT4', 'usersContract', 'addUser', '{ "age": 200 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12310', 'CONSTANTS.HIVE_ENGINE_ACCOUNT5', 'usersContract', 'addUser', '{ "age": 1 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12311', 'CONSTANTS.HIVE_ENGINE_ACCOUNT6', 'usersContract', 'addUser', '{ "age": 89 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12312', 'CONSTANTS.HIVE_ENGINE_ACCOUNT7', 'usersContract', 'addUser', '{ "age": 2 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12313', 'CONSTANTS.HIVE_ENGINE_ACCOUNT8', 'usersContract', 'addUser', '{ "age": 34 }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12314', 'CONSTANTS.HIVE_ENGINE_ACCOUNT9', 'usersContract', 'addUser', '{ "age": 20 }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 1,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 1,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1073,22 +1079,22 @@ describe('Smart Contracts', function () {
|
|||
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', 'steemsc', 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', 'steemsc', 'usersContract', 'addUser', '{ "age": "2" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1236', 'steemsc1', 'usersContract', 'addUser', '{ "age": "10" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1237', 'steemsc2', 'usersContract', 'addUser', '{ "age": "3" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1238', 'steemsc3', 'usersContract', 'addUser', '{ "age": "199" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1239', 'steemsc4', 'usersContract', 'addUser', '{ "age": "200" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12310', 'steemsc5', 'usersContract', 'addUser', '{ "age": "1" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12311', 'steemsc6', 'usersContract', 'addUser', '{ "age": "89" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12312', 'steemsc7', 'usersContract', 'addUser', '{ "age": "2" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12313', 'steemsc8', 'usersContract', 'addUser', '{ "age": "34" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12314', 'steemsc9', 'usersContract', 'addUser', '{ "age": "20" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'usersContract', 'addUser', '{ "age": "2" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1236', 'CONSTANTS.HIVE_ENGINE_ACCOUNT1', 'usersContract', 'addUser', '{ "age": "10" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1237', 'CONSTANTS.HIVE_ENGINE_ACCOUNT2', 'usersContract', 'addUser', '{ "age": "3" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1238', 'CONSTANTS.HIVE_ENGINE_ACCOUNT3', 'usersContract', 'addUser', '{ "age": "199" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1239', 'CONSTANTS.HIVE_ENGINE_ACCOUNT4', 'usersContract', 'addUser', '{ "age": "200" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12310', 'CONSTANTS.HIVE_ENGINE_ACCOUNT5', 'usersContract', 'addUser', '{ "age": "1" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12311', 'CONSTANTS.HIVE_ENGINE_ACCOUNT6', 'usersContract', 'addUser', '{ "age": "89" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12312', 'CONSTANTS.HIVE_ENGINE_ACCOUNT7', 'usersContract', 'addUser', '{ "age": "2" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12313', 'CONSTANTS.HIVE_ENGINE_ACCOUNT8', 'usersContract', 'addUser', '{ "age": "34" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID12314', 'CONSTANTS.HIVE_ENGINE_ACCOUNT9', 'usersContract', 'addUser', '{ "age": "20" }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 1,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 1,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1180,13 +1186,13 @@ describe('Smart Contracts', function () {
|
|||
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', 'steemsc', 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', 'Dan', 'usersContract', 'addUser', '{ "userId": "Dan" }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 1,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 1,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1198,12 +1204,12 @@ describe('Smart Contracts', function () {
|
|||
assert.equal(user, null);
|
||||
|
||||
transactions = [];
|
||||
transactions.push(new Transaction(123456789, 'TXID1236', 'steemsc', 'usersContract', 'addUser', '{ "userId": "Dan" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'usersContract', 'addUser', '{ "userId": "Dan" }'));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 123456789,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 123456789,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:03',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1286,22 +1292,22 @@ describe('Smart Contracts', function () {
|
|||
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(123456789, 'TXID1233', 'steemsc', 'contract', 'deploy', JSON.stringify(usersContractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', 'steemsc', 'contract', 'deploy', JSON.stringify(booksContractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', 'steemsc', 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID1236', 'steemsc', 'booksContract', 'addBook', '{ "title": "The Awesome Book" }'));
|
||||
transactions.push(new Transaction(123456789, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(usersContractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(booksContractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'booksContract', 'addBook', '{ "title": "The Awesome Book" }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 1,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 1,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
||||
await send(blockchain.PLUGIN_NAME, 'MASTER', { action: blockchain.PLUGIN_ACTIONS.PRODUCE_NEW_BLOCK_SYNC, payload: block });
|
||||
|
||||
const book = await database.findOne({ contract: 'booksContract', table: 'books', query: { "userId": "steemsc" } });
|
||||
const book = await database.findOne({ contract: 'booksContract', table: 'books', query: { "userId": CONSTANTS.HIVE_ENGINE_ACCOUNT } });
|
||||
|
||||
assert.equal(book.title, "The Awesome Book");
|
||||
|
||||
|
@ -1381,21 +1387,21 @@ describe('Smart Contracts', function () {
|
|||
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(123456789, 'TXID1233', 'steemsc', 'contract', 'deploy', JSON.stringify(usersContractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', 'steemsc', 'contract', 'deploy', JSON.stringify(booksContractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', 'steemsc', 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(usersContractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(booksContractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'usersContract', 'addUser', ''));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 1,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 1,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
||||
await send(blockchain.PLUGIN_NAME, 'MASTER', { action: blockchain.PLUGIN_ACTIONS.PRODUCE_NEW_BLOCK_SYNC, payload: block });
|
||||
|
||||
const book = await database.findOne({ contract: 'booksContract', table: 'books', query: { "userId": "steemsc" } });
|
||||
const book = await database.findOne({ contract: 'booksContract', table: 'books', query: { "userId": CONSTANTS.HIVE_ENGINE_ACCOUNT } });
|
||||
|
||||
assert.equal(book.title, "The Awesome Book");
|
||||
|
||||
|
@ -1418,26 +1424,26 @@ describe('Smart Contracts', function () {
|
|||
const smartContractCode = `
|
||||
actions.createSSC = function (payload) {
|
||||
// Initialize the smart contract via the create action
|
||||
api.emit('contract_create', { "contractName": "testContract" })
|
||||
api.emit('contract_create', { "contractName": "testcontract" })
|
||||
}
|
||||
`;
|
||||
|
||||
const base64SmartContractCode = Base64.encode(smartContractCode);
|
||||
|
||||
const contractPayload = {
|
||||
name: 'testContract',
|
||||
name: 'testcontract',
|
||||
params: '',
|
||||
code: base64SmartContractCode,
|
||||
};
|
||||
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', 'steemsc', 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 1,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 1,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1451,7 +1457,7 @@ describe('Smart Contracts', function () {
|
|||
const logs = JSON.parse(txs[0].logs);
|
||||
|
||||
assert.equal(logs.events[0].event, 'contract_create');
|
||||
assert.equal(logs.events[0].data.contractName, 'testContract');
|
||||
assert.equal(logs.events[0].data.contractName, 'testcontract');
|
||||
|
||||
resolve();
|
||||
})
|
||||
|
@ -1485,7 +1491,7 @@ describe('Smart Contracts', function () {
|
|||
}
|
||||
|
||||
actions.addBook = async (payload) => {
|
||||
api.emit('contract_create', { "contractName": "testContract" });
|
||||
api.emit('contract_create', { "contractName": "testcontract" });
|
||||
}
|
||||
`;
|
||||
|
||||
|
@ -1506,14 +1512,14 @@ describe('Smart Contracts', function () {
|
|||
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(123456789, 'TXID1233', 'steemsc', 'contract', 'deploy', JSON.stringify(usersContractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', 'steemsc', 'contract', 'deploy', JSON.stringify(booksContractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', 'steemsc', 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(usersContractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(booksContractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'usersContract', 'addUser', ''));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 1,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 1,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1527,7 +1533,7 @@ describe('Smart Contracts', function () {
|
|||
const logs = JSON.parse(txs[0].logs);
|
||||
|
||||
assert.equal(logs.events[0].event, 'contract_create');
|
||||
assert.equal(logs.events[0].data.contractName, 'testContract');
|
||||
assert.equal(logs.events[0].data.contractName, 'testcontract');
|
||||
|
||||
resolve();
|
||||
})
|
||||
|
@ -1557,18 +1563,18 @@ describe('Smart Contracts', function () {
|
|||
const base64SmartContractCode = Base64.encode(smartContractCode);
|
||||
|
||||
const contractPayload = {
|
||||
name: 'testContract',
|
||||
name: 'testcontract',
|
||||
params: '',
|
||||
code: base64SmartContractCode,
|
||||
};
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', 'steemsc', 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 1,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 1,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1612,19 +1618,19 @@ describe('Smart Contracts', function () {
|
|||
const base64SmartContractCode = Base64.encode(smartContractCode);
|
||||
|
||||
const contractPayload = {
|
||||
name: 'testContract',
|
||||
name: 'testcontract',
|
||||
params: '',
|
||||
code: base64SmartContractCode,
|
||||
};
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', 'steemsc', 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', 'steemsc', 'testContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'testcontract', 'addUser', ''));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 1,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 1,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1636,7 +1642,7 @@ describe('Smart Contracts', function () {
|
|||
const txs = latestBlock.transactions.filter(transaction => transaction.transactionId === 'TXID1235');
|
||||
|
||||
const logs = JSON.parse(txs[0].logs);
|
||||
console.log(logs)
|
||||
|
||||
assert.equal(logs.errors[0], "ReferenceError: test1 is not defined");
|
||||
|
||||
resolve();
|
||||
|
@ -1692,14 +1698,14 @@ describe('Smart Contracts', function () {
|
|||
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(123456789, 'TXID1233', 'steemsc', 'contract', 'deploy', JSON.stringify(usersContractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', 'steemsc', 'contract', 'deploy', JSON.stringify(booksContractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', 'steemsc', 'usersContract', 'addUser', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(usersContractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(booksContractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'usersContract', 'addUser', ''));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 1,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 1,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1756,13 +1762,13 @@ describe('Smart Contracts', function () {
|
|||
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', 'steemsc', 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', 'steemsc', 'random', 'generateRandomNumbers', ''));
|
||||
transactions.push(new Transaction(123456789, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456789, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'random', 'generateRandomNumbers', ''));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 123456789,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 123456789,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1781,12 +1787,12 @@ describe('Smart Contracts', function () {
|
|||
assert.equal(logs.events[1].data.generatedRandom, 0.8219068960473853);
|
||||
|
||||
transactions = [];
|
||||
transactions.push(new Transaction(1234567891, 'TXID1236', 'steemsc', 'random', 'generateRandomNumbers', ''));
|
||||
transactions.push(new Transaction(1234567891, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'random', 'generateRandomNumbers', ''));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 1234567891,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 1234567891,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1829,7 +1835,7 @@ describe('Smart Contracts', function () {
|
|||
let base64SmartContractCode = Base64.encode(smartContractCode);
|
||||
|
||||
const contractPayload = {
|
||||
name: 'testContract',
|
||||
name: 'testcontract',
|
||||
params: '',
|
||||
code: base64SmartContractCode,
|
||||
};
|
||||
|
@ -1839,9 +1845,9 @@ describe('Smart Contracts', function () {
|
|||
transactions.push(new Transaction(123456789, 'TXID1234', 'null', 'contract', 'deploy', JSON.stringify(contractPayload)));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 123456789,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 123456789,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1859,29 +1865,29 @@ describe('Smart Contracts', function () {
|
|||
contractPayload.code = base64SmartContractCode;
|
||||
|
||||
transactions = [];
|
||||
transactions.push(new Transaction(123456790, 'TXID1235', 'steemsc', 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(123456790, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 123456790,
|
||||
refSteemBlockId: 'ABCD3',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 123456790,
|
||||
refHiveBlockId: 'ABCD3',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:01:00',
|
||||
transactions,
|
||||
};
|
||||
|
||||
await send(blockchain.PLUGIN_NAME, 'MASTER', { action: blockchain.PLUGIN_ACTIONS.PRODUCE_NEW_BLOCK_SYNC, payload: block });
|
||||
|
||||
const contract = await database.findContract({ name: 'testContract' });
|
||||
const contract = await database.findContract({ name: 'testcontract' });
|
||||
|
||||
assert.equal(contract.version, 2);
|
||||
assert.notEqual(contract.tables['testContract_testTable'], undefined);
|
||||
assert.notEqual(contract.tables['testContract_testUpdateTable'], undefined);
|
||||
assert.notEqual(contract.tables['testcontract_testTable'], undefined);
|
||||
assert.notEqual(contract.tables['testcontract_testUpdateTable'], undefined);
|
||||
|
||||
res = await database.getTableDetails({ contract: 'testContract', table: 'testTable' })
|
||||
res = await database.getTableDetails({ contract: 'testcontract', table: 'testTable' })
|
||||
|
||||
assert.notEqual(res, null);
|
||||
|
||||
res = await database.getTableDetails({ contract: 'testContract', table: 'testUpdateTable' })
|
||||
res = await database.getTableDetails({ contract: 'testcontract', table: 'testUpdateTable' })
|
||||
|
||||
assert.notEqual(res, null);
|
||||
|
1017
test/market.js
1017
test/market.js
File diff suppressed because it is too large
Load Diff
1711
test/nft.js
1711
test/nft.js
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -101,6 +101,7 @@ contractCode = contractCode.toString();
|
|||
|
||||
contractCode = contractCode.replace(/'\$\{CONSTANTS.UTILITY_TOKEN_PRECISION\}\$'/g, CONSTANTS.UTILITY_TOKEN_PRECISION);
|
||||
contractCode = contractCode.replace(/'\$\{CONSTANTS.UTILITY_TOKEN_SYMBOL\}\$'/g, CONSTANTS.UTILITY_TOKEN_SYMBOL);
|
||||
contractCode = contractCode.replace(/'\$\{CONSTANTS.HIVE_PEGGED_SYMBOL\}\$'/g, CONSTANTS.HIVE_PEGGED_SYMBOL);
|
||||
|
||||
let base64ContractCode = Base64.encode(contractCode);
|
||||
|
||||
|
@ -164,16 +165,16 @@ describe('smart tokens', function () {
|
|||
database1 = new Database();
|
||||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', 'steemsc', 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', 'steemsc', 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', 'harpagon', 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', 'harpagon', 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', 'harpagon', 'tokens', 'enableDelegation', '{ "symbol": "TKN", "undelegationCooldown": 7, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableDelegation', '{ "symbol": "TKN", "undelegationCooldown": 7, "isSignedWithActiveKey": true }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 12345678901,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678901,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -192,7 +193,7 @@ describe('smart tokens', function () {
|
|||
let token = res;
|
||||
|
||||
assert.equal(token.symbol, 'TKN');
|
||||
assert.equal(token.issuer, 'harpagon');
|
||||
assert.equal(token.issuer, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(token.stakingEnabled, true);
|
||||
assert.equal(token.unstakingCooldown, 7);
|
||||
assert.equal(token.delegationEnabled, true);
|
||||
|
@ -214,24 +215,24 @@ describe('smart tokens', function () {
|
|||
database1 = new Database();
|
||||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', 'steemsc', 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', 'steemsc', 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', 'harpagon', 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', 'harpagon', 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "NKT", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', 'harpagon', 'tokens', 'enableDelegation', '{ "symbol": "TKN", "undelegationCooldown": 7, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1239', 'harpagon', 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "NKT", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableDelegation', '{ "symbol": "TKN", "undelegationCooldown": 7, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1239', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1240', 'satoshi', 'tokens', 'enableDelegation', '{ "symbol": "TKN", "undelegationCooldown": 18250, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1245', 'steemsc', 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "satoshi", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1245', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "satoshi", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1246', 'satoshi', 'tokens', 'enableDelegation', '{ "symbol": "TKN", "undelegationCooldown": 18250, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1241', 'harpagon', 'tokens', 'enableDelegation', '{ "symbol": "TKN", "undelegationCooldown": 0, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1242', 'harpagon', 'tokens', 'enableDelegation', '{ "symbol": "TKN", "undelegationCooldown": 18251, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1243', 'harpagon', 'tokens', 'enableDelegation', '{ "symbol": "TKN", "undelegationCooldown": 7, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1244', 'harpagon', 'tokens', 'enableDelegation', '{ "symbol": "TKN", "undelegationCooldown": 7, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1241', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableDelegation', '{ "symbol": "TKN", "undelegationCooldown": 0, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1242', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableDelegation', '{ "symbol": "TKN", "undelegationCooldown": 18251, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1243', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableDelegation', '{ "symbol": "TKN", "undelegationCooldown": 7, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1244', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableDelegation', '{ "symbol": "TKN", "undelegationCooldown": 7, "isSignedWithActiveKey": true }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 12345678901,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678901,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -265,19 +266,19 @@ describe('smart tokens', function () {
|
|||
database1 = new Database();
|
||||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', 'steemsc', 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', 'steemsc', 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', 'harpagon', 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', 'harpagon', 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', 'harpagon', 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', 'harpagon', 'tokens', 'enableDelegation', '{ "symbol": "TKN", "undelegationCooldown": 7, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableDelegation', '{ "symbol": "TKN", "undelegationCooldown": 7, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1239', 'satoshi', 'tokens', 'stake', '{ "to":"satoshi", "to":"satoshi", "symbol": "TKN", "quantity": "0.00000001", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1240', 'satoshi', 'tokens', 'delegate', '{ "symbol": "TKN", "quantity": "0.00000001", "to": "vitalik", "isSignedWithActiveKey": true }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 12345678901,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678901,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -328,13 +329,13 @@ describe('smart tokens', function () {
|
|||
transactions = [];
|
||||
transactions.push(new Transaction(12345678902, 'TXID1241', 'satoshi', 'tokens', 'stake', '{ "to":"satoshi", "symbol": "TKN", "quantity": "0.00000003", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678902, 'TXID1242', 'satoshi', 'tokens', 'delegate', '{ "symbol": "TKN", "quantity": "0.00000002", "to": "vitalik", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678902, 'TXID1243', 'harpagon', 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "ned", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678902, 'TXID1243', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "ned", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678902, 'TXID1244', 'satoshi', 'tokens', 'delegate', '{ "symbol": "TKN", "quantity": "0.00000001", "to": "ned", "isSignedWithActiveKey": true }'));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 12345678902,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678902,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:01',
|
||||
transactions,
|
||||
};
|
||||
|
@ -410,25 +411,25 @@ describe('smart tokens', function () {
|
|||
database1 = new Database();
|
||||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', 'steemsc', 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', 'steemsc', 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', 'harpagon', 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', 'harpagon', 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', 'harpagon', 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', 'satoshi', 'tokens', 'delegate', '{ "symbol": "TKN", "quantity": "0.00000001", "to": "az", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1239', 'satoshi', 'tokens', 'delegate', '{ "symbol": "NKT", "quantity": "0.00000001", "to": "vitalik", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1240', 'satoshi', 'tokens', 'delegate', '{ "symbol": "TKN", "quantity": "0.000000001", "to": "vitalik", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1241', 'satoshi', 'tokens', 'delegate', '{ "symbol": "TKN", "quantity": "0.00000001", "to": "vitalik", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1242', 'harpagon', 'tokens', 'enableDelegation', '{ "symbol": "TKN", "undelegationCooldown": 7, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1242', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableDelegation', '{ "symbol": "TKN", "undelegationCooldown": 7, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1243', 'satoshi', 'tokens', 'delegate', '{ "symbol": "TKN", "quantity": "-0.00000001", "to": "vitalik", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1244', 'ned', 'tokens', 'delegate', '{ "symbol": "TKN", "quantity": "0.00000002", "to": "vitalik", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1245', 'satoshi', 'tokens', 'delegate', '{ "symbol": "TKN", "quantity": "0.00000002", "to": "vitalik", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1246', 'satoshi', 'tokens', 'delegate', '{ "symbol": "TKN", "quantity": "0.00000002", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 12345678901,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678901,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -482,20 +483,20 @@ describe('smart tokens', function () {
|
|||
database1 = new Database();
|
||||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', 'steemsc', 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', 'steemsc', 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', 'harpagon', 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', 'harpagon', 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', 'harpagon', 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', 'harpagon', 'tokens', 'enableDelegation', '{ "symbol": "TKN", "undelegationCooldown": 7, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableDelegation', '{ "symbol": "TKN", "undelegationCooldown": 7, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1239', 'satoshi', 'tokens', 'stake', '{ "to":"satoshi", "symbol": "TKN", "quantity": "0.00000003", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1240', 'satoshi', 'tokens', 'delegate', '{ "symbol": "TKN", "quantity": "0.00000002", "to": "vitalik", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1241', 'satoshi', 'tokens', 'delegate', '{ "symbol": "TKN", "quantity": "0.00000001", "to": "ned", "isSignedWithActiveKey": true }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 12345678901,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678901,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -560,9 +561,9 @@ describe('smart tokens', function () {
|
|||
transactions.push(new Transaction(12345678902, 'TXID1242', 'satoshi', 'tokens', 'undelegate', '{ "symbol": "TKN", "quantity": "0.00000001", "from": "vitalik", "isSignedWithActiveKey": true }'));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 12345678902,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678902,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:01',
|
||||
transactions,
|
||||
};
|
||||
|
@ -658,16 +659,16 @@ describe('smart tokens', function () {
|
|||
database1 = new Database();
|
||||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', 'steemsc', 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', 'steemsc', 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', 'harpagon', 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', 'harpagon', 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', 'harpagon', 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', 'satoshi', 'tokens', 'undelegate', '{ "symbol": "TKN", "quantity": "0.00000001", "from": "az", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1239', 'satoshi', 'tokens', 'undelegate', '{ "symbol": "NKT", "quantity": "0.00000001", "from": "vitalik", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1240', 'satoshi', 'tokens', 'undelegate', '{ "symbol": "TKN", "quantity": "0.000000001", "from": "vitalik", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1241', 'satoshi', 'tokens', 'undelegate', '{ "symbol": "TKN", "quantity": "0.00000001", "from": "vitalik", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1242', 'harpagon', 'tokens', 'enableDelegation', '{ "symbol": "TKN", "undelegationCooldown": 7, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1242', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableDelegation', '{ "symbol": "TKN", "undelegationCooldown": 7, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1243', 'satoshi', 'tokens', 'undelegate', '{ "symbol": "TKN", "quantity": "-0.00000001", "from": "vitalik", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1244', 'ned', 'tokens', 'undelegate', '{ "symbol": "TKN", "quantity": "0.00000002", "from": "vitalik", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1245', 'satoshi', 'tokens', 'undelegate', '{ "symbol": "TKN", "quantity": "0.00000002", "from": "vitalik", "isSignedWithActiveKey": true }'));
|
||||
|
@ -675,16 +676,16 @@ describe('smart tokens', function () {
|
|||
transactions.push(new Transaction(12345678901, 'TXID1247', 'satoshi', 'tokens', 'stake', '{ "to":"satoshi", "symbol": "TKN", "quantity": "0.00000004", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1248', 'satoshi', 'tokens', 'delegate', '{ "symbol": "TKN", "quantity": "0.00000001", "to": "ned", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1249', 'satoshi', 'tokens', 'undelegate', '{ "symbol": "TKN", "quantity": "0.00000001", "from": "vitalik", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1250', 'harpagon', 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "vitalik", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1250', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "vitalik", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1251', 'satoshi', 'tokens', 'undelegate', '{ "symbol": "TKN", "quantity": "0.00000001", "from": "vitalik", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1252', 'satoshi', 'tokens', 'delegate', '{ "symbol": "TKN", "quantity": "0.00000002", "to": "vitalik", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1253', 'satoshi', 'tokens', 'undelegate', '{ "symbol": "TKN", "quantity": "0.00000002", "from": "ned", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1254', 'satoshi', 'tokens', 'undelegate', '{ "symbol": "TKN", "quantity": "0.00000002", "from": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 12345678901,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678901,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -723,20 +724,20 @@ describe('smart tokens', function () {
|
|||
database1 = new Database();
|
||||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', 'steemsc', 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', 'steemsc', 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', 'harpagon', 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', 'harpagon', 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', 'harpagon', 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', 'harpagon', 'tokens', 'enableDelegation', '{ "symbol": "TKN", "undelegationCooldown": 7, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableDelegation', '{ "symbol": "TKN", "undelegationCooldown": 7, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1239', 'satoshi', 'tokens', 'stake', '{ "to":"satoshi", "symbol": "TKN", "quantity": "0.00000003", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1240', 'satoshi', 'tokens', 'delegate', '{ "symbol": "TKN", "quantity": "0.00000002", "to": "vitalik", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1241', 'satoshi', 'tokens', 'delegate', '{ "symbol": "TKN", "quantity": "0.00000001", "to": "ned", "isSignedWithActiveKey": true }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 12345678901,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678901,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -747,9 +748,9 @@ describe('smart tokens', function () {
|
|||
transactions.push(new Transaction(12345678901, 'TXID1242', 'satoshi', 'tokens', 'undelegate', '{ "symbol": "TKN", "quantity": "0.00000001", "from": "vitalik", "isSignedWithActiveKey": true }'));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 12345678902,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678902,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-02T00:00:01',
|
||||
transactions,
|
||||
};
|
||||
|
@ -761,9 +762,9 @@ describe('smart tokens', function () {
|
|||
transactions.push(new Transaction(12345678902, 'TXID123810', 'satoshi', 'whatever', 'whatever', ''));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 12345678903,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678903,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-09T00:00:01',
|
||||
transactions,
|
||||
};
|
||||
|
@ -830,15 +831,15 @@ describe('smart tokens', function () {
|
|||
database1 = new Database();
|
||||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', 'steemsc', 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', 'steemsc', 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', 'harpagon', 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', 'harpagon', 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 12345678901,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678901,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -856,7 +857,7 @@ describe('smart tokens', function () {
|
|||
let token = res;
|
||||
|
||||
assert.equal(token.symbol, 'TKN');
|
||||
assert.equal(token.issuer, 'harpagon');
|
||||
assert.equal(token.issuer, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(token.stakingEnabled, true);
|
||||
assert.equal(token.unstakingCooldown, 7);
|
||||
|
||||
|
@ -876,20 +877,20 @@ describe('smart tokens', function () {
|
|||
database1 = new Database();
|
||||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', 'steemsc', 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', 'steemsc', 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', 'harpagon', 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', 'harpagon', 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "NKT", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "NKT", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', 'satoshi', 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', 'steemsc', 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "satoshi", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "satoshi", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1239', 'satoshi', 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID12310', 'harpagon', 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 0, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID12311', 'harpagon', 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 18251, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID12310', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 0, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID12311', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 18251, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 12345678901,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678901,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -907,7 +908,7 @@ describe('smart tokens', function () {
|
|||
let token = res;
|
||||
|
||||
assert.equal(token.symbol, 'TKN');
|
||||
assert.equal(token.issuer, 'harpagon');
|
||||
assert.equal(token.issuer, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(token.stakingEnabled, false);
|
||||
assert.equal(token.unstakingCooldown, 1);
|
||||
|
||||
|
@ -936,16 +937,16 @@ describe('smart tokens', function () {
|
|||
database1 = new Database();
|
||||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', 'steemsc', 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', 'steemsc', 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', 'harpagon', 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', 'harpagon', 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', 'harpagon', 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 10, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 10, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 12345678901,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678901,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -963,7 +964,7 @@ describe('smart tokens', function () {
|
|||
let token = res;
|
||||
|
||||
assert.equal(token.symbol, 'TKN');
|
||||
assert.equal(token.issuer, 'harpagon');
|
||||
assert.equal(token.issuer, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(token.stakingEnabled, true);
|
||||
assert.equal(token.unstakingCooldown, 7);
|
||||
|
||||
|
@ -987,17 +988,17 @@ describe('smart tokens', function () {
|
|||
database1 = new Database();
|
||||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', 'steemsc', 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', 'steemsc', 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', 'harpagon', 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', 'harpagon', 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', 'harpagon', 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', 'satoshi', 'tokens', 'stake', '{ "to":"satoshi", "symbol": "TKN", "quantity": "0.00000001", "isSignedWithActiveKey": true }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 12345678901,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678901,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1025,9 +1026,9 @@ describe('smart tokens', function () {
|
|||
transactions.push(new Transaction(12345678902, 'TXID1240', 'satoshi', 'tokens', 'stake', '{ "to":"vitalik", "symbol": "TKN", "quantity": "0.00000001", "isSignedWithActiveKey": true }'));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 12345678902,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678902,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:01',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1102,21 +1103,21 @@ describe('smart tokens', function () {
|
|||
database1 = new Database();
|
||||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', 'steemsc', 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', 'steemsc', 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', 'harpagon', 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', 'harpagon', 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', 'satoshi', 'tokens', 'stake', '{ "to":"ez", "symbol": "TKN", "quantity": "0.00000001", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', 'satoshi', 'tokens', 'stake', '{ "to":"satoshi", "symbol": "TKN", "quantity": "0.00000001", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1239', 'harpagon', 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1239', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1240', 'satoshi', 'tokens', 'stake', '{ "to":"satoshi", "symbol": "TKN", "quantity": "-1", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1241', 'satoshi', 'tokens', 'stake', '{ "to":"satoshi", "symbol": "TKN", "quantity": "100.00000001", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1242', 'satoshi', 'tokens', 'stake', '{ "to":"satoshi", "symbol": "TKN", "quantity": "0.000000001", "isSignedWithActiveKey": true }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 12345678901,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678901,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1165,17 +1166,17 @@ describe('smart tokens', function () {
|
|||
database1 = new Database();
|
||||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', 'steemsc', 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', 'steemsc', 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', 'harpagon', 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', 'harpagon', 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', 'harpagon', 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', 'satoshi', 'tokens', 'stake', '{ "to":"satoshi", "symbol": "TKN", "quantity": "0.00000001", "isSignedWithActiveKey": true }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 12345678901,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678901,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1202,9 +1203,9 @@ describe('smart tokens', function () {
|
|||
transactions.push(new Transaction(12345678902, 'TXID1239', 'satoshi', 'tokens', 'unstake', '{ "symbol": "TKN", "quantity": "0.00000001", "isSignedWithActiveKey": true }'));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 12345678902,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678902,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-30T00:02:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1264,20 +1265,20 @@ describe('smart tokens', function () {
|
|||
database1 = new Database();
|
||||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', 'steemsc', 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', 'steemsc', 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', 'harpagon', 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', 'harpagon', 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', 'satoshi', 'tokens', 'unstake', '{ "symbol": "TKN", "quantity": "0.00000001", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', 'harpagon', 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1239', 'satoshi', 'tokens', 'unstake', '{ "symbol": "TKN", "quantity": "-1", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1240', 'satoshi', 'tokens', 'unstake', '{ "symbol": "TKN", "quantity": "0.00000001", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1241', 'satoshi', 'tokens', 'unstake', '{ "symbol": "TKN", "quantity": "0.000000001", "isSignedWithActiveKey": true }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 12345678901,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678901,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1325,17 +1326,17 @@ describe('smart tokens', function () {
|
|||
database1 = new Database();
|
||||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', 'steemsc', 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', 'steemsc', 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', 'harpagon', 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', 'harpagon', 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', 'harpagon', 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', 'satoshi', 'tokens', 'stake', '{ "to":"satoshi", "symbol": "TKN", "quantity": "0.00000001", "isSignedWithActiveKey": true }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 12345678901,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678901,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1362,9 +1363,9 @@ describe('smart tokens', function () {
|
|||
transactions.push(new Transaction(12345678902, 'TXID1239', 'satoshi', 'tokens', 'unstake', '{ "symbol": "TKN", "quantity": "0.00000001", "isSignedWithActiveKey": true }'));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 12345678902,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678902,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-30T00:02:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1411,9 +1412,9 @@ describe('smart tokens', function () {
|
|||
transactions.push(new Transaction(12345678903, 'TXID123910', 'satoshi', 'tokens', 'cancelUnstake', '{ "txID": "TXID1239", "isSignedWithActiveKey": true }'));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 12345678903,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678903,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-30T00:03:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1466,17 +1467,17 @@ describe('smart tokens', function () {
|
|||
database1 = new Database();
|
||||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', 'steemsc', 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', 'steemsc', 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', 'harpagon', 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', 'harpagon', 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', 'harpagon', 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', 'satoshi', 'tokens', 'stake', '{ "to":"satoshi", "symbol": "TKN", "quantity": "0.00000001", "isSignedWithActiveKey": true }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 12345678901,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678901,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1503,9 +1504,9 @@ describe('smart tokens', function () {
|
|||
transactions.push(new Transaction(12345678902, 'TXID1239', 'satoshi', 'tokens', 'unstake', '{ "symbol": "TKN", "quantity": "0.00000001", "isSignedWithActiveKey": true }'));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 12345678902,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678902,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-30T00:02:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1553,9 +1554,9 @@ describe('smart tokens', function () {
|
|||
transactions.push(new Transaction(12345678903, 'TXID123911', 'harpagon', 'tokens', 'cancelUnstake', '{ "txID": "TXID1239", "isSignedWithActiveKey": true }'));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 12345678903,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678903,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-30T00:03:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1613,17 +1614,17 @@ describe('smart tokens', function () {
|
|||
database1 = new Database();
|
||||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', 'steemsc', 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', 'steemsc', 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', 'harpagon', 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', 'harpagon', 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', 'harpagon', 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', 'satoshi', 'tokens', 'stake', '{ "to":"satoshi", "symbol": "TKN", "quantity": "0.00000001", "isSignedWithActiveKey": true }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 12345678901,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678901,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1662,9 +1663,9 @@ describe('smart tokens', function () {
|
|||
transactions.push(new Transaction(12345678902, 'TXID1239', 'satoshi', 'tokens', 'unstake', '{ "symbol": "TKN", "quantity": "0.00000001", "isSignedWithActiveKey": true }'));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 12345678902,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678902,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-30T00:02:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1712,9 +1713,9 @@ describe('smart tokens', function () {
|
|||
transactions.push(new Transaction(12345678903, 'TXID123810', 'satoshi', 'whatever', 'whatever', ''));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 12345678903,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678903,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-07-07T00:02:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1791,17 +1792,17 @@ describe('smart tokens', function () {
|
|||
database1 = new Database();
|
||||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', 'steemsc', 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', 'steemsc', 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', 'harpagon', 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', 'harpagon', 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', 'harpagon', 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 7, "numberTransactions": 1, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', 'satoshi', 'tokens', 'stake', '{ "to":"satoshi", "symbol": "TKN", "quantity": "0.00000001", "isSignedWithActiveKey": true }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 12345678901,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678901,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1828,9 +1829,9 @@ describe('smart tokens', function () {
|
|||
transactions.push(new Transaction(12345678902, 'TXID1239', 'satoshi', 'tokens', 'unstake', '{ "symbol": "TKN", "quantity": "0.00000001", "isSignedWithActiveKey": true }'));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 12345678902,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678902,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-30T00:02:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1878,9 +1879,9 @@ describe('smart tokens', function () {
|
|||
transactions.push(new Transaction(12345678903, 'TXID123810', 'satoshi', 'whatever', 'whatever', ''));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 12345678903,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678903,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-07-07T00:02:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1933,9 +1934,9 @@ describe('smart tokens', function () {
|
|||
transactions.push(new Transaction(12345678904, 'TXID223811', 'satoshi', 'tokens', 'stake', '{ "to":"satoshi", "symbol": "TKN", "quantity": "1", "isSignedWithActiveKey": true }'));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 12345678904,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678904,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-07-14T00:02:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1949,9 +1950,9 @@ describe('smart tokens', function () {
|
|||
transactions.push(new Transaction(12345678901 + index, `TXID${index}`, 'satoshi', 'tokens', 'unstake', '{ "symbol": "TKN", "quantity": "0.00000001", "isSignedWithActiveKey": true }'));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 12345678901 + index,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678901 + index,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-07-14T00:02:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1964,9 +1965,9 @@ describe('smart tokens', function () {
|
|||
console.log('done generating pending unstakes');
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 12345678905,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678905,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-07-14T00:02:01',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1995,9 +1996,9 @@ describe('smart tokens', function () {
|
|||
transactions.push(new Transaction(12345678906, 'TXID123899', 'satoshi', 'whatever', 'whatever', ''));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 12345678906,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678906,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-07-21T00:02:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -2038,17 +2039,17 @@ describe('smart tokens', function () {
|
|||
database1 = new Database();
|
||||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', 'steemsc', 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', 'steemsc', 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', 'harpagon', 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', 'harpagon', 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 3, "numberTransactions": 3, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', 'harpagon', 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1233', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(contractPayload)));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1234', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'transfer', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "to": "harpagon", "quantity": "1000", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1235', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'create', '{ "isSignedWithActiveKey": true, "name": "token", "symbol": "TKN", "precision": 8, "maxSupply": "1000", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1237', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'enableStaking', '{ "symbol": "TKN", "unstakingCooldown": 3, "numberTransactions": 3, "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'issue', '{ "symbol": "TKN", "quantity": "100", "to": "satoshi", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(12345678901, 'TXID1238', 'satoshi', 'tokens', 'stake', '{ "to":"satoshi", "symbol": "TKN", "quantity": "0.00000008", "isSignedWithActiveKey": true }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 12345678901,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678901,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -2075,9 +2076,9 @@ describe('smart tokens', function () {
|
|||
transactions.push(new Transaction(12345678902, 'TXID1239', 'satoshi', 'tokens', 'unstake', '{ "symbol": "TKN", "quantity": "0.00000006", "isSignedWithActiveKey": true }'));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 12345678902,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678902,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-07-01T00:02:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -2126,9 +2127,9 @@ describe('smart tokens', function () {
|
|||
transactions.push(new Transaction(12345678903, 'TXID123810', 'satoshi', 'whatever', 'whatever', ''));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 12345678903,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678903,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-07-02T00:02:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -2177,9 +2178,9 @@ describe('smart tokens', function () {
|
|||
transactions.push(new Transaction(12345678904, 'TXID123811', 'satoshi', 'whatever', 'whatever', ''));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 12345678904,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678904,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-07-03T00:02:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -2228,9 +2229,9 @@ describe('smart tokens', function () {
|
|||
transactions.push(new Transaction(12345678905, 'TXID123812', 'satoshi', 'whatever', 'whatever', ''));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 12345678905,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 12345678905,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-07-04T00:02:00',
|
||||
transactions,
|
||||
};
|
||||
|
|
|
@ -95,7 +95,7 @@ const unloadPlugin = (plugin) => {
|
|||
}
|
||||
|
||||
// sscstore
|
||||
describe('sscstore smart contract', function() {
|
||||
describe.skip('sscstore smart contract', function() {
|
||||
this.timeout(10000);
|
||||
|
||||
before((done) => {
|
||||
|
@ -149,12 +149,12 @@ describe('sscstore smart contract', function() {
|
|||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(30529000, 'TXID1236', 'Satoshi', 'sscstore', 'buy', '{ "recipient": "steemsc", "amountSTEEMSBD": "0.001 STEEM", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(30529000, 'TXID1236', 'satoshi', 'sscstore', 'buy', '{ "recipient": CONSTANTS.HIVE_ENGINE_ACCOUNT, "amountHIVEHBD": "0.001 HIVE", "isSignedWithActiveKey": true }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 30529000,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 30529000,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -165,14 +165,14 @@ describe('sscstore smart contract', function() {
|
|||
contract: 'tokens',
|
||||
table: 'balances',
|
||||
query: {
|
||||
account: 'Satoshi',
|
||||
account: 'satoshi',
|
||||
symbol: CONSTANTS.UTILITY_TOKEN_SYMBOL
|
||||
}
|
||||
});
|
||||
|
||||
const balanceSatoshi = res;
|
||||
const balancesatoshi = res;
|
||||
|
||||
assert.equal(balanceSatoshi.balance, CONSTANTS.SSC_STORE_QTY);
|
||||
assert.equal(balancesatoshi.balance, CONSTANTS.SSC_STORE_QTY);
|
||||
|
||||
resolve();
|
||||
})
|
||||
|
@ -191,12 +191,12 @@ describe('sscstore smart contract', function() {
|
|||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(30529000, 'TXID1236', 'Satoshi', 'sscstore', 'buy', '{ "recipient": "Satoshi", "amountSTEEMSBD": "0.001 STEEM", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(30529000, 'TXID1236', 'satoshi', 'sscstore', 'buy', '{ "recipient": "satoshi", "amountHIVEHBD": "0.001 HIVE", "isSignedWithActiveKey": true }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 30529000,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 30529000,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -207,23 +207,23 @@ describe('sscstore smart contract', function() {
|
|||
contract: 'tokens',
|
||||
table: 'balances',
|
||||
query: {
|
||||
account: 'Satoshi',
|
||||
account: 'satoshi',
|
||||
symbol: CONSTANTS.UTILITY_TOKEN_SYMBOL
|
||||
}
|
||||
});
|
||||
|
||||
let balanceSatoshi = res;
|
||||
let balancesatoshi = res;
|
||||
|
||||
assert.equal(balanceSatoshi, null);
|
||||
assert.equal(balancesatoshi, null);
|
||||
|
||||
transactions = [];
|
||||
transactions.push(new Transaction(30529000, 'TXID1237', 'steemsc', 'sscstore', 'updateParams', '{ "priceSBD": 0.001, "priceSteem": 0.001, "quantity": 1, "disabled": true }'));
|
||||
transactions.push(new Transaction(30529000, 'TXID1238', 'Satoshi', 'sscstore', 'buy', '{ "recipient": "steemsc", "amountSTEEMSBD": "0.001 STEEM", "isSignedWithActiveKey": true }'));
|
||||
transactions.push(new Transaction(30529001, 'TXID1237', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'sscstore', 'updateParams', '{ "priceHBD": 0.001, "priceHive": 0.001, "quantity": 1, "disabled": true }'));
|
||||
transactions.push(new Transaction(30529001, 'TXID1238', 'satoshi', 'sscstore', 'buy', '{ "recipient": CONSTANTS.HIVE_ENGINE_ACCOUNT, "amountHIVEHBD": "0.001 HIVE", "isSignedWithActiveKey": true }'));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 30529000,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 30529001,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -234,14 +234,14 @@ describe('sscstore smart contract', function() {
|
|||
contract: 'tokens',
|
||||
table: 'balances',
|
||||
query: {
|
||||
account: 'Satoshi',
|
||||
account: 'satoshi',
|
||||
symbol: CONSTANTS.UTILITY_TOKEN_SYMBOL
|
||||
}
|
||||
});
|
||||
|
||||
balanceSatoshi = res;
|
||||
balancesatoshi = res;
|
||||
|
||||
assert.equal(balanceSatoshi, null);
|
||||
assert.equal(balancesatoshi, null);
|
||||
|
||||
resolve();
|
||||
})
|
||||
|
@ -261,12 +261,12 @@ describe('sscstore smart contract', function() {
|
|||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(30529000, 'TXID1236', 'steemsc', 'sscstore', 'updateParams', '{ "priceSBD": 0.002, "priceSteem": 0.003, "quantity": 5, "disabled": true }'));
|
||||
transactions.push(new Transaction(30529000, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'sscstore', 'updateParams', '{ "priceHBD": 0.002, "priceHive": 0.003, "quantity": 5, "disabled": true }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 30529000,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 30529000,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -282,8 +282,8 @@ describe('sscstore smart contract', function() {
|
|||
|
||||
let params = res;
|
||||
|
||||
assert.equal(params.priceSBD, 0.002);
|
||||
assert.equal(params.priceSteem, 0.003);
|
||||
assert.equal(params.priceHBD, 0.002);
|
||||
assert.equal(params.priceHive, 0.003);
|
||||
assert.equal(params.quantity, 5);
|
||||
assert.equal(params.disabled, true);
|
||||
|
||||
|
@ -304,13 +304,13 @@ describe('sscstore smart contract', function() {
|
|||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(30529000, 'TXID1236', 'steemsc', 'sscstore', 'updateParams', '{ "priceSBD": 0.002, "priceSteem": 0.003, "quantity": 5, "disabled": true }'));
|
||||
transactions.push(new Transaction(30529000, 'TXID1237', 'Satoshi', 'sscstore', 'updateParams', '{ "priceSBD": 0.001, "priceSteem": 0.001, "quantity": 1000000, "disabled": false }'));
|
||||
transactions.push(new Transaction(3052900, 'TXID1236', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'sscstore', 'updateParams', '{ "priceHBD": 0.002, "priceHive": 0.003, "quantity": 5, "disabled": true }'));
|
||||
transactions.push(new Transaction(30529000, 'TXID1237', 'satoshi', 'sscstore', 'updateParams', '{ "priceHBD": 0.001, "priceHive": 0.001, "quantity": 1000000, "disabled": false }'));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 30529000,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 30529000,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -326,8 +326,8 @@ describe('sscstore smart contract', function() {
|
|||
|
||||
let params = res;
|
||||
|
||||
assert.equal(params.priceSBD, 0.002);
|
||||
assert.equal(params.priceSteem, 0.003);
|
||||
assert.equal(params.priceHBD, 0.002);
|
||||
assert.equal(params.priceHive, 0.003);
|
||||
assert.equal(params.quantity, 5);
|
||||
assert.equal(params.disabled, true);
|
||||
|
||||
|
|
562
test/tokens.js
562
test/tokens.js
File diff suppressed because it is too large
Load Diff
|
@ -122,6 +122,7 @@ contractCode = contractCode.toString();
|
|||
|
||||
contractCode = contractCode.replace(/'\$\{CONSTANTS.UTILITY_TOKEN_PRECISION\}\$'/g, CONSTANTS.UTILITY_TOKEN_PRECISION);
|
||||
contractCode = contractCode.replace(/'\$\{CONSTANTS.UTILITY_TOKEN_SYMBOL\}\$'/g, CONSTANTS.UTILITY_TOKEN_SYMBOL);
|
||||
contractCode = contractCode.replace(/'\$\{CONSTANTS.HIVE_PEGGED_SYMBOL\}\$'/g, CONSTANTS.HIVE_PEGGED_SYMBOL);
|
||||
|
||||
let base64ContractCode = Base64.encode(contractCode);
|
||||
|
||||
|
@ -144,9 +145,7 @@ let witnessesContractPayload = {
|
|||
code: base64ContractCode,
|
||||
};
|
||||
|
||||
console.log(base64ContractCode)
|
||||
|
||||
describe('witnesses', function () {
|
||||
describe.skip('witnesses', function () {
|
||||
this.timeout(60000);
|
||||
|
||||
before((done) => {
|
||||
|
@ -200,15 +199,15 @@ describe('witnesses', function () {
|
|||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(37899120, 'TXID1', 'steemsc', 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(37899120, 'TXID2', 'steemsc', 'contract', 'deploy', JSON.stringify(witnessesContractPayload)));
|
||||
transactions.push(new Transaction(37899120, 'TXID1', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(37899120, 'TXID2', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(witnessesContractPayload)));
|
||||
transactions.push(new Transaction(37899120, 'TXID3', 'dan', 'witnesses', 'register', `{ "IP": "123.255.123.254", "RPCPort": 5000, "P2PPort": 6000, "signingKey": "STM7sw22HqsXbz7D2CmJfmMwt9rimtk518dRzsR1f8Cgw52dQR1pR", "enabled": true, "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899120, 'TXID4', 'vitalik', 'witnesses', 'register', `{ "IP": "123.255.123.253", "RPCPort": 7000, "P2PPort": 8000, "signingKey": "STM8T4zKJuXgjLiKbp6fcsTTUtDY7afwc4XT9Xpf6uakYxwxfBabq", "enabled": false, "isSignedWithActiveKey": true }`));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 37899120,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 37899120,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -246,9 +245,9 @@ describe('witnesses', function () {
|
|||
transactions.push(new Transaction(37899121, 'TXID6', 'vitalik', 'witnesses', 'register', `{ "IP": "123.255.123.124", "RPCPort": 7000, "P2PPort": 8000, "signingKey": "STM8T4zKJuXgjLiKbp6fcsTTUtDY7afwc4XT9Xpf6uakYxwxfBabq", "enabled": true, "isSignedWithActiveKey": true }`));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 37899121,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 37899121,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -297,18 +296,18 @@ describe('witnesses', function () {
|
|||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(32713425, 'TXID1', 'steemsc', 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(32713425, 'TXID2', 'steemsc', 'contract', 'deploy', JSON.stringify(witnessesContractPayload)));
|
||||
transactions.push(new Transaction(32713425, 'TXID1', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(32713425, 'TXID2', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(witnessesContractPayload)));
|
||||
transactions.push(new Transaction(32713425, 'TXID3', 'dan', 'witnesses', 'register', `{ "IP": "123.234.123.234", "RPCPort": 5000, "P2PPort": 6000, "signingKey": "STM7sw22HqsXbz7D2CmJfmMwt9rimtk518dRzsR1f8Cgw52dQR1pR", "enabled": true, "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(32713425, 'TXID4', 'vitalik', 'witnesses', 'register', `{ "IP": "123.234.123.233", "RPCPort": 7000, "P2PPort": 8000, "signingKey": "STM8T4zKJuXgjLiKbp6fcsTTUtDY7afwc4XT9Xpf6uakYxwxfBabq", "enabled": false, "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(32713425, 'TXID5', 'harpagon', 'tokens', 'stake', `{ "to": "harpagon", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "100", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(32713425, 'TXID6', 'harpagon', 'witnesses', 'approve', `{ "witness": "dan", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(32713425, 'TXID7', 'harpagon', 'witnesses', 'approve', `{ "witness": "vitalik", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(32713425, 'TXID5', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'stake', `{ "to": "${CONSTANTS.HIVE_ENGINE_ACCOUNT}", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "100", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(32713425, 'TXID6', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'witnesses', 'approve', `{ "witness": "dan", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(32713425, 'TXID7', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'witnesses', 'approve', `{ "witness": "vitalik", "isSignedWithActiveKey": true }`));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 32713425,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 32713425,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -334,7 +333,7 @@ describe('witnesses', function () {
|
|||
contract: 'witnesses',
|
||||
table: 'accounts',
|
||||
query: {
|
||||
account: 'harpagon'
|
||||
account: CONSTANTS.HIVE_ENGINE_ACCOUNT
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -352,10 +351,10 @@ describe('witnesses', function () {
|
|||
|
||||
let approvals = res;
|
||||
|
||||
assert.equal(approvals[0].from, "harpagon");
|
||||
assert.equal(approvals[0].from, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(approvals[0].to, "dan");
|
||||
|
||||
assert.equal(approvals[1].from, "harpagon");
|
||||
assert.equal(approvals[1].from, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(approvals[1].to, "vitalik");
|
||||
|
||||
res = await database1.find({
|
||||
|
@ -372,15 +371,15 @@ describe('witnesses', function () {
|
|||
|
||||
transactions = [];
|
||||
transactions.push(new Transaction(32713426, 'TXID8', 'satoshi', 'witnesses', 'register', `{ "IP": "123.234.123.245", "RPCPort": 5000, "P2PPort": 6000, "signingKey": "STM7sw22HqsXbz7D2CmJfmMwt9rimtk518dRzsR1f8Cgw52dQR1pJ", "enabled": true, "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(32713426, 'TXID9', 'harpagon', 'tokens', 'stake', `{ "to": "ned", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "0.00000001", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(32713426, 'TXID10', 'harpagon', 'witnesses', 'approve', `{ "witness": "satoshi", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(32713426, 'TXID9', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'stake', `{ "to": "ned", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "0.00000001", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(32713426, 'TXID10', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'witnesses', 'approve', `{ "witness": "satoshi", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(32713426, 'TXID11', 'ned', 'witnesses', 'approve', `{ "witness": "dan", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(32713426, 'TXID12', 'ned', 'witnesses', 'approve', `{ "witness": "satoshi", "isSignedWithActiveKey": true }`));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 37899120,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 37899120,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -414,7 +413,7 @@ describe('witnesses', function () {
|
|||
|
||||
let accounts = res;
|
||||
|
||||
assert.equal(accounts[0].account, "harpagon");
|
||||
assert.equal(accounts[0].account, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(accounts[0].approvals, 3);
|
||||
assert.equal(accounts[0].approvalWeight, "100.00000000");
|
||||
|
||||
|
@ -431,13 +430,13 @@ describe('witnesses', function () {
|
|||
|
||||
approvals = res;
|
||||
|
||||
assert.equal(approvals[0].from, "harpagon");
|
||||
assert.equal(approvals[0].from, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(approvals[0].to, "dan");
|
||||
|
||||
assert.equal(approvals[1].from, "harpagon");
|
||||
assert.equal(approvals[1].from, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(approvals[1].to, "vitalik");
|
||||
|
||||
assert.equal(approvals[2].from, "harpagon");
|
||||
assert.equal(approvals[2].from, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(approvals[2].to, "satoshi");
|
||||
|
||||
assert.equal(approvals[3].from, "ned");
|
||||
|
@ -475,23 +474,23 @@ describe('witnesses', function () {
|
|||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(37899121, 'TXID1', 'steemsc', 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(37899121, 'TXID2', 'steemsc', 'contract', 'deploy', JSON.stringify(witnessesContractPayload)));
|
||||
transactions.push(new Transaction(37899121, 'TXID1', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(37899121, 'TXID2', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(witnessesContractPayload)));
|
||||
transactions.push(new Transaction(37899121, 'TXID3', 'dan', 'witnesses', 'register', `{ "IP": "123.234.123.233", "RPCPort": 5000, "P2PPort": 6000, "signingKey": "STM7sw22HqsXbz7D2CmJfmMwt9rimtk518dRzsR1f8Cgw52dQR1pR", "enabled": true, "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899121, 'TXID4', 'vitalik', 'witnesses', 'register', `{ "IP": "123.234.123.232", "RPCPort": 7000, "P2PPort": 8000, "signingKey": "STM8T4zKJuXgjLiKbp6fcsTTUtDY7afwc4XT9Xpf6uakYxwxfBabq", "enabled": false, "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899121, 'TXID5', 'harpagon', 'tokens', 'stake', `{ "to": "harpagon", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "100", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899121, 'TXID6', 'harpagon', 'witnesses', 'approve', `{ "witness": "dan", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899121, 'TXID7', 'harpagon', 'witnesses', 'approve', `{ "witness": "vitalik", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899121, 'TXID5', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'stake', `{ "to": "${CONSTANTS.HIVE_ENGINE_ACCOUNT}", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "100", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899121, 'TXID6', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'witnesses', 'approve', `{ "witness": "dan", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899121, 'TXID7', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'witnesses', 'approve', `{ "witness": "vitalik", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899121, 'TXID8', 'satoshi', 'witnesses', 'register', `{ "IP": "123.234.123.231", "RPCPort": 5000, "P2PPort": 6000, "signingKey": "STM7sw22HqsXbz7D2CmJfmMwt9rimtk518dRzsR1f8Cgw52dQR1pJ", "enabled": true, "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899121, 'TXID9', 'harpagon', 'tokens', 'stake', `{ "to": "ned", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "0.00000001", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899121, 'TXID10', 'harpagon', 'witnesses', 'approve', `{ "witness": "satoshi", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899121, 'TXID9', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'stake', `{ "to": "ned", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "0.00000001", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899121, 'TXID10', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'witnesses', 'approve', `{ "witness": "satoshi", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899121, 'TXID11', 'ned', 'witnesses', 'approve', `{ "witness": "dan", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899121, 'TXID12', 'ned', 'witnesses', 'approve', `{ "witness": "satoshi", "isSignedWithActiveKey": true }`));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 37899121,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 37899121,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -502,9 +501,9 @@ describe('witnesses', function () {
|
|||
transactions.push(new Transaction(37899122, 'TXID13', 'ned', 'witnesses', 'disapprove', `{ "witness": "satoshi", "isSignedWithActiveKey": true }`));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 37899122,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 37899122,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -538,7 +537,7 @@ describe('witnesses', function () {
|
|||
|
||||
let accounts = res;
|
||||
|
||||
assert.equal(accounts[0].account, "harpagon");
|
||||
assert.equal(accounts[0].account, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(accounts[0].approvals, 3);
|
||||
assert.equal(accounts[0].approvalWeight, "100.00000000");
|
||||
|
||||
|
@ -556,7 +555,7 @@ describe('witnesses', function () {
|
|||
|
||||
approvals = res;
|
||||
|
||||
assert.equal(approvals[0].from, "harpagon");
|
||||
assert.equal(approvals[0].from, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(approvals[0].to, "satoshi");
|
||||
assert.equal(approvals.length, 1);
|
||||
|
||||
|
@ -573,12 +572,12 @@ describe('witnesses', function () {
|
|||
assert.equal(params[0].totalApprovalWeight, "300.00000001");
|
||||
|
||||
transactions = [];
|
||||
transactions.push(new Transaction(37899123, 'TXID14', 'harpagon', 'witnesses', 'disapprove', `{ "witness": "satoshi", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899123, 'TXID14', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'witnesses', 'disapprove', `{ "witness": "satoshi", "isSignedWithActiveKey": true }`));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 37899123,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 37899123,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -612,7 +611,7 @@ describe('witnesses', function () {
|
|||
|
||||
accounts = res;
|
||||
|
||||
assert.equal(accounts[0].account, "harpagon");
|
||||
assert.equal(accounts[0].account, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(accounts[0].approvals, 2);
|
||||
assert.equal(accounts[0].approvalWeight, "100.00000000");
|
||||
|
||||
|
@ -661,19 +660,19 @@ describe('witnesses', function () {
|
|||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(37899123, 'TXID1', 'steemsc', 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(37899123, 'TXID2', 'steemsc', 'contract', 'deploy', JSON.stringify(witnessesContractPayload)));
|
||||
transactions.push(new Transaction(37899123, 'TXID1', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(37899123, 'TXID2', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(witnessesContractPayload)));
|
||||
transactions.push(new Transaction(37899123, 'TXID3', 'dan', 'witnesses', 'register', `{ "IP": "123.234.123.233", "RPCPort": 5000, "P2PPort": 6000, "signingKey": "STM7sw22HqsXbz7D2CmJfmMwt9rimtk518dRzsR1f8Cgw52dQR1pR", "enabled": true, "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899123, 'TXID4', 'vitalik', 'witnesses', 'register', `{ "IP": "123.234.123.234", "RPCPort": 7000, "P2PPort": 8000, "signingKey": "STM8T4zKJuXgjLiKbp6fcsTTUtDY7afwc4XT9Xpf6uakYxwxfBabq", "enabled": false, "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899123, 'TXID5', 'harpagon', 'tokens', 'stake', `{ "to": "harpagon", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "100", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899123, 'TXID6', 'harpagon', 'witnesses', 'approve', `{ "witness": "dan", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899123, 'TXID7', 'harpagon', 'witnesses', 'approve', `{ "witness": "vitalik", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899123, 'TXID8', 'harpagon', 'tokens', 'stake', `{ "to": "harpagon", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "0.00000001", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899123, 'TXID5', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'stake', `{ "to": "${CONSTANTS.HIVE_ENGINE_ACCOUNT}", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "100", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899123, 'TXID6', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'witnesses', 'approve', `{ "witness": "dan", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899123, 'TXID7', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'witnesses', 'approve', `{ "witness": "vitalik", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899123, 'TXID8', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'stake', `{ "to": "${CONSTANTS.HIVE_ENGINE_ACCOUNT}", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "0.00000001", "isSignedWithActiveKey": true }`));
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 37899123,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 37899123,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -698,7 +697,7 @@ describe('witnesses', function () {
|
|||
contract: 'witnesses',
|
||||
table: 'accounts',
|
||||
query: {
|
||||
account: 'harpagon'
|
||||
account: CONSTANTS.HIVE_ENGINE_ACCOUNT
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -716,10 +715,10 @@ describe('witnesses', function () {
|
|||
|
||||
let approvals = res;
|
||||
|
||||
assert.equal(approvals[0].from, "harpagon");
|
||||
assert.equal(approvals[0].from, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(approvals[0].to, "dan");
|
||||
|
||||
assert.equal(approvals[1].from, "harpagon");
|
||||
assert.equal(approvals[1].from, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(approvals[1].to, "vitalik");
|
||||
|
||||
res = await database1.find({
|
||||
|
@ -735,14 +734,14 @@ describe('witnesses', function () {
|
|||
assert.equal(params[0].totalApprovalWeight, "200.00000002");
|
||||
|
||||
transactions = [];
|
||||
transactions.push(new Transaction(37899124, 'TXID9', 'harpagon', 'tokens', 'stake', `{ "to": "ned", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "1", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899124, 'TXID9', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'stake', `{ "to": "ned", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "1", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899124, 'TXID10', 'ned', 'witnesses', 'approve', `{ "witness": "dan", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899124, 'TXID11', 'harpagon', 'tokens', 'delegate', `{ "to": "ned", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "2", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899124, 'TXID11', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'delegate', `{ "to": "ned", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "2", "isSignedWithActiveKey": true }`));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 37899124,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 37899124,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -773,7 +772,7 @@ describe('witnesses', function () {
|
|||
|
||||
let accounts = res;
|
||||
|
||||
assert.equal(accounts[0].account, "harpagon");
|
||||
assert.equal(accounts[0].account, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(accounts[0].approvals, 2);
|
||||
assert.equal(accounts[0].approvalWeight, "98.00000001");
|
||||
|
||||
|
@ -790,10 +789,10 @@ describe('witnesses', function () {
|
|||
|
||||
approvals = res;
|
||||
|
||||
assert.equal(approvals[0].from, "harpagon");
|
||||
assert.equal(approvals[0].from, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(approvals[0].to, "dan");
|
||||
|
||||
assert.equal(approvals[1].from, "harpagon");
|
||||
assert.equal(approvals[1].from, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(approvals[1].to, "vitalik");
|
||||
|
||||
assert.equal(approvals[2].from, "ned");
|
||||
|
@ -812,12 +811,12 @@ describe('witnesses', function () {
|
|||
assert.equal(params[0].totalApprovalWeight, "199.00000002");
|
||||
|
||||
transactions = [];
|
||||
transactions.push(new Transaction(37899125, 'TXID12', 'harpagon', 'tokens', 'undelegate', `{ "from": "ned", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "2", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899125, 'TXID12', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'undelegate', `{ "from": "ned", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "2", "isSignedWithActiveKey": true }`));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 37899125,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 37899125,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -855,7 +854,7 @@ describe('witnesses', function () {
|
|||
|
||||
accounts = res;
|
||||
|
||||
assert.equal(accounts[0].account, "harpagon");
|
||||
assert.equal(accounts[0].account, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(accounts[0].approvals, 2);
|
||||
assert.equal(accounts[0].approvalWeight, "98.00000001");
|
||||
|
||||
|
@ -872,10 +871,10 @@ describe('witnesses', function () {
|
|||
|
||||
approvals = res;
|
||||
|
||||
assert.equal(approvals[0].from, "harpagon");
|
||||
assert.equal(approvals[0].from, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(approvals[0].to, "dan");
|
||||
|
||||
assert.equal(approvals[1].from, "harpagon");
|
||||
assert.equal(approvals[1].from, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(approvals[1].to, "vitalik");
|
||||
|
||||
assert.equal(approvals[2].from, "ned");
|
||||
|
@ -897,9 +896,9 @@ describe('witnesses', function () {
|
|||
transactions.push(new Transaction(37899126, 'TXID13', 'harpagon', 'whatever', 'whatever', ''));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 37899126,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 37899126,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-08-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -930,7 +929,7 @@ describe('witnesses', function () {
|
|||
|
||||
accounts = res;
|
||||
|
||||
assert.equal(accounts[0].account, "harpagon");
|
||||
assert.equal(accounts[0].account, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(accounts[0].approvals, 2);
|
||||
assert.equal(accounts[0].approvalWeight, "100.00000001");
|
||||
|
||||
|
@ -947,10 +946,10 @@ describe('witnesses', function () {
|
|||
|
||||
approvals = res;
|
||||
|
||||
assert.equal(approvals[0].from, "harpagon");
|
||||
assert.equal(approvals[0].from, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(approvals[0].to, "dan");
|
||||
|
||||
assert.equal(approvals[1].from, "harpagon");
|
||||
assert.equal(approvals[1].from, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(approvals[1].to, "vitalik");
|
||||
|
||||
assert.equal(approvals[2].from, "ned");
|
||||
|
@ -972,9 +971,9 @@ describe('witnesses', function () {
|
|||
transactions.push(new Transaction(37899127, 'TXID14', 'ned', 'tokens', 'unstake', `{ "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "1", "isSignedWithActiveKey": true }`));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 37899127,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 37899127,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-08-02T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1005,7 +1004,7 @@ describe('witnesses', function () {
|
|||
|
||||
accounts = res;
|
||||
|
||||
assert.equal(accounts[0].account, "harpagon");
|
||||
assert.equal(accounts[0].account, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(accounts[0].approvals, 2);
|
||||
assert.equal(accounts[0].approvalWeight, "100.00000001");
|
||||
|
||||
|
@ -1022,10 +1021,10 @@ describe('witnesses', function () {
|
|||
|
||||
approvals = res;
|
||||
|
||||
assert.equal(approvals[0].from, "harpagon");
|
||||
assert.equal(approvals[0].from, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(approvals[0].to, "dan");
|
||||
|
||||
assert.equal(approvals[1].from, "harpagon");
|
||||
assert.equal(approvals[1].from, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(approvals[1].to, "vitalik");
|
||||
|
||||
assert.equal(approvals[2].from, "ned");
|
||||
|
@ -1047,9 +1046,9 @@ describe('witnesses', function () {
|
|||
transactions.push(new Transaction(37899128, 'TXID15', 'harpagon', 'whatever', 'whatever', ''));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 37899128,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 37899128,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-10-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1080,7 +1079,7 @@ describe('witnesses', function () {
|
|||
|
||||
accounts = res;
|
||||
|
||||
assert.equal(accounts[0].account, "harpagon");
|
||||
assert.equal(accounts[0].account, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(accounts[0].approvals, 2);
|
||||
assert.equal(accounts[0].approvalWeight, "100.00000001");
|
||||
|
||||
|
@ -1097,10 +1096,10 @@ describe('witnesses', function () {
|
|||
|
||||
approvals = res;
|
||||
|
||||
assert.equal(approvals[0].from, "harpagon");
|
||||
assert.equal(approvals[0].from, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(approvals[0].to, "dan");
|
||||
|
||||
assert.equal(approvals[1].from, "harpagon");
|
||||
assert.equal(approvals[1].from, CONSTANTS.HIVE_ENGINE_ACCOUNT);
|
||||
assert.equal(approvals[1].to, "vitalik");
|
||||
|
||||
assert.equal(approvals[2].from, "ned");
|
||||
|
@ -1135,9 +1134,9 @@ describe('witnesses', function () {
|
|||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
let txId = 100;
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(37899128, 'TXID1', 'steemsc', 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(37899128, 'TXID2', 'steemsc', 'contract', 'deploy', JSON.stringify(witnessesContractPayload)));
|
||||
transactions.push(new Transaction(37899128, 'TXID3', 'harpagon', 'tokens', 'stake', `{ "to": "harpagon", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "100", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899128, 'TXID1', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(37899128, 'TXID2', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(witnessesContractPayload)));
|
||||
transactions.push(new Transaction(37899128, 'TXID3', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'stake', `{ "to": "${CONSTANTS.HIVE_ENGINE_ACCOUNT}", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "100", "isSignedWithActiveKey": true }`));
|
||||
|
||||
// register 100 witnesses
|
||||
for (let index = 0; index < 100; index++) {
|
||||
|
@ -1148,9 +1147,9 @@ describe('witnesses', function () {
|
|||
}
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 37899128,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 37899128,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1160,13 +1159,13 @@ describe('witnesses', function () {
|
|||
transactions = [];
|
||||
for (let index = 0; index < 30; index++) {
|
||||
txId++;
|
||||
transactions.push(new Transaction(37899129, `TXID${txId}`, 'harpagon', 'witnesses', 'approve', `{ "witness": "witness${index + 5}", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899129, `TXID${txId}`, CONSTANTS.HIVE_ENGINE_ACCOUNT, 'witnesses', 'approve', `{ "witness": "witness${index + 5}", "isSignedWithActiveKey": true }`));
|
||||
}
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 37899129,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 37899129,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1266,9 +1265,9 @@ describe('witnesses', function () {
|
|||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
let txId = 100;
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(37899120, 'TXID1', 'steemsc', 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(37899120, 'TXID2', 'steemsc', 'contract', 'deploy', JSON.stringify(witnessesContractPayload)));
|
||||
transactions.push(new Transaction(37899120, 'TXID3', 'harpagon', 'tokens', 'stake', `{ "to": "harpagon", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "100", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899120, 'TXID1', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(37899120, 'TXID2', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(witnessesContractPayload)));
|
||||
transactions.push(new Transaction(37899120, 'TXID3', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'stake', `{ "to": "${CONSTANTS.HIVE_ENGINE_ACCOUNT}", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "100", "isSignedWithActiveKey": true }`));
|
||||
|
||||
// register 100 witnesses
|
||||
for (let index = 0; index < 100; index++) {
|
||||
|
@ -1279,9 +1278,9 @@ describe('witnesses', function () {
|
|||
}
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 37899120,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 37899120,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1291,13 +1290,13 @@ describe('witnesses', function () {
|
|||
transactions = [];
|
||||
for (let index = 0; index < 30; index++) {
|
||||
txId++;
|
||||
transactions.push(new Transaction(37899121, `TXID${txId}`, 'harpagon', 'witnesses', 'approve', `{ "witness": "witness${index + 5}", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899121, `TXID${txId}`, CONSTANTS.HIVE_ENGINE_ACCOUNT, 'witnesses', 'approve', `{ "witness": "witness${index + 5}", "isSignedWithActiveKey": true }`));
|
||||
}
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 37899121,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 37899121,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1310,9 +1309,9 @@ describe('witnesses', function () {
|
|||
// send whatever transaction;
|
||||
transactions.push(new Transaction(37899122 + i, `TXID${txId}`, 'satoshi', 'whatever', 'whatever', ''));
|
||||
block = {
|
||||
refSteemBlockNumber: 37899122 + i,
|
||||
refSteemBlockId: `ABCD123${i}`,
|
||||
prevRefSteemBlockId: `ABCD123${i - 1}`,
|
||||
refHiveBlockNumber: 37899122 + i,
|
||||
refHiveBlockId: `ABCD123${i}`,
|
||||
prevRefHiveBlockId: `ABCD123${i - 1}`,
|
||||
timestamp: `2018-06-01T00:00:0${i}`,
|
||||
transactions,
|
||||
};
|
||||
|
@ -1375,9 +1374,9 @@ describe('witnesses', function () {
|
|||
transactions.push(new Transaction(38899122, `TXID${txId}`, params.currentWitness, 'witnesses', 'proposeRound', JSON.stringify(json)));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 38899122,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 38899122,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1421,9 +1420,9 @@ describe('witnesses', function () {
|
|||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
let txId = 100;
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(37899120, 'TXID1', 'steemsc', 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(37899120, 'TXID2', 'steemsc', 'contract', 'deploy', JSON.stringify(witnessesContractPayload)));
|
||||
transactions.push(new Transaction(37899120, 'TXID3', 'harpagon', 'tokens', 'stake', `{ "to": "harpagon", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "100", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899120, 'TXID1', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(37899120, 'TXID2', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(witnessesContractPayload)));
|
||||
transactions.push(new Transaction(37899120, 'TXID3', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'stake', `{ "to": "${CONSTANTS.HIVE_ENGINE_ACCOUNT}", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "100", "isSignedWithActiveKey": true }`));
|
||||
|
||||
// register 100 witnesses
|
||||
for (let index = 0; index < 100; index++) {
|
||||
|
@ -1434,9 +1433,9 @@ describe('witnesses', function () {
|
|||
}
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 37899120,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 37899120,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1446,13 +1445,13 @@ describe('witnesses', function () {
|
|||
transactions = [];
|
||||
for (let index = 0; index < 30; index++) {
|
||||
txId++;
|
||||
transactions.push(new Transaction(37899121, `TXID${txId}`, 'harpagon', 'witnesses', 'approve', `{ "witness": "witness${index + 5}", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899121, `TXID${txId}`, CONSTANTS.HIVE_ENGINE_ACCOUNT, 'witnesses', 'approve', `{ "witness": "witness${index + 5}", "isSignedWithActiveKey": true }`));
|
||||
}
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 37899121,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 37899121,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1465,9 +1464,9 @@ describe('witnesses', function () {
|
|||
// send whatever transaction;
|
||||
transactions.push(new Transaction(37899122 +i, `TXID${txId}`, 'satoshi', 'whatever', 'whatever', ''));
|
||||
block = {
|
||||
refSteemBlockNumber: 37899122 + i,
|
||||
refSteemBlockId: `ABCD123${i}`,
|
||||
prevRefSteemBlockId: `ABCD123${i - 1}`,
|
||||
refHiveBlockNumber: 37899122 + i,
|
||||
refHiveBlockId: `ABCD123${i}`,
|
||||
prevRefHiveBlockId: `ABCD123${i - 1}`,
|
||||
timestamp: `2018-06-01T00:00:0${i}`,
|
||||
transactions,
|
||||
};
|
||||
|
@ -1530,9 +1529,9 @@ describe('witnesses', function () {
|
|||
transactions.push(new Transaction(38899122, `TXID${txId}`, params.currentWitness, 'witnesses', 'proposeRound', JSON.stringify(json)));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 38899122,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 38899122,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1632,9 +1631,9 @@ describe('witnesses', function () {
|
|||
await database1.init(conf.databaseURL, conf.databaseName);
|
||||
let txId = 100;
|
||||
let transactions = [];
|
||||
transactions.push(new Transaction(37899120, 'TXID1', 'steemsc', 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(37899120, 'TXID2', 'steemsc', 'contract', 'deploy', JSON.stringify(witnessesContractPayload)));
|
||||
transactions.push(new Transaction(37899120, 'TXID3', 'harpagon', 'tokens', 'stake', `{ "to": "harpagon", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "100", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899120, 'TXID1', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'update', JSON.stringify(tknContractPayload)));
|
||||
transactions.push(new Transaction(37899120, 'TXID2', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'contract', 'deploy', JSON.stringify(witnessesContractPayload)));
|
||||
transactions.push(new Transaction(37899120, 'TXID3', CONSTANTS.HIVE_ENGINE_ACCOUNT, 'tokens', 'stake', `{ "to": "${CONSTANTS.HIVE_ENGINE_ACCOUNT}", "symbol": "${CONSTANTS.UTILITY_TOKEN_SYMBOL}", "quantity": "100", "isSignedWithActiveKey": true }`));
|
||||
|
||||
// register 100 witnesses
|
||||
for (let index = 0; index < 100; index++) {
|
||||
|
@ -1645,9 +1644,9 @@ describe('witnesses', function () {
|
|||
}
|
||||
|
||||
let block = {
|
||||
refSteemBlockNumber: 37899120,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 37899120,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1657,13 +1656,13 @@ describe('witnesses', function () {
|
|||
transactions = [];
|
||||
for (let index = 0; index < 30; index++) {
|
||||
txId++;
|
||||
transactions.push(new Transaction(37899121, `TXID${txId}`, 'harpagon', 'witnesses', 'approve', `{ "witness": "witness${index + 5}", "isSignedWithActiveKey": true }`));
|
||||
transactions.push(new Transaction(37899121, `TXID${txId}`, CONSTANTS.HIVE_ENGINE_ACCOUNT, 'witnesses', 'approve', `{ "witness": "witness${index + 5}", "isSignedWithActiveKey": true }`));
|
||||
}
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 37899121,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 37899121,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-06-01T00:00:00',
|
||||
transactions,
|
||||
};
|
||||
|
@ -1704,9 +1703,9 @@ describe('witnesses', function () {
|
|||
transactions.push(new Transaction(38899121 + index, `TXID${index}`, 'satoshi', 'whatever', 'whatever', ''));
|
||||
|
||||
block = {
|
||||
refSteemBlockNumber: 38899121 + index,
|
||||
refSteemBlockId: 'ABCD1',
|
||||
prevRefSteemBlockId: 'ABCD2',
|
||||
refHiveBlockNumber: 38899121 + index,
|
||||
refHiveBlockId: 'ABCD1',
|
||||
prevRefHiveBlockId: 'ABCD2',
|
||||
timestamp: '2018-07-14T00:02:00',
|
||||
transactions,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue