@debridge-finance/solana-utils 6.2.2 → 6.2.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.
@@ -6508,6 +6508,25 @@ var constants$1 = /*#__PURE__*/Object.freeze({
6508
6508
  dlnDst: dlnDst$1
6509
6509
  });
6510
6510
 
6511
+ /**
6512
+ * Losslessly converts a numeric value (up to uint256) into a BN.
6513
+ * Supports numbers, decimal strings, 0x-prefixed hex strings, byte arrays,
6514
+ * Buffers and BN instances.
6515
+ */
6516
+ function toBN(value) {
6517
+ if (value === undefined || value === null)
6518
+ return new BN(0);
6519
+ if (BN.isBN(value))
6520
+ return value;
6521
+ if (typeof value === "string") {
6522
+ if (value.startsWith("0x") || value.startsWith("0X")) {
6523
+ const hex = value.slice(2);
6524
+ return hex ? new BN(hex, "hex") : new BN(0);
6525
+ }
6526
+ return new BN(value, 10);
6527
+ }
6528
+ return new BN(value);
6529
+ }
6511
6530
  var TimestampCheckKind;
6512
6531
  (function (TimestampCheckKind) {
6513
6532
  TimestampCheckKind[TimestampCheckKind["Slot"] = 0] = "Slot";
@@ -6785,6 +6804,7 @@ function sendAll(connection, wallet, transactions, options) {
6785
6804
 
6786
6805
  var helpers = /*#__PURE__*/Object.freeze({
6787
6806
  __proto__: null,
6807
+ toBN: toBN,
6788
6808
  setReplayProtectionIx: setReplayProtectionIx,
6789
6809
  setExpirationTimestampIx: setExpirationTimestampIx,
6790
6810
  getAccountInfo: getAccountInfo,
@@ -7042,7 +7062,7 @@ function getShortcutFromAutoParams(params) {
7042
7062
  return isBuffer(shortcut) ? shortcut : hexToBuffer(shortcut);
7043
7063
  }
7044
7064
  else {
7045
- const flags = BigInt(new BN(((_b = params.autoParams) === null || _b === void 0 ? void 0 : _b.flags) || 0).toNumber());
7065
+ const flags = BigInt(toBN((_b = params.autoParams) === null || _b === void 0 ? void 0 : _b.flags).toString());
7046
7066
  const data = (_c = params.autoParams) === null || _c === void 0 ? void 0 : _c.data;
7047
7067
  if (!data)
7048
7068
  return hashExternalCallBytes(data);
@@ -7102,7 +7122,7 @@ function hashSubmissionIdRaw(params) {
7102
7122
  : new PublicKey(params.autoParams.fallbackAddress).toBuffer();
7103
7123
  packData = packData.concat([
7104
7124
  new BN(((_a = params === null || params === void 0 ? void 0 : params.autoParams) === null || _a === void 0 ? void 0 : _a.executionFee) || 0).toArray("be", 32),
7105
- new BN(((_b = params.autoParams) === null || _b === void 0 ? void 0 : _b.flags) || 0).toArray("be", 32),
7125
+ toBN((_b = params.autoParams) === null || _b === void 0 ? void 0 : _b.flags).toArray("be", 32),
7106
7126
  hashExternalCallBytes(fallback),
7107
7127
  shortcut,
7108
7128
  hashExternalCallBytes(params.autoParams.nativeSender),