@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.
Files changed (194) hide show
  1. package/README.md +126 -0
  2. package/dist/accord.d.ts +43 -0
  3. package/dist/accord.d.ts.map +1 -0
  4. package/dist/adapter.d.ts +39 -0
  5. package/dist/adapter.d.ts.map +1 -0
  6. package/dist/chunk-7QVYU63E.js +7 -0
  7. package/dist/chunk-7QVYU63E.js.map +1 -0
  8. package/dist/constants.d.ts +83 -0
  9. package/dist/constants.d.ts.map +1 -0
  10. package/dist/domain.d.ts +73 -0
  11. package/dist/domain.d.ts.map +1 -0
  12. package/dist/errors.d.ts +64 -0
  13. package/dist/errors.d.ts.map +1 -0
  14. package/dist/evidence/crypto.d.ts +12 -0
  15. package/dist/evidence/crypto.d.ts.map +1 -0
  16. package/dist/evidence/ecies.d.ts +45 -0
  17. package/dist/evidence/ecies.d.ts.map +1 -0
  18. package/dist/evidence/fetch.d.ts +20 -0
  19. package/dist/evidence/fetch.d.ts.map +1 -0
  20. package/dist/evidence/index.d.ts +27 -0
  21. package/dist/evidence/index.d.ts.map +1 -0
  22. package/dist/evidence/index.js +392 -0
  23. package/dist/evidence/index.js.map +1 -0
  24. package/dist/evidence/keys.d.ts +33 -0
  25. package/dist/evidence/keys.d.ts.map +1 -0
  26. package/dist/evidence/manifest.d.ts +47 -0
  27. package/dist/evidence/manifest.d.ts.map +1 -0
  28. package/dist/evidence/options.d.ts +14 -0
  29. package/dist/evidence/options.d.ts.map +1 -0
  30. package/dist/evidence/parse.d.ts +39 -0
  31. package/dist/evidence/parse.d.ts.map +1 -0
  32. package/dist/evidence/publish.d.ts +45 -0
  33. package/dist/evidence/publish.d.ts.map +1 -0
  34. package/dist/fetch.d.ts +24 -0
  35. package/dist/fetch.d.ts.map +1 -0
  36. package/dist/generated/accounts/accordState.d.ts +58 -0
  37. package/dist/generated/accounts/accordState.d.ts.map +1 -0
  38. package/dist/generated/accounts/appealBond.d.ts +61 -0
  39. package/dist/generated/accounts/appealBond.d.ts.map +1 -0
  40. package/dist/generated/accounts/dispute.d.ts +213 -0
  41. package/dist/generated/accounts/dispute.d.ts.map +1 -0
  42. package/dist/generated/accounts/index.d.ts +15 -0
  43. package/dist/generated/accounts/index.d.ts.map +1 -0
  44. package/dist/generated/accounts/jurorStake.d.ts +137 -0
  45. package/dist/generated/accounts/jurorStake.d.ts.map +1 -0
  46. package/dist/generated/accounts/pendingUpdate.d.ts +43 -0
  47. package/dist/generated/accounts/pendingUpdate.d.ts.map +1 -0
  48. package/dist/generated/accounts/round.d.ts +143 -0
  49. package/dist/generated/accounts/round.d.ts.map +1 -0
  50. package/dist/generated/accounts/subaccord.d.ts +300 -0
  51. package/dist/generated/accounts/subaccord.d.ts.map +1 -0
  52. package/dist/generated/errors/accord.d.ts +160 -0
  53. package/dist/generated/errors/accord.d.ts.map +1 -0
  54. package/dist/generated/errors/index.d.ts +9 -0
  55. package/dist/generated/errors/index.d.ts.map +1 -0
  56. package/dist/generated/index.d.ts +14 -0
  57. package/dist/generated/index.d.ts.map +1 -0
  58. package/dist/generated/instructions/appeal.d.ts +107 -0
  59. package/dist/generated/instructions/appeal.d.ts.map +1 -0
  60. package/dist/generated/instructions/cancelDispute.d.ts +73 -0
  61. package/dist/generated/instructions/cancelDispute.d.ts.map +1 -0
  62. package/dist/generated/instructions/claimAppealRefund.d.ts +91 -0
  63. package/dist/generated/instructions/claimAppealRefund.d.ts.map +1 -0
  64. package/dist/generated/instructions/commit.d.ts +50 -0
  65. package/dist/generated/instructions/commit.d.ts.map +1 -0
  66. package/dist/generated/instructions/commitVrfCallback.d.ts +47 -0
  67. package/dist/generated/instructions/commitVrfCallback.d.ts.map +1 -0
  68. package/dist/generated/instructions/createDispute.d.ts +136 -0
  69. package/dist/generated/instructions/createDispute.d.ts.map +1 -0
  70. package/dist/generated/instructions/createSubaccord.d.ts +196 -0
  71. package/dist/generated/instructions/createSubaccord.d.ts.map +1 -0
  72. package/dist/generated/instructions/drawSeat.d.ts +74 -0
  73. package/dist/generated/instructions/drawSeat.d.ts.map +1 -0
  74. package/dist/generated/instructions/executeSubaccordUpdate.d.ts +43 -0
  75. package/dist/generated/instructions/executeSubaccordUpdate.d.ts.map +1 -0
  76. package/dist/generated/instructions/executeUnpause.d.ts +59 -0
  77. package/dist/generated/instructions/executeUnpause.d.ts.map +1 -0
  78. package/dist/generated/instructions/finalizeDispute.d.ts +46 -0
  79. package/dist/generated/instructions/finalizeDispute.d.ts.map +1 -0
  80. package/dist/generated/instructions/finalizeRound.d.ts +46 -0
  81. package/dist/generated/instructions/finalizeRound.d.ts.map +1 -0
  82. package/dist/generated/instructions/getRuling.d.ts +42 -0
  83. package/dist/generated/instructions/getRuling.d.ts.map +1 -0
  84. package/dist/generated/instructions/health.d.ts +37 -0
  85. package/dist/generated/instructions/health.d.ts.map +1 -0
  86. package/dist/generated/instructions/index.d.ts +37 -0
  87. package/dist/generated/instructions/index.d.ts.map +1 -0
  88. package/dist/generated/instructions/initializePause.d.ts +51 -0
  89. package/dist/generated/instructions/initializePause.d.ts.map +1 -0
  90. package/dist/generated/instructions/pause.d.ts +47 -0
  91. package/dist/generated/instructions/pause.d.ts.map +1 -0
  92. package/dist/generated/instructions/proposeSubaccordUpdate.d.ts +90 -0
  93. package/dist/generated/instructions/proposeSubaccordUpdate.d.ts.map +1 -0
  94. package/dist/generated/instructions/proposeUnpause.d.ts +47 -0
  95. package/dist/generated/instructions/proposeUnpause.d.ts.map +1 -0
  96. package/dist/generated/instructions/pruneJuror.d.ts +68 -0
  97. package/dist/generated/instructions/pruneJuror.d.ts.map +1 -0
  98. package/dist/generated/instructions/reclaimSlot.d.ts +48 -0
  99. package/dist/generated/instructions/reclaimSlot.d.ts.map +1 -0
  100. package/dist/generated/instructions/reconcileStake.d.ts +48 -0
  101. package/dist/generated/instructions/reconcileStake.d.ts.map +1 -0
  102. package/dist/generated/instructions/redraw.d.ts +86 -0
  103. package/dist/generated/instructions/redraw.d.ts.map +1 -0
  104. package/dist/generated/instructions/requestVrf.d.ts +71 -0
  105. package/dist/generated/instructions/requestVrf.d.ts.map +1 -0
  106. package/dist/generated/instructions/requestWithdraw.d.ts +61 -0
  107. package/dist/generated/instructions/requestWithdraw.d.ts.map +1 -0
  108. package/dist/generated/instructions/reveal.d.ts +53 -0
  109. package/dist/generated/instructions/reveal.d.ts.map +1 -0
  110. package/dist/generated/instructions/settleRound.d.ts +60 -0
  111. package/dist/generated/instructions/settleRound.d.ts.map +1 -0
  112. package/dist/generated/instructions/stake.d.ts +98 -0
  113. package/dist/generated/instructions/stake.d.ts.map +1 -0
  114. package/dist/generated/instructions/withdraw.d.ts +67 -0
  115. package/dist/generated/instructions/withdraw.d.ts.map +1 -0
  116. package/dist/generated/instructions/withdrawFees.d.ts +67 -0
  117. package/dist/generated/instructions/withdrawFees.d.ts.map +1 -0
  118. package/dist/generated/pdas/accordState.d.ts +12 -0
  119. package/dist/generated/pdas/accordState.d.ts.map +1 -0
  120. package/dist/generated/pdas/appealBond.d.ts +16 -0
  121. package/dist/generated/pdas/appealBond.d.ts.map +1 -0
  122. package/dist/generated/pdas/dispute.d.ts +16 -0
  123. package/dist/generated/pdas/dispute.d.ts.map +1 -0
  124. package/dist/generated/pdas/index.d.ts +16 -0
  125. package/dist/generated/pdas/index.d.ts.map +1 -0
  126. package/dist/generated/pdas/jurorStake.d.ts +16 -0
  127. package/dist/generated/pdas/jurorStake.d.ts.map +1 -0
  128. package/dist/generated/pdas/pendingUpdate.d.ts +16 -0
  129. package/dist/generated/pdas/pendingUpdate.d.ts.map +1 -0
  130. package/dist/generated/pdas/programIdentity.d.ts +12 -0
  131. package/dist/generated/pdas/programIdentity.d.ts.map +1 -0
  132. package/dist/generated/pdas/round.d.ts +16 -0
  133. package/dist/generated/pdas/round.d.ts.map +1 -0
  134. package/dist/generated/pdas/subaccord.d.ts +16 -0
  135. package/dist/generated/pdas/subaccord.d.ts.map +1 -0
  136. package/dist/generated/programs/accord.d.ts +182 -0
  137. package/dist/generated/programs/accord.d.ts.map +1 -0
  138. package/dist/generated/programs/index.d.ts +9 -0
  139. package/dist/generated/programs/index.d.ts.map +1 -0
  140. package/dist/generated/types/aggregation.d.ts +25 -0
  141. package/dist/generated/types/aggregation.d.ts.map +1 -0
  142. package/dist/generated/types/caseTerms.d.ts +87 -0
  143. package/dist/generated/types/caseTerms.d.ts.map +1 -0
  144. package/dist/generated/types/disputeState.d.ts +34 -0
  145. package/dist/generated/types/disputeState.d.ts.map +1 -0
  146. package/dist/generated/types/index.d.ts +15 -0
  147. package/dist/generated/types/index.d.ts.map +1 -0
  148. package/dist/generated/types/leafClaim.d.ts +27 -0
  149. package/dist/generated/types/leafClaim.d.ts.map +1 -0
  150. package/dist/generated/types/mSTNode.d.ts +26 -0
  151. package/dist/generated/types/mSTNode.d.ts.map +1 -0
  152. package/dist/generated/types/shortfallPolicy.d.ts +23 -0
  153. package/dist/generated/types/shortfallPolicy.d.ts.map +1 -0
  154. package/dist/generated/types/updatePayload.d.ts +107 -0
  155. package/dist/generated/types/updatePayload.d.ts.map +1 -0
  156. package/dist/index.d.ts +47 -0
  157. package/dist/index.d.ts.map +1 -0
  158. package/dist/index.js +8714 -0
  159. package/dist/index.js.map +1 -0
  160. package/dist/methods/appeal.d.ts +131 -0
  161. package/dist/methods/appeal.d.ts.map +1 -0
  162. package/dist/methods/dispute.d.ts +177 -0
  163. package/dist/methods/dispute.d.ts.map +1 -0
  164. package/dist/methods/disputePhase.d.ts +34 -0
  165. package/dist/methods/disputePhase.d.ts.map +1 -0
  166. package/dist/methods/lifecycle.d.ts +228 -0
  167. package/dist/methods/lifecycle.d.ts.map +1 -0
  168. package/dist/methods/mst.d.ts +100 -0
  169. package/dist/methods/mst.d.ts.map +1 -0
  170. package/dist/methods/settlement.d.ts +69 -0
  171. package/dist/methods/settlement.d.ts.map +1 -0
  172. package/dist/methods/stakeFlow.d.ts +65 -0
  173. package/dist/methods/stakeFlow.d.ts.map +1 -0
  174. package/dist/methods/staking.d.ts +220 -0
  175. package/dist/methods/staking.d.ts.map +1 -0
  176. package/dist/methods/voting.d.ts +227 -0
  177. package/dist/methods/voting.d.ts.map +1 -0
  178. package/dist/methods/vrf.d.ts +143 -0
  179. package/dist/methods/vrf.d.ts.map +1 -0
  180. package/dist/methods.d.ts +79 -0
  181. package/dist/methods.d.ts.map +1 -0
  182. package/dist/pda.d.ts +37 -0
  183. package/dist/pda.d.ts.map +1 -0
  184. package/dist/queries.d.ts +27 -0
  185. package/dist/queries.d.ts.map +1 -0
  186. package/dist/query.d.ts +30 -0
  187. package/dist/query.d.ts.map +1 -0
  188. package/dist/token.d.ts +24 -0
  189. package/dist/token.d.ts.map +1 -0
  190. package/dist/types.d.ts +19 -0
  191. package/dist/types.d.ts.map +1 -0
  192. package/dist/wallet.d.ts +30 -0
  193. package/dist/wallet.d.ts.map +1 -0
  194. package/package.json +45 -0
@@ -0,0 +1,131 @@
1
+ /**
2
+ * appeal.ts — dispute appeal + bond refund (ADR-0004).
3
+ *
4
+ * `appeal` is permissionless: any appellant pays the new (larger) round's fee
5
+ * plus an equal bond, opening round `current_round + 1` with a `2N+1` panel
6
+ * and resetting the dispute to `Created` so snapshot→draw→vote reruns. The
7
+ * bond is custodied in a per-appeal `AppealBond` PDA keyed by the round it
8
+ * opened.
9
+ *
10
+ * `claim_appeal_refund` returns a FLIPPED bond to its appellant after
11
+ * `finalize_dispute` (no-flip bonds are folded into the coherent pool there).
12
+ * Idempotent: zeroing the bond on payout makes re-invocation a no-op.
13
+ *
14
+ * Client-side helpers mirror the on-chain appeal ladder (`panel_size_for_round`,
15
+ * lib.rs:2555) and cost math so the facade can quote a panel + fee before
16
+ * sending. Same ADR-0010 facade pattern: Kit type-only, PDA lazy.
17
+ *
18
+ * Sources of truth:
19
+ * - appeal / claim_appeal_refund: lib.rs:1643 (appeal), :1772 (claim_appeal_refund)
20
+ * - Appeal / ClaimAppealRefund accounts: lib.rs:3422 (Appeal), :3486 (ClaimAppealRefund)
21
+ * - AppealBond struct + seeds: state.rs (174-193) `["bond", dispute, round_idx]`
22
+ * - appeal ladder: lib.rs:2553-2570, ADR-0004
23
+ */
24
+ import { type Address, type Instruction } from "@solana/kit";
25
+ export { MAX_JURORS, DEFAULT_APPEAL_WINDOW_SECS, panelSizeForRound, } from "../constants.js";
26
+ /**
27
+ * Required panel size for round `roundIdx` — the appeal ladder
28
+ * `N_{k+1} = 2·N_k + 1` (closed form `(J+1)·2^k − 1`), capped at
29
+ * {@link MAX_JURORS}. Direct port of `panel_size_for_round` (lib.rs:2555).
30
+ * Returns `null` on overflow (round_idx ≥ 31).
31
+ *
32
+ * Re-exported from {@link ../constants.js} for module-internal use.
33
+ */
34
+ /** Appeal cost breakdown for opening round `currentRound + 1` (lib.rs:1688-1695). */
35
+ export interface AppealCost {
36
+ newRound: number;
37
+ panel: number;
38
+ /** New-round fee = panel · fee_per_juror. */
39
+ fee: bigint;
40
+ /** Bond == new-round fee (forfeited if no flip, returned if flipped). */
41
+ bond: bigint;
42
+ /** Appellant pays fee + bond up front. */
43
+ total: bigint;
44
+ }
45
+ /**
46
+ * Quote the panel + fee + bond for an appeal from `currentRound`. Mirrors
47
+ * lib.rs:1688-1695 (`panel_new = panel_size_for_round(J, current+1)`,
48
+ * `fee_new = panel_new · fee_per_juror`, `bond = fee_new`,
49
+ * `total = fee_new + bond`). Returns `null` if the panel math overflows.
50
+ */
51
+ export declare function appealCost(currentRound: number, feePerJuror: bigint, minJurySize?: number): AppealCost | null;
52
+ /** Gate: a fresh appeal requires `currentRound < maxAppeals` (lib.rs:1660). */
53
+ export declare function canAppeal(currentRound: number, maxAppeals: number): boolean;
54
+ /** AppealBond PDA seeds (state.rs:2286): `["bond", dispute, round_idx_le4]`. */
55
+ export declare function appealBondSeeds(disputeBytes: Uint8Array, roundIdx: number): Uint8Array[];
56
+ export declare function findAppealBondPda(programAddress: Address, dispute: Address, roundIdx: number): Promise<{
57
+ address: Address;
58
+ bump: number;
59
+ }>;
60
+ /** Accounts for `appeal`. */
61
+ export interface AppealAccounts {
62
+ /** Any appellant (permissionless). Fee + bond payer. Signer. */
63
+ appellant: Address;
64
+ subaccord: Address;
65
+ accordState: Address;
66
+ dispute: Address;
67
+ /** The just-resolved round (`current_round`) — read for `prior_result`. */
68
+ round: Address;
69
+ /** AppealBond PDA for the NEW round (`["bond", dispute, current_round+1]`). */
70
+ appealBond: Address;
71
+ feeToken: Address;
72
+ appellantTokenAccount: Address;
73
+ feeVault: Address;
74
+ }
75
+ /** Accounts for `claim_appeal_refund`. */
76
+ export interface ClaimRefundAccounts {
77
+ /** Any caller (permissionless crank). Signer. */
78
+ caller: Address;
79
+ subaccord: Address;
80
+ dispute: Address;
81
+ /** AppealBond PDA for `roundIdx` (the round the appeal opened). */
82
+ appealBond: Address;
83
+ feeToken: Address;
84
+ /** Appellant's ATA — sweep destination (owner checked on-chain). */
85
+ claimantTokenAccount: Address;
86
+ feeVault: Address;
87
+ }
88
+ /**
89
+ * Seam to the Codama-generated Kit client. Foundation wires the concrete
90
+ * adapter; appeal.ts stays orchestration-only.
91
+ */
92
+ export interface AccordAppealClient {
93
+ buildAppeal(input: {
94
+ programId: Address;
95
+ accounts: AppealAccounts;
96
+ newEvidenceHash: Uint8Array;
97
+ }): Instruction;
98
+ buildClaimAppealRefund(input: {
99
+ programId: Address;
100
+ accounts: ClaimRefundAccounts;
101
+ roundIdx: number;
102
+ }): Instruction;
103
+ }
104
+ /**
105
+ * Validate a per-round evidence commitment is `[u8; 32]` (lib.rs appeal arg).
106
+ * The `[0u8; 32]` sentinel (no new evidence this round) is a legal value, so
107
+ * only the length is checked. Mirrors {@link assertValidEvidenceHash} in
108
+ * dispute.ts but is duplicated here to keep appeal.ts self-contained.
109
+ */
110
+ export declare function assertValidNewEvidenceHash(newEvidenceHash: Uint8Array): void;
111
+ /**
112
+ * Build `appeal` (lib.rs:1643). Opens `current_round + 1` with a `2N+1` panel;
113
+ * the appellant pays `fee_new + bond` (bond == fee_new). The AppealBond PDA is
114
+ * keyed by the round BEING appealed (`current_round`, pre-increment) — derive it
115
+ * via {@link findAppealBondPda} with `currentRound`.
116
+ *
117
+ * `newEvidenceHash` optionally introduces fresh evidence for the new round
118
+ * (stored at `evidence_hashes[current_round + 1]`); pass the `[0u8; 32]`
119
+ * sentinel (milestone accord-qp7c) to carry forward prior rounds' evidence
120
+ * without adding any.
121
+ */
122
+ export declare function appeal(client: AccordAppealClient, programId: Address, accounts: AppealAccounts, newEvidenceHash: Uint8Array): Instruction;
123
+ /**
124
+ * Build `claim_appeal_refund` (lib.rs:1772) for a specific appeal's bond.
125
+ * `roundIdx` is the round that was appealed (`current_round` at appeal time —
126
+ * the AppealBond PDA seed, pre-increment), selecting which bond to claim.
127
+ * Idempotent
128
+ * on-chain (the bond is zeroed on payout).
129
+ */
130
+ export declare function claimAppealRefund(client: AccordAppealClient, programId: Address, accounts: ClaimRefundAccounts, roundIdx: number): Instruction;
131
+ //# sourceMappingURL=appeal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appeal.d.ts","sourceRoot":"","sources":["../../src/methods/appeal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,WAAW,EACjB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,UAAU,EACV,0BAA0B,EAC1B,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AAgBzB;;;;;;;GAOG;AAEH,qFAAqF;AACrF,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM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QACnB,QAAQ,EAAE,cAAc,CAAC;QACzB,eAAe,EAAE,UAAU,CAAC;KAC7B,GAAG,WAAW,CAAC;IAChB,sBAAsB,CAAC,KAAK,EAAE;QAC5B,SAAS,EAAE,OAAO,CAAC;QACnB,QAAQ,EAAE,mBAAmB,CAAC;QAC9B,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,WAAW,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,eAAe,EAAE,UAAU,GAAG,IAAI,CAM5E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CACpB,MAAM,EAAE,kBAAkB,EAC1B,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,cAAc,EACxB,eAAe,EAAE,UAAU,GAC1B,WAAW,CAGb;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,kBAAkB,EAC1B,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,mBAAmB,EAC7B,QAAQ,EAAE,MAAM,GACf,WAAW,CAKb"}
@@ -0,0 +1,177 @@
1
+ /**
2
+ * dispute.ts — the PRIMARY external surface of @useaccord/sdk.
3
+ *
4
+ * Two methods every Arbitrable integrates against:
5
+ * - {@link createDispute} — files a Dispute (CPI from an Arbitrable program,
6
+ * - {@link getRuling} — lazy read of a dispute's `final_ruling`
7
+ * (u64 with the `u64::MAX` no-ruling sentinel; `null` until the dispute
8
+ * reaches `Final` — ADR-0025).
9
+ *
10
+ * Per ADR-0010 the SDK is two layers: a Codama-generated Kit client (drift-free
11
+ * instruction builders + account codecs) and a thin hand-written facade that
12
+ * owns domain logic. This module is the facade layer for dispute intake; it
13
+ * stays orchestration-only and consumes the generated client through the
14
+ * {@link AccordDisputeClient} seam, which the Foundation task wires to a real
15
+ * adapter. The domain logic that is NOT generated — PDA derivation, fee math,
16
+ * option validation — lives here and is unit-tested independently of the chain.
17
+ *
18
+ * Sources of truth:
19
+ * - Instruction + accounts: programs/accord/src/lib.rs (create_dispute, get_ruling)
20
+ * - Dispute struct + seeds: programs/accord/src/state.rs (Dispute, SEED_DISPUTE)
21
+ * - v1 constants: programs/accord/src/constants.rs (MAX_OPTIONS)
22
+ */
23
+ import { type Address, type Instruction } from "@solana/kit";
24
+ import { Aggregation } from "../types.js";
25
+ export { MAX_OPTIONS } from "../constants.js";
26
+ /** Accord program id (declare_id! in programs/accord/src/lib.rs). */
27
+ export declare const ACCORD_PROGRAM_ID: Address;
28
+ /**
29
+ * A 32-byte option label hash (one row of `Dispute.options`). The Arbitrable
30
+ * chooses these off-chain; the Accord only stores + tallies them.
31
+ */
32
+ export type OptionHash = Uint8Array;
33
+ /**
34
+ * Args for `create_dispute` (lib.rs:254). All amounts in the Subaccord's
35
+ * staking token.
36
+ */
37
+ export interface CreateDisputeArgs {
38
+ /**
39
+ * Option label hashes, each 32 bytes. `Plurality`: 2..={@link MAX_OPTIONS}
40
+ * (see {@link assertValidOptions}). `Median` (ADR-0025): file with none —
41
+ * the vote is a u64 fixed-point scalar, not an index.
42
+ */
43
+ options: OptionHash[];
44
+ /** ADR-0006 on-chain evidence commitment (`[u8; 32]`). */
45
+ evidenceHash: Uint8Array;
46
+ /** Filer-chosen nonce → private dispute namespace. Dispute PDA = `["dispute", filer, nonce]`. */
47
+ nonce: bigint;
48
+ /** Total fee = `min_jury_size * fee_per_juror` (see {@link requiredFee}). Filer pays in full. */
49
+ fee: bigint;
50
+ /**
51
+ * Aggregation rule of the Subaccord being filed against — gates
52
+ * {@link CreateDisputeArgs.options} exactly like the on-chain handler
53
+ * (instructions/create_dispute.rs). Omit for `Plurality` (v1 default).
54
+ */
55
+ aggregation?: Aggregation;
56
+ }
57
+ /** Signer + token accounts the filer brings to `create_dispute`. */
58
+ export interface CreateDisputeAccounts {
59
+ /** The Arbitrable (a program signer via CPI) or any wallet. Fee source + signer. */
60
+ filer: Address;
61
+ /**
62
+ * Data-free rent payer for the dispute `init` + fee_vault `init_if_needed`
63
+ * (the system program rejects lamport transfers from data-carrying accounts,
64
+ * so a PDA filer must not pay rent). Wallet filers pass themselves.
65
+ */
66
+ rentPayer: Address;
67
+ /** The Subaccord this dispute is filed against (fee/panel source). */
68
+ subaccord: Address;
69
+ /** The Subaccord's staking_token mint (fee currency). */
70
+ feeToken: Address;
71
+ /** Filer's ATA of the fee token (fee source). */
72
+ filerTokenAccount: Address;
73
+ /** Subaccord PDA's fee_vault ATA (fee sink, ADR-0020). */
74
+ feeVault: Address;
75
+ /** Circuit-breaker singleton PDA (`["state"]`); stake/create revert while paused. */
76
+ accordState: Address;
77
+ }
78
+ /** Result of preparing a `create_dispute`: the derived Dispute PDA + its instruction. */
79
+ export interface CreateDisputeResult {
80
+ /** The initialized Dispute PDA (`["dispute", filer, nonce]`). */
81
+ dispute: Address;
82
+ /** Canonical bump stored on the account (state.rs: Dispute.bump). */
83
+ bump: number;
84
+ /** Unsigned instruction; the facade's wallet adapter signs + sends it. */
85
+ instruction: Instruction;
86
+ }
87
+ /** Minimal decoded view `getRuling` consumes (avoids duplicating the full Dispute shape). */
88
+ export interface DisputeRulingView {
89
+ /**
90
+ * Winning value once `state == Final`: the option index for `Plurality`
91
+ * disputes, the final median (settlement-mint base units) for `Median`
92
+ * disputes (ADR-0025). `u64::MAX` ({@link NO_RULING}) → `null`.
93
+ */
94
+ finalRuling: bigint | null;
95
+ }
96
+ /**
97
+ * Dispute `final_ruling` no-ruling sentinel — `u64::MAX`. ADR-0025 widened
98
+ * the ruling from `Option<u8>` to a plain u64 (so `Median` disputes can carry
99
+ * a scalar verdict); the old `u8::MAX` (255) sentinel is gone. Stored until
100
+ * `finalize_dispute` writes the real value atomically with `state = Final`
101
+ * (state.rs: `Dispute::ruling`). Same value as voting's `NO_VOTE`.
102
+ */
103
+ export declare const NO_RULING = 18446744073709551615n;
104
+ /**
105
+ * Seam to the Codama-generated Kit client + typed fetcher (ADR-0010). The
106
+ * Foundation task provides a concrete adapter; dispute.ts stays pure
107
+ * orchestration over this interface, so it is parallel-safe under fleet
108
+ * dispatch and compile-verifiable before the generator lands.
109
+ */
110
+ export interface AccordDisputeClient {
111
+ /** Build the `create_dispute` instruction (Anchor discriminator + Borsh args). */
112
+ buildCreateDispute(input: {
113
+ programId: Address;
114
+ accounts: CreateDisputeAccounts;
115
+ args: CreateDisputeArgs;
116
+ disputePda: Address;
117
+ }): Instruction;
118
+ /** Fetch + decode a Dispute account, or `null` if it does not exist yet. */
119
+ fetchDispute(address: Address): Promise<DisputeRulingView | null>;
120
+ }
121
+ /**
122
+ * Compute the required `create_dispute` round-1 fee. The panel is the
123
+ * Subaccord's `min_jury_size` (accord-9q3e; default 3), so the fee is
124
+ * `min_jury_size · fee_per_juror`. Mirrors lib.rs
125
+ * (`(sub.min_jury_size as u64).checked_mul(sub.fee_per_juror)`). Returns `null`
126
+ * on u64 overflow rather than throwing — callers surface a typed error.
127
+ */
128
+ export declare function requiredFee(feePerJuror: bigint, minJurySize?: number): bigint | null;
129
+ /**
130
+ * Validate `create_dispute` options against the Subaccord's aggregation rule
131
+ * (instructions/create_dispute.rs, ADR-0025). `Plurality` (default):
132
+ * `2..=MAX_OPTIONS` hashes, each `[u8; 32]`. `Median`: none — the vote is a
133
+ * u64 scalar, not an option index. Throws a typed `Error` on violation.
134
+ * Pure — no chain access.
135
+ */
136
+ export declare function assertValidOptions(options: OptionHash[], aggregation?: Aggregation): void;
137
+ /** Validate the evidence commitment is `[u8; 32]` (lib.rs:257 instruction arg). */
138
+ export declare function assertValidEvidenceHash(evidenceHash: Uint8Array): void;
139
+ /** Validate a `nonce` fits in a u64 (lib.rs:258 instruction arg). */
140
+ export declare function assertValidNonce(nonce: bigint): void;
141
+ /**
142
+ * Build the Dispute PDA seed bytes (state.rs:1872):
143
+ * `["dispute", filer.key().as_ref(), &nonce.to_le_bytes()]`.
144
+ *
145
+ * `filerBytes` is the filer's 32-byte pubkey encoding (Kit's
146
+ * `getAddressEncoder().encode(filer)`). Pure + deterministic — the unit-test
147
+ * entry point; {@link findDisputePda} wraps it with Kit's resolver.
148
+ */
149
+ export declare function disputeSeeds(filerBytes: Uint8Array, nonce: bigint): Uint8Array[];
150
+ /**
151
+ * Derive the canonical Dispute PDA (`["dispute", filer, nonce.to_le()]`).
152
+ */
153
+ export declare function findDisputePda(programAddress: Address, filer: Address, nonce: bigint): Promise<{
154
+ address: Address;
155
+ bump: number;
156
+ }>;
157
+ /**
158
+ * Prepare a `create_dispute`: validate args, derive the Dispute PDA, and build
159
+ * the instruction via the client seam. The caller (Accord facade) signs + sends
160
+ * `result.instruction` with its wallet adapter.
161
+ *
162
+ * On success the Dispute PDA is `init`-ialized (instructions/create_dispute.rs)
163
+ * and reads `state == Created`, `final_ruling == u64::MAX` ({@link NO_RULING}).
164
+ */
165
+ export declare function createDispute(client: AccordDisputeClient, accounts: CreateDisputeAccounts, args: CreateDisputeArgs, programId?: Address): Promise<CreateDisputeResult>;
166
+ /**
167
+ * Lazily read a dispute's final ruling. Returns the winning value once the
168
+ * dispute reaches `Final` — the option index for `Plurality` disputes, the
169
+ * final median in settlement-mint base units for `Median` disputes
170
+ * (ADR-0025) — or `null` beforehand; on-chain `final_ruling` holds the
171
+ * `u64::MAX` sentinel ({@link NO_RULING}) until then, and both the adapter
172
+ * and {@link getRuling} fold it to `null` (matches the on-chain `get_ruling`
173
+ * CPI entry, lib.rs:480 → `Dispute::ruling()`). Returns `null` if the
174
+ * Dispute account does not exist yet.
175
+ */
176
+ export declare function getRuling(client: AccordDisputeClient, dispute: Address): Promise<bigint | null>;
177
+ //# sourceMappingURL=dispute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispute.d.ts","sourceRoot":"","sources":["../../src/methods/dispute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,WAAW,EACjB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,WAAW,EAA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C,MAAM,GAAG,IAAI,CAAC,CAQxB"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * disputePhase.ts — dispute phase label + countdown for the juror dashboard.
3
+ *
4
+ * The juror dashboard (`/juror`) shows each active draw's current phase
5
+ * (Review / Commit / Reveal) with a countdown timer. The phase is derived
6
+ * from the Dispute's `state` enum + the Round's window deadlines
7
+ * (`reviewEnd`, `commitEnd`, `revealEnd`).
8
+ *
9
+ * Pure — no chain access. Takes already-fetched typed data.
10
+ */
11
+ import { DisputeState } from "../generated/types/disputeState.js";
12
+ /** The Round window deadlines the phase computation needs. */
13
+ export interface RoundPhaseWindows {
14
+ reviewEnd: bigint;
15
+ commitEnd: bigint;
16
+ revealEnd: bigint;
17
+ }
18
+ /** Human-readable phase + remaining seconds (null = no active countdown). */
19
+ export interface PhaseInfo {
20
+ phase: string;
21
+ /** Seconds remaining in the current window. `null` when past the deadline
22
+ * or the state has no countdown. Negative = overdue (crank pending). */
23
+ countdownSecs: bigint | null;
24
+ }
25
+ /**
26
+ * Derive the juror-facing phase label + countdown for a dispute.
27
+ *
28
+ * @param state The Dispute's `state` field.
29
+ * @param now Current Unix timestamp (seconds).
30
+ * @param round The current Round's window deadlines (required for
31
+ * Review/Commit/Reveal; pass `undefined` if not yet drawn).
32
+ */
33
+ export declare function disputePhase(state: DisputeState, now: bigint, round?: RoundPhaseWindows): PhaseInfo;
34
+ //# sourceMappingURL=disputePhase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"disputePhase.d.ts","sourceRoot":"","sources":["../../src/methods/disputePhase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAElE,8DAA8D;AAC9D,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,6EAA6E;AAC7E,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd;6EACyE;IACzE,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,YAAY,EACnB,GAAG,EAAE,MAAM,EACX,KAAK,CAAC,EAAE,iBAAiB,GACxB,SAAS,CA0CX"}
@@ -0,0 +1,228 @@
1
+ /**
2
+ * lifecycle.ts — Subaccord lifecycle + circuit breaker (ADR-0005, ADR-0007).
3
+ *
4
+ * Seven instructions:
5
+ * - {@link createSubaccord} permissionless pool creation.
6
+ * - {@link proposeSubaccordUpdate} authority-gated; arms a 48h timelock.
7
+ * - {@link executeSubaccordUpdate} permissionless crank; lands post-timelock.
8
+ * - {@link initializePause} / {@link pause} / {@link proposeUnpause} /
9
+ * {@link executeUnpause} the ADR-0007 circuit-breaker quartet.
10
+ *
11
+ * Client-side timelock awareness (ADR-0010 §4): `propose_subaccord_update`
12
+ * writes `execute_after_slot = slot + UPDATE_TIMELOCK_SLOTS` on-chain. The SDK
13
+ * cannot predict the exact landing slot, so the flow is: propose → read
14
+ * `execute_after_slot` back from the PendingUpdate account → wait until
15
+ * `canExecuteAt(executeAfterSlot, currentSlot)` → execute. The same shape backs
16
+ * the unpause timelock (`UNPAUSE_TIMELOCK_SLOTS`).
17
+ *
18
+ * Same ADR-0010 facade pattern as the other method modules: pure orchestration
19
+ * over a typed {@link AccordLifecycleClient} seam; Kit type-only; PDAs lazy.
20
+ *
21
+ * Sources of truth:
22
+ * - instructions: programs/accord/src/lib.rs (146-397, 77-144)
23
+ * - accounts/PDAs: programs/accord/src/lib.rs (1693-1845, 1640-1690)
24
+ * - constants: programs/accord/src/constants.rs
25
+ * - UpdatePayload: programs/accord/src/state.rs (254-266)
26
+ */
27
+ import { type Address, type Instruction } from "@solana/kit";
28
+ import type { Aggregation, ShortfallPolicy, UpdatePayload } from "../types.js";
29
+ export { MAX_APPEALS, MAX_DRAW_ATTEMPTS, MAX_JURORS, MIN_APPEAL_WINDOW_SECS, UPDATE_TIMELOCK_SLOTS, UNPAUSE_TIMELOCK_SLOTS, } from "../constants.js";
30
+ export { type ShortfallPolicy, type UpdatePayload } from "../types.js";
31
+ /** Args for `create_subaccord` (lib.rs:146). `domain_ref`/`evidence_spec` immutable. */
32
+ export interface CreateSubaccordArgs {
33
+ /** Immutable identity hash: the class of dispute this pool adjudicates. ≠ [0;32]. */
34
+ domainRef: Uint8Array;
35
+ /** Immutable evidence-format spec hash (ADR-0006). */
36
+ evidenceSpec: Uint8Array;
37
+ /** SPL mint juror capital is staked in (collateral, ADR-0002/0020). */
38
+ stakingToken: Address;
39
+ /** Compensation mint — fees + appeal bonds (ADR-0020). Distinct from stakingToken. */
40
+ feeToken: Address;
41
+ minStake: bigint;
42
+ /** Slash factor in bps (10% = 1000). */
43
+ alphaBps: number;
44
+ reviewWindow: bigint;
45
+ commitWindow: bigint;
46
+ revealWindow: bigint;
47
+ /** Appeal window after a round resolves before finality (ADR-0022). Per-
48
+ * Subaccord, frozen onto `CaseTerms` at filing. ≥ {@link MIN_APPEAL_WINDOW_SECS}. */
49
+ appealWindow: bigint;
50
+ /** ≤ {@link MAX_APPEALS}; bounds the appeal ladder depth. The round-1 panel
51
+ * size is per-Subaccord via {@link CreateSubaccordArgs.minJurySize}
52
+ * (accord-9q3e); each appeal doubles+1. */
53
+ maxAppeals: number;
54
+ /** Round-1 juror panel size (accord-9q3e). Default 3 ({@link INITIAL_NUM_JURORS});
55
+ * must be odd and the appeal ladder `(J+1)·2^maxAppeals − 1` must fit
56
+ * {@link MAX_JURORS}. Set 1 + `maxAppeals = 0` for a single-juror pool.
57
+ * Immutable on the Subaccord (not in {@link UpdatePayload}). */
58
+ minJurySize: number;
59
+ /** Per-Subaccord aggregation rule (ADR-0019). v1 = `Plurality`. */
60
+ aggregation: Aggregation;
61
+ feePerJuror: bigint;
62
+ /**
63
+ * Reveal-quorum fraction in bps (ADR-0021). A round is authoritative only if
64
+ * `reveal_count >= ceil(panel × bps / 10_000)`. Default 6_666 (2/3); the
65
+ * absolute commitment escalates per appeal for free via panel growth.
66
+ */
67
+ revealThresholdBps: number;
68
+ /** Shortfall policy (ADR-0021). v1 = `Redraw` (same-size redraw via `draw_attempt`). */
69
+ shortfallPolicy: ShortfallPolicy;
70
+ /**
71
+ * Same-size redraw cap per round before the dispute fails (ADR-0021).
72
+ * Orthogonal to {@link CreateSubaccordArgs.maxAppeals} (which bounds rounds).
73
+ */
74
+ maxDrawAttempts: number;
75
+ /**
76
+ * Coherence tolerance for `Median` pools, in bps of the final median
77
+ * (ADR-0025): a revealed vote is coherent iff
78
+ * `|vote − ruling| · 10_000 ≤ ruling · coherence_tol_bps`. `0` = exact
79
+ * match. Inert for `Plurality`. Immutable on the Subaccord (not in
80
+ * `UpdatePayload`); frozen onto `CaseTerms` at filing. Docs default 100
81
+ * (1% band) for `Median` pools; use `0` for `Plurality`-only pools.
82
+ */
83
+ coherenceTolBps: number;
84
+ /** `Pubkey::default()` => immutable Subaccord; else signs propose/execute. */
85
+ authority: Address;
86
+ /** ADR-0006 trusted re-encryption service. */
87
+ evidenceOperator: Address;
88
+ /**
89
+ * Fixed accumulator tree depth (ADR-0012). Bounds the juror pool at
90
+ * `2^depth`; the tree never grows a level during operation. Default 20.
91
+ */
92
+ depth: number;
93
+ /**
94
+ * PROG-ATTESTTION: optional credential gate. Omit (or set both to the default
95
+ * pubkey) ⇒ stake-only Subaccord (today's behaviour). Set both ⇒ jurors must
96
+ * hold a valid SAS attestation to stake/draw. Both-or-neither.
97
+ */
98
+ jurorCredential?: Address;
99
+ jurorSchema?: Address;
100
+ }
101
+ /** Subaccord PDA seeds (state.rs:1697): `["subaccord", creator, domain_ref]`. */
102
+ export declare function subaccordSeeds(creatorBytes: Uint8Array, domainRef: Uint8Array): Uint8Array[];
103
+ /** PendingUpdate PDA seeds (state.rs:1816): `["update", subaccord, nonce_le]`. */
104
+ export declare function pendingUpdateSeeds(subaccordBytes: Uint8Array, nonce: bigint): Uint8Array[];
105
+ /** AccordState PDA seeds (state.rs: `["state"]`). Singleton. */
106
+ export declare function accordStateSeeds(): Uint8Array[];
107
+ /** Validate `max_appeals ≤ MAX_APPEALS` (lib.rs). With a configurable round-1
108
+ * panel size (accord-9q3e), `maxAppeals` bounds the appeal ladder depth; the
109
+ * ladder must also fit `MAX_JURORS` — see {@link assertValidMinJurySize}. */
110
+ export declare function assertValidMaxAppeals(maxAppeals: number): void;
111
+ /** Validate `min_jury_size` is odd and the appeal ladder fits `MAX_JURORS`
112
+ * (lib.rs create_subaccord, accord-9q3e). The ladder top
113
+ * `(J+1)·2^maxAppeals − 1` must not exceed {@link MAX_JURORS} or panel growth
114
+ * would be silently truncated by the on-chain `.min()` cap. Throws on violation. */
115
+ export declare function assertValidMinJurySize(minJurySize: number, maxAppeals: number): void;
116
+ /** Validate `appeal_window ≥ MIN_APPEAL_WINDOW_SECS` (lib.rs, ADR-0022). A pool
117
+ * that wants no appeals sets `max_appeals == 0`; a 0 window is rejected. */
118
+ export declare function assertValidAppealWindow(appealWindow: bigint): void;
119
+ /** Validate `reveal_threshold_bps ≤ 10_000` (lib.rs, ADR-0021). */
120
+ export declare function assertValidRevealThreshold(revealThresholdBps: number): void;
121
+ /** Validate `1 ≤ max_draw_attempts ≤ MAX_DRAW_ATTEMPTS` (lib.rs, ADR-0021). */
122
+ export declare function assertValidMaxDrawAttempts(maxDrawAttempts: number): void;
123
+ /** Validate `coherence_tol_bps ≤ 10_000` (lib.rs create_subaccord, ADR-0025).
124
+ * Mirrors the on-chain `InvalidThreshold` gate — same bound as
125
+ * {@link assertValidRevealThreshold}. */
126
+ export declare function assertValidCoherenceTol(coherenceTolBps: number): void;
127
+ /** Reject the degenerate zero domain_ref (lib.rs:164 namespace squat guard). */
128
+ export declare function assertValidRiskType(domainRef: Uint8Array): void;
129
+ /** Timelock gate: may a pending update/unpause land at `currentSlot`? */
130
+ export declare function canExecuteAt(executeAfterSlot: bigint, currentSlot: bigint): boolean;
131
+ export declare function findSubaccordPda(programAddress: Address, creator: Address, domainRef: Uint8Array): Promise<{
132
+ address: Address;
133
+ bump: number;
134
+ }>;
135
+ export declare function findPendingUpdatePda(programAddress: Address, subaccord: Address, nonce: bigint): Promise<{
136
+ address: Address;
137
+ bump: number;
138
+ }>;
139
+ export declare function findAccordStatePdaWithBump(programAddress: Address): Promise<{
140
+ address: Address;
141
+ bump: number;
142
+ }>;
143
+ /**
144
+ * Seam to the Codama-generated Kit client + fetcher. Foundation wires the
145
+ * concrete adapter; lifecycle.ts stays orchestration-only.
146
+ */
147
+ export interface AccordLifecycleClient {
148
+ buildCreateSubaccord(input: {
149
+ programId: Address;
150
+ creator: Address;
151
+ subaccordPda: Address;
152
+ args: CreateSubaccordArgs;
153
+ }): Instruction;
154
+ buildProposeSubaccordUpdate(input: {
155
+ programId: Address;
156
+ authority: Address;
157
+ subaccord: Address;
158
+ pendingUpdatePda: Address;
159
+ nonce: bigint;
160
+ payload: UpdatePayload;
161
+ }): Instruction;
162
+ buildExecuteSubaccordUpdate(input: {
163
+ programId: Address;
164
+ caller: Address;
165
+ subaccord: Address;
166
+ pendingUpdate: Address;
167
+ }): Instruction;
168
+ buildInitializePause(input: {
169
+ programId: Address;
170
+ authority: Address;
171
+ accordStatePda: Address;
172
+ }): Instruction;
173
+ buildPause(input: {
174
+ programId: Address;
175
+ authority: Address;
176
+ accordState: Address;
177
+ }): Instruction;
178
+ buildProposeUnpause(input: {
179
+ programId: Address;
180
+ authority: Address;
181
+ accordState: Address;
182
+ }): Instruction;
183
+ buildExecuteUnpause(input: {
184
+ programId: Address;
185
+ caller: Address;
186
+ accordState: Address;
187
+ }): Instruction;
188
+ /** Read `execute_after_slot` back from a PendingUpdate account (timelock flow). */
189
+ fetchPendingUpdateExecuteAfter(pendingUpdate: Address): Promise<bigint | null>;
190
+ }
191
+ /** Build `create_subaccord` (lib.rs:146). Permissionless; creator owns the namespace. */
192
+ export declare function createSubaccord(client: AccordLifecycleClient, programId: Address, creator: Address, args: CreateSubaccordArgs): Promise<{
193
+ instruction: Instruction;
194
+ subaccord: Address;
195
+ bump: number;
196
+ }>;
197
+ /**
198
+ * Build `propose_subaccord_update` (lib.rs:331). Authority-gated; arms a 48h
199
+ * timelock. The adapter pins the data-free rent payer to its wallet signer
200
+ * (ADR-0028) — wallet authorities pay their own PendingUpdate rent; a PDA
201
+ * authority CPIs from its program with a crank caller as rent payer.
202
+ * The exact `execute_after_slot` is set on-chain from the landing
203
+ * slot — read it back via `fetchPendingUpdateExecuteAfter` and gate execution
204
+ * with `canExecuteAt`. Returns the derived PendingUpdate PDA.
205
+ */
206
+ export declare function proposeSubaccordUpdate(client: AccordLifecycleClient, programId: Address, authority: Address, subaccord: Address, nonce: bigint, payload: UpdatePayload): Promise<{
207
+ instruction: Instruction;
208
+ pendingUpdate: Address;
209
+ }>;
210
+ /**
211
+ * Resolve the timelock for a pending update: read `execute_after_slot` back
212
+ * from the PendingUpdate account. Pair with {@link canExecuteAt}.
213
+ */
214
+ export declare function getUpdateExecuteAfterSlot(client: AccordLifecycleClient, pendingUpdate: Address): Promise<bigint | null>;
215
+ /** Build `execute_subaccord_update` (lib.rs:372). Permissionless; lands post-timelock. */
216
+ export declare function executeSubaccordUpdate(client: AccordLifecycleClient, programId: Address, caller: Address, subaccord: Address, pendingUpdate: Address): Instruction;
217
+ /** Build `initialize_pause` (lib.rs:77). One-time: sets the pause authority. */
218
+ export declare function initializePause(client: AccordLifecycleClient, programId: Address, authority: Address): Promise<{
219
+ instruction: Instruction;
220
+ accordState: Address;
221
+ }>;
222
+ /** Build `pause` (lib.rs:86). Instant, authority-gated emergency freeze. */
223
+ export declare function pause(client: AccordLifecycleClient, programId: Address, authority: Address, accordState: Address): Instruction;
224
+ /** Build `propose_unpause` (lib.rs:102). Arms `UNPAUSE_TIMELOCK_SLOTS` notice. */
225
+ export declare function proposeUnpause(client: AccordLifecycleClient, programId: Address, authority: Address, accordState: Address): Instruction;
226
+ /** Build `execute_unpause` (lib.rs:120). Permissionless; lands post-timelock. */
227
+ export declare function executeUnpause(client: AccordLifecycleClient, programId: Address, caller: Address, accordState: Address): Instruction;
228
+ //# sourceMappingURL=lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../src/methods/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,WAAW,EACjB,MAAM,aAAa,CAAC;AASrB,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE/E,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAuBvE,wFAAwF;AACxF,MAAM,WAAW,mBAAmB;IAClC,qFAAqF;IACrF,SAAS,EAAE,UAAU,CAAC;IACtB,sDAAsD;IACtD,YAAY,EAAE,UAAU,CAAC;IACzB,uEAAuE;IACvE,YAAY,EAAE,OAAO,CAAC;IACtB,sFAAsF;IACtF,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB;0FACsF;IACtF,YAAY,EAAE,MAAM,CAAC;IACrB;;gDAE4C;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB;;;qEAGiE;IACjE,WAAW,EAAE,MAAM,CAAC;IACpB,mEAAmE;IACnE,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,kBAAkB,E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