@useaccord/sdk 0.1.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/README.md +126 -0
- package/dist/accord.d.ts +43 -0
- package/dist/accord.d.ts.map +1 -0
- package/dist/adapter.d.ts +39 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/chunk-7QVYU63E.js +7 -0
- package/dist/chunk-7QVYU63E.js.map +1 -0
- package/dist/constants.d.ts +83 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/domain.d.ts +73 -0
- package/dist/domain.d.ts.map +1 -0
- package/dist/errors.d.ts +64 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/evidence/crypto.d.ts +12 -0
- package/dist/evidence/crypto.d.ts.map +1 -0
- package/dist/evidence/ecies.d.ts +45 -0
- package/dist/evidence/ecies.d.ts.map +1 -0
- package/dist/evidence/fetch.d.ts +20 -0
- package/dist/evidence/fetch.d.ts.map +1 -0
- package/dist/evidence/index.d.ts +27 -0
- package/dist/evidence/index.d.ts.map +1 -0
- package/dist/evidence/index.js +392 -0
- package/dist/evidence/index.js.map +1 -0
- package/dist/evidence/keys.d.ts +33 -0
- package/dist/evidence/keys.d.ts.map +1 -0
- package/dist/evidence/manifest.d.ts +47 -0
- package/dist/evidence/manifest.d.ts.map +1 -0
- package/dist/evidence/options.d.ts +14 -0
- package/dist/evidence/options.d.ts.map +1 -0
- package/dist/evidence/parse.d.ts +39 -0
- package/dist/evidence/parse.d.ts.map +1 -0
- package/dist/evidence/publish.d.ts +45 -0
- package/dist/evidence/publish.d.ts.map +1 -0
- package/dist/fetch.d.ts +24 -0
- package/dist/fetch.d.ts.map +1 -0
- package/dist/generated/accounts/accordState.d.ts +58 -0
- package/dist/generated/accounts/accordState.d.ts.map +1 -0
- package/dist/generated/accounts/appealBond.d.ts +61 -0
- package/dist/generated/accounts/appealBond.d.ts.map +1 -0
- package/dist/generated/accounts/dispute.d.ts +213 -0
- package/dist/generated/accounts/dispute.d.ts.map +1 -0
- package/dist/generated/accounts/index.d.ts +15 -0
- package/dist/generated/accounts/index.d.ts.map +1 -0
- package/dist/generated/accounts/jurorStake.d.ts +137 -0
- package/dist/generated/accounts/jurorStake.d.ts.map +1 -0
- package/dist/generated/accounts/pendingUpdate.d.ts +43 -0
- package/dist/generated/accounts/pendingUpdate.d.ts.map +1 -0
- package/dist/generated/accounts/round.d.ts +143 -0
- package/dist/generated/accounts/round.d.ts.map +1 -0
- package/dist/generated/accounts/subaccord.d.ts +300 -0
- package/dist/generated/accounts/subaccord.d.ts.map +1 -0
- package/dist/generated/errors/accord.d.ts +160 -0
- package/dist/generated/errors/accord.d.ts.map +1 -0
- package/dist/generated/errors/index.d.ts +9 -0
- package/dist/generated/errors/index.d.ts.map +1 -0
- package/dist/generated/index.d.ts +14 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/instructions/appeal.d.ts +107 -0
- package/dist/generated/instructions/appeal.d.ts.map +1 -0
- package/dist/generated/instructions/cancelDispute.d.ts +73 -0
- package/dist/generated/instructions/cancelDispute.d.ts.map +1 -0
- package/dist/generated/instructions/claimAppealRefund.d.ts +91 -0
- package/dist/generated/instructions/claimAppealRefund.d.ts.map +1 -0
- package/dist/generated/instructions/commit.d.ts +50 -0
- package/dist/generated/instructions/commit.d.ts.map +1 -0
- package/dist/generated/instructions/commitVrfCallback.d.ts +47 -0
- package/dist/generated/instructions/commitVrfCallback.d.ts.map +1 -0
- package/dist/generated/instructions/createDispute.d.ts +136 -0
- package/dist/generated/instructions/createDispute.d.ts.map +1 -0
- package/dist/generated/instructions/createSubaccord.d.ts +196 -0
- package/dist/generated/instructions/createSubaccord.d.ts.map +1 -0
- package/dist/generated/instructions/drawSeat.d.ts +74 -0
- package/dist/generated/instructions/drawSeat.d.ts.map +1 -0
- package/dist/generated/instructions/executeSubaccordUpdate.d.ts +43 -0
- package/dist/generated/instructions/executeSubaccordUpdate.d.ts.map +1 -0
- package/dist/generated/instructions/executeUnpause.d.ts +59 -0
- package/dist/generated/instructions/executeUnpause.d.ts.map +1 -0
- package/dist/generated/instructions/finalizeDispute.d.ts +46 -0
- package/dist/generated/instructions/finalizeDispute.d.ts.map +1 -0
- package/dist/generated/instructions/finalizeRound.d.ts +46 -0
- package/dist/generated/instructions/finalizeRound.d.ts.map +1 -0
- package/dist/generated/instructions/getRuling.d.ts +42 -0
- package/dist/generated/instructions/getRuling.d.ts.map +1 -0
- package/dist/generated/instructions/health.d.ts +37 -0
- package/dist/generated/instructions/health.d.ts.map +1 -0
- package/dist/generated/instructions/index.d.ts +37 -0
- package/dist/generated/instructions/index.d.ts.map +1 -0
- package/dist/generated/instructions/initializePause.d.ts +51 -0
- package/dist/generated/instructions/initializePause.d.ts.map +1 -0
- package/dist/generated/instructions/pause.d.ts +47 -0
- package/dist/generated/instructions/pause.d.ts.map +1 -0
- package/dist/generated/instructions/proposeSubaccordUpdate.d.ts +90 -0
- package/dist/generated/instructions/proposeSubaccordUpdate.d.ts.map +1 -0
- package/dist/generated/instructions/proposeUnpause.d.ts +47 -0
- package/dist/generated/instructions/proposeUnpause.d.ts.map +1 -0
- package/dist/generated/instructions/pruneJuror.d.ts +68 -0
- package/dist/generated/instructions/pruneJuror.d.ts.map +1 -0
- package/dist/generated/instructions/reclaimSlot.d.ts +48 -0
- package/dist/generated/instructions/reclaimSlot.d.ts.map +1 -0
- package/dist/generated/instructions/reconcileStake.d.ts +48 -0
- package/dist/generated/instructions/reconcileStake.d.ts.map +1 -0
- package/dist/generated/instructions/redraw.d.ts +86 -0
- package/dist/generated/instructions/redraw.d.ts.map +1 -0
- package/dist/generated/instructions/requestVrf.d.ts +71 -0
- package/dist/generated/instructions/requestVrf.d.ts.map +1 -0
- package/dist/generated/instructions/requestWithdraw.d.ts +61 -0
- package/dist/generated/instructions/requestWithdraw.d.ts.map +1 -0
- package/dist/generated/instructions/reveal.d.ts +53 -0
- package/dist/generated/instructions/reveal.d.ts.map +1 -0
- package/dist/generated/instructions/settleRound.d.ts +60 -0
- package/dist/generated/instructions/settleRound.d.ts.map +1 -0
- package/dist/generated/instructions/stake.d.ts +98 -0
- package/dist/generated/instructions/stake.d.ts.map +1 -0
- package/dist/generated/instructions/withdraw.d.ts +67 -0
- package/dist/generated/instructions/withdraw.d.ts.map +1 -0
- package/dist/generated/instructions/withdrawFees.d.ts +67 -0
- package/dist/generated/instructions/withdrawFees.d.ts.map +1 -0
- package/dist/generated/pdas/accordState.d.ts +12 -0
- package/dist/generated/pdas/accordState.d.ts.map +1 -0
- package/dist/generated/pdas/appealBond.d.ts +16 -0
- package/dist/generated/pdas/appealBond.d.ts.map +1 -0
- package/dist/generated/pdas/dispute.d.ts +16 -0
- package/dist/generated/pdas/dispute.d.ts.map +1 -0
- package/dist/generated/pdas/index.d.ts +16 -0
- package/dist/generated/pdas/index.d.ts.map +1 -0
- package/dist/generated/pdas/jurorStake.d.ts +16 -0
- package/dist/generated/pdas/jurorStake.d.ts.map +1 -0
- package/dist/generated/pdas/pendingUpdate.d.ts +16 -0
- package/dist/generated/pdas/pendingUpdate.d.ts.map +1 -0
- package/dist/generated/pdas/programIdentity.d.ts +12 -0
- package/dist/generated/pdas/programIdentity.d.ts.map +1 -0
- package/dist/generated/pdas/round.d.ts +16 -0
- package/dist/generated/pdas/round.d.ts.map +1 -0
- package/dist/generated/pdas/subaccord.d.ts +16 -0
- package/dist/generated/pdas/subaccord.d.ts.map +1 -0
- package/dist/generated/programs/accord.d.ts +182 -0
- package/dist/generated/programs/accord.d.ts.map +1 -0
- package/dist/generated/programs/index.d.ts +9 -0
- package/dist/generated/programs/index.d.ts.map +1 -0
- package/dist/generated/types/aggregation.d.ts +25 -0
- package/dist/generated/types/aggregation.d.ts.map +1 -0
- package/dist/generated/types/caseTerms.d.ts +87 -0
- package/dist/generated/types/caseTerms.d.ts.map +1 -0
- package/dist/generated/types/disputeState.d.ts +34 -0
- package/dist/generated/types/disputeState.d.ts.map +1 -0
- package/dist/generated/types/index.d.ts +15 -0
- package/dist/generated/types/index.d.ts.map +1 -0
- package/dist/generated/types/leafClaim.d.ts +27 -0
- package/dist/generated/types/leafClaim.d.ts.map +1 -0
- package/dist/generated/types/mSTNode.d.ts +26 -0
- package/dist/generated/types/mSTNode.d.ts.map +1 -0
- package/dist/generated/types/shortfallPolicy.d.ts +23 -0
- package/dist/generated/types/shortfallPolicy.d.ts.map +1 -0
- package/dist/generated/types/updatePayload.d.ts +107 -0
- package/dist/generated/types/updatePayload.d.ts.map +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8714 -0
- package/dist/index.js.map +1 -0
- package/dist/methods/appeal.d.ts +131 -0
- package/dist/methods/appeal.d.ts.map +1 -0
- package/dist/methods/dispute.d.ts +177 -0
- package/dist/methods/dispute.d.ts.map +1 -0
- package/dist/methods/disputePhase.d.ts +34 -0
- package/dist/methods/disputePhase.d.ts.map +1 -0
- package/dist/methods/lifecycle.d.ts +228 -0
- package/dist/methods/lifecycle.d.ts.map +1 -0
- package/dist/methods/mst.d.ts +100 -0
- package/dist/methods/mst.d.ts.map +1 -0
- package/dist/methods/settlement.d.ts +69 -0
- package/dist/methods/settlement.d.ts.map +1 -0
- package/dist/methods/stakeFlow.d.ts +65 -0
- package/dist/methods/stakeFlow.d.ts.map +1 -0
- package/dist/methods/staking.d.ts +220 -0
- package/dist/methods/staking.d.ts.map +1 -0
- package/dist/methods/voting.d.ts +227 -0
- package/dist/methods/voting.d.ts.map +1 -0
- package/dist/methods/vrf.d.ts +143 -0
- package/dist/methods/vrf.d.ts.map +1 -0
- package/dist/methods.d.ts +79 -0
- package/dist/methods.d.ts.map +1 -0
- package/dist/pda.d.ts +37 -0
- package/dist/pda.d.ts.map +1 -0
- package/dist/queries.d.ts +27 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/query.d.ts +30 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/token.d.ts +24 -0
- package/dist/token.d.ts.map +1 -0
- package/dist/types.d.ts +19 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/wallet.d.ts +30 -0
- package/dist/wallet.d.ts.map +1 -0
- package/package.json +45 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* voting.ts — commit-reveal voting + finalization cranks (ADR-0010) with
|
|
3
|
+
* scalar u64 votes (ADR-0025).
|
|
4
|
+
*
|
|
5
|
+
* The load-bearing client-side cryptography lives here: the commit hash
|
|
6
|
+
* `sha256(vote_le[8] ‖ salt[32] ‖ juror_pubkey[32])`
|
|
7
|
+
* where `vote_le` is the vote's 8-byte little-endian encoding — votes are
|
|
8
|
+
* `u64` on the wire (option index for `Plurality`, fixed-point scalar in
|
|
9
|
+
* settlement-mint base units for `Median`). The on-chain `reveal`
|
|
10
|
+
* recomputes this via `solana_program::hash::hashv` (instructions/reveal.rs:
|
|
11
|
+
* `hashv(&[&vote.to_le_bytes(), &salt, juror_key.as_ref()])`) and checks it
|
|
12
|
+
* against the stored commitment. Mismatching the byte order or lengths here
|
|
13
|
+
* silently breaks every dispute, so `commitHash` is unit-tested against a
|
|
14
|
+
* hardcoded digest vector.
|
|
15
|
+
*
|
|
16
|
+
* Four instructions are orchestrated:
|
|
17
|
+
* - {@link commit} juror commits `hash(vote, salt, juror)`.
|
|
18
|
+
* - {@link reveal} juror reveals `{vote, salt}` (chain re-derives hash).
|
|
19
|
+
* - {@link finalizeRound} permissionless crank: tally (plurality or median) → RoundResolved.
|
|
20
|
+
* - {@link finalizeDispute} permissionless crank: settles economics, writes ruling.
|
|
21
|
+
*
|
|
22
|
+
* As in dispute.ts, the module is pure facade orchestration over a typed
|
|
23
|
+
* {@link AccordVotingClient} seam that Foundation wires to the Codama-generated
|
|
24
|
+
* Kit client. Kit is imported type-only (erased at runtime); the PDA helper
|
|
25
|
+
* lazy-imports Kit so the unit tests load zero runtime deps.
|
|
26
|
+
*
|
|
27
|
+
* Sources of truth:
|
|
28
|
+
* - commit/reveal/finalize_*: programs/accord/src/instructions/{commit,reveal,finalize_round,finalize_dispute}.rs
|
|
29
|
+
* - Round struct + seeds: programs/accord/src/state.rs (Round, SEED_ROUND)
|
|
30
|
+
*/
|
|
31
|
+
import type { Address, Instruction } from "@solana/kit";
|
|
32
|
+
/**
|
|
33
|
+
* No-reveal sentinel: `u64::MAX` marks "not revealed" in `Round.reveals` and
|
|
34
|
+
* "not set" in `Round.result` (ADR-0025; was `u8::MAX` before scalar votes).
|
|
35
|
+
* Both aggregation modes reject it as an actual vote on-chain.
|
|
36
|
+
*/
|
|
37
|
+
export declare const NO_VOTE = 18446744073709551615n;
|
|
38
|
+
/**
|
|
39
|
+
* Shared accounts every voting instruction takes (juror or cranker signs).
|
|
40
|
+
*
|
|
41
|
+
* `commit`/`reveal`/`finalizeRound`/`finalizeDispute` use only the first four.
|
|
42
|
+
* The `stakingToken`/`jurorTokenAccount`/`vault` fields are vestigial: pre
|
|
43
|
+
* ADR-0020 `reveal` paid a fee on reveal; that credit now happens in
|
|
44
|
+
* `finalize_round`. The adapter ignores them and the chain doesn't ask.
|
|
45
|
+
* `tokenProgram` is a fixed constant.
|
|
46
|
+
*/
|
|
47
|
+
export interface VotingAccounts {
|
|
48
|
+
/** Commit/reveal: the drawn juror. finalize_*: any cranker. Always a signer. */
|
|
49
|
+
signer: Address;
|
|
50
|
+
subaccord: Address;
|
|
51
|
+
dispute: Address;
|
|
52
|
+
round: Address;
|
|
53
|
+
/** @deprecated vestigial — reveal no longer moves tokens (ADR-0020). */
|
|
54
|
+
stakingToken?: Address;
|
|
55
|
+
/** @deprecated vestigial — reveal no longer moves tokens (ADR-0020). */
|
|
56
|
+
jurorTokenAccount?: Address;
|
|
57
|
+
/** @deprecated vestigial — reveal no longer moves tokens (ADR-0020). */
|
|
58
|
+
vault?: Address;
|
|
59
|
+
}
|
|
60
|
+
/** A juror's vote + salt (the reveal preimage). */
|
|
61
|
+
export interface VoteArgs {
|
|
62
|
+
/**
|
|
63
|
+
* The vote, `u64` on the wire (ADR-0025): an option index for `Plurality`
|
|
64
|
+
* disputes or a scaled scalar for `Median` (see {@link encodeScalarVote}).
|
|
65
|
+
*/
|
|
66
|
+
vote: bigint;
|
|
67
|
+
/** 32-byte random salt — secret until reveal. */
|
|
68
|
+
salt: Uint8Array;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Compute the commit hash `sha256(vote_le[8] ‖ salt[32] ‖ juror_pubkey[32])`.
|
|
72
|
+
*
|
|
73
|
+
* Bit-for-bit compatible with the on-chain `reveal` check
|
|
74
|
+
* (instructions/reveal.rs): `hashv(&[&vote.to_le_bytes(), &salt,
|
|
75
|
+
* juror_key.as_ref()]).to_bytes()` — the vote is hashed as 8-byte
|
|
76
|
+
* little-endian (ADR-0025), so the preimage is 72 bytes.
|
|
77
|
+
*
|
|
78
|
+
* Uses the Web Crypto API (`globalThis.crypto.subtle`): zero-dependency,
|
|
79
|
+
* available in Node ≥ 18 and all browsers. `jurorBytes` is the juror's 32-byte
|
|
80
|
+
* pubkey encoding (Kit's `getAddressEncoder().encode(juror)`).
|
|
81
|
+
*/
|
|
82
|
+
export declare function commitHash(vote: bigint, salt: Uint8Array, jurorBytes: Uint8Array): Promise<Uint8Array>;
|
|
83
|
+
/**
|
|
84
|
+
* Validate an option-index vote for `Plurality` disputes: `vote <
|
|
85
|
+
* num_options` (instructions/reveal.rs). `Median` scalars carry no
|
|
86
|
+
* client-side range beyond the u64 fit checked in {@link commitHash} and the
|
|
87
|
+
* facades. Pure.
|
|
88
|
+
*/
|
|
89
|
+
export declare function assertValidVote(vote: bigint, numOptions: number): void;
|
|
90
|
+
/** Validate the salt is 32 bytes. Pure. */
|
|
91
|
+
export declare function assertValidSalt(salt: Uint8Array): void;
|
|
92
|
+
/**
|
|
93
|
+
* Encode a human-readable scalar vote (ADR-0025 `Median` disputes) as the
|
|
94
|
+
* u64 base-unit bigint the wire takes: `input · 10^decimals`. Accepts plain
|
|
95
|
+
* decimal strings (`"123"`, `"123.45"`); rejects anything else (sign,
|
|
96
|
+
* exponent, separators, empty string) and fractions longer than `decimals`.
|
|
97
|
+
* The `u64` fit is enforced downstream ({@link commitHash} / the facades).
|
|
98
|
+
* Inverse of {@link decodeScalarVote}.
|
|
99
|
+
*/
|
|
100
|
+
export declare function encodeScalarVote(input: string, decimals?: number): bigint;
|
|
101
|
+
/**
|
|
102
|
+
* Decode a u64 base-unit vote back to a plain decimal string (inverse of
|
|
103
|
+
* {@link encodeScalarVote}): `123450000n` → `"123.45"` at the default 6
|
|
104
|
+
* decimals. Trailing fraction zeros are trimmed; a zero fraction collapses
|
|
105
|
+
* to the integer form. Pure.
|
|
106
|
+
*/
|
|
107
|
+
export declare function decodeScalarVote(vote: bigint, decimals?: number): string;
|
|
108
|
+
/**
|
|
109
|
+
* Build the Round PDA seed bytes (state.rs:2124):
|
|
110
|
+
* `["round", dispute.key(), ¤t_round.to_le_bytes()]`.
|
|
111
|
+
*
|
|
112
|
+
* `roundIdx` is `u32` little-endian (4 bytes). Pure + deterministic.
|
|
113
|
+
*/
|
|
114
|
+
export declare function roundSeeds(disputeBytes: Uint8Array, roundIdx: number): Uint8Array[];
|
|
115
|
+
/** Derive the canonical Round PDA. Kit lazy-imported. */
|
|
116
|
+
export declare function findRoundPda(programAddress: Address, dispute: Address, roundIdx: number): Promise<{
|
|
117
|
+
address: Address;
|
|
118
|
+
bump: number;
|
|
119
|
+
}>;
|
|
120
|
+
/**
|
|
121
|
+
* Seam to the Codama-generated Kit client (ADR-0010). Foundation provides the
|
|
122
|
+
* concrete adapter; voting.ts stays orchestration-only, so it is parallel-safe
|
|
123
|
+
* under fleet dispatch and compile-verifiable before the generator lands.
|
|
124
|
+
*/
|
|
125
|
+
export interface AccordVotingClient {
|
|
126
|
+
buildCommit(input: {
|
|
127
|
+
programId: Address;
|
|
128
|
+
accounts: VotingAccounts;
|
|
129
|
+
commitment: Uint8Array;
|
|
130
|
+
}): Instruction;
|
|
131
|
+
buildReveal(input: {
|
|
132
|
+
programId: Address;
|
|
133
|
+
accounts: VotingAccounts;
|
|
134
|
+
vote: bigint;
|
|
135
|
+
salt: Uint8Array;
|
|
136
|
+
}): Instruction;
|
|
137
|
+
buildFinalizeRound(input: {
|
|
138
|
+
programId: Address;
|
|
139
|
+
accounts: VotingAccounts;
|
|
140
|
+
remainingAccounts?: Address[];
|
|
141
|
+
}): Instruction;
|
|
142
|
+
buildFinalizeDispute(input: {
|
|
143
|
+
programId: Address;
|
|
144
|
+
accounts: VotingAccounts;
|
|
145
|
+
/** remaining_accounts: drawn JurorStake PDAs (+ AppealBond PDAs). */
|
|
146
|
+
remainingAccounts: Address[];
|
|
147
|
+
}): Instruction;
|
|
148
|
+
/** `redraw` (ADR-0021) — see {@link redraw}. */
|
|
149
|
+
buildRedraw(input: {
|
|
150
|
+
programId: Address;
|
|
151
|
+
accounts: RedrawAccounts;
|
|
152
|
+
remainingAccounts?: Address[];
|
|
153
|
+
}): Instruction;
|
|
154
|
+
/** Encode a juror Address to its 32-byte pubkey (Kit `getAddressEncoder`). */
|
|
155
|
+
encodeAddress(address: Address): Uint8Array;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Build a `commit` instruction: compute `commitHash(vote, salt, juror)` and
|
|
159
|
+
* hand the 32-byte commitment to the chain (instructions/commit.rs). The
|
|
160
|
+
* juror must be drawn into the round and inside the commit window; those
|
|
161
|
+
* gates are enforced on-chain. Returns the instruction + the computed
|
|
162
|
+
* commitment (for local bookkeeping / indexing).
|
|
163
|
+
*/
|
|
164
|
+
export declare function commit(client: AccordVotingClient, programId: Address, accounts: VotingAccounts, args: VoteArgs): Promise<{
|
|
165
|
+
instruction: Instruction;
|
|
166
|
+
commitment: Uint8Array;
|
|
167
|
+
}>;
|
|
168
|
+
/**
|
|
169
|
+
* Build a `reveal` instruction with `{vote, salt}` (instructions/reveal.rs).
|
|
170
|
+
* The chain recomputes `hash(vote_le ‖ salt ‖ juror)` and checks it equals
|
|
171
|
+
* the stored commitment — so `args` MUST be the exact pair used in
|
|
172
|
+
* {@link commit}.
|
|
173
|
+
*/
|
|
174
|
+
export declare function reveal(client: AccordVotingClient, programId: Address, accounts: VotingAccounts, args: VoteArgs): Instruction;
|
|
175
|
+
/**
|
|
176
|
+
* Build the permissionless `finalize_round` crank
|
|
177
|
+
* (instructions/finalize_round.rs). After the reveal window elapses, anyone
|
|
178
|
+
* can advance the dispute to `RoundResolved` with the tally winner written
|
|
179
|
+
* to `round.result` (plurality option or median scalar, ADR-0025).
|
|
180
|
+
* ADR-0020: credits
|
|
181
|
+
* `fees_earned` to each revealer — pass the panel's JurorStake PDAs as
|
|
182
|
+
* `remainingAccounts` when `fee_per_juror > 0`.
|
|
183
|
+
*/
|
|
184
|
+
export declare function finalizeRound(client: AccordVotingClient, programId: Address, accounts: VotingAccounts, remainingAccounts?: Address[]): Instruction;
|
|
185
|
+
/**
|
|
186
|
+
* Build the permissionless `finalize_dispute` crank
|
|
187
|
+
* (instructions/finalize_dispute.rs). After the appeal window elapses,
|
|
188
|
+
* anyone can settle the final round: slash incoherent
|
|
189
|
+
* jurors, redistribute the pool, decrement `active_draws`, and write
|
|
190
|
+
* `final_ruling` (transition to `Final`).
|
|
191
|
+
*
|
|
192
|
+
* `remainingAccounts` = the drawn `JurorStake` PDAs (panel), followed by one
|
|
193
|
+
* `AppealBond` PDA per prior appeal (`current_round` of them). With no appeals
|
|
194
|
+
* this collapses to just the juror stakes.
|
|
195
|
+
*/
|
|
196
|
+
export declare function finalizeDispute(client: AccordVotingClient, programId: Address, accounts: VotingAccounts, remainingAccounts: Address[]): Instruction;
|
|
197
|
+
/**
|
|
198
|
+
* Accounts for `redraw` (lib.rs). The Fail branch refunds the filer from
|
|
199
|
+
* `feeVault`, so it carries the filer's `feeToken` ATA + the vault (validated
|
|
200
|
+
* but unused on the Redraw branch).
|
|
201
|
+
*/
|
|
202
|
+
export interface RedrawAccounts {
|
|
203
|
+
/** Permissionless cranker. */
|
|
204
|
+
caller: Address;
|
|
205
|
+
subaccord: Address;
|
|
206
|
+
dispute: Address;
|
|
207
|
+
/** The shortfall round (`dispute.current_round`). */
|
|
208
|
+
round: Address;
|
|
209
|
+
feeToken: Address;
|
|
210
|
+
/** Filer's `feeToken` ATA — refund destination on exhaustion. */
|
|
211
|
+
filerTokenAccount: Address;
|
|
212
|
+
feeVault: Address;
|
|
213
|
+
tokenProgram: Address;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Build the permissionless `redraw` crank (lib.rs, ADR-0021). Only callable
|
|
217
|
+
* from `RedrawEligible`. Slashes no-shows into `stake_delta`, bumps
|
|
218
|
+
* `round.draw_attempt` (orthogonal to `round_idx` — same panel size, no appeal
|
|
219
|
+
* consumed), clears the round → `Created`; on `draw_attempt + 1 ≥
|
|
220
|
+
* max_draw_attempts` → `Failed` (filer `fee_paid` refunded, slashes stand).
|
|
221
|
+
*
|
|
222
|
+
* `remainingAccounts` = the round's drawn `JurorStake` PDAs (panel); on the Fail
|
|
223
|
+
* branch additionally prior-round `Round` PDAs + their `JurorStake` PDAs + the
|
|
224
|
+
* dispute's `AppealBond` PDAs (same layout as `cancel_dispute`).
|
|
225
|
+
*/
|
|
226
|
+
export declare function redraw(client: AccordVotingClient, programId: Address, accounts: RedrawAccounts, remainingAccounts?: Address[]): Instruction;
|
|
227
|
+
//# sourceMappingURL=voting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"voting.d.ts","sourceRoot":"","sources":["../../src/methods/voting.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAExD;;;;GAIG;AACH,eAAO,MAAM,OAAO,wBAAyB,CAAC;AAQ9C;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC7B,gFAAgF;IAChF,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,KAA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AI,EAAE,QAAQ,GACb,WAAW,CAab;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,kBAAkB,EAC1B,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,cAAc,EACxB,iBAAiB,GAAE,OAAO,EAAO,GAChC,WAAW,CAEb;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,kBAAkB,EAC1B,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,cAAc,EACxB,iBAAiB,EAAE,OAAO,EAAE,GAC3B,WAAW,CAMb;AAID;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,8BAA8B;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,qDAAqD;IACrD,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,iEAAiE;IACjE,iBAAiB,EAAE,OAAO,CAAC;IAC3B,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CACpB,MAAM,EAAE,kBAAkB,EAC1B,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,cAAc,EACxB,iBAAiB,GAAE,OAAO,EAAO,GAChC,WAAW,CAEb"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vrf.ts — VRF request + per-seat draw choreography (ADR-0009 §2 + ADR-0012).
|
|
3
|
+
*
|
|
4
|
+
* 1. request_vrf — CPI into the magicblock VRF oracle (one-shot).
|
|
5
|
+
* 2. commit_vrf_callback — oracle calls back; sets `dispute.committed_vrf`
|
|
6
|
+
* AND atomically freezes `dispute.frozen_root`.
|
|
7
|
+
* 3. draw_seat(seat, mem) — submit one seat's membership against the frozen
|
|
8
|
+
* root. One tx per seat (1232B can't hold N proofs).
|
|
9
|
+
*
|
|
10
|
+
* The VRF result is committed ONCE and immutable. The frozen root is the live
|
|
11
|
+
* accumulator root captured atomically at callback time — all N draw_seat txs
|
|
12
|
+
* (and every appeal round) select against the SAME root.
|
|
13
|
+
*
|
|
14
|
+
* The chain is a dumb verifier: per seat `i`, it derives
|
|
15
|
+
* vrf_seed = sha256(committed_vrf ‖ dispute ‖ round_idx_le4 ‖ draw_attempt_le4)
|
|
16
|
+
* r_i = u64_le(sha256(vrf_seed ‖ seat_le4 ‖ retry_le4)[0..8]) % frozen_total_stake
|
|
17
|
+
* and checks the submitted leaf's reconstructed prefix ranges contains `r_i`.
|
|
18
|
+
* `draw_attempt` (ADR-0021) is orthogonal to `round_idx`: a shortfall redraw
|
|
19
|
+
* increments it to re-seed the panel at the same size (no appeal consumed).
|
|
20
|
+
* Deterministic collision re-roll (sampling without replacement) is computed
|
|
21
|
+
* client-side to match the chain — bean accord-tzo0.
|
|
22
|
+
*
|
|
23
|
+
* Sources of truth:
|
|
24
|
+
* - request_vrf / commit_vrf_callback / draw_seat: lib.rs
|
|
25
|
+
* - sortition criterion: ADR-0009 §2 (subtree-sum form, ADR-0012)
|
|
26
|
+
*/
|
|
27
|
+
import type { Address, Instruction } from "@solana/kit";
|
|
28
|
+
import { type LeafClaim, type MSTNode, type MerkleAccumulator } from "./mst.js";
|
|
29
|
+
/**
|
|
30
|
+
* `vrf_seed = sha256(committed_vrf ‖ dispute ‖ round_idx_le4 ‖ draw_attempt_le4)`
|
|
31
|
+
* (lib.rs draw_seat, ADR-0021). Binds the committed VRF to this dispute + round
|
|
32
|
+
* + redraw attempt. `drawAttempt` defaults to 0 (the initial draw); a shortfall
|
|
33
|
+
* redraw bumps it so the same panel size yields fresh seats.
|
|
34
|
+
*/
|
|
35
|
+
export declare function vrfSeed(committedVrf: Uint8Array, disputeBytes: Uint8Array, roundIdx: number, drawAttempt?: number): Promise<Uint8Array>;
|
|
36
|
+
/**
|
|
37
|
+
* Derive the sortition point for a single seat at a given retry:
|
|
38
|
+
* `r_i = u64_le(sha256(vrf_seed ‖ seat_le4 ‖ retry_le4)[0..8]) % frozen_total_stake`.
|
|
39
|
+
* `retry` defaults to 0 (the common case — no collision). The on-chain
|
|
40
|
+
* `draw_seat` includes the same retry counter in its sortition hash and verifies
|
|
41
|
+
* that every prior retry (0..retries) genuinely collided with an already-drawn
|
|
42
|
+
* juror (bean accord-tzo0).
|
|
43
|
+
*/
|
|
44
|
+
export declare function seatSlot(committedVrf: Uint8Array, disputeBytes: Uint8Array, roundIdx: number, seat: number, frozenTotalStake: bigint, retry?: number, drawAttempt?: number): Promise<bigint>;
|
|
45
|
+
/**
|
|
46
|
+
* Find the leaf in `tree` whose sortition range `[prefix, prefix+stake)`
|
|
47
|
+
* contains `slot`, and return it with its index + proof. Returns `null` if the
|
|
48
|
+
* slot lands in a zero-stake gap (no eligible leaf).
|
|
49
|
+
*/
|
|
50
|
+
export declare function findLeafForSlot(tree: MerkleAccumulator, slot: bigint): Promise<{
|
|
51
|
+
leaf: LeafClaim;
|
|
52
|
+
index: number;
|
|
53
|
+
proof: MSTNode[];
|
|
54
|
+
} | null>;
|
|
55
|
+
/**
|
|
56
|
+
* Resolve a single seat using the deterministic collision re-roll algorithm
|
|
57
|
+
* (bean accord-tzo0). Iterates `retry = 0, 1, 2, …` computing
|
|
58
|
+
* `r_i = sha256(seed ‖ seat ‖ retry) % total_stake`; the first retry whose
|
|
59
|
+
* selected leaf is NOT in `alreadyDrawn` is the terminal. Returns the leaf,
|
|
60
|
+
* proof, and the `retries` count the cranker must submit to `draw_seat`.
|
|
61
|
+
*
|
|
62
|
+
* The on-chain verifier independently confirms every prior retry collided — so
|
|
63
|
+
* there is exactly one valid (leaf, retries) pair per seat. No caller choice.
|
|
64
|
+
*/
|
|
65
|
+
export declare function resolveSeat(committedVrf: Uint8Array, disputeBytes: Uint8Array, roundIdx: number, seat: number, tree: MerkleAccumulator, alreadyDrawn: Uint8Array[], maxRetries?: number, drawAttempt?: number): Promise<{
|
|
66
|
+
leaf: LeafClaim;
|
|
67
|
+
index: number;
|
|
68
|
+
proof: MSTNode[];
|
|
69
|
+
retries: number;
|
|
70
|
+
}>;
|
|
71
|
+
/** Verify a seat's membership reconstructs to the frozen root (client-side precheck). */
|
|
72
|
+
export declare function verifySeat(leaf: LeafClaim, index: number, proof: MSTNode[], frozenRoot: Uint8Array, frozenTotalStake: bigint): Promise<boolean>;
|
|
73
|
+
/** Accounts for `request_vrf` / `draw_seat` (the cranker signs). */
|
|
74
|
+
export interface VrfDrawAccounts {
|
|
75
|
+
caller: Address;
|
|
76
|
+
subaccord: Address;
|
|
77
|
+
dispute: Address;
|
|
78
|
+
}
|
|
79
|
+
/** Extra accounts `request_vrf` needs for the VRF oracle CPI. */
|
|
80
|
+
export interface RequestVrfExtras {
|
|
81
|
+
/** magicblock VRF oracle queue account. */
|
|
82
|
+
oracleQueue: Address;
|
|
83
|
+
/** Accord program-identity PDA (CPI authority for the VRF oracle). */
|
|
84
|
+
programIdentity: Address;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* One seat's resolved membership: the leaf `(juror, stake)` at `index` plus its
|
|
88
|
+
* accumulator proof, the juror's `JurorStake` PDA (remaining_accounts[0]), and
|
|
89
|
+
* the deterministic collision re-roll count (bean accord-tzo0).
|
|
90
|
+
*/
|
|
91
|
+
export interface SeatMembership {
|
|
92
|
+
leaf: LeafClaim;
|
|
93
|
+
index: number;
|
|
94
|
+
proof: MSTNode[];
|
|
95
|
+
jurorStake: Address;
|
|
96
|
+
/** Number of sortition retries (collisions) before this leaf was selected. */
|
|
97
|
+
retries: number;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Seam to the Codama-generated Kit client + Dispute fetcher. Foundation wires
|
|
101
|
+
* the concrete adapter; vrf.ts stays orchestration-only.
|
|
102
|
+
*/
|
|
103
|
+
export interface AccordVrfClient {
|
|
104
|
+
buildRequestVrf(input: {
|
|
105
|
+
programId: Address;
|
|
106
|
+
accounts: VrfDrawAccounts;
|
|
107
|
+
extras: RequestVrfExtras;
|
|
108
|
+
}): Instruction;
|
|
109
|
+
buildDrawSeat(input: {
|
|
110
|
+
programId: Address;
|
|
111
|
+
accounts: VrfDrawAccounts;
|
|
112
|
+
/** Round PDA — `init_if_needed` by draw_seat (`["round", dispute, current_round]`). */
|
|
113
|
+
roundPda: Address;
|
|
114
|
+
seat: number;
|
|
115
|
+
/** Sortition collision re-roll count (bean accord-tzo0). */
|
|
116
|
+
retries: number;
|
|
117
|
+
leaf: LeafClaim;
|
|
118
|
+
proof: MSTNode[];
|
|
119
|
+
index: number;
|
|
120
|
+
jurorStake: Address;
|
|
121
|
+
}): Instruction;
|
|
122
|
+
/** Read `committed_vrf` from a Dispute; `null` until the oracle callback lands. */
|
|
123
|
+
fetchCommittedVrf(dispute: Address): Promise<Uint8Array | null>;
|
|
124
|
+
}
|
|
125
|
+
/** Build `request_vrf`. One-shot; triggers the oracle callback (freezes the root). */
|
|
126
|
+
export declare function requestVrf(client: AccordVrfClient, programId: Address, accounts: VrfDrawAccounts, extras: RequestVrfExtras): Instruction;
|
|
127
|
+
/**
|
|
128
|
+
* Poll a Dispute's `committed_vrf` until the oracle callback lands (or
|
|
129
|
+
* `timeoutMs` elapses). Returns the 32-byte randomness. Use between
|
|
130
|
+
* {@link requestVrf} and {@link drawSeat}.
|
|
131
|
+
*/
|
|
132
|
+
export declare function awaitCommittedVrf(client: AccordVrfClient, dispute: Address, opts?: {
|
|
133
|
+
pollIntervalMs?: number;
|
|
134
|
+
timeoutMs?: number;
|
|
135
|
+
}): Promise<Uint8Array>;
|
|
136
|
+
/**
|
|
137
|
+
* Build `draw_seat` for one seat (lib.rs). Pass the pre-resolved `seat` +
|
|
138
|
+
* membership (from {@link resolveSeat}) and the juror's `JurorStake` PDA. The
|
|
139
|
+
* round is `init_if_needed` on-chain and persists across the N seat txs.
|
|
140
|
+
* `membership.retries` carries the deterministic collision re-roll count.
|
|
141
|
+
*/
|
|
142
|
+
export declare function drawSeat(client: AccordVrfClient, programId: Address, accounts: VrfDrawAccounts, roundPda: Address, seat: number, membership: SeatMembership): Instruction;
|
|
143
|
+
//# sourceMappingURL=vrf.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vrf.d.ts","sourceRoot":"","sources":["../../src/methods/vrf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EACL,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,iBAAiB,EAGvB,MAAM,UAAU,CAAC;AAoClB;;;;;GAKG;AACH,wBAAsB,OAAO,CAC3B,YAAY,EAAE,UAAU,EACxB,YAAY,EAAE,UAAU,EACxB,QAAQ,EAAE,MAAM,EAChB,WAAW,GAAE,MAAU,GACtB,OAAO,CAAC,UAAU,CAAC,CAcrB;AAED;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAC5B,YAAY,EAAE,UAAU,EACxB,YAAY,EAAE,UAAU,EACxB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,MAAM,EACxB,KAAK,GAAE,MAAU,EACjB,WAAW,GAAE,MAAU,GACtB,OAAO,CAAC,MAAM,CAAC,CAWjB;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,iBAAiB,EACvB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,EAAE,CAAA;CAAE,GAAG,IAAI,CAAC,CAWtE;AAED;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAC/B,YAAY,EAAE,UAAU,EACxB,YAAY,EAAE,UAAU,EACxB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,iB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vF,QAAQ,EAAE,OAAO,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,4DAA4D;QAC5D,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,SAAS,CAAC;QAChB,KAAK,EAAE,OAAO,EAAE,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,OAAO,CAAC;KACrB,GAAG,WAAW,CAAC;IAChB,mFAAmF;IACnF,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;CACjE;AAED,sFAAsF;AACtF,wBAAgB,UAAU,CACxB,MAAM,EAAE,eAAe,EACvB,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,gBAAgB,GACvB,WAAW,CAEb;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,OAAO,EAChB,IAAI,GAAE;IAAE,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACzD,OAAO,CAAC,UAAU,CAAC,CASrB;AAMD;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,MAAM,EAAE,eAAe,EACvB,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,OAAO,EACjB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,cAAc,GACzB,WAAW,CAYb"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bound orchestration namespace — the eight Accord method groups, pre-bound to
|
|
3
|
+
* a concrete {@link AccordAdapter} + the canonical program id.
|
|
4
|
+
*
|
|
5
|
+
* Each entry forwards to the pure orchestration function in `src/methods/*.ts`,
|
|
6
|
+
* injecting the adapter as the `client` argument. The pure crypto helpers
|
|
7
|
+
* (`buildMst`, `resolvePanel`, `commitHash`, `appealCost`, …) are NOT bound
|
|
8
|
+
* here — they take no client, so import them directly from `@useaccord/sdk`.
|
|
9
|
+
*
|
|
10
|
+
* @see ADR-0010
|
|
11
|
+
*/
|
|
12
|
+
import type { Address, Instruction, TransactionSigner } from "@solana/kit";
|
|
13
|
+
import { type CreateDisputeAccounts, type CreateDisputeArgs } from "./methods/dispute.js";
|
|
14
|
+
import { type CreateSubaccordArgs, type UpdatePayload } from "./methods/lifecycle.js";
|
|
15
|
+
import type { MSTNode } from "./methods/mst.js";
|
|
16
|
+
import { type StakingAccounts, type WithdrawFeesAccounts, type PruneJurorAccounts } from "./methods/staking.js";
|
|
17
|
+
import { type CancelDisputeAccounts, type SettleRoundAccounts } from "./methods/settlement.js";
|
|
18
|
+
import { type SeatMembership, type RequestVrfExtras, type VrfDrawAccounts } from "./methods/vrf.js";
|
|
19
|
+
import { type RedrawAccounts, type VoteArgs, type VotingAccounts } from "./methods/voting.js";
|
|
20
|
+
import { type AppealAccounts, type ClaimRefundAccounts } from "./methods/appeal.js";
|
|
21
|
+
import type { AccordAdapter } from "./adapter.js";
|
|
22
|
+
/** Bound method groups returned by `accord.methods`. */
|
|
23
|
+
export interface AccordMethods {
|
|
24
|
+
createDispute(accounts: CreateDisputeAccounts, args: CreateDisputeArgs): Promise<{
|
|
25
|
+
instruction: Instruction;
|
|
26
|
+
dispute: Address;
|
|
27
|
+
bump: number;
|
|
28
|
+
}>;
|
|
29
|
+
getRuling(dispute: Address): Promise<bigint | null>;
|
|
30
|
+
createSubaccord(creator: Address, args: CreateSubaccordArgs): Promise<{
|
|
31
|
+
instruction: Instruction;
|
|
32
|
+
subaccord: Address;
|
|
33
|
+
bump: number;
|
|
34
|
+
}>;
|
|
35
|
+
proposeSubaccordUpdate(authority: Address, subaccord: Address, nonce: bigint, payload: UpdatePayload): Promise<{
|
|
36
|
+
instruction: Instruction;
|
|
37
|
+
pendingUpdate: Address;
|
|
38
|
+
}>;
|
|
39
|
+
getUpdateExecuteAfterSlot(pendingUpdate: Address): Promise<bigint | null>;
|
|
40
|
+
executeSubaccordUpdate(caller: Address, subaccord: Address, pendingUpdate: Address): Instruction;
|
|
41
|
+
initializePause(authority: Address): Promise<{
|
|
42
|
+
instruction: Instruction;
|
|
43
|
+
accordState: Address;
|
|
44
|
+
}>;
|
|
45
|
+
pause(authority: Address, accordState: Address): Instruction;
|
|
46
|
+
proposeUnpause(authority: Address, accordState: Address): Instruction;
|
|
47
|
+
executeUnpause(caller: Address, accordState: Address): Instruction;
|
|
48
|
+
stake(accounts: StakingAccounts, amount: bigint, path: MSTNode[], attestation?: Address): Instruction;
|
|
49
|
+
requestWithdraw(accounts: StakingAccounts, amount: bigint, path: MSTNode[]): Instruction;
|
|
50
|
+
withdraw(accounts: StakingAccounts): Instruction;
|
|
51
|
+
reconcileStake(accounts: StakingAccounts, path: MSTNode[]): Instruction;
|
|
52
|
+
withdrawFees(accounts: WithdrawFeesAccounts): Instruction;
|
|
53
|
+
pruneJuror(accounts: PruneJurorAccounts, path: MSTNode[], attestation: Address): Instruction;
|
|
54
|
+
settleRound(accounts: SettleRoundAccounts, roundIdx: number, remainingAccounts: Address[]): Instruction;
|
|
55
|
+
cancelDispute(accounts: CancelDisputeAccounts, remainingAccounts: Address[]): Instruction;
|
|
56
|
+
requestVrf(accounts: VrfDrawAccounts, extras: RequestVrfExtras): Instruction;
|
|
57
|
+
awaitCommittedVrf(dispute: Address, opts?: {
|
|
58
|
+
pollIntervalMs?: number;
|
|
59
|
+
timeoutMs?: number;
|
|
60
|
+
}): Promise<Uint8Array>;
|
|
61
|
+
drawSeat(accounts: VrfDrawAccounts, roundPda: Address, seat: number, membership: SeatMembership): Instruction;
|
|
62
|
+
commit(accounts: VotingAccounts, args: VoteArgs): Promise<{
|
|
63
|
+
instruction: Instruction;
|
|
64
|
+
commitment: Uint8Array;
|
|
65
|
+
}>;
|
|
66
|
+
reveal(accounts: VotingAccounts, args: VoteArgs): Instruction;
|
|
67
|
+
finalizeRound(accounts: VotingAccounts, remainingAccounts?: Address[]): Instruction;
|
|
68
|
+
finalizeDispute(accounts: VotingAccounts, remainingAccounts: Address[]): Instruction;
|
|
69
|
+
redraw(accounts: RedrawAccounts, remainingAccounts?: Address[]): Instruction;
|
|
70
|
+
appeal(accounts: AppealAccounts, newEvidenceHash: Uint8Array): Instruction;
|
|
71
|
+
claimAppealRefund(accounts: ClaimRefundAccounts, roundIdx: number): Instruction;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Build the bound method namespace. `signer` is accepted so future per-call
|
|
75
|
+
* signer overrides can route through the facade; today the adapter uses the
|
|
76
|
+
* facade's wallet.
|
|
77
|
+
*/
|
|
78
|
+
export declare function createAccordMethods(adapter: AccordAdapter, programId?: Address, _signer?: TransactionSigner): AccordMethods;
|
|
79
|
+
//# sourceMappingURL=methods.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"methods.d.ts","sourceRoot":"","sources":["../src/methods.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE3E,OAAO,EAGL,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EASL,KAAK,mBAAmB,EACxB,KAAK,aAAa,EACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAOL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAGL,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAML,KAAK,cAAc,EACnB,KAAK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AAC,CAAC;IACvB,QAAQ,CACN,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,OAAO,EACjB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,cAAc,GACzB,WAAW,CAAC;IAGf,MAAM,CACJ,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC;QAAE,WAAW,EAAE,WAAW,CAAC;QAAC,UAAU,EAAE,UAAU,CAAA;KAAE,CAAC,CAAC;IACjE,MAAM,CAAC,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,QAAQ,GAAG,WAAW,CAAC;IAC9D,aAAa,CACX,QAAQ,EAAE,cAAc,EACxB,iBAAiB,CAAC,EAAE,OAAO,EAAE,GAC5B,WAAW,CAAC;IACf,eAAe,CACb,QAAQ,EAAE,cAAc,EACxB,iBAAiB,EAAE,OAAO,EAAE,GAC3B,WAAW,CAAC;IACf,MAAM,CACJ,QAAQ,EAAE,cAAc,EACxB,iBAAiB,CAAC,EAAE,OAAO,EAAE,GAC5B,WAAW,CAAC;IAGf,MAAM,CAAC,QAAQ,EAAE,cAAc,EAAE,eAAe,EAAE,UAAU,GAAG,WAAW,CAAC;IAC3E,iBAAiB,CACf,QAAQ,EAAE,mBAAmB,EAC7B,QAAQ,EAAE,MAAM,GACf,WAAW,CAAC;CAChB;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,aAAa,EACtB,SAAS,GAAE,OAA2B,EAGtC,OAAO,CAAC,EAAE,iBAAiB,GAC1B,aAAa,CAsFf"}
|
package/dist/pda.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical PDA derivations for every Accord account.
|
|
3
|
+
*
|
|
4
|
+
* Seeds sourced from `programs/accord/src/state.rs` + `constants.rs`:
|
|
5
|
+
* SEED_SUBACCORD = "subaccord" SEED_DISPUTE = "dispute"
|
|
6
|
+
* SEED_JUROR_STAKE = "stake" SEED_ROUND = "round"
|
|
7
|
+
* SEED_PENDING_UPDATE = "update" SEED_APPEAL_BOND = "bond"
|
|
8
|
+
* SEED_ACCORD_STATE = "state"
|
|
9
|
+
*
|
|
10
|
+
* Five of seven PDAs are emitted by Codama into `./generated/pdas/` and
|
|
11
|
+
* re-exported here unchanged. `Round` is hand-written because its on-chain seeds
|
|
12
|
+
* reference `dispute.key()` (a runtime address, not a static field) — Codama
|
|
13
|
+
* cannot encode that statically, so it omits it.
|
|
14
|
+
*
|
|
15
|
+
* ADR-0012: the `Snapshot` PDA is gone (snapshot layer deleted).
|
|
16
|
+
*
|
|
17
|
+
* Every function returns `ProgramDerivedAddress` = `{ address: Address; bump: number }`.
|
|
18
|
+
*
|
|
19
|
+
* @see ADR-0010
|
|
20
|
+
*/
|
|
21
|
+
import { type Address, type ProgramDerivedAddress } from "@solana/kit";
|
|
22
|
+
export declare const ACCORD_PROGRAM_ID: Address<"cordhVoshqRV6kzGBmM89A66wuusJGsDCvLMHPLyKed">;
|
|
23
|
+
export { findAppealBondPda, type AppealBondSeeds, } from "./generated/pdas/appealBond";
|
|
24
|
+
export { findDisputePda, type DisputeSeeds } from "./generated/pdas/dispute";
|
|
25
|
+
export { findJurorStakePda, type JurorStakeSeeds, } from "./generated/pdas/jurorStake";
|
|
26
|
+
export { findAccordStatePda } from "./generated/pdas/accordState";
|
|
27
|
+
export { findPendingUpdatePda, type PendingUpdateSeeds, } from "./generated/pdas/pendingUpdate";
|
|
28
|
+
export { findSubaccordPda, type SubaccordSeeds, } from "./generated/pdas/subaccord";
|
|
29
|
+
export { findProgramIdentityPda, } from "./generated/pdas/programIdentity";
|
|
30
|
+
export type RoundSeeds = {
|
|
31
|
+
dispute: Address;
|
|
32
|
+
roundIdx: number;
|
|
33
|
+
};
|
|
34
|
+
export declare function findRoundPda(seeds: RoundSeeds, config?: {
|
|
35
|
+
programAddress?: Address;
|
|
36
|
+
}): Promise<ProgramDerivedAddress>;
|
|
37
|
+
//# sourceMappingURL=pda.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pda.d.ts","sourceRoot":"","sources":["../src/pda.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAKL,KAAK,OAAO,EACZ,KAAK,qBAAqB,EAC3B,MAAM,aAAa,CAAC;AAIrB,eAAO,MAAM,iBAAiB,EACqB,OAAO,CAAC,6CAA6C,CAAC,CAAC;AAI1G,OAAO,EACL,iBAAiB,EACjB,KAAK,eAAe,GACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EACL,iBAAiB,EACjB,KAAK,eAAe,GACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EACL,oBAAoB,EACpB,KAAK,kBAAkB,GACxB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,gBAAgB,EAChB,KAAK,cAAc,GACpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,sBAAsB,GACvB,MAAM,kCAAkC,CAAC;AAS1C,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,wBAAsB,YAAY,CAChC,KAAK,EAAE,UAAU,EACjB,MAAM,GAAE;IAAE,cAAc,CAAC,EAAE,OAAO,CAAA;CAAO,GACxC,OAAO,CAAC,qBAAqB,CAAC,CAUhC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed `getProgramAccounts` query wrappers.
|
|
3
|
+
*
|
|
4
|
+
* Each function encapsulates the discriminator + memcmp construction so the
|
|
5
|
+
* caller never touches raw bytes. Returns typed `Account<T>[]` with the
|
|
6
|
+
* account address preserved (needed for deep links, PDA navigation, etc.).
|
|
7
|
+
*
|
|
8
|
+
* @see ADR-0010
|
|
9
|
+
*/
|
|
10
|
+
import { type Account, type Commitment, type GetProgramAccountsApi, type Rpc } from "@solana/kit";
|
|
11
|
+
import { type Dispute } from "./generated/accounts/dispute.js";
|
|
12
|
+
import { type PendingUpdate } from "./generated/accounts/pendingUpdate.js";
|
|
13
|
+
export type QueryConfig = {
|
|
14
|
+
commitment?: Commitment;
|
|
15
|
+
abortSignal?: AbortSignal;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Fetch every Dispute account on-chain, decoded and typed.
|
|
19
|
+
* Filters by the 8-byte account discriminator at offset 0.
|
|
20
|
+
*/
|
|
21
|
+
export declare function findAllDisputes(rpc: Rpc<GetProgramAccountsApi>, config?: QueryConfig): Promise<Account<Dispute>[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Fetch every PendingUpdate account on-chain, decoded and typed.
|
|
24
|
+
* Filters by the 8-byte account discriminator at offset 0.
|
|
25
|
+
*/
|
|
26
|
+
export declare function findAllPendingUpdates(rpc: Rpc<GetProgramAccountsApi>, config?: QueryConfig): Promise<Account<PendingUpdate>[]>;
|
|
27
|
+
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,KAAK,OAAO,EAGZ,KAAK,UAAU,EACf,KAAK,qBAAqB,EAG1B,KAAK,GAAG,EACT,MAAM,aAAa,CAAC;AAErB,OAAO,EAGL,KAAK,OAAO,EACb,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,uCAAuC,CAAC;AAG/C,MAAM,MAAM,WAAW,GAAG;IACxB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B,CAAC;AAOF;;;GAGG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,GAAG,CAAC,qBAAqB,CAAC,EAC/B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAoB7B;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,GAAG,CAAC,qBAAqB,CAAC,EAC/B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,CAoBnC"}
|
package/dist/query.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed `getProgramAccounts` wrappers — bulk reads that hide discriminator +
|
|
3
|
+
* memcmp-offset construction from the caller. Each function returns fully
|
|
4
|
+
* decoded `Account<T>[]`; no raw bytes, no memcmp offsets, no decoders leak.
|
|
5
|
+
*
|
|
6
|
+
* Filters match the 8-byte Anchor discriminator at offset 0 plus an optional
|
|
7
|
+
* 32-byte `Address` field. Offsets below are fixed by the generated struct
|
|
8
|
+
* layouts (see `./generated/accounts/*.ts`); the round-trip in `query.test.ts`
|
|
9
|
+
* fails if they ever drift.
|
|
10
|
+
*
|
|
11
|
+
* Accepts a raw Kit `Rpc<GetProgramAccountsApi>` — the same `rpc` the facade
|
|
12
|
+
* (`Accord.rpc`) or a bare `createSolanaRpc(...)` exposes.
|
|
13
|
+
*
|
|
14
|
+
* @see ADR-0010
|
|
15
|
+
*/
|
|
16
|
+
import { type Account, type Address, type GetProgramAccountsApi, type Rpc } from "@solana/kit";
|
|
17
|
+
import { type Dispute, type JurorStake, type Subaccord } from "./generated/accounts/index.js";
|
|
18
|
+
/** All Subaccords on the Accord program (discriminator-only filter). */
|
|
19
|
+
export declare function findAllSubaccords(rpc: Rpc<GetProgramAccountsApi>): Promise<Account<Subaccord>[]>;
|
|
20
|
+
/** Every JurorStake on the Accord program (global browse / aggregation). */
|
|
21
|
+
export declare function findAllJurorStakes(rpc: Rpc<GetProgramAccountsApi>): Promise<Account<JurorStake>[]>;
|
|
22
|
+
/** Every JurorStake for a Subaccord (draw pool / accumulator rebuild). */
|
|
23
|
+
export declare function findJurorStakesBySubaccord(rpc: Rpc<GetProgramAccountsApi>, subaccord: Address): Promise<Account<JurorStake>[]>;
|
|
24
|
+
/** Every JurorStake owned by a juror across all Subaccords. */
|
|
25
|
+
export declare function findJurorStakesByJuror(rpc: Rpc<GetProgramAccountsApi>, juror: Address): Promise<Account<JurorStake>[]>;
|
|
26
|
+
/** Every Dispute filed under a Subaccord. */
|
|
27
|
+
export declare function findDisputesBySubaccord(rpc: Rpc<GetProgramAccountsApi>, subaccord: Address): Promise<Account<Dispute>[]>;
|
|
28
|
+
/** Every Dispute filed by a given filer. */
|
|
29
|
+
export declare function findDisputesByFiler(rpc: Rpc<GetProgramAccountsApi>, filer: Address): Promise<Account<Dispute>[]>;
|
|
30
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAIL,KAAK,OAAO,EACZ,KAAK,OAAO,EAEZ,KAAK,qBAAqB,EAG1B,KAAK,GAAG,EACT,MAAM,aAAa,CAAC;AAGrB,OAAO,EAOL,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,KAAK,SAAS,EACf,MAAM,+BAA+B,CAAC;AAsEvC,wEAAwE;AACxE,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,GAAG,CAAC,qBAAqB,CAAC,GAC9B,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAM/B;AAED,4EAA4E;AAC5E,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,GAAG,CAAC,qBAAqB,CAAC,GAC9B,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAMhC;AAED,0EAA0E;AAC1E,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,GAAG,CAAC,qBAAqB,CAAC,EAC/B,SAAS,EAAE,OAAO,GACjB,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAShC;AAED,+DAA+D;AAC/D,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,GAAG,CAAC,qBAAqB,CAAC,EAC/B,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAShC;AAED,6CAA6C;AAC7C,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,GAAG,CAAC,qBAAqB,CAAC,EAC/B,SAAS,EAAE,OAAO,GACjB,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAS7B;AAED,4CAA4C;AAC5C,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,GAAG,CAAC,qBAAqB,CAAC,EAC/B,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAS7B"}
|
package/dist/token.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SPL Token + Associated Token Account (ATA) derivation.
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth for the canonical ATA address used across fee and
|
|
5
|
+
* collateral flows (ADR-0020). `@solana/kit` v7 does not export the SPL
|
|
6
|
+
* program ids, so they live here. Hand-rolled (no `@solana/spl-token`
|
|
7
|
+
* dependency) to keep the jest e2e suite free of the web3.js v1 `uuid` break —
|
|
8
|
+
* matches the on-chain `create_associated_token_account` layout:
|
|
9
|
+
* `ATA_PROGRAM ‖ [owner, TOKEN_PROGRAM, mint]`.
|
|
10
|
+
*
|
|
11
|
+
* @see ADR-0020
|
|
12
|
+
*/
|
|
13
|
+
import { type Address } from "@solana/kit";
|
|
14
|
+
/** SPL Token program id (not exported by @solana/kit v7). */
|
|
15
|
+
export declare const TOKEN_PROGRAM_ADDRESS: Address;
|
|
16
|
+
/** SPL Associated Token Account program id (not exported by @solana/kit v7). */
|
|
17
|
+
export declare const ASSOCIATED_TOKEN_PROGRAM_ADDRESS: Address;
|
|
18
|
+
/**
|
|
19
|
+
* Derive the canonical Associated Token Account (ATA) address for `mint`
|
|
20
|
+
* owned by `owner`. Argument order follows `@solana/spl-token`'s
|
|
21
|
+
* `getAssociatedTokenAddress(mint, owner, …)`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function findAssociatedTokenAddress(mint: Address, owner: Address): Promise<Address>;
|
|
24
|
+
//# sourceMappingURL=token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../src/token.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAGL,KAAK,OAAO,EACb,MAAM,aAAa,CAAC;AAErB,6DAA6D;AAC7D,eAAO,MAAM,qBAAqB,EACiB,OAAO,CAAC;AAE3D,gFAAgF;AAChF,eAAO,MAAM,gCAAgC,EACO,OAAO,CAAC;AAE5D;;;;GAIG;AACH,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,OAAO,CAAC,CAOlB"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain types for the Accord.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the Codama-generated type modules (DisputeState, UpdatePayload,
|
|
5
|
+
* LeafClaim, MSTNode) which are sourced directly from
|
|
6
|
+
* `programs/accord/src/state.rs`. No hand-written duplicates — the generated
|
|
7
|
+
* tree is the single source of truth for on-chain shapes.
|
|
8
|
+
*
|
|
9
|
+
* ADR-0012: `SnapshotStatus` / `FraudProof` are gone (snapshot layer deleted);
|
|
10
|
+
* `LeafClaim` carries only `(juror, stake)` — the cumulative-from-left prefix
|
|
11
|
+
* used for sortition is reconstructed from the authenticated sibling sums.
|
|
12
|
+
*/
|
|
13
|
+
export { DisputeState, getDisputeStateDecoder, getDisputeStateEncoder, } from "./generated/types/disputeState.js";
|
|
14
|
+
export { Aggregation, type AggregationArgs, getAggregationCodec, } from "./generated/types/aggregation.js";
|
|
15
|
+
export { ShortfallPolicy, type ShortfallPolicyArgs, getShortfallPolicyCodec, } from "./generated/types/shortfallPolicy.js";
|
|
16
|
+
export { type UpdatePayload, getUpdatePayloadCodec, } from "./generated/types/updatePayload.js";
|
|
17
|
+
export { type LeafClaim as LeafClaimIdl, getLeafClaimCodec, } from "./generated/types/leafClaim.js";
|
|
18
|
+
export { type MSTNode as MSTNodeIdl, getMSTNodeCodec, } from "./generated/types/mSTNode.js";
|
|
19
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACL,WAAW,EACX,KAAK,eAAe,EACpB,mBAAmB,GACpB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACL,eAAe,EACf,KAAK,mBAAmB,EACxB,uBAAuB,GACxB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACL,KAAK,aAAa,EAClB,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACL,KAAK,SAAS,IAAI,YAAY,EAC9B,iBAAiB,GAClB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,KAAK,OAAO,IAAI,UAAU,EAC1B,eAAe,GAChB,MAAM,8BAA8B,CAAC"}
|