@debridge-finance/solana-utils 5.5.0 → 5.5.1
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/browser/index.js +27 -4
- package/dist/browser/index.js.map +1 -1
- package/dist/cjs/spl.js +26 -4
- package/dist/cjs/spl.js.map +1 -1
- package/dist/esm/spl.js +27 -4
- package/dist/esm/spl.js.map +1 -1
- package/dist/types/spl.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -11573,11 +11573,27 @@ function getNativeWalletBalance(connection, wallet) {
|
|
|
11573
11573
|
*/
|
|
11574
11574
|
function getAssocSPLWalletBalance(connection, originalWallet, tokenMint) {
|
|
11575
11575
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11576
|
+
var _a, _b, _c, _d;
|
|
11576
11577
|
originalWallet = new PublicKey(originalWallet);
|
|
11577
11578
|
tokenMint = new PublicKey(tokenMint);
|
|
11578
11579
|
const [wallet] = findAssociatedTokenAddress(originalWallet, tokenMint);
|
|
11579
|
-
const
|
|
11580
|
-
|
|
11580
|
+
const [wallet22] = findAssociatedTokenAddress(originalWallet, tokenMint, TOKEN_2022_PROGRAM_ID);
|
|
11581
|
+
const [tokenMintInfo, walletInfo, wallet22Info] = yield connection.getMultipleAccountsInfo([tokenMint, wallet, wallet22]);
|
|
11582
|
+
if (!tokenMintInfo) {
|
|
11583
|
+
throw new Error("Mint doesn't exist");
|
|
11584
|
+
}
|
|
11585
|
+
const owner = tokenMintInfo.owner.toBase58();
|
|
11586
|
+
switch (owner) {
|
|
11587
|
+
case TOKEN_PROGRAM_ID$1.toBase58(): {
|
|
11588
|
+
return new BN((_b = (_a = parseSplAccount(walletInfo !== null && walletInfo !== void 0 ? walletInfo : null)) === null || _a === void 0 ? void 0 : _a.amount.toString()) !== null && _b !== void 0 ? _b : 0);
|
|
11589
|
+
}
|
|
11590
|
+
case TOKEN_2022_PROGRAM_ID.toBase58(): {
|
|
11591
|
+
return new BN((_d = (_c = parseSplAccount(wallet22Info !== null && wallet22Info !== void 0 ? wallet22Info : null)) === null || _c === void 0 ? void 0 : _c.amount.toString()) !== null && _d !== void 0 ? _d : 0);
|
|
11592
|
+
}
|
|
11593
|
+
default: {
|
|
11594
|
+
throw new Error(`Unexpected tokenMint owner: ${owner}`);
|
|
11595
|
+
}
|
|
11596
|
+
}
|
|
11581
11597
|
});
|
|
11582
11598
|
}
|
|
11583
11599
|
/**
|
|
@@ -11587,8 +11603,15 @@ function getAssocSPLWalletBalance(connection, originalWallet, tokenMint) {
|
|
|
11587
11603
|
function getSPLWalletBalance(connection, wallet) {
|
|
11588
11604
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11589
11605
|
wallet = new PublicKey(wallet);
|
|
11590
|
-
const
|
|
11591
|
-
|
|
11606
|
+
const info = yield getAccountInfo(connection, wallet, "finalized");
|
|
11607
|
+
if (!info) {
|
|
11608
|
+
return new BN(0);
|
|
11609
|
+
}
|
|
11610
|
+
const parsed = parseSplAccount(info.data);
|
|
11611
|
+
if (!parsed) {
|
|
11612
|
+
return new BN(0);
|
|
11613
|
+
}
|
|
11614
|
+
return new BN(parsed.amount.toString());
|
|
11592
11615
|
});
|
|
11593
11616
|
}
|
|
11594
11617
|
/**
|