@debridge-finance/solana-utils 6.1.1 → 6.1.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.
@@ -13046,15 +13046,22 @@ function getTokenInfo(connection_1, tokenAddress_1) {
13046
13046
  }
13047
13047
  }
13048
13048
  }
13049
- if (!pdaAccount || pdaAccount.lamports === 0) {
13050
- return null;
13051
- }
13052
13049
  // parse token account
13053
13050
  // mint_authority - coption(pubkey) = 36
13054
13051
  // supply - u64 = 8
13055
13052
  // decimals - u8
13056
13053
  const decimalsOffset = 44;
13057
13054
  const decimals = tokenAccount.data[decimalsOffset];
13055
+ if (!pdaAccount || pdaAccount.lamports === 0) {
13056
+ return {
13057
+ address: tokenAddress,
13058
+ decimals,
13059
+ name: "",
13060
+ symbol: "",
13061
+ json: "",
13062
+ tokenProgram: tokenAccount.owner,
13063
+ };
13064
+ }
13058
13065
  const { name, symbol, uri } = decodeMetaplexMetadataPartial(pdaAccount.data);
13059
13066
  return {
13060
13067
  address: tokenAddress,
@@ -13490,20 +13497,22 @@ function getTransactionDiff(connection, tx, txAccounts) {
13490
13497
  const preBalances = parseMultipleAccounts(accountsInfo);
13491
13498
  const postBalances = parseMultipleAccounts(simulatesInfo);
13492
13499
  const balancesDiff = accountsPubKeys.reduce((map, pubKey, i) => {
13493
- var _a;
13500
+ var _a, _b, _c;
13494
13501
  if ((_a = accountsInfo[i]) === null || _a === void 0 ? void 0 : _a.executable) {
13495
13502
  return map;
13496
13503
  }
13497
13504
  const preBalance = preBalances[i];
13498
13505
  const postBalance = postBalances[i];
13506
+ const nativeBefore = (_b = preBalance === null || preBalance === void 0 ? void 0 : preBalance.balance) !== null && _b !== void 0 ? _b : 0;
13507
+ const nativeAfter = (_c = postBalance === null || postBalance === void 0 ? void 0 : postBalance.balance) !== null && _c !== void 0 ? _c : 0;
13499
13508
  const diff = {
13500
13509
  pubKey: pubKey,
13501
- preBalance: preBalance.balance,
13502
- postBalance: postBalance.balance,
13503
- diff: postBalance.balance - preBalance.balance,
13510
+ preBalance: nativeBefore,
13511
+ postBalance: nativeAfter,
13512
+ diff: nativeAfter - nativeBefore,
13504
13513
  };
13505
- if (preBalance.spl || postBalance.spl) {
13506
- const splDiff = getSplDiff(preBalance.spl, postBalance.spl);
13514
+ if ((preBalance === null || preBalance === void 0 ? void 0 : preBalance.spl) || (postBalance === null || postBalance === void 0 ? void 0 : postBalance.spl)) {
13515
+ const splDiff = getSplDiff(preBalance === null || preBalance === void 0 ? void 0 : preBalance.spl, postBalance === null || postBalance === void 0 ? void 0 : postBalance.spl);
13507
13516
  if (splDiff.diff) {
13508
13517
  diff.spl = splDiff;
13509
13518
  }