@vercora-protocol/sdk 0.2.2 → 0.2.4
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/CHANGELOG.md +19 -0
- package/README.md +1 -1
- package/dist/client.d.ts +20 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +184 -14
- package/dist/client.js.map +1 -1
- package/dist/generated/vercora.d.ts +7 -1
- package/dist/generated/vercora.d.ts.map +1 -1
- package/dist/idl/vercora.json +7 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/pda.d.ts +6 -0
- package/dist/pda.d.ts.map +1 -1
- package/dist/pda.js +12 -0
- package/dist/pda.js.map +1 -1
- package/dist/resolverDecode.d.ts +70 -0
- package/dist/resolverDecode.d.ts.map +1 -0
- package/dist/resolverDecode.js +155 -0
- package/dist/resolverDecode.js.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,25 @@ All notable changes to `@vercora-protocol/sdk` are documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
### [0.2.4](https://github.com/vercora/vercora-anchor/compare/v0.2.3...v0.2.4) (2026-04-23)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **web:** removing market example ([4072b5b](https://github.com/vercora/vercora-anchor/commit/4072b5b8d91916ee9312e5f32aaa90b5f21bc5f2))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* **sdk:** update resolution pda and vote ([1e59f7a](https://github.com/vercora/vercora-anchor/commit/1e59f7a53215f1f633436aba29ce75f03daec910))
|
|
19
|
+
|
|
20
|
+
### [0.2.3](https://github.com/vercora/vercora-anchor/compare/v0.2.2...v0.2.3) (2026-04-22)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
* **all:** fix resolver resolution ([dc907cf](https://github.com/vercora/vercora-anchor/commit/dc907cf31bdffb960d1e9f7ddc322b8d1b85abcd))
|
|
26
|
+
|
|
8
27
|
### [0.2.2](https://github.com/vercora/vercora-anchor/compare/v0.2.1...v0.2.2) (2026-04-22)
|
|
9
28
|
|
|
10
29
|
|
package/README.md
CHANGED
|
@@ -157,7 +157,7 @@ See **[Resolution approval flow](#resolution-approval-flow-propose--challenge--c
|
|
|
157
157
|
| `fetchParimutuelActiveStakesBatch(marketPda, user, outcomeCount)` | Active stakes per outcome. |
|
|
158
158
|
| `computeParimutuelOdds(state, outcomeCount)` | Implied probs + payout multipliers. |
|
|
159
159
|
| `fetchResolver(marketPda, index)` | One resolver account. |
|
|
160
|
-
| `fetchAllResolvers(marketPda, numResolvers)`
|
|
160
|
+
| `fetchAllResolvers(marketPda, numResolvers, { debug })` | Initialized resolver slots; optional `debug: true` logs PDA presence to the console. |
|
|
161
161
|
|
|
162
162
|
### Profiles
|
|
163
163
|
|
package/dist/client.d.ts
CHANGED
|
@@ -263,6 +263,19 @@ export declare class PredictionMarketClient {
|
|
|
263
263
|
/**
|
|
264
264
|
* Fetch the `ResolutionVote` PDA for a specific resolver slot.
|
|
265
265
|
* Returns `null` if the account does not exist (resolver has not voted).
|
|
266
|
+
*
|
|
267
|
+
* Decode is tolerant of IDL drift: if `coder.accounts.decode('ResolutionVote',
|
|
268
|
+
* …)` throws (e.g. the deployed program added/changed padding and the
|
|
269
|
+
* bundled IDL hasn't been re-released yet), this falls back to a raw
|
|
270
|
+
* byte-offset decode via {@link decodeResolutionVoteFromAccountData} — but
|
|
271
|
+
* only when the account is owned by this program id, since only the
|
|
272
|
+
* program's own `vote_resolution` / `revoke_resolution_vote` instructions
|
|
273
|
+
* can write to a PDA derived from `[market, "vote", resolver_index]`.
|
|
274
|
+
*
|
|
275
|
+
* Without this fallback a successful `vote_resolution` tx would leave
|
|
276
|
+
* `hasVoted: false` in any caller that silently treats a decode throw as
|
|
277
|
+
* "no vote" (the most common pattern), leaving the UI stuck on the
|
|
278
|
+
* "Submit vote" form.
|
|
266
279
|
*/
|
|
267
280
|
fetchResolutionVote(marketPda: PublicKey, resolverIndex: number): Promise<ResolutionVoteAccount | null>;
|
|
268
281
|
/**
|
|
@@ -345,9 +358,15 @@ export declare class PredictionMarketClient {
|
|
|
345
358
|
* Fetch all initialized resolver accounts for a market in parallel.
|
|
346
359
|
* Slots whose PDA has never been created are omitted from the result.
|
|
347
360
|
*
|
|
361
|
+
* Resolver PDAs are **not** created in `create_market`; they appear after
|
|
362
|
+
* `initialize_market_resolver` (e.g. `initializeMarketResolverSlots` in the SDK).
|
|
363
|
+
*
|
|
348
364
|
* @param numResolvers - Value of `MarketAccount.numResolvers` (or an upper bound like 8).
|
|
365
|
+
* @param options.debug - When true, logs each slot (`console.info` / `console.warn`): PDA, existence, owner vs program id, decode outcome, RPC endpoint.
|
|
349
366
|
*/
|
|
350
|
-
fetchAllResolvers(market: PublicKey, numResolvers: number
|
|
367
|
+
fetchAllResolvers(market: PublicKey, numResolvers: number, options?: {
|
|
368
|
+
debug?: boolean;
|
|
369
|
+
}): Promise<{
|
|
351
370
|
index: number;
|
|
352
371
|
resolverPubkey: PublicKey;
|
|
353
372
|
}[]>;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,UAAU,EACV,SAAS,EAOV,MAAM,iBAAiB,CAAC;AASzB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,C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39
|
const web3_js_1 = require("@solana/web3.js");
|
|
40
40
|
const spl_token_1 = require("@solana/spl-token");
|
|
41
41
|
const pda_1 = require("./pda");
|
|
42
|
+
const resolverDecode_1 = require("./resolverDecode");
|
|
42
43
|
const types_1 = require("./types");
|
|
43
44
|
/**
|
|
44
45
|
* Some RPC plans (e.g. QuickNode Discover) reject `getMultipleAccounts` with more than 5 keys.
|
|
@@ -332,6 +333,12 @@ class PredictionMarketClient {
|
|
|
332
333
|
const marketCategoryPk = !categoryIdBn.isZero()
|
|
333
334
|
? (0, pda_1.deriveMarketCategory)(this.program.programId, platformIdBn, categoryIdBn)
|
|
334
335
|
: null;
|
|
336
|
+
const maxOi = params.maxOutcomeInvestment ?? new anchor_1.BN(0);
|
|
337
|
+
const maxWi = params.maxWalletOutcomeInvestment ?? new anchor_1.BN(0);
|
|
338
|
+
if (params.marketType === 'parimutuel' &&
|
|
339
|
+
!(0, pda_1.isValidParimutuelWalletVsOutcomeCap)(maxOi, maxWi)) {
|
|
340
|
+
throw new Error('Parimutuel: maxWalletOutcomeInvestment cannot exceed maxOutcomeInvestment when both are non-zero');
|
|
341
|
+
}
|
|
335
342
|
const createIx = await this.program.methods
|
|
336
343
|
.createMarket({
|
|
337
344
|
marketId: params.marketId,
|
|
@@ -341,8 +348,8 @@ class PredictionMarketClient {
|
|
|
341
348
|
creatorFeeBps: params.creatorFeeBps,
|
|
342
349
|
depositPlatformFeeBps: params.depositPlatformFeeBps,
|
|
343
350
|
numResolvers: params.numResolvers,
|
|
344
|
-
maxOutcomeInvestment:
|
|
345
|
-
maxWalletOutcomeInvestment:
|
|
351
|
+
maxOutcomeInvestment: maxOi,
|
|
352
|
+
maxWalletOutcomeInvestment: maxWi,
|
|
346
353
|
title: params.title,
|
|
347
354
|
marketType: (0, types_1.toMarketTypeIx)(params.marketType),
|
|
348
355
|
platformId: (0, pda_1.bnToU32)(platformIdBn),
|
|
@@ -546,6 +553,11 @@ class PredictionMarketClient {
|
|
|
546
553
|
* To change only one knob, pass current values from `fetchMarket` / `fetchParimutuelState` for the rest.
|
|
547
554
|
*/
|
|
548
555
|
async updateParimutuelState(marketPda, params, opts) {
|
|
556
|
+
const market = await this.fetchMarket(marketPda);
|
|
557
|
+
const maxOi = (0, pda_1.bnLike)(market.maxOutcomeInvestment ?? 0);
|
|
558
|
+
if (!(0, pda_1.isValidParimutuelWalletVsOutcomeCap)(maxOi, params.maxWalletOutcomeInvestment)) {
|
|
559
|
+
throw new Error('maxWalletOutcomeInvestment cannot exceed maxOutcomeInvestment on the market when both are non-zero');
|
|
560
|
+
}
|
|
549
561
|
return this.program.methods
|
|
550
562
|
.updateParimutuelState({
|
|
551
563
|
marketId: params.marketId,
|
|
@@ -1351,13 +1363,48 @@ class PredictionMarketClient {
|
|
|
1351
1363
|
/**
|
|
1352
1364
|
* Fetch the `ResolutionVote` PDA for a specific resolver slot.
|
|
1353
1365
|
* Returns `null` if the account does not exist (resolver has not voted).
|
|
1366
|
+
*
|
|
1367
|
+
* Decode is tolerant of IDL drift: if `coder.accounts.decode('ResolutionVote',
|
|
1368
|
+
* …)` throws (e.g. the deployed program added/changed padding and the
|
|
1369
|
+
* bundled IDL hasn't been re-released yet), this falls back to a raw
|
|
1370
|
+
* byte-offset decode via {@link decodeResolutionVoteFromAccountData} — but
|
|
1371
|
+
* only when the account is owned by this program id, since only the
|
|
1372
|
+
* program's own `vote_resolution` / `revoke_resolution_vote` instructions
|
|
1373
|
+
* can write to a PDA derived from `[market, "vote", resolver_index]`.
|
|
1374
|
+
*
|
|
1375
|
+
* Without this fallback a successful `vote_resolution` tx would leave
|
|
1376
|
+
* `hasVoted: false` in any caller that silently treats a decode throw as
|
|
1377
|
+
* "no vote" (the most common pattern), leaving the UI stuck on the
|
|
1378
|
+
* "Submit vote" form.
|
|
1354
1379
|
*/
|
|
1355
1380
|
async fetchResolutionVote(marketPda, resolverIndex) {
|
|
1356
1381
|
const pda = (0, pda_1.deriveResolutionVote)(this.program.programId, marketPda, resolverIndex);
|
|
1357
1382
|
const info = await this.connection.getAccountInfo(pda);
|
|
1358
1383
|
if (!info)
|
|
1359
1384
|
return null;
|
|
1360
|
-
|
|
1385
|
+
const buf = Buffer.from(info.data);
|
|
1386
|
+
try {
|
|
1387
|
+
return this.program.coder.accounts.decode('ResolutionVote', buf);
|
|
1388
|
+
}
|
|
1389
|
+
catch (e) {
|
|
1390
|
+
const ownerMatchesProgram = info.owner.equals(this.program.programId);
|
|
1391
|
+
const decoded = (0, resolverDecode_1.decodeResolutionVoteFromAccountData)(this.program, buf, {
|
|
1392
|
+
trustOwner: ownerMatchesProgram,
|
|
1393
|
+
});
|
|
1394
|
+
if (decoded) {
|
|
1395
|
+
// eslint-disable-next-line no-console
|
|
1396
|
+
console.warn('[vercora:fetchResolutionVote] Anchor coder decode failed — returning raw byte-offset decode (likely IDL drift after redeploy).', {
|
|
1397
|
+
pda: pda.toBase58(),
|
|
1398
|
+
owner: info.owner.toBase58(),
|
|
1399
|
+
programId: this.program.programId.toBase58(),
|
|
1400
|
+
dataLen: buf.length,
|
|
1401
|
+
rpc: this.connection.rpcEndpoint,
|
|
1402
|
+
coderError: e instanceof Error ? e.message : String(e),
|
|
1403
|
+
});
|
|
1404
|
+
return decoded;
|
|
1405
|
+
}
|
|
1406
|
+
throw e;
|
|
1407
|
+
}
|
|
1361
1408
|
}
|
|
1362
1409
|
/**
|
|
1363
1410
|
* Decode all 8 `MarketOutcome` PDAs via chunked `getMultipleAccounts` (QuickNode Discover: max 5 keys/call).
|
|
@@ -1633,32 +1680,155 @@ class PredictionMarketClient {
|
|
|
1633
1680
|
* Fetch all initialized resolver accounts for a market in parallel.
|
|
1634
1681
|
* Slots whose PDA has never been created are omitted from the result.
|
|
1635
1682
|
*
|
|
1683
|
+
* Resolver PDAs are **not** created in `create_market`; they appear after
|
|
1684
|
+
* `initialize_market_resolver` (e.g. `initializeMarketResolverSlots` in the SDK).
|
|
1685
|
+
*
|
|
1636
1686
|
* @param numResolvers - Value of `MarketAccount.numResolvers` (or an upper bound like 8).
|
|
1687
|
+
* @param options.debug - When true, logs each slot (`console.info` / `console.warn`): PDA, existence, owner vs program id, decode outcome, RPC endpoint.
|
|
1637
1688
|
*/
|
|
1638
|
-
async fetchAllResolvers(market, numResolvers) {
|
|
1639
|
-
const
|
|
1689
|
+
async fetchAllResolvers(market, numResolvers, options) {
|
|
1690
|
+
const expectedProgram = this.program.programId;
|
|
1691
|
+
const pdas = Array.from({ length: numResolvers }, (_, i) => (0, pda_1.deriveResolver)(expectedProgram, market, i));
|
|
1640
1692
|
const infos = await this.getMultipleAccountsInfoBatched(pdas);
|
|
1693
|
+
if (options?.debug && infos.length !== pdas.length) {
|
|
1694
|
+
// eslint-disable-next-line no-console
|
|
1695
|
+
console.warn('[vercora:fetchAllResolvers] batch length mismatch', {
|
|
1696
|
+
expectedKeys: pdas.length,
|
|
1697
|
+
infosReturned: infos.length,
|
|
1698
|
+
rpc: this.connection.rpcEndpoint,
|
|
1699
|
+
});
|
|
1700
|
+
}
|
|
1701
|
+
// Per-PDA `getAccountInfo` fallback. Some RPC / validator combinations
|
|
1702
|
+
// (observed on `solana-test-validator`) have returned `null` entries from
|
|
1703
|
+
// `getMultipleAccountsInfo` for PDAs that a subsequent single
|
|
1704
|
+
// `getAccountInfo` fetches fine. Rather than silently dropping those
|
|
1705
|
+
// slots (which caused the app to believe "no resolver PDAs yet" for live
|
|
1706
|
+
// markets), re-fetch any null slot individually before the decode pass.
|
|
1707
|
+
const nullSlotIndices = [];
|
|
1708
|
+
for (let i = 0; i < numResolvers; i++) {
|
|
1709
|
+
if (!infos[i])
|
|
1710
|
+
nullSlotIndices.push(i);
|
|
1711
|
+
}
|
|
1712
|
+
if (nullSlotIndices.length > 0) {
|
|
1713
|
+
const rechecked = await Promise.all(nullSlotIndices.map((i) => this.connection.getAccountInfo(pdas[i])));
|
|
1714
|
+
let recoveredCount = 0;
|
|
1715
|
+
nullSlotIndices.forEach((slotIdx, k) => {
|
|
1716
|
+
const info = rechecked[k];
|
|
1717
|
+
if (info) {
|
|
1718
|
+
infos[slotIdx] = info;
|
|
1719
|
+
recoveredCount += 1;
|
|
1720
|
+
}
|
|
1721
|
+
});
|
|
1722
|
+
if (recoveredCount > 0) {
|
|
1723
|
+
// eslint-disable-next-line no-console
|
|
1724
|
+
console.warn('[vercora:fetchAllResolvers] getMultipleAccountsInfo returned null for slots that getAccountInfo found — using the single-account results (RPC batch inconsistency).', {
|
|
1725
|
+
market: market.toBase58(),
|
|
1726
|
+
programId: expectedProgram.toBase58(),
|
|
1727
|
+
rpc: this.connection.rpcEndpoint,
|
|
1728
|
+
recoveredSlots: nullSlotIndices.filter((_, k) => !!rechecked[k]),
|
|
1729
|
+
stillMissingSlots: nullSlotIndices.filter((_, k) => !rechecked[k]),
|
|
1730
|
+
});
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1641
1733
|
const results = [];
|
|
1734
|
+
const debugRows = [];
|
|
1642
1735
|
for (let i = 0; i < numResolvers; i++) {
|
|
1643
1736
|
const info = infos[i];
|
|
1644
1737
|
if (!info) {
|
|
1645
1738
|
results.push(null);
|
|
1739
|
+
if (options?.debug) {
|
|
1740
|
+
debugRows.push({
|
|
1741
|
+
index: i,
|
|
1742
|
+
pda: pdas[i].toBase58(),
|
|
1743
|
+
accountExists: false,
|
|
1744
|
+
});
|
|
1745
|
+
}
|
|
1646
1746
|
continue;
|
|
1647
1747
|
}
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1748
|
+
const ownerMatchesProgram = info.owner.equals(expectedProgram);
|
|
1749
|
+
const buf = Buffer.from(info.data);
|
|
1750
|
+
const expectedDisc = (0, resolverDecode_1.resolverDiscriminatorFromIdl)(this.program);
|
|
1751
|
+
const actualDisc = buf.subarray(0, 8);
|
|
1752
|
+
const discriminatorMatch = !!(expectedDisc &&
|
|
1753
|
+
expectedDisc.length === 8 &&
|
|
1754
|
+
actualDisc.equals(expectedDisc));
|
|
1755
|
+
// `trustOwner: true` only when the account is owned by this program. The resolver PDA is
|
|
1756
|
+
// derived from program-controlled seeds, so a program-owned account at this PDA must have
|
|
1757
|
+
// been created by `initialize_market_resolver`. This lets wallets still match resolver
|
|
1758
|
+
// slots when the browser IDL differs from the deployed program (e.g. after `declare_id!`
|
|
1759
|
+
// rotation or IDL lag following a redeploy); without it, `findResolverSlot` would return
|
|
1760
|
+
// null and the UI would refuse to show resolver voting controls.
|
|
1761
|
+
const resolverPubkey = (0, resolverDecode_1.decodeResolverPubkeyFromAccountData)(this.program, buf, {
|
|
1762
|
+
trustOwner: ownerMatchesProgram,
|
|
1763
|
+
});
|
|
1764
|
+
if (resolverPubkey) {
|
|
1765
|
+
results.push({ index: i, resolverPubkey });
|
|
1766
|
+
if (options?.debug) {
|
|
1767
|
+
debugRows.push({
|
|
1768
|
+
index: i,
|
|
1769
|
+
pda: pdas[i].toBase58(),
|
|
1770
|
+
accountExists: true,
|
|
1771
|
+
owner: info.owner.toBase58(),
|
|
1772
|
+
ownerMatchesProgram,
|
|
1773
|
+
resolverPubkey: resolverPubkey.toBase58(),
|
|
1774
|
+
dataLen: buf.length,
|
|
1775
|
+
discriminatorMatch,
|
|
1776
|
+
expectedDiscHex: expectedDisc?.toString('hex') ?? null,
|
|
1777
|
+
actualDiscHex: actualDisc.toString('hex'),
|
|
1778
|
+
});
|
|
1656
1779
|
}
|
|
1657
1780
|
}
|
|
1658
|
-
|
|
1781
|
+
else {
|
|
1659
1782
|
results.push(null);
|
|
1783
|
+
if (options?.debug) {
|
|
1784
|
+
debugRows.push({
|
|
1785
|
+
index: i,
|
|
1786
|
+
pda: pdas[i].toBase58(),
|
|
1787
|
+
accountExists: true,
|
|
1788
|
+
owner: info.owner.toBase58(),
|
|
1789
|
+
ownerMatchesProgram,
|
|
1790
|
+
decodeError: true,
|
|
1791
|
+
dataLen: buf.length,
|
|
1792
|
+
discriminatorMatch,
|
|
1793
|
+
expectedDiscHex: expectedDisc?.toString('hex') ?? null,
|
|
1794
|
+
actualDiscHex: actualDisc.toString('hex'),
|
|
1795
|
+
});
|
|
1796
|
+
}
|
|
1660
1797
|
}
|
|
1661
1798
|
}
|
|
1799
|
+
if (options?.debug) {
|
|
1800
|
+
const badOwnerSlots = debugRows.filter((r) => r.accountExists && r.ownerMatchesProgram === false);
|
|
1801
|
+
if (badOwnerSlots.length > 0) {
|
|
1802
|
+
// eslint-disable-next-line no-console
|
|
1803
|
+
console.warn('[vercora:fetchAllResolvers] account at resolver PDA is not owned by this program (wrong deploy / cluster / IDL?)', {
|
|
1804
|
+
expectedProgram: expectedProgram.toBase58(),
|
|
1805
|
+
rpc: this.connection.rpcEndpoint,
|
|
1806
|
+
slots: badOwnerSlots,
|
|
1807
|
+
});
|
|
1808
|
+
}
|
|
1809
|
+
const wrongDiscOwnerOk = debugRows.filter((r) => r.accountExists &&
|
|
1810
|
+
r.ownerMatchesProgram &&
|
|
1811
|
+
r.decodeError &&
|
|
1812
|
+
r.discriminatorMatch === false);
|
|
1813
|
+
if (wrongDiscOwnerOk.length > 0) {
|
|
1814
|
+
// eslint-disable-next-line no-console
|
|
1815
|
+
console.warn('[vercora:fetchAllResolvers] program-owned account at resolver PDA has wrong discriminator (not Resolver for this IDL — wrong seeds vs on-chain program, wrong market PDA, or wrong program id for derivation)', { rpc: this.connection.rpcEndpoint, slots: wrongDiscOwnerOk });
|
|
1816
|
+
}
|
|
1817
|
+
const initializedN = results.filter((r) => r !== null).length;
|
|
1818
|
+
const missingAccountN = debugRows.filter((r) => !r.accountExists).length;
|
|
1819
|
+
const decodeErrN = debugRows.filter((r) => r.decodeError === true).length;
|
|
1820
|
+
const badOwnerN = debugRows.filter((r) => r.accountExists && r.ownerMatchesProgram === false).length;
|
|
1821
|
+
// One-line summary so a collapsed console row still shows the diagnosis.
|
|
1822
|
+
// eslint-disable-next-line no-console
|
|
1823
|
+
console.info(`[vercora:fetchAllResolvers] decoded=${initializedN}/${numResolvers} missingAccount=${missingAccountN} decodeError=${decodeErrN} badOwner=${badOwnerN} market=${market.toBase58().slice(0, 8)}…`, {
|
|
1824
|
+
programId: expectedProgram.toBase58(),
|
|
1825
|
+
market: market.toBase58(),
|
|
1826
|
+
numResolvers,
|
|
1827
|
+
rpc: this.connection.rpcEndpoint,
|
|
1828
|
+
slots: debugRows,
|
|
1829
|
+
initializedCount: initializedN,
|
|
1830
|
+
});
|
|
1831
|
+
}
|
|
1662
1832
|
return results.filter((r) => r !== null);
|
|
1663
1833
|
}
|
|
1664
1834
|
// ─── Internal ────────────────────────────────────────────────────────────────
|