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