@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.
@@ -72,6 +72,8 @@ function scValToBigInt(scv) {
72
72
  return BigInt(scv.value());
73
73
  case 'scvU64':
74
74
  case 'scvI64':
75
+ case 'scvTimepoint':
76
+ case 'scvDuration':
75
77
  return new _xdr_large_int.XdrLargeInt(scIntType, scv.value()).toBigInt();
76
78
  case 'scvU128':
77
79
  case 'scvI128':
@@ -65,6 +65,8 @@ var XdrLargeInt = exports.XdrLargeInt = /*#__PURE__*/function () {
65
65
  this["int"] = new _int2.Int256(values);
66
66
  break;
67
67
  case 'u64':
68
+ case 'timepoint':
69
+ case 'duration':
68
70
  this["int"] = new _jsXdr.UnsignedHyper(values);
69
71
  break;
70
72
  case 'u128':
@@ -121,6 +123,24 @@ var XdrLargeInt = exports.XdrLargeInt = /*#__PURE__*/function () {
121
123
  );
122
124
  }
123
125
 
126
+ /** @returns {xdr.ScVal} the integer encoded with `ScValType = Timepoint` */
127
+ }, {
128
+ key: "toTimepoint",
129
+ value: function toTimepoint() {
130
+ this._sizeCheck(64);
131
+ return _xdr["default"].ScVal.scvTimepoint(new _xdr["default"].Uint64(BigInt.asUintN(64, this.toBigInt())) // reiterpret as unsigned
132
+ );
133
+ }
134
+
135
+ /** @returns {xdr.ScVal} the integer encoded with `ScValType = Duration` */
136
+ }, {
137
+ key: "toDuration",
138
+ value: function toDuration() {
139
+ this._sizeCheck(64);
140
+ return _xdr["default"].ScVal.scvDuration(new _xdr["default"].Uint64(BigInt.asUintN(64, this.toBigInt())) // reiterpret as unsigned
141
+ );
142
+ }
143
+
124
144
  /**
125
145
  * @returns {xdr.ScVal} the integer encoded with `ScValType = I128`
126
146
  * @throws {RangeError} if the value cannot fit in 128 bits
@@ -205,6 +225,10 @@ var XdrLargeInt = exports.XdrLargeInt = /*#__PURE__*/function () {
205
225
  return this.toU128();
206
226
  case 'u256':
207
227
  return this.toU256();
228
+ case 'timepoint':
229
+ return this.toTimepoint();
230
+ case 'duration':
231
+ return this.toDuration();
208
232
  default:
209
233
  throw TypeError("invalid type: ".concat(this.type));
210
234
  }
@@ -244,6 +268,8 @@ var XdrLargeInt = exports.XdrLargeInt = /*#__PURE__*/function () {
244
268
  case 'u64':
245
269
  case 'u128':
246
270
  case 'u256':
271
+ case 'timepoint':
272
+ case 'duration':
247
273
  return true;
248
274
  default:
249
275
  return false;
package/lib/scval.js CHANGED
@@ -303,7 +303,7 @@ function nativeToScVal(val) {
303
303
  *
304
304
  * - void -> `null`
305
305
  * - u32, i32 -> `number`
306
- * - u64, i64, u128, i128, u256, i256 -> `bigint`
306
+ * - u64, i64, u128, i128, u256, i256, timepoint, duration -> `bigint`
307
307
  * - vec -> `Array` of any of the above (via recursion)
308
308
  * - map -> key-value object of any of the above (via recursion)
309
309
  * - bool -> `boolean`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stellar/stellar-base",
3
- "version": "14.0.2",
3
+ "version": "14.0.3",
4
4
  "description": "Low-level support library for the Stellar network.",
5
5
  "main": "./lib/index.js",
6
6
  "browser": {