@bropump/sdk 0.2.1 → 0.2.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 +170 -19
- package/dist/client.js +1 -1
- package/dist/types.d.ts +9 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,53 +4,204 @@ TypeScript SDK for the BroPump API.
|
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
|
-
Install from public npmjs:
|
|
8
|
-
|
|
9
7
|
```bash
|
|
10
8
|
npm install @bropump/sdk
|
|
11
9
|
```
|
|
12
10
|
|
|
13
|
-
##
|
|
11
|
+
## Create a Client
|
|
12
|
+
|
|
13
|
+
Use the built-in network presets for the normal app environments:
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
import { BroPumpClient } from '@bropump/sdk'
|
|
17
17
|
|
|
18
|
+
const mainnet = new BroPumpClient({ network: 'mainnet' })
|
|
19
|
+
const devnet = new BroPumpClient({ network: 'devnet' })
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The SDK resolves hosts automatically:
|
|
23
|
+
|
|
24
|
+
- `mainnet` -> `https://api.bropump.run`
|
|
25
|
+
- `devnet` -> `https://dev.bropump.run`
|
|
26
|
+
|
|
27
|
+
If you need local or preview infrastructure, keep using `baseUrl` as an override:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
18
30
|
const client = new BroPumpClient({
|
|
19
|
-
network: '
|
|
31
|
+
network: 'devnet',
|
|
32
|
+
baseUrl: 'http://localhost:3001',
|
|
20
33
|
})
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Config Modes
|
|
37
|
+
|
|
38
|
+
Launch selection is driven by Cloudflare config binding names, not raw threshold numbers.
|
|
39
|
+
|
|
40
|
+
Fetch the currently available modes from the API:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
const launchConfig = await client.launchConfig.get()
|
|
44
|
+
|
|
45
|
+
console.log(launchConfig.defaultConfigMode)
|
|
46
|
+
console.log(launchConfig.availableConfigModes)
|
|
47
|
+
console.log(launchConfig.configModeOptions)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Each option includes:
|
|
51
|
+
|
|
52
|
+
- `configMode`, for example `MAINNET_CONFIG_25`
|
|
53
|
+
- `migrationThreshold`, the resolved quote target behind that mode
|
|
54
|
+
- `configAddress`
|
|
55
|
+
- `deploymentMode`
|
|
56
|
+
|
|
57
|
+
## Launch a Token
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { BroPumpClient, BroPumpTokenFailedError } from '@bropump/sdk'
|
|
61
|
+
|
|
62
|
+
const client = new BroPumpClient({ network: 'devnet' })
|
|
21
63
|
|
|
22
64
|
const token = await client.tokens.create({
|
|
65
|
+
mode: 'live',
|
|
23
66
|
name: 'Bro Pump',
|
|
24
67
|
symbol: 'BRO',
|
|
25
68
|
description: 'Simple token flow',
|
|
26
69
|
deployer: 'YOUR_WALLET',
|
|
27
|
-
|
|
70
|
+
configMode: 'DEVNET_CONFIG_1',
|
|
71
|
+
firstBuyAmount: 0.25,
|
|
28
72
|
image: new Blob(['demo'], { type: 'image/png' }),
|
|
29
73
|
})
|
|
30
74
|
|
|
31
|
-
|
|
75
|
+
try {
|
|
76
|
+
const ready = await client.tokens.waitForReadyToSign(token.id)
|
|
77
|
+
|
|
78
|
+
await client.tokens.submitSigned(token.id, {
|
|
79
|
+
submitId: ready.submit.id,
|
|
80
|
+
signedTransactions: [
|
|
81
|
+
/* signed base64 transactions */
|
|
82
|
+
],
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
const live = await client.tokens.waitForLive(token.id)
|
|
86
|
+
console.log(live.pool, live.mint)
|
|
87
|
+
} catch (error) {
|
|
88
|
+
if (error instanceof BroPumpTokenFailedError) {
|
|
89
|
+
console.error(error.token.error)
|
|
90
|
+
}
|
|
91
|
+
throw error
|
|
92
|
+
}
|
|
93
|
+
```
|
|
32
94
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
95
|
+
## Preview Fees and Curve Data
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
const preview = await client.fees.preview({
|
|
99
|
+
configMode: 'MAINNET_CONFIG_25',
|
|
100
|
+
firstBuyAmount: 0.5,
|
|
101
|
+
deployerWallet: 'YOUR_WALLET',
|
|
36
102
|
})
|
|
103
|
+
|
|
104
|
+
console.log(preview.selectedConfigMode)
|
|
105
|
+
console.log(preview.curve.migrationThreshold)
|
|
106
|
+
console.log(preview.costQuote.recommendedMinBalanceSol)
|
|
37
107
|
```
|
|
38
108
|
|
|
39
|
-
|
|
109
|
+
## Polling Helpers
|
|
110
|
+
|
|
111
|
+
The SDK includes built-in polling helpers for the common launch lifecycle checkpoints:
|
|
112
|
+
|
|
113
|
+
- `client.tokens.waitForReadyToSign(id, options)`
|
|
114
|
+
- `client.tokens.waitForLive(id, options)`
|
|
115
|
+
- `client.tokens.waitFor(id, predicate, options)`
|
|
116
|
+
|
|
117
|
+
All wait helpers accept:
|
|
118
|
+
|
|
119
|
+
- `timeoutMs`
|
|
120
|
+
- `pollIntervalMs`
|
|
121
|
+
- `signal`
|
|
122
|
+
- `stopOnFailed`
|
|
123
|
+
|
|
124
|
+
## Realtime / WSS
|
|
125
|
+
|
|
126
|
+
You do not need to manage a separate websocket host manually. The SDK derives `ws://` or `wss://`
|
|
127
|
+
from the API base URL automatically.
|
|
128
|
+
|
|
129
|
+
### Watch a Token Session
|
|
40
130
|
|
|
41
131
|
```ts
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
132
|
+
const stream = await client.tokens.watch(token.id)
|
|
133
|
+
|
|
134
|
+
for await (const message of stream) {
|
|
135
|
+
console.log(message.type, message.data)
|
|
136
|
+
|
|
137
|
+
if (message.type === 'token_update' && message.data?.status === 'live') {
|
|
138
|
+
break
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
stream.close()
|
|
45
143
|
```
|
|
46
144
|
|
|
47
|
-
|
|
145
|
+
### Wait for a Specific Realtime Event
|
|
48
146
|
|
|
49
|
-
|
|
147
|
+
```ts
|
|
148
|
+
const stream = await client.tokens.watch(token.id)
|
|
50
149
|
|
|
51
|
-
|
|
150
|
+
const readyMessage = await stream.waitFor(
|
|
151
|
+
(message) =>
|
|
152
|
+
message.type === 'token_update' &&
|
|
153
|
+
Boolean(message.data?.submit?.id),
|
|
154
|
+
30_000
|
|
155
|
+
)
|
|
52
156
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
157
|
+
console.log(readyMessage.data?.submit?.id)
|
|
158
|
+
stream.close()
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Watch a Pool Directly
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
const poolStream = await client.tokens.watchPool('POOL_ADDRESS')
|
|
165
|
+
|
|
166
|
+
for await (const message of poolStream) {
|
|
167
|
+
console.log(message.type, message.data?.runtime?.phase)
|
|
168
|
+
}
|
|
56
169
|
```
|
|
170
|
+
|
|
171
|
+
Common message types:
|
|
172
|
+
|
|
173
|
+
- `token_snapshot`
|
|
174
|
+
- `token_update`
|
|
175
|
+
- `launch_snapshot`
|
|
176
|
+
- `launch_update`
|
|
177
|
+
- `runtime_snapshot`
|
|
178
|
+
- `runtime_update`
|
|
179
|
+
|
|
180
|
+
## Manual WSS URL Access
|
|
181
|
+
|
|
182
|
+
If you need the derived websocket URL for your own socket layer, use `buildWebSocketUrl`:
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
import { buildWebSocketUrl } from '@bropump/sdk'
|
|
186
|
+
|
|
187
|
+
const wsUrl = buildWebSocketUrl('https://dev.bropump.run', '/tokens/123/ws')
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Errors
|
|
191
|
+
|
|
192
|
+
Request failures throw `BroPumpApiError`:
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
import { BroPumpApiError } from '@bropump/sdk'
|
|
196
|
+
|
|
197
|
+
try {
|
|
198
|
+
await client.health()
|
|
199
|
+
} catch (error) {
|
|
200
|
+
if (error instanceof BroPumpApiError) {
|
|
201
|
+
console.error(error.status, error.code, error.body)
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Lifecycle polling helpers throw `BroPumpTokenFailedError` when a token reaches `failed` while
|
|
207
|
+
you are waiting on it.
|
package/dist/client.js
CHANGED
|
@@ -198,7 +198,7 @@ function buildCreateTokenFormData(input) {
|
|
|
198
198
|
appendFormValue(form, 'symbol', input.symbol);
|
|
199
199
|
appendFormValue(form, 'description', input.description);
|
|
200
200
|
appendFormValue(form, 'deployer', input.deployer);
|
|
201
|
-
appendFormValue(form, '
|
|
201
|
+
appendFormValue(form, 'configMode', input.configMode);
|
|
202
202
|
appendFormValue(form, 'firstBuyAmount', input.firstBuyAmount);
|
|
203
203
|
appendFormValue(form, 'x', input.x);
|
|
204
204
|
appendFormValue(form, 'website', input.website);
|
package/dist/types.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export type CreateTokenInput = {
|
|
|
38
38
|
symbol: string;
|
|
39
39
|
description: string;
|
|
40
40
|
deployer: string;
|
|
41
|
-
|
|
41
|
+
configMode?: string;
|
|
42
42
|
firstBuyAmount?: number;
|
|
43
43
|
x?: string;
|
|
44
44
|
website?: string;
|
|
@@ -90,19 +90,17 @@ export type LaunchCostQuote = {
|
|
|
90
90
|
};
|
|
91
91
|
breakdown: LaunchCostBreakdown;
|
|
92
92
|
};
|
|
93
|
-
export type
|
|
93
|
+
export type ConfigModeOption = {
|
|
94
|
+
configMode: string;
|
|
94
95
|
migrationThreshold: number;
|
|
95
|
-
presetBinding: string;
|
|
96
96
|
configAddress: string | null;
|
|
97
97
|
deploymentMode: 'predeployed-config' | 'per-launch-config';
|
|
98
98
|
};
|
|
99
99
|
export type LaunchConfigView = {
|
|
100
100
|
network: 'devnet' | 'mainnet';
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
migrationThresholdOptions: MigrationThresholdOption[];
|
|
105
|
-
availableMigrationThresholdOptions: MigrationThresholdOption[];
|
|
101
|
+
defaultConfigMode: string;
|
|
102
|
+
availableConfigModes: string[];
|
|
103
|
+
configModeOptions: ConfigModeOption[];
|
|
106
104
|
};
|
|
107
105
|
export type SubmitAction = {
|
|
108
106
|
id: string;
|
|
@@ -159,9 +157,8 @@ export type RealtimeMessage<T> = {
|
|
|
159
157
|
data: T | null;
|
|
160
158
|
};
|
|
161
159
|
export type CurvePreview = {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
selectedMigrationThreshold: number;
|
|
160
|
+
configModeOptions: ConfigModeOption[];
|
|
161
|
+
selectedConfigMode: string;
|
|
165
162
|
curve: {
|
|
166
163
|
startingMC: number;
|
|
167
164
|
endingMC: number;
|
|
@@ -202,7 +199,7 @@ export type CurvePreview = {
|
|
|
202
199
|
};
|
|
203
200
|
export type FeePreviewRequest = {
|
|
204
201
|
totalSupply?: string;
|
|
205
|
-
|
|
202
|
+
configMode?: string;
|
|
206
203
|
firstBuyAmount?: number;
|
|
207
204
|
deployerWallet?: string;
|
|
208
205
|
};
|