Skip to content

Proposal: Rename extendFootprintTtl.extendTo to minimumTtl for clarity #743

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

Open
wants to merge 1 commit 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

### Breaking Changes
* `Operation.extendFootprintTtl`'s `extendTo` field is now named `minimumTtl` for clarity: the value is a quantity of ledgers relative to the last-closed ledger.


## [`v11.1.0`](https://github.com/stellar/js-stellar-base/compare/v11.0.1...v11.1.0)

Expand Down
2 changes: 1 addition & 1 deletion src/operation.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ export class Operation {
}
case 'extendFootprintTtl': {
result.type = 'extendFootprintTtl';
result.extendTo = attrs.extendTo();
result.minimumTtl = attrs.extendTo();
break;
}
case 'restoreFootprint': {
Expand Down
16 changes: 9 additions & 7 deletions src/operations/extend_footprint_ttl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import xdr from '../xdr';

/**
* Builds an operation to bump the time-to-live of a footprint (read and written
* ledger keys). Its only parameter is the new, absolute ledger sequence number
* at which the entry will expire.
* ledger keys). Its only parameter is the number of ledgers (N) **relative** to
* the last-closed ledger (LCL) at which the entry will be archived, i.e. it
* will be archived at a ledger >= LCL+N. These are the entries' time to live.
*
* The footprint itself is derived from the transaction (see
* {@link TransactionBuilder}'s `opts.sorobanData` parameter, which is a
Expand All @@ -14,21 +15,22 @@ import xdr from '../xdr';
* @alias Operation.extendFootprintTtl
*
* @param {object} opts - object holding operation parameters
* @param {number} opts.extendTo - the absolute ledger sequence number at which
* the transaction's ledger keys will now expire
* @param {number} opts.minimumTtl - the number of ledgers relative to the
* last-closed ledger that the footprint entry should live for (note that
* this value has to be below the network's `max_entry_ttl` setting)
* @param {string} [opts.source] - an optional source account
*
* @returns {xdr.Operation} an Extend Footprint TTL operation
* (xdr.ExtendFootprintTTLOp)
*/
export function extendFootprintTtl(opts) {
if ((opts.extendTo ?? -1) <= 0) {
throw new RangeError("extendTo isn't a ledger quantity (uint32)");
if ((opts.minimumTtl ?? -1) <= 0) {
throw new RangeError("minimumTtl isn't a ledger quantity (uint32)");
}

const extendFootprintOp = new xdr.ExtendFootprintTtlOp({
ext: new xdr.ExtensionPoint(0),
extendTo: opts.extendTo
extendTo: opts.minimumTtl
});

const opAttributes = {
Expand Down
6 changes: 3 additions & 3 deletions test/unit/operations/extend_restore_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ const { Operation } = StellarBase;
describe('Operation', function () {
describe('.extendFootprintTtl()', function () {
it('creates operation', function () {
const op = StellarBase.Operation.extendFootprintTtl({ extendTo: 1234 });
const op = StellarBase.Operation.extendFootprintTtl({ minimumTtl: 1234 });
const xdr = op.toXDR('hex');
const operation = StellarBase.xdr.Operation.fromXDR(xdr, 'hex');

expect(operation.body().switch().name).to.equal('extendFootprintTtl');
const obj = StellarBase.Operation.fromXDRObject(operation);
expect(obj.type).to.be.equal('extendFootprintTtl');
expect(obj.extendTo).to.equal(1234);
expect(obj.minimumTtl).to.equal(1234);

expect(() => {
StellarBase.Operation.extendFootprintTtl({ extendTo: 0 });
StellarBase.Operation.extendFootprintTtl({ minimumTtl: 0 });
}).to.throw(/ledger quantity/i);
});
});
Expand Down
4 changes: 2 additions & 2 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ export namespace OperationOptions {
}

interface ExtendFootprintTTL extends BaseOptions {
extendTo: number;
minimumTtl: number;
}
type RestoreFootprint = BaseOptions;
}
Expand Down Expand Up @@ -904,7 +904,7 @@ export namespace Operation {
options: OperationOptions.ExtendFootprintTTL
): xdr.Operation<ExtendFootprintTTL>;
interface ExtendFootprintTTL extends BaseOperation<OperationType.ExtendFootprintTTL> {
extendTo: number;
minimumTtl: number;
}

function restoreFootprint(options: OperationOptions.RestoreFootprint):
Expand Down
Loading