@xgamesfun/solana 0.24.0 → 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.
- package/README.md +94 -51
- package/bin/xsolana.mjs +23 -8
- package/examples/blind-forge.json +2 -4
- package/examples/coin-flip-arena.json +2 -5
- package/examples/duel-arena.json +1 -4
- package/examples/fair-presale.json +1 -3
- package/examples/hero-trials.json +14 -2
- package/examples/holder-den.json +38 -0
- package/examples/holders-drop.json +105 -0
- package/examples/ideas.json +788 -788
- package/examples/match-predictions.json +24 -0
- package/examples/nft-raffle.json +1 -0
- package/examples/pack-league.json +108 -0
- package/examples/partner-vault.json +19 -3
- package/examples/sacrifice-raffle.json +2 -10
- package/examples/shelter-fair.json +1 -0
- package/examples/stakers-draw.json +3 -7
- package/examples/stride-sneakers.json +164 -0
- package/examples/trade-in-shop.json +2 -3
- package/js/approve/details.mjs +117 -48
- package/js/approve/ed25519.mjs +5 -1
- package/js/approve/live-check.mjs +83 -26
- package/js/approve/page.html +217 -78
- package/js/approve/page.js +43 -15
- package/js/approve/server.mjs +276 -74
- package/js/chain/base58.js +7 -1
- package/js/chain/borsh.js +15 -11
- package/js/chain/bytes.js +11 -8
- package/js/chain/core.js +21 -5
- package/js/chain/curve.js +1 -1
- package/js/chain/lookup.js +118 -36
- package/js/chain/mint.js +6 -2
- package/js/chain/pda.js +2 -2
- package/js/chain/programs.js +6 -6
- package/js/chain/rpc.js +40 -14
- package/js/chain/token.js +13 -2
- package/js/chain/token2022.js +55 -16
- package/js/chain/tx.js +32 -22
- package/js/client/accounts.js +270 -80
- package/js/client/compressed.js +4 -3
- package/js/client/grant.js +165 -40
- package/js/client/idl/loot.js +1 -1
- package/js/client/idl/loot.json +104 -16
- package/js/client/ix.js +2121 -457
- package/js/client/pda.js +20 -18
- package/js/client/policy.js +12 -5
- package/js/client/random.js +1 -1
- package/js/client/sizes.js +220 -65
- package/js/client/traits.js +14 -5
- package/js/connect/connect.mjs +59 -17
- package/js/economy/check.mjs +3873 -690
- package/js/economy/cost.mjs +380 -56
- package/js/economy/examples.mjs +176 -35
- package/js/economy/explain.mjs +461 -110
- package/js/economy/guide.mjs +282 -59
- package/js/economy/legal.mjs +12 -6
- package/js/economy/live.mjs +60 -19
- package/js/economy/model.mjs +320 -97
- package/js/economy/plan.mjs +1022 -203
- package/js/economy/schema.json +127 -369
- package/js/economy/secrets.mjs +17 -7
- package/js/economy/simulate.mjs +771 -178
- package/js/economy/txsize.mjs +15 -3
- package/js/economy/validate.mjs +61 -24
- package/js/mcp/server.mjs +42 -14
- package/js/mcp/tools.mjs +293 -80
- package/js/play/index.js +1960 -461
- package/js/play/keys.js +35 -9
- package/js/results/index.js +223 -30
- package/js/results/server.js +230 -0
- package/js/results/wire.js +64 -16
- package/package.json +6 -4
- package/release.json +5 -5
- package/skills/xsolana-economy/SKILL.md +30 -16
- package/skills/xsolana-economy/references/after-launch.md +30 -20
- package/skills/xsolana-economy/references/apps.md +47 -36
- package/skills/xsolana-economy/references/sentence-to-spec.md +148 -129
- package/skills/xsolana-economy/references/telling-the-person.md +9 -6
- package/types/chain/core.d.ts +1 -1
- package/types/chain/lookup.d.ts +1 -1
- package/types/client/accounts.d.ts +24 -3
- package/types/client/grant.d.ts +2 -2
- package/types/client/idl/loot.d.ts +22 -0
- package/types/client/ix.d.ts +54 -45
- package/types/client/pda.d.ts +3 -1
- package/types/economy/guide.d.mts +5 -0
- package/types/economy/model.d.mts +48 -3
- package/types/economy/plan.d.mts +44 -2
- package/types/play/index.d.ts +8 -19
- package/types/results/index.d.ts +7 -6
- package/types/results/server.d.ts +126 -0
- package/types/results/wire.d.ts +1 -1
package/js/economy/secrets.mjs
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
import { isSignature } from '../chain/base58.js';
|
|
4
4
|
|
|
5
5
|
/** The names only a credential goes by. */
|
|
6
|
-
const CREDENTIAL_ONLY =
|
|
6
|
+
const CREDENTIAL_ONLY =
|
|
7
|
+
'api[-_ ]?key|apikey|private[-_ ]?key|secret[-_ ]?key|seed[-_ ]?phrase|mnemonic|access[-_ ]?token|auth[-_ ]?token';
|
|
7
8
|
/** Every name a credential goes by, ordinary words ("secret", "bearer") included: a field named so holds one. */
|
|
8
9
|
const CREDENTIAL = `${CREDENTIAL_ONLY}|secret|bearer`;
|
|
9
10
|
|
|
@@ -31,30 +32,39 @@ const SECRET_PATTERNS = [
|
|
|
31
32
|
];
|
|
32
33
|
|
|
33
34
|
/** Whether a string looks like it carries a key, a token or a keyed RPC URL. */
|
|
34
|
-
export const secretLike =
|
|
35
|
+
export const secretLike = value => typeof value === 'string' && SECRET_PATTERNS.some(p => p.test(value));
|
|
35
36
|
|
|
36
37
|
const MNEMONIC_LENGTHS = new Set([12, 15, 18, 21, 24]);
|
|
37
38
|
/** A seed phrase: 12 to 24 lower-case words of 3 to 8 letters and nothing else (no sentence is only such words). */
|
|
38
|
-
const seedPhrase =
|
|
39
|
+
const seedPhrase = s => {
|
|
39
40
|
const words = s.trim().split(/\s+/);
|
|
40
|
-
return MNEMONIC_LENGTHS.has(words.length) && words.every(
|
|
41
|
+
return MNEMONIC_LENGTHS.has(words.length) && words.every(w => /^[a-z]{3,8}$/.test(w));
|
|
41
42
|
};
|
|
42
43
|
|
|
43
44
|
/** A field's name that is a credential's: "apiKey", "private_key", "seed phrase", "my-secret". */
|
|
44
45
|
const CREDENTIAL_FIELD = new RegExp(`\\b(${CREDENTIAL})$`, 'i');
|
|
45
46
|
/** Whether a field holds anything: a string with more than spaces, a number, a list or an object that is not empty. */
|
|
46
|
-
const filled =
|
|
47
|
+
const filled = v =>
|
|
48
|
+
typeof v === 'string'
|
|
49
|
+
? v.trim() !== ''
|
|
50
|
+
: Array.isArray(v)
|
|
51
|
+
? v.length > 0
|
|
52
|
+
: v !== null && v !== undefined && (typeof v !== 'object' || Object.keys(v).length > 0);
|
|
47
53
|
|
|
48
54
|
/** Every place in `value` that looks like a key, a seed phrase or a keypair file. */
|
|
49
55
|
export function findSecrets(value, path = 'economy') {
|
|
50
56
|
if (typeof value === 'string') return secretLike(value) || seedPhrase(value) ? [path] : [];
|
|
51
57
|
if (Array.isArray(value)) {
|
|
52
|
-
if (value.length >= 32 && value.every(
|
|
58
|
+
if (value.length >= 32 && value.every(n => Number.isInteger(n) && n >= 0 && n <= 255)) return [path];
|
|
53
59
|
return value.flatMap((v, i) => findSecrets(v, `${path}[${i}]`));
|
|
54
60
|
}
|
|
55
61
|
// A transaction's signature is as long as a key; the spec keeps signatures in fields named "signature" only. A field
|
|
56
62
|
// named for a credential ("apiKey", "privateKey", "mnemonic", …) that holds something is one.
|
|
57
63
|
if (value && typeof value === 'object')
|
|
58
|
-
return Object.entries(value).flatMap(([k, v]) =>
|
|
64
|
+
return Object.entries(value).flatMap(([k, v]) =>
|
|
65
|
+
k === 'signature' && isSignature(v)
|
|
66
|
+
? []
|
|
67
|
+
: [...(CREDENTIAL_FIELD.test(k) && filled(v) ? [`${path}.${k}`] : []), ...findSecrets(v, `${path}.${k}`)],
|
|
68
|
+
);
|
|
59
69
|
return [];
|
|
60
70
|
}
|