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

Commit

Permalink
Merge pull request #143 from nearprotocol/delete-account
Browse files Browse the repository at this point in the history
Add delete account + test to near shell
  • Loading branch information
janedegtiareva authored Sep 18, 2019
2 parents f7ee72b + b60f210 commit 379acc9
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
18 changes: 18 additions & 0 deletions bin/near
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,23 @@ const viewAccount = {
handler: (argv) => exitOnError(main.viewAccount(argv))
};

const deleteAccount = {
command: 'delete_account <accountId> <beneficiaryId>',
desc: 'delete an account and transfer funds to beneficiary account.',
builder: (yargs) => yargs
.option('accountId', {
desc: 'Account to view',
type: 'string',
required: true
})
.option('beneficiaryId', {
desc: 'Account to transfer funds to',
type: 'string',
required: true
}),
handler: (argv) => exitOnError(main.deleteAccount(argv))
};

const keys = {
command: 'keys <accountId>',
desc: 'view account public keys',
Expand Down Expand Up @@ -218,6 +235,7 @@ yargs // eslint-disable-line
})
.command(createAccount)
.command(viewAccount)
.command(deleteAccount)
.command(keys)
.command(txStatus)
.command(build)
Expand Down
9 changes: 9 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ exports.viewAccount = async function(options) {
console.log(state);
}

exports.deleteAccount = async function(options) {
console.log(
`Deleting account. Account id: ${options.accountId}, node: ${options.nodeUrl}, helper: ${options.helperUrl}, beneficiary: ${options.beneficiaryId}`);
const near = await connect(options);
const account = await near.account(options.accountId);
await account.deleteAccount(options.beneficiaryId);
console.log(`Account ${options.accountId} for network "${options.networkId}" was deleted.`);
};

exports.keys = async function(options) {
let near = await connect(options);
let account = await near.account(options.accountId);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"jest-environment-node": "^24.5.0",
"ncp": "^2.0.0",
"near-runtime-ts": "github:nearprotocol/near-runtime-ts",
"nearlib": "^0.13.1",
"nearlib": "^0.13.3",
"rimraf": "^2.6.3",
"yargs": "^13.2.1"
},
Expand Down
2 changes: 2 additions & 0 deletions test/account_operations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ if [[ $RESULT != *"Account $testaccount"*"amount: '100000000'"* ]]; then
echo FAILURE Unexpected output from near state
exit 1
fi

../bin/near delete_account $testaccount test.near
2 changes: 1 addition & 1 deletion test/index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
set -ex
./test/new_project.sh
./test/account_operations.sh
./test/contract_tests.sh
#./test/contract_tests.sh

0 comments on commit 379acc9

Please sign in to comment.