@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,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mst.ts — subtree-sum stake accumulator builder (ADR-0012).
|
|
3
|
+
*
|
|
4
|
+
* Replaces the ADR-0009 cumulative-from-left snapshot MST. The on-chain
|
|
5
|
+
* program maintains only the root (`Subaccord.root_hash` + `total_stake`);
|
|
6
|
+
* the full tree lives off-chain (indexers). This module is the byte-exact
|
|
7
|
+
* reference the chain verifies against:
|
|
8
|
+
*
|
|
9
|
+
* leaf = H(juror[32] ‖ stake_le[8])
|
|
10
|
+
* node = H(left_hash[32] ‖ left_sum_le[8] ‖ right_hash[32] ‖ right_sum_le[8])
|
|
11
|
+
* node.sum = left_sum + right_sum
|
|
12
|
+
*
|
|
13
|
+
* Sums are bound into node hashes, so stake-weighted ranges are
|
|
14
|
+
* cryptographically authenticated (CONCEPT-REVIEW Bad 5, fixed by
|
|
15
|
+
* construction). A one-leaf change touches only that leaf's ancestors →
|
|
16
|
+
* O(log N) updates via {@link proofFor}.
|
|
17
|
+
*
|
|
18
|
+
* Sortition uses the cumulative-from-left prefix (sum of left-sibling subtree
|
|
19
|
+
* sums on right-branch levels), reconstructed from the authenticated path:
|
|
20
|
+
* the selected leaf's range is `[prefix, prefix + stake)`.
|
|
21
|
+
*
|
|
22
|
+
* Sources of truth:
|
|
23
|
+
* - on-chain helpers: programs/accord/src/lib.rs (mst_leaf_hash, mst_node_hash,
|
|
24
|
+
* empty_tree_root, verify_and_recompute, verify_membership_and_prefix)
|
|
25
|
+
* - state: LeafClaim / MSTNode in programs/accord/src/state.rs
|
|
26
|
+
*
|
|
27
|
+
* @see ADR-0012
|
|
28
|
+
*/
|
|
29
|
+
/** A subtree-sum proof element: the sibling subtree's hash + total stake. */
|
|
30
|
+
export interface MSTNode {
|
|
31
|
+
siblingHash: Uint8Array;
|
|
32
|
+
siblingSum: bigint;
|
|
33
|
+
}
|
|
34
|
+
/** A leaf of the accumulator: `(juror, stake)`. */
|
|
35
|
+
export interface LeafClaim {
|
|
36
|
+
juror: Uint8Array;
|
|
37
|
+
stake: bigint;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Internal cache of all hash/sum levels. `levels[0]` = leaf hashes,
|
|
41
|
+
* `levels[d]` = root. Stored so `proofFor` is O(log N) instead of O(N).
|
|
42
|
+
*/
|
|
43
|
+
interface LevelCache {
|
|
44
|
+
hashes: Uint8Array[][];
|
|
45
|
+
sums: bigint[][];
|
|
46
|
+
}
|
|
47
|
+
/** A built accumulator: leaves + the canonical root. */
|
|
48
|
+
export interface MerkleAccumulator {
|
|
49
|
+
/** Fixed tree depth (bounds the pool at 2^depth). */
|
|
50
|
+
depth: number;
|
|
51
|
+
/** Index → leaf. Empty slots hold the all-zero leaf `(default, 0)`. */
|
|
52
|
+
leaves: LeafClaim[];
|
|
53
|
+
rootHash: Uint8Array;
|
|
54
|
+
rootSum: bigint;
|
|
55
|
+
/** Opaque cache — don't inspect; use {@link proofFor}. */
|
|
56
|
+
_levels?: LevelCache;
|
|
57
|
+
}
|
|
58
|
+
/** Maximum depth the SDK accepts. The on-chain program allows up to 31, but
|
|
59
|
+
* `buildAccumulator` hashes `2^depth` leaves — impractical beyond 20 in a
|
|
60
|
+
* browser. Deeper pools should use a dedicated indexer for proofs. */
|
|
61
|
+
export declare const MAX_SDK_DEPTH = 20;
|
|
62
|
+
/** Leaf hash `H(juror ‖ stake_le)` (lib.rs mst_leaf_hash). */
|
|
63
|
+
export declare function leafHash(juror: Uint8Array, stake: bigint): Promise<Uint8Array>;
|
|
64
|
+
/** Root hash of an all-zero tree at `depth` (lib.rs empty_tree_root). */
|
|
65
|
+
export declare function emptyRoot(depth: number): Promise<Uint8Array>;
|
|
66
|
+
/**
|
|
67
|
+
* Build a depth-`depth` accumulator from `leaves` (index = position), padding
|
|
68
|
+
* the remaining `2^depth` slots with zero leaves. Returns the canonical root
|
|
69
|
+
* the on-chain program would hold after these stakes (the audit property: an
|
|
70
|
+
* off-chain rebuild from `JurorStake` via `getProgramAccounts` reproduces it).
|
|
71
|
+
*
|
|
72
|
+
* Caches all intermediate hash levels so {@link proofFor} is O(log N).
|
|
73
|
+
*/
|
|
74
|
+
export declare function buildAccumulator(leaves: LeafClaim[], depth: number): Promise<MerkleAccumulator>;
|
|
75
|
+
/**
|
|
76
|
+
* The client-supplied Merkle path for `index` (sibling hash + sum per level,
|
|
77
|
+
* leaf → root). Used by `stake`/`requestWithdraw`/`reconcileStake`
|
|
78
|
+
* (verify-and-recompute) and by `draw_seat` (membership + sortition prefix).
|
|
79
|
+
*
|
|
80
|
+
* O(log N) — reads siblings from the cached levels built by
|
|
81
|
+
* {@link buildAccumulator}. Falls back to O(N) rehash if the cache is absent
|
|
82
|
+
* (e.g. the accumulator was constructed by hand without `_levels`).
|
|
83
|
+
*/
|
|
84
|
+
export declare function proofFor(tree: MerkleAccumulator, index: number): Promise<MSTNode[]>;
|
|
85
|
+
/** Reconstruct the path root from a leaf (for off-chain audit / debugging). */
|
|
86
|
+
export declare function recomputeRoot(leaf: LeafClaim, index: number, path: MSTNode[]): Promise<{
|
|
87
|
+
hash: Uint8Array;
|
|
88
|
+
sum: bigint;
|
|
89
|
+
}>;
|
|
90
|
+
/**
|
|
91
|
+
* Verify `leaf` at `index` authenticates against `(rootHash, rootSum)` and
|
|
92
|
+
* return the cumulative-from-left prefix (lib.rs verify_membership_and_prefix).
|
|
93
|
+
* The leaf's sortition range is `[prefix, prefix + stake)`.
|
|
94
|
+
*/
|
|
95
|
+
export declare function verifyMembership(leaf: LeafClaim, index: number, path: MSTNode[], rootHash: Uint8Array, rootSum: bigint): Promise<{
|
|
96
|
+
ok: boolean;
|
|
97
|
+
prefix: bigint;
|
|
98
|
+
}>;
|
|
99
|
+
export {};
|
|
100
|
+
//# sourceMappingURL=mst.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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ED,+EAA+E;AAC/E,wBAAsB,aAAa,CACjC,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,OAAO,EAAE,GACd,OAAO,CAAC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAe5C;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,OAAO,EAAE,EACf,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAY1C"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* settlement.ts — per-round settlement crank + dispute cancellation.
|
|
3
|
+
*
|
|
4
|
+
* `settle_round` is the permissionless per-round crank that settles a single
|
|
5
|
+
* round's economics (slashing incoherent jurors + redistributing the pool) once
|
|
6
|
+
* revealed. `cancel_dispute` refunds the filer's fee when a round fails to
|
|
7
|
+
* reach a ruling within its timeout window — a permissionless timeout exit.
|
|
8
|
+
*
|
|
9
|
+
* Same ADR-0010 facade pattern: pure orchestration over a typed
|
|
10
|
+
* {@link AccordSettlementClient} seam; Kit type-only; `remainingAccounts`
|
|
11
|
+
* carry the JurorStake / Round / AppealBond PDAs the handlers mutate.
|
|
12
|
+
*
|
|
13
|
+
* Sources of truth:
|
|
14
|
+
* - settle_round: programs/accord/src/lib.rs (1291)
|
|
15
|
+
* - cancel_dispute: programs/accord/src/lib.rs (1539)
|
|
16
|
+
*/
|
|
17
|
+
import type { Address, Instruction } from "@solana/kit";
|
|
18
|
+
/** Accounts for `settle_round`. */
|
|
19
|
+
export interface SettleRoundAccounts {
|
|
20
|
+
/** Any caller (permissionless crank). Signer. */
|
|
21
|
+
caller: Address;
|
|
22
|
+
subaccord: Address;
|
|
23
|
+
dispute: Address;
|
|
24
|
+
round: Address;
|
|
25
|
+
}
|
|
26
|
+
/** Accounts for `cancel_dispute`. */
|
|
27
|
+
export interface CancelDisputeAccounts {
|
|
28
|
+
/** Any caller (permissionless crank). Signer. */
|
|
29
|
+
caller: Address;
|
|
30
|
+
subaccord: Address;
|
|
31
|
+
dispute: Address;
|
|
32
|
+
feeToken: Address;
|
|
33
|
+
/** Filer's ATA — refund destination (owner checked on-chain). */
|
|
34
|
+
filerTokenAccount: Address;
|
|
35
|
+
feeVault: Address;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Seam to the Codama-generated Kit client (ADR-0010). Foundation wires the
|
|
39
|
+
* concrete adapter; settlement.ts stays orchestration-only.
|
|
40
|
+
*/
|
|
41
|
+
export interface AccordSettlementClient {
|
|
42
|
+
buildSettleRound(input: {
|
|
43
|
+
programId: Address;
|
|
44
|
+
accounts: SettleRoundAccounts;
|
|
45
|
+
roundIdx: number;
|
|
46
|
+
/** remaining_accounts: drawn JurorStake PDAs the crank mutates. */
|
|
47
|
+
remainingAccounts: Address[];
|
|
48
|
+
}): Instruction;
|
|
49
|
+
buildCancelDispute(input: {
|
|
50
|
+
programId: Address;
|
|
51
|
+
accounts: CancelDisputeAccounts;
|
|
52
|
+
/** remaining_accounts: Round + JurorStake + AppealBond PDAs. */
|
|
53
|
+
remainingAccounts: Address[];
|
|
54
|
+
}): Instruction;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Build the permissionless `settle_round` crank (lib.rs:1291). Settles one
|
|
58
|
+
* round's economics after reveal — slashing incoherent jurors, redistributing
|
|
59
|
+
* the pool. `roundIdx` selects the round; `remainingAccounts` are the drawn
|
|
60
|
+
* JurorStake PDAs for that round (writable, mutated for slashes/rewards).
|
|
61
|
+
*/
|
|
62
|
+
export declare function settleRound(client: AccordSettlementClient, programId: Address, accounts: SettleRoundAccounts, roundIdx: number, remainingAccounts: Address[]): Instruction;
|
|
63
|
+
/**
|
|
64
|
+
* Build the permissionless `cancel_dispute` crank (lib.rs:1539). Refunds the
|
|
65
|
+
* filer's fee when a round times out without a ruling. `remainingAccounts`
|
|
66
|
+
* carries the Round + JurorStake + AppealBond PDAs the handler closes/refunds.
|
|
67
|
+
*/
|
|
68
|
+
export declare function cancelDispute(client: AccordSettlementClient, programId: Address, accounts: CancelDisputeAccounts, remainingAccounts: Address[]): Instruction;
|
|
69
|
+
//# sourceMappingURL=settlement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settlement.d.ts","sourceRoot":"","sources":["../../src/methods/settlement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAExD,mCAAmC;AACnC,MAAM,WAAW,mBAAmB;IAClC,iDAAiD;IACjD,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,qCAAqC;AACrC,MAAM,WAAW,qBAAqB;IACpC,iDAAiD;IACjD,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,iEAAiE;IACjE,iBAAiB,EAAE,OAAO,CAAC;IAC3B,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,gBAAgB,CAAC,KAAK,EAAE;QACtB,SAAS,EAAE,OAAO,CAAC;QACnB,QAAQ,EAAE,mBAAmB,CAAC;QAC9B,QAAQ,EAAE,MAAM,CAAC;QACjB,mEAAmE;QACnE,iBAAiB,EAAE,OAAO,EAAE,CAAC;KAC9B,GAAG,WAAW,CAAC;IAChB,kBAAkB,CAAC,KAAK,EAAE;QACxB,SAAS,EAAE,OAAO,CAAC;QACnB,QAAQ,EAAE,qBAAqB,CAAC;QAChC,gEAAgE;QAChE,iBAAiB,EAAE,OAAO,EAAE,CAAC;KAC9B,GAAG,WAAW,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,sBAAsB,EAC9B,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,mBAAmB,EAC7B,QAAQ,EAAE,MAAM,EAChB,iBAAiB,EAAE,OAAO,EAAE,GAC3B,WAAW,CAUb;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,sBAAsB,EAC9B,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,qBAAqB,EAC/B,iBAAiB,EAAE,OAAO,EAAE,GAC3B,WAAW,CAMb"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* stakeFlow.ts — MST accumulator proof orchestration for stake / unstake.
|
|
3
|
+
*
|
|
4
|
+
* This is the domain logic the `/juror/stake` route executes after fetching
|
|
5
|
+
* a Subaccord + all its JurorStake accounts:
|
|
6
|
+
*
|
|
7
|
+
* 1. Sort JurorStake leaves by `treeIndex` (canonical append-only order).
|
|
8
|
+
* 2. Build `LeafClaim[]` at each juror's canonical position.
|
|
9
|
+
* 3. `buildAccumulator(leafClaims, depth)` — rebuild the canonical tree.
|
|
10
|
+
* 4. Verify `accumulator.rootHash === subaccord.rootHash` — a mismatch
|
|
11
|
+
* means the local data is stale (race with a concurrent stake/unstake).
|
|
12
|
+
* 5. Determine the juror's leaf index:
|
|
13
|
+
* - Existing staker → their assigned `treeIndex`.
|
|
14
|
+
* - New staker → `subaccord.nextIndex` (the next free leaf).
|
|
15
|
+
* 6. `proofFor(accumulator, index)` — the Merkle path passed to `stake` /
|
|
16
|
+
* `requestWithdraw` / `reconcileStake`.
|
|
17
|
+
*
|
|
18
|
+
* Pure — no chain access. Takes already-fetched typed data so it's testable
|
|
19
|
+
* without a validator.
|
|
20
|
+
*
|
|
21
|
+
* Sources of truth:
|
|
22
|
+
* - on-chain stake/requestWithdraw: programs/accord/src/lib.rs
|
|
23
|
+
* - accumulator builder: ./mst.ts (ADR-0012)
|
|
24
|
+
* - e2e flow reference: tests/src/staking.spec.ts (TreeTracker)
|
|
25
|
+
*/
|
|
26
|
+
import { type Address } from "@solana/kit";
|
|
27
|
+
import { type MerkleAccumulator, type MSTNode } from "./mst.js";
|
|
28
|
+
/** The Subaccord fields the proof builder needs. */
|
|
29
|
+
export interface SubaccordAccumulatorView {
|
|
30
|
+
/** On-chain accumulator root (state.rs `root_hash`). */
|
|
31
|
+
rootHash: Uint8Array;
|
|
32
|
+
/** Next free leaf index (state.rs `next_index`). */
|
|
33
|
+
nextIndex: number;
|
|
34
|
+
/** Fixed tree depth (state.rs `depth`). */
|
|
35
|
+
depth: number;
|
|
36
|
+
}
|
|
37
|
+
/** A JurorStake leaf needed for the accumulator. */
|
|
38
|
+
export interface JurorStakeLeaf {
|
|
39
|
+
juror: Address;
|
|
40
|
+
/** Canonical collateral (`staked`, not `staked + stakeDelta`). */
|
|
41
|
+
staked: bigint;
|
|
42
|
+
/** Leaf position assigned at first stake (state.rs `tree_index`). */
|
|
43
|
+
treeIndex: number;
|
|
44
|
+
}
|
|
45
|
+
/** Result of proof computation for stake / unstake. */
|
|
46
|
+
export interface StakeProofResult {
|
|
47
|
+
/** The Merkle path to pass to `stake` / `requestWithdraw` / `reconcileStake`. */
|
|
48
|
+
path: MSTNode[];
|
|
49
|
+
/** The leaf index the proof authenticates. */
|
|
50
|
+
index: number;
|
|
51
|
+
/** The root-verified accumulator (for audit / sortition prefix). */
|
|
52
|
+
accumulator: MerkleAccumulator;
|
|
53
|
+
/** `true` if this juror has never staked (proof for `nextIndex`). */
|
|
54
|
+
isNewStaker: boolean;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Build the MST accumulator proof for a stake or unstake operation.
|
|
58
|
+
*
|
|
59
|
+
* @param subaccord The on-chain accumulator state (rootHash, nextIndex, depth).
|
|
60
|
+
* @param jurorStakes All JurorStake accounts for this Subaccord (any order).
|
|
61
|
+
* @param juror The staking juror's address.
|
|
62
|
+
* @throws if the rebuilt root does not match the on-chain root (stale data).
|
|
63
|
+
*/
|
|
64
|
+
export declare function prepareStakeProof(subaccord: SubaccordAccumulatorView, jurorStakes: readonly JurorStakeLeaf[], juror: Address): Promise<StakeProofResult>;
|
|
65
|
+
//# sourceMappingURL=stakeFlow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stakeFlow.d.ts","sourceRoot":"","sources":["../../src/methods/stakeFlow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAqB,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACb,MAAM,UAAU,CAAC;AAElB,oDAAoD;AACpD,MAAM,WAAW,wBAAwB;IACvC,wDAAwD;IACxD,QAAQ,EAAE,UAAU,CAAC;IACrB,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;CACf;AAED,oDAAoD;AACpD,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,OAAO,CAAC;IACf,kEAAkE;IAClE,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,uDAAuD;AACvD,MAAM,WAAW,gBAAgB;IAC/B,iFAAiF;IACjF,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,WAAW,EAAE,iBAAiB,CAAC;IAC/B,qEAAqE;IACrE,WAAW,EAAE,OAAO,CAAC;CACtB;AAOD;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,wBAAwB,EACnC,WAAW,EAAE,SAAS,cAAc,EAAE,EACtC,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,gBAAgB,CAAC,CA+C3B"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* staking.ts — Juror capital stake / unstake + the `active_draws` guard.
|
|
3
|
+
*
|
|
4
|
+
* `unstake` is blocked on-chain while a juror is drawn into any open dispute
|
|
5
|
+
* (`JurorStake.active_draws > 0` → `StakeLocked`, lib.rs:272) — stake is frozen
|
|
6
|
+
* until every drawn dispute settles (ADR-0003). The facade surfaces this as a
|
|
7
|
+
* typed pre-check ({@link canUnstake} / {@link assertCanUnstake}) so a client
|
|
8
|
+
* rejects the unstake BEFORE building or sending the transaction (matches the
|
|
9
|
+
* on-chain error; test-matrix row 4).
|
|
10
|
+
*
|
|
11
|
+
* `stake` SPL-transfers `amount` of the Subaccord's staking token from the
|
|
12
|
+
* juror's ATA into the Subaccord PDA's vault ATA (lazily created on first
|
|
13
|
+
* stake). Reverts while the circuit breaker is paused (ADR-0007).
|
|
14
|
+
*
|
|
15
|
+
* Same ADR-0010 facade pattern: pure orchestration over a typed
|
|
16
|
+
* {@link AccordStakingClient} seam; Kit type-only; PDA lazy.
|
|
17
|
+
*
|
|
18
|
+
* Sources of truth:
|
|
19
|
+
* - stake / unstake handlers: programs/accord/src/lib.rs (206-324)
|
|
20
|
+
* - Stake / Unstake accounts: programs/accord/src/lib.rs (1716-1798)
|
|
21
|
+
* - JurorStake struct + seeds: programs/accord/src/state.rs (60-70)
|
|
22
|
+
*/
|
|
23
|
+
import { type Address, type Instruction } from "@solana/kit";
|
|
24
|
+
import type { MSTNode } from "./mst.js";
|
|
25
|
+
/** The decoded JurorStake fields the guard + caller need. */
|
|
26
|
+
export interface JurorStakeView {
|
|
27
|
+
juror: Address;
|
|
28
|
+
/** Collateral (stake_token, ADR-0020). */
|
|
29
|
+
staked: bigint;
|
|
30
|
+
/** Aggregate earned fees (fee_token, ADR-0020). Withdrawable via `withdrawFees`. */
|
|
31
|
+
feesEarned: bigint;
|
|
32
|
+
/** Disputes this juror is currently drawn into; >0 blocks unstake. */
|
|
33
|
+
activeDraws: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Typed unstake guard result. `ok === false` ⇒ do not build the tx; the
|
|
37
|
+
* `reason` matches the on-chain error class (StakeLocked / InvalidAmount /
|
|
38
|
+
* InsufficientBalance).
|
|
39
|
+
*/
|
|
40
|
+
export interface UnstakeGuard {
|
|
41
|
+
ok: boolean;
|
|
42
|
+
reason?: "StakeLocked" | "InvalidAmount" | "InsufficientBalance";
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Pre-flight the `unstake` against the juror's live stake. Mirrors the three
|
|
46
|
+
* on-chain requires (lib.rs:270-277): `amount > 0`, `active_draws == 0`,
|
|
47
|
+
* `amount ≤ staked`. Pure — no chain access.
|
|
48
|
+
*/
|
|
49
|
+
export declare function canUnstake(stake: JurorStakeView, amount: bigint): UnstakeGuard;
|
|
50
|
+
/** Throw a typed `Error` if the unstake would revert on-chain. */
|
|
51
|
+
export declare function assertCanUnstake(stake: JurorStakeView, amount: bigint): void;
|
|
52
|
+
/** Validate a stake/unstake `amount` is a positive u64 (lib.rs:208 / 270). */
|
|
53
|
+
export declare function assertValidAmount(amount: bigint): void;
|
|
54
|
+
/** JurorStake PDA seeds (state.rs:1732): `["stake", subaccord, juror]`. */
|
|
55
|
+
export declare function jurorStakeSeeds(subaccordBytes: Uint8Array, jurorBytes: Uint8Array): Uint8Array[];
|
|
56
|
+
/** Derive the canonical JurorStake PDA. */
|
|
57
|
+
export declare function findJurorStakePda(programAddress: Address, subaccord: Address, juror: Address): Promise<{
|
|
58
|
+
address: Address;
|
|
59
|
+
bump: number;
|
|
60
|
+
}>;
|
|
61
|
+
/** Accounts shared by `stake` / `unstake` (the juror signs). */
|
|
62
|
+
export interface StakingAccounts {
|
|
63
|
+
juror: Address;
|
|
64
|
+
subaccord: Address;
|
|
65
|
+
/** `stake` only — the ADR-0007 circuit breaker (unstake is never halted). */
|
|
66
|
+
accordState?: Address;
|
|
67
|
+
jurorStake: Address;
|
|
68
|
+
stakingToken: Address;
|
|
69
|
+
/** Juror's ATA of the staking token (source on stake, dest on unstake). */
|
|
70
|
+
jurorTokenAccount: Address;
|
|
71
|
+
/** Subaccord PDA's stake_vault ATA (dest on stake, source on unstake). */
|
|
72
|
+
stakeVault: Address;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Seam to the Codama-generated Kit client + JurorStake fetcher. Foundation
|
|
76
|
+
* wires the concrete adapter; staking.ts stays orchestration-only.
|
|
77
|
+
*
|
|
78
|
+
* ADR-0012: `stake`/`unstake` take a client-supplied accumulator `path`
|
|
79
|
+
* (sibling hash + sum per level). The chain verifies it against the stored
|
|
80
|
+
* root and recomputes a new canonical root — O(log N). A wrong path reverts;
|
|
81
|
+
* build it via `proofFor(tree, jurorIndex)` from `./mst.js`.
|
|
82
|
+
*/
|
|
83
|
+
export interface AccordStakingClient {
|
|
84
|
+
buildStake(input: {
|
|
85
|
+
programId: Address;
|
|
86
|
+
accounts: StakingAccounts;
|
|
87
|
+
amount: bigint;
|
|
88
|
+
path: MSTNode[];
|
|
89
|
+
attestation?: Address;
|
|
90
|
+
}): Instruction;
|
|
91
|
+
buildRequestWithdraw(input: {
|
|
92
|
+
programId: Address;
|
|
93
|
+
accounts: StakingAccounts;
|
|
94
|
+
amount: bigint;
|
|
95
|
+
path: MSTNode[];
|
|
96
|
+
}): Instruction;
|
|
97
|
+
buildWithdraw(input: {
|
|
98
|
+
programId: Address;
|
|
99
|
+
accounts: StakingAccounts;
|
|
100
|
+
}): Instruction;
|
|
101
|
+
buildReconcileStake(input: {
|
|
102
|
+
programId: Address;
|
|
103
|
+
accounts: StakingAccounts;
|
|
104
|
+
path: MSTNode[];
|
|
105
|
+
}): Instruction;
|
|
106
|
+
buildReclaimSlot(input: {
|
|
107
|
+
programId: Address;
|
|
108
|
+
accounts: {
|
|
109
|
+
subaccord: Address;
|
|
110
|
+
jurorStake: Address;
|
|
111
|
+
};
|
|
112
|
+
path: MSTNode[];
|
|
113
|
+
}): Instruction;
|
|
114
|
+
/** Fetch the decoded JurorStake fields the guard needs. */
|
|
115
|
+
fetchJurorStake(jurorStake: Address): Promise<JurorStakeView | null>;
|
|
116
|
+
/** Build `withdraw_fees` (ADR-0020). */
|
|
117
|
+
buildWithdrawFees(input: {
|
|
118
|
+
programId: Address;
|
|
119
|
+
accounts: WithdrawFeesAccounts;
|
|
120
|
+
}): Instruction;
|
|
121
|
+
/**
|
|
122
|
+
* Build `prune_juror` (PROG-ATTESTATION) — permissionless crank that evicts
|
|
123
|
+
* an expired juror's stake from a credential-gated Subaccord. The cranker
|
|
124
|
+
* signs; the expired `juror` does not. `attestation` is appended as
|
|
125
|
+
* `remaining_accounts[0]` (read-only).
|
|
126
|
+
*/
|
|
127
|
+
buildPruneJuror(input: {
|
|
128
|
+
programId: Address;
|
|
129
|
+
accounts: PruneJurorAccounts;
|
|
130
|
+
path: MSTNode[];
|
|
131
|
+
attestation: Address;
|
|
132
|
+
}): Instruction;
|
|
133
|
+
}
|
|
134
|
+
/** Build `stake` (lib.rs). SPL-transfers `amount` into the vault.
|
|
135
|
+
* RECLAIM-LEAF: when `freedSlotAccount` is provided, the stake pops from the
|
|
136
|
+
* free list (the freed JurorStake is appended as a remaining account). */
|
|
137
|
+
export declare function stake(client: AccordStakingClient, programId: Address, accounts: StakingAccounts, amount: bigint, path: MSTNode[],
|
|
138
|
+
/** PROG-ATTESTATION: juror SAS attestation (required on credential-gated Subaccords). */
|
|
139
|
+
attestation?: Address,
|
|
140
|
+
/** RECLAIM-LEAF: freed JurorStake PDA to pop from the free list when staking into a recycled slot. */
|
|
141
|
+
freedSlotAccount?: Address): Instruction;
|
|
142
|
+
/**
|
|
143
|
+
* Build `request_withdraw` (lib.rs) — phase 1 of the two-phase withdraw
|
|
144
|
+
* (REVIEW #5). Ledger-only: subtracts `amount` from `JurorStake.amount`, banks
|
|
145
|
+
* it in `pending_withdrawal`, and recomputes the accumulator root. No tokens
|
|
146
|
+
* move; no `active_draws` gate (the lock is enforced at `withdraw`). Allowed
|
|
147
|
+
* while paused. `path` is the juror's accumulator proof (ADR-0012).
|
|
148
|
+
*
|
|
149
|
+
* Precondition: `settlementDelta == 0` — call `reconcileStake` first when the
|
|
150
|
+
* juror has a pending reward/slash. DRY with `reconcileStake` (the delta fold
|
|
151
|
+
* lives in one place); withdraw only ever reads the canonical `amount`.
|
|
152
|
+
*/
|
|
153
|
+
export declare function requestWithdraw(client: AccordStakingClient, programId: Address, accounts: StakingAccounts, amount: bigint, path: MSTNode[]): Instruction;
|
|
154
|
+
/**
|
|
155
|
+
* Build `withdraw` (lib.rs:407) — phase 2 of the two-phase withdraw. Moves the
|
|
156
|
+
* banked `pending_withdrawal` from the vault to the juror's ATA. On-chain gates:
|
|
157
|
+
* `WITHDRAWAL_DELAY` elapsed since `request_withdraw` AND `active_draws == 0`.
|
|
158
|
+
* No args — reads `pending_withdrawal` from `JurorStake`.
|
|
159
|
+
*/
|
|
160
|
+
export declare function withdraw(client: AccordStakingClient, programId: Address, accounts: StakingAccounts): Instruction;
|
|
161
|
+
/**
|
|
162
|
+
* Build `reconcile_stake` (lib.rs:460) — permissionless crank (REVIEW #4) that
|
|
163
|
+
* folds a juror's `settlement_delta` into their canonical `amount` and updates
|
|
164
|
+
* the accumulator root via a Merkle proof. After reconcile, the ledger and the
|
|
165
|
+
* accumulator agree again. No tokens move; any caller may trigger it. `path` is
|
|
166
|
+
* the juror's accumulator proof (ADR-0012).
|
|
167
|
+
*/
|
|
168
|
+
export declare function reconcileStake(client: AccordStakingClient, programId: Address, accounts: StakingAccounts, path: MSTNode[]): Instruction;
|
|
169
|
+
/**
|
|
170
|
+
* Build `reclaim_slot` (RECLAIM-LEAF) — permissionless crank that pushes a
|
|
171
|
+
* fully-drained JurorStake's `tree_index` onto the free list, blanking the
|
|
172
|
+
* leaf identity to `(default, 0)`. This recycles the tree slot for reuse by a
|
|
173
|
+
* new staker. No tokens move; any caller may trigger it. `path` is the juror's
|
|
174
|
+
* accumulator proof (ADR-0012).
|
|
175
|
+
*
|
|
176
|
+
* Preconditions: the juror must be fully drained (`staked == 0`,
|
|
177
|
+
* `active_draws == 0`, `stake_delta == 0`, `fees_earned == 0`).
|
|
178
|
+
*/
|
|
179
|
+
export declare function reclaimSlot(client: AccordStakingClient, programId: Address, accounts: {
|
|
180
|
+
subaccord: Address;
|
|
181
|
+
jurorStake: Address;
|
|
182
|
+
}, path: MSTNode[]): Instruction;
|
|
183
|
+
/** Accounts for `withdraw_fees` (ADR-0020). */
|
|
184
|
+
export interface WithdrawFeesAccounts {
|
|
185
|
+
juror: Address;
|
|
186
|
+
subaccord: Address;
|
|
187
|
+
jurorStake: Address;
|
|
188
|
+
feeToken: Address;
|
|
189
|
+
/** Juror's ATA of the fee token (withdraw destination). */
|
|
190
|
+
jurorFeeTokenAccount: Address;
|
|
191
|
+
/** Subaccord PDA's fee_vault ATA (withdraw source). */
|
|
192
|
+
feeVault: Address;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Accounts for `prune_juror` (PROG-ATTESTATION). `caller` is the cranker
|
|
196
|
+
* (signer = the adapter's wallet); `juror` is the EXPIRED juror being pruned
|
|
197
|
+
* (NOT a signer — read-only on chain). Mirrors the on-chain `PruneJuror` struct
|
|
198
|
+
* (lib.rs).
|
|
199
|
+
*/
|
|
200
|
+
export interface PruneJurorAccounts {
|
|
201
|
+
caller: Address;
|
|
202
|
+
juror: Address;
|
|
203
|
+
subaccord: Address;
|
|
204
|
+
jurorStake: Address;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Build `withdraw_fees` (ADR-0020). Per-juror: pulls aggregate `fees_earned`
|
|
208
|
+
* from the Subaccord's `fee_vault` → the juror's `fee_token` ATA. No
|
|
209
|
+
* `active_draws` gate, no timelock — earned fees are not at-risk capital.
|
|
210
|
+
*/
|
|
211
|
+
export declare function withdrawFees(client: AccordStakingClient, programId: Address, accounts: WithdrawFeesAccounts): Instruction;
|
|
212
|
+
/**
|
|
213
|
+
* Build `prune_juror` (PROG-ATTESTATION) — permissionless crank. Evicts an
|
|
214
|
+
* expired juror's `JurorStake` from a credential-gated Subaccord and recomputes
|
|
215
|
+
* the accumulator root via `path`. The cranker (`caller`) signs; the expired
|
|
216
|
+
* `juror` does NOT. `attestation` is the expired juror's SAS attestation,
|
|
217
|
+
* passed as `remaining_accounts[0]` (read-only) so the handler can revoke it.
|
|
218
|
+
*/
|
|
219
|
+
export declare function pruneJuror(client: AccordStakingClient, programId: Address, accounts: PruneJurorAccounts, path: MSTNode[], attestation: Address): Instruction;
|
|
220
|
+
//# sourceMappingURL=staking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../../src/methods/staking.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAIL,KAAK,OAAO,EACZ,KAAK,WAAW,EACjB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAOxC,6DAA6D;AAC7D,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,OAAO,CAAC;IACf,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,oFAAoF;IACpF,UAAU,EAAE,MAAM,CAAC;IACnB,sEAAsE;IACtE,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,CAAC,EAAE,aAAa,GAAG,eAAe,GAAG,qBAAqB,CAAC;CAClE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,cAAc,EACrB,MAAM,EAAE,MAAM,GACb,YAAY,CAMd;AAED,kEAAkE;AAClE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE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