Skip to content

Commit

Permalink
feat(create-tx): Enforce tx and reward input formats PE-661
Browse files Browse the repository at this point in the history
  • Loading branch information
Ariel Melendez committed Nov 24, 2021
1 parent 03da0e0 commit 56b9776
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/commands/create_tx.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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<CreateTransactionInterface> = {
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);
Expand Down

0 comments on commit 56b9776

Please sign in to comment.