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