@stellar/stellar-base 14.0.1 → 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.
@@ -22689,14 +22689,31 @@ var TransactionBuilder = /*#__PURE__*/function () {
22689
22689
  key: "buildFeeBumpTransaction",
22690
22690
  value: function buildFeeBumpTransaction(feeSource, baseFee, innerTx, networkPassphrase) {
22691
22691
  var innerOps = innerTx.operations.length;
22692
- var innerBaseFeeRate = new util_bignumber(innerTx.fee).div(innerOps);
22692
+ var minBaseFee = new util_bignumber(BASE_FEE);
22693
+ var innerInclusionFee = new util_bignumber(innerTx.fee).div(innerOps);
22694
+ var resourceFee = new util_bignumber(0);
22695
+
22696
+ // Do we need to do special Soroban fee handling? We only want the fee-bump
22697
+ // requirement to match the inclusion fee, not the inclusion+resource fee.
22698
+ var env = innerTx.toEnvelope();
22699
+ switch (env["switch"]().value) {
22700
+ case src_xdr.EnvelopeType.envelopeTypeTx().value:
22701
+ {
22702
+ var _sorobanData$resource;
22703
+ var sorobanData = env.v1().tx().ext().value();
22704
+ resourceFee = new util_bignumber((_sorobanData$resource = sorobanData === null || sorobanData === void 0 ? void 0 : sorobanData.resourceFee()) !== null && _sorobanData$resource !== void 0 ? _sorobanData$resource : 0);
22705
+ innerInclusionFee = util_bignumber.max(minBaseFee, innerInclusionFee.minus(resourceFee));
22706
+ break;
22707
+ }
22708
+ default:
22709
+ break;
22710
+ }
22693
22711
  var base = new util_bignumber(baseFee);
22694
22712
 
22695
22713
  // The fee rate for fee bump is at least the fee rate of the inner transaction
22696
- if (base.lt(innerBaseFeeRate)) {
22697
- throw new Error("Invalid baseFee, it should be at least ".concat(innerBaseFeeRate, " stroops."));
22714
+ if (base.lt(innerInclusionFee)) {
22715
+ throw new Error("Invalid baseFee, it should be at least ".concat(innerInclusionFee, " stroops."));
22698
22716
  }
22699
- var minBaseFee = new util_bignumber(BASE_FEE);
22700
22717
 
22701
22718
  // The fee rate is at least the minimum fee
22702
22719
  if (base.lt(minBaseFee)) {
@@ -22727,7 +22744,7 @@ var TransactionBuilder = /*#__PURE__*/function () {
22727
22744
  }
22728
22745
  var tx = new src_xdr.FeeBumpTransaction({
22729
22746
  feeSource: feeSourceAccount,
22730
- fee: src_xdr.Int64.fromString(base.times(innerOps + 1).toString()),
22747
+ fee: src_xdr.Int64.fromString(base.times(innerOps + 1).plus(resourceFee).toString()),
22731
22748
  innerTx: src_xdr.FeeBumpTransactionInnerTx.envelopeTypeTx(innerTxEnvelope.v1()),
22732
22749
  ext: new src_xdr.FeeBumpTransactionExt(0)
22733
22750
  });
@@ -23224,6 +23241,8 @@ var XdrLargeInt = /*#__PURE__*/function () {
23224
23241
  this["int"] = new Int256(values);
23225
23242
  break;
23226
23243
  case 'u64':
23244
+ case 'timepoint':
23245
+ case 'duration':
23227
23246
  this["int"] = new xdr.UnsignedHyper(values);
23228
23247
  break;
23229
23248
  case 'u128':
@@ -23280,6 +23299,24 @@ var XdrLargeInt = /*#__PURE__*/function () {
23280
23299
  );
23281
23300
  }
23282
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
+
23283
23320
  /**
23284
23321
  * @returns {xdr.ScVal} the integer encoded with `ScValType = I128`
23285
23322
  * @throws {RangeError} if the value cannot fit in 128 bits
@@ -23364,6 +23401,10 @@ var XdrLargeInt = /*#__PURE__*/function () {
23364
23401
  return this.toU128();
23365
23402
  case 'u256':
23366
23403
  return this.toU256();
23404
+ case 'timepoint':
23405
+ return this.toTimepoint();
23406
+ case 'duration':
23407
+ return this.toDuration();
23367
23408
  default:
23368
23409
  throw TypeError("invalid type: ".concat(this.type));
23369
23410
  }
@@ -23403,6 +23444,8 @@ var XdrLargeInt = /*#__PURE__*/function () {
23403
23444
  case 'u64':
23404
23445
  case 'u128':
23405
23446
  case 'u256':
23447
+ case 'timepoint':
23448
+ case 'duration':
23406
23449
  return true;
23407
23450
  default:
23408
23451
  return false;
@@ -23585,6 +23628,8 @@ function scValToBigInt(scv) {
23585
23628
  return BigInt(scv.value());
23586
23629
  case 'scvU64':
23587
23630
  case 'scvI64':
23631
+ case 'scvTimepoint':
23632
+ case 'scvDuration':
23588
23633
  return new XdrLargeInt(scIntType, scv.value()).toBigInt();
23589
23634
  case 'scvU128':
23590
23635
  case 'scvI128':
@@ -23896,7 +23941,7 @@ function nativeToScVal(val) {
23896
23941
  *
23897
23942
  * - void -> `null`
23898
23943
  * - u32, i32 -> `number`
23899
- * - u64, i64, u128, i128, u256, i256 -> `bigint`
23944
+ * - u64, i64, u128, i128, u256, i256, timepoint, duration -> `bigint`
23900
23945
  * - vec -> `Array` of any of the above (via recursion)
23901
23946
  * - map -> key-value object of any of the above (via recursion)
23902
23947
  * - bool -> `boolean`