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

Commit

Permalink
Add delete account + test to near shell
Browse files Browse the repository at this point in the history
  • Loading branch information
janedegtiareva committed Sep 17, 2019
1 parent f7ee72b commit d1a69d7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
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

0 comments on commit d1a69d7

Please sign in to comment.