@xgamesfun/solana 0.20.1 → 0.25.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 (112) hide show
  1. package/README.md +95 -52
  2. package/bin/xsolana.mjs +23 -8
  3. package/examples/blind-forge.json +2 -4
  4. package/examples/coin-flip-arena.json +4 -12
  5. package/examples/duel-arena.json +1 -4
  6. package/examples/elements-set.json +2 -9
  7. package/examples/expedition-guild.json +1 -8
  8. package/examples/fair-presale.json +1 -3
  9. package/examples/guild-missions.json +3 -10
  10. package/examples/halving-seasons.json +4 -9
  11. package/examples/hero-trials.json +15 -6
  12. package/examples/holder-den.json +38 -0
  13. package/examples/holders-drop.json +105 -0
  14. package/examples/ideas.json +788 -788
  15. package/examples/match-predictions.json +24 -0
  16. package/examples/merge-2048.json +5 -5
  17. package/examples/nft-raffle.json +1 -0
  18. package/examples/pack-league.json +108 -0
  19. package/examples/paper-hands-farm.json +4 -16
  20. package/examples/partner-vault.json +20 -7
  21. package/examples/sacrifice-raffle.json +2 -10
  22. package/examples/shelter-fair.json +1 -0
  23. package/examples/stakers-draw.json +4 -15
  24. package/examples/star-fleet.json +1 -8
  25. package/examples/starforce.json +6 -6
  26. package/examples/stride-sneakers.json +164 -0
  27. package/examples/trade-in-shop.json +2 -3
  28. package/js/approve/details.mjs +122 -52
  29. package/js/approve/ed25519.mjs +5 -1
  30. package/js/approve/live-check.mjs +83 -26
  31. package/js/approve/page.html +217 -78
  32. package/js/approve/page.js +43 -15
  33. package/js/approve/server.mjs +290 -73
  34. package/js/chain/base58.js +7 -1
  35. package/js/chain/borsh.js +24 -11
  36. package/js/chain/bytes.js +11 -8
  37. package/js/chain/core.js +35 -7
  38. package/js/chain/curve.js +1 -1
  39. package/js/chain/lookup.js +124 -36
  40. package/js/chain/mint.js +6 -2
  41. package/js/chain/pda.js +2 -2
  42. package/js/chain/programs.js +6 -6
  43. package/js/chain/rpc.js +44 -16
  44. package/js/chain/token.js +13 -2
  45. package/js/chain/token2022.js +55 -16
  46. package/js/chain/tx.js +32 -22
  47. package/js/client/accounts.js +653 -131
  48. package/js/client/compressed.js +4 -3
  49. package/js/client/grant.js +267 -83
  50. package/js/client/idl/loot.js +1 -1
  51. package/js/client/idl/loot.json +2406 -2176
  52. package/js/client/index.js +1 -0
  53. package/js/client/ix.js +3059 -664
  54. package/js/client/pda.js +39 -33
  55. package/js/client/policy.js +52 -24
  56. package/js/client/random.js +70 -0
  57. package/js/client/sizes.js +414 -16
  58. package/js/client/traits.js +14 -5
  59. package/js/connect/connect.mjs +59 -17
  60. package/js/economy/check.mjs +4153 -725
  61. package/js/economy/cost.mjs +403 -64
  62. package/js/economy/examples.mjs +176 -35
  63. package/js/economy/explain.mjs +466 -111
  64. package/js/economy/guide.mjs +296 -72
  65. package/js/economy/legal.mjs +12 -6
  66. package/js/economy/live.mjs +83 -19
  67. package/js/economy/model.mjs +462 -124
  68. package/js/economy/plan.mjs +1306 -219
  69. package/js/economy/schema.json +390 -484
  70. package/js/economy/secrets.mjs +17 -7
  71. package/js/economy/simulate.mjs +883 -223
  72. package/js/economy/txsize.mjs +15 -3
  73. package/js/economy/validate.mjs +61 -24
  74. package/js/mcp/server.mjs +42 -14
  75. package/js/mcp/tools.mjs +307 -88
  76. package/js/play/index.js +2864 -619
  77. package/js/play/keys.js +193 -0
  78. package/js/results/index.js +223 -30
  79. package/js/results/server.js +230 -0
  80. package/js/results/wire.js +64 -16
  81. package/package.json +6 -4
  82. package/release.json +5 -5
  83. package/skills/xsolana-economy/SKILL.md +39 -21
  84. package/skills/xsolana-economy/references/after-launch.md +58 -38
  85. package/skills/xsolana-economy/references/apps.md +97 -50
  86. package/skills/xsolana-economy/references/sentence-to-spec.md +148 -121
  87. package/skills/xsolana-economy/references/telling-the-person.md +61 -17
  88. package/types/chain/core.d.ts +4 -2
  89. package/types/chain/lookup.d.ts +5 -2
  90. package/types/chain/rpc.d.ts +3 -1
  91. package/types/client/accounts.d.ts +217 -56
  92. package/types/client/grant.d.ts +72 -27
  93. package/types/client/idl/loot.d.ts +602 -549
  94. package/types/client/index.d.ts +1 -0
  95. package/types/client/ix.d.ts +3884 -247
  96. package/types/client/pda.d.ts +22 -16
  97. package/types/client/policy.d.ts +39 -14
  98. package/types/client/random.d.ts +26 -0
  99. package/types/client/sizes.d.ts +93 -5
  100. package/types/economy/check.d.mts +5 -10
  101. package/types/economy/cost.d.mts +2 -1
  102. package/types/economy/guide.d.mts +5 -0
  103. package/types/economy/live.d.mts +16 -1
  104. package/types/economy/model.d.mts +151 -38
  105. package/types/economy/plan.d.mts +237 -194
  106. package/types/economy/simulate.d.mts +21 -13
  107. package/types/mcp/tools.d.mts +21 -13
  108. package/types/play/index.d.ts +453 -53
  109. package/types/play/keys.d.ts +51 -0
  110. package/types/results/index.d.ts +7 -6
  111. package/types/results/server.d.ts +126 -0
  112. package/types/results/wire.d.ts +1 -1
@@ -7,7 +7,8 @@ and the spec differ (a limit, an amount, a key not set yet), change one of them
7
7
  1. **What each play costs and is worth.** Lead with the tools' "in all" number: "A cast costs about 0.0234 SOL in
8
8
  all (0.02 SOL, the 0.002 SOL player fee, the oracle and the network, and the Perch's rent when one is caught), and
9
9
  gives back 0.01 SOL in prizes on average (50%), plus a Perch 3 casts in 10." For a box of items, the odds; for a
10
- lottery, what the pot reaches and what each place wins; for a farm, a day of rewards per unit staked and what the
10
+ lottery, where its places are paid from (its pot, which gifts and what earlier rounds left fill, or each round's own
11
+ ticket money, which nothing from outside can change), what that reaches and what each place wins; for a farm, a day of rewards per unit staked and what the
11
12
  lock tiers multiply.
12
13
  2. **Where the money goes.** "55% of each cast goes into the pond that pays the Golden Carp, 5% into the monthly
13
14
  draw's pot, and the other 40% to your treasury."
@@ -17,18 +18,19 @@ and the spec differ (a limit, an amount, a key not set yet), change one of them
17
18
  the odds players are shown don't hold until then (`W-PRIZE-SEED`).
18
19
  4. **What going live costs.** "About 12.51 SOL on devnet, in one wallet approval: 12.5 SOL is the pond's seed, the
19
20
  rest is rent and fees."
20
- 5. **Who does what while it runs** (`after-launch.md` has the table): what anyone can send (a draw, a schedule, an
21
- auction's end, claims), what only they can (a contest's result, a payout, a held item, a collectible's new level)
21
+ 5. **Who does what while it runs** (`after-launch.md` has the table): what anyone can send (a draw, an
22
+ auction's end, claims), what only they can (a contest's result, a payout, a held item, a collectible's new level, each run of a schedule that isn't sealed: without them or a server holding a project key, an emission stops)
22
23
  and how often, and what happens if nobody does. If a payout rewards a result the game reports (a clear, a win,
23
24
  a score): "Checking that a player really did it is up to you, on your own server: a game runs in the player's
24
25
  browser, and the program trusts the authority's signature."
25
- 6. **Flags for the law.** `W-CHANCE-PRIZE`: "Players pay for a chance at money. That is gambling in many places once
26
+ 6. **Flags for the law, once.** `W-CHANCE-PRIZE`: "Players pay for a chance at money. That is gambling in many places once
26
27
  it is real money; this runs on devnet only." `W-CHANCE-ITEMS`: "Players pay for random items they can resell: some
27
28
  places treat that as gambling, and many require the odds to be shown." `W-REVENUE-SHARE`: "Stakers are paid from
28
- what players spend; regulators look at that when they decide whether a token is a security." Say them every time
29
- they are raised. Before they go live, every time: "The program isn't independently audited and comes as is, with
30
- no warranty: you use it at your own risk, and making sure this is legal where you offer it is up to you." The
31
- approval page shows all of this too, and keeps Approve off until the owner ticks that they read it.
29
+ what players spend; regulators look at that when they decide whether a token is a security." Say each once, the
30
+ first time the checker raises it; then leave them, saying them again only when the person asks or a flag of a new
31
+ kind appears, and keep them out of pages and apps unless asked. The approval page shows them, with the program's
32
+ status (not independently audited, as is, at their own risk, theirs to make legal where they offer it), and keeps
33
+ Approve off until the owner ticks that they read it.
32
34
  7. **For an auction**, say how it ends, in their words: "The highest bid when the 48 hours are up wins. Each bid must
33
35
  be at least 0.5 SOL and 5% over the last; a bid in the last 10 minutes gives everyone 10 more. Whoever is outbid
34
36
  has their SOL back at once, in the same transaction. With no bid, the lot goes back (an item's unit is never
@@ -39,7 +41,46 @@ and the spec differ (a limit, an amount, a key not set yet), change one of them
39
41
  8. **Anything else the checker warned about**, in a sentence each (a mint that can freeze accounts, a free box bots
40
42
  can drain, a grant with no limits or no funds).
41
43
 
44
+ ## What stays the project's job
45
+
46
+ Say these whenever the spec has the part they name, before the person goes live. The program holds the rules and the
47
+ money; it holds no files and serves nothing.
48
+
49
+ - **Images and metadata are off the chain.** An item's `uri` points at a file the project hosts; the program keeps no
50
+ images. A fresh item's `uri` with `{attribute}` in it (`https://…/hero/{color}/{power}.json`) becomes a different link
51
+ for every value drawn: the project hosts a file for every value a table or range can give (every row's label, every
52
+ number from `min` to `max`), or a server that renders them on request. A link with nothing behind it is a card
53
+ that shows no picture, for good.
54
+ - **Large tables cost rent the owner pays, never back**: about 8 bytes a row of numbers and 40 a row of labels, at
55
+ 5,080 lamports (0.00000508 SOL) a byte: 1,000 labels about 0.2 SOL, 100,000 numbers about 4.1 SOL. Quote
56
+ `xsolana_cost` for the real figure.
57
+ - **A pack's cards each cost a collectible's rent when settled.** Whoever settles pays what the settle mints: Core
58
+ keeps about 0.0031 SOL in each card the player gets. The page lends its throwaway settle key 0.006 SOL for each Core
59
+ card it may mint, in the purchase's one prompt, and the key sends back what it didn't spend. A plain compressed card
60
+ costs none. A pack of fixed cards (nothing random) is bought in one step, its cards minted in the purchase; a pack
61
+ too big for one transaction settles in parts (about 14 Core cards a part), which the page sends.
62
+ - **When an outcome runs out, the project chooses what its box does (`whenOut`), and should hear the trade-off.**
63
+ An outcome runs out when its item sells out, its pool can't cover its whole prize, or its stash empties. With
64
+ `"stopSales"` (the default) the box isn't sold while any outcome couldn't cover this purchase and those still waiting
65
+ for the oracle: every roll is on the odds written, nobody can buy their way to a rare once the commons are gone, and
66
+ the project restocks or edits the box to sell again (a pool holds its prize for every draw waiting; a named NFT is in
67
+ one waiting purchase at a time). With `"drawLeft"` the box keeps selling and draws among what is left, by the written
68
+ weights: the others' chances rise as one runs out, so anyone watching the stock can empty a common outcome and then
69
+ open for the rare at better odds. Put it as: "stop selling keeps your odds honest; keep selling never stalls but lets
70
+ a player tilt the odds". A box selling a rare prize keeps the default; `drawLeft` suits a box of alike prizes, or one
71
+ only other routes roll (a grant's, a mission's), where nothing is sold. `xsolana_check` says what each does to the
72
+ box (W-WHEN-OUT, W-OUT-OF-STOCK, W-PRIZE-SEED, W-STASH) and `xsolana_simulate` the day it stops or each outcome runs out.
73
+ - **A prize the program can't give right now is out of stock, not an error.** A prize in a token with a transfer hook
74
+ (or confidential transfers) is never moved by a roll. An outcome emptied by another route after a purchase (another
75
+ box sharing its pool, item or stash) can't be given: a draw that lands on it is not made, no other outcome takes its
76
+ place, and that draw's worth of the price goes back at the settle. With no draw made a paid open is refunded and a
77
+ free roll waits to be asked again, and a box with nothing in stock is refused (SoldOut).
78
+ - **The oracle's answer reads at most 21 accounts**, so a box's distinct prize accounts (its items, pools, stashes,
79
+ the mints and vaults of its tokens, a fresh item's tables) are bounded by that, however many outcomes it has.
80
+ `xsolana_check` counts them.
81
+
42
82
  Don'ts:
83
+
43
84
  - Don't show mints, account addresses, PDAs, lamports or instruction names unless asked.
44
85
  - Don't promise returns, profits or "passive income". Say what the program does, with the numbers.
45
86
  - Don't hide a gap: if loot can't do what they asked, the first line says so and offers the nearest thing.
@@ -60,8 +101,8 @@ Don'ts:
60
101
  set (`traits`): say who proves them, and when.
61
102
  - **Rolls that can fail**: a box, a mission or a recipe that can burn or give away the NFT it rolls on holds it from
62
103
  the moment the roll is made until it is settled. Say the odds in plain numbers, which stats raise them, and what a
63
- loss means (burned, or given to whom). Nobody can back out of a roll once it is made; anyone (the page, a keeper)
64
- asks the oracle for it and settles it.
104
+ loss means (burned, or given to whom). Nobody can back out of a roll once it is made; the player or the project's keys ask the oracle
105
+ for it, and the player, a key they named or the project's keys settle it.
65
106
  - **NFT custody** (a farm, a mission): Escrow is the default: the NFT moves to the project while it is staked.
66
107
  Freeze keeps it in the player's wallet, locked, with the project the only key that unlocks it; a soulbound
67
108
  collectible needs Freeze. Watch holds nothing: say plainly that a staked NFT can be sold, that its seller then
@@ -69,12 +110,15 @@ Don'ts:
69
110
  at once: a guild frozen, its missions watched. Either way the NFT issuer's own controls still apply: an issuer who
70
111
  can block transfers, or (under Freeze) one whose later metadata or plugin changes stop the unfreeze, can keep an
71
112
  NFT from coming back, and forfeiting rewards doesn't get around that. Never promise an unconditional exit.
72
- - **A farm releases everything in its rewards pool** to its stakers, over its longest lock (a day at least), by
73
- weight as it is released: give each farm a pool of its own (`W-POOL-SHARED`). Whoever stakes first is credited all
74
- that is released while they are alone, so say early stakers share the first rewards among few. A farm that
75
- `runs` takes no stake at its end, and what it has not released by then stays in the pool, the project's, as does
76
- what a seat gives back after it: say to fund it at least its release span before the end, and to refresh a seat
77
- they suspect is dead (a watched NFT sold, an upkeep run out) a span before it. A sharing farm of a token with a
113
+ - **A farm releases everything that lands in its own rewards vault** to its stakers, over its longest lock (a day at
114
+ least), by weight as it is released. Something must send it rewards: its `seed`, a share `"farm:<key>"` of a sale,
115
+ or a schedule that pays or mints into `"farm:<key>"` (`W-FARM-DRY` when nothing does). Whoever stakes first is
116
+ credited all that is released while they are alone, so say early stakers share the first rewards among few. A farm
117
+ that `runs` takes no stake at its end, and what it has not released by then stays in its vault (the authority may
118
+ take back what is free there), as does what a seat forfeits after it: say to fund it at least its release span
119
+ before the end. What a seat earned by its term (`earnsFor`) or its fuel is exact however late it is next touched, and
120
+ nobody has to act at that time. Such a farm keeps a record of those times: each new one costs whoever writes it 44 bytes
121
+ of rent (about 0.00022 SOL), not refunded on leaving. A sharing farm of a token with a
78
122
  great many base units (a memecoin) that pays a reward of few units rounds each seat's share to nothing
79
123
  (`W-FARM-ROUNDING`). A farm with
80
124
  a fixed `rate` pays the same to each NFT instead; minted, it grows the token's supply every day it runs, which
@@ -83,7 +127,7 @@ Don'ts:
83
127
  (`W-FARM-MINT-ROOM`, for a rate that could get there).
84
128
  - **Levels written by staking are attributes on the NFT** (or in the project's Sheet of it, for an NFT the project
85
129
  has no authority over): marketplaces show them, anyone can read them, and the person's other mechanics can use
86
- them. They grow only when a seat is refreshed or the NFT leaves: the page refreshes (`app.refresh`).
130
+ them. They grow only when a seat is refreshed or the NFT leaves: the page refreshes (`app.refresh`). A boost that reads a level the farm's own growth writes counts each level from when it is written, so a seat refreshed often earns more than one refreshed rarely: have the page or a keeper refresh seats (anyone may, for free).
87
131
  - **Grants pay their claims' rent from their own funds** (`fund`, in SOL, held in the grant): the player pays the
88
132
  0.002 SOL player fee and the network fee to claim, once, even when the prize is a roll. A first claim of a token
89
133
  prize also opens the winner's account from the funds:
@@ -6,7 +6,7 @@ export { MPL_CORE_PROGRAM };
6
6
  * it also carries Bubblegum's plugin, so compressed NFTs can be minted into it. The collection address signs too (a
7
7
  * fresh key).
8
8
  */
9
- export declare function createCollectionInstruction({ collection, creator, name, uri, royaltyBps, project, compressed }: {
9
+ export declare function createCollectionInstruction({ collection, creator, name, uri, royaltyBps, project, compressed, }: {
10
10
  collection: any;
11
11
  compressed?: boolean | undefined;
12
12
  creator: any;
@@ -33,13 +33,15 @@ export declare function parseCoreAsset(data: any): {
33
33
  frozen: boolean;
34
34
  soulbound: boolean;
35
35
  };
36
- /** Decode the start of a Core CollectionV1: { updateAuthority, name, uri, numMinted, currentSize }. */
36
+ /** Decode the start of a Core CollectionV1: { updateAuthority, name, uri, numMinted, currentSize, bubblegum (whether it
37
+ * carries Bubblegum's plugin, BubblegumV2: compressed NFTs can be minted into it) }. */
37
38
  export declare function parseCoreCollection(data: any): {
38
39
  updateAuthority: string;
39
40
  name: string;
40
41
  uri: string;
41
42
  numMinted: number;
42
43
  currentSize: number;
44
+ bubblegum: boolean;
43
45
  };
44
46
  /** getProgramAccounts filters for Core assets owned by `owner` in `collection` (no indexer needed). */
45
47
  export declare const ownedAssetFilters: (owner: any, collection: any) => {
@@ -169,12 +169,14 @@ declare const pause: (ms: any) => Promise<any>;
169
169
  * first (`planTable`); else the table first, then each compressed NFT's prove_leaf alone, then the rest as v0 (or the
170
170
  * proofs then a legacy rest, when that fits with no table). The v0 transaction is compiled against the table as the
171
171
  * chain holds it. `sign(message)` → the signed wire transaction. `rpc`: the client's (latestBlockhash, send, confirm,
172
- * account, call('getSlot')). `table: false` sends no lookup table (a throwaway key holds no rent for one); `first`:
172
+ * account, call('getSlot')). `standing`: tables already made ([{ address, addresses }], a project's, active), tried
173
+ * first: one v0 transaction with them when they hold enough. `table: false` sends no lookup table of its own (a throwaway
174
+ * key holds no rent for one); `first`:
173
175
  * addresses a table holds first (`planTable`). Throws a
174
176
  * plain sentence when it can't be sent. Returns { signature (the last transaction's), table (its address, or null),
175
177
  * steps (the signatures of the transactions before it) }.
176
178
  */
177
- export declare function sendFitting({ rpc, payer, instructions, sign, table, alone, first, sleep }: {
179
+ export declare function sendFitting({ rpc, payer, instructions, sign, table, alone, first, standing, sleep, }: {
178
180
  alone?: (() => boolean) | undefined;
179
181
  first?: never[] | undefined;
180
182
  instructions: any;
@@ -182,6 +184,7 @@ export declare function sendFitting({ rpc, payer, instructions, sign, table, alo
182
184
  rpc: any;
183
185
  sign: any;
184
186
  sleep?: typeof pause | undefined;
187
+ standing?: never[] | undefined;
185
188
  table?: boolean | undefined;
186
189
  }): Promise<{
187
190
  signature: any;
@@ -18,7 +18,9 @@ export declare function notMainnet(url: any): any;
18
18
  * let through). `rpc` has `call`. Returns the genesis hash.
19
19
  */
20
20
  export declare function checkCluster(rpc: any): Promise<any>;
21
- /** The program's own words for a failed run (`AnchorError … Error Message: …`), else the last error log line. */
21
+ /** The program's own words for a failed run (`AnchorError … Error Message: …`), else the last error log line. A program
22
+ * built without its errors' text logs the error's name as its message: then the name alone (the client's IDL has
23
+ * the sentence: `loot.lootError`). */
22
24
  export declare function programError(err: any, logs: any): any;
23
25
  /** A client for one RPC URL. `fetchImpl` and `sleepImpl` are for tests. */
24
26
  export declare function rpcClient(url: any, { fetchImpl, sleepImpl }?: {
@@ -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,67 @@ 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
+ /**
90
+ * What a winning entry that put in `amount` takes with its first claim of a decided contest of tokens: its part of what
91
+ * the decision wrote (`pot_won`, the pot once the shares were taken; `prize_won`, a split prize's vault), by what it put
92
+ * in against its side's total. The winners claimed before it took `won × claimed ÷ total`, so the parts add up exactly
93
+ * whatever the order: `{ pot, prize }` (the prize part is 0 when the claim forgoes it). Tokens sent to the pot after the
94
+ * decision are nobody's.
95
+ */
96
+ export declare function contestWinnings(contest: any, amount: any): {
97
+ pot: bigint;
98
+ prize: bigint;
99
+ };
100
+ /** What a count allows `n` more of at `now` under `limit` ({ total, per_window, window }, 0 is no limit; a lottery's
101
+ * window is its round plus one, given as `window`). */
102
+ export declare function countAllows(count: any, limit: any, now: any, n?: number, window?: number): boolean;
50
103
  /**
51
104
  * A Sheet (`["sheet", project, nft]`): what the project wrote about an NFT it has no authority over. Returns { project, nft,
52
105
  * attributes: [{ key, value }] }. A Sheet never written reads as none: pass `null` data for no account.
@@ -59,11 +112,49 @@ export declare function decodeSheet(data: any): {
59
112
  value: string;
60
113
  }[];
61
114
  } | null;
62
- /** A stash (`["stash", project, id]`): { project, id, nfts }, the NFTs the project holds to give away, in no order. */
115
+ /** A player's profile (`["profile", project, wallet]`): { project, wallet, attributes }, what the project keeps about
116
+ * the wallet (its XP, level, rank). Its layout is a Sheet's, under its own tag. */
117
+ export declare function decodeProfile(data: any): {
118
+ project: string;
119
+ wallet: string;
120
+ attributes: {
121
+ key: string;
122
+ value: string;
123
+ }[];
124
+ } | null;
125
+ /** What a table's rows carry (its payload byte). */
126
+ export declare const PAYLOAD: Readonly<{
127
+ Number: 0;
128
+ Label: 1;
129
+ Nft: 2;
130
+ }>;
131
+ /** 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. */
132
+ export declare function tableRowAt(len: any, r: any): number;
133
+ /**
134
+ * A table (`["table", project, id]`, `table.rs`): { project, id, payload ('Number' | 'Label'), sealed, count, total
135
+ * (the weight in stock), rows: [{ weight, left, label }] }. A row's `left` is `NO_LIMIT` (4294967295) for a stock that
136
+ * never runs out.
137
+ */
138
+ export declare function decodeTable(data: any): {
139
+ project: string;
140
+ id: number;
141
+ payload: string;
142
+ sealed: boolean;
143
+ count: number;
144
+ total: bigint;
145
+ rows: {
146
+ weight: number;
147
+ left: number;
148
+ label: string;
149
+ }[];
150
+ } | null;
151
+ /** A stash (`["stash", project, id]`, or a lottery's own): { project, id, nfts, weights }, the NFTs the project holds to
152
+ * give away and the weight each is drawn by, as a table of NFTs keeps them (a row: its weight, then the NFT). */
63
153
  export declare function decodeStash(data: any): {
64
154
  project: string;
65
155
  id: number;
66
156
  nfts: string[];
157
+ weights: number[];
67
158
  } | null;
68
159
  /**
69
160
  * A compressed NFT's record (`["leaf", asset]`, `prove_leaf`): { asset, tree, owner (null once burned), delegate,
@@ -98,52 +189,121 @@ export declare function decodeTokenMetadata(data: any): {
98
189
  programmable: boolean;
99
190
  ruleSet: string | null;
100
191
  } | 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). */
192
+ export declare const OWN_PAID: bigint;
193
+ /** The mint a lottery's tickets are paid in (`terms`: a Lottery's or a round's): its ticket mint, burned, or `mint`. */
194
+ export declare const paymentMint: (terms: any) => any;
195
+ /** Whether a lottery's tickets are burned: they are paid in a ticket mint of its own. */
196
+ export declare const ticketsBurn: (terms: any) => boolean;
197
+ /** The most pots one lottery keeps (`MAX_POTS`): a pot's id is below it. */
198
+ export declare const MAX_POTS: number;
199
+ /** The pot a lottery's places are paid from (`terms.pays_from`: `{ Pot: [id] }`), or null when each round pays from its
200
+ * own ticket money (`{ Round: { rest } }`). */
201
+ export declare const potIdOf: (terms: any) => number | null;
202
+ /** Where what a round's places leave goes (`Part::Common` past the shares): its pot, or the `rest` a round paid from
203
+ * its own money names (`lotteryAddress`: the lottery's). */
204
+ export declare const leftoverTo: (lotteryAddress: any, terms: any) => any;
205
+ /** The ids of the pots a lottery opened (`Lottery::pots`, one bit an id), lowest first: a close empties each. */
206
+ export declare const lotteryPots: (lottery: any) => number[];
207
+ /** A share the buyer chooses (a referrer, a collectible's holder): paid out of the price as they buy, from their own account. */
208
+ export declare const chosenAtPurchase: (share: any) => boolean;
209
+ /** The bytes of one entry of a round: buyer, word, what arrived (`fee`: a fee mint, or a chosen share), the NFT ticket. */
210
+ export declare const entryWidth: (fee: any, nft: any) => number;
211
+ /**
212
+ * A lottery round (`["round", lottery, incarnation, round]`): its header (`status` 'Open' | 'Drawing' | 'Drawn' |
213
+ * 'Cancelled', the terms it copied, `sold`, `owed`, the draw and the money the ask fixed, `nfts` the NFT of the
214
+ * lottery's own stash each such place got), and `entries`, one a purchase: { buyer, start, end (its tickets), paid (its
215
+ * own part's bit), amount (what reached the round), nft (its NFT ticket) }.
216
+ */
217
+ export declare function decodeRound(data: any): any;
218
+ /** How many places a lottery's (or a round's) `places` are, every run counted (`Place.times`). */
219
+ export declare const placeCount: (places: any) => any;
220
+ /** The places of a round that have a winner: every place, but no more than tickets. */
221
+ export declare const roundWinners: (r: any) => number;
222
+ /** The ticket that wins `place` of a drawn round: even steps around the list from first place's ticket. */
223
+ export declare function ticketOfPlace(r: any, place: any): bigint;
224
+ /** The run of places that holds `place`, and its first place. */
225
+ export declare function runOf(r: any, place: any): any[];
226
+ /** The places of run `run` with a winner: [first, end). */
227
+ export declare function runPlaces(r: any, run: any): number[];
228
+ /** The places of run `run` whose ticket is in `start..end` (an entry's), in order. */
229
+ export declare function placesIn(r: any, run: any, start: any, end: any): any[];
230
+ /**
231
+ * What place `place` (counted from the first place of `runs`) takes of a pass-through amount, as the program splits it:
232
+ * runs of `[a, n]` (n places taking `a` each), `sent` what the places are owed and `arrived` what the round holds for
233
+ * them; the last place with a part takes what the others leave.
234
+ */
235
+ export declare function splitPart(runs: any, sent: any, arrived: any, place: any): number | bigint;
236
+ /** Whether place `place`'s part is paid: its pot part's bit (every place's first), or with `prize` its prize's (after
237
+ * every place's pot bit). */
238
+ export declare const placePaid: (r: any, place: any, prize: any) => boolean;
239
+ /** What entry `i`'s places in run `run` take and are not paid yet, of its pot part or (`prize`) its token prize. */
240
+ export declare const placesOwed: (r: any, i: any, run: any, prize: any) => bigint;
241
+ /** How many of the round's owed parts a pull of `{ Pot: [run] }` or a token `{ Prize: [run] }` for entry `i` settles:
242
+ * its places there that take more than nothing (one pull pays them all). */
243
+ export declare const placesPulled: (r: any, i: any, run: any, prize: any) => number;
244
+ /** Whether run `run` of a round's places gives tokens (its prize is fixed at the ask, a `TokenPrize`). */
245
+ export declare const tokenRun: (r: any, run: any) => boolean;
246
+ /** A place whose prize is an NFT of the lottery's own stash (`Held`, `Raffled`): assigned by the pulls, in place order. */
247
+ export declare const ownStash: (place: any) => boolean;
248
+ /** Entry `i`'s places in run `run` whose prize (not tokens) is not given yet, lowest first. */
249
+ export declare const prizePlacesOwed: (r: any, i: any, run: any) => any[];
250
+ /** 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). */
251
+ export declare function nftSlot(r: any, place: any): number;
252
+ /** How many places of a round win an NFT of the lottery's own stash (every such place with a winner). */
253
+ export declare function stashPlacesWon(r: any): number;
254
+ /** Whether entry `i`'s places in run `run` (an NFT of the lottery's own stash) wait for their NFTs to be taken out
255
+ * (`LotteryRound::assign`): a pull with the stash alone does it, and `r.nfts` then names each. */
256
+ export declare function awaitsNfts(r: any, i: any, run: any): boolean;
257
+ /**
258
+ * The parts entry `i` of a round is owed now, in the order a keeper pulls them (`pullIx`'s `part`): its own ('Own': a
259
+ * refund, a no-loss ticket's price, its NFT ticket back or where its price sends it), and with `places`, its places'
260
+ * parts of the pot ({ Pot: [run] }) and prizes ({ Prize: [run] }). Parts owed in common (a share, the pot's, a pool's
261
+ * prize back) are no entry's: `commonOwed`.
262
+ */
263
+ export declare function partsOwed(r: any, i: any, { places }?: {
264
+ places?: boolean | undefined;
265
+ }): (string | {
266
+ Pot: number[];
267
+ Prize?: undefined;
268
+ } | {
269
+ Pot?: undefined;
270
+ Prize: number[];
271
+ })[];
272
+ /**
273
+ * The parts of a round owed in common, of no entry (`{ Common: [i] }`): each share paid in common once drawn (one that
274
+ * burns is burned at the close), then what its places leave, owed to its pot or to `rest` (`i` = the shares' count), then after a
275
+ * cancel each pool's token prize back to its pool (past it).
276
+ */
277
+ export declare function commonOwed(r: any): {
278
+ Common: any[];
279
+ }[];
280
+ /** The entry of a round holding `ticket`. */
281
+ export declare const entryOf: (r: any, ticket: any) => any;
282
+ /** Whether a round is done and owes nothing: the next pull closes it, given its close's accounts. */
283
+ export declare const roundFinished: (r: any) => boolean;
284
+ /** Whether a lottery's place wins something: a part of what the round pays from, a prize, or both. */
114
285
  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;
129
- /**
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.
136
- */
137
- export declare function lotteryStep(lottery: any, contribution: any): "finish" | "pay" | "prizes" | "refund" | null;
286
+ /** The address of a lottery's current round's record (there or not). */
287
+ export declare const roundAddress: (lotteryAddress: any, lottery: any) => any;
288
+ /** Whether a lottery (decoded) drew once and has ended. */
289
+ export declare const lotteryEnded: (lottery: any) => boolean;
290
+ /** The round a lottery's close, its write again and its own stash's moves name (`lottery::check_idle`): its current
291
+ * round's, or once a lottery that draws once has ended, round 0's (which keeps its stash's NFTs until its places took
292
+ * them out). */
293
+ export declare const idleRound: (lotteryAddress: any, lottery: any) => any;
138
294
  /**
139
295
  * Who rents a listed NFT at `now` (Unix seconds), from its decoded Listing (or null for none): the renter's wallet while
140
296
  * a rental runs, else null (a sale listing, or a rental that is over).
141
297
  */
142
298
  export declare function renterOf(listing: any, now: any): any;
299
+ /** Whether a schedule pays every run due when it is sent late (`schedule::catches_up`): only a sealed fixed amount. */
300
+ export declare const scheduleCatchesUp: (schedule: any) => boolean;
143
301
  /**
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.
302
+ * How many runs of a schedule are due at `now` (Unix seconds, the chain's clock, never the computer's). One `run_schedule`
303
+ * makes them all. A sealed schedule's fixed amount pays each of them (`scheduleCatchesUp`; up to its `upto`, the runs made
304
+ * after it: `schedule.runs` plus these, and a long backlog takes a few calls). Any other run pays once, for the latest
305
+ * run due, and those before it lapse. A sealed schedule past its last run is due once whenever its vault holds something
306
+ * (`vaultBalance`), which goes where it always went.
147
307
  */
148
308
  export declare function runsDue(schedule: any, now: any, vaultBalance?: bigint): number;
149
309
  /**
@@ -166,7 +326,8 @@ export declare const ERRORS: Readonly<{
166
326
  }>;
167
327
  /**
168
328
  * 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
329
+ * null: { code, name, msg }, `msg` the IDL's sentence (the program's own log names the error only: its text is
330
+ * compiled out). Only loot's own: another program the transaction calls (Bubblegum, the VRF program, …) has codes of its own
170
331
  * 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
332
  * The first program that fails is where the error came from; the programs that called it fail after it with the same
172
333
  * code.