From 265b2acec307ff2e94c3e48b3bf1451b36b1e0d9 Mon Sep 17 00:00:00 2001 From: ArtemZ Date: Tue, 12 Jul 2022 15:32:19 +0500 Subject: [PATCH] Bugfix of address calculation when entering initial data in dialog mode --- CHANGELOG.md | 7 ++++++ package.json | 2 +- src/controllers/contract/index.ts | 39 +++++++++++++++++-------------- src/controllers/contract/run.ts | 3 +++ 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1c99b4..0d40772 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. +## [1.2.2] - 2022-07-12 + +### Fixed + +- Fixed the address calculation error that occurred when running "everdev contract deploy" and entering initial data in dialog mode. + + ## [1.2.1] - 2022-06-30 ### Fixed diff --git a/package.json b/package.json index 0bb2e61..bb88a30 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "everdev", - "version": "1.2.1", + "version": "1.2.2", "description": "Everscale Dev Environment", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/controllers/contract/index.ts b/src/controllers/contract/index.ts index 67dc1a2..b34bba0 100644 --- a/src/controllers/contract/index.ts +++ b/src/controllers/contract/index.ts @@ -196,7 +196,27 @@ export const contractDeployCommand: Command = { ) { let account = await getAccount(terminal, args) const info = await account.getAccount() - const accountAddress = await account.getAddress() + let accountAddress = await account.getAddress() + + const dataParams = account.contract.abi.data ?? [] + if (dataParams.length > 0) { + const initData = await resolveParams( + terminal, + `\nDeploying initial data:\n`, + dataParams, + args.data ?? "", + args.preventUi, + ) + await account.free() + account = new Account(account.contract, { + client: account.client, + signer: account.signer, + initData, + }) + + accountAddress = await account.getAddress() + } + if (info.acc_type === AccountType.active) { throw new Error(`Account ${accountAddress} already deployed.`) } @@ -220,23 +240,6 @@ export const contractDeployCommand: Command = { ) } } - const dataParams = account.contract.abi.data ?? [] - if (dataParams.length > 0) { - const initData = await resolveParams( - terminal, - `\nDeploying initial data:\n`, - dataParams, - args.data ?? "", - args.preventUi, - ) - await account.free() - account = new Account(account.contract, { - client: account.client, - address: await accountAddress, - signer: account.signer, - initData, - }) - } const initFunctionName = args.function.toLowerCase() === "none" diff --git a/src/controllers/contract/run.ts b/src/controllers/contract/run.ts index fe82945..6079a65 100644 --- a/src/controllers/contract/run.ts +++ b/src/controllers/contract/run.ts @@ -53,7 +53,10 @@ function inputLine(terminal: Terminal, prompt: string): Promise { return new Promise(resolve => { const standard_input = process.stdin standard_input.setEncoding("utf-8") + // SO: https://stackoverflow.com/questions/54182732/process-never-ends-when-using-process-stdin-once + standard_input.resume() standard_input.once("data", function (data) { + standard_input.pause() resolve(`${data}`.trim()) }) })