@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
@@ -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 = 'api[-_ ]?key|apikey|private[-_ ]?key|secret[-_ ]?key|seed[-_ ]?phrase|mnemonic|access[-_ ]?token|auth[-_ ]?token';
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 = (value) => typeof value === 'string' && SECRET_PATTERNS.some((p) => p.test(value));
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 = (s) => {
39
+ const seedPhrase = s => {
39
40
  const words = s.trim().split(/\s+/);
40
- return MNEMONIC_LENGTHS.has(words.length) && words.every((w) => /^[a-z]{3,8}$/.test(w));
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 = (v) => (typeof v === 'string' ? v.trim() !== '' : Array.isArray(v) ? v.length > 0 : v !== null && v !== undefined && (typeof v !== 'object' || Object.keys(v).length > 0));
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((n) => Number.isInteger(n) && n >= 0 && n <= 255)) return [path];
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]) => (k === 'signature' && isSignature(v) ? [] : [...(CREDENTIAL_FIELD.test(k) && filled(v) ? [`${path}.${k}`] : []), ...findSecrets(v, `${path}.${k}`)]));
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
  }