@xgamesfun/solana 0.0.0-stage → 0.20.1

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 (134) hide show
  1. package/DISCLAIMER.md +41 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +13 -0
  4. package/README.md +172 -2
  5. package/bin/xsolana.mjs +189 -0
  6. package/examples/artwork-auction.json +51 -0
  7. package/examples/blind-forge.json +128 -0
  8. package/examples/coin-flip-arena.json +108 -0
  9. package/examples/duel-arena.json +137 -0
  10. package/examples/elements-set.json +281 -0
  11. package/examples/event-badges.json +67 -0
  12. package/examples/expedition-guild.json +161 -0
  13. package/examples/fair-presale.json +48 -0
  14. package/examples/falling-drop.json +90 -0
  15. package/examples/guild-missions.json +144 -0
  16. package/examples/halving-seasons.json +112 -0
  17. package/examples/hero-trials.json +96 -0
  18. package/examples/ideas.json +789 -0
  19. package/examples/level-ladder.json +65 -0
  20. package/examples/merge-2048.json +128 -0
  21. package/examples/nft-raffle.json +33 -0
  22. package/examples/paper-hands-farm.json +56 -0
  23. package/examples/partner-vault.json +115 -0
  24. package/examples/sacrifice-raffle.json +118 -0
  25. package/examples/scorched-treasury.json +84 -0
  26. package/examples/shelter-fair.json +164 -0
  27. package/examples/spark-pity.json +153 -0
  28. package/examples/stakers-draw.json +125 -0
  29. package/examples/star-fleet.json +157 -0
  30. package/examples/starforce.json +116 -0
  31. package/examples/stud-farm.json +134 -0
  32. package/examples/team-vesting.json +70 -0
  33. package/examples/trade-in-shop.json +168 -0
  34. package/js/approve/details.mjs +262 -0
  35. package/js/approve/ed25519.mjs +36 -0
  36. package/js/approve/live-check.mjs +144 -0
  37. package/js/approve/page.html +86 -0
  38. package/js/approve/page.js +203 -0
  39. package/js/approve/server.mjs +711 -0
  40. package/js/chain/base58.js +73 -0
  41. package/js/chain/borsh.js +261 -0
  42. package/js/chain/bytes.js +141 -0
  43. package/js/chain/core.js +169 -0
  44. package/js/chain/curve.js +52 -0
  45. package/js/chain/lookup.js +273 -0
  46. package/js/chain/mint.js +96 -0
  47. package/js/chain/pda.js +66 -0
  48. package/js/chain/programs.js +102 -0
  49. package/js/chain/rpc.js +217 -0
  50. package/js/chain/sha256.js +68 -0
  51. package/js/chain/token.js +85 -0
  52. package/js/chain/token2022.js +247 -0
  53. package/js/chain/tx.js +224 -0
  54. package/js/client/accounts.js +347 -0
  55. package/js/client/compressed.js +46 -0
  56. package/js/client/grant.js +240 -0
  57. package/js/client/idl/loot.js +2 -0
  58. package/js/client/idl/loot.json +17064 -0
  59. package/js/client/index.js +9 -0
  60. package/js/client/ix.js +2156 -0
  61. package/js/client/pda.js +110 -0
  62. package/js/client/policy.js +48 -0
  63. package/js/client/sizes.js +54 -0
  64. package/js/client/traits.js +44 -0
  65. package/js/connect/connect.mjs +182 -0
  66. package/js/economy/check.mjs +1991 -0
  67. package/js/economy/cost.mjs +170 -0
  68. package/js/economy/examples.mjs +114 -0
  69. package/js/economy/explain.mjs +235 -0
  70. package/js/economy/guide.mjs +231 -0
  71. package/js/economy/legal.mjs +15 -0
  72. package/js/economy/live.mjs +107 -0
  73. package/js/economy/model.mjs +583 -0
  74. package/js/economy/plan.mjs +887 -0
  75. package/js/economy/schema.json +2923 -0
  76. package/js/economy/secrets.mjs +60 -0
  77. package/js/economy/simulate.mjs +952 -0
  78. package/js/economy/txsize.mjs +45 -0
  79. package/js/economy/validate.mjs +85 -0
  80. package/js/index.js +10 -0
  81. package/js/mcp/server.mjs +113 -0
  82. package/js/mcp/tools.mjs +479 -0
  83. package/js/play/index.js +2109 -0
  84. package/js/results/index.js +184 -0
  85. package/js/results/wire.js +90 -0
  86. package/package.json +100 -4
  87. package/release.json +8 -0
  88. package/skills/xsolana-economy/SKILL.md +105 -0
  89. package/skills/xsolana-economy/references/after-launch.md +114 -0
  90. package/skills/xsolana-economy/references/apps.md +157 -0
  91. package/skills/xsolana-economy/references/sentence-to-spec.md +172 -0
  92. package/skills/xsolana-economy/references/telling-the-person.md +93 -0
  93. package/types/chain/base58.d.ts +10 -0
  94. package/types/chain/borsh.d.ts +23 -0
  95. package/types/chain/bytes.d.ts +45 -0
  96. package/types/chain/core.d.ts +50 -0
  97. package/types/chain/curve.d.ts +1 -0
  98. package/types/chain/lookup.d.ts +191 -0
  99. package/types/chain/mint.d.ts +25 -0
  100. package/types/chain/pda.d.ts +25 -0
  101. package/types/chain/programs.d.ts +65 -0
  102. package/types/chain/rpc.d.ts +66 -0
  103. package/types/chain/sha256.d.ts +1 -0
  104. package/types/chain/token.d.ts +141 -0
  105. package/types/chain/token2022.d.ts +53 -0
  106. package/types/chain/tx.d.ts +60 -0
  107. package/types/client/accounts.d.ts +178 -0
  108. package/types/client/compressed.d.ts +29 -0
  109. package/types/client/grant.d.ts +125 -0
  110. package/types/client/idl/loot.d.ts +4467 -0
  111. package/types/client/index.d.ts +8 -0
  112. package/types/client/ix.d.ts +1687 -0
  113. package/types/client/pda.d.ts +91 -0
  114. package/types/client/policy.d.ts +23 -0
  115. package/types/client/sizes.d.ts +13 -0
  116. package/types/client/traits.d.ts +12 -0
  117. package/types/economy/check.d.mts +105 -0
  118. package/types/economy/cost.d.mts +68 -0
  119. package/types/economy/examples.d.mts +27 -0
  120. package/types/economy/explain.d.mts +19 -0
  121. package/types/economy/guide.d.mts +140 -0
  122. package/types/economy/legal.d.mts +12 -0
  123. package/types/economy/live.d.mts +109 -0
  124. package/types/economy/model.d.mts +363 -0
  125. package/types/economy/plan.d.mts +1013 -0
  126. package/types/economy/secrets.d.mts +4 -0
  127. package/types/economy/simulate.d.mts +156 -0
  128. package/types/economy/txsize.d.mts +17 -0
  129. package/types/economy/validate.d.mts +3 -0
  130. package/types/index.d.ts +9 -0
  131. package/types/mcp/tools.d.mts +627 -0
  132. package/types/play/index.d.ts +469 -0
  133. package/types/results/index.d.ts +155 -0
  134. package/types/results/wire.d.ts +122 -0
@@ -0,0 +1,469 @@
1
+ /** A signer from a Wallet Standard wallet and one of its accounts: the wallet signs, the app sends. */
2
+ export declare function walletStandardSigner(wallet: any, account: any, chain?: string): {
3
+ address: any;
4
+ signTransaction(wire: any): Promise<any>;
5
+ };
6
+ /**
7
+ * An amount in whole units of a token ("12", "0.5", or a number) in its base units. Only a plain decimal is taken, with
8
+ * at most the token's decimals: "0x10", "1.2.3", "", "1e3", "-1" and an extra decimal place are refused, never read as
9
+ * some other amount.
10
+ */
11
+ export declare const units: (amount: any, decimals: any) => bigint;
12
+ /**
13
+ * The player's side of a live economy. `rpc` may be given instead of `rpcUrl` (any object with the client's rpc
14
+ * methods: accounts, account, latestBlockhash, send, confirm, programAccounts, and call(method, params), the raw JSON
15
+ * RPC request the devnet check, the slot and the compressed-NFT reads go through). `now` is the clock auctions are read
16
+ * by (Unix seconds). Devnet only (`devnetOnly`): mainnet waits for an audit.
17
+ */
18
+ export declare function solanaApp({ spec, rpcUrl, rpc, wallet, programs, now }: {
19
+ now?: (() => number) | undefined;
20
+ programs?: {} | undefined;
21
+ rpc?: null | undefined;
22
+ rpcUrl?: string | undefined;
23
+ spec: any;
24
+ wallet: any;
25
+ }): {
26
+ project: any;
27
+ readonly address: any;
28
+ /** The shop: every item with a price (or free), its price now and what is left. */
29
+ shop(): Promise<any>;
30
+ /** The boxes: price now and each outcome's chance. */
31
+ boxes(): Promise<any>;
32
+ /**
33
+ * Buys a shop item, in one transaction (`buy`: the price split and the item given at once). A listing that rolls
34
+ * (an NFT at random, or one it rolls on) is opened and settled instead. Returns { signature, assets, asset } for a
35
+ * purchase, or what `collect` returns for an open.
36
+ */
37
+ buy(itemKey: any, options?: {}): Promise<{
38
+ order: any;
39
+ settled: string;
40
+ says: string;
41
+ } | {
42
+ order: any;
43
+ settled: null;
44
+ says: string;
45
+ } | {
46
+ says?: undefined;
47
+ order: any;
48
+ won: any;
49
+ assets: any;
50
+ settled: any;
51
+ asset?: any;
52
+ } | {
53
+ signature: any;
54
+ assets: any;
55
+ asset?: any;
56
+ }>;
57
+ /**
58
+ * Opens a box (shows a collectible for its gate or odds when given): a box that needs no roll is bought at once
59
+ * (`buy`); one that rolls waits for the roll and collects it.
60
+ */
61
+ openBox(boxKey: any, options?: {}): Promise<{
62
+ order: any;
63
+ settled: string;
64
+ says: string;
65
+ } | {
66
+ order: any;
67
+ settled: null;
68
+ says: string;
69
+ } | {
70
+ says?: undefined;
71
+ order: any;
72
+ won: any;
73
+ assets: any;
74
+ settled: any;
75
+ asset?: any;
76
+ } | {
77
+ signature: any;
78
+ assets: any;
79
+ asset?: any;
80
+ }>;
81
+ /** Collects an order opened earlier (its roll arrived after the app stopped waiting). */
82
+ collect: (orderAddress: any, options?: {}) => Promise<{
83
+ order: any;
84
+ settled: string;
85
+ says: string;
86
+ } | {
87
+ order: any;
88
+ settled: null;
89
+ says: string;
90
+ } | {
91
+ says?: undefined;
92
+ order: any;
93
+ won: any;
94
+ assets: any;
95
+ settled: any;
96
+ asset?: any;
97
+ }>;
98
+ /** Gives an order's payment back once its time has come (a roll that failed or never came). */
99
+ refund(orderAddress: any): Promise<any>;
100
+ /** Asks the oracle for a roll a mission, a recipe or a prize made (anyone may; the asker pays the oracle). */
101
+ askRoll: (orderAddress: any) => Promise<any>;
102
+ /**
103
+ * Pays a payment of the economy (an entry, an attempt, a tip). `amount`: what the player chose, in whole units, for
104
+ * a payment with `any` (at least its `amount`). `chosenRecipient`: the wallet the player names for a share the
105
+ * payment lets them choose (a referrer), never their own. `holders`: asset → holder, for a holder's share (read
106
+ * now when not given).
107
+ */
108
+ pay(paymentKey: any, { amount: chosen, holders, chosenRecipient, ...others }?: Readonly<Record<string, any>>): Promise<any>;
109
+ /**
110
+ * Pays with one of the player's NFTs, any kind (`pay_nft`): burned (`to` null), or given to the wallet `to` (the
111
+ * treasury, a partner), straight from the player. The receipt (`PaidNft`) is the record an app admits the player
112
+ * by, with `reference` (32 bytes, or text the client hashes). Returns the signature.
113
+ */
114
+ payNft(asset: any, { to, reference, ...others }?: Readonly<Record<string, any>>): Promise<any>;
115
+ /**
116
+ * The lotteries: each one's ticket price now, its round and status, and its terms (`incarnation`, `revision`),
117
+ * which `buyTickets` takes as the terms the player was shown. A lottery not written yet (a raffle still to open)
118
+ * has a null price.
119
+ */
120
+ lotteries(): Promise<any>;
121
+ /**
122
+ * Buys `count` tickets of a lottery, on the terms the player was shown: `listing`, the lottery as `lotteries()`
123
+ * showed it (a lottery changed since, its price or anything else, is refused rather than paid), or `maxPrice`, the
124
+ * most a ticket may cost, in base units. One of them is required: the price read now is never the bound.
125
+ * `chosenRecipient`: the wallet (or collectible) the player names for a share the lottery lets them choose (a
126
+ * referrer). A lottery whose ticket costs an NFT (`nft_ticket`) sells one ticket for one of the player's NFTs that
127
+ * passes its rule: `nft`, its address (held by the project until the draw, then burned, given on or stashed; back to
128
+ * the player if the round is cancelled). `listProof`: for a list gate.
129
+ */
130
+ buyTickets(lotteryKey: any, count?: number, { shown, chosenRecipient, listProof, nft: paidWith, listing, maxPrice, ...others }?: Readonly<Record<string, any>>): Promise<any>;
131
+ /**
132
+ * Writes an NFT's traits from the project's traits tree (`traits` in the spec) into its Sheet, where rules read them:
133
+ * anyone may, paying the Sheet's rent. `attributes` ([{ key, value }]) and `proof` come from the project's tree
134
+ * (`loot.traitsTree`); `key` names the tree (a collection's address), the spec's first when left out. Traits the
135
+ * Sheet already has are left as they are.
136
+ */
137
+ proveTraits(nft: any, attributes: any, proof: any, key?: any): Promise<any>;
138
+ /**
139
+ * Stakes `amount` (whole units) of a farm's token at lock tier `tier`. A farm with an end takes no stake at its end
140
+ * or after it, nor one whose lock would run past it: refused here, before the wallet signs.
141
+ */
142
+ stake(farmKey: any, amount: any, tier?: number, { shown, extra, transfers, ...others }?: Readonly<Record<string, any>>): Promise<any>;
143
+ /**
144
+ * Takes `amount` out once its lock has run (0: only rewards); `forfeit` gives up rewards that cannot move. Before the
145
+ * lock, a tier with an early exit lets it leave for its fee, and gives up what the seat is owed; in a farm that
146
+ * unbonds, what is taken out waits first (`withdraw` takes it out once free).
147
+ */
148
+ unstake(farmKey: any, amount?: number, { forfeit, extra, transfers, ...others }?: Readonly<Record<string, any>>): Promise<any>;
149
+ /**
150
+ * Stakes one of the player's NFTs in a farm (its own seat, or as the booster of their token seat), of any kind: a
151
+ * Core asset, a Token Metadata NFT's mint (legacy or pNFT), or a compressed NFT's asset id. In a farm that watches,
152
+ * an NFT whose last staker sold it takes their seat over. A farm with an end takes none at its end or after it.
153
+ */
154
+ stakeNft(farmKey: any, asset: any, tier?: number, { extra, transfers, ...others }?: Readonly<Record<string, any>>): Promise<any>;
155
+ /**
156
+ * Releases the collectible after its lock: it grows on its way out (a farm with `growth`), and from its own seat
157
+ * takes its tier's prize (a mission: `prize.rs`). `forfeit` gives up rewards, and the prize, that cannot move.
158
+ * Returns the signature, or { signature, roll } when it makes a roll (a mission's result on the NFT, or a chest),
159
+ * which `collect` then finishes.
160
+ */
161
+ unstakeNft(farmKey: any, asset: any, { forfeit, extra, transfers, ...others }?: Readonly<Record<string, any>>): Promise<any>;
162
+ /**
163
+ * Writes what a staked collectible has grown (a farm with `growth`: its points and level, on it or in its Sheet)
164
+ * and reads its boosts again. Anyone may send it; the player pays for what the write adds. `by`: the collectible,
165
+ * or the player for their token seat's booster.
166
+ */
167
+ refresh(farmKey: any, by: any, { extra, transfers, ...others }?: Readonly<Record<string, any>>): Promise<any>;
168
+ /**
169
+ * Collects what a seat owes (the player's own, or one of their collectibles' seats). In a farm that watches, it
170
+ * shows the seat's NFT is still theirs: the Core asset, or their token account of a Token Metadata NFT.
171
+ */
172
+ harvest(farmKey: any, by?: any, { compound, extra, transfers, ...others }?: Readonly<Record<string, any>>): Promise<any>;
173
+ /**
174
+ * Adds what a token seat is owed to its stake, without restarting its lock (a farm of tokens whose rewards are the
175
+ * staked token). The farm's toll, if any, is taken first.
176
+ */
177
+ compound(farmKey: any, opts?: {}): Promise<any>;
178
+ /** Takes out the tokens whose unbonding wait is over (a farm with `unbond`), and what the seat is owed. */
179
+ withdraw(farmKey: any, opts?: {}): Promise<any>;
180
+ /**
181
+ * The player's seats in a farm (the wallet's, or `player`'s): each one's NFT (`asset`, null for a token seat with
182
+ * no booster), what it holds staked (`amount`, in whole units of the staked token, a number for display that can
183
+ * round past 2^53 base units; `amountUnits`, in base units exactly, a bigint; 1 for an NFT), its tier, when it
184
+ * came in (`since`) and when its lock is over (`freeAt`, unix seconds; null when the NFT says it, `lockKey`), its
185
+ * boost in percent, and what it is owed now: `waiting` (whole units of the rewards, `rewards` their token) and
186
+ * `owedUnits` (base units). What it is owed is the program's own sum, from a refresh of the seat dry-run on the
187
+ * network (nothing is signed or sent): what the farm released or its rate paid since its last move is in it, by the
188
+ * farm's rounding. When the dry run fails, it is what the seat was last credited, and `counted` is false.
189
+ * One search of the chain, and one dry run per seat: read it when the page opens and after a stake or a harvest.
190
+ */
191
+ staked(farmKey: any, player?: any): Promise<{
192
+ asset: any;
193
+ amount: number;
194
+ amountUnits: bigint;
195
+ tier: any;
196
+ since: number;
197
+ freeAt: number | null;
198
+ lockKey?: any;
199
+ boostPercent: number;
200
+ rewards: any;
201
+ waiting: string;
202
+ owedUnits: bigint;
203
+ counted: boolean;
204
+ }[]>;
205
+ /** The recipes: whether each is on, and its version now (what `craft` takes as the terms the player was shown). */
206
+ recipes(): Promise<any>;
207
+ /**
208
+ * Crafts a recipe, handing in `assets` (the collectibles it burns or uses, in the recipe's order). `version`: the
209
+ * recipe's version the page showed the player (`recipes()`, or the listing itself as `listing`), so a recipe the
210
+ * owner changed since is refused rather than crafted on terms the player never saw. It is required: the version
211
+ * read now is never signed in its place.
212
+ */
213
+ craft(recipeKey: any, assets?: any[], times?: number, { version, listing, ...others }?: Readonly<Record<string, any>>): Promise<{
214
+ signature: any;
215
+ made: any;
216
+ roll?: any;
217
+ }>;
218
+ /**
219
+ * Hands an NFT of any kind to the project until a time (a hold): `seconds` from now, or `{ until }` (Unix seconds).
220
+ * The hold's address names its end. Returns { signature, freeAt }.
221
+ */
222
+ hold(asset: any, seconds: any): Promise<{
223
+ signature: any;
224
+ freeAt: bigint;
225
+ }>;
226
+ /**
227
+ * A lender's offer to borrow against: `maker`'s offer number `id` in this project. Returns { address, offer, mint,
228
+ * amount, repay, lasts, risks }: `risks`, in words, each power over the loan's token that could make repaying fail
229
+ * (its freeze authority, a Token-2022 pause, a transfer hook, a permanent delegate) and who holds it. The program
230
+ * takes such tokens, and a lender who holds one can stop every repayment and take the NFT once it is due: show the
231
+ * risks before the player borrows.
232
+ */
233
+ loanOffer(maker: any, id: any): Promise<{
234
+ address: any;
235
+ offer: any;
236
+ mint: any;
237
+ program: any;
238
+ amount: any;
239
+ repay: any;
240
+ lasts: any;
241
+ risks: any[];
242
+ }>;
243
+ /**
244
+ * Borrows against the player's NFT `asset` from `maker`'s offer `id`: the NFT is held until the loan is repaid, or
245
+ * goes to the lender once it is due (`due`, Unix seconds; by default the longest the offer allows, less a minute).
246
+ * A loan whose token someone could freeze, pause, hook or move (`loanOffer`'s `risks`) is refused unless
247
+ * `acceptRisks` is true: the page shows the player who holds that power first. `extra`: a transfer hook's accounts.
248
+ */
249
+ borrow(maker: any, id: any, asset: any, { due, acceptRisks, extra, ...others }?: Readonly<Record<string, any>>): Promise<{
250
+ signature: any;
251
+ due: any;
252
+ hold: any;
253
+ }>;
254
+ /**
255
+ * Backs `side` of contest number `id` (the authority opens contests while the project runs) with `amount`; a contest
256
+ * of NFTs takes one of the player's NFTs that passes its rule instead (`nft`, its address), held until it is
257
+ * claimed. `listProof`: for a list gate.
258
+ */
259
+ enter(id: any, side: any, amount: any, { shown, listProof, nft: staked, ...others }?: Readonly<Record<string, any>>): Promise<any>;
260
+ /**
261
+ * The auctions: each one's lot, high bid, the least the next bid must be, when it ends and how long is left, and
262
+ * whether the player leads. One no longer on chain has ended. `waiting`: SOL that came back to the player's
263
+ * wrapped-SOL account from a bid that was topped (`unwrap` turns it into plain SOL).
264
+ */
265
+ auctions(): Promise<any>;
266
+ /**
267
+ * Bids `amount` (whole units) on an auction. The bid it tops goes back to its bidder in the same transaction
268
+ * (the program opens their account again if they closed it, paid by this bidder). In SOL, only what the player's
269
+ * wrapped-SOL account does not hold already is wrapped, and the account stays open: if this bid is topped, it comes
270
+ * back there.
271
+ */
272
+ bid(auctionKey: any, amount: any, { shown, listProof, nfts, ...others }?: Readonly<Record<string, any>>): Promise<any>;
273
+ /**
274
+ * Ends an auction that is over (anyone can; the winner usually does): the lot to the highest bidder, a new
275
+ * collectible minted for them at the address its item and serial name, however long after the end it is sent. A
276
+ * roll lot makes the winner's roll of its box (`order`), which `collect` asks for and settles.
277
+ */
278
+ endAuction(auctionKey: any, { holders, ...others }?: Readonly<Record<string, any>>): Promise<{
279
+ signature: any;
280
+ winner?: any;
281
+ asset?: any;
282
+ order?: any;
283
+ }>;
284
+ /**
285
+ * Runs a schedule that is due (an emission into a pool, a rent or a drip): anyone may, and nothing is paid to
286
+ * whoever sends it but the network fee. `holders`: asset → holder, for a schedule that pays a collectible's holder.
287
+ * Returns null when it isn't due yet.
288
+ */
289
+ runSchedule(scheduleKey: any, { holders, most, ...others }?: Readonly<Record<string, any>>): Promise<any>;
290
+ /**
291
+ * Lists one of the player's NFTs (any kind) for sale at `price` (whole units of `currency`, the economy's by
292
+ * default), `shares` taken first (a royalty, a platform's cut). The project holds it until it sells or is unlisted.
293
+ */
294
+ listForSale(asset: any, { price, currency, shares, ...others }?: Readonly<Record<string, any>>): Promise<any>;
295
+ /**
296
+ * Lists one of the player's NFTs for rent: `price` (whole units) a period of `lasts` seconds, a renter taking 1 to
297
+ * `maxPeriods` at once. Nobody can end a rental early; the next renter takes it once one is over, until it is unlisted.
298
+ */
299
+ listForRent(asset: any, { price, lasts, maxPeriods, currency, shares, ...others }?: Readonly<Record<string, any>>): Promise<any>;
300
+ /** The listing of `asset` (one account read), or null: { listing, asset, maker, mint, deal, renter, until }. */
301
+ listing(asset: any): Promise<any>;
302
+ /** Who rents `asset` now (one account read, then a check that the project still holds it), or null. */
303
+ rentedTo(asset: any): Promise<any>;
304
+ /** The project's listings, a maker's (`maker`) or all: one search of the program's accounts. */
305
+ listings({ maker, ...others }?: Readonly<Record<string, any>>): Promise<any>;
306
+ /**
307
+ * Buys a listed NFT at the terms the player saw: `listing`, as `listing()` or `listings()` showed it. It is
308
+ * required: the terms signed are those, never the listing read now, so a price or a share changed since is refused.
309
+ */
310
+ buyListing(asset: any, { listing, ...others }?: Readonly<Record<string, any>>): Promise<any>;
311
+ /**
312
+ * Rents a listed NFT for `periods` periods, at the terms the player saw: `listing`, as `listing()` or `listings()`
313
+ * showed it (required, as for `buyListing`).
314
+ */
315
+ rentListing(asset: any, { periods, listing, ...others }?: Readonly<Record<string, any>>): Promise<any>;
316
+ /** Takes a listed NFT home (its maker). While a rental runs it only stops the listing; call again once it is over. */
317
+ unlist(asset: any): Promise<any>;
318
+ /**
319
+ * The project's owner raffles an NFT they hold, as lottery `id`: the NFT goes into the lottery's own stash, where
320
+ * nothing but the lottery can take it while a place names it; the winner gets it before any ticket money moves.
321
+ * `price` (whole units of `currency`) a ticket, `drawsAt` (Unix seconds) its one draw, `minSold` the least tickets
322
+ * (fewer: the round is cancelled and refunded), `shares` where the ticket money goes (the seller's own wallet by
323
+ * default: the treasury). A seller runs it in a project of their own, whose owner they are.
324
+ */
325
+ raffle(id: any, nft: any, { price, currency, drawsAt, minSold, perWallet, shares, ...others }?: Readonly<Record<string, any>>): Promise<any>;
326
+ /** The raffle's owner takes the NFT back out of lottery `id`'s own stash once nothing promises it (the lottery ended, or no place names it). */
327
+ unraffle(id: any, nft: any): Promise<any>;
328
+ /** Turns what waits in the player's wrapped-SOL account (a bid that was topped) into plain SOL. */
329
+ unwrap(): Promise<any>;
330
+ /**
331
+ * Claims a grant for the connected wallet: from the approved list (the proof comes from xsolana.json, or is given:
332
+ * `proof`, `personHash` and the `round` the list pays, as a results server's list answers them), or with a voucher
333
+ * a server signed ({ publicKey, signature, incarnation, round, expires, personHash, amount }). A list in xsolana.json names
334
+ * no round (zeros). `amount` (a voucher's, or `options.amount` for a list's leaf): the tokens this claim gives, in
335
+ * base units, up to the grant's own, for a grant of a fixed amount of tokens (a reward by rank); absent or 0 gives
336
+ * the grant's prize as it is. A grant that gives a roll of a box makes the wallet's roll, which `claims()` then
337
+ * lists and `collect` asks for and settles.
338
+ */
339
+ claimGrant(grantKey: any, options?: {}): Promise<any>;
340
+ /**
341
+ * Takes every prize a results server vouched for this wallet's wins, or put on a list (`server`: its URL;
342
+ * a results server), page by page. Each pays only this wallet, within the grant's limits. Returns [{ round, grant,
343
+ * signature }] for each claim made, and [{ round, grant, error }] for one that failed, without stopping the rest;
344
+ * wins already claimed are skipped (the program pays a wallet each round once per grant incarnation).
345
+ *
346
+ * `token`: the player's play-host sign-in for this game. A drop that gives NFTs from a stash gives one only at a
347
+ * signed-in claim, first come first served (the server answers `R-SIGN-IN` to a voucher request with no sign-in, so
348
+ * a stranger can't hand them out): with the token such a win is claimed through `POST /v1/claims`; without it, it is
349
+ * [{ round, grant, error }].
350
+ */
351
+ claimWins({ server, token, fetchImpl, ...others }?: Readonly<Record<string, any>>): Promise<{
352
+ round: any;
353
+ grant: any;
354
+ error: any;
355
+ }[]>;
356
+ /**
357
+ * What this player can finish now, themselves: a box to settle or refund, a contest entry to claim, a held
358
+ * collectible to take home, an auction they won (or one off by the clock: their bid back), a lottery place they
359
+ * won, a draw that is due (anyone may reveal it, or ask again when the oracle never answered; it takes 0.0005
360
+ * SOL), and a drawn lottery's unpaid places, which anyone may pay so the next round can open. [{ kind, says, … }];
361
+ * pass one to `claim`.
362
+ */
363
+ claims(): Promise<({
364
+ key?: undefined;
365
+ kind: string;
366
+ order: any;
367
+ says: string;
368
+ entry?: undefined;
369
+ id?: undefined;
370
+ side?: undefined;
371
+ hold?: undefined;
372
+ contribution?: undefined;
373
+ asset?: undefined;
374
+ table?: undefined;
375
+ } | {
376
+ key?: undefined;
377
+ order?: undefined;
378
+ kind: string;
379
+ entry: any;
380
+ id: any;
381
+ side: any;
382
+ says: string;
383
+ hold?: undefined;
384
+ contribution?: undefined;
385
+ asset?: undefined;
386
+ table?: undefined;
387
+ } | {
388
+ key?: undefined;
389
+ order?: undefined;
390
+ entry?: undefined;
391
+ id?: undefined;
392
+ side?: undefined;
393
+ kind: string;
394
+ asset: any;
395
+ hold: any;
396
+ says: string;
397
+ contribution?: undefined;
398
+ table?: undefined;
399
+ } | {
400
+ order?: undefined;
401
+ entry?: undefined;
402
+ id?: undefined;
403
+ side?: undefined;
404
+ hold?: undefined;
405
+ kind: string;
406
+ key: any;
407
+ says: string;
408
+ contribution?: undefined;
409
+ asset?: undefined;
410
+ table?: undefined;
411
+ } | {
412
+ order?: undefined;
413
+ entry?: undefined;
414
+ id?: undefined;
415
+ side?: undefined;
416
+ hold?: undefined;
417
+ kind: string;
418
+ key: any;
419
+ contribution: any;
420
+ says: string;
421
+ asset?: undefined;
422
+ table?: undefined;
423
+ } | {
424
+ key?: undefined;
425
+ order?: undefined;
426
+ entry?: undefined;
427
+ id?: undefined;
428
+ side?: undefined;
429
+ hold?: undefined;
430
+ contribution?: undefined;
431
+ kind: string;
432
+ asset: any;
433
+ says: string;
434
+ table?: undefined;
435
+ } | {
436
+ key?: undefined;
437
+ order?: undefined;
438
+ entry?: undefined;
439
+ id?: undefined;
440
+ side?: undefined;
441
+ hold?: undefined;
442
+ contribution?: undefined;
443
+ asset?: undefined;
444
+ kind: string;
445
+ table: any;
446
+ says: string;
447
+ })[]>;
448
+ /**
449
+ * Finishes one of `claims()`, signed by this player. Returns the signature. A winner of a contest of NFTs picks
450
+ * which loser's NFT they take (`{ take: asset }`, the NFT of a losing entry that still holds one; the first found by default):
451
+ * only the winner can, while any are left.
452
+ */
453
+ claim(c: any, { take, ...others }?: Readonly<Record<string, any>>): Promise<any>;
454
+ /** The player's collectibles of this project: [{ asset, item, itemId, name, uri, attributes, frozen }]. `item` is its key in the spec. */
455
+ collectibles: (owner?: any) => Promise<{
456
+ owner: string;
457
+ collection: string | null;
458
+ name: string;
459
+ uri: string;
460
+ attributes: {};
461
+ frozen: boolean;
462
+ soulbound: boolean;
463
+ asset: any;
464
+ itemId: number | null;
465
+ item: any;
466
+ }[]>;
467
+ /** What the player holds of each of the economy's tokens, in whole units. */
468
+ balances(owner?: any): Promise<{}>;
469
+ };
@@ -0,0 +1,155 @@
1
+ export { canonicalJson, CERT_KINDS, CLUSTERS, drawText, entryText, giveawayHostText, hostCertText, lockText, NO_GRANT, RESULT_DOMAIN, resultBytes, revokeGiveawayText, revokeText, rosterHash } from './wire.js';
2
+ /** games.fun's results server, on its play host (devnet until the program's audit). */
3
+ export declare const RESULTS_SERVER = "https://play.xgames.fun/xsolana";
4
+ /** A fresh round id: 16 random bytes, in hex. Make it when the round starts. */
5
+ export declare const newRound: () => string;
6
+ /**
7
+ * A fresh Ed25519 key: { address, sign(bytes) → Promise<64 bytes>, secret }. `secret` is its 32-byte seed in base58,
8
+ * for a host server to keep in its secret store; a page's session key never needs it.
9
+ */
10
+ export declare function newKey(): Promise<{
11
+ address: string;
12
+ secret: string;
13
+ sign: (message: any) => Promise<Uint8Array<ArrayBuffer>>;
14
+ }>;
15
+ /** The key a host server kept (`secret`: its seed in base58). */
16
+ export declare function keyFromSecret(secret: any): Promise<{
17
+ address: string;
18
+ secret: string;
19
+ sign: (message: any) => Promise<Uint8Array<ArrayBuffer>>;
20
+ }>;
21
+ /** One signer's signature of a result: { key, signature }. `signer` is a key from newKey, or anything with sign(). */
22
+ export declare function signResult(signer: any, result: any, cluster?: string): Promise<{
23
+ key: any;
24
+ signature: string;
25
+ }>;
26
+ /**
27
+ * A host server reports a round. `cert`: the owner's { text, signature } certifying `signer`, the host key. Retrying
28
+ * with the same result is safe: it is the same answer. Returns the server's answer, { result, vouchers }, or throws its
29
+ * { code, why }.
30
+ */
31
+ export declare function report({ server, cert, signer, game, round, endedAt, winners, cluster, fetchImpl }: {
32
+ cert: any;
33
+ cluster?: string | undefined;
34
+ endedAt: any;
35
+ fetchImpl?: typeof fetch | undefined;
36
+ game: any;
37
+ round: any;
38
+ server: any;
39
+ signer: any;
40
+ winners: any;
41
+ }): Promise<any>;
42
+ /** A wallet's vouchers for a round it won: [{ grant, publicKey, signature, round, expires, … }]. */
43
+ export declare function fetchVouchers({ server, game, round, wallet, fetchImpl }: {
44
+ fetchImpl?: typeof fetch | undefined;
45
+ game: any;
46
+ round: any;
47
+ server: any;
48
+ wallet: any;
49
+ }): Promise<any>;
50
+ /**
51
+ * A loot grant voucher the host key signs itself, for a host server whose key the grant names (no results server
52
+ * involved): the program checks it and pays only `wallet`, within the grant's limits. `round` is the result's round id
53
+ * (16 bytes hex): the program pays a wallet each round once, ever, so the voucher may be signed again, any time, and
54
+ * still pays once. `incarnation` is the grant's (`Grant.incarnation`): a voucher pays only the grant it was signed
55
+ * for, never one written again at the same address. `now` is the cluster's clock (unix s); the voucher lives
56
+ * `seconds` from it, 30 days at most. `amount`: the tokens this claim gives, in base units, for a grant of a fixed amount
57
+ * of tokens (a rank's reward), at most the grant's; 0 (the default) gives the grant's prize as it is.
58
+ * Returns { wallet, grant, incarnation, publicKey, signature, round, expires, personHash, amount } for js/play claimGrant,
59
+ * plain JSON (`incarnation` and `amount` as decimal text), so a server can send it as it is.
60
+ */
61
+ export declare function signVoucher({ signer, game, grant, incarnation, wallet, round, now, seconds, personHash, amount }: {
62
+ amount?: bigint | undefined;
63
+ game: any;
64
+ grant: any;
65
+ incarnation: any;
66
+ now: any;
67
+ personHash?: null | undefined;
68
+ round: any;
69
+ seconds?: number | undefined;
70
+ signer: any;
71
+ wallet: any;
72
+ }): Promise<{
73
+ wallet: any;
74
+ grant: any;
75
+ incarnation: string;
76
+ publicKey: any;
77
+ signature: string;
78
+ round: any;
79
+ expires: number;
80
+ personHash: string;
81
+ amount: string;
82
+ }>;
83
+ /**
84
+ * A draw, from the organizer's side and the players'. `signMessage(text) → signature bytes` is the organizer's wallet
85
+ * (its signMessage) or a host key's sign; `by` its address; `cert` the owner's host certificate when `by` is a host key.
86
+ */
87
+ export declare const draws: {
88
+ open: ({ server, signMessage, by, cert, rates, fetchImpl, ...spec }: {
89
+ [x: string]: any;
90
+ by: any;
91
+ cert?: null | undefined;
92
+ fetchImpl?: typeof fetch | undefined;
93
+ rates?: null | undefined;
94
+ server: any;
95
+ signMessage: any;
96
+ }) => Promise<any>;
97
+ /** A player enters with their play-host token, or with their wallet's signature (`wallet`, `signMessage`). */
98
+ enter: ({ server, game, draw, token, wallet, signMessage, cluster, fetchImpl }: {
99
+ cluster?: string | undefined;
100
+ draw: any;
101
+ fetchImpl?: typeof fetch | undefined;
102
+ game: any;
103
+ server: any;
104
+ signMessage?: null | undefined;
105
+ token?: null | undefined;
106
+ wallet?: null | undefined;
107
+ }) => Promise<any>;
108
+ /** Locks the players the server holds now to `beacon`, a drand round still to come. Checks their hash itself. */
109
+ lock: ({ server, game, draw, beacon, signMessage, by, cert, cluster, net, fetchImpl }: {
110
+ beacon: any;
111
+ by: any;
112
+ cert?: null | undefined;
113
+ cluster?: string | undefined;
114
+ draw: any;
115
+ fetchImpl?: typeof fetch | undefined;
116
+ game: any;
117
+ net?: string | undefined;
118
+ server: any;
119
+ signMessage: any;
120
+ }) => Promise<any>;
121
+ /** The draw as anyone may check it; settled, with its result, once its beacon round is out. */
122
+ get: ({ server, game, draw, fetchImpl }: {
123
+ draw: any;
124
+ fetchImpl?: typeof fetch | undefined;
125
+ game: any;
126
+ server: any;
127
+ }) => Promise<any>;
128
+ };
129
+ /** A giveaway, from its appointed host's page. */
130
+ export declare const giveaways: {
131
+ /** Opens one: `cert` the owner's appointment, `token` the host's play-host sign-in, `session` a key from newKey(). */
132
+ open: ({ server, game, cert, token, giveaway, winners, endsBy, session, fetchImpl }: {
133
+ cert: any;
134
+ endsBy: any;
135
+ fetchImpl?: typeof fetch | undefined;
136
+ game: any;
137
+ giveaway: any;
138
+ server: any;
139
+ session: any;
140
+ token: any;
141
+ winners: any;
142
+ }) => Promise<any>;
143
+ /** Reports its result, signed by its session key. `grant`: the host's grant (each winner is paid from it). */
144
+ report: ({ server, game, giveaway, session, endedAt, winners, grant, cluster, fetchImpl }: {
145
+ cluster?: string | undefined;
146
+ endedAt: any;
147
+ fetchImpl?: typeof fetch | undefined;
148
+ game: any;
149
+ giveaway: any;
150
+ grant: any;
151
+ server: any;
152
+ session: any;
153
+ winners: any;
154
+ }) => Promise<any>;
155
+ };