@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.
- package/README.md +95 -52
- package/bin/xsolana.mjs +23 -8
- package/examples/blind-forge.json +2 -4
- package/examples/coin-flip-arena.json +4 -12
- package/examples/duel-arena.json +1 -4
- package/examples/elements-set.json +2 -9
- package/examples/expedition-guild.json +1 -8
- package/examples/fair-presale.json +1 -3
- package/examples/guild-missions.json +3 -10
- package/examples/halving-seasons.json +4 -9
- package/examples/hero-trials.json +15 -6
- 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/merge-2048.json +5 -5
- package/examples/nft-raffle.json +1 -0
- package/examples/pack-league.json +108 -0
- package/examples/paper-hands-farm.json +4 -16
- package/examples/partner-vault.json +20 -7
- package/examples/sacrifice-raffle.json +2 -10
- package/examples/shelter-fair.json +1 -0
- package/examples/stakers-draw.json +4 -15
- package/examples/star-fleet.json +1 -8
- package/examples/starforce.json +6 -6
- package/examples/stride-sneakers.json +164 -0
- package/examples/trade-in-shop.json +2 -3
- package/js/approve/details.mjs +122 -52
- 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 +290 -73
- package/js/chain/base58.js +7 -1
- package/js/chain/borsh.js +24 -11
- package/js/chain/bytes.js +11 -8
- package/js/chain/core.js +35 -7
- package/js/chain/curve.js +1 -1
- package/js/chain/lookup.js +124 -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 +44 -16
- 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 +653 -131
- package/js/client/compressed.js +4 -3
- package/js/client/grant.js +267 -83
- package/js/client/idl/loot.js +1 -1
- package/js/client/idl/loot.json +2406 -2176
- package/js/client/index.js +1 -0
- package/js/client/ix.js +3059 -664
- package/js/client/pda.js +39 -33
- package/js/client/policy.js +52 -24
- package/js/client/random.js +70 -0
- package/js/client/sizes.js +414 -16
- package/js/client/traits.js +14 -5
- package/js/connect/connect.mjs +59 -17
- package/js/economy/check.mjs +4153 -725
- package/js/economy/cost.mjs +403 -64
- package/js/economy/examples.mjs +176 -35
- package/js/economy/explain.mjs +466 -111
- package/js/economy/guide.mjs +296 -72
- package/js/economy/legal.mjs +12 -6
- package/js/economy/live.mjs +83 -19
- package/js/economy/model.mjs +462 -124
- package/js/economy/plan.mjs +1306 -219
- package/js/economy/schema.json +390 -484
- package/js/economy/secrets.mjs +17 -7
- package/js/economy/simulate.mjs +883 -223
- 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 +307 -88
- package/js/play/index.js +2864 -619
- package/js/play/keys.js +193 -0
- 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 +39 -21
- package/skills/xsolana-economy/references/after-launch.md +58 -38
- package/skills/xsolana-economy/references/apps.md +97 -50
- package/skills/xsolana-economy/references/sentence-to-spec.md +148 -121
- package/skills/xsolana-economy/references/telling-the-person.md +61 -17
- package/types/chain/core.d.ts +4 -2
- package/types/chain/lookup.d.ts +5 -2
- package/types/chain/rpc.d.ts +3 -1
- package/types/client/accounts.d.ts +217 -56
- package/types/client/grant.d.ts +72 -27
- package/types/client/idl/loot.d.ts +602 -549
- package/types/client/index.d.ts +1 -0
- package/types/client/ix.d.ts +3884 -247
- package/types/client/pda.d.ts +22 -16
- 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/guide.d.mts +5 -0
- package/types/economy/live.d.mts +16 -1
- package/types/economy/model.d.mts +151 -38
- package/types/economy/plan.d.mts +237 -194
- package/types/economy/simulate.d.mts +21 -13
- package/types/mcp/tools.d.mts +21 -13
- package/types/play/index.d.ts +453 -53
- package/types/play/keys.d.ts +51 -0
- package/types/results/index.d.ts +7 -6
- package/types/results/server.d.ts +126 -0
- package/types/results/wire.d.ts +1 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** An Ed25519 key from its 32-byte seed: { address, sign(message) }. */
|
|
2
|
+
export declare function keyFromSeed(seed: any, name?: null): Promise<{
|
|
3
|
+
address: string;
|
|
4
|
+
name: null;
|
|
5
|
+
sign: (message: any) => Promise<Uint8Array<ArrayBuffer>>;
|
|
6
|
+
}>;
|
|
7
|
+
/** The text a wallet signs once a session for its settle keys. It moves nothing and says so. */
|
|
8
|
+
export declare const settleKeysText: (project: any, wallet: any) => string;
|
|
9
|
+
/**
|
|
10
|
+
* The page's storage of keys that can't be made again (`localStorage`), and a device key that encrypts them, kept in
|
|
11
|
+
* IndexedDB as a non-extractable AES-GCM key. Null where either is missing (then keys live in memory only).
|
|
12
|
+
*/
|
|
13
|
+
export declare function browserStore(): {
|
|
14
|
+
get: (k: any) => string | null;
|
|
15
|
+
set: (k: any, v: any) => void;
|
|
16
|
+
remove: (k: any) => void;
|
|
17
|
+
keys: () => (string | null)[];
|
|
18
|
+
cryptoKey: () => any;
|
|
19
|
+
} | null;
|
|
20
|
+
/**
|
|
21
|
+
* The keys of `wallet` ({ address, signMessage? }) in `project`. `store`: `browserStore()`'s shape ({ get, set, remove,
|
|
22
|
+
* keys, cryptoKey }), or null. `key(name)` makes the key named by an address (asking the wallet for its signature the
|
|
23
|
+
* first time in a session); `again(name)` makes it again for a job left unfinished, or finds it stored, or null;
|
|
24
|
+
* `stored()` lists the names of keys stored; `forget(name)` drops a stored key once its job is done and it is empty.
|
|
25
|
+
* `how()` says how keys are made: 'derived', 'stored' or 'memory'.
|
|
26
|
+
*/
|
|
27
|
+
export declare function keyring({ wallet, project, store }: {
|
|
28
|
+
project: any;
|
|
29
|
+
store?: null | undefined;
|
|
30
|
+
wallet: any;
|
|
31
|
+
}): {
|
|
32
|
+
how(): Promise<"derived" | "memory" | "stored">;
|
|
33
|
+
/** The key named `name` (an address) for a new job. */
|
|
34
|
+
key(name: any): Promise<{
|
|
35
|
+
address: string;
|
|
36
|
+
name: null;
|
|
37
|
+
sign: (message: any) => Promise<Uint8Array<ArrayBuffer>>;
|
|
38
|
+
}>;
|
|
39
|
+
/** The key named `name` again, for a job left unfinished: made again from the wallet's signature, or read from
|
|
40
|
+
* storage; null when neither can. `ask`: false to make it only from a signature already given this session. */
|
|
41
|
+
again(name: any, { ask }?: {
|
|
42
|
+
ask?: boolean | undefined;
|
|
43
|
+
}): Promise<{
|
|
44
|
+
address: string;
|
|
45
|
+
name: null;
|
|
46
|
+
sign: (message: any) => Promise<Uint8Array<ArrayBuffer>>;
|
|
47
|
+
} | null>;
|
|
48
|
+
/** The names of the keys this page stored for the wallet (none when keys are made from its signature). */
|
|
49
|
+
stored(): any;
|
|
50
|
+
forget(name: any): void;
|
|
51
|
+
};
|
package/types/results/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { canonicalJson, CERT_KINDS, CLUSTERS, drawText, entryText, giveawayHostText, hostCertText, lockText, NO_GRANT, RESULT_DOMAIN, resultBytes, revokeGiveawayText, revokeText, rosterHash } from './wire.js';
|
|
1
|
+
export { canonicalJson, CERT_KINDS, CLUSTERS, drawText, entryText, giveawayHostText, hostCertText, lockText, NO_GRANT, RESULT_DOMAIN, resultBytes, revokeGiveawayText, revokeText, rosterHash, } from './wire.js';
|
|
2
2
|
/** games.fun's results server, on its play host (devnet until the program's audit). */
|
|
3
3
|
export declare const RESULTS_SERVER = "https://play.xgames.fun/xsolana";
|
|
4
4
|
/** A fresh round id: 16 random bytes, in hex. Make it when the round starts. */
|
|
@@ -28,7 +28,7 @@ export declare function signResult(signer: any, result: any, cluster?: string):
|
|
|
28
28
|
* with the same result is safe: it is the same answer. Returns the server's answer, { result, vouchers }, or throws its
|
|
29
29
|
* { code, why }.
|
|
30
30
|
*/
|
|
31
|
-
export declare function report({ server, cert, signer, game, round, endedAt, winners, cluster, fetchImpl }: {
|
|
31
|
+
export declare function report({ server, cert, signer, game, round, endedAt, winners, cluster, fetchImpl, }: {
|
|
32
32
|
cert: any;
|
|
33
33
|
cluster?: string | undefined;
|
|
34
34
|
endedAt: any;
|
|
@@ -58,7 +58,7 @@ export declare function fetchVouchers({ server, game, round, wallet, fetchImpl }
|
|
|
58
58
|
* Returns { wallet, grant, incarnation, publicKey, signature, round, expires, personHash, amount } for js/play claimGrant,
|
|
59
59
|
* plain JSON (`incarnation` and `amount` as decimal text), so a server can send it as it is.
|
|
60
60
|
*/
|
|
61
|
-
export declare function signVoucher({ signer, game, grant, incarnation, wallet, round, now, seconds, personHash, amount }: {
|
|
61
|
+
export declare function signVoucher({ signer, game, grant, incarnation, wallet, round, now, seconds, personHash, amount, }: {
|
|
62
62
|
amount?: bigint | undefined;
|
|
63
63
|
game: any;
|
|
64
64
|
grant: any;
|
|
@@ -95,7 +95,7 @@ export declare const draws: {
|
|
|
95
95
|
signMessage: any;
|
|
96
96
|
}) => Promise<any>;
|
|
97
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 }: {
|
|
98
|
+
enter: ({ server, game, draw, token, wallet, signMessage, cluster, fetchImpl, }: {
|
|
99
99
|
cluster?: string | undefined;
|
|
100
100
|
draw: any;
|
|
101
101
|
fetchImpl?: typeof fetch | undefined;
|
|
@@ -106,7 +106,7 @@ export declare const draws: {
|
|
|
106
106
|
wallet?: null | undefined;
|
|
107
107
|
}) => Promise<any>;
|
|
108
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 }: {
|
|
109
|
+
lock: ({ server, game, draw, beacon, signMessage, by, cert, cluster, net, fetchImpl, }: {
|
|
110
110
|
beacon: any;
|
|
111
111
|
by: any;
|
|
112
112
|
cert?: null | undefined;
|
|
@@ -141,7 +141,7 @@ export declare const giveaways: {
|
|
|
141
141
|
winners: any;
|
|
142
142
|
}) => Promise<any>;
|
|
143
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 }: {
|
|
144
|
+
report: ({ server, game, giveaway, session, endedAt, winners, grant, cluster, fetchImpl, }: {
|
|
145
145
|
cluster?: string | undefined;
|
|
146
146
|
endedAt: any;
|
|
147
147
|
fetchImpl?: typeof fetch | undefined;
|
|
@@ -153,3 +153,4 @@ export declare const giveaways: {
|
|
|
153
153
|
winners: any;
|
|
154
154
|
}) => Promise<any>;
|
|
155
155
|
};
|
|
156
|
+
export { codeAddresses, codeKey, codeVoucher, collectiblesOf, holds, makeCodes, normalizeCode, proofRequest, proofText, readProof, verifyProof, } from './server.js';
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The game's collectibles `wallet` holds now, read from the chain (Metaplex Core assets of the live spec's collection
|
|
3
|
+
* and of the collections it names): [{ asset, item (its key in the spec, or null), itemId, name, uri, attributes,
|
|
4
|
+
* frozen }]. `rpc`: an RPC link or a `rpcClient`. Token Metadata and compressed NFTs are not read here.
|
|
5
|
+
*/
|
|
6
|
+
export declare function collectiblesOf({ rpc, spec, wallet }: {
|
|
7
|
+
rpc: any;
|
|
8
|
+
spec: any;
|
|
9
|
+
wallet: any;
|
|
10
|
+
}): Promise<{
|
|
11
|
+
owner: string;
|
|
12
|
+
collection: string | null;
|
|
13
|
+
name: string;
|
|
14
|
+
uri: string;
|
|
15
|
+
attributes: {};
|
|
16
|
+
frozen: boolean;
|
|
17
|
+
soulbound: boolean;
|
|
18
|
+
asset: any;
|
|
19
|
+
itemId: number | null;
|
|
20
|
+
item: any;
|
|
21
|
+
}[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Whether `wallet` holds at least `atLeast` of the game's collectible `item` (its key in the spec), or of any of the
|
|
24
|
+
* game's collectibles when `item` is left out. With `attribute`, only those whose number under it is at least
|
|
25
|
+
* `minimum` count (a level, a rarity). → the count it holds when that is enough, else 0.
|
|
26
|
+
*/
|
|
27
|
+
export declare function holds({ rpc, spec, wallet, item, atLeast, attribute, minimum }: {
|
|
28
|
+
atLeast?: number | undefined;
|
|
29
|
+
attribute?: null | undefined;
|
|
30
|
+
item?: null | undefined;
|
|
31
|
+
minimum?: number | undefined;
|
|
32
|
+
rpc: any;
|
|
33
|
+
spec: any;
|
|
34
|
+
wallet: any;
|
|
35
|
+
}): Promise<number>;
|
|
36
|
+
/** The exact text a wallet signs to prove it is its owner's: fixed lines, so nothing else can be passed off as it. */
|
|
37
|
+
export declare const proofText: ({ cluster, game, wallet, purpose, nonce, expires }: {
|
|
38
|
+
cluster?: string | undefined;
|
|
39
|
+
expires: any;
|
|
40
|
+
game: any;
|
|
41
|
+
nonce: any;
|
|
42
|
+
purpose: any;
|
|
43
|
+
wallet: any;
|
|
44
|
+
}) => string;
|
|
45
|
+
/**
|
|
46
|
+
* A proof to ask of `wallet`, made by the server: { text, nonce, expires }. The server keeps `nonce` until `expires`
|
|
47
|
+
* (unix seconds, `seconds` from now) and takes each nonce once, so a signed proof can't be replayed.
|
|
48
|
+
*/
|
|
49
|
+
export declare function proofRequest({ cluster, game, wallet, purpose, seconds, now, }: {
|
|
50
|
+
cluster?: string | undefined;
|
|
51
|
+
game: any;
|
|
52
|
+
now?: number | undefined;
|
|
53
|
+
purpose?: string | undefined;
|
|
54
|
+
seconds?: number | undefined;
|
|
55
|
+
wallet: any;
|
|
56
|
+
}): {
|
|
57
|
+
text: string;
|
|
58
|
+
nonce: string;
|
|
59
|
+
expires: number;
|
|
60
|
+
};
|
|
61
|
+
/** A proof text's fields, or null when it is not one. */
|
|
62
|
+
export declare function readProof(text: any): {
|
|
63
|
+
expires: any;
|
|
64
|
+
} | null;
|
|
65
|
+
/**
|
|
66
|
+
* Checks a wallet's signed proof: the text is a proof for this `game` (and `purpose`, when given), for `wallet`, not
|
|
67
|
+
* expired at `now`, and `signature` (base58, or 64 bytes) is that wallet's Ed25519 signature of it. → the proof's
|
|
68
|
+
* fields ({ wallet, nonce, expires, … }), or throws in words. Taking each nonce once is the caller's: check
|
|
69
|
+
* `fields.nonce` against the ones the server handed out and not yet used.
|
|
70
|
+
*/
|
|
71
|
+
export declare function verifyProof({ text, signature, wallet, game, purpose, cluster, now, }: {
|
|
72
|
+
cluster?: string | undefined;
|
|
73
|
+
game: any;
|
|
74
|
+
now?: number | undefined;
|
|
75
|
+
purpose?: null | undefined;
|
|
76
|
+
signature: any;
|
|
77
|
+
text: any;
|
|
78
|
+
wallet: any;
|
|
79
|
+
}): Promise<{
|
|
80
|
+
expires: any;
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* `n` fresh promo codes, each `bits` of randomness (80 by default, 16 characters of Crockford base32, in groups of 4).
|
|
84
|
+
* A code's key is in the spec for anyone to read, so a short code can be found by trying them all offline: fewer than
|
|
85
|
+
* 64 bits is refused.
|
|
86
|
+
*/
|
|
87
|
+
export declare function makeCodes(n: any, { bits, group }?: {
|
|
88
|
+
bits?: number | undefined;
|
|
89
|
+
group?: number | undefined;
|
|
90
|
+
}): string[];
|
|
91
|
+
/** A code as typed, read the forgiving way (Crockford): case, spaces and dashes don't matter, O reads 0, I and L read 1. */
|
|
92
|
+
export declare const normalizeCode: (code: any) => string;
|
|
93
|
+
/** The key a code stands for: { address, sign } (Ed25519, its seed sha256 of the domain and the code). */
|
|
94
|
+
export declare function codeKey(code: any, { domain }?: {
|
|
95
|
+
domain?: string | undefined;
|
|
96
|
+
}): Promise<{
|
|
97
|
+
address: string;
|
|
98
|
+
sign: (message: any) => Promise<Uint8Array<ArrayBuffer>>;
|
|
99
|
+
}>;
|
|
100
|
+
/** The public keys for a grant's `keys`, one per code, in order. */
|
|
101
|
+
export declare const codeAddresses: (codes: any, options: any) => Promise<any[]>;
|
|
102
|
+
/**
|
|
103
|
+
* A voucher a typed code signs for `wallet` (the page, or a server, makes it): the grant pays it once per code with
|
|
104
|
+
* `limits.perKey: 1`. Its round is the code's own, so one wallet can't use one code twice either. `incarnation` is the
|
|
105
|
+
* grant's, read from the chain; `now` the cluster's clock.
|
|
106
|
+
*/
|
|
107
|
+
export declare function codeVoucher({ code, game, grant, incarnation, wallet, now, seconds, domain, }: {
|
|
108
|
+
code: any;
|
|
109
|
+
domain?: string | undefined;
|
|
110
|
+
game: any;
|
|
111
|
+
grant: any;
|
|
112
|
+
incarnation: any;
|
|
113
|
+
now: any;
|
|
114
|
+
seconds?: number | undefined;
|
|
115
|
+
wallet: any;
|
|
116
|
+
}): Promise<{
|
|
117
|
+
wallet: any;
|
|
118
|
+
grant: any;
|
|
119
|
+
incarnation: string;
|
|
120
|
+
publicKey: any;
|
|
121
|
+
signature: string;
|
|
122
|
+
round: any;
|
|
123
|
+
expires: number;
|
|
124
|
+
personHash: string;
|
|
125
|
+
amount: string;
|
|
126
|
+
}>;
|
package/types/results/wire.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ export declare const revokeText: ({ cluster, game, host }: {
|
|
|
56
56
|
* `slug`: the game's play-host name (its tokens' audience), or '-'; `rates`: the sha256 of the engine's rates (canonical
|
|
57
57
|
* JSON), or 'default'.
|
|
58
58
|
*/
|
|
59
|
-
export declare const drawText: ({ cluster, game, draw, engine, winners, prizes, payout, identity, slug, rates }: {
|
|
59
|
+
export declare const drawText: ({ cluster, game, draw, engine, winners, prizes, payout, identity, slug, rates, }: {
|
|
60
60
|
cluster?: string | undefined;
|
|
61
61
|
draw: any;
|
|
62
62
|
engine: any;
|