diff --git a/index.js b/index.js index a93465a3..b4869bcd 100644 --- a/index.js +++ b/index.js @@ -224,9 +224,15 @@ exports.deleteAccount = async function (options) { const near = await connect(options); const beneficiaryAccount = await near.account(options.beneficiaryId); // beneficiary account does not exist if there are no access keys - if (!(await beneficiaryAccount.getAccessKeys()).length) { - console.log('Beneficiary account does not exist, please create the account to transfer Near tokens.'); - return; + try { + await beneficiaryAccount.state(); + } catch (e) { + if (e.type === 'AccountDoesNotExist') { + console.error(`Beneficiary account ${options.beneficiaryId} does not exist. Please create the account to transfer Near tokens.`); + return; + } else { + throw e; + } } if (await confirmDelete()) { @@ -238,7 +244,7 @@ exports.deleteAccount = async function (options) { console.log(`Account ${options.accountId} for network "${options.networkId}" was deleted.`); } else { - console.log(chalk`{bold.white Deletion of account with account id: {bold.blue ${options.accountId} } was {bold.red canceled}}`); + console.log(chalk`{bold.white Deletion of account with account id: {bold.blue ${options.accountId} } was {bold.red cancelled}}`); } }; diff --git a/package.json b/package.json index 67388653..94443ee8 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,9 @@ "main": "index.js", "scripts": { "pretest": "rm -rf tmp-project", - "test": "jest && ./test/index.sh", + "test": "npm run test:unit && npm run test:integration", + "test:unit": "jest", + "test:integration": "bash ./test/index.sh", "lint": "eslint .", "fix": "eslint . --fix" }, diff --git a/test/test_deploy_init_contract.sh b/test/test_deploy_init_contract.sh index d46c8956..7b7adee9 100755 --- a/test/test_deploy_init_contract.sh +++ b/test/test_deploy_init_contract.sh @@ -19,7 +19,9 @@ else fi # Delete account, remake, redeploy -./bin/near delete $testaccount test.near > /dev/null +echo Deleting account: $testaccount +printf 'y\n' | ./bin/near delete $testaccount test.near > /dev/null +echo Recreating account: $testaccount ./bin/near create-account $testaccount > /dev/null ./bin/near deploy --accountId $testaccount --wasmFile ./test/res/fungible_token.wasm --initFunction new --initArgs '{"owner_id": "test.near", "total_supply": "1000000"}' > /dev/null RESULT=$(./bin/near view $testaccount get_balance '{"owner_id": "test.near"}' -v | ./node_modules/.bin/strip-ansi)