@xgamesfun/solana 0.25.0 → 0.25.2
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/DISCLAIMER.md +1 -1
- package/NOTICE +4 -4
- package/README.md +81 -31
- package/bin/xsolana.mjs +19 -5
- package/examples/stakers-draw.json +1 -0
- package/js/client/index.js +1 -0
- package/js/client/kit.js +36 -0
- package/js/client/random.js +1 -1
- package/js/economy/check.mjs +11 -0
- package/js/economy/cost.mjs +1 -1
- package/js/economy/explain.mjs +10 -3
- package/js/economy/guide.mjs +1 -1
- package/js/economy/live.mjs +2 -1
- package/js/economy/review.mjs +760 -0
- package/js/economy/schema.json +8 -4
- package/js/economy/trust.mjs +15 -0
- package/js/index.js +1 -0
- package/js/mcp/http.mjs +136 -0
- package/js/mcp/server.mjs +34 -10
- package/js/mcp/tools.mjs +50 -2
- package/js/play/index.js +116 -2
- package/js/play/sponsor.js +302 -0
- package/js/results/index.js +2 -2
- package/package.json +35 -8
- package/release.json +1 -1
- package/skills/xsolana-economy/SKILL.md +32 -13
- package/skills/xsolana-economy/references/after-launch.md +2 -1
- package/skills/xsolana-economy/references/apps.md +28 -0
- package/skills/xsolana-economy/references/sentence-to-spec.md +1 -0
- package/skills/xsolana-economy/references/telling-the-person.md +6 -0
- package/skills/xsolana-economy/references/trust-and-cheating.md +126 -0
- package/types/client/index.d.ts +1 -0
- package/types/client/kit.d.ts +49 -0
- package/types/economy/cost.d.mts +1 -1
- package/types/economy/explain.d.mts +3 -0
- package/types/economy/plan.d.mts +14 -14
- package/types/economy/review.d.mts +45 -0
- package/types/economy/trust.d.mts +8 -0
- package/types/index.d.ts +1 -0
- package/types/mcp/http.d.mts +30 -0
- package/types/mcp/server.d.mts +321 -0
- package/types/mcp/tools.d.mts +71 -1
- package/types/play/index.d.ts +3 -1
- package/types/play/sponsor.d.ts +149 -0
- package/types/results/index.d.ts +1 -1
- package/examples/holder-den.json +0 -38
- package/examples/holders-drop.json +0 -105
- package/examples/match-predictions.json +0 -24
- package/examples/pack-league.json +0 -108
- package/examples/stride-sneakers.json +0 -164
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
export declare const INSTRUCTIONS: string;
|
|
2
|
+
/**
|
|
3
|
+
* What a hosted server (js/mcp/http.mjs) tells the agent: the same work, with the spec passed whole in every call,
|
|
4
|
+
* and going live on the person's own computer, since a hosted server can neither write their files nor open a page there.
|
|
5
|
+
*/
|
|
6
|
+
export declare const REMOTE_INSTRUCTIONS: string;
|
|
7
|
+
/**
|
|
8
|
+
* The protocol versions this server speaks, newest first. A client that asks for one of them gets it; any other ask
|
|
9
|
+
* gets the newest, and the client decides whether it can go on (the spec's version negotiation).
|
|
10
|
+
*/
|
|
11
|
+
export declare const PROTOCOLS: string[];
|
|
12
|
+
/** Every way `input` does not fit a tool's input schema, in words; [] when it fits. */
|
|
13
|
+
export declare function inputProblems(schema: any, input: any): any;
|
|
14
|
+
/** Runs one tool by name: the same checks and answer on the server and in the terminal. */
|
|
15
|
+
export declare function runTool(name: any, input?: {}, ctx?: {}): Promise<{
|
|
16
|
+
ok: boolean;
|
|
17
|
+
from: any;
|
|
18
|
+
refusals: any;
|
|
19
|
+
warnings: any;
|
|
20
|
+
text: string;
|
|
21
|
+
} | {
|
|
22
|
+
name: any;
|
|
23
|
+
spec: any;
|
|
24
|
+
checks: string | any[];
|
|
25
|
+
text: string;
|
|
26
|
+
examples?: undefined;
|
|
27
|
+
ideas?: undefined;
|
|
28
|
+
hows?: undefined;
|
|
29
|
+
limits?: undefined;
|
|
30
|
+
} | {
|
|
31
|
+
name?: undefined;
|
|
32
|
+
checks?: undefined;
|
|
33
|
+
examples: any;
|
|
34
|
+
ideas: {
|
|
35
|
+
count: any;
|
|
36
|
+
};
|
|
37
|
+
text: string;
|
|
38
|
+
hows?: undefined;
|
|
39
|
+
limits?: undefined;
|
|
40
|
+
spec?: undefined;
|
|
41
|
+
} | {
|
|
42
|
+
name?: undefined;
|
|
43
|
+
checks?: undefined;
|
|
44
|
+
examples: any;
|
|
45
|
+
ideas: any;
|
|
46
|
+
hows: any;
|
|
47
|
+
limits: any;
|
|
48
|
+
text: string;
|
|
49
|
+
spec?: undefined;
|
|
50
|
+
} | {
|
|
51
|
+
ok: boolean;
|
|
52
|
+
from: any;
|
|
53
|
+
summary: {
|
|
54
|
+
boxes: {
|
|
55
|
+
key: any;
|
|
56
|
+
returnPercent: any;
|
|
57
|
+
houseEdgePercent: any;
|
|
58
|
+
}[];
|
|
59
|
+
pools: {
|
|
60
|
+
key: any;
|
|
61
|
+
lasts: any;
|
|
62
|
+
lastsDays: any;
|
|
63
|
+
settlesAt: any;
|
|
64
|
+
}[];
|
|
65
|
+
farms: any;
|
|
66
|
+
platformSolPerDay: any;
|
|
67
|
+
};
|
|
68
|
+
simulation?: {
|
|
69
|
+
scenario: {
|
|
70
|
+
days: any;
|
|
71
|
+
perDay: any;
|
|
72
|
+
defaultPerDay: number;
|
|
73
|
+
defaultBidsPerDay: number;
|
|
74
|
+
defaultClaimsPerDay: number;
|
|
75
|
+
};
|
|
76
|
+
boxes: {
|
|
77
|
+
key: any;
|
|
78
|
+
name: any;
|
|
79
|
+
price: number;
|
|
80
|
+
averagePrice?: any;
|
|
81
|
+
token: any;
|
|
82
|
+
opensPerDay: number;
|
|
83
|
+
outcomes: any;
|
|
84
|
+
expectedBack: any;
|
|
85
|
+
returnPercent: any;
|
|
86
|
+
houseEdgePercent: any;
|
|
87
|
+
alsoPays: {};
|
|
88
|
+
unpriced: any[];
|
|
89
|
+
playerFee: number;
|
|
90
|
+
oracleFee: number;
|
|
91
|
+
realCost: {
|
|
92
|
+
price: any;
|
|
93
|
+
token: any;
|
|
94
|
+
atLeast?: boolean | undefined;
|
|
95
|
+
priceBack?: boolean | undefined;
|
|
96
|
+
playerFeeSol: number;
|
|
97
|
+
oracleSol: number;
|
|
98
|
+
networkSol: any;
|
|
99
|
+
rentSol: any;
|
|
100
|
+
rentIs?: string | undefined;
|
|
101
|
+
heldSol?: any;
|
|
102
|
+
heldIs?: string | undefined;
|
|
103
|
+
extrasSol: any;
|
|
104
|
+
totalSol?: any;
|
|
105
|
+
holdSol: any;
|
|
106
|
+
};
|
|
107
|
+
limitedStock?: boolean | undefined;
|
|
108
|
+
whenOut?: string | undefined;
|
|
109
|
+
stock?: {
|
|
110
|
+
whenOut: string;
|
|
111
|
+
stopsSellingInDays: any;
|
|
112
|
+
by: any;
|
|
113
|
+
} | {
|
|
114
|
+
by?: undefined;
|
|
115
|
+
whenOut: string;
|
|
116
|
+
runsOut: {
|
|
117
|
+
inDays: any;
|
|
118
|
+
outcomes: any;
|
|
119
|
+
chancesAfter: any;
|
|
120
|
+
}[];
|
|
121
|
+
stopsSellingInDays?: any;
|
|
122
|
+
} | undefined;
|
|
123
|
+
returnOfRealCostPercent?: any;
|
|
124
|
+
}[];
|
|
125
|
+
items: any;
|
|
126
|
+
payments: any;
|
|
127
|
+
recipes: any;
|
|
128
|
+
schedules: any;
|
|
129
|
+
lotteries: any;
|
|
130
|
+
farms: any;
|
|
131
|
+
grants: any;
|
|
132
|
+
contests: any;
|
|
133
|
+
auctions: any;
|
|
134
|
+
stashes: any;
|
|
135
|
+
pools: {
|
|
136
|
+
key: any;
|
|
137
|
+
pot?: any;
|
|
138
|
+
farm?: any;
|
|
139
|
+
token: any;
|
|
140
|
+
seed: any;
|
|
141
|
+
inPerDay: any;
|
|
142
|
+
outPerDay: any;
|
|
143
|
+
ins: any;
|
|
144
|
+
outs: any[];
|
|
145
|
+
}[];
|
|
146
|
+
perDay: {
|
|
147
|
+
players: {
|
|
148
|
+
pay: {
|
|
149
|
+
[k: string]: any;
|
|
150
|
+
};
|
|
151
|
+
getBack: {
|
|
152
|
+
[k: string]: any;
|
|
153
|
+
};
|
|
154
|
+
playerFeesSol: any;
|
|
155
|
+
oracleFeesSol: any;
|
|
156
|
+
networkFeesSol: any;
|
|
157
|
+
rentSol: any;
|
|
158
|
+
};
|
|
159
|
+
creator: {
|
|
160
|
+
treasury: {
|
|
161
|
+
[k: string]: any;
|
|
162
|
+
};
|
|
163
|
+
projectFeesSol: any;
|
|
164
|
+
oracleFeesSol: any;
|
|
165
|
+
networkFeesSol: any;
|
|
166
|
+
grantRentSol: any;
|
|
167
|
+
};
|
|
168
|
+
oracle: {
|
|
169
|
+
totalSol: any;
|
|
170
|
+
};
|
|
171
|
+
platform: {
|
|
172
|
+
playerFeesSol: any;
|
|
173
|
+
projectFeesSol: any;
|
|
174
|
+
totalSol: any;
|
|
175
|
+
};
|
|
176
|
+
burned: {
|
|
177
|
+
[k: string]: any;
|
|
178
|
+
};
|
|
179
|
+
accounts: {
|
|
180
|
+
[k: string]: any;
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
fees: {
|
|
184
|
+
playerSol: number;
|
|
185
|
+
projectSol: number;
|
|
186
|
+
oracleSol: number;
|
|
187
|
+
networkPerSignatureSol: number;
|
|
188
|
+
settleRentUnitSol: number;
|
|
189
|
+
ticketLineRentSol: any;
|
|
190
|
+
collectibleRentSol: number;
|
|
191
|
+
burnRefundSol: number;
|
|
192
|
+
};
|
|
193
|
+
notes: string[];
|
|
194
|
+
} | undefined;
|
|
195
|
+
text: string;
|
|
196
|
+
} | {
|
|
197
|
+
ok: boolean;
|
|
198
|
+
from: any;
|
|
199
|
+
setup: any;
|
|
200
|
+
actions: any;
|
|
201
|
+
fees: any;
|
|
202
|
+
text: string;
|
|
203
|
+
} | {
|
|
204
|
+
refusals?: undefined;
|
|
205
|
+
ok: boolean;
|
|
206
|
+
warnings: any[];
|
|
207
|
+
needsAuthority: boolean;
|
|
208
|
+
chance: boolean;
|
|
209
|
+
setupSol: any;
|
|
210
|
+
from: any;
|
|
211
|
+
text: string;
|
|
212
|
+
} | {
|
|
213
|
+
ok: boolean;
|
|
214
|
+
from: any;
|
|
215
|
+
routes: ({
|
|
216
|
+
kind: string;
|
|
217
|
+
key: any;
|
|
218
|
+
name: any;
|
|
219
|
+
trigger: string;
|
|
220
|
+
enforced: any[];
|
|
221
|
+
trusts: any[];
|
|
222
|
+
trust: any;
|
|
223
|
+
ceiling: string;
|
|
224
|
+
feeds: any[];
|
|
225
|
+
} | {
|
|
226
|
+
kind: string;
|
|
227
|
+
key: any;
|
|
228
|
+
name: any;
|
|
229
|
+
trigger: string;
|
|
230
|
+
enforced: any[];
|
|
231
|
+
trusts: any;
|
|
232
|
+
trust: null;
|
|
233
|
+
ceiling: string;
|
|
234
|
+
feeds: any[];
|
|
235
|
+
})[];
|
|
236
|
+
findings: any[];
|
|
237
|
+
tradeoffs: string;
|
|
238
|
+
text: string;
|
|
239
|
+
} | {
|
|
240
|
+
file?: undefined;
|
|
241
|
+
ok: boolean;
|
|
242
|
+
isError: boolean;
|
|
243
|
+
text: string;
|
|
244
|
+
warnings?: undefined;
|
|
245
|
+
} | {
|
|
246
|
+
isError?: undefined;
|
|
247
|
+
ok: boolean;
|
|
248
|
+
file: any;
|
|
249
|
+
warnings: any[];
|
|
250
|
+
text: string;
|
|
251
|
+
} | {
|
|
252
|
+
ok: boolean;
|
|
253
|
+
transactions: number;
|
|
254
|
+
approvals: number;
|
|
255
|
+
steps: never[];
|
|
256
|
+
text: string;
|
|
257
|
+
command?: undefined;
|
|
258
|
+
setupSol?: undefined;
|
|
259
|
+
} | {
|
|
260
|
+
ok: boolean;
|
|
261
|
+
command: string;
|
|
262
|
+
transactions: number;
|
|
263
|
+
approvals: number | undefined;
|
|
264
|
+
setupSol: any;
|
|
265
|
+
steps: any[];
|
|
266
|
+
text: string;
|
|
267
|
+
} | {
|
|
268
|
+
ok: boolean;
|
|
269
|
+
text: string;
|
|
270
|
+
rows?: undefined;
|
|
271
|
+
} | {
|
|
272
|
+
ok: boolean;
|
|
273
|
+
rows: ({
|
|
274
|
+
part: any;
|
|
275
|
+
address: any;
|
|
276
|
+
found: boolean;
|
|
277
|
+
kind: string;
|
|
278
|
+
sol: number;
|
|
279
|
+
} | {
|
|
280
|
+
sol?: undefined;
|
|
281
|
+
part: any;
|
|
282
|
+
address: any;
|
|
283
|
+
found: boolean;
|
|
284
|
+
amount?: number | undefined;
|
|
285
|
+
nfts?: any;
|
|
286
|
+
kind?: string | undefined;
|
|
287
|
+
})[];
|
|
288
|
+
text: string;
|
|
289
|
+
} | {
|
|
290
|
+
program: string;
|
|
291
|
+
cluster: "devnet";
|
|
292
|
+
version: string;
|
|
293
|
+
idl: "@xgamesfun/solana/idl.json";
|
|
294
|
+
package: `@xgamesfun/solana@${any}`;
|
|
295
|
+
text: string;
|
|
296
|
+
} | {
|
|
297
|
+
isError: boolean;
|
|
298
|
+
text: any;
|
|
299
|
+
}>;
|
|
300
|
+
/** The answer to one JSON-RPC request, or null for a notification. */
|
|
301
|
+
export declare function handle(message: any, ctx?: {}): Promise<{
|
|
302
|
+
jsonrpc: string;
|
|
303
|
+
id: any;
|
|
304
|
+
result: any;
|
|
305
|
+
} | {
|
|
306
|
+
jsonrpc: string;
|
|
307
|
+
id: any;
|
|
308
|
+
error: {
|
|
309
|
+
code: any;
|
|
310
|
+
message: any;
|
|
311
|
+
};
|
|
312
|
+
} | null>;
|
|
313
|
+
/**
|
|
314
|
+
* Serves the tools over stdio until stdin closes. Once it closes, every request already read is answered before
|
|
315
|
+
* `exit` runs, so a client that sends its last request and closes still gets the reply.
|
|
316
|
+
*/
|
|
317
|
+
export declare function serveStdio({ input, output, exit, }?: {
|
|
318
|
+
exit?: (() => any) | undefined;
|
|
319
|
+
input?: any;
|
|
320
|
+
output?: any;
|
|
321
|
+
}): Promise<void>;
|
package/types/mcp/tools.d.mts
CHANGED
|
@@ -25,6 +25,11 @@ export declare const PROGRAM_INFO: Readonly<{
|
|
|
25
25
|
package: `@xgamesfun/solana@${any}`;
|
|
26
26
|
}>;
|
|
27
27
|
export declare const DEFAULT_FILE = "xsolana.json";
|
|
28
|
+
/**
|
|
29
|
+
* The tools a hosted server (js/mcp/http.mjs) offers: those that read nothing but their arguments and the chain.
|
|
30
|
+
* xsolana_save and xsolana_publish write and read the person's own files, so they run only on the person's machine.
|
|
31
|
+
*/
|
|
32
|
+
export declare const REMOTE_TOOLS: Set<string>;
|
|
28
33
|
/**
|
|
29
34
|
* The spec file `rel` names, inside the project folder: a `.json` file there or in a folder below it. Anything else (an
|
|
30
35
|
* absolute path elsewhere, `..`, a link out of the folder, another kind of file) is refused.
|
|
@@ -451,6 +456,68 @@ export declare const tools: ({
|
|
|
451
456
|
from: any;
|
|
452
457
|
text: string;
|
|
453
458
|
}>;
|
|
459
|
+
} | {
|
|
460
|
+
name: string;
|
|
461
|
+
annotations: {
|
|
462
|
+
readOnlyHint: boolean;
|
|
463
|
+
destructiveHint: boolean;
|
|
464
|
+
idempotentHint: boolean;
|
|
465
|
+
openWorldHint: boolean;
|
|
466
|
+
};
|
|
467
|
+
description: string;
|
|
468
|
+
inputSchema: {
|
|
469
|
+
type: string;
|
|
470
|
+
properties: {
|
|
471
|
+
spec: {
|
|
472
|
+
type: string;
|
|
473
|
+
description: string;
|
|
474
|
+
};
|
|
475
|
+
file: {
|
|
476
|
+
type: string;
|
|
477
|
+
description: string;
|
|
478
|
+
};
|
|
479
|
+
example: {
|
|
480
|
+
type: string;
|
|
481
|
+
description: string;
|
|
482
|
+
};
|
|
483
|
+
};
|
|
484
|
+
additionalProperties: boolean;
|
|
485
|
+
required?: undefined;
|
|
486
|
+
};
|
|
487
|
+
handler(input: any, ctx: any): Promise<{
|
|
488
|
+
ok: boolean;
|
|
489
|
+
from: any;
|
|
490
|
+
refusals: any;
|
|
491
|
+
warnings: any;
|
|
492
|
+
text: string;
|
|
493
|
+
} | {
|
|
494
|
+
ok: boolean;
|
|
495
|
+
from: any;
|
|
496
|
+
routes: ({
|
|
497
|
+
kind: string;
|
|
498
|
+
key: any;
|
|
499
|
+
name: any;
|
|
500
|
+
trigger: string;
|
|
501
|
+
enforced: any[];
|
|
502
|
+
trusts: any[];
|
|
503
|
+
trust: any;
|
|
504
|
+
ceiling: string;
|
|
505
|
+
feeds: any[];
|
|
506
|
+
} | {
|
|
507
|
+
kind: string;
|
|
508
|
+
key: any;
|
|
509
|
+
name: any;
|
|
510
|
+
trigger: string;
|
|
511
|
+
enforced: any[];
|
|
512
|
+
trusts: any;
|
|
513
|
+
trust: null;
|
|
514
|
+
ceiling: string;
|
|
515
|
+
feeds: any[];
|
|
516
|
+
})[];
|
|
517
|
+
findings: any[];
|
|
518
|
+
tradeoffs: string;
|
|
519
|
+
text: string;
|
|
520
|
+
}>;
|
|
454
521
|
} | {
|
|
455
522
|
name: string;
|
|
456
523
|
annotations: {
|
|
@@ -570,7 +637,10 @@ export declare const tools: ({
|
|
|
570
637
|
name?: undefined;
|
|
571
638
|
fit?: undefined;
|
|
572
639
|
limit?: undefined;
|
|
573
|
-
spec
|
|
640
|
+
spec: {
|
|
641
|
+
type: string;
|
|
642
|
+
description: string;
|
|
643
|
+
};
|
|
574
644
|
file: {
|
|
575
645
|
type: string;
|
|
576
646
|
description: string;
|
package/types/play/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { checkSponsored, httpSponsor, sponsoredCost, sponsorGiveBack, sponsorHandler, sponsorSigner, sponsorTopUp, stepShape, topUpFor, SPONSOR_MAX_LAMPORTS, } from './sponsor.js';
|
|
1
2
|
/**
|
|
2
3
|
* A signer from a Wallet Standard wallet and one of its accounts: the wallet signs, the app sends. With the wallet's
|
|
3
4
|
* `solana:signMessage`, also `signMessage(bytes)`: the app's settle keys are made from one signature of it a session,
|
|
@@ -22,7 +23,7 @@ export declare const units: (amount: any, decimals: any) => bigint;
|
|
|
22
23
|
* be made again from the wallet's signature is kept, encrypted (`browserStore()` in a browser; null keeps keys in memory
|
|
23
24
|
* only).
|
|
24
25
|
*/
|
|
25
|
-
export declare function solanaApp({ spec, rpcUrl, rpc, wallet, programs, now, keyStore, }: {
|
|
26
|
+
export declare function solanaApp({ spec, rpcUrl, rpc, wallet, programs, now, keyStore, sponsor, }: {
|
|
26
27
|
keyStore?: {
|
|
27
28
|
get: (k: any) => string | null;
|
|
28
29
|
set: (k: any, v: any) => void;
|
|
@@ -35,6 +36,7 @@ export declare function solanaApp({ spec, rpcUrl, rpc, wallet, programs, now, ke
|
|
|
35
36
|
rpc?: null | undefined;
|
|
36
37
|
rpcUrl?: string | undefined;
|
|
37
38
|
spec: any;
|
|
39
|
+
sponsor?: null | undefined;
|
|
38
40
|
wallet: any;
|
|
39
41
|
}): {
|
|
40
42
|
project: any;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/** What a signature costs the fee payer, in lamports. */
|
|
2
|
+
export declare const SIGNATURE_LAMPORTS = 5000n;
|
|
3
|
+
/** The most a sponsored transaction may cost the sponsor by default: its top-up and its network fee, 0.01 SOL. */
|
|
4
|
+
export declare const SPONSOR_MAX_LAMPORTS = 10000000n;
|
|
5
|
+
/** The top-up: the sponsor's transfer to the player, first in the transaction. */
|
|
6
|
+
export declare const sponsorTopUp: (sponsor: any, player: any, lamports: any) => {
|
|
7
|
+
programId: string;
|
|
8
|
+
keys: {
|
|
9
|
+
pubkey: any;
|
|
10
|
+
isSigner: any;
|
|
11
|
+
isWritable: any;
|
|
12
|
+
}[];
|
|
13
|
+
data: Uint8Array<any>;
|
|
14
|
+
};
|
|
15
|
+
/** The give-back: what the step didn't need of the top-up, from the player back to the sponsor, last in the transaction. */
|
|
16
|
+
export declare const sponsorGiveBack: (sponsor: any, player: any, lamports: any) => {
|
|
17
|
+
programId: string;
|
|
18
|
+
keys: {
|
|
19
|
+
pubkey: any;
|
|
20
|
+
isSigner: any;
|
|
21
|
+
isWritable: any;
|
|
22
|
+
}[];
|
|
23
|
+
data: Uint8Array<any>;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* What a step cost in fees and rent, from the accounts it names before and after a dry run (`pre`, `post`: one each
|
|
27
|
+
* per address, null when there is none): what the project's fee box and the oracle took, and the full rent of each
|
|
28
|
+
* account it opened that loot, Core or a token program owns. Only what the program's own moves open counts: a token
|
|
29
|
+
* account counts when its mint is named by one of the step's loot instructions (`lootNamed`), and a Core asset when no
|
|
30
|
+
* instruction of the step calls Core itself (`programs`: the programs its instructions call), so a player can't open
|
|
31
|
+
* accounts of their own on the sponsor and close them for the rent. `skip`: the payer and the player.
|
|
32
|
+
* @param {{ addresses: string[], pre: ({ owner: string, lamports: number | bigint, data?: Uint8Array } | null)[],
|
|
33
|
+
* post: ({ owner: string, lamports: number | bigint, data?: Uint8Array } | null)[], project: string, skip?: string[],
|
|
34
|
+
* programs?: string[], lootNamed?: string[] }} input
|
|
35
|
+
* @returns {bigint}
|
|
36
|
+
*/
|
|
37
|
+
export declare function sponsoredCost({ addresses, pre, post, project, skip, programs, lootNamed }: {
|
|
38
|
+
addresses: string[];
|
|
39
|
+
pre: ({
|
|
40
|
+
owner: string;
|
|
41
|
+
lamports: number | bigint;
|
|
42
|
+
data?: Uint8Array;
|
|
43
|
+
} | null)[];
|
|
44
|
+
post: ({
|
|
45
|
+
owner: string;
|
|
46
|
+
lamports: number | bigint;
|
|
47
|
+
data?: Uint8Array;
|
|
48
|
+
} | null)[];
|
|
49
|
+
project: string;
|
|
50
|
+
skip?: string[];
|
|
51
|
+
programs?: string[];
|
|
52
|
+
lootNamed?: string[];
|
|
53
|
+
}): bigint;
|
|
54
|
+
/** The programs a step's instructions call, and every account its loot instructions name: what `sponsoredCost` reads. */
|
|
55
|
+
export declare function stepShape(instructions: any): {
|
|
56
|
+
programs: any[];
|
|
57
|
+
lootNamed: any[];
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* The top-up a step needs: what it cost the player (`spend`, before any top-up) bounded by its fees and rent
|
|
61
|
+
* (`cost`), never below 0. A step that leaves the player richer, or costs nothing, needs none.
|
|
62
|
+
*/
|
|
63
|
+
export declare const topUpFor: ({ spend, cost }: {
|
|
64
|
+
cost: any;
|
|
65
|
+
spend: any;
|
|
66
|
+
}) => any;
|
|
67
|
+
/**
|
|
68
|
+
* Whether the project's sponsor should sign this transaction (a wire, the player's signature in it): read it, dry-run
|
|
69
|
+
* it, and hold it to the rules above. Returns { ok: true, player, topUp, cost, lamports, message } (`topUp`: what the
|
|
70
|
+
* player kept of it, the top-up less the give-back; `lamports`: what it costs the sponsor, that and the network fee)
|
|
71
|
+
* or { ok: false, reason } in words.
|
|
72
|
+
* @param {Uint8Array} wire
|
|
73
|
+
* @param {{ rpc: any, project: string, sponsor: string, maxLamports?: bigint | number, maxPriorityMicroLamports?: bigint | number,
|
|
74
|
+
* budget?: ((ask: { player: string, lamports: bigint, topUp: bigint }) => boolean | Promise<boolean>) | null }} options
|
|
75
|
+
*/
|
|
76
|
+
export declare function checkSponsored(wire: Uint8Array, { rpc, project, sponsor, maxLamports, maxPriorityMicroLamports, budget }: {
|
|
77
|
+
rpc: any;
|
|
78
|
+
project: string;
|
|
79
|
+
sponsor: string;
|
|
80
|
+
maxLamports?: bigint | number;
|
|
81
|
+
maxPriorityMicroLamports?: bigint | number;
|
|
82
|
+
budget?: ((ask: {
|
|
83
|
+
player: string;
|
|
84
|
+
lamports: bigint;
|
|
85
|
+
topUp: bigint;
|
|
86
|
+
}) => boolean | Promise<boolean>) | null;
|
|
87
|
+
}): Promise<{
|
|
88
|
+
ok: boolean;
|
|
89
|
+
reason: any;
|
|
90
|
+
} | {
|
|
91
|
+
ok: boolean;
|
|
92
|
+
player: any;
|
|
93
|
+
topUp: bigint;
|
|
94
|
+
cost: bigint;
|
|
95
|
+
lamports: bigint;
|
|
96
|
+
message: any;
|
|
97
|
+
}>;
|
|
98
|
+
/**
|
|
99
|
+
* The project's server side: `sign(wire)` checks a transaction (`checkSponsored`) and, when it passes, returns it with
|
|
100
|
+
* the sponsor's signature; otherwise it throws the reason (`refused: true`). `sponsor.sign(message)`: the sponsor key's
|
|
101
|
+
* ed25519 signature of the message bytes, made by the project's server, which alone holds that key.
|
|
102
|
+
* @param {{ rpc: any, project: string, sponsor: { address: string, sign: (message: Uint8Array) => Uint8Array | Promise<Uint8Array> },
|
|
103
|
+
* maxLamports?: bigint | number, maxPriorityMicroLamports?: bigint | number,
|
|
104
|
+
* budget?: ((ask: { player: string, lamports: bigint, topUp: bigint }) => boolean | Promise<boolean>) | null }} options
|
|
105
|
+
*/
|
|
106
|
+
export declare function sponsorSigner({ rpc, project, sponsor, ...limits }: {
|
|
107
|
+
rpc: any;
|
|
108
|
+
project: string;
|
|
109
|
+
sponsor: {
|
|
110
|
+
address: string;
|
|
111
|
+
sign: (message: Uint8Array) => Uint8Array | Promise<Uint8Array>;
|
|
112
|
+
};
|
|
113
|
+
maxLamports?: bigint | number;
|
|
114
|
+
maxPriorityMicroLamports?: bigint | number;
|
|
115
|
+
budget?: ((ask: {
|
|
116
|
+
player: string;
|
|
117
|
+
lamports: bigint;
|
|
118
|
+
topUp: bigint;
|
|
119
|
+
}) => boolean | Promise<boolean>) | null;
|
|
120
|
+
}): {
|
|
121
|
+
address: string;
|
|
122
|
+
sign(wire: any): Promise<Uint8Array<any>>;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* The sponsor as an HTTP endpoint (a Next.js route, a Worker): POST { transaction } (base64) answers { transaction }
|
|
126
|
+
* signed, or 403 { error } in words. `signer`: a `sponsorSigner`.
|
|
127
|
+
* @param {Request} request
|
|
128
|
+
* @param {{ address: string, sign: (wire: Uint8Array) => Promise<Uint8Array> }} signer
|
|
129
|
+
* @returns {Promise<Response>}
|
|
130
|
+
*/
|
|
131
|
+
export declare function sponsorHandler(request: Request, signer: {
|
|
132
|
+
address: string;
|
|
133
|
+
sign: (wire: Uint8Array) => Promise<Uint8Array>;
|
|
134
|
+
}): Promise<Response>;
|
|
135
|
+
/**
|
|
136
|
+
* The app's side of a sponsor behind `url` (`sponsorHandler`): what `solanaApp({ sponsor })` takes. `address`: the
|
|
137
|
+
* sponsor's public key; `maxLamports`: the most it pays a transaction, as its server says.
|
|
138
|
+
* @param {{ url: string, address: string, maxLamports?: bigint | number, fetchImpl?: typeof fetch }} options
|
|
139
|
+
*/
|
|
140
|
+
export declare function httpSponsor({ url, address, maxLamports, fetchImpl }: {
|
|
141
|
+
url: string;
|
|
142
|
+
address: string;
|
|
143
|
+
maxLamports?: bigint | number;
|
|
144
|
+
fetchImpl?: typeof fetch;
|
|
145
|
+
}): {
|
|
146
|
+
address: string;
|
|
147
|
+
maxLamports: bigint;
|
|
148
|
+
sign(wire: any): Promise<Uint8Array<ArrayBuffer>>;
|
|
149
|
+
};
|
package/types/results/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { canonicalJson, CERT_KINDS, CLUSTERS, drawText, entryText, giveawayHostText, hostCertText, lockText, NO_GRANT, RESULT_DOMAIN, resultBytes, revokeGiveawayText, revokeText, rosterHash, } from './wire.js';
|
|
2
|
-
/**
|
|
2
|
+
/** xgames.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. */
|
|
5
5
|
export declare const newRound: () => string;
|
package/examples/holder-den.json
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 2,
|
|
3
|
-
"network": "devnet",
|
|
4
|
-
"name": "Holder Den",
|
|
5
|
-
"prompt": "Holders of our NFT collection stake them without the NFT leaving their wallet and earn 10 DUST a day each. Locking for 30 days doubles it, 90 days triples it. NFTs with a gold background earn 25% more. Every day staked adds a point to the NFT, which the game shows as its rank.",
|
|
6
|
-
"currency": "dust",
|
|
7
|
-
"tokens": [{ "key": "dust", "source": "project", "name": "Den Dust", "symbol": "DUST", "decimals": 6 }],
|
|
8
|
-
"collection": false,
|
|
9
|
-
"farms": [
|
|
10
|
-
{
|
|
11
|
-
"key": "den",
|
|
12
|
-
"name": "The Den",
|
|
13
|
-
"stakes": "collectibles",
|
|
14
|
-
"custody": "freeze",
|
|
15
|
-
"gate": { "collection": "5N3f6KXYGvtX4zCVD3DeQoEGbzahifQiFtkxfTfEyiRz" },
|
|
16
|
-
"rewards": "dust",
|
|
17
|
-
"rate": { "perDay": 10, "minted": true },
|
|
18
|
-
"tiers": [
|
|
19
|
-
{ "lock": "0d", "multiplier": 1 },
|
|
20
|
-
{ "lock": "30d", "multiplier": 2 },
|
|
21
|
-
{ "lock": "90d", "multiplier": 3 }
|
|
22
|
-
],
|
|
23
|
-
"boosts": [
|
|
24
|
-
{
|
|
25
|
-
"when": {
|
|
26
|
-
"collection": "5N3f6KXYGvtX4zCVD3DeQoEGbzahifQiFtkxfTfEyiRz",
|
|
27
|
-
"attribute": "Background",
|
|
28
|
-
"equals": "Gold"
|
|
29
|
-
},
|
|
30
|
-
"add": { "addPercent": 25 }
|
|
31
|
-
}
|
|
32
|
-
],
|
|
33
|
-
"maxBoostPercent": 25,
|
|
34
|
-
"growth": { "attribute": "points", "perDay": 1 }
|
|
35
|
-
}
|
|
36
|
-
],
|
|
37
|
-
"scenario": { "days": 90, "perDay": { "farm:den": 30 }, "staked": { "den": 1500 } }
|
|
38
|
-
}
|