@perena/vault-sdk 1.0.65 → 1.0.66
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.ts +2 -0
- package/dist/index.js +36 -11
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -11366,6 +11366,8 @@ declare class AccountClient extends BaseAccountClient {
|
|
|
11366
11366
|
fetchVaultOracleForVault(vault: Address, opts?: {
|
|
11367
11367
|
fresh?: boolean;
|
|
11368
11368
|
}): Promise<VaultOracleAccountData>;
|
|
11369
|
+
/** Fresh discovery read: only an absent oracle returns null; RPC errors propagate. */
|
|
11370
|
+
fetchVaultOracleForVaultNullable(vault: Address): Promise<VaultOracleAccountData | null>;
|
|
11369
11371
|
fetchVaultTrancheState(vaultTrancheState: Address, opts?: {
|
|
11370
11372
|
fresh?: boolean;
|
|
11371
11373
|
}): Promise<VaultTrancheStateAccountData>;
|
package/dist/index.js
CHANGED
|
@@ -13603,6 +13603,13 @@ var AccountClient = class extends import_common.BaseAccountClient {
|
|
|
13603
13603
|
const [vaultOracle] = await this.pda.deriveVaultOraclePda(vault);
|
|
13604
13604
|
return this.fetchVaultOracle(vaultOracle, opts);
|
|
13605
13605
|
}
|
|
13606
|
+
/** Fresh discovery read: only an absent oracle returns null; RPC errors propagate. */
|
|
13607
|
+
async fetchVaultOracleForVaultNullable(vault) {
|
|
13608
|
+
const [vaultOracle] = await this.pda.deriveVaultOraclePda(vault);
|
|
13609
|
+
return this.program.account.vaultOracle.fetchNullable(
|
|
13610
|
+
(0, import_common.toWeb3Pk)(vaultOracle)
|
|
13611
|
+
);
|
|
13612
|
+
}
|
|
13606
13613
|
async fetchVaultTrancheState(vaultTrancheState, opts) {
|
|
13607
13614
|
if (opts?.fresh) {
|
|
13608
13615
|
this.dataCache.clearCacheEntry(
|
|
@@ -22050,20 +22057,38 @@ async function discoverVaultsForSigner(client, signer, opts = {}) {
|
|
|
22050
22057
|
log(
|
|
22051
22058
|
`Discovered ${allVaults.length} vault(s) on-chain, checking oracle membership\u2026`
|
|
22052
22059
|
);
|
|
22053
|
-
const
|
|
22054
|
-
await Promise.all(
|
|
22060
|
+
const inspections = await Promise.allSettled(
|
|
22055
22061
|
allVaults.map(async ({ publicKey: vault }) => {
|
|
22056
|
-
|
|
22057
|
-
|
|
22058
|
-
|
|
22059
|
-
|
|
22060
|
-
|
|
22061
|
-
|
|
22062
|
-
|
|
22063
|
-
|
|
22064
|
-
|
|
22062
|
+
const oracle = await client.account.fetchVaultOracleForVaultNullable(
|
|
22063
|
+
vault
|
|
22064
|
+
);
|
|
22065
|
+
if (!oracle) {
|
|
22066
|
+
log(` ${vault}: no oracle account, skipping`);
|
|
22067
|
+
return null;
|
|
22068
|
+
}
|
|
22069
|
+
const data = oracle.data;
|
|
22070
|
+
if (!signerInOracleData(data, signerBytes)) return null;
|
|
22071
|
+
log(` ${vault}: signer is registered oracle`);
|
|
22072
|
+
return { vault };
|
|
22065
22073
|
})
|
|
22066
22074
|
);
|
|
22075
|
+
const results = [];
|
|
22076
|
+
const unreadable = [];
|
|
22077
|
+
inspections.forEach((inspection, index) => {
|
|
22078
|
+
if (inspection.status === "fulfilled") {
|
|
22079
|
+
if (inspection.value) results.push(inspection.value);
|
|
22080
|
+
return;
|
|
22081
|
+
}
|
|
22082
|
+
const vault = allVaults[index].publicKey;
|
|
22083
|
+
const error = inspection.reason instanceof Error ? inspection.reason.message : String(inspection.reason);
|
|
22084
|
+
log(`FAILED oracle discovery ${vault}: ${error}`);
|
|
22085
|
+
unreadable.push(vault.toString());
|
|
22086
|
+
});
|
|
22087
|
+
if (unreadable.length > 0) {
|
|
22088
|
+
throw new Error(
|
|
22089
|
+
`Oracle discovery incomplete: could not inspect ${unreadable.length}/${allVaults.length} vault(s) (${unreadable.join(", ")}); refusing to run a partial target list`
|
|
22090
|
+
);
|
|
22091
|
+
}
|
|
22067
22092
|
return results;
|
|
22068
22093
|
}
|
|
22069
22094
|
|