@xgamesfun/solana 0.20.1 → 0.24.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 (70) hide show
  1. package/README.md +10 -10
  2. package/examples/coin-flip-arena.json +2 -7
  3. package/examples/elements-set.json +2 -9
  4. package/examples/expedition-guild.json +1 -8
  5. package/examples/guild-missions.json +3 -10
  6. package/examples/halving-seasons.json +4 -9
  7. package/examples/hero-trials.json +1 -4
  8. package/examples/merge-2048.json +5 -5
  9. package/examples/paper-hands-farm.json +4 -16
  10. package/examples/partner-vault.json +1 -4
  11. package/examples/stakers-draw.json +1 -8
  12. package/examples/star-fleet.json +1 -8
  13. package/examples/starforce.json +6 -6
  14. package/js/approve/details.mjs +8 -7
  15. package/js/approve/server.mjs +20 -5
  16. package/js/chain/borsh.js +9 -0
  17. package/js/chain/core.js +14 -2
  18. package/js/chain/lookup.js +8 -2
  19. package/js/chain/rpc.js +4 -2
  20. package/js/client/accounts.js +448 -116
  21. package/js/client/grant.js +125 -66
  22. package/js/client/idl/loot.js +1 -1
  23. package/js/client/idl/loot.json +2360 -2218
  24. package/js/client/index.js +1 -0
  25. package/js/client/ix.js +1204 -473
  26. package/js/client/pda.js +20 -16
  27. package/js/client/policy.js +44 -23
  28. package/js/client/random.js +70 -0
  29. package/js/client/sizes.js +255 -12
  30. package/js/economy/check.mjs +455 -210
  31. package/js/economy/cost.mjs +45 -30
  32. package/js/economy/examples.mjs +2 -2
  33. package/js/economy/explain.mjs +24 -20
  34. package/js/economy/guide.mjs +31 -30
  35. package/js/economy/live.mjs +30 -7
  36. package/js/economy/model.mjs +171 -56
  37. package/js/economy/plan.mjs +380 -112
  38. package/js/economy/schema.json +291 -143
  39. package/js/economy/simulate.mjs +154 -87
  40. package/js/mcp/tools.mjs +14 -8
  41. package/js/play/index.js +1121 -375
  42. package/js/play/keys.js +167 -0
  43. package/package.json +1 -1
  44. package/release.json +5 -5
  45. package/skills/xsolana-economy/SKILL.md +15 -11
  46. package/skills/xsolana-economy/references/after-launch.md +37 -27
  47. package/skills/xsolana-economy/references/apps.md +55 -19
  48. package/skills/xsolana-economy/references/sentence-to-spec.md +30 -22
  49. package/skills/xsolana-economy/references/telling-the-person.md +52 -11
  50. package/types/chain/core.d.ts +3 -1
  51. package/types/chain/lookup.d.ts +5 -2
  52. package/types/chain/rpc.d.ts +3 -1
  53. package/types/client/accounts.d.ts +195 -55
  54. package/types/client/grant.d.ts +72 -27
  55. package/types/client/idl/loot.d.ts +590 -559
  56. package/types/client/index.d.ts +1 -0
  57. package/types/client/ix.d.ts +3862 -234
  58. package/types/client/pda.d.ts +19 -15
  59. package/types/client/policy.d.ts +39 -14
  60. package/types/client/random.d.ts +26 -0
  61. package/types/client/sizes.d.ts +93 -5
  62. package/types/economy/check.d.mts +5 -10
  63. package/types/economy/cost.d.mts +2 -1
  64. package/types/economy/live.d.mts +16 -1
  65. package/types/economy/model.d.mts +105 -37
  66. package/types/economy/plan.d.mts +193 -192
  67. package/types/economy/simulate.d.mts +21 -13
  68. package/types/mcp/tools.d.mts +21 -13
  69. package/types/play/index.d.ts +450 -39
  70. package/types/play/keys.d.ts +51 -0
@@ -1,5 +1,8 @@
1
- export { MAX_RECEIPT_ROUNDS } from './sizes.js';
2
- /** Account tags: each account's first byte, as the program writes it. */
1
+ /** The bytes of one time in a farm's record of ends (`decodeEnds`): rent its writer pays, not refunded when a seat leaves. */
2
+ export declare const END_BYTES = 44;
3
+ /** The bytes of a farm's record of ends with no time in it, its owner's rent at `open_farm`. */
4
+ export declare const ENDS_HEAD_BYTES = 7;
5
+ /** Account tags: each account's first byte, as the program writes it; every list of records (`decodeList`) is 26. */
3
6
  export declare const TAGS: Readonly<{
4
7
  Platform: 1;
5
8
  Project: 2;
@@ -11,23 +14,24 @@ export declare const TAGS: Readonly<{
11
14
  Recipe: 8;
12
15
  Hold: 9;
13
16
  Contest: 10;
14
- Entry: 11;
15
17
  Sheet: 12;
16
18
  Traits: 13;
17
- Grant: 14;
18
- Receipt: 15;
19
- LotteryContribution: 16;
19
+ LotteryRound: 16;
20
20
  Farm: 17;
21
21
  Seat: 18;
22
22
  Proven: 19;
23
23
  Auction: 20;
24
- Stash: 21;
25
24
  Offer: 22;
26
25
  Listing: 23;
26
+ Profile: 24;
27
+ Grant: 27;
28
+ Table: 25;
29
+ List: 26;
30
+ Ends: 29;
27
31
  }>;
28
32
  /** The kind of a loot account from its first byte, or null. */
29
33
  export declare const accountKind: (data: any) => string | null;
30
- /** A loot account of the named kind (one the IDL describes). Throws when the data is not one. */
34
+ /** A loot account of the named kind (one the IDL describes, or a `LotteryRound`). Throws when the data is not one. */
31
35
  export declare const decode: (name: any, data: any) => any;
32
36
  /** Any loot account: { kind, value }, or null for data that is no loot account. */
33
37
  export declare function decodeAny(data: any): {
@@ -35,18 +39,56 @@ export declare function decodeAny(data: any): {
35
39
  value: any;
36
40
  } | null;
37
41
  /**
38
- * A counter (a Receipt): a wallet's on a box, a lottery, a recipe or a grant, a person's or a key's on
39
- * a grant. { count (lifetime where tracked), window (the window `inWindow` counts), inWindow, rounds (the first 8
40
- * bytes of sha256 of each round a grant paid it, by voucher or list, in order), claimed(round) }. A round it holds
41
- * was paid once and can never be paid again.
42
+ * A list of records (tag 26, `list.rs`): { width, records } in their order: a wallet's counts
43
+ * (`["counts", project, wallet]`) and a grant's claims are limit records (28 bytes, `readLimit`), a grant's rounds 16
44
+ * bytes, a contest's entries 43 or 83 (`decodeEntries`).
42
45
  */
43
- export declare function decodeReceipt(data: any): {
46
+ export declare function decodeList(data: any): {
47
+ width: number;
48
+ records: Uint8Array<ArrayBufferLike>[];
49
+ };
50
+ /**
51
+ * A farm's record of when its seats stop earning (`["ends", farm]`, tag 29; `Farm.keeps_ends`): its times in order, each
52
+ * `{ at, rewardPerWeight, weight, seats }`: the time (Unix seconds), `reward_per_weight` there once the farm has walked past
53
+ * it, the weight that stops earning then, and the seats that still need the record.
54
+ */
55
+ export declare function decodeEnds(data: any): {
56
+ at: bigint;
57
+ rewardPerWeight: bigint;
58
+ weight: bigint;
59
+ seats: number;
60
+ }[];
61
+ /** The first 16 bytes of the sha256 of `parts` (addresses, bytes or u64s): a record's key in a list. */
62
+ export declare const recordKey16: (...parts: any[]) => Uint8Array<ArrayBuffer>;
63
+ /** The key of a wallet's count for a box, a recipe (incarnation 0) or a lottery (its incarnation), in its counts. */
64
+ export declare const countKey: (record: any, incarnation?: number) => Uint8Array<ArrayBuffer>;
65
+ /** What the limit record at `key` counts in a decoded list (`decodeList`, or null for none): { count, window, inWindow }. */
66
+ export declare function readLimit(list: any, key: any): {
44
67
  count: number;
45
68
  window: number;
46
69
  inWindow: number;
47
- rounds: Uint8Array<ArrayBuffer>[];
48
- claimed: (round: any) => boolean;
49
70
  };
71
+ /** A fetched list account, or null for none (or an empty System account someone sent SOL to, which the program opens
72
+ * as the list). Any other owner or layout is refused. */
73
+ export declare function readListAccount(account: any): {
74
+ width: number;
75
+ records: Uint8Array<ArrayBufferLike>[];
76
+ } | null;
77
+ /**
78
+ * A contest's entries (`["entries", contest, incarnation, 0]`), in the list's order (by player): [{ player, side,
79
+ * amount (0 once paid or refunded; 1 while a contest of NFTs holds its NFT), bits (`CLAIMED`, `ENDED`), nft, place (how
80
+ * many entered its side before it), taken (the losers' NFTs a winner took) }]. A claim names an entry by its index here.
81
+ */
82
+ export declare function decodeEntries(data: any): any[];
83
+ /** A winner's first claim came (its prize given or forgone); a winner ended its picks early. */
84
+ export declare const CLAIMED = 1;
85
+ export declare const ENDED = 2;
86
+ /** How many losers' NFTs a winner of a contest of NFTs takes: the share fixed at the decision, one more for an early
87
+ * place on its side. */
88
+ export declare const shareOf: (contest: any, entry: any) => number;
89
+ /** What a count allows `n` more of at `now` under `limit` ({ total, per_window, window }, 0 is no limit; a lottery's
90
+ * window is its round plus one, given as `window`). */
91
+ export declare function countAllows(count: any, limit: any, now: any, n?: number, window?: number): boolean;
50
92
  /**
51
93
  * A Sheet (`["sheet", project, nft]`): what the project wrote about an NFT it has no authority over. Returns { project, nft,
52
94
  * attributes: [{ key, value }] }. A Sheet never written reads as none: pass `null` data for no account.
@@ -59,11 +101,49 @@ export declare function decodeSheet(data: any): {
59
101
  value: string;
60
102
  }[];
61
103
  } | null;
62
- /** A stash (`["stash", project, id]`): { project, id, nfts }, the NFTs the project holds to give away, in no order. */
104
+ /** A player's profile (`["profile", project, wallet]`): { project, wallet, attributes }, what the project keeps about
105
+ * the wallet (its XP, level, rank). Its layout is a Sheet's, under its own tag. */
106
+ export declare function decodeProfile(data: any): {
107
+ project: string;
108
+ wallet: string;
109
+ attributes: {
110
+ key: string;
111
+ value: string;
112
+ }[];
113
+ } | null;
114
+ /** What a table's rows carry (its payload byte). */
115
+ export declare const PAYLOAD: Readonly<{
116
+ Number: 0;
117
+ Label: 1;
118
+ Nft: 2;
119
+ }>;
120
+ /** Where row `r` of a table of `len`-byte rows is: groups of 64 blocks of 64 rows, each led by its weight in stock. */
121
+ export declare function tableRowAt(len: any, r: any): number;
122
+ /**
123
+ * A table (`["table", project, id]`, `table.rs`): { project, id, payload ('Number' | 'Label'), sealed, count, total
124
+ * (the weight in stock), rows: [{ weight, left, label }] }. A row's `left` is `NO_LIMIT` (4294967295) for a stock that
125
+ * never runs out.
126
+ */
127
+ export declare function decodeTable(data: any): {
128
+ project: string;
129
+ id: number;
130
+ payload: string;
131
+ sealed: boolean;
132
+ count: number;
133
+ total: bigint;
134
+ rows: {
135
+ weight: number;
136
+ left: number;
137
+ label: string;
138
+ }[];
139
+ } | null;
140
+ /** A stash (`["stash", project, id]`, or a lottery's own): { project, id, nfts, weights }, the NFTs the project holds to
141
+ * give away and the weight each is drawn by, as a table of NFTs keeps them (a row: its weight, then the NFT). */
63
142
  export declare function decodeStash(data: any): {
64
143
  project: string;
65
144
  id: number;
66
145
  nfts: string[];
146
+ weights: number[];
67
147
  } | null;
68
148
  /**
69
149
  * A compressed NFT's record (`["leaf", asset]`, `prove_leaf`): { asset, tree, owner (null once burned), delegate,
@@ -98,52 +178,111 @@ export declare function decodeTokenMetadata(data: any): {
98
178
  programmable: boolean;
99
179
  ruleSet: string | null;
100
180
  } | null;
101
- /** A fetched receipt, or null for a missing/prefunded empty System account. Other owners/layouts are refused. */
102
- export declare function readReceiptAccount(account: any): {
103
- count: number;
104
- window: number;
105
- inWindow: number;
106
- rounds: Uint8Array<ArrayBuffer>[];
107
- claimed: (round: any) => boolean;
108
- } | null;
109
- /** What a counter allows `n` more of at `now` under `limit` ({ total, per_window, window }, 0 is no limit). */
110
- export declare function receiptAllows(receipt: any, limit: any, now: any, n?: number): boolean;
111
- /** The contribution among `contributions` ([{ address, value }], decoded LotteryContributions) that holds `ticket`. */
112
- export declare const contributionOf: (contributions: any, ticket: any) => any;
113
- /** Whether a lottery's place wins something: a share of the pot, a roll, or both (as the program counts a place set). */
114
- export declare const placeSet: (place: any) => boolean;
115
- /** The places of a lottery that have a winner this round: as many as are set, but no more than tickets. */
116
- export declare function lotteryWinners(lottery: any): number;
117
- /** The ticket that wins `place` of a drawn lottery: even steps around the list from first place's ticket. */
118
- export declare function ticketOfPlace(lottery: any, place: any): bigint;
119
- /** The places of a drawn lottery whose winning ticket is in `first..end` (a contribution's), in order. */
120
- export declare function placesWon(lottery: any, first: any, end: any): number[];
121
- /** The places of a drawn round that have a winner and a prize, in order: what it gives before its money moves. */
122
- export declare const prizePlaces: (lottery: any) => number[];
123
- /** The places a contribution won whose prize is not given yet (`Lottery.given`): its next step gives them. */
124
- export declare function lotteryOwed(lottery: any, contribution: any): number[];
125
- /** Whether every place's prize of a drawn round is given, so its money may move (`PrizesFirst`). */
126
- export declare const prizesGiven: (lottery: any) => boolean;
127
- /** The lowest place of a drawn round whose prize is not given yet, or null: prizes go in place order (`PlacesInOrder`). */
128
- export declare const nextPrizePlace: (lottery: any) => number | null;
181
+ export declare const OWN_PAID: bigint;
182
+ /** The mint a lottery's tickets are paid in (`terms`: a Lottery's or a round's): its ticket mint, burned, or its pot's. */
183
+ export declare const paymentMint: (terms: any) => any;
184
+ /** Whether a lottery's tickets are burned: they are paid in a ticket mint of its own. */
185
+ export declare const ticketsBurn: (terms: any) => boolean;
186
+ /** A share the buyer chooses (a referrer, a collectible's holder): paid out of the price as they buy, from their own account. */
187
+ export declare const chosenAtPurchase: (share: any) => boolean;
188
+ /** The bytes of one entry of a round: buyer, word, what arrived (`fee`: a fee mint, or a chosen share), the NFT ticket. */
189
+ export declare const entryWidth: (fee: any, nft: any) => number;
129
190
  /**
130
- * What a contribution's next `finish_lottery_contribution` does, or null for nothing yet:
131
- * 'prizes' give the prize of the next place it won, one place a call (a drawn round gives every prize before any money moves);
132
- * 'refund' its tickets back to its buyer (a cancelled round, or a lottery that returns them);
133
- * 'finish' its money through the shares into the pot, its tickets burned, or its NFT ticket spent (only once every
134
- * prize of the round is given);
135
- * 'pay' its places' shares of the pot, once every contribution of the round is finished.
191
+ * A lottery round (`["round", lottery, incarnation, round]`): its header (`status` 'Open' | 'Drawing' | 'Drawn' |
192
+ * 'Cancelled', the terms it copied, `sold`, `owed`, the draw and the money the ask fixed, `nfts` the NFT of the
193
+ * lottery's own stash each such place got), and `entries`, one a purchase: { buyer, start, end (its tickets), paid (its
194
+ * own part's bit), amount (what reached the round), nft (its NFT ticket) }.
136
195
  */
137
- export declare function lotteryStep(lottery: any, contribution: any): "finish" | "pay" | "prizes" | "refund" | null;
196
+ export declare function decodeRound(data: any): any;
197
+ /** How many places a lottery's (or a round's) `places` are, every run counted (`Place.times`). */
198
+ export declare const placeCount: (places: any) => any;
199
+ /** The places of a round that have a winner: every place, but no more than tickets. */
200
+ export declare const roundWinners: (r: any) => number;
201
+ /** The ticket that wins `place` of a drawn round: even steps around the list from first place's ticket. */
202
+ export declare function ticketOfPlace(r: any, place: any): bigint;
203
+ /** The run of places that holds `place`, and its first place. */
204
+ export declare function runOf(r: any, place: any): any[];
205
+ /** The places of run `run` with a winner: [first, end). */
206
+ export declare function runPlaces(r: any, run: any): number[];
207
+ /** The places of run `run` whose ticket is in `start..end` (an entry's), in order. */
208
+ export declare function placesIn(r: any, run: any, start: any, end: any): any[];
209
+ /**
210
+ * What place `place` (counted from the first place of `runs`) takes of a pass-through amount, as the program splits it:
211
+ * runs of `[a, n]` (n places taking `a` each), `sent` what the places are owed and `arrived` what the round holds for
212
+ * them; the last place with a part takes what the others leave.
213
+ */
214
+ export declare function splitPart(runs: any, sent: any, arrived: any, place: any): number | bigint;
215
+ /** Whether place `place`'s part is paid: its pot part's bit (every place's first), or with `prize` its prize's (after
216
+ * every place's pot bit). */
217
+ export declare const placePaid: (r: any, place: any, prize: any) => boolean;
218
+ /** What entry `i`'s places in run `run` take and are not paid yet, of its pot part or (`prize`) its token prize. */
219
+ export declare const placesOwed: (r: any, i: any, run: any, prize: any) => bigint;
220
+ /** How many of the round's owed parts a pull of `{ Pot: [run] }` or a token `{ Prize: [run] }` for entry `i` settles:
221
+ * its places there that take more than nothing (one pull pays them all). */
222
+ export declare const placesPulled: (r: any, i: any, run: any, prize: any) => number;
223
+ /** Whether run `run` of a round's places gives tokens (its prize is fixed at the ask, a `TokenPrize`). */
224
+ export declare const tokenRun: (r: any, run: any) => boolean;
225
+ /** A place whose prize is an NFT of the lottery's own stash (`Held`, `Raffled`): assigned by the pulls, in place order. */
226
+ export declare const ownStash: (place: any) => boolean;
227
+ /** Entry `i`'s places in run `run` whose prize (not tokens) is not given yet, lowest first. */
228
+ export declare const prizePlacesOwed: (r: any, i: any, run: any) => any[];
229
+ /** Where in `r.nfts` the NFT of `place` is (a place of a run that holds or draws one of the lottery's own stash). */
230
+ export declare function nftSlot(r: any, place: any): number;
231
+ /** How many places of a round win an NFT of the lottery's own stash (every such place with a winner). */
232
+ export declare function stashPlacesWon(r: any): number;
233
+ /** Whether entry `i`'s places in run `run` (an NFT of the lottery's own stash) wait for their NFTs to be taken out
234
+ * (`LotteryRound::assign`): a pull with the stash alone does it, and `r.nfts` then names each. */
235
+ export declare function awaitsNfts(r: any, i: any, run: any): boolean;
236
+ /**
237
+ * The parts entry `i` of a round is owed now, in the order a keeper pulls them (`pullIx`'s `part`): its own ('Own': a
238
+ * refund, a no-loss ticket's price, its NFT ticket back or where its price sends it), and with `places`, its places'
239
+ * parts of the pot ({ Pot: [run] }) and prizes ({ Prize: [run] }). Parts owed in common (a share, the pot's, a pool's
240
+ * prize back) are no entry's: `commonOwed`.
241
+ */
242
+ export declare function partsOwed(r: any, i: any, { places }?: {
243
+ places?: boolean | undefined;
244
+ }): (string | {
245
+ Pot: number[];
246
+ Prize?: undefined;
247
+ } | {
248
+ Pot?: undefined;
249
+ Prize: number[];
250
+ })[];
251
+ /**
252
+ * The parts of a round owed in common, of no entry (`{ Common: [i] }`): each share paid in common once drawn (one that
253
+ * burns is burned at the close), then what the round owes the lottery's pot (`i` = the shares' count), then after a
254
+ * cancel each pool's token prize back to its pool (past it).
255
+ */
256
+ export declare function commonOwed(r: any): {
257
+ Common: any[];
258
+ }[];
259
+ /** The entry of a round holding `ticket`. */
260
+ export declare const entryOf: (r: any, ticket: any) => any;
261
+ /** Whether a round is done and owes nothing: the next pull closes it, given its close's accounts. */
262
+ export declare const roundFinished: (r: any) => boolean;
263
+ /** Whether a lottery's place wins something: a share of the pot, a prize, or both. */
264
+ export declare const placeSet: (place: any) => boolean;
265
+ /** The address of a lottery's current round's record (there or not). */
266
+ export declare const roundAddress: (lotteryAddress: any, lottery: any) => any;
267
+ /** Whether a lottery (decoded) drew once and has ended. */
268
+ export declare const lotteryEnded: (lottery: any) => boolean;
269
+ /** The round a lottery's close, its write again and its own stash's moves name (`lottery::check_idle`): its current
270
+ * round's, or once a lottery that draws once has ended, round 0's (which keeps its stash's NFTs until its places took
271
+ * them out). */
272
+ export declare const idleRound: (lotteryAddress: any, lottery: any) => any;
138
273
  /**
139
274
  * Who rents a listed NFT at `now` (Unix seconds), from its decoded Listing (or null for none): the renter's wallet while
140
275
  * a rental runs, else null (a sale listing, or a rental that is over).
141
276
  */
142
277
  export declare function renterOf(listing: any, now: any): any;
278
+ /** Whether a schedule pays every run due when it is sent late (`schedule::catches_up`): only a sealed fixed amount. */
279
+ export declare const scheduleCatchesUp: (schedule: any) => boolean;
143
280
  /**
144
- * How many runs of a schedule are due at `now` (Unix seconds, the chain's clock, never the computer's): each its own
145
- * `run_schedule`, several in one transaction to catch up; one too many fails the whole transaction. A sealed schedule
146
- * past its last run is due once whenever its vault holds something (`vaultBalance`), which goes where it always went.
281
+ * How many runs of a schedule are due at `now` (Unix seconds, the chain's clock, never the computer's). One `run_schedule`
282
+ * makes them all. A sealed schedule's fixed amount pays each of them (`scheduleCatchesUp`; up to its `upto`, the runs made
283
+ * after it: `schedule.runs` plus these, and a long backlog takes a few calls). Any other run pays once, for the latest
284
+ * run due, and those before it lapse. A sealed schedule past its last run is due once whenever its vault holds something
285
+ * (`vaultBalance`), which goes where it always went.
147
286
  */
148
287
  export declare function runsDue(schedule: any, now: any, vaultBalance?: bigint): number;
149
288
  /**
@@ -166,7 +305,8 @@ export declare const ERRORS: Readonly<{
166
305
  }>;
167
306
  /**
168
307
  * The loot error in a failed transaction's logs ("custom program error: 0x…", or Anchor's "Error Code: …" line), or
169
- * null. Only loot's own: another program the transaction calls (Bubblegum, the VRF program, …) has codes of its own
308
+ * null: { code, name, msg }, `msg` the IDL's sentence (the program's own log names the error only: its text is
309
+ * compiled out). Only loot's own: another program the transaction calls (Bubblegum, the VRF program, …) has codes of its own
170
310
  * that may be the same numbers, so an error is loot's only when loot is the program that logged it or failed with it.
171
311
  * The first program that fails is where the error came from; the programs that called it fail after it with the same
172
312
  * code.
@@ -1,19 +1,18 @@
1
- export declare const VOUCHER_DOMAIN = "loot-grant-v4";
1
+ export declare const VOUCHER_DOMAIN = "loot-grant-v5";
2
2
  export declare const LIST_DOMAIN = "loot-list-v3";
3
3
  export declare const KEY_DOMAIN = "loot-key-v1";
4
- /** 13 + 32 × 4 + 8 + 16 + 8. */
5
- export declare const VOUCHER_BYTES = 181;
4
+ /** What a voucher key signs: the prefix (13 bytes), then the sha256 of the voucher's body. */
5
+ export declare const VOUCHER_BYTES = 45;
6
+ /** A grant claim's compute limit: its rounds' records and prizes can pass the 200,000 a transaction has by default. */
7
+ export declare const CLAIM_COMPUTE_UNITS = 400000;
6
8
  export declare const ZERO_HASH: Uint8Array<ArrayBuffer>;
7
9
  export declare const ED25519_PROGRAM = "Ed25519SigVerify111111111111111111111111111";
8
- /** The day the program counts `per_day` in. */
10
+ /** The day a window of `DAY_SECONDS` counts in, from the unix epoch. */
9
11
  export declare const dayOf: (unixSeconds: any) => number;
10
12
  /** An i64 little-endian (two's complement), as the program reads `expires`. */
11
13
  export declare const i64LE: (value: any) => Uint8Array<any>;
12
- /**
13
- * The 181 bytes a voucher key signs and `claim_grant` rebuilds from its own accounts and arguments. `round` names the
14
- * win (the project round, draw or giveaway it was won in): the program pays a wallet each round once per grant incarnation.
15
- */
16
- export declare function voucherBytes({ program, grant, incarnation, wallet, personHash, round, expires, amount }: {
14
+ /** A voucher's body, which its key signs the sha256 of (`voucherBytes`). */
15
+ export declare function voucherBody({ program, grant, incarnation, wallet, personHash, expires, rounds, round, amount }: {
17
16
  amount?: bigint | undefined;
18
17
  expires: any;
19
18
  grant: any;
@@ -21,18 +20,28 @@ export declare function voucherBytes({ program, grant, incarnation, wallet, pers
21
20
  personHash: any;
22
21
  program?: string | undefined;
23
22
  round: any;
23
+ rounds: any;
24
24
  wallet: any;
25
25
  }): Uint8Array<any>;
26
- /** The fields back from voucher bytes (addresses as bytes). */
27
- export declare function readVoucher(bytes: any): {
26
+ /**
27
+ * The 45 bytes a voucher key signs and `claim_grant` rebuilds from its own accounts and arguments: the prefix, then the
28
+ * sha256 of the voucher's body (`voucherBody`), so a voucher of many rounds is as short to check as one of one. `rounds`
29
+ * ([{ id, amount }], or one `round` and its `amount`) names the wins (the project round, draw or giveaway each was won
30
+ * in): the program pays a wallet each round once per grant incarnation.
31
+ */
32
+ export declare const voucherBytes: (fields: any) => Uint8Array<any>;
33
+ /** The fields back from a voucher's body (`voucherBody`; addresses as bytes, rounds as [{ id, amount }]). */
34
+ export declare function readVoucher(body: any): {
28
35
  program: Uint8Array<ArrayBuffer>;
29
36
  grant: Uint8Array<ArrayBuffer>;
30
37
  incarnation: bigint;
31
38
  wallet: Uint8Array<ArrayBuffer>;
32
39
  personHash: Uint8Array<ArrayBuffer>;
33
- round: Uint8Array<ArrayBuffer>;
34
40
  expires: bigint;
35
- amount: bigint;
41
+ rounds: {
42
+ id: Uint8Array<ArrayBuffer>;
43
+ amount: bigint;
44
+ }[];
36
45
  };
37
46
  /** A voucher key's leaf under a grant's `key_root`. */
38
47
  export declare const keyLeaf: (key: any) => Uint8Array<ArrayBuffer>;
@@ -81,23 +90,41 @@ export declare function ed25519Ix({ publicKey, signature, message }: {
81
90
  keys: never[];
82
91
  data: Uint8Array<any>;
83
92
  };
93
+ /** The key of a grant's limit record of `kind` ('wallet', 'person', 'badge', 'code') for `subject` (an address or 32
94
+ * bytes): sha256(kind | subject)[..16]. */
95
+ export declare const limitKey: (kind: any, subject: any) => Uint8Array<ArrayBuffer>;
96
+ /** The key of a wallet's record of a round a grant paid it: sha256(round | wallet)[..16]. */
97
+ export declare const roundKey: (round: any, wallet: any) => Uint8Array<ArrayBuffer>;
98
+ /** The shard a record's key falls in, of a grant's `2^bits`: the top `bits` bits of its first byte. */
99
+ export declare const shardOf: (key: any, bits: any) => number;
100
+ /** The rounds shard a wallet's paid rounds are kept in: its own limit record's. */
101
+ export declare const walletShard: (grant: any, wallet: any) => number;
102
+ /** Whether a grant paid `wallet` for `round`, from the wallet's decoded rounds shard (`decodeList`, null for none). */
103
+ export declare const roundPaid: (list: any, wallet: any, round: any) => boolean;
104
+ /**
105
+ * The fewest shard bits (0 to 8) that keep each of a grant's lists under ~100,000 records over its life: `wallets` ×
106
+ * the rounds each may claim (`rounds`). A 10,000-wallet airdrop takes 0 (one shard).
107
+ */
108
+ export declare function shardBitsFor(wallets: any, rounds?: number): number;
84
109
  /**
85
110
  * The claim of grant `id` for `wallet`, sent and signed by `signer` (anyone: the play host, the owner's server, the
86
- * player). The grant's funds pay its rent through the signer; what they can't cover, the signer pays. The signer pays
87
- * the player fee with its own SOL. `grant` is the decoded Grant; `count` the wallet's receipt count before this claim (0 for a
88
- * first claim); `poolMint` the mint of a Payout's pool, read from the pool.
89
- * A voucher claim goes right after `ed25519Ix` in the same transaction, `voucherKey` the key that signed it (its
90
- * counter is passed when the grant limits keys; a key under the key root carries its `proof`); a list claim carries
91
- * its `proof`; an open grant (no keys, no key root, no list) needs neither. What passes its gate (`shown`, or
92
- * `listProof` for a list gate) comes first. Its prize (`grant.gives`, `prizeMetas`)
93
- * follows: `poolMint` for tokens from a pool, `item` (the decoded Item) for a collectible or a compressed NFT of one, `nft` for an NFT of a stash;
94
- * a roll's order at `nonce` (`prizeNonce(grant, round, count)` by default), then the rolled box's prize mints
95
- * (`rollMints`: `boxes` maps the box's id to its decoded LootBox, null for one never written; `rollPools` each pool its
96
- * prizes name to its mint, null for one never opened). The grant's funds pay what it opens.
111
+ * player). The grant's funds pay its records through the signer; what they can't cover, the signer pays. The signer pays
112
+ * the player fee, and a roll's order, with its own SOL. `grant` is the decoded Grant.
113
+ *
114
+ * A voucher claim goes right after `ed25519Ix` in the same transaction, `voucherKey` the key that signed it (a key under
115
+ * the key root carries its proof as `proofs[0]`); a list claim carries a proof for each round (`proofs`); an open grant
116
+ * (no keys, no key root, no list) names no round and pays one prize (`count`: the wallet's claims before it, for its
117
+ * roll's nonce). `rounds` ([{ id, amount }], or one `round` and its `amount`) are the wins it names: each paid once, so
118
+ * one already paid is skipped (`paidRounds`: the wallet's decoded rounds shard, `decodeList`, to leave out its prize's
119
+ * accounts). What passes its gate (`shown`, or `listProof` for a list gate) comes first, then each shard of the grant's
120
+ * claims it counts in, then each round's prize (`grant.gives`, `prizeMetas`): `poolMint` for tokens from a pool, `item`
121
+ * (the decoded Item) for a collectible or a compressed NFT of one, `nft` for an NFT of a stash; round `i`'s roll at
122
+ * `prizeRollNonce(nonce + i)` (`nonce`: `prizeNonce` of the grant, the wallet and its rounds by default), its box and
123
+ * order only (`askRollIx` then asks for it, in the same transaction when it fits). Send it with a compute limit of
124
+ * `CLAIM_COMPUTE_UNITS`.
97
125
  */
98
- export declare function claimGrantIx({ project, id, grant, wallet, signer, count, round, expires, personHash, amount, proof, poolMint, item, nft, boxes, rollPools, shown, listProof, programs, voucherKey, nonce, extra }: {
126
+ export declare function claimGrantIx({ project, id, grant, wallet, signer, count, rounds, round, expires, personHash, amount, proofs, proof, paidRounds, poolMint, item, nft, shown, listProof, programs, voucherKey, nonce, extra }: {
99
127
  amount?: bigint | undefined;
100
- boxes?: {} | undefined;
101
128
  count?: number | undefined;
102
129
  expires: any;
103
130
  extra?: never[] | undefined;
@@ -107,13 +134,15 @@ export declare function claimGrantIx({ project, id, grant, wallet, signer, count
107
134
  listProof: any;
108
135
  nft: any;
109
136
  nonce: any;
137
+ paidRounds?: null | undefined;
110
138
  personHash: any;
111
139
  poolMint: any;
112
140
  programs: any;
113
141
  project: any;
114
142
  proof?: never[] | undefined;
115
- rollPools?: {} | undefined;
143
+ proofs: any;
116
144
  round: any;
145
+ rounds: any;
117
146
  shown: any;
118
147
  signer: any;
119
148
  voucherKey: any;
@@ -123,3 +152,19 @@ export declare function claimGrantIx({ project, id, grant, wallet, signer, count
123
152
  keys: any[];
124
153
  data: Uint8Array<any>;
125
154
  };
155
+ /**
156
+ * Anyone closes shard `shard` of a grant's rounds (`rounds`) or claims once the grant is closed or made again
157
+ * (`incarnation` the one the shard is of): its rent goes to the project's `owner`.
158
+ */
159
+ export declare const closeShardIx: ({ project, id, incarnation, rounds, shard, owner }: {
160
+ id: any;
161
+ incarnation: any;
162
+ owner: any;
163
+ project: any;
164
+ rounds?: boolean | undefined;
165
+ shard: any;
166
+ }) => {
167
+ programId: string;
168
+ keys: any[];
169
+ data: Uint8Array<any>;
170
+ };