Skip to content

Commit 8b8a7d3

Browse files
authored
Updated the docs for extend/restore footprint ops. (#752)
* Updated the docs for extend/restore footprint ops. Extend TTL doc was incorrect, and restore doc lacked some important details.
1 parent 2f38f46 commit 8b8a7d3

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

src/operations/extend_footprint_ttl.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,38 @@
11
import xdr from '../xdr';
22

33
/**
4-
* Builds an operation to bump the time-to-live of a footprint (read and written
5-
* ledger keys). Its only parameter is the new, absolute ledger sequence number
6-
* at which the entry will expire.
4+
* Builds an operation to bump the time-to-live (TTL) of the ledger keys. The
5+
* keys for extension have to be provided in the read-only footprint of
6+
* the transaction.
77
*
8-
* The footprint itself is derived from the transaction (see
8+
* The only parameter of the operation itself is the new minimum TTL for
9+
* all the provided entries. If an entry already has a higher TTL, then it
10+
* will just be skipped.
11+
*
12+
* TTL is the number of ledgers from the current ledger (exclusive) until
13+
* the last ledger the entry is still considered alive (inclusive). Thus
14+
* the exact ledger until the entries will live will only be determined
15+
* when transaction has been applied.
16+
*
17+
* The footprint has to be specified in the transaction. See
918
* {@link TransactionBuilder}'s `opts.sorobanData` parameter, which is a
1019
* {@link xdr.SorobanTransactionData} instance that contains fee data & resource
11-
* usage as part of {@link xdr.SorobanResources}).
20+
* usage as part of {@link xdr.SorobanResources}.
1221
*
1322
* @function
1423
* @alias Operation.extendFootprintTtl
1524
*
1625
* @param {object} opts - object holding operation parameters
17-
* @param {number} opts.extendTo - the absolute ledger sequence number at which
18-
* the transaction's ledger keys will now expire
26+
* @param {number} opts.extendTo - the minimum TTL that all the entries in
27+
* the read-only footprint will have
1928
* @param {string} [opts.source] - an optional source account
2029
*
2130
* @returns {xdr.Operation} an Extend Footprint TTL operation
2231
* (xdr.ExtendFootprintTTLOp)
2332
*/
2433
export function extendFootprintTtl(opts) {
2534
if ((opts.extendTo ?? -1) <= 0) {
26-
throw new RangeError("extendTo isn't a ledger quantity (uint32)");
35+
throw new RangeError('extendTo has to be positive');
2736
}
2837

2938
const extendFootprintOp = new xdr.ExtendFootprintTtlOp({

src/operations/restore_footprint.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import xdr from '../xdr';
22

33
/**
4-
* Builds a footprint restoration operation.
4+
* Builds an operation to restore the archived ledger entries specified
5+
* by the ledger keys.
6+
*
7+
* The ledger keys to restore are specified separately from the operation
8+
* in read-write footprint of the transaction.
59
*
610
* It takes no parameters because the relevant footprint is derived from the
7-
* transaction itself (see {@link TransactionBuilder}'s `opts.sorobanData`
11+
* transaction itself. See {@link TransactionBuilder}'s `opts.sorobanData`
812
* parameter (or {@link TransactionBuilder.setSorobanData} /
913
* {@link TransactionBuilder.setLedgerKeys}), which is a
1014
* {@link xdr.SorobanTransactionData} instance that contains fee data & resource
11-
* usage as part of {@link xdr.SorobanTransactionData}).
15+
* usage as part of {@link xdr.SorobanTransactionData}.
1216
*
1317
* @function
1418
* @alias Operation.restoreFootprint

test/unit/operations/extend_restore_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe('Operation', function () {
1414

1515
expect(() => {
1616
StellarBase.Operation.extendFootprintTtl({ extendTo: 0 });
17-
}).to.throw(/ledger quantity/i);
17+
}).to.throw(/has to be positive/i);
1818
});
1919
});
2020

0 commit comments

Comments
 (0)