@zauthx402/sdk 0.1.7 → 0.1.9

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.
@@ -4552,25 +4552,54 @@ function decodePaymentHeader(paymentHeader) {
4552
4552
  return null;
4553
4553
  }
4554
4554
  }
4555
+ var SPL_TOKEN_PROGRAM = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
4556
+ var SPL_TOKEN_2022_PROGRAM = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
4555
4557
  function extractSolanaFeePayer(base64Transaction) {
4556
4558
  try {
4557
4559
  const txBytes = typeof Buffer !== "undefined" ? Buffer.from(base64Transaction, "base64") : Uint8Array.from(atob(base64Transaction), (c) => c.charCodeAt(0));
4558
4560
  let offset = 0;
4559
4561
  const numSignatures = txBytes[offset];
4560
- offset += 1;
4561
- offset += numSignatures * 64;
4562
- const firstByte = txBytes[offset];
4563
- if ((firstByte & 128) !== 0) {
4562
+ offset += 1 + numSignatures * 64;
4563
+ if ((txBytes[offset] & 128) !== 0) {
4564
4564
  offset += 1;
4565
4565
  }
4566
4566
  offset += 3;
4567
4567
  const numAccounts = txBytes[offset];
4568
4568
  offset += 1;
4569
- if (numAccounts > 0 && offset + 32 <= txBytes.length) {
4570
- const feePayerBytes = txBytes.slice(offset, offset + 32);
4571
- return base58Encode(feePayerBytes);
4569
+ const accountKeys = [];
4570
+ for (let i = 0; i < numAccounts; i++) {
4571
+ accountKeys.push(txBytes.slice(offset, offset + 32));
4572
+ offset += 32;
4573
+ }
4574
+ if (accountKeys.length === 0) return null;
4575
+ offset += 32;
4576
+ const numInstructions = txBytes[offset];
4577
+ offset += 1;
4578
+ for (let i = 0; i < numInstructions; i++) {
4579
+ const programIdIndex = txBytes[offset];
4580
+ offset += 1;
4581
+ const numIxAccounts = txBytes[offset];
4582
+ offset += 1;
4583
+ const ixAccountIndices = [];
4584
+ for (let j = 0; j < numIxAccounts; j++) {
4585
+ ixAccountIndices.push(txBytes[offset]);
4586
+ offset += 1;
4587
+ }
4588
+ const dataLen = txBytes[offset];
4589
+ offset += 1 + dataLen;
4590
+ const programAddr = base58Encode(accountKeys[programIdIndex]);
4591
+ if (programAddr === SPL_TOKEN_PROGRAM || programAddr === SPL_TOKEN_2022_PROGRAM) {
4592
+ if (ixAccountIndices.length >= 4) {
4593
+ const authorityIndex = ixAccountIndices[3];
4594
+ return base58Encode(accountKeys[authorityIndex]);
4595
+ }
4596
+ if (ixAccountIndices.length >= 3) {
4597
+ const authorityIndex = ixAccountIndices[2];
4598
+ return base58Encode(accountKeys[authorityIndex]);
4599
+ }
4600
+ }
4572
4601
  }
4573
- return null;
4602
+ return base58Encode(accountKeys[0]);
4574
4603
  } catch {
4575
4604
  return null;
4576
4605
  }