@bordrless/shared 0.2.0 → 0.3.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/dist/api.d.ts CHANGED
@@ -145,6 +145,10 @@ export interface ConfigInspection {
145
145
  registryReady: boolean | null;
146
146
  /** The hook is Half-Life: the launch prepares it for the mint and lights its furnace itself. */
147
147
  halfLife?: boolean;
148
+ /** A listed config's author share of the creator fee (bps of it), paid on a launch by anyone but its author; 0 for a plain config. */
149
+ authorShareBps: number;
150
+ /** The hook was built and deployed by Studio: the launch prepares it for the mint itself (its standard `prepare`). */
151
+ studioHook?: boolean;
148
152
  }
149
153
  /** Live figures of a launch's token rules; each null when the launch lacks the rule or it is not tracked. */
150
154
  export interface RuleStats {
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './api.ts';
2
2
  export * from './policy.ts';
3
3
  export * from './programs.ts';
4
+ export * from './studio.ts';
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./api.js";
2
2
  export * from "./policy.js";
3
3
  export * from "./programs.js";
4
+ export * from "./studio.js";
@@ -0,0 +1,333 @@
1
+ /**
2
+ * Studio and the config marketplace: the shapes the site and the backend exchange.
3
+ *
4
+ * Studio is where anyone designs a launch config, and optionally a token hook of their own, with an
5
+ * assistant that knows the Bordrless programs; has it reviewed; pays the rent for Bordrless to build
6
+ * and deploy the hook (its upgrade authority then handed to them); makes the config; and may list it
7
+ * on the marketplace, where every launch someone else makes from it pays them their share of the
8
+ * creator fee (`create_listed_config`, docs/hooks-v2.md §5.7).
9
+ *
10
+ * A Studio hook is written against one template (`STUDIO_TEMPLATE`): an Anchor program with a fixed
11
+ * `Cargo.toml` and the standard `prepare` (`STUDIO_PREPARE`), so the site can prepare any Studio hook
12
+ * for a new mint without knowing its code. The backend refuses source that leaves the template's
13
+ * limits (`StaticCheck`) before it is built, reviewed or paid for.
14
+ */
15
+ import type { Address, PreparedTx } from './api.ts';
16
+ /** One source file of a hook. Only `src/**.rs` files; `Cargo.toml` is the template's and never sent. */
17
+ export interface StudioFile {
18
+ /** Relative path, e.g. `src/lib.rs`. */
19
+ path: string;
20
+ content: string;
21
+ }
22
+ /** What a project becomes: a config of existing rules alone, or a config with its own hook program. */
23
+ export type StudioKind = 'config' | 'hook';
24
+ /** The launch config a project makes (the arguments of `create_config` / `create_listed_config`). */
25
+ export interface StudioConfigDraft {
26
+ /** At most 32 bytes. */
27
+ label: string;
28
+ creatorFeeBps: number;
29
+ burnBuyBps: number;
30
+ burnSellBps: number;
31
+ /** Kit rules, for a `config` project only (a hook of one's own excludes them). */
32
+ holderFeeBuyBps: number;
33
+ holderFeeSellBps: number;
34
+ maxWalletBps: number;
35
+ creatorLockDays: number;
36
+ earlyWindowSecs: number;
37
+ earlyLockSecs: number;
38
+ /** `TOKEN_HOOK_FLAGS` the hook runs on, for a `hook` project; 0 for a `config` project. */
39
+ hookFlags: number;
40
+ /** List it on the marketplace (made with `create_listed_config`). */
41
+ listed: boolean;
42
+ /** The author's share of the creator fee on others' launches, bps of it: 1 to `MAX_AUTHOR_SHARE_BPS`. */
43
+ authorShareBps: number;
44
+ }
45
+ /** Where a project stands, in the order the Studio walks it. */
46
+ export type StudioStage = 'draft' | 'reviewed' | 'built' | 'paid' | 'deploying' | 'deployed' | 'configured' | 'listed';
47
+ export interface StudioProjectSummary {
48
+ id: string;
49
+ owner: Address;
50
+ name: string;
51
+ kind: StudioKind;
52
+ stage: StudioStage;
53
+ /** The deployed hook, once deployed. */
54
+ programId: Address | null;
55
+ /** The config made from it, once made. */
56
+ config: Address | null;
57
+ updatedAt: number;
58
+ }
59
+ export interface StudioProject extends StudioProjectSummary {
60
+ /** A one-paragraph description, shown on the marketplace when listed. */
61
+ description: string;
62
+ files: StudioFile[];
63
+ draft: StudioConfigDraft;
64
+ /** The last review of the current source; null when the source changed since. */
65
+ review: StudioReview | null;
66
+ /** The last build of the current source; null when the source changed since. */
67
+ build: StudioBuild | null;
68
+ deploy: StudioDeploy | null;
69
+ createdAt: number;
70
+ }
71
+ export interface StudioProjectCreateRequest {
72
+ name: string;
73
+ kind: StudioKind;
74
+ /** Start from a template (`STUDIO_STARTERS`), or blank. */
75
+ starter?: string;
76
+ }
77
+ /** A save: any of the fields; files replace the whole set. Changing files drops the review and the build. */
78
+ export interface StudioProjectUpdateRequest {
79
+ name?: string;
80
+ description?: string;
81
+ files?: StudioFile[];
82
+ draft?: Partial<StudioConfigDraft>;
83
+ }
84
+ /** `POST /v1/studio/session`: the wallet signs `message` (from `studioSignInMessage`), the backend answers a session token. */
85
+ export interface StudioSessionRequest {
86
+ wallet: Address;
87
+ /** The exact message signed. */
88
+ message: string;
89
+ /** Base58 ed25519 signature of the message's UTF-8 bytes. */
90
+ signature: string;
91
+ }
92
+ export interface StudioSessionResponse {
93
+ token: string;
94
+ wallet: Address;
95
+ expiresAt: number;
96
+ /** What the assistant still allows this wallet today. */
97
+ quota: StudioQuota;
98
+ }
99
+ export interface StudioQuota {
100
+ /** Assistant messages left today (UTC). */
101
+ messagesLeft: number;
102
+ messagesPerDay: number;
103
+ /** The assistant is off for everyone (no key, or today's budget spent). */
104
+ assistantOff: boolean;
105
+ }
106
+ /** The message a wallet signs to use Studio: no transaction, nothing moves. */
107
+ export declare function studioSignInMessage(wallet: Address, nonce: string, issuedAt: string): string;
108
+ /** The header the session token travels in, browser → site proxy → backend. */
109
+ export declare const STUDIO_SESSION_HEADER = "x-studio-session";
110
+ export interface StudioMessage {
111
+ id: string;
112
+ role: 'user' | 'assistant';
113
+ /** Markdown. An assistant message may carry proposals (below) as fenced blocks. */
114
+ content: string;
115
+ at: number;
116
+ /** For an assistant message: the changes it proposes, parsed from its fenced blocks. */
117
+ proposal: StudioProposal | null;
118
+ }
119
+ /**
120
+ * What an assistant reply proposes: whole files (```rust file=src/lib.rs fences) and config
121
+ * fields (a ```json studio-config fence). The Studio shows them as a diff to apply or dismiss.
122
+ */
123
+ export interface StudioProposal {
124
+ files: StudioFile[];
125
+ draft: Partial<StudioConfigDraft> | null;
126
+ /** Applied by the user (the project's files or draft were replaced by it). */
127
+ applied: boolean;
128
+ }
129
+ /** `POST /v1/studio/projects/:id/chat`: one user message; the reply is produced in the background. */
130
+ export interface StudioChatRequest {
131
+ content: string;
132
+ }
133
+ export interface StudioChatResponse {
134
+ job: string;
135
+ /** The user's message as stored. */
136
+ message: StudioMessage;
137
+ quota: StudioQuota;
138
+ }
139
+ /** `GET /v1/studio/chat/:job`: the reply so far; poll until `state` is not `running`. */
140
+ export interface StudioChatJob {
141
+ job: string;
142
+ state: 'running' | 'done' | 'failed';
143
+ /** The reply's text so far (all of it once done). */
144
+ text: string;
145
+ /** Once done: the stored message, its proposal parsed. */
146
+ message: StudioMessage | null;
147
+ error: string | null;
148
+ }
149
+ /** One of the template's limits, checked on the source before anything else (no model involved). */
150
+ export interface StaticCheck {
151
+ id: string;
152
+ ok: boolean;
153
+ /** What is checked, in words. */
154
+ label: string;
155
+ /** Where it failed: `src/lib.rs:42` and the offending text. */
156
+ detail: string | null;
157
+ }
158
+ export type FindingSeverity = 'critical' | 'high' | 'medium' | 'low' | 'info';
159
+ export interface ReviewFinding {
160
+ severity: FindingSeverity;
161
+ title: string;
162
+ detail: string;
163
+ /** `src/lib.rs:42`, when it points at a line. */
164
+ location: string | null;
165
+ }
166
+ /** `POST /v1/studio/projects/:id/review`: the static checks, then the assistant's security review. */
167
+ export interface StudioReview {
168
+ /** `fail`: a static check failed or a critical/high finding; deploy is refused. */
169
+ verdict: 'pass' | 'warn' | 'fail';
170
+ checks: StaticCheck[];
171
+ findings: ReviewFinding[];
172
+ /** A short paragraph: what the hook does, as the reviewer read it. */
173
+ summary: string;
174
+ /** sha256 of the source reviewed. */
175
+ sourceHash: string;
176
+ at: number;
177
+ }
178
+ /** `POST /v1/studio/projects/:id/build`: compiled by the build worker in the verifiable-build image. */
179
+ export interface StudioBuild {
180
+ state: 'queued' | 'building' | 'ok' | 'failed';
181
+ /** The program id the source was built for (its `declare_id!`), reserved for this project. */
182
+ programId: Address;
183
+ /** sha256 of the program binary (what `solana-verify get-executable-hash` prints). */
184
+ hash: string | null;
185
+ bytes: number | null;
186
+ /** The compiler's output, its tail. */
187
+ log: string;
188
+ sourceHash: string;
189
+ at: number;
190
+ }
191
+ /** `POST /v1/studio/projects/:id/deploy/quote`: what deploying the built hook costs, in lamports. */
192
+ export interface StudioDeployQuote {
193
+ /** Rent of the program's data account (the binary plus room to upgrade: `maxDataLen`). */
194
+ programDataRent: string;
195
+ /** Rent of the program account. */
196
+ programRent: string;
197
+ /** Transaction fees of writing and deploying it. */
198
+ fees: string;
199
+ /** Bordrless's service fee. */
200
+ service: string;
201
+ total: string;
202
+ maxDataLen: number;
203
+ /** The wallet the payment goes to (Studio's deployer). */
204
+ payTo: Address;
205
+ /** The payment transaction: a plain SOL transfer of `total` with a memo naming this deploy. */
206
+ transactions: PreparedTx[];
207
+ /** The quote holds until then (unix seconds). */
208
+ expiresAt: number;
209
+ }
210
+ export interface StudioDeployRequest {
211
+ /** The confirmed payment transaction. */
212
+ paymentSignature: string;
213
+ /** Hand the upgrade authority to the owner (default), or make the program final. */
214
+ authority: 'owner' | 'final';
215
+ }
216
+ export type StudioDeployState = 'awaiting_payment' | 'paid' | 'writing' | 'deploying' | 'handing_over' | 'deployed' | 'failed' | 'refunded';
217
+ export interface StudioDeploy {
218
+ state: StudioDeployState;
219
+ programId: Address;
220
+ /** Lamports paid, and the payment. */
221
+ paid: string | null;
222
+ paymentSignature: string | null;
223
+ /** Bytes written of the binary, while writing. */
224
+ written: number;
225
+ bytes: number;
226
+ deploySignature: string | null;
227
+ /** Who can upgrade it now: the owner, or null once final. */
228
+ upgradeAuthority: Address | null;
229
+ error: string | null;
230
+ refundSignature: string | null;
231
+ at: number;
232
+ }
233
+ /** `POST /v1/studio/projects/:id/config/prepare`: `create_config` or `create_listed_config` for the draft. */
234
+ export interface StudioConfigPrepareRequest {
235
+ /** A fresh keypair's address the browser made; it signs after the wallet. */
236
+ config: Address;
237
+ }
238
+ export interface StudioConfigPrepareResponse {
239
+ config: Address;
240
+ transactions: PreparedTx[];
241
+ }
242
+ export interface MarketplaceListing {
243
+ config: Address;
244
+ author: Address;
245
+ /** The config's on-chain label. */
246
+ label: string;
247
+ /** The author's title and description (from Studio), or the label alone. */
248
+ title: string;
249
+ description: string;
250
+ authorShareBps: number;
251
+ creatorFeeBps: number;
252
+ burnBuyBps: number;
253
+ burnSellBps: number;
254
+ holderFeeBuyBps: number;
255
+ holderFeeSellBps: number;
256
+ maxWalletBps: number;
257
+ customHook: Address | null;
258
+ customHookFlags: number;
259
+ /** The hook was built and deployed by Studio from source anyone can read. */
260
+ studioSource: boolean;
261
+ /** Who can upgrade the hook now (null: final, or no hook). */
262
+ hookUpgradeAuthority: Address | null;
263
+ /** The source passed review when it was deployed. */
264
+ reviewVerdict: 'pass' | 'warn' | null;
265
+ launches: number;
266
+ /** Paid to the author so far, lamports. */
267
+ authorEarned: string;
268
+ volumeUsd: number | null;
269
+ createdAt: number;
270
+ }
271
+ export interface MarketplaceListResponse {
272
+ listings: MarketplaceListing[];
273
+ total: number;
274
+ }
275
+ export interface MarketplaceDetail extends MarketplaceListing {
276
+ /** The hook's source when Studio built it. */
277
+ files: StudioFile[] | null;
278
+ buildHash: string | null;
279
+ review: StudioReview | null;
280
+ /** Launches made from it, newest first. */
281
+ recentLaunches: {
282
+ mint: Address;
283
+ symbol: string;
284
+ name: string;
285
+ image: string | null;
286
+ createdAt: number;
287
+ }[];
288
+ }
289
+ /** `POST /v1/author/prepare`: a config author's claims of their share, on up to four launches a transaction, paid as SOL. */
290
+ export interface AuthorPrepareRequest {
291
+ author: Address;
292
+ /** The launches to claim on; all with something to claim when absent. */
293
+ mints?: Address[];
294
+ }
295
+ export interface AuthorEarnings {
296
+ author: Address;
297
+ /** Waiting to be claimed on each launch: the author's part of what the launch holds. */
298
+ launches: {
299
+ mint: Address;
300
+ symbol: string;
301
+ config: Address;
302
+ claimable: string;
303
+ paid: string;
304
+ }[];
305
+ claimable: string;
306
+ paid: string;
307
+ }
308
+ /** `bordrless_launch::constants::MAX_AUTHOR_SHARE_BPS`: half the creator fee. */
309
+ export declare const MAX_AUTHOR_SHARE_BPS = 5000;
310
+ /** The share the Studio suggests. */
311
+ export declare const DEFAULT_AUTHOR_SHARE_BPS = 2000;
312
+ /**
313
+ * The standard `prepare` of a Studio hook: `prepare()` (no arguments) with the accounts
314
+ * `[payer (signer, writable), mint, state = PDA(["state", mint], hook) (writable), registry =
315
+ * PDA(["bordrless-hook-accounts", mint], hook) (writable), system program]`. It creates the hook's
316
+ * state for the mint and writes its registry; anyone may send it, once per mint.
317
+ */
318
+ export declare const STUDIO_PREPARE: {
319
+ readonly instruction: "prepare";
320
+ readonly stateSeed: "state";
321
+ };
322
+ /** Limits of a project's source. */
323
+ export declare const STUDIO_LIMITS: {
324
+ readonly files: 8;
325
+ readonly bytes: 120000;
326
+ readonly messageChars: 8000;
327
+ };
328
+ /** Starters a new hook project can begin from (the template's `src/lib.rs` variants). */
329
+ export declare const STUDIO_STARTERS: readonly {
330
+ id: string;
331
+ name: string;
332
+ blurb: string;
333
+ }[];
package/dist/studio.js ADDED
@@ -0,0 +1,26 @@
1
+ /** The message a wallet signs to use Studio: no transaction, nothing moves. */
2
+ export function studioSignInMessage(wallet, nonce, issuedAt) {
3
+ return ['Sign in to Bordrless Studio', '', 'This signature proves you own this wallet. It does not move funds or approve any transaction.', '', `Wallet: ${wallet}`, `Nonce: ${nonce}`, `Issued: ${issuedAt}`].join('\n');
4
+ }
5
+ /** The header the session token travels in, browser → site proxy → backend. */
6
+ export const STUDIO_SESSION_HEADER = 'x-studio-session';
7
+ // ---- constants ----------------------------------------------------------------------------------------
8
+ /** `bordrless_launch::constants::MAX_AUTHOR_SHARE_BPS`: half the creator fee. */
9
+ export const MAX_AUTHOR_SHARE_BPS = 5_000;
10
+ /** The share the Studio suggests. */
11
+ export const DEFAULT_AUTHOR_SHARE_BPS = 2_000;
12
+ /**
13
+ * The standard `prepare` of a Studio hook: `prepare()` (no arguments) with the accounts
14
+ * `[payer (signer, writable), mint, state = PDA(["state", mint], hook) (writable), registry =
15
+ * PDA(["bordrless-hook-accounts", mint], hook) (writable), system program]`. It creates the hook's
16
+ * state for the mint and writes its registry; anyone may send it, once per mint.
17
+ */
18
+ export const STUDIO_PREPARE = { instruction: 'prepare', stateSeed: 'state' };
19
+ /** Limits of a project's source. */
20
+ export const STUDIO_LIMITS = { files: 8, bytes: 120_000, messageChars: 8_000 };
21
+ /** Starters a new hook project can begin from (the template's `src/lib.rs` variants). */
22
+ export const STUDIO_STARTERS = [
23
+ { id: 'blank', name: 'Blank hook', blurb: 'The template: every callback stubbed, nothing taken, nothing refused.' },
24
+ { id: 'sell-tax', name: 'Sell tax to a wallet', blurb: 'A cut of every sell sent to a wallet you choose; buys and transfers pass free.' },
25
+ { id: 'cooldown', name: 'Transfer cooldown', blurb: 'A holding that received tokens cannot send them on for a while, stamped in its hook data.' },
26
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bordrless/shared",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "description": "Bordrless policy (the same math as crates/bordrless-core), program addresses and the API types shared by the server and the site. No Solana dependencies.",
6
6
  "license": "Apache-2.0",