Skip to content

Commit

Permalink
feat(aens): don't require name ttl in name extend
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Apr 9, 2024
1 parent 797186c commit 0d4aa51
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
6 changes: 2 additions & 4 deletions src/commands/chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@ addCommonOptions(program
.description('Get relative ttl')
.action(Chain.ttl));

// ## Initialize `ttl` command
//
// You can use this command to retrieve relative `ttl`
// ## Initialize `network_id` command
//
// Example: `aecli chain ttl <absolute_ttl>`
// You can use this command to get current network ID
addCommonOptions(program
.command('network_id')
.description('Get network ID')
Expand Down
9 changes: 5 additions & 4 deletions src/commands/name.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ addCommonOptions(program
.command('update <wallet_path> <name> [addresses...]')
.option('-M, --no-waitMined', 'Do not wait until transaction will be mined')
.option('--extendPointers', 'Extend pointers', false)
.option('--nameTtl [nameTtl]', 'Validity of name.', NAME_TTL)
.option('--clientTtl [clientTtl]', 'Client ttl.', CLIENT_TTL)
.option('--nameTtl [nameTtl]', 'A number of blocks until name expires', NAME_TTL)
.option('--clientTtl [clientTtl]', 'Client TTL', CLIENT_TTL)
.description('Update a name pointer')
.action(AENS.updateName));

Expand All @@ -109,9 +109,10 @@ addCommonOptions(program
//
// Example: `aecli name extend ./myWalletKeyFile --password testpass testname.chain 100`
addCommonOptions(program
.command('extend <wallet_path> <name> <nameTtl>')
.command('extend <wallet_path> <name>')
.argument('[nameTtl]', 'A number of blocks until name expires', NAME_TTL)
.option('-M, --no-waitMined', 'Do not wait until transaction will be mined')
.option('--clientTtl [clientTtl]', 'Client ttl.', CLIENT_TTL)
.option('--clientTtl [clientTtl]', 'Client TTL', CLIENT_TTL)
.description('Extend name ttl')
.action(AENS.extendName));

Expand Down
6 changes: 3 additions & 3 deletions src/commands/tx.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ addCommonOptions(program
//
// You can use this command to build `oracle-post-query` transaction
//
// Example: `aecli tx oracle-post-query ak_2a1j2Mk9YSmC1gioUq4PWRm3bsv887MbuRVwyv4KaUGoR1eiKi ok_348hrfdhisdkhasdaksdasdsad {city: 'Berlin'}`
// Example: `aecli tx oracle-post-query ak_2a1j2Mk9YSmC1gioUq4PWRm3bsv887MbuRVwyv4KaUGoR1eiKi ok_348hrfdhisdkhasdaksdasdsad '{"city": "Berlin"}'`
addCommonOptions(program
.command('oracle-post-query <accountId> <oracleId> <query>')
.addArgument(nonceArgument)
Expand All @@ -162,7 +162,7 @@ addCommonOptions(program
//
// You can use this command to build `oracle-extend` transaction
//
// Example: `aecli tx oracle-extend ak_2a1j2Mk9YSmC1gioUq4PWRm3bsv887MbuRVwyv4KaUGoR1eiKi ok_348hrfdhisdkhasdaksdasdsad 100
// Example: `aecli tx oracle-extend ak_2a1j2Mk9YSmC1gioUq4PWRm3bsv887MbuRVwyv4KaUGoR1eiKi ok_348hrfdhisdkhasdaksdasdsad 100
addCommonOptions(program
.command('oracle-extend <callerId> <oracleId> <oracleTtl>')
.addArgument(nonceArgument)
Expand All @@ -173,7 +173,7 @@ addCommonOptions(program
//
// You can use this command to build `oracle-respond` transaction
//
// Example: `aecli tx oracle-respond ak_2a1j2Mk9YSmC1gioUq4PWRm3bsv887MbuRVwyv4KaUGoR1eiKi ok_348hrfdhisdkhasdaksdasdsad oq_asdjn23ifsdiuhfk2h3fuksadh {tmp: 1}`
// Example: `aecli tx oracle-respond ak_2a1j2Mk9YSmC1gioUq4PWRm3bsv887MbuRVwyv4KaUGoR1eiKi ok_348hrfdhisdkhasdaksdasdsad oq_asdjn23ifsdiuhfk2h3fuksadh '{"tmp": 1}'`
addCommonOptions(program
.command('oracle-respond <callerId> <oracleId> <queryId> <response>')
.addArgument(nonceArgument)
Expand Down
14 changes: 10 additions & 4 deletions test/name.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,18 @@ describe('AENS Module', () => {
'test',
'--json',
]);
expect(extendTx.blockHeight - height).within(0, 3);
const nameResult = await executeInspect([name2, '--json']);
expect(nameResult.ttl - extendTx.blockHeight).to.be.equal(50);
expect(nameResult.status).to.equal('CLAIMED');
});

it('extend name with max ttl', async () => {
const extendTx = await executeName([
'extend', WALLET_NAME, name2, '--password', 'test', '--json',
]);
const nameResult = await executeInspect([name2, '--json']);
const isExtended = nameResult.ttl - 50 >= height;
isExtended.should.be.equal(true);
extendTx.blockHeight.should.be.gt(0);
nameResult.status.should.equal('CLAIMED');
expect(nameResult.ttl - extendTx.blockHeight).to.be.equal(180000);
});

it('Fail spend by name on invalid input', async () => {
Expand Down

0 comments on commit 0d4aa51

Please sign in to comment.