Skip to content

Commit

Permalink
Add transaction id log for delete account (#487)
Browse files Browse the repository at this point in the history
  • Loading branch information
janedegtiareva committed Aug 7, 2020
1 parent cd34af1 commit e289641
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion commands/create-account.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const exitOnError = require('../utils/exit-on-error');
const connect = require('../utils/connect');
const { KeyPair } = require('near-api-js');
const eventtracking = require('../utils/eventtracking');
const inspectResponse = require('../utils/inspect-response');
// Top-level account (TLA) is testnet for foo.alice.testnet
const TLA_MIN_LENGTH = 32;

Expand Down Expand Up @@ -127,8 +128,10 @@ async function createAccount(options) {
}
// Create account
try {
await near.createAccount(options.accountId, publicKey);
const response = await near.createAccount(options.accountId, publicKey);
inspectResponse.prettyPrintResponse(response, options);
console.log(`Account ${options.accountId} for network "${options.networkId}" was created.`);

} catch(error) {
if (error.type === 'RetriesExceeded') {
console.warn('Received a timeout when creating account, please run:');
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ exports.deleteAccount = async function (options) {
`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);
const result = await account.deleteAccount(options.beneficiaryId);
inspectResponse.prettyPrintResponse(result, options);
console.log(`Account ${options.accountId} for network "${options.networkId}" was deleted.`);
};

Expand Down
6 changes: 4 additions & 2 deletions utils/inspect-response.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ const prettyPrintResponse = (response, options) => {
console.log(formatResponse(response));
}
const txnId = getTxnId(response);
console.log(`Transaction Id ${txnId}`);
explorer.printTransactionUrl(txnId, options);
if (txnId) {
console.log(`Transaction Id ${txnId}`);
explorer.printTransactionUrl(txnId, options);
}
};

const prettyPrintError = (error, options) => {
Expand Down

0 comments on commit e289641

Please sign in to comment.