This repository has been archived by the owner on Oct 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move logic to commands/delete-key.js
- Loading branch information
1 parent
1dd9530
commit 4691e46
Showing
3 changed files
with
27 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const exitOnError = require('../utils/exit-on-error'); | ||
const connect = require('../utils/connect'); | ||
const eventtracking = require('../utils/eventtracking'); | ||
const inspectResponse = require('../utils/inspect-response'); | ||
|
||
module.exports = { | ||
command: 'delete-key [accessKey]', | ||
desc: 'delete access key', | ||
builder: (yargs) => yargs | ||
.option('accessKey', { | ||
desc: 'Public key to delete (base58 encoded)', | ||
type: 'string', | ||
required: true, | ||
}), | ||
handler: exitOnError(deleteAccessKey) | ||
}; | ||
|
||
async function deleteAccessKey(options) { | ||
await eventtracking.track(eventtracking.EVENT_ID_DELETE_KEY_START, { node: options.nodeUrl, amount: options.amount }); | ||
console.log(`Deleting key = ${options.accessKey} on ${options.accountId}.`); | ||
const near = await connect(options); | ||
const account = await near.account(options.accountId); | ||
const result = await account.deleteKey(options.accessKey); | ||
console.log(inspectResponse(result)); | ||
await eventtracking.track(eventtracking.EVENT_ID_DELETE_KEY_END, { node: options.nodeUrl, success: true }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters