Skip to content
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

Introducing the 'AccountSet' XRP Ledger transaction to xrp-commander tool #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ xrp escrow <create|release>
xrp tx <find>
```

### Account Settings

```
xrp account <domain|emailHash>
```

## 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.
Expand Down
7 changes: 7 additions & 0 deletions src/commands/account.ts
Original file line number Diff line number Diff line change
@@ -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')
}
13 changes: 13 additions & 0 deletions src/commands/account/account-set-transaction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { api, getXrpAddressAndSecret, signSubmitVerify } from '../../utils/xrp'
import { FormattedTransactionType } from 'ripple-lib';


export async function execute (fields :any): Promise<FormattedTransactionType> {

const { address, secret } = await getXrpAddressAndSecret();

const prepared = await (await api()).prepareSettings(address, fields);
console.log('AccountSet transaction prepared...');

return signSubmitVerify(prepared, secret);
}
32 changes: 32 additions & 0 deletions src/commands/account/domain.ts
Original file line number Diff line number Diff line change
@@ -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)
}
29 changes: 29 additions & 0 deletions src/commands/account/emailHash.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Options } from 'yargs'
import * as accountSet from './account-set-transaction';

export type Params = {
emailHash: string
}
export const command = 'emailHash <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)
}