@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.
package/dist/index.mjs CHANGED
@@ -4610,25 +4610,54 @@ function decodePaymentHeader(paymentHeader) {
4610
4610
  return null;
4611
4611
  }
4612
4612
  }
4613
+ var SPL_TOKEN_PROGRAM = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
4614
+ var SPL_TOKEN_2022_PROGRAM = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
4613
4615
  function extractSolanaFeePayer(base64Transaction) {
4614
4616
  try {
4615
4617
  const txBytes = typeof Buffer !== "undefined" ? Buffer.from(base64Transaction, "base64") : Uint8Array.from(atob(base64Transaction), (c) => c.charCodeAt(0));
4616
4618
  let offset = 0;
4617
4619
  const numSignatures = txBytes[offset];
4618
- offset += 1;
4619
- offset += numSignatures * 64;
4620
- const firstByte = txBytes[offset];
4621
- if ((firstByte & 128) !== 0) {
4620
+ offset += 1 + numSignatures * 64;
4621
+ if ((txBytes[offset] & 128) !== 0) {
4622
4622
  offset += 1;
4623
4623
  }
4624
4624
  offset += 3;
4625
4625
  const numAccounts = txBytes[offset];
4626
4626
  offset += 1;
4627
- if (numAccounts > 0 && offset + 32 <= txBytes.length) {
4628
- const feePayerBytes = txBytes.slice(offset, offset + 32);
4629
- return base58Encode(feePayerBytes);
4627
+ const accountKeys = [];
4628
+ for (let i = 0; i < numAccounts; i++) {
4629
+ accountKeys.push(txBytes.slice(offset, offset + 32));
4630
+ offset += 32;
4631
+ }
4632
+ if (accountKeys.length === 0) return null;
4633
+ offset += 32;
4634
+ const numInstructions = txBytes[offset];
4635
+ offset += 1;
4636
+ for (let i = 0; i < numInstructions; i++) {
4637
+ const programIdIndex = txBytes[offset];
4638
+ offset += 1;
4639
+ const numIxAccounts = txBytes[offset];
4640
+ offset += 1;
4641
+ const ixAccountIndices = [];
4642
+ for (let j = 0; j < numIxAccounts; j++) {
4643
+ ixAccountIndices.push(txBytes[offset]);
4644
+ offset += 1;
4645
+ }
4646
+ const dataLen = txBytes[offset];
4647
+ offset += 1 + dataLen;
4648
+ const programAddr = base58Encode(accountKeys[programIdIndex]);
4649
+ if (programAddr === SPL_TOKEN_PROGRAM || programAddr === SPL_TOKEN_2022_PROGRAM) {
4650
+ if (ixAccountIndices.length >= 4) {
4651
+ const authorityIndex = ixAccountIndices[3];
4652
+ return base58Encode(accountKeys[authorityIndex]);
4653
+ }
4654
+ if (ixAccountIndices.length >= 3) {
4655
+ const authorityIndex = ixAccountIndices[2];
4656
+ return base58Encode(accountKeys[authorityIndex]);
4657
+ }
4658
+ }
4630
4659
  }
4631
- return null;
4660
+ return base58Encode(accountKeys[0]);
4632
4661
  } catch {
4633
4662
  return null;
4634
4663
  }