@debridge-finance/solana-utils 4.5.1 → 4.5.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.
@@ -6664,7 +6664,9 @@ function sendAll(connection, wallet, transactions, options) {
6664
6664
  if (!skipPreflight) {
6665
6665
  yield Promise.all(transactions.map((tx) => simulateTx(connection, tx, simulationCommitment, wallet.publicKey, convertIntoTxV0, skipSign)));
6666
6666
  }
6667
- const blockhashResponse = yield connection.getLatestBlockhashAndContext({ commitment: blockhashCommitment });
6667
+ const blockhashResponse = yield connection.getLatestBlockhashAndContext({
6668
+ commitment: blockhashCommitment,
6669
+ });
6668
6670
  let signed = transactions;
6669
6671
  if (!skipSign) {
6670
6672
  // set real blockhash
@@ -6679,7 +6681,9 @@ function sendAll(connection, wallet, transactions, options) {
6679
6681
  return connection.sendEncodedTransaction(serialized, {
6680
6682
  preflightCommitment: simulationCommitment,
6681
6683
  skipPreflight: false,
6682
- minContextSlot: useMinContextSlot ? blockhashResponse.context.slot + 1 : undefined,
6684
+ minContextSlot: useMinContextSlot
6685
+ ? blockhashResponse.context.slot + 1
6686
+ : undefined,
6683
6687
  });
6684
6688
  }));
6685
6689
  }
@@ -6933,10 +6937,8 @@ function hashExternalCallBytes(data) {
6933
6937
  if (data === undefined || (data === null || data === void 0 ? void 0 : data.length) === 0) {
6934
6938
  // precomputed "empty" hash
6935
6939
  return buffer.Buffer.from([
6936
- 197, 210, 70, 1, 134, 247, 35, 60,
6937
- 146, 126, 125, 178, 220, 199, 3, 192,
6938
- 229, 0, 182, 83, 202, 130, 39, 59,
6939
- 123, 250, 216, 4, 93, 133, 164, 112
6940
+ 197, 210, 70, 1, 134, 247, 35, 60, 146, 126, 125, 178, 220, 199, 3, 192,
6941
+ 229, 0, 182, 83, 202, 130, 39, 59, 123, 250, 216, 4, 93, 133, 164, 112,
6940
6942
  ]);
6941
6943
  }
6942
6944
  return hexToBuffer(solidityKeccak256(["bytes"], [data ? data : buffer.Buffer.from([])]), 32);
@@ -7485,9 +7487,7 @@ const DlnSrc = {
7485
7487
  getFeeLedgerAddress: (DLN_SRC_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnSrc$1.Seeds.FEE_LEDGER)], DLN_SRC_PROGRAM_ID),
7486
7488
  };
7487
7489
  const DlnDst = {
7488
- getStateAddress: (DLN_DST_PROGRAM_ID) => {
7489
- PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnDst$1.Seeds.STATE)], DLN_DST_PROGRAM_ID);
7490
- },
7490
+ getStateAddress: (DLN_DST_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnDst$1.Seeds.STATE)], DLN_DST_PROGRAM_ID),
7491
7491
  getAuthorizedSrcContractAddress: (chainId, DLN_DST_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnDst$1.Seeds.AUTHORIZED_SRC_CONTRACT), chainId], DLN_DST_PROGRAM_ID),
7492
7492
  getAuthorizedDstNativeSenderAddress: (DLN_DST_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnDst$1.Seeds.AUTHORIZED_DST_NATIVE_SENDER)], DLN_DST_PROGRAM_ID),
7493
7493
  getTakeOrderStateAddress: (orderId, DLN_DST_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnDst$1.Seeds.ORDER_STATE), orderId], DLN_DST_PROGRAM_ID),
@@ -7524,37 +7524,37 @@ class ResolverContainer2 {
7524
7524
  }
7525
7525
  const DeBridgeResolver = (programId, settingsProgramId) => {
7526
7526
  const deBridgeMemoizeList = {
7527
- "getClaimMarkerAddress": {},
7528
- "getNonceAddress": {},
7529
- "getMintAuthorityAddress": { maxSize: 20 }
7527
+ getClaimMarkerAddress: {},
7528
+ getNonceAddress: {},
7529
+ getMintAuthorityAddress: { maxSize: 20 },
7530
7530
  };
7531
7531
  const settingsMemoizeList = {
7532
- "getTokenMetadataMasterAddress": {},
7533
- "getTokenMintAddress": { maxSize: 5 },
7534
- "getStateAddress": {},
7535
- "getBridgeFeeAddress": { maxSize: 40 },
7536
- "getChainSupportInfoAddress": { maxSize: 10 },
7537
- "getBridgeAddress": { maxSize: 10 },
7538
- "getBridgeMapAddress": { maxSize: 10 },
7539
- "getNoBridgeFeeAddress": {},
7540
- "getNoDiscountAddress": {},
7532
+ getTokenMetadataMasterAddress: {},
7533
+ getTokenMintAddress: { maxSize: 5 },
7534
+ getStateAddress: {},
7535
+ getBridgeFeeAddress: { maxSize: 40 },
7536
+ getChainSupportInfoAddress: { maxSize: 10 },
7537
+ getBridgeAddress: { maxSize: 10 },
7538
+ getBridgeMapAddress: { maxSize: 10 },
7539
+ getNoBridgeFeeAddress: {},
7540
+ getNoDiscountAddress: {},
7541
7541
  };
7542
7542
  return new ResolverContainer2(new Resolver(programId, deBridge$1, deBridgeMemoizeList), new Resolver(settingsProgramId, deBridgeSettings, settingsMemoizeList));
7543
7543
  };
7544
7544
  const dlnSrcResolver = (programId) => {
7545
7545
  const dlnMemoizeList = {
7546
- "getStateAccount": {},
7547
- "getAuthorizedNativeSenderAddress": { maxSize: 10 },
7548
- "getFeeLedgerAddress": {},
7549
- "getFeeLedgerWalletAddress": { maxSize: 10 }
7546
+ getStateAccount: {},
7547
+ getAuthorizedNativeSenderAddress: { maxSize: 10 },
7548
+ getFeeLedgerAddress: {},
7549
+ getFeeLedgerWalletAddress: { maxSize: 10 },
7550
7550
  };
7551
7551
  return new Resolver(programId, DlnSrc, dlnMemoizeList);
7552
7552
  };
7553
7553
  const dlnDstResolver = (programId) => {
7554
7554
  const dstMemoizeList = {
7555
- "getAuthorizedSrcContractAddress": { maxSize: 10 },
7556
- "getAuthorizedDstNativeSenderAddress": {},
7557
- "getStateAddress": {},
7555
+ getAuthorizedSrcContractAddress: { maxSize: 10 },
7556
+ getAuthorizedDstNativeSenderAddress: {},
7557
+ getStateAddress: {},
7558
7558
  };
7559
7559
  return new Resolver(programId, DlnDst, dstMemoizeList);
7560
7560
  };
@@ -10074,7 +10074,7 @@ function parseSplAccount(dataOrInfo) {
10074
10074
  if (dataOrInfo === null) {
10075
10075
  return null;
10076
10076
  }
10077
- const data = 'executable' in dataOrInfo ? dataOrInfo.data : dataOrInfo;
10077
+ const data = "executable" in dataOrInfo ? dataOrInfo.data : dataOrInfo;
10078
10078
  try {
10079
10079
  return AccountLayout.decode(data);
10080
10080
  }
@@ -10300,26 +10300,34 @@ function simulateTransaction(connection, tx, simulateConfig) {
10300
10300
  var _a, _b, _c, _d, _e, _f, _g, _h;
10301
10301
  return __awaiter(this, void 0, void 0, function* () {
10302
10302
  const addressesToGetDiffFor = ((_b = (_a = simulateConfig.accounts) === null || _a === void 0 ? void 0 : _a.addresses) !== null && _b !== void 0 ? _b : []).map((a) => new PublicKey(a));
10303
- const accountsToFetch = addressesToGetDiffFor.length > 0 ? yield connection.getMultipleAccountsInfo(addressesToGetDiffFor) : [];
10303
+ const accountsToFetch = addressesToGetDiffFor.length > 0
10304
+ ? yield connection.getMultipleAccountsInfo(addressesToGetDiffFor)
10305
+ : [];
10304
10306
  const result = yield connection.simulateTransaction(tx, simulateConfig);
10305
10307
  const diffMap = new Map();
10306
10308
  for (const [idx, simulatedAccountInfo] of ((_c = result.value.accounts) !== null && _c !== void 0 ? _c : []).entries()) {
10307
10309
  const accountAddress = addressesToGetDiffFor[idx];
10308
10310
  const oldAccountData = (_d = accountsToFetch.at(idx)) !== null && _d !== void 0 ? _d : null;
10309
- const oldParsedMaybeSpl = (oldAccountData === null || oldAccountData === void 0 ? void 0 : oldAccountData.owner.equals(TOKEN_PROGRAM_ID)) ? parseSplAccount(oldAccountData) : null;
10311
+ const oldParsedMaybeSpl = (oldAccountData === null || oldAccountData === void 0 ? void 0 : oldAccountData.owner.equals(TOKEN_PROGRAM_ID))
10312
+ ? parseSplAccount(oldAccountData)
10313
+ : null;
10310
10314
  const oldSolValue = (_e = oldAccountData === null || oldAccountData === void 0 ? void 0 : oldAccountData.lamports) !== null && _e !== void 0 ? _e : 0;
10311
10315
  const newSolValue = (_f = simulatedAccountInfo === null || simulatedAccountInfo === void 0 ? void 0 : simulatedAccountInfo.lamports) !== null && _f !== void 0 ? _f : 0;
10312
- const solDiff = oldSolValue === newSolValue ? null : {
10313
- before: oldSolValue,
10314
- after: newSolValue,
10315
- };
10316
+ const solDiff = oldSolValue === newSolValue
10317
+ ? null
10318
+ : {
10319
+ before: oldSolValue,
10320
+ after: newSolValue,
10321
+ };
10316
10322
  let newParsedMaybeSpl = null;
10317
10323
  if (simulatedAccountInfo) {
10318
10324
  const [rawData, encoding] = simulatedAccountInfo.data;
10319
10325
  if (encoding !== "base64")
10320
10326
  throw new Error("Expected bs64 account data");
10321
10327
  const artificialAccountInfo = Object.assign(Object.assign({}, simulatedAccountInfo), { owner: new PublicKey(simulatedAccountInfo.owner), data: Buffer.from(rawData, "base64") });
10322
- newParsedMaybeSpl = artificialAccountInfo.owner.equals(TOKEN_PROGRAM_ID) ? parseSplAccount(artificialAccountInfo) : null;
10328
+ newParsedMaybeSpl = artificialAccountInfo.owner.equals(TOKEN_PROGRAM_ID)
10329
+ ? parseSplAccount(artificialAccountInfo)
10330
+ : null;
10323
10331
  }
10324
10332
  let splDiff = null;
10325
10333
  // old state is spl token account OR new state is spl token account
@@ -10350,11 +10358,11 @@ function simulateTransaction(connection, tx, simulateConfig) {
10350
10358
  });
10351
10359
  }
10352
10360
  /**
10353
- * Serializes transaction and returns serialized size
10354
- * @param transaction tx to get length
10355
- * @param feePayer optional fee payer
10356
- * @returns transaction size
10357
- */
10361
+ * Serializes transaction and returns serialized size
10362
+ * @param transaction tx to get length
10363
+ * @param feePayer optional fee payer
10364
+ * @returns transaction size
10365
+ */
10358
10366
  function getTransactionSize(tx) {
10359
10367
  try {
10360
10368
  if ("version" in tx) {