@xgamesfun/solana 0.20.1 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/examples/coin-flip-arena.json +2 -7
- package/examples/elements-set.json +2 -9
- package/examples/expedition-guild.json +1 -8
- package/examples/guild-missions.json +3 -10
- package/examples/halving-seasons.json +4 -9
- package/examples/hero-trials.json +1 -4
- package/examples/merge-2048.json +5 -5
- package/examples/paper-hands-farm.json +4 -16
- package/examples/partner-vault.json +1 -4
- package/examples/stakers-draw.json +1 -8
- package/examples/star-fleet.json +1 -8
- package/examples/starforce.json +6 -6
- package/js/approve/details.mjs +8 -7
- package/js/approve/server.mjs +20 -5
- package/js/chain/borsh.js +9 -0
- package/js/chain/core.js +14 -2
- package/js/chain/lookup.js +8 -2
- package/js/chain/rpc.js +4 -2
- package/js/client/accounts.js +448 -116
- package/js/client/grant.js +125 -66
- package/js/client/idl/loot.js +1 -1
- package/js/client/idl/loot.json +2360 -2218
- package/js/client/index.js +1 -0
- package/js/client/ix.js +1204 -473
- package/js/client/pda.js +20 -16
- package/js/client/policy.js +44 -23
- package/js/client/random.js +70 -0
- package/js/client/sizes.js +255 -12
- package/js/economy/check.mjs +455 -210
- package/js/economy/cost.mjs +45 -30
- package/js/economy/examples.mjs +2 -2
- package/js/economy/explain.mjs +24 -20
- package/js/economy/guide.mjs +31 -30
- package/js/economy/live.mjs +30 -7
- package/js/economy/model.mjs +171 -56
- package/js/economy/plan.mjs +380 -112
- package/js/economy/schema.json +291 -143
- package/js/economy/simulate.mjs +154 -87
- package/js/mcp/tools.mjs +14 -8
- package/js/play/index.js +1121 -375
- package/js/play/keys.js +167 -0
- package/package.json +1 -1
- package/release.json +5 -5
- package/skills/xsolana-economy/SKILL.md +15 -11
- package/skills/xsolana-economy/references/after-launch.md +37 -27
- package/skills/xsolana-economy/references/apps.md +55 -19
- package/skills/xsolana-economy/references/sentence-to-spec.md +30 -22
- package/skills/xsolana-economy/references/telling-the-person.md +52 -11
- package/types/chain/core.d.ts +3 -1
- package/types/chain/lookup.d.ts +5 -2
- package/types/chain/rpc.d.ts +3 -1
- package/types/client/accounts.d.ts +195 -55
- package/types/client/grant.d.ts +72 -27
- package/types/client/idl/loot.d.ts +590 -559
- package/types/client/index.d.ts +1 -0
- package/types/client/ix.d.ts +3862 -234
- package/types/client/pda.d.ts +19 -15
- package/types/client/policy.d.ts +39 -14
- package/types/client/random.d.ts +26 -0
- package/types/client/sizes.d.ts +93 -5
- package/types/economy/check.d.mts +5 -10
- package/types/economy/cost.d.mts +2 -1
- package/types/economy/live.d.mts +16 -1
- package/types/economy/model.d.mts +105 -37
- package/types/economy/plan.d.mts +193 -192
- package/types/economy/simulate.d.mts +21 -13
- package/types/mcp/tools.d.mts +21 -13
- package/types/play/index.d.ts +450 -39
- package/types/play/keys.d.ts +51 -0
package/js/chain/lookup.js
CHANGED
|
@@ -222,12 +222,14 @@ async function freshSlot(rpc, payer) {
|
|
|
222
222
|
* first (`planTable`); else the table first, then each compressed NFT's prove_leaf alone, then the rest as v0 (or the
|
|
223
223
|
* proofs then a legacy rest, when that fits with no table). The v0 transaction is compiled against the table as the
|
|
224
224
|
* chain holds it. `sign(message)` → the signed wire transaction. `rpc`: the client's (latestBlockhash, send, confirm,
|
|
225
|
-
* account, call('getSlot')). `
|
|
225
|
+
* account, call('getSlot')). `standing`: tables already made ([{ address, addresses }], a project's, active), tried
|
|
226
|
+
* first: one v0 transaction with them when they hold enough. `table: false` sends no lookup table of its own (a throwaway
|
|
227
|
+
* key holds no rent for one); `first`:
|
|
226
228
|
* addresses a table holds first (`planTable`). Throws a
|
|
227
229
|
* plain sentence when it can't be sent. Returns { signature (the last transaction's), table (its address, or null),
|
|
228
230
|
* steps (the signatures of the transactions before it) }.
|
|
229
231
|
*/
|
|
230
|
-
export async function sendFitting({ rpc, payer, instructions, sign, table = true, alone = () => false, first = [], sleep = pause }) {
|
|
232
|
+
export async function sendFitting({ rpc, payer, instructions, sign, table = true, alone = () => false, first = [], standing = [], sleep = pause }) {
|
|
231
233
|
const sendOne = async (build) => {
|
|
232
234
|
const { blockhash, lastValidBlockHeight } = await rpc.latestBlockhash();
|
|
233
235
|
const message = build(blockhash);
|
|
@@ -240,6 +242,10 @@ export async function sendFitting({ rpc, payer, instructions, sign, table = true
|
|
|
240
242
|
const plan = sendPlan({ payer, blockhash, instructions, alone });
|
|
241
243
|
if (!plan) throw new Error(`This transaction is too large to send even as a v0 one with a lookup table: it names ${tableAccounts(instructions).length + 1} accounts or more (a transaction locks at most 64), or its instructions are too long.`);
|
|
242
244
|
if (plan.legacy) return { signature: await plain(instructions), table: null, steps: [] };
|
|
245
|
+
// Standing tables (a project's, made at go-live; each still active) that hold enough of its accounts: one v0
|
|
246
|
+
// transaction with them, and no table of its own.
|
|
247
|
+
const fits = standing.length && compileFitting({ payer, blockhash, instructions, tables: standing });
|
|
248
|
+
if (fits && fits[0] === 0x80) return { signature: await sendOne((bh) => compileMessage({ payer, blockhash: bh, instructions, version: 0, lookupTables: standing })), table: null, steps: [] };
|
|
243
249
|
if (plan.table && !table) throw new Error(`This transaction takes ${sizeOf({ payer, blockhash, instructions })} bytes, more than the ${MAX_TRANSACTION_BYTES} a legacy one holds, and this key holds no rent for a lookup table.`);
|
|
244
250
|
const steps = [];
|
|
245
251
|
const proofs = async () => {
|
package/js/chain/rpc.js
CHANGED
|
@@ -59,13 +59,15 @@ export async function checkCluster(rpc) {
|
|
|
59
59
|
const decodeAccount = (raw) =>
|
|
60
60
|
raw ? { owner: raw.owner, lamports: raw.lamports, data: fromBase64(raw.data[0]), executable: raw.executable } : null;
|
|
61
61
|
|
|
62
|
-
/** The program's own words for a failed run (`AnchorError … Error Message: …`), else the last error log line.
|
|
62
|
+
/** The program's own words for a failed run (`AnchorError … Error Message: …`), else the last error log line. A program
|
|
63
|
+
* built without its errors' text logs the error's name as its message: then the name alone (the client's IDL has
|
|
64
|
+
* the sentence: `loot.lootError`). */
|
|
63
65
|
export function programError(err, logs) {
|
|
64
66
|
const anchor = logs?.find((line) => line.includes('AnchorError'));
|
|
65
67
|
const said = anchor ? /Error Message: (.+?)\.?$/.exec(anchor)?.[1] : undefined;
|
|
66
68
|
const code = anchor ? /Error Code: (\w+)/.exec(anchor)?.[1] : undefined;
|
|
67
69
|
const last = logs?.filter((l) => /error|failed|insufficient/i.test(l)).at(-1);
|
|
68
|
-
if (said) return code ? `${said} (${code})` : said;
|
|
70
|
+
if (said) return code && code !== said ? `${said} (${code})` : said;
|
|
69
71
|
return last ?? (typeof err === 'string' ? err : JSON.stringify(err));
|
|
70
72
|
}
|
|
71
73
|
|