Skip to content

Commit

Permalink
fix(cli): include bin/turbo in argv check PE-6449
Browse files Browse the repository at this point in the history
  • Loading branch information
fedellen committed Aug 29, 2024
1 parent 93f1f93 commit cf57515
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ Usage: turbo [options] [command]
- `-t, --token <token>` - Token type for the command or connected wallet (default: "arweave")

- `-w, --wallet-file <filePath>` - Wallet file to use with the action. Formats accepted: JWK.json, KYVE or ETH private key as a string, or SOL Secret Key as a Uint8Array
- `-m, --mnemonic <phrase>` - Mnemonic to use with the action
- `-m, --mnemonic <phrase>` - Mnemonic to use with the action (KYVE only)
- `-p, --private-key <key>` - Private key to use with the action

#### Commands
Expand Down
4 changes: 2 additions & 2 deletions src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ applyOptions(

applyOptions(
program.command('crypto-fund').description('Top up a wallet with crypto'),
[...walletOptions, optionMap.token, optionMap.value],
[...walletOptions, optionMap.value],
).action(async (_commandOptions, command: Command) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const options: any = command.optsWithGlobals();
Expand All @@ -88,7 +88,7 @@ applyOptions(
});

if (
process.argv[1].includes('.bin/turbo') || // Running from global .bin
process.argv[1].includes('bin/turbo') || // Running from global .bin
process.argv[1].includes('cli/cli') // Running from source
) {
program.parse(process.argv);
Expand Down
6 changes: 5 additions & 1 deletion src/cli/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export const globalOptions = [
optionMap.gateway,
optionMap.debug,
optionMap.quiet,
optionMap.token,
];

export function applyOptions(
Expand Down Expand Up @@ -149,6 +150,7 @@ export async function privateKeyFromOptions(
if (token === 'kyve') {
return privateKeyFromKyveMnemonic(mnemonic);
} else {
// TODO: Implement other token types mnemonic to wallet
throw new Error(
'mnemonic provided but this token type mnemonic to wallet is not supported',
);
Expand All @@ -160,8 +162,10 @@ export async function privateKeyFromOptions(
} else if (privateKey !== undefined) {
return privateKey;
}
// TODO: Get TURBO_WALLET_FILE, TURBO_MNEMONIC, TURBO_PRIVATE_KEY or similar from ENV variables
// TODO: Add prompts for selecting wallet type and secure input

throw new Error('mnemonic or wallet file required');
throw new Error('mnemonic or wallet file or private key is required');
}

const tokenToDevGatewayMap: Record<TokenType, string> = {
Expand Down

0 comments on commit cf57515

Please sign in to comment.