@wireio/stake 2.4.4 → 2.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/lib/stake.browser.js +52 -39
- package/lib/stake.browser.js.map +1 -1
- package/lib/stake.d.ts +19 -6
- package/lib/stake.js +53 -37
- package/lib/stake.js.map +1 -1
- package/lib/stake.m.js +52 -39
- package/lib/stake.m.js.map +1 -1
- package/package.json +1 -1
- package/src/networks/solana/clients/outpost.client.ts +61 -42
- package/src/networks/solana/types.ts +10 -6
- package/src/networks/solana/utils.ts +8 -0
package/lib/stake.browser.js
CHANGED
|
@@ -15839,6 +15839,14 @@ function normalizeToBigInt(x) {
|
|
|
15839
15839
|
if (typeof x === "number") return BigInt(x);
|
|
15840
15840
|
throw new Error(`normalizeToBigInt: unsupported type ${typeof x}`);
|
|
15841
15841
|
}
|
|
15842
|
+
const safeFetch = async (promise, label) => {
|
|
15843
|
+
try {
|
|
15844
|
+
return await promise;
|
|
15845
|
+
} catch (err) {
|
|
15846
|
+
console.error(`Safe Fetch Failed${label ? ` (${label})` : ""}:`, err);
|
|
15847
|
+
return null;
|
|
15848
|
+
}
|
|
15849
|
+
};
|
|
15842
15850
|
|
|
15843
15851
|
let ConvertClient$1 = class ConvertClient {
|
|
15844
15852
|
constructor(provider, pgs) {
|
|
@@ -16369,50 +16377,55 @@ class OutpostClient {
|
|
|
16369
16377
|
return buildOutpostAccounts(this.connection, userPk, this.pgs);
|
|
16370
16378
|
}
|
|
16371
16379
|
async getTokenBalance(ata) {
|
|
16380
|
+
const bal = await this.connection.getTokenAccountBalance(ata);
|
|
16381
|
+
return new BN(bal.value.amount);
|
|
16382
|
+
}
|
|
16383
|
+
async fetchOutpostAccount(address) {
|
|
16372
16384
|
try {
|
|
16373
|
-
|
|
16374
|
-
|
|
16375
|
-
|
|
16376
|
-
|
|
16385
|
+
return await this.program.account.outpostAccount.fetchNullable(address);
|
|
16386
|
+
} catch (e) {
|
|
16387
|
+
if (!(e instanceof RangeError)) throw e;
|
|
16388
|
+
const info = await this.connection.getAccountInfo(address);
|
|
16389
|
+
if (!info) return null;
|
|
16390
|
+
const EXPECTED_SIZE = info.data.length + 3;
|
|
16391
|
+
const padded = Buffer.alloc(EXPECTED_SIZE);
|
|
16392
|
+
info.data.copy(padded);
|
|
16393
|
+
return this.program.coder.accounts.decode(
|
|
16394
|
+
"outpostAccount",
|
|
16395
|
+
padded
|
|
16396
|
+
);
|
|
16377
16397
|
}
|
|
16378
16398
|
}
|
|
16379
16399
|
async fetchWireState(user) {
|
|
16380
16400
|
const userPk = user ?? this.wallet.publicKey;
|
|
16381
|
-
if (!userPk)
|
|
16382
|
-
throw new Error("OutpostClient.fetchWireState: wallet not connected");
|
|
16383
|
-
}
|
|
16401
|
+
if (!userPk) throw new Error("OutpostClient.fetchWireState: wallet not connected");
|
|
16384
16402
|
const pdas = await this.buildAccounts(userPk);
|
|
16385
|
-
|
|
16386
|
-
|
|
16387
|
-
|
|
16388
|
-
|
|
16389
|
-
|
|
16390
|
-
|
|
16391
|
-
|
|
16392
|
-
|
|
16393
|
-
|
|
16394
|
-
|
|
16395
|
-
|
|
16396
|
-
|
|
16397
|
-
|
|
16398
|
-
|
|
16399
|
-
|
|
16400
|
-
|
|
16401
|
-
|
|
16402
|
-
|
|
16403
|
-
|
|
16404
|
-
|
|
16405
|
-
|
|
16406
|
-
|
|
16407
|
-
|
|
16408
|
-
|
|
16409
|
-
|
|
16410
|
-
|
|
16411
|
-
};
|
|
16412
|
-
} catch (err) {
|
|
16413
|
-
console.error("Error fetching Outpost wire state:", err);
|
|
16414
|
-
throw err;
|
|
16415
|
-
}
|
|
16403
|
+
const [
|
|
16404
|
+
globalState,
|
|
16405
|
+
outpostAccount,
|
|
16406
|
+
distributionState,
|
|
16407
|
+
userPretokenRecord,
|
|
16408
|
+
trancheState,
|
|
16409
|
+
liqsolPoolBalance,
|
|
16410
|
+
userLiqsolBalance
|
|
16411
|
+
] = await Promise.all([
|
|
16412
|
+
safeFetch(this.program.account.globalState.fetch(pdas.globalState), "globalState"),
|
|
16413
|
+
safeFetch(this.fetchOutpostAccount(pdas.outpostAccount), "outpostAccount"),
|
|
16414
|
+
safeFetch(this.program.account.distributionState.fetchNullable(pdas.distributionState), "distributionState"),
|
|
16415
|
+
safeFetch(this.program.account.userPretokenRecord.fetchNullable(pdas.userPretokenRecord), "userPretokenRecord"),
|
|
16416
|
+
safeFetch(this.program.account.trancheState.fetchNullable(pdas.trancheState), "trancheState"),
|
|
16417
|
+
safeFetch(this.getTokenBalance(pdas.liqsolPoolAta), "liqsolPoolAta"),
|
|
16418
|
+
safeFetch(this.getTokenBalance(pdas.userAta), "userAta")
|
|
16419
|
+
]);
|
|
16420
|
+
return {
|
|
16421
|
+
globalState,
|
|
16422
|
+
outpostAccount,
|
|
16423
|
+
distributionState,
|
|
16424
|
+
trancheState,
|
|
16425
|
+
userPretokenRecord,
|
|
16426
|
+
liqsolPoolBalance,
|
|
16427
|
+
userLiqsolBalance
|
|
16428
|
+
};
|
|
16416
16429
|
}
|
|
16417
16430
|
async buildStakeIx(amountLamports, user = this.wallet.publicKey) {
|
|
16418
16431
|
if (!user) {
|
|
@@ -43004,5 +43017,5 @@ var types = /*#__PURE__*/Object.freeze({
|
|
|
43004
43017
|
__proto__: null
|
|
43005
43018
|
});
|
|
43006
43019
|
|
|
43007
|
-
export { ADDRESSES, ADDRESS_BOOK_BY_CHAIN, CHAINLINK_FEED, CHAINLINK_PROGRAM, CONTRACTS_BY_CHAIN, ConvertClient$1 as ConvertClient, DEFAULT_AVERAGE_PAY_RATE, DEFAULT_PAY_RATE_LOOKBACK, DistributionClient, EPHEMERAL_RENT_EXEMPTION, ERC1155Abi, ERC20Abi, ERC721Abi, types$1 as ETH, EthereumContractService, EthereumStakingClient, HOODI_ADDRESSES, INDEX_SCALE$1 as INDEX_SCALE, INITIAL_TRANCHE_SUPPLY, LAMPORTS_PER_SOL, LeaderboardClient, MAINNET_ADDRESSES, OutpostClient, PAY_RATE_SCALE_FACTOR, PDA_SEEDS, PROGRAM_IDS_BY_CHAIN, PurchaseAsset, ReceiptNFTKind, SCALE, types as SOL, SolanaStakingClient, Staker, SupportedEvmChainID, SupportedSolChainID, TokenClient, airdropSol, buildOutpostAccounts, buildSolanaTrancheLadder, buildSolanaTrancheSnapshot, ceilDiv, deriveEphemeralStakeAddress, generateRandomDepositAmount, generateTestKeypair, getEpochSnapshot, getErrorMessage, getProgramIds, lamportsToSol, msToEpochEnd, normalizeToBigInt, scheduledInstruction, sleep, solToLamports, toBigint, tokensToShares, waitForConfirmation, waitUntilSafeToExecuteFunction };
|
|
43020
|
+
export { ADDRESSES, ADDRESS_BOOK_BY_CHAIN, CHAINLINK_FEED, CHAINLINK_PROGRAM, CONTRACTS_BY_CHAIN, ConvertClient$1 as ConvertClient, DEFAULT_AVERAGE_PAY_RATE, DEFAULT_PAY_RATE_LOOKBACK, DistributionClient, EPHEMERAL_RENT_EXEMPTION, ERC1155Abi, ERC20Abi, ERC721Abi, types$1 as ETH, EthereumContractService, EthereumStakingClient, HOODI_ADDRESSES, INDEX_SCALE$1 as INDEX_SCALE, INITIAL_TRANCHE_SUPPLY, LAMPORTS_PER_SOL, LeaderboardClient, MAINNET_ADDRESSES, OutpostClient, PAY_RATE_SCALE_FACTOR, PDA_SEEDS, PROGRAM_IDS_BY_CHAIN, PurchaseAsset, ReceiptNFTKind, SCALE, types as SOL, SolanaStakingClient, Staker, SupportedEvmChainID, SupportedSolChainID, TokenClient, airdropSol, buildOutpostAccounts, buildSolanaTrancheLadder, buildSolanaTrancheSnapshot, ceilDiv, deriveEphemeralStakeAddress, generateRandomDepositAmount, generateTestKeypair, getEpochSnapshot, getErrorMessage, getProgramIds, lamportsToSol, msToEpochEnd, normalizeToBigInt, safeFetch, scheduledInstruction, sleep, solToLamports, toBigint, tokensToShares, waitForConfirmation, waitUntilSafeToExecuteFunction };
|
|
43008
43021
|
//# sourceMappingURL=stake.browser.js.map
|