@stellar/stellar-base 13.1.0 → 14.0.0-rc.2

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.
package/lib/index.js CHANGED
@@ -9,7 +9,6 @@ var _exportNames = {
9
9
  hash: true,
10
10
  sign: true,
11
11
  verify: true,
12
- FastSigning: true,
13
12
  getLiquidityPoolId: true,
14
13
  LiquidityPoolFeeV18: true,
15
14
  Keypair: true,
@@ -103,12 +102,6 @@ Object.defineProperty(exports, "Contract", {
103
102
  return _contract.Contract;
104
103
  }
105
104
  });
106
- Object.defineProperty(exports, "FastSigning", {
107
- enumerable: true,
108
- get: function get() {
109
- return _signing.FastSigning;
110
- }
111
- });
112
105
  Object.defineProperty(exports, "FeeBumpTransaction", {
113
106
  enumerable: true,
114
107
  get: function get() {
package/lib/keypair.js CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Keypair = void 0;
7
- var _tweetnacl = _interopRequireDefault(require("tweetnacl"));
7
+ var _ed = require("@noble/curves/ed25519");
8
8
  var _signing = require("./signing");
9
9
  var _strkey = require("./strkey");
10
10
  var _hashing = require("./hashing");
@@ -47,7 +47,7 @@ var Keypair = exports.Keypair = /*#__PURE__*/function () {
47
47
  }
48
48
  this._secretSeed = keys.secretKey;
49
49
  this._publicKey = (0, _signing.generate)(keys.secretKey);
50
- this._secretKey = Buffer.concat([keys.secretKey, this._publicKey]);
50
+ this._secretKey = keys.secretKey;
51
51
  if (keys.publicKey && !this._publicKey.equals(Buffer.from(keys.publicKey))) {
52
52
  throw new Error('secretKey does not match publicKey');
53
53
  }
@@ -62,7 +62,7 @@ var Keypair = exports.Keypair = /*#__PURE__*/function () {
62
62
  /**
63
63
  * Creates a new `Keypair` instance from secret. This can either be secret key or secret seed depending
64
64
  * on underlying public-key signature system. Currently `Keypair` only supports ed25519.
65
- * @param {string} secret secret key (ex. `SDAKFNYEIAORZKKCYRILFQKLLOCNPL5SWJ3YY5NM3ZH6GJSZGXHZEPQS`)
65
+ * @param {string} secret secret key (ex. `SDAK....`)
66
66
  * @returns {Keypair}
67
67
  */
68
68
  return _createClass(Keypair, [{
@@ -300,7 +300,7 @@ var Keypair = exports.Keypair = /*#__PURE__*/function () {
300
300
  }, {
301
301
  key: "random",
302
302
  value: function random() {
303
- var secret = _tweetnacl["default"].randomBytes(32);
303
+ var secret = _ed.ed25519.utils.randomPrivateKey();
304
304
  return this.fromRawEd25519Seed(secret);
305
305
  }
306
306
  }]);
@@ -25,9 +25,9 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
25
25
  * the type / width / size in bits of the integer you're targeting, regardless
26
26
  * of the input value(s) you provide.
27
27
  *
28
- * @param {string} type - force a specific data type. the type choices are:
29
- * 'i64', 'u64', 'i128', 'u128', 'i256', and 'u256' (default: the smallest
30
- * one that fits the `value`) (see {@link XdrLargeInt.isType})
28
+ * @param {string} type - specifies a data type to use to represent the, one
29
+ * of: 'i64', 'u64', 'i128', 'u128', 'i256', and 'u256' (see
30
+ * {@link XdrLargeInt.isType})
31
31
  * @param {number|bigint|string|Array<number|bigint|string>} values a list of
32
32
  * integer-like values interpreted in big-endian order
33
33
  */
@@ -49,7 +49,7 @@ var XdrLargeInt = exports.XdrLargeInt = /*#__PURE__*/function () {
49
49
  if (typeof i === 'bigint') {
50
50
  return i;
51
51
  }
52
- if (i instanceof XdrLargeInt) {
52
+ if (typeof i.toBigInt === 'function') {
53
53
  return i.toBigInt();
54
54
  }
55
55
  return BigInt(i);
package/lib/operation.js CHANGED
@@ -16,8 +16,7 @@ var _liquidity_pool_id = require("./liquidity_pool_id");
16
16
  var _xdr = _interopRequireDefault(require("./xdr"));
17
17
  var ops = _interopRequireWildcard(require("./operations"));
18
18
  var _decode_encode_muxed_account = require("./util/decode_encode_muxed_account");
19
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
20
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
19
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
21
20
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
22
21
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
23
22
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
@@ -46,6 +46,25 @@ function invokeHostFunction(opts) {
46
46
  if (!opts.func) {
47
47
  throw new TypeError("host function invocation ('func') required (got ".concat(JSON.stringify(opts), ")"));
48
48
  }
49
+ if (opts.func["switch"]().value === _xdr["default"].HostFunctionType.hostFunctionTypeInvokeContract().value) {
50
+ // Ensure that there are no claimable balance or liquidity pool IDs in the
51
+ // invocation because those are not allowed.
52
+ opts.func.invokeContract().args().forEach(function (arg) {
53
+ var scv;
54
+ try {
55
+ scv = _address.Address.fromScVal(arg);
56
+ } catch (_unused) {
57
+ // swallow non-Address errors
58
+ return;
59
+ }
60
+ switch (scv._type) {
61
+ case 'claimableBalance':
62
+ case 'liquidityPool':
63
+ throw new TypeError("claimable balances and liquidity pools cannot be arguments to invokeHostFunction");
64
+ default:
65
+ }
66
+ });
67
+ }
49
68
  var invokeHostFunctionOp = new _xdr["default"].InvokeHostFunctionOp({
50
69
  hostFunction: opts.func,
51
70
  auth: opts.auth || []
@@ -219,7 +238,7 @@ function uploadContractWasm(opts) {
219
238
  });
220
239
  }
221
240
 
222
- /** @returns {Buffer} a random 256-bit "salt" value. */
241
+ /* Returns a random 256-bit "salt" value. */
223
242
  function getSalty() {
224
243
  return _keypair.Keypair.random().xdrPublicKey().value(); // ed25519 is 256 bits, too
225
244
  }
package/lib/scval.js CHANGED
@@ -17,6 +17,11 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
17
17
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
18
18
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
19
19
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
20
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
21
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
22
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
23
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
24
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
20
25
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
21
26
  /**
22
27
  * Attempts to convert native types into smart contract values
@@ -104,6 +109,9 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
104
109
  * nativeToScVal(true); // scvBool
105
110
  * nativeToScVal([1, 2, 3]); // gives scvVec with each element as scvU64
106
111
  * nativeToScVal([1, 2, 3], { type: 'i128' }); // scvVec<scvI128>
112
+ * nativeToScVal([1, '2'], { type: ['i128', 'symbol'] }); // scvVec with diff types
113
+ * nativeToScVal([1, '2', 3], { type: ['i128', 'symbol'] });
114
+ * // scvVec with diff types, using the default when omitted
107
115
  * nativeToScVal({ 'hello': 1, 'world': [ true, false ] }, {
108
116
  * type: {
109
117
  * 'hello': [ 'symbol', 'i128' ],
@@ -139,6 +147,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
139
147
  * etc: false
140
148
  * },
141
149
  * vec: ['same', 'type', 'list'],
150
+ * vec: ['diff', 1, 'type', 2, 'list'],
142
151
  * };
143
152
  *
144
153
  * // then, simply:
@@ -188,7 +197,18 @@ function nativeToScVal(val) {
188
197
  }
189
198
  }
190
199
  if (Array.isArray(val)) {
191
- return _xdr["default"].ScVal.scvVec(val.map(function (v) {
200
+ return _xdr["default"].ScVal.scvVec(val.map(function (v, idx) {
201
+ // There may be different type specifications for each element in
202
+ // the array, so we need to apply those accordingly.
203
+ if (Array.isArray(opts.type)) {
204
+ return nativeToScVal(v, // only include a `{ type: ... }` if it's present (safer than
205
+ // `{type: undefined}`)
206
+ _objectSpread({}, opts.type.length > idx && {
207
+ type: opts.type[idx]
208
+ }));
209
+ }
210
+
211
+ // Otherwise apply a generic (or missing) type specifier on it.
192
212
  return nativeToScVal(v, opts);
193
213
  }));
194
214
  }
package/lib/signing.js CHANGED
@@ -3,94 +3,18 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.FastSigning = void 0;
7
6
  exports.generate = generate;
8
7
  exports.sign = sign;
9
8
  exports.verify = verify;
10
- // This module provides the signing functionality used by the stellar network
11
- // The code below may look a little strange... this is because we try to provide
12
- // the most efficient signing method possible. First, we try to load the
13
- // native `sodium-native` package for node.js environments, and if that fails we
14
- // fallback to `tweetnacl`
15
-
16
- var actualMethods = {};
17
-
18
- /**
19
- * Use this flag to check if fast signing (provided by `sodium-native` package) is available.
20
- * If your app is signing a large number of transaction or verifying a large number
21
- * of signatures make sure `sodium-native` package is installed.
22
- */
23
- var FastSigning = exports.FastSigning = checkFastSigning();
24
- function sign(data, secretKey) {
25
- return actualMethods.sign(data, secretKey);
26
- }
27
- function verify(data, signature, publicKey) {
28
- return actualMethods.verify(data, signature, publicKey);
29
- }
9
+ var _ed = require("@noble/curves/ed25519");
30
10
  function generate(secretKey) {
31
- return actualMethods.generate(secretKey);
32
- }
33
- function checkFastSigning() {
34
- return typeof window === 'undefined' ? checkFastSigningNode() : checkFastSigningBrowser();
11
+ return Buffer.from(_ed.ed25519.getPublicKey(secretKey));
35
12
  }
36
- function checkFastSigningNode() {
37
- // NOTE: we use commonjs style require here because es6 imports
38
- // can only occur at the top level. thanks, obama.
39
- var sodium;
40
- try {
41
- // eslint-disable-next-line
42
- sodium = require('sodium-native');
43
- } catch (err) {
44
- return checkFastSigningBrowser();
45
- }
46
- if (!Object.keys(sodium).length) {
47
- return checkFastSigningBrowser();
48
- }
49
- actualMethods.generate = function (secretKey) {
50
- var pk = Buffer.alloc(sodium.crypto_sign_PUBLICKEYBYTES);
51
- var sk = Buffer.alloc(sodium.crypto_sign_SECRETKEYBYTES);
52
- sodium.crypto_sign_seed_keypair(pk, sk, secretKey);
53
- return pk;
54
- };
55
- actualMethods.sign = function (data, secretKey) {
56
- data = Buffer.from(data);
57
- var signature = Buffer.alloc(sodium.crypto_sign_BYTES);
58
- sodium.crypto_sign_detached(signature, data, secretKey);
59
- return signature;
60
- };
61
- actualMethods.verify = function (data, signature, publicKey) {
62
- data = Buffer.from(data);
63
- try {
64
- return sodium.crypto_sign_verify_detached(signature, data, publicKey);
65
- } catch (e) {
66
- return false;
67
- }
68
- };
69
- return true;
13
+ function sign(data, secretKey) {
14
+ return Buffer.from(_ed.ed25519.sign(Buffer.from(data), secretKey));
70
15
  }
71
- function checkFastSigningBrowser() {
72
- // fallback to `tweetnacl` if we're in the browser or
73
- // if there was a failure installing `sodium-native`
74
- // eslint-disable-next-line
75
- var nacl = require('tweetnacl');
76
- actualMethods.generate = function (secretKey) {
77
- var secretKeyUint8 = new Uint8Array(secretKey);
78
- var naclKeys = nacl.sign.keyPair.fromSeed(secretKeyUint8);
79
- return Buffer.from(naclKeys.publicKey);
80
- };
81
- actualMethods.sign = function (data, secretKey) {
82
- data = Buffer.from(data);
83
- data = new Uint8Array(data.toJSON().data);
84
- secretKey = new Uint8Array(secretKey.toJSON().data);
85
- var signature = nacl.sign.detached(data, secretKey);
86
- return Buffer.from(signature);
87
- };
88
- actualMethods.verify = function (data, signature, publicKey) {
89
- data = Buffer.from(data);
90
- data = new Uint8Array(data.toJSON().data);
91
- signature = new Uint8Array(signature.toJSON().data);
92
- publicKey = new Uint8Array(publicKey.toJSON().data);
93
- return nacl.sign.detached.verify(data, signature, publicKey);
94
- };
95
- return false;
16
+ function verify(data, signature, publicKey) {
17
+ return _ed.ed25519.verify(Buffer.from(signature), Buffer.from(data), Buffer.from(publicKey), {
18
+ zip215: false
19
+ });
96
20
  }
@@ -56,10 +56,10 @@ var SorobanDataBuilder = exports.SorobanDataBuilder = /*#__PURE__*/function () {
56
56
  readWrite: []
57
57
  }),
58
58
  instructions: 0,
59
- readBytes: 0,
59
+ diskReadBytes: 0,
60
60
  writeBytes: 0
61
61
  }),
62
- ext: new _xdr["default"].ExtensionPoint(0),
62
+ ext: new _xdr["default"].SorobanTransactionDataExt(0),
63
63
  resourceFee: new _xdr["default"].Int64(0)
64
64
  });
65
65
  } else if (typeof sorobanData === 'string' || ArrayBuffer.isView(sorobanData)) {
@@ -95,16 +95,16 @@ var SorobanDataBuilder = exports.SorobanDataBuilder = /*#__PURE__*/function () {
95
95
  * by transaction simulation/preflight from a Soroban RPC server.
96
96
  *
97
97
  * @param {number} cpuInstrs number of CPU instructions
98
- * @param {number} readBytes number of bytes being read
99
- * @param {number} writeBytes number of bytes being written
98
+ * @param {number} diskReadBytes number of bytes being read from disk
99
+ * @param {number} writeBytes number of bytes being written to disk/memory
100
100
  *
101
101
  * @returns {SorobanDataBuilder}
102
102
  */
103
103
  }, {
104
104
  key: "setResources",
105
- value: function setResources(cpuInstrs, readBytes, writeBytes) {
105
+ value: function setResources(cpuInstrs, diskReadBytes, writeBytes) {
106
106
  this._data.resources().instructions(cpuInstrs);
107
- this._data.resources().readBytes(readBytes);
107
+ this._data.resources().diskReadBytes(diskReadBytes);
108
108
  this._data.resources().writeBytes(writeBytes);
109
109
  return this;
110
110
  }
package/lib/strkey.js CHANGED
@@ -13,6 +13,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
13
13
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
14
14
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
15
15
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
16
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
16
17
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
17
18
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /* eslint no-bitwise: ["error", {"allow": ["<<", ">>", "^", "&", "&="]}] */
18
19
  var versionBytes = {
@@ -28,7 +29,11 @@ var versionBytes = {
28
29
  // X
29
30
  signedPayload: 15 << 3,
30
31
  // P
31
- contract: 2 << 3 // C
32
+ contract: 2 << 3,
33
+ // C
34
+ liquidityPool: 11 << 3,
35
+ // L
36
+ claimableBalance: 1 << 3 // B
32
37
  };
33
38
  var strkeyTypes = {
34
39
  G: 'ed25519PublicKey',
@@ -37,7 +42,9 @@ var strkeyTypes = {
37
42
  T: 'preAuthTx',
38
43
  X: 'sha256Hash',
39
44
  P: 'signedPayload',
40
- C: 'contract'
45
+ C: 'contract',
46
+ L: 'liquidityPool',
47
+ B: 'claimableBalance'
41
48
  };
42
49
 
43
50
  /**
@@ -263,6 +270,72 @@ var StrKey = exports.StrKey = /*#__PURE__*/function () {
263
270
  value: function isValidContract(address) {
264
271
  return isValid('contract', address);
265
272
  }
273
+
274
+ /**
275
+ * Encodes raw data to strkey claimable balance (B...).
276
+ * @param {Buffer} data data to encode
277
+ * @returns {string}
278
+ */
279
+ }, {
280
+ key: "encodeClaimableBalance",
281
+ value: function encodeClaimableBalance(data) {
282
+ return encodeCheck('claimableBalance', data);
283
+ }
284
+
285
+ /**
286
+ * Decodes strkey contract (B...) to raw data.
287
+ * @param {string} address balance to decode
288
+ * @returns {Buffer}
289
+ */
290
+ }, {
291
+ key: "decodeClaimableBalance",
292
+ value: function decodeClaimableBalance(address) {
293
+ return decodeCheck('claimableBalance', address);
294
+ }
295
+
296
+ /**
297
+ * Checks validity of alleged claimable balance (B...) strkey address.
298
+ * @param {string} address balance to check
299
+ * @returns {boolean}
300
+ */
301
+ }, {
302
+ key: "isValidClaimableBalance",
303
+ value: function isValidClaimableBalance(address) {
304
+ return isValid('claimableBalance', address);
305
+ }
306
+
307
+ /**
308
+ * Encodes raw data to strkey liquidity pool (L...).
309
+ * @param {Buffer} data data to encode
310
+ * @returns {string}
311
+ */
312
+ }, {
313
+ key: "encodeLiquidityPool",
314
+ value: function encodeLiquidityPool(data) {
315
+ return encodeCheck('liquidityPool', data);
316
+ }
317
+
318
+ /**
319
+ * Decodes strkey liquidity pool (L...) to raw data.
320
+ * @param {string} address address to decode
321
+ * @returns {Buffer}
322
+ */
323
+ }, {
324
+ key: "decodeLiquidityPool",
325
+ value: function decodeLiquidityPool(address) {
326
+ return decodeCheck('liquidityPool', address);
327
+ }
328
+
329
+ /**
330
+ * Checks validity of alleged liquidity pool (L...) strkey address.
331
+ * @param {string} address pool to check
332
+ * @returns {boolean}
333
+ */
334
+ }, {
335
+ key: "isValidLiquidityPool",
336
+ value: function isValidLiquidityPool(address) {
337
+ return isValid('liquidityPool', address);
338
+ }
266
339
  }, {
267
340
  key: "getVersionByteForPrefix",
268
341
  value: function getVersionByteForPrefix(address) {
@@ -283,6 +356,7 @@ var StrKey = exports.StrKey = /*#__PURE__*/function () {
283
356
  * check based on (a) input length, (b) whether or not it can be decoded,
284
357
  * and (c) output length.
285
358
  */
359
+ _defineProperty(StrKey, "types", strkeyTypes);
286
360
  function isValid(versionByteName, encoded) {
287
361
  if (typeof encoded !== 'string') {
288
362
  return false;
@@ -294,11 +368,17 @@ function isValid(versionByteName, encoded) {
294
368
  case 'ed25519SecretSeed': // falls through
295
369
  case 'preAuthTx': // falls through
296
370
  case 'sha256Hash': // falls through
297
- case 'contract':
371
+ case 'contract': // falls through
372
+ case 'liquidityPool':
298
373
  if (encoded.length !== 56) {
299
374
  return false;
300
375
  }
301
376
  break;
377
+ case 'claimableBalance':
378
+ if (encoded.length !== 58) {
379
+ return false;
380
+ }
381
+ break;
302
382
  case 'med25519PublicKey':
303
383
  if (encoded.length !== 69) {
304
384
  return false;
@@ -326,7 +406,12 @@ function isValid(versionByteName, encoded) {
326
406
  case 'preAuthTx': // falls through
327
407
  case 'sha256Hash': // falls through
328
408
  case 'contract':
409
+ case 'liquidityPool':
329
410
  return decoded.length === 32;
411
+ case 'claimableBalance':
412
+ return decoded.length === 32 + 1;
413
+ // +1 byte for discriminant
414
+
330
415
  case 'med25519PublicKey':
331
416
  return decoded.length === 40;
332
417
  // +8 bytes for the ID
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "@stellar/stellar-base",
3
- "version": "13.1.0",
3
+ "version": "14.0.0-rc.2",
4
4
  "description": "Low-level support library for the Stellar network.",
5
5
  "main": "./lib/index.js",
6
6
  "browser": {
7
- "main": "./dist/stellar-base.min.js",
8
- "sodium-native": false
7
+ "./lib/index.js": "./dist/stellar-base.min.js"
9
8
  },
10
9
  "types": "./types/index.d.ts",
11
10
  "scripts": {
@@ -16,7 +15,7 @@
16
15
  "build:browser:prod": "cross-env NODE_ENV=production yarn build:browser",
17
16
  "build:prod": "cross-env NODE_ENV=production yarn build",
18
17
  "test": "yarn build && yarn test:node && yarn test:browser",
19
- "test:node": "NODE_OPTIONS=$(test ! $(node -v | awk -F'.' '{printf substr($1,2)}') = '18' && echo '--no-experimental-detect-module') yarn _nyc mocha",
18
+ "test:node": "NODE_OPTIONS=--no-experimental-detect-module yarn _nyc mocha",
20
19
  "test:browser": "karma start ./config/karma.conf.js",
21
20
  "docs": "jsdoc -c ./config/.jsdoc.json --verbose",
22
21
  "lint": "eslint -c ./config/.eslintrc.js src/ && dtslint --localTs node_modules/typescript/lib types/",
@@ -27,7 +26,7 @@
27
26
  "_nyc": "nyc --nycrc-path ./config/.nycrc"
28
27
  },
29
28
  "engines": {
30
- "node": ">=18.0.0"
29
+ "node": ">=20.0.0"
31
30
  },
32
31
  "mocha": {
33
32
  "require": [
@@ -73,12 +72,12 @@
73
72
  },
74
73
  "homepage": "https://github.com/stellar/js-stellar-base",
75
74
  "devDependencies": {
76
- "@babel/cli": "^7.27.0",
77
- "@babel/core": "^7.26.10",
78
- "@babel/eslint-parser": "^7.27.0",
79
- "@babel/eslint-plugin": "^7.27.0",
80
- "@babel/preset-env": "^7.26.9",
81
- "@babel/register": "^7.25.9",
75
+ "@babel/cli": "^7.27.2",
76
+ "@babel/core": "^7.27.4",
77
+ "@babel/eslint-parser": "^7.27.5",
78
+ "@babel/eslint-plugin": "^7.27.1",
79
+ "@babel/preset-env": "^7.27.2",
80
+ "@babel/register": "^7.27.1",
82
81
  "@definitelytyped/dtslint": "^0.0.182",
83
82
  "@istanbuljs/nyc-config-babel": "3.0.0",
84
83
  "@types/node": "^20.14.11",
@@ -94,7 +93,7 @@
94
93
  "eslint-plugin-import": "^2.31.0",
95
94
  "eslint-plugin-node": "^11.1.0",
96
95
  "eslint-plugin-prefer-import": "^0.0.1",
97
- "eslint-plugin-prettier": "^5.2.5",
96
+ "eslint-plugin-prettier": "^5.5.0",
98
97
  "eslint-webpack-plugin": "^4.2.0",
99
98
  "ghooks": "^2.0.4",
100
99
  "husky": "^8.0.3",
@@ -119,18 +118,15 @@
119
118
  "terser-webpack-plugin": "^5.3.14",
120
119
  "ts-node": "^10.9.2",
121
120
  "typescript": "5.6.3",
122
- "webpack": "^5.98.0",
121
+ "webpack": "^5.99.9",
123
122
  "webpack-cli": "^5.1.1"
124
123
  },
125
124
  "dependencies": {
125
+ "@noble/curves": "^1.9.2",
126
126
  "@stellar/js-xdr": "^3.1.2",
127
127
  "base32.js": "^0.1.0",
128
- "bignumber.js": "^9.1.2",
128
+ "bignumber.js": "^9.3.0",
129
129
  "buffer": "^6.0.3",
130
- "sha.js": "^2.3.6",
131
- "tweetnacl": "^1.0.3"
132
- },
133
- "optionalDependencies": {
134
- "sodium-native": "^4.3.3"
130
+ "sha.js": "^2.3.6"
135
131
  }
136
132
  }