Skip to content

Commit

Permalink
feat(crypto fund): use crypto amount parameter PE-5993
Browse files Browse the repository at this point in the history
  • Loading branch information
fedellen committed Aug 9, 2024
1 parent 8ad61bb commit 95d2ed9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/commands/crypto_fund.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ParametersHelper } from '../CLICommand';
import { CLIAction } from '../CLICommand/action';
import { SUCCESS_EXIT_CODE } from '../CLICommand/error_codes';
import {
ArAmountParameter,
CryptoAmountParameter,
BoostParameter,
DryRunParameter,
GatewayParameter,
Expand All @@ -29,7 +29,7 @@ function isTokenType(tokenType: string): tokenType is TokenType {
new CLICommand({
name: 'crypto-fund',
parameters: [
ArAmountParameter,
CryptoAmountParameter,
BoostParameter,
DryRunParameter,
TokenTypeParameter,
Expand Down Expand Up @@ -59,7 +59,7 @@ new CLICommand({
return SUCCESS_EXIT_CODE;
}

const arAmount = parameters.getRequiredParameterValue(ArAmountParameter, AR.from);
const cryptoAmount = parameters.getRequiredParameterValue(CryptoAmountParameter, AR.from);
const jwkWallet = (await parameters.getRequiredWallet()) as JWKWallet;

// TODO: These conversions could be done by convenience in the Turbo SDK
Expand All @@ -74,7 +74,9 @@ new CLICommand({
privateKey: tokenConversions[tokenType].wallet()
});

const res = await turbo.topUpWithTokens({ tokenAmount: tokenConversions[tokenType].token(arAmount.valueOf()) });
const res = await turbo.topUpWithTokens({
tokenAmount: tokenConversions[tokenType].token(cryptoAmount.valueOf())
});

console.log('res', JSON.stringify(res, null, 2));

Expand Down
9 changes: 9 additions & 0 deletions src/parameter_declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const DriveKeyParameter = 'driveKey';
export const AddressParameter = 'address';
export const DriveIdParameter = 'driveId';
export const ArAmountParameter = 'arAmount';
export const CryptoAmountParameter = 'cryptoAmount';
export const RewardParameter = 'reward';
export const LastTxParameter = 'lastTx';
export const TxFilePathParameter = 'txFilePath';
Expand Down Expand Up @@ -66,6 +67,7 @@ export const AllParameters = [
AddressParameter,
AllParameter,
ArAmountParameter,
CryptoAmountParameter,
TurboUrlParameter,
BoostParameter,
ConfirmationsParameter,
Expand Down Expand Up @@ -206,6 +208,13 @@ Parameter.declare({
\t\t\t\t\t\t\t• does NOT include transaction mining base rewards`
});

Parameter.declare({
name: CryptoAmountParameter,
aliases: ['-a', '--crypto-amount'],
description: `amount of crypto tokens to send in the transaction
\t\t\t\t\t\t\t• does NOT include transaction mining base rewards`
});

Parameter.declare({
name: RewardParameter,
aliases: ['-r', '--reward'],
Expand Down

0 comments on commit 95d2ed9

Please sign in to comment.