@xgamesfun/solana 0.25.1 → 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/README.md +57 -12
- package/bin/xsolana.mjs +10 -2
- package/js/client/index.js +1 -0
- package/js/client/kit.js +36 -0
- package/js/mcp/http.mjs +136 -0
- package/js/mcp/server.mjs +33 -9
- package/js/mcp/tools.mjs +24 -1
- package/js/play/index.js +116 -2
- package/js/play/sponsor.js +302 -0
- package/package.json +35 -8
- package/release.json +1 -1
- package/skills/xsolana-economy/SKILL.md +6 -3
- package/skills/xsolana-economy/references/apps.md +28 -0
- package/types/client/index.d.ts +1 -0
- package/types/client/kit.d.ts +49 -0
- package/types/economy/plan.d.mts +14 -14
- package/types/mcp/http.d.mts +30 -0
- package/types/mcp/server.d.mts +321 -0
- package/types/mcp/tools.d.mts +9 -1
- package/types/play/index.d.ts +9 -7
- package/types/play/sponsor.d.ts +149 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** The largest request body read: a spec is a few kilobytes; a megabyte is far more than any. */
|
|
2
|
+
export declare const MAX_BODY_BYTES = 1000000;
|
|
3
|
+
/**
|
|
4
|
+
* One HTTP request to the MCP endpoint, answered. `allowOrigin(origin)` decides which browser origins may call it (a
|
|
5
|
+
* request with no Origin header, from a server or a desktop app, always may); by default every origin, since the
|
|
6
|
+
* endpoint holds no session, no cookie and nothing private.
|
|
7
|
+
* @param {Request} request
|
|
8
|
+
* @param {{ allowOrigin?: (origin: string) => boolean, maxBodyBytes?: number, ctx?: object }} [options]
|
|
9
|
+
* @returns {Promise<Response>}
|
|
10
|
+
*/
|
|
11
|
+
export declare function mcpHttp(request: Request, { allowOrigin, maxBodyBytes, ctx }?: {
|
|
12
|
+
allowOrigin?: (origin: string) => boolean;
|
|
13
|
+
maxBodyBytes?: number;
|
|
14
|
+
ctx?: object;
|
|
15
|
+
}): Promise<Response>;
|
|
16
|
+
/**
|
|
17
|
+
* Serves mcpHttp at `path` on this machine (`xsolana mcp --http`). It listens on 127.0.0.1 unless told otherwise, and
|
|
18
|
+
* then answers only pages on localhost: a site in the browser can't reach it by renaming its host (DNS rebinding).
|
|
19
|
+
* @returns {Promise<{ address(): { port: number } | string | null, close(done?: () => void): unknown }>} the node:http server
|
|
20
|
+
*/
|
|
21
|
+
export declare function serveHttp({ port, host, path }?: {
|
|
22
|
+
host?: string | undefined;
|
|
23
|
+
path?: string | undefined;
|
|
24
|
+
port?: number | undefined;
|
|
25
|
+
}): Promise<{
|
|
26
|
+
address(): {
|
|
27
|
+
port: number;
|
|
28
|
+
} | string | null;
|
|
29
|
+
close(done?: () => void): unknown;
|
|
30
|
+
}>;
|
|
@@ -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.
|
|
@@ -632,7 +637,10 @@ export declare const tools: ({
|
|
|
632
637
|
name?: undefined;
|
|
633
638
|
fit?: undefined;
|
|
634
639
|
limit?: undefined;
|
|
635
|
-
spec
|
|
640
|
+
spec: {
|
|
641
|
+
type: string;
|
|
642
|
+
description: string;
|
|
643
|
+
};
|
|
636
644
|
file: {
|
|
637
645
|
type: string;
|
|
638
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;
|
|
@@ -735,17 +737,18 @@ export declare function solanaApp({ spec, rpcUrl, rpc, wallet, programs, now, ke
|
|
|
735
737
|
* it (base units, as text). Pass one to `claim`.
|
|
736
738
|
*/
|
|
737
739
|
claims(): Promise<({
|
|
740
|
+
key?: undefined;
|
|
738
741
|
tree?: undefined;
|
|
739
742
|
kind: string;
|
|
740
743
|
order: any;
|
|
741
744
|
says: string;
|
|
742
745
|
hold?: undefined;
|
|
743
|
-
key?: undefined;
|
|
744
746
|
round?: undefined;
|
|
745
747
|
pulls?: undefined;
|
|
746
748
|
asset?: undefined;
|
|
747
749
|
table?: undefined;
|
|
748
750
|
} | {
|
|
751
|
+
key?: undefined;
|
|
749
752
|
tree?: undefined;
|
|
750
753
|
order?: undefined;
|
|
751
754
|
kind: string;
|
|
@@ -755,30 +758,29 @@ export declare function solanaApp({ spec, rpcUrl, rpc, wallet, programs, now, ke
|
|
|
755
758
|
potUnits?: string | undefined;
|
|
756
759
|
prizeUnits?: string | undefined;
|
|
757
760
|
hold?: undefined;
|
|
758
|
-
key?: undefined;
|
|
759
761
|
round?: undefined;
|
|
760
762
|
pulls?: undefined;
|
|
761
763
|
asset?: undefined;
|
|
762
764
|
table?: undefined;
|
|
763
765
|
} | {
|
|
766
|
+
key?: undefined;
|
|
764
767
|
tree?: undefined;
|
|
765
768
|
order?: undefined;
|
|
766
769
|
kind: string;
|
|
767
770
|
asset: any;
|
|
768
771
|
hold: any;
|
|
769
772
|
says: string;
|
|
770
|
-
key?: undefined;
|
|
771
773
|
round?: undefined;
|
|
772
774
|
pulls?: undefined;
|
|
773
775
|
table?: undefined;
|
|
774
776
|
} | {
|
|
777
|
+
key?: undefined;
|
|
775
778
|
order?: undefined;
|
|
776
779
|
hold?: undefined;
|
|
777
780
|
kind: string;
|
|
778
781
|
asset: string;
|
|
779
782
|
tree: string;
|
|
780
783
|
says: string;
|
|
781
|
-
key?: undefined;
|
|
782
784
|
round?: undefined;
|
|
783
785
|
pulls?: undefined;
|
|
784
786
|
table?: undefined;
|
|
@@ -816,10 +818,10 @@ export declare function solanaApp({ spec, rpcUrl, rpc, wallet, programs, now, ke
|
|
|
816
818
|
asset?: undefined;
|
|
817
819
|
table?: undefined;
|
|
818
820
|
} | {
|
|
821
|
+
key?: undefined;
|
|
819
822
|
tree?: undefined;
|
|
820
823
|
order?: undefined;
|
|
821
824
|
hold?: undefined;
|
|
822
|
-
key?: undefined;
|
|
823
825
|
round?: undefined;
|
|
824
826
|
pulls?: undefined;
|
|
825
827
|
kind: string;
|
|
@@ -827,10 +829,10 @@ export declare function solanaApp({ spec, rpcUrl, rpc, wallet, programs, now, ke
|
|
|
827
829
|
says: string;
|
|
828
830
|
table?: undefined;
|
|
829
831
|
} | {
|
|
832
|
+
key?: undefined;
|
|
830
833
|
tree?: undefined;
|
|
831
834
|
order?: undefined;
|
|
832
835
|
hold?: undefined;
|
|
833
|
-
key?: undefined;
|
|
834
836
|
round?: undefined;
|
|
835
837
|
pulls?: undefined;
|
|
836
838
|
asset?: undefined;
|
|
@@ -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
|
+
};
|