diff --git a/README.md b/README.md index 7a714b8..88ab943 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,12 @@ xrp escrow xrp tx ``` +### Account Settings + +``` +xrp account +``` + ## Contributing This lib has been intentionally designed for easy contribution. To add a command simply submit a PR that adds a new file in the `./src/commands/` folder. diff --git a/src/commands/account.ts b/src/commands/account.ts new file mode 100644 index 0000000..663dfb5 --- /dev/null +++ b/src/commands/account.ts @@ -0,0 +1,7 @@ +import { Argv } from 'yargs' + +export const command = 'account ' +export const describe = `Set a Domain and/or Avatar on your XRP ledger account` +export const builder = (argv: Argv) => { + return argv.commandDir('account') +} diff --git a/src/commands/account/account-set-transaction.ts b/src/commands/account/account-set-transaction.ts new file mode 100644 index 0000000..99a6e13 --- /dev/null +++ b/src/commands/account/account-set-transaction.ts @@ -0,0 +1,13 @@ +import { api, getXrpAddressAndSecret, signSubmitVerify } from '../../utils/xrp' +import { FormattedTransactionType } from 'ripple-lib'; + + +export async function execute (fields :any): Promise { + + const { address, secret } = await getXrpAddressAndSecret(); + + const prepared = await (await api()).prepareSettings(address, fields); + console.log('AccountSet transaction prepared...'); + + return signSubmitVerify(prepared, secret); +} diff --git a/src/commands/account/domain.ts b/src/commands/account/domain.ts new file mode 100644 index 0000000..ef2a94f --- /dev/null +++ b/src/commands/account/domain.ts @@ -0,0 +1,32 @@ +import { Options } from 'yargs' +import * as accountSet from './account-set-transaction'; + +export type Params = { + domain?: string +} +export const command = 'domain [domain]' +export const describe = `Sets a domain on the XRP ledger account. Leave empty to delete your domain.` +export const builder: { [key: string]: Options } = { + domain: { + type: 'string', + required: false, + description: 'domain to set on your XRPL account' + } +} + +export async function handler ({ domain }: Params) { + + let result = await accountSet.execute({domain: domain ? domain : ''}); + + console.log(JSON.stringify(result, null, 2)) + + if (result.outcome.result === 'tesSUCCESS') { + if(domain) + console.log('\nDomain set to: ' + domain) + else + console.log('\nDomain deleted'); + + process.exit(0) + } + process.exit(1) +} diff --git a/src/commands/account/emailHash.ts b/src/commands/account/emailHash.ts new file mode 100644 index 0000000..703db60 --- /dev/null +++ b/src/commands/account/emailHash.ts @@ -0,0 +1,29 @@ +import { Options } from 'yargs' +import * as accountSet from './account-set-transaction'; + +export type Params = { + emailHash: string +} +export const command = 'emailHash ' +export const describe = `Sets an emailHash on the XRP ledger account to show the avatar.` +export const builder: { [key: string]: Options } = { + emailHash: { + type: 'string', + required: true, + description: 'emailHash to set on your XRPL account' + } +} + +export async function handler ({ emailHash }: Params) { + + let result = await accountSet.execute({emailHash: emailHash}); + + console.log(JSON.stringify(result, null, 2)) + + if (result.outcome.result === 'tesSUCCESS') { + console.log('\nemailHash set to: ' + emailHash) + process.exit(0) + } + process.exit(1) +} +