Skip to content

Commit

Permalink
Merge pull request #259 from aeternity/tx-builder-amounts
Browse files Browse the repository at this point in the history
Extract options in tx builder
  • Loading branch information
davidyuk authored Jan 18, 2025
2 parents 1c9d1f6 + 7bc49c8 commit 5530d51
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 15 deletions.
10 changes: 5 additions & 5 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ Register current account as oracle.
`--oracleTtl [oracleTtl]`
Relative oracle time to leave (default: 500).
`--queryFee [queryFee]`
Oracle query fee (default: 0).
Oracle query fee (default: 0ae).
`-P, --password [password]`
Wallet Password, may be recorded to shell history (env: AECLI_WALLET_PASSWORD).
`-T, --ttl [ttl]`
Expand Down Expand Up @@ -765,7 +765,7 @@ Relative query response time to leave (default: 10).
`--queryTtl [queryTtl]`
Relative query time to leave (default: 10).
`--queryFee [queryFee]`
Oracle query fee (default: 0).
Oracle query fee (default: provided by oracle).
`-P, --password [password]`
Wallet Password, may be recorded to shell history (env: AECLI_WALLET_PASSWORD).
`-T, --ttl [ttl]`
Expand Down Expand Up @@ -1055,7 +1055,7 @@ Unique number that is required to sign transaction securely.

#### Options
`--nameFee [nameFee]`
Name fee.
Amount of coins to pay for name.
`-F, --fee [fee]`
Override the transaction fee.
`-T, --ttl [ttl]`
Expand Down Expand Up @@ -1257,7 +1257,7 @@ Unique number that is required to sign transaction securely.

#### Options
`--queryFee [queryFee]`
Oracle query fee (default: 0).
Oracle query fee (default: 0ae).
`--oracleTtl [oracleTtl]`
Oracle TTL (default: 500).
`-F, --fee [fee]`
Expand Down Expand Up @@ -1321,7 +1321,7 @@ Unique number that is required to sign transaction securely.

#### Options
`--queryFee [queryFee]`
Oracle query fee (default: 0).
Oracle query fee (default: provided by oracle).
`--queryTtl [oracleTtl]`
Oracle TTL (default: 10).
`--responseTtl [oracleTtl]`
Expand Down
7 changes: 7 additions & 0 deletions src/arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ export const amountOption = new Option('-a, --amount [amount]', 'Amount of coins
export const feeOption = new Option('-F, --fee [fee]', 'Override the transaction fee')
.argParser(coinAmountParser);

export const nameFeeOption = new Option('--nameFee [nameFee]', 'Amount of coins to pay for name')
.argParser(coinAmountParser);

export const queryFeeOption = (isCreate) => new Option('--queryFee [queryFee]', 'Oracle query fee')
.default(...isCreate ? [0, '0ae'] : [noValue, 'provided by oracle'])
.argParser(coinAmountParser);

export const nodeOption = new Option('-u, --url [nodeUrl]', 'Node to connect to')
.default('https://mainnet.aeternity.io', 'mainnet')
.env('AECLI_NODE_URL');
Expand Down
6 changes: 3 additions & 3 deletions src/commands/name.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { NAME_TTL } from '@aeternity/aepp-sdk';
import * as AENS from '../actions/aens.js';
import {
nodeOption, jsonOption, feeOption, forceOption, passwordOption, ttlOption, coinAmountParser,
clientTtlOption,
clientTtlOption, nameFeeOption,
} from '../arguments.js';
import {
addExamples, exampleAddress1, exampleContract, exampleName,
Expand Down Expand Up @@ -34,7 +34,7 @@ const claimingGuide = [
].join(' ');

let command = program.command('full-claim <wallet_path> <name>')
.option('--nameFee [nameFee]', 'Amount of coins to pay for name', coinAmountParser)
.addOption(nameFeeOption)
.option('--nameTtl [nameTtl]', 'Validity of name.', NAME_TTL)
.addOption(clientTtlOption)
.summary('claim an AENS name in a single command')
Expand All @@ -61,7 +61,7 @@ command = program.command('pre-claim <wallet_path> <name>')
addCommonOptions(command, `./wallet.json ${exampleName}`);

command = program.command('claim <wallet_path> <name> <salt>')
.option('--nameFee [nameFee]', 'Amount of coins to pay for name', coinAmountParser)
.addOption(nameFeeOption)
.summary('claim an AENS name (requires pre-claim)')
.description([
'Claim an AENS name, it requires a salt provided by `aecli name pre-claim`.',
Expand Down
6 changes: 3 additions & 3 deletions src/commands/oracle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Command } from 'commander';
import { ORACLE_TTL, QUERY_TTL, RESPONSE_TTL } from '@aeternity/aepp-sdk';
import * as Oracle from '../actions/oracle.js';
import {
nodeOption, jsonOption, feeOption, forceOption, passwordOption, ttlOption,
nodeOption, jsonOption, feeOption, queryFeeOption, forceOption, passwordOption, ttlOption,
} from '../arguments.js';
import { addExamples, exampleOracle, exampleOracleQuery } from '../utils/helpers.js';

Expand All @@ -24,7 +24,7 @@ const addCommonOptions = (cmd, example) => {

let command = program.command('create <wallet_path> <queryFormat> <responseFormat>')
.option('--oracleTtl [oracleTtl]', 'Relative oracle time to leave', ORACLE_TTL.value)
.option('--queryFee [queryFee]', 'Oracle query fee', 0)
.addOption(queryFeeOption(true))
.summary('register current account as oracle')
.action(Oracle.createOracle);
addCommonOptions(command, './wallet.json string string');
Expand All @@ -37,7 +37,7 @@ addCommonOptions(command, './wallet.json 200');
command = program.command('create-query <wallet_path> <oracleId> <query>')
.option('--responseTtl [responseTtl]', 'Relative query response time to leave', RESPONSE_TTL.value)
.option('--queryTtl [queryTtl]', 'Relative query time to leave', QUERY_TTL.value)
.option('--queryFee [queryFee]', 'Oracle query fee', 0)
.addOption(queryFeeOption(false))
.summary('create an oracle query')
.action(Oracle.createOracleQuery);
addCommonOptions(command, `./wallet.json ${exampleOracle} WhatTheWeatherIs?`);
Expand Down
10 changes: 7 additions & 3 deletions src/commands/tx.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
gasOption,
gasPriceOption,
feeOption,
nameFeeOption,
queryFeeOption,
forceOption,
ttlOption,
amountOption,
Expand Down Expand Up @@ -51,7 +53,7 @@ command = program.command('name-preclaim <accountId> <name>')
addTxBuilderOptions(command, `${exampleAddress1} ${exampleName} 42`);

command = program.command('name-claim <accountId> <salt> <name>')
.option('--nameFee [nameFee]', 'Name fee')
.addOption(nameFeeOption)
.action(Transaction.nameClaim);
addTxBuilderOptions(command, `${exampleAddress1} 12327389123 ${exampleName} 42`);

Expand Down Expand Up @@ -86,8 +88,9 @@ command = program.command('contract-call <callerId> <contractId> <callData>')
.action(Transaction.contractCall);
addTxBuilderOptions(command, `${exampleAddress1} ${exampleContract} ${exampleCalldata} 42`);

// TODO: choose between "register" and "create" (in oracle.js)
command = program.command('oracle-register <accountId> <queryFormat> <responseFormat>')
.option('--queryFee [queryFee]', 'Oracle query fee', 0)
.addOption(queryFeeOption(true))
.option('--oracleTtl [oracleTtl]', 'Oracle TTL', ORACLE_TTL.value)
.action(Transaction.oracleRegister);
addTxBuilderOptions(command, `${exampleAddress1} '{"city": "string"}' '{"tmp": "number"}' 42`);
Expand All @@ -96,8 +99,9 @@ command = program.command('oracle-extend <oracleId> <oracleTtl>')
.action(Transaction.oracleExtend);
addTxBuilderOptions(command, `${exampleOracle} 100 42`);

// TODO: choose between "post" and "create" (in oracle.js)
command = program.command('oracle-post-query <accountId> <oracleId> <query>')
.option('--queryFee [queryFee]', 'Oracle query fee', 0)
.addOption(queryFeeOption(false))
.option('--queryTtl [oracleTtl]', 'Oracle TTL', QUERY_TTL.value)
.option('--responseTtl [oracleTtl]', 'Oracle TTL', RESPONSE_TTL.value)
.action(Transaction.oraclePostQuery);
Expand Down
2 changes: 1 addition & 1 deletion user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ To deploy a contract, run [`aecli contract deploy`](./reference.md#deploy) addin
$ aecli contract deploy --contractSource ./contract.aes ./wallet.json
Contract was successfully deployed
Contract address ________________________ ct_5MbRKEb77pJVZrjVrQYHu2nzr2EKojuthotio1vZ2Q23dkYkV
Transaction hash ________________________ th_dGEn3MsUsEjYWpFVSWtfwo5shnGiAZvtyyQDEMaaVcuMEHEKa
Transaction hash ________________________ th_5M77avjrPKezyBrUfkn19C79MnVh9SSoX4Euz4nY75kn9Fxto
Deploy descriptor _______________________ /path/to/contract.aes.deploy.5MbRKEb77pJVZrjVrQYHu2nzr2EKojuthotio1vZ2Q23dkYkV.json
```
<!-- CONTRACT-DEPLOY-END -->
Expand Down

0 comments on commit 5530d51

Please sign in to comment.