Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
♻️ Fix naming and add verify transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
shuse2 committed May 16, 2018
1 parent f37ae31 commit e4188c8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/commands/sign_transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ const description = `Sign a transaction using your secret passphrase.
Example: sign transaction '{"amount":"100","recipientId":"13356260975429434553L","senderPublicKey":null,"timestamp":52871598,"type":0,"fee":"10000000","recipientPublicKey":null,"asset":{}}'
`;

const getTransactionInput = ({ transaction, stdin, shouldUseStdIn }) => {
const getTransactionInput = ({ transaction, stdin }) => {
const hasStdIn = stdin && stdin[0];
if (shouldUseStdIn && !hasStdIn) {
if (!transaction && !hasStdIn) {
return null;
}
return shouldUseStdIn ? stdin[0] : transaction;
return transaction || stdin[0];
};

const getStdInOnNonInteractiveMode = async () => {
const getStdInForNonInteractiveMode = async () => {
// We should only get normal stdin for NON_INTERACTIVE_MODE
if (process.env.NON_INTERACTIVE_MODE) {
const stdin = await getStdIn({ dataIsRequired: true });
Expand All @@ -54,7 +54,7 @@ export const actionCreator = vorpal => async ({
shouldUseStdIn,
});
const transactionInput =
transactionSource || (await getStdInOnNonInteractiveMode());
transactionSource || (await getStdInForNonInteractiveMode());

if (!transactionInput) {
throw new ValidationError('No transaction was provided.');
Expand All @@ -67,6 +67,8 @@ export const actionCreator = vorpal => async ({
throw new ValidationError('Could not parse transaction JSON.');
}

transactions.utils.verifyTransaction(transactionObject);

const passphraseSource = options.passphrase;

const { passphrase } = await getInputsFromSources(vorpal, {
Expand Down

0 comments on commit e4188c8

Please sign in to comment.