From 56b9776464102647a9ed9d8f45490b25920d41d5 Mon Sep 17 00:00:00 2001 From: Ariel Melendez Date: Wed, 24 Nov 2021 10:57:43 -0800 Subject: [PATCH] feat(create-tx): Enforce tx and reward input formats PE-661 --- src/commands/create_tx.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/commands/create_tx.ts b/src/commands/create_tx.ts index 71ef2619..696948f6 100644 --- a/src/commands/create_tx.ts +++ b/src/commands/create_tx.ts @@ -1,4 +1,4 @@ -import { ADDR, AR, JWKWallet, Winston } from 'ardrive-core-js'; +import { ADDR, AR, JWKWallet, TxID, W, Winston } from 'ardrive-core-js'; import { CreateTransactionInterface } from 'arweave/node/common'; import { cliArweave, CLI_APP_NAME, CLI_APP_VERSION } from '..'; import { CLICommand } from '../CLICommand'; @@ -28,13 +28,15 @@ new CLICommand({ const winston: Winston = arAmount.toWinston(); const destAddress = parameters.getRequiredParameterValue(DestinationAddressParameter, ADDR); const jwkWallet = (await parameters.getRequiredWallet()) as JWKWallet; + const lastTxParam = parameters.getParameterValue(LastTxParameter); // Can be provided as a txID or empty string + const last_tx = lastTxParam && lastTxParam.length ? `${TxID(lastTxParam)}` : undefined; // Create and sign transaction const trxAttributes: Partial = { target: destAddress.toString(), quantity: winston.toString(), - reward: parameters.getParameterValue(RewardParameter), - last_tx: parameters.getParameterValue(LastTxParameter) + reward: `${parameters.getRequiredParameterValue(RewardParameter, W)}`, + last_tx }; const transaction = await cliArweave.createTransaction(trxAttributes, jwkWallet.getPrivateKey()); transaction.addTag('App-Name', CLI_APP_NAME);