@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
@@ -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
+ };