@orderly.network/default-solana-adapter 2.9.1 → 2.10.0-alpha.0
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.d.mts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +66 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +72 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -42,13 +42,13 @@ var __async = (__this, __arguments, generator) => {
|
|
|
42
42
|
// src/version.ts
|
|
43
43
|
if (typeof window !== "undefined") {
|
|
44
44
|
window.__ORDERLY_VERSION__ = window.__ORDERLY_VERSION__ || {};
|
|
45
|
-
window.__ORDERLY_VERSION__["@orderly.network/default-solana-adapter"] = "2.
|
|
45
|
+
window.__ORDERLY_VERSION__["@orderly.network/default-solana-adapter"] = "2.10.0-alpha.0";
|
|
46
46
|
}
|
|
47
|
-
var version_default = "2.
|
|
47
|
+
var version_default = "2.10.0-alpha.0";
|
|
48
48
|
|
|
49
49
|
// src/walletAdapter.ts
|
|
50
50
|
import * as ed from "@noble/ed25519";
|
|
51
|
-
import { getAccount } from "@solana/spl-token";
|
|
51
|
+
import { getAccount, getMultipleAccounts } from "@solana/spl-token";
|
|
52
52
|
import { WalletAdapterNetwork } from "@solana/wallet-adapter-base";
|
|
53
53
|
import {
|
|
54
54
|
clusterApiUrl,
|
|
@@ -63,7 +63,11 @@ import {
|
|
|
63
63
|
BaseWalletAdapter,
|
|
64
64
|
SimpleDI
|
|
65
65
|
} from "@orderly.network/core";
|
|
66
|
-
import {
|
|
66
|
+
import {
|
|
67
|
+
MaxUint256,
|
|
68
|
+
ChainNamespace,
|
|
69
|
+
isNativeTokenChecker
|
|
70
|
+
} from "@orderly.network/types";
|
|
67
71
|
|
|
68
72
|
// src/helper.ts
|
|
69
73
|
import { BN, Program } from "@coral-xyz/anchor";
|
|
@@ -3019,10 +3023,6 @@ function getDepositQuoteFee(_0) {
|
|
|
3019
3023
|
}
|
|
3020
3024
|
const encodedReturnData = returnLogEntry.slice(returnPrefix.length);
|
|
3021
3025
|
const decodedBuffer = Buffer.from(encodedReturnData, "base64");
|
|
3022
|
-
console.log(
|
|
3023
|
-
decodedBuffer.readBigUInt64LE(0),
|
|
3024
|
-
decodedBuffer.readBigUInt64LE(1)
|
|
3025
|
-
);
|
|
3026
3026
|
return decodedBuffer.readBigUInt64LE(0);
|
|
3027
3027
|
});
|
|
3028
3028
|
}
|
|
@@ -3556,19 +3556,69 @@ var DefaultSolanaWalletAdapter = class extends BaseWalletAdapter {
|
|
|
3556
3556
|
return BigInt(lamports);
|
|
3557
3557
|
});
|
|
3558
3558
|
}
|
|
3559
|
-
|
|
3559
|
+
getBalances(addresses) {
|
|
3560
3560
|
return __async(this, null, function* () {
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3561
|
+
const userPublicKey = new PublicKey4(this._address);
|
|
3562
|
+
const connection = this.connection;
|
|
3563
|
+
const isNativeToken = addresses.map(
|
|
3564
|
+
(address) => isNativeTokenChecker(address)
|
|
3565
|
+
);
|
|
3566
|
+
const hasNativeSOL = addresses.some(
|
|
3567
|
+
(address) => isNativeTokenChecker(address)
|
|
3568
|
+
);
|
|
3569
|
+
let nativeSolBalance = null;
|
|
3570
|
+
if (hasNativeSOL) {
|
|
3571
|
+
nativeSolBalance = yield this.getBalance();
|
|
3572
|
+
}
|
|
3573
|
+
const splTokenAddresses = addresses.filter(
|
|
3574
|
+
(address) => !isNativeTokenChecker(address)
|
|
3575
|
+
);
|
|
3576
|
+
let splTokenBalances = [];
|
|
3577
|
+
if (splTokenAddresses.length > 0) {
|
|
3578
|
+
const tokenPublicKeys = splTokenAddresses.map(
|
|
3579
|
+
(address) => new PublicKey4(address)
|
|
3580
|
+
);
|
|
3581
|
+
const userTokenAccounts = tokenPublicKeys.map(
|
|
3582
|
+
(tokenPublicKey) => getTokenAccounts(tokenPublicKey, userPublicKey)
|
|
3583
|
+
);
|
|
3584
|
+
const tokenAmount = yield getMultipleAccounts(
|
|
3567
3585
|
connection,
|
|
3568
|
-
|
|
3586
|
+
userTokenAccounts,
|
|
3569
3587
|
"confirmed"
|
|
3570
3588
|
);
|
|
3571
|
-
|
|
3589
|
+
splTokenBalances = tokenAmount.map((item) => item.amount);
|
|
3590
|
+
}
|
|
3591
|
+
const results = [];
|
|
3592
|
+
let splIndex = 0;
|
|
3593
|
+
for (let i = 0; i < addresses.length; i++) {
|
|
3594
|
+
if (isNativeToken[i]) {
|
|
3595
|
+
results.push(nativeSolBalance);
|
|
3596
|
+
} else {
|
|
3597
|
+
results.push(splTokenBalances[splIndex]);
|
|
3598
|
+
splIndex++;
|
|
3599
|
+
}
|
|
3600
|
+
}
|
|
3601
|
+
return results;
|
|
3602
|
+
});
|
|
3603
|
+
}
|
|
3604
|
+
getBalanceByAddress(address) {
|
|
3605
|
+
return __async(this, null, function* () {
|
|
3606
|
+
const tokenPublicKey = new PublicKey4(address);
|
|
3607
|
+
const userPublicKey = new PublicKey4(this._address);
|
|
3608
|
+
const userTokenAccount = getTokenAccounts(tokenPublicKey, userPublicKey);
|
|
3609
|
+
const connection = this.connection;
|
|
3610
|
+
const tokenAmount = yield getAccount(
|
|
3611
|
+
connection,
|
|
3612
|
+
userTokenAccount,
|
|
3613
|
+
"confirmed"
|
|
3614
|
+
);
|
|
3615
|
+
return tokenAmount.amount;
|
|
3616
|
+
});
|
|
3617
|
+
}
|
|
3618
|
+
call(address, method, params, options) {
|
|
3619
|
+
return __async(this, null, function* () {
|
|
3620
|
+
if (method === "balanceOf") {
|
|
3621
|
+
return this.getBalanceByAddress(address);
|
|
3572
3622
|
}
|
|
3573
3623
|
if (method === "allowance") {
|
|
3574
3624
|
return MaxUint256;
|
|
@@ -3614,6 +3664,11 @@ var DefaultSolanaWalletAdapter = class extends BaseWalletAdapter {
|
|
|
3614
3664
|
return 0;
|
|
3615
3665
|
});
|
|
3616
3666
|
}
|
|
3667
|
+
estimateGasFee(contractAddress, method, payload) {
|
|
3668
|
+
return __async(this, null, function* () {
|
|
3669
|
+
return BigInt(0);
|
|
3670
|
+
});
|
|
3671
|
+
}
|
|
3617
3672
|
pollTransactionReceiptWithBackoff(txHash, baseInterval, maxInterval, maxRetries) {
|
|
3618
3673
|
return __async(this, null, function* () {
|
|
3619
3674
|
return Promise.resolve({ status: 1 });
|