@stellar/stellar-base 12.0.0 → 12.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,21 +7,30 @@ exports.extendFootprintTtl = extendFootprintTtl;
7
7
  var _xdr = _interopRequireDefault(require("../xdr"));
8
8
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
9
9
  /**
10
- * Builds an operation to bump the time-to-live of a footprint (read and written
11
- * ledger keys). Its only parameter is the new, absolute ledger sequence number
12
- * at which the entry will expire.
10
+ * Builds an operation to bump the time-to-live (TTL) of the ledger keys. The
11
+ * keys for extension have to be provided in the read-only footprint of
12
+ * the transaction.
13
13
  *
14
- * The footprint itself is derived from the transaction (see
14
+ * The only parameter of the operation itself is the new minimum TTL for
15
+ * all the provided entries. If an entry already has a higher TTL, then it
16
+ * will just be skipped.
17
+ *
18
+ * TTL is the number of ledgers from the current ledger (exclusive) until
19
+ * the last ledger the entry is still considered alive (inclusive). Thus
20
+ * the exact ledger until the entries will live will only be determined
21
+ * when transaction has been applied.
22
+ *
23
+ * The footprint has to be specified in the transaction. See
15
24
  * {@link TransactionBuilder}'s `opts.sorobanData` parameter, which is a
16
25
  * {@link xdr.SorobanTransactionData} instance that contains fee data & resource
17
- * usage as part of {@link xdr.SorobanResources}).
26
+ * usage as part of {@link xdr.SorobanResources}.
18
27
  *
19
28
  * @function
20
29
  * @alias Operation.extendFootprintTtl
21
30
  *
22
31
  * @param {object} opts - object holding operation parameters
23
- * @param {number} opts.extendTo - the absolute ledger sequence number at which
24
- * the transaction's ledger keys will now expire
32
+ * @param {number} opts.extendTo - the minimum TTL that all the entries in
33
+ * the read-only footprint will have
25
34
  * @param {string} [opts.source] - an optional source account
26
35
  *
27
36
  * @returns {xdr.Operation} an Extend Footprint TTL operation
@@ -30,7 +39,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default":
30
39
  function extendFootprintTtl(opts) {
31
40
  var _opts$extendTo;
32
41
  if (((_opts$extendTo = opts.extendTo) !== null && _opts$extendTo !== void 0 ? _opts$extendTo : -1) <= 0) {
33
- throw new RangeError("extendTo isn't a ledger quantity (uint32)");
42
+ throw new RangeError('extendTo has to be positive');
34
43
  }
35
44
  var extendFootprintOp = new _xdr["default"].ExtendFootprintTtlOp({
36
45
  ext: new _xdr["default"].ExtensionPoint(0),
@@ -7,14 +7,18 @@ exports.restoreFootprint = restoreFootprint;
7
7
  var _xdr = _interopRequireDefault(require("../xdr"));
8
8
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
9
9
  /**
10
- * Builds a footprint restoration operation.
10
+ * Builds an operation to restore the archived ledger entries specified
11
+ * by the ledger keys.
12
+ *
13
+ * The ledger keys to restore are specified separately from the operation
14
+ * in read-write footprint of the transaction.
11
15
  *
12
16
  * It takes no parameters because the relevant footprint is derived from the
13
- * transaction itself (see {@link TransactionBuilder}'s `opts.sorobanData`
17
+ * transaction itself. See {@link TransactionBuilder}'s `opts.sorobanData`
14
18
  * parameter (or {@link TransactionBuilder.setSorobanData} /
15
19
  * {@link TransactionBuilder.setLedgerKeys}), which is a
16
20
  * {@link xdr.SorobanTransactionData} instance that contains fee data & resource
17
- * usage as part of {@link xdr.SorobanTransactionData}).
21
+ * usage as part of {@link xdr.SorobanTransactionData}.
18
22
  *
19
23
  * @function
20
24
  * @alias Operation.restoreFootprint
package/lib/scval.js CHANGED
@@ -350,21 +350,23 @@ function scValToNative(scv) {
350
350
  case _xdr["default"].ScValType.scvTimepoint().value:
351
351
  case _xdr["default"].ScValType.scvDuration().value:
352
352
  return new _xdr["default"].Uint64(scv.value()).toBigInt();
353
- case _xdr["default"].ScValType.scvStatus().value:
354
- // TODO: Convert each status type into a human-readable error string?
355
- switch (scv.value()["switch"]()) {
356
- case _xdr["default"].ScStatusType.sstOk().value:
357
- case _xdr["default"].ScStatusType.sstUnknownError().value:
358
- case _xdr["default"].ScStatusType.sstHostValueError().value:
359
- case _xdr["default"].ScStatusType.sstHostObjectError().value:
360
- case _xdr["default"].ScStatusType.sstHostFunctionError().value:
361
- case _xdr["default"].ScStatusType.sstHostStorageError().value:
362
- case _xdr["default"].ScStatusType.sstHostContextError().value:
363
- case _xdr["default"].ScStatusType.sstVmError().value:
364
- case _xdr["default"].ScStatusType.sstContractError().value:
365
- case _xdr["default"].ScStatusType.sstHostAuthError().value:
353
+ case _xdr["default"].ScValType.scvError().value:
354
+ switch (scv.error()["switch"]().value) {
355
+ // Distinguish errors from the user contract.
356
+ case _xdr["default"].ScErrorType.sceContract().value:
357
+ return {
358
+ type: 'contract',
359
+ code: scv.error().contractCode()
360
+ };
366
361
  default:
367
- break;
362
+ {
363
+ var err = scv.error();
364
+ return {
365
+ type: 'system',
366
+ code: err.code().value,
367
+ value: err.code().name
368
+ };
369
+ }
368
370
  }
369
371
 
370
372
  // in the fallthrough case, just return the underlying value directly
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stellar/stellar-base",
3
- "version": "12.0.0",
3
+ "version": "12.0.1",
4
4
  "description": "Low-level support library for the Stellar network.",
5
5
  "main": "./lib/index.js",
6
6
  "browser": {
@@ -70,15 +70,15 @@
70
70
  },
71
71
  "homepage": "https://github.com/stellar/js-stellar-base",
72
72
  "devDependencies": {
73
- "@babel/cli": "^7.24.6",
74
- "@babel/core": "^7.24.6",
75
- "@babel/eslint-parser": "^7.24.6",
76
- "@babel/eslint-plugin": "^7.24.6",
77
- "@babel/preset-env": "^7.24.6",
73
+ "@babel/cli": "^7.24.7",
74
+ "@babel/core": "^7.24.7",
75
+ "@babel/eslint-parser": "^7.24.7",
76
+ "@babel/eslint-plugin": "^7.24.7",
77
+ "@babel/preset-env": "^7.24.7",
78
78
  "@babel/register": "^7.24.6",
79
79
  "@definitelytyped/dtslint": "^0.0.182",
80
80
  "@istanbuljs/nyc-config-babel": "3.0.0",
81
- "@types/node": "^20.12.13",
81
+ "@types/node": "^20.14.2",
82
82
  "@typescript-eslint/parser": "^6.20.0",
83
83
  "babel-loader": "^9.1.3",
84
84
  "babel-plugin-istanbul": "^6.1.1",
@@ -103,12 +103,12 @@
103
103
  "karma-mocha": "^2.0.0",
104
104
  "karma-sinon-chai": "^2.0.2",
105
105
  "karma-webpack": "^5.0.1",
106
- "lint-staged": "^15.2.5",
106
+ "lint-staged": "^15.2.7",
107
107
  "minami": "^1.1.1",
108
108
  "mocha": "^10.4.0",
109
109
  "node-polyfill-webpack-plugin": "^3.0.0",
110
110
  "nyc": "^15.1.0",
111
- "prettier": "^3.2.5",
111
+ "prettier": "^3.3.2",
112
112
  "randombytes": "^2.1.0",
113
113
  "sinon": "^16.1.0",
114
114
  "sinon-chai": "^3.7.0",
@@ -116,7 +116,7 @@
116
116
  "terser-webpack-plugin": "^5.3.10",
117
117
  "ts-node": "^10.9.2",
118
118
  "typescript": "^5.4.5",
119
- "webpack": "^5.90.3",
119
+ "webpack": "^5.92.0",
120
120
  "webpack-cli": "^5.1.1"
121
121
  },
122
122
  "dependencies": {
package/types/index.d.ts CHANGED
@@ -988,6 +988,7 @@ export namespace StrKey {
988
988
 
989
989
  function encodeContract(data: Buffer): string;
990
990
  function decodeContract(address: string): Buffer;
991
+ function isValidContract(address: string): boolean;
991
992
  }
992
993
 
993
994
  export namespace SignerKey {