@stellar/stellar-base 14.0.2 → 14.0.3

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/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## [`v14.0.3`](https://github.com/stellar/js-stellar-base/compare/v14.0.2...v14.0.3):
6
+
7
+ ### Fixed
8
+
9
+ - Add conversions for timepoint and duration scval types ([#819](https://github.com/stellar/js-stellar-base/pull/819))
10
+
5
11
  ## [`v14.0.2`](https://github.com/stellar/js-stellar-base/compare/v14.0.1...v14.0.2):
6
12
 
7
13
  ### Fixed
@@ -23241,6 +23241,8 @@ var XdrLargeInt = /*#__PURE__*/function () {
23241
23241
  this["int"] = new Int256(values);
23242
23242
  break;
23243
23243
  case 'u64':
23244
+ case 'timepoint':
23245
+ case 'duration':
23244
23246
  this["int"] = new xdr.UnsignedHyper(values);
23245
23247
  break;
23246
23248
  case 'u128':
@@ -23297,6 +23299,24 @@ var XdrLargeInt = /*#__PURE__*/function () {
23297
23299
  );
23298
23300
  }
23299
23301
 
23302
+ /** @returns {xdr.ScVal} the integer encoded with `ScValType = Timepoint` */
23303
+ }, {
23304
+ key: "toTimepoint",
23305
+ value: function toTimepoint() {
23306
+ this._sizeCheck(64);
23307
+ return src_xdr.ScVal.scvTimepoint(new src_xdr.Uint64(BigInt.asUintN(64, this.toBigInt())) // reiterpret as unsigned
23308
+ );
23309
+ }
23310
+
23311
+ /** @returns {xdr.ScVal} the integer encoded with `ScValType = Duration` */
23312
+ }, {
23313
+ key: "toDuration",
23314
+ value: function toDuration() {
23315
+ this._sizeCheck(64);
23316
+ return src_xdr.ScVal.scvDuration(new src_xdr.Uint64(BigInt.asUintN(64, this.toBigInt())) // reiterpret as unsigned
23317
+ );
23318
+ }
23319
+
23300
23320
  /**
23301
23321
  * @returns {xdr.ScVal} the integer encoded with `ScValType = I128`
23302
23322
  * @throws {RangeError} if the value cannot fit in 128 bits
@@ -23381,6 +23401,10 @@ var XdrLargeInt = /*#__PURE__*/function () {
23381
23401
  return this.toU128();
23382
23402
  case 'u256':
23383
23403
  return this.toU256();
23404
+ case 'timepoint':
23405
+ return this.toTimepoint();
23406
+ case 'duration':
23407
+ return this.toDuration();
23384
23408
  default:
23385
23409
  throw TypeError("invalid type: ".concat(this.type));
23386
23410
  }
@@ -23420,6 +23444,8 @@ var XdrLargeInt = /*#__PURE__*/function () {
23420
23444
  case 'u64':
23421
23445
  case 'u128':
23422
23446
  case 'u256':
23447
+ case 'timepoint':
23448
+ case 'duration':
23423
23449
  return true;
23424
23450
  default:
23425
23451
  return false;
@@ -23602,6 +23628,8 @@ function scValToBigInt(scv) {
23602
23628
  return BigInt(scv.value());
23603
23629
  case 'scvU64':
23604
23630
  case 'scvI64':
23631
+ case 'scvTimepoint':
23632
+ case 'scvDuration':
23605
23633
  return new XdrLargeInt(scIntType, scv.value()).toBigInt();
23606
23634
  case 'scvU128':
23607
23635
  case 'scvI128':
@@ -23913,7 +23941,7 @@ function nativeToScVal(val) {
23913
23941
  *
23914
23942
  * - void -> `null`
23915
23943
  * - u32, i32 -> `number`
23916
- * - u64, i64, u128, i128, u256, i256 -> `bigint`
23944
+ * - u64, i64, u128, i128, u256, i256, timepoint, duration -> `bigint`
23917
23945
  * - vec -> `Array` of any of the above (via recursion)
23918
23946
  * - map -> key-value object of any of the above (via recursion)
23919
23947
  * - bool -> `boolean`