From bc93b0f99b2f22aca7c98c9c2358fb7f78071a89 Mon Sep 17 00:00:00 2001 From: georgi-l95 Date: Fri, 28 Oct 2022 18:01:55 +0300 Subject: [PATCH] Release 2.1.3 (#211) * Add smoke tests for each network Signed-off-by: nikolay * Edit ci Signed-off-by: nikolay * Bump versions Signed-off-by: nikolay * Edit ci Signed-off-by: nikolay * Edit ci Signed-off-by: nikolay * Fix local node occasionally fails to start (#203) * wait before generating accounts Signed-off-by: georgi-l95 * bump sdk version Signed-off-by: georgi-l95 * bump sdk version Signed-off-by: georgi-l95 * test Signed-off-by: georgi-l95 * check if network node is started Signed-off-by: georgi-l95 Signed-off-by: georgi-l95 * Add environment readiness test flow (#188) Add environment readiness test flow Signed-off-by: georgi-l95 * Add feature flag for atomicCryptoTransfer (#210) Signed-off-by: nikolay Signed-off-by: nikolay * bump version 2.1.3 Signed-off-by: georgi-l95 Signed-off-by: nikolay Signed-off-by: georgi-l95 Co-authored-by: nikolay --- configs/local.json | 9 +- package-lock.json | 18 ++- package.json | 10 +- src/utils/testNode.js | 124 ++++++++++++++++++ templates/local/bootstrap.template.properties | 1 + 5 files changed, 153 insertions(+), 9 deletions(-) create mode 100644 src/utils/testNode.js diff --git a/configs/local.json b/configs/local.json index 5b4a1dd0..ad669e71 100644 --- a/configs/local.json +++ b/configs/local.json @@ -7,11 +7,11 @@ "maxSizeKb": 2048, "streamExtension": "rcd.gz", "sidecarEnabled": true, - "nodeImageTag": "0.31.0", - "havegedImageTag": "0.31.0", + "nodeImageTag": "0.32.0-alpha.1", + "havegedImageTag": "0.32.0-alpha.1", "uploaderImageTag": "0.7.0", "mirrorImageTag": "0.67.0-rc1", - "relayImageTag": "0.9.0", + "relayImageTag": "0.10.0", "mirrorNodeExplorerImageTag": "latest", "timeout": "180s", "pythonVersion": "python3.7", @@ -30,6 +30,7 @@ "signatureFileVersion": 6, "enableTraceabilityMigration": true, "compressFilesOnCreation": true, - "sidecars": "CONTRACT_STATE_CHANGE,CONTRACT_BYTECODE" + "sidecars": "CONTRACT_STATE_CHANGE,CONTRACT_BYTECODE", + "atomicCryptoTransfer": true } } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 41fc96e8..1ede8015 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@hashgraph/hedera-local", - "version": "2.1.2", + "version": "2.1.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@hashgraph/hedera-local", - "version": "2.1.2", + "version": "2.1.3", "license": "Apache-2.0", "dependencies": { "@hashgraph/hethers": "^1.1.2", @@ -14,6 +14,7 @@ "blessed": "^0.1.81", "blessed-contrib": "^4.11.0", "dockerode": "^3.3.4", + "dotenv": "^16.0.3", "ethers": "^5.6.9", "js-yaml": "^4.1.0", "mustache": "^4.2.0", @@ -8703,6 +8704,14 @@ "node": ">= 8.0" } }, + "node_modules/dotenv": { + "version": "16.0.3", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", + "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==", + "engines": { + "node": ">=12" + } + }, "node_modules/drawille-blessed-contrib": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/drawille-blessed-contrib/-/drawille-blessed-contrib-1.0.0.tgz", @@ -20890,6 +20899,11 @@ "tar-fs": "~2.0.1" } }, + "dotenv": { + "version": "16.0.3", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", + "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==" + }, "drawille-blessed-contrib": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/drawille-blessed-contrib/-/drawille-blessed-contrib-1.0.0.tgz", diff --git a/package.json b/package.json index 305f16a2..a74d5443 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hashgraph/hedera-local", - "version": "2.1.2", + "version": "2.1.3", "description": "Developer tooling for running Local Hedera Network (Consensus + Mirror Nodes).", "homepage": "https://github.com/hashgraph/hedera-local-node", "repository": "github.com:hashgraph/hedera-local-node", @@ -13,18 +13,22 @@ "bin": { "hedera": "./cli.js" }, + "scripts": { + "test:readiness": "node src/utils/testNode.js" + }, "dependencies": { "@hashgraph/hethers": "^1.1.2", "@hashgraph/sdk": "2.18.5", "blessed": "^0.1.81", "blessed-contrib": "^4.11.0", "dockerode": "^3.3.4", + "dotenv": "^16.0.3", "ethers": "^5.6.9", "js-yaml": "^4.1.0", + "mustache": "^4.2.0", "rimraf": "^3.0.2", "shelljs": "^0.8.5", - "yargs": "^17.5.1", - "mustache": "^4.2.0" + "yargs": "^17.5.1" }, "devDependencies": { "hardhat": "^2.11.2" diff --git a/src/utils/testNode.js b/src/utils/testNode.js new file mode 100644 index 00000000..c56569c2 --- /dev/null +++ b/src/utils/testNode.js @@ -0,0 +1,124 @@ +const { + Client, + PrivateKey, + AccountCreateTransaction, + AccountBalanceQuery, + Hbar, + TransferTransaction, + AccountId, + TransactionId, + TokenCreateTransaction +} = require("@hashgraph/sdk"); +const axios = require('axios'); +require("dotenv").config(); + +async function main() { + const myAccountId = process.env.RELAY_OPERATOR_ID_MAIN; + const myPrivateKey = process.env.RELAY_OPERATOR_KEY_MAIN; + + if (myAccountId == null || myPrivateKey == null) { + throw new Error( + "Environment variables myAccountId and myPrivateKey must be present" + ); + } + const node = { "127.0.0.1:50211": new AccountId(3) }; + const client = Client.forNetwork(node).setMirrorNetwork("127.0.0.1:5600"); + client.setOperator(myAccountId, myPrivateKey); + + const newAccountId = await createAccount(client); + await transferHbar(client, myAccountId, newAccountId); + + const { validStart } = await createHTSToken(client); + const transactionIdFormatted = `${myAccountId}-${validStart.replace(/\./g,'-')}`; + console.log(`- Mirror Node Explorer URL: http://localhost:9090/#/devnet/transaction/${transactionIdFormatted}`); + await getTransactionInformation(transactionIdFormatted); +} + + +const getTransactionInformation = async function(transactionIdFormatted) { + const url = "http://localhost:5551/api/v1/transactions/"+transactionIdFormatted + console.log('- Mirror Node Url: ' + url) + await sleep(5); + axios.get(url, {}) + .then(function (response) { + console.log(response.data.transactions); + process.exit(0); + }) +} + +const createAccount = async function (client) { + const newAccountPrivateKey = await PrivateKey.generateED25519(); + const newAccountPublicKey = newAccountPrivateKey.publicKey; + + const newAccount = await new AccountCreateTransaction() + .setKey(newAccountPublicKey) + .setInitialBalance(Hbar.fromTinybars(1000)) + .execute(client); + + const getReceipt = await newAccount.getReceipt(client); + const newAccountId = getReceipt.accountId; + + console.log("- New account ID is: " + newAccountId); + + const accountBalance = await new AccountBalanceQuery() + .setAccountId(newAccountId) + .execute(client); + + console.log( + "- New account balance is: " + + accountBalance.hbars.toTinybars() + + " tinybar." + ); + + return newAccountId; +} + +const transferHbar = async function (client, myAccountId, newAccountId) { + await new TransferTransaction() + .addHbarTransfer(myAccountId, Hbar.fromTinybars(-10000)) + .addHbarTransfer(newAccountId, Hbar.fromTinybars(10000)) + .execute(client); + + await sleep(5); + + const balance = await new AccountBalanceQuery() + .setAccountId(newAccountId) + .execute(client); + + console.log( + "- New account balance after transfer is: " + + balance.hbars.toTinybars() + + " tinybar." + ); +} + +const createHTSToken = async function(client) { + const expiration = new Date(); + expiration.setDate(expiration.getDate() + 30); + const tokenCreate = await (await new TokenCreateTransaction() + .setTokenName("WrappedHedera") + .setTokenSymbol("WHBAR") + .setExpirationTime(expiration) + .setDecimals(8) + .setInitialSupply(200000000000) + .setTreasuryAccountId(client.operatorAccountId) + .setTransactionId(TransactionId.generate(client.operatorAccountId)) + .setNodeAccountIds([client._network.getNodeAccountIdsForExecute()[0]])) + .setTransactionMemo('relay dapp test token create') + .execute(client); + + const receipt = await tokenCreate.getReceipt(client); + const transactionId = tokenCreate.transactionId.toString(); + const validStart = tokenCreate.transactionId.validStart.toString(); + const tokenId = receipt.tokenId.toString(); + + console.log(`- HTS Token Deployed with id ${tokenId}, transactionId: ${transactionId}, valid start: ${validStart}`); + + return { tokenId, transactionId, validStart }; + }; + +const sleep = async function (seconds) { + await new Promise(r => setTimeout(r, seconds * 1000 )); +} + +main(); \ No newline at end of file diff --git a/templates/local/bootstrap.template.properties b/templates/local/bootstrap.template.properties index 0b20ad1e..6f6d63a3 100644 --- a/templates/local/bootstrap.template.properties +++ b/templates/local/bootstrap.template.properties @@ -10,4 +10,5 @@ hedera.recordStream.signatureFileVersion={{signatureFileVersion}} hedera.recordStream.enableTraceabilityMigration={{enableTraceabilityMigration}} hedera.recordStream.compressFilesOnCreation={{compressFilesOnCreation}} contracts.sidecars={{sidecars}} +contracts.precompile.atomicCryptoTransfer.enabled={{atomicCryptoTransfer}} {{/features}}