-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Bitcore-cli XRP updates #4184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Bitcore-cli XRP updates #4184
Changes from 21 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
b99727a
Merge branch 'master' of github.com:bitpay/bitcore into bitcoreCli
kajoseph b35b486
Merge branch 'master' of github.com:bitpay/bitcore into bitcoreCli
kajoseph 4961e96
Merge branch 'master' of github.com:bitpay/bitcore into bitcoreCli
kajoseph 09992e6
add get flags to bws, bwc, cli
kajoseph 966b11c
add ability to accountset with xrp bws wallets
kajoseph 2f129ae
add dest tag to bitcore-cli send
kajoseph 5d99b48
better flags setting ux
kajoseph b5e7f8b
fix typing error
kajoseph a142248
fix tests; fix blue; fix pending multisig + add tests
kajoseph 20f063d
add try-catches to test transforms
kajoseph 8fa7518
better extension options
kajoseph a8ec289
lint: consistent exported memeber semicolon
kajoseph 8bf8de4
change log to die for non-xrp code
kajoseph fdac93d
throw in getAccountFlags for non-xrp
kajoseph fe83e0f
fix txproposal flags type
kajoseph 165a9df
pass thru number flags; add xrp flags tests
kajoseph 0f031c7
add promptXrpFlag tests
kajoseph 0464f07
show failure reasons for ci tests
kajoseph bf3f2d5
use npm ci in pipeline; fix colorization in tests after picocolor rep…
kajoseph 8d57df3
Merge branch 'master' of github.com:bitpay/bitcore into bitcoreCli
kajoseph 9ec4271
fix normalizeXrpFlag for payment flags
kajoseph 32999bf
reset opts after each command
kajoseph 92e5e45
fix program double parsing when extending transaction
kajoseph 78b587d
add missing and mismatched enum test cases; better normalizeXrpFlag e…
kajoseph File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import { Utils as CWCUtils, xrpl } from '@bitpay-labs/crypto-wallet-core'; | ||
| import * as prompt from '@clack/prompts'; | ||
| import { promptXrpFlag } from '../prompts'; | ||
| import { Utils } from '../utils'; | ||
| import { type ITransactionArgs, createTransaction, command as txCommand } from './transaction'; | ||
| import type { CommonArgs } from '../../types/cli'; | ||
|
|
||
| function flagsDisplay() { | ||
| const flags = Object.keys(xrpl.AccountSetTfFlags).filter(k => isNaN(parseInt(k))); // filter out numeric keys | ||
| return 'Possible flags are: ' + flags.join(', '); | ||
| } | ||
|
|
||
| export function command(args: CommonArgs<ITransactionArgs>) { | ||
| const { program } = args; | ||
| program | ||
| .description('View and manage XRP wallet flags') | ||
| .usage('<walletName> --command flags [options]') | ||
| .optionsGroup('Flags Options') | ||
| .option('--flags <flags>', 'Comma-delimited list of account transaction flag(s) to set. If provided, see Transaction Options below for additional options to provide for the setting transaction. ' + flagsDisplay()); | ||
|
|
||
| const opts = txCommand({ | ||
| ...args, | ||
| opts: { | ||
| ...args.opts, | ||
| extensionOpts: { | ||
| excludedOptions: new Set(['--to', '--amount']), | ||
| parse: (opts) => { | ||
| if (opts.flags) { | ||
| const flags = opts.flags.split(',').map(f => CWCUtils.normalizeXrpFlag(f.trim())); | ||
| if (flags.some(f => !f)) { | ||
| throw new Error('Invalid flag(s) specified. ' + flagsDisplay()); | ||
| } | ||
| opts.flags = flags.join(','); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| return opts; | ||
| } | ||
|
|
||
| export async function getOrSetFlags(args: CommonArgs<ITransactionArgs>) { | ||
| const { wallet, opts } = args; | ||
| if (opts.command) { | ||
| Object.assign(opts, command(args)); | ||
| } | ||
|
|
||
| if (!wallet.isXrp()) { | ||
| // This code should only be reachable if using --command, so we should die. | ||
| Utils.die('Flags management is only available for XRP wallets'); | ||
| } | ||
|
|
||
| const existingFlags = await wallet.getAccountFlags(); | ||
|
kajoseph marked this conversation as resolved.
|
||
| prompt.note( | ||
| Object.entries(existingFlags) | ||
| .map(([key, value]) => `${key}: ${value ? Utils.colorText('ON', 'green') : Utils.colorText('OFF', 'red')}`) | ||
| .join('\n'), | ||
| 'Current XRP Account Flags' | ||
| ); | ||
|
|
||
| const flags = opts.command ? opts.flags : await promptXrpFlag(existingFlags); | ||
|
|
||
| if (flags) { | ||
| opts.flags = flags; | ||
| opts.to = (await wallet.client.getMainAddresses())[0].address; | ||
| opts.amount = '0'; | ||
| opts.txType = 'AccountSet'; | ||
| await createTransaction(args); | ||
| } | ||
|
|
||
| return { action: 'menu' }; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.