Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Fix Check for Existing Beneficiary in Account Deletion & Repair CI #1009

Merged
merged 9 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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}}`);
}
};

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
4 changes: 3 additions & 1 deletion test/test_deploy_init_contract.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down