@wireio/stake 2.5.0 → 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 +17 -9
- package/lib/stake.browser.js.map +1 -1
- package/lib/stake.d.ts +8 -0
- package/lib/stake.js +27 -17
- package/lib/stake.js.map +1 -1
- package/lib/stake.m.js +17 -9
- package/lib/stake.m.js.map +1 -1
- package/package.json +1 -1
- package/src/networks/solana/clients/outpost.client.ts +31 -1
- package/src/networks/solana/solana.ts +0 -9
package/package.json
CHANGED
|
@@ -79,6 +79,36 @@ export class OutpostClient {
|
|
|
79
79
|
return new BN(bal.value.amount);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Fetch an OutpostAccount, handling legacy accounts that pre-date the
|
|
84
|
+
* three trailing Option<u64> fields. If the normal decode throws a
|
|
85
|
+
* RangeError we re-fetch the raw data, pad it to the expected size
|
|
86
|
+
* (zeros → Option::None for each missing field), and let Anchor's
|
|
87
|
+
* coder decode the padded buffer.
|
|
88
|
+
*/
|
|
89
|
+
private async fetchOutpostAccount(address: PublicKey) {
|
|
90
|
+
try {
|
|
91
|
+
return await this.program.account.outpostAccount.fetchNullable(address);
|
|
92
|
+
} catch (e) {
|
|
93
|
+
if (!(e instanceof RangeError)) throw e;
|
|
94
|
+
|
|
95
|
+
const info = await this.connection.getAccountInfo(address);
|
|
96
|
+
if (!info) return null;
|
|
97
|
+
|
|
98
|
+
// 3 × Option<u64> encoded as 1-byte tag (0x00 = None) = 3 bytes
|
|
99
|
+
// when present (Some) each is 9 bytes, but None is just 0x00
|
|
100
|
+
const EXPECTED_SIZE = info.data.length + 3;
|
|
101
|
+
const padded = Buffer.alloc(EXPECTED_SIZE);
|
|
102
|
+
info.data.copy(padded);
|
|
103
|
+
// trailing bytes are already 0x00 → Option::None for each field
|
|
104
|
+
|
|
105
|
+
return this.program.coder.accounts.decode(
|
|
106
|
+
'outpostAccount',
|
|
107
|
+
padded,
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
82
112
|
/**
|
|
83
113
|
* Fetch the core "Wire state" for Outpost / pretokens for a given user.
|
|
84
114
|
*/
|
|
@@ -97,7 +127,7 @@ export class OutpostClient {
|
|
|
97
127
|
userLiqsolBalance,
|
|
98
128
|
] = await Promise.all([
|
|
99
129
|
safeFetch(this.program.account.globalState.fetch(pdas.globalState), 'globalState'),
|
|
100
|
-
safeFetch(this.
|
|
130
|
+
safeFetch(this.fetchOutpostAccount(pdas.outpostAccount), 'outpostAccount'),
|
|
101
131
|
safeFetch(this.program.account.distributionState.fetchNullable(pdas.distributionState), 'distributionState'),
|
|
102
132
|
safeFetch(this.program.account.userPretokenRecord.fetchNullable(pdas.userPretokenRecord), 'userPretokenRecord'),
|
|
103
133
|
safeFetch(this.program.account.trancheState.fetchNullable(pdas.trancheState), 'trancheState'),
|
|
@@ -445,15 +445,6 @@ export class SolanaStakingClient implements IStakingClient {
|
|
|
445
445
|
userPretokenRecord?.totalPretokensPurchased?.toString?.() ??
|
|
446
446
|
'0';
|
|
447
447
|
|
|
448
|
-
console.log('userPretokenRecord', userPretokenRecord);
|
|
449
|
-
console.log('address', address);
|
|
450
|
-
console.log('userPretokenRecord?.totalPretokensPurchased?.toString', userPretokenRecord?.totalPretokensPurchased?.toString);
|
|
451
|
-
if (userPretokenRecord) {
|
|
452
|
-
for (const [key, value] of Object.entries(userPretokenRecord)) {
|
|
453
|
-
console.log(`userPretokenRecord.${key}: ${value?.toString?.() ?? value}`);
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
|
|
457
448
|
// -----------------------------
|
|
458
449
|
// Yield view (index + shares)
|
|
459
450
|
// -----------------------------
|