@rougechain/sdk 0.4.1 → 0.6.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 +40 -6
- package/dist/index.cjs +152 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +765 -0
- package/dist/index.d.ts +765 -0
- package/dist/index.js +149 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,765 @@
|
|
|
1
|
+
interface WalletKeys {
|
|
2
|
+
publicKey: string;
|
|
3
|
+
privateKey: string;
|
|
4
|
+
}
|
|
5
|
+
interface ApiResponse<T = unknown> {
|
|
6
|
+
success: boolean;
|
|
7
|
+
error?: string;
|
|
8
|
+
data?: T;
|
|
9
|
+
}
|
|
10
|
+
type TransactionType = "transfer" | "create_token" | "swap" | "create_pool" | "add_liquidity" | "remove_liquidity" | "stake" | "unstake" | "faucet" | "nft_create_collection" | "nft_mint" | "nft_batch_mint" | "nft_transfer" | "nft_burn" | "nft_lock" | "nft_freeze_collection" | "bridge_withdraw" | "update_token_metadata" | "claim_token_metadata" | "shield" | "shielded_transfer" | "unshield";
|
|
11
|
+
interface TransactionPayload {
|
|
12
|
+
type: TransactionType;
|
|
13
|
+
from: string;
|
|
14
|
+
to?: string;
|
|
15
|
+
amount?: number;
|
|
16
|
+
fee?: number;
|
|
17
|
+
token?: string;
|
|
18
|
+
tokenSymbol?: string;
|
|
19
|
+
evmAddress?: string;
|
|
20
|
+
timestamp: number;
|
|
21
|
+
nonce: string;
|
|
22
|
+
token_name?: string;
|
|
23
|
+
token_symbol?: string;
|
|
24
|
+
initial_supply?: number;
|
|
25
|
+
token_in?: string;
|
|
26
|
+
token_out?: string;
|
|
27
|
+
amount_in?: number;
|
|
28
|
+
min_amount_out?: number;
|
|
29
|
+
pool_id?: string;
|
|
30
|
+
token_a?: string;
|
|
31
|
+
token_b?: string;
|
|
32
|
+
amount_a?: number;
|
|
33
|
+
amount_b?: number;
|
|
34
|
+
lp_amount?: number;
|
|
35
|
+
symbol?: string;
|
|
36
|
+
name?: string;
|
|
37
|
+
collectionId?: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
image?: string;
|
|
40
|
+
maxSupply?: number;
|
|
41
|
+
royaltyBps?: number;
|
|
42
|
+
tokenId?: number;
|
|
43
|
+
metadataUri?: string;
|
|
44
|
+
attributes?: unknown;
|
|
45
|
+
locked?: boolean;
|
|
46
|
+
frozen?: boolean;
|
|
47
|
+
salePrice?: number;
|
|
48
|
+
names?: string[];
|
|
49
|
+
uris?: string[];
|
|
50
|
+
batchAttributes?: unknown[];
|
|
51
|
+
website?: string;
|
|
52
|
+
twitter?: string;
|
|
53
|
+
discord?: string;
|
|
54
|
+
}
|
|
55
|
+
interface SignedTransaction {
|
|
56
|
+
payload: TransactionPayload;
|
|
57
|
+
signature: string;
|
|
58
|
+
public_key: string;
|
|
59
|
+
}
|
|
60
|
+
interface BlockHeader {
|
|
61
|
+
version: number;
|
|
62
|
+
chain_id: string;
|
|
63
|
+
height: number;
|
|
64
|
+
time: number;
|
|
65
|
+
prev_hash: string;
|
|
66
|
+
tx_hash: string;
|
|
67
|
+
proposer_pub_key: string;
|
|
68
|
+
}
|
|
69
|
+
interface Transaction {
|
|
70
|
+
version: number;
|
|
71
|
+
tx_type: string;
|
|
72
|
+
from_pub_key: string;
|
|
73
|
+
target_pub_key?: string | null;
|
|
74
|
+
amount: number;
|
|
75
|
+
fee: number;
|
|
76
|
+
sig: string;
|
|
77
|
+
token_name?: string | null;
|
|
78
|
+
token_symbol?: string | null;
|
|
79
|
+
token_decimals?: number | null;
|
|
80
|
+
token_total_supply?: number | null;
|
|
81
|
+
pool_id?: string | null;
|
|
82
|
+
token_a_symbol?: string | null;
|
|
83
|
+
token_b_symbol?: string | null;
|
|
84
|
+
amount_a?: number | null;
|
|
85
|
+
amount_b?: number | null;
|
|
86
|
+
min_amount_out?: number | null;
|
|
87
|
+
swap_path?: string[] | null;
|
|
88
|
+
lp_amount?: number | null;
|
|
89
|
+
faucet?: boolean;
|
|
90
|
+
signed_payload?: string | null;
|
|
91
|
+
}
|
|
92
|
+
interface Block {
|
|
93
|
+
version: number;
|
|
94
|
+
header: BlockHeader;
|
|
95
|
+
txs: Transaction[];
|
|
96
|
+
proposer_sig: string;
|
|
97
|
+
hash: string;
|
|
98
|
+
}
|
|
99
|
+
interface NodeStats {
|
|
100
|
+
height: number;
|
|
101
|
+
peers: number;
|
|
102
|
+
network_height: number;
|
|
103
|
+
mining: boolean;
|
|
104
|
+
total_fees: number;
|
|
105
|
+
last_block_fees: number;
|
|
106
|
+
finalized_height: number;
|
|
107
|
+
ws_clients: number;
|
|
108
|
+
}
|
|
109
|
+
interface TokenMetadata {
|
|
110
|
+
symbol: string;
|
|
111
|
+
name: string;
|
|
112
|
+
creator: string;
|
|
113
|
+
image?: string;
|
|
114
|
+
description?: string;
|
|
115
|
+
website?: string;
|
|
116
|
+
twitter?: string;
|
|
117
|
+
discord?: string;
|
|
118
|
+
created_at: number;
|
|
119
|
+
updated_at: number;
|
|
120
|
+
}
|
|
121
|
+
interface TokenHolder {
|
|
122
|
+
address: string;
|
|
123
|
+
balance: number;
|
|
124
|
+
}
|
|
125
|
+
interface BalanceResponse {
|
|
126
|
+
balance: number;
|
|
127
|
+
token_balances: Record<string, number>;
|
|
128
|
+
lp_balances: Record<string, number>;
|
|
129
|
+
}
|
|
130
|
+
interface LiquidityPool {
|
|
131
|
+
pool_id: string;
|
|
132
|
+
token_a_symbol: string;
|
|
133
|
+
token_b_symbol: string;
|
|
134
|
+
reserve_a: number;
|
|
135
|
+
reserve_b: number;
|
|
136
|
+
total_lp: number;
|
|
137
|
+
fee_rate: number;
|
|
138
|
+
created_at: number;
|
|
139
|
+
}
|
|
140
|
+
interface SwapQuote {
|
|
141
|
+
amount_out: number;
|
|
142
|
+
price_impact: number;
|
|
143
|
+
path: string[];
|
|
144
|
+
}
|
|
145
|
+
interface PoolEvent {
|
|
146
|
+
event_type: string;
|
|
147
|
+
pool_id: string;
|
|
148
|
+
actor: string;
|
|
149
|
+
token_a_amount?: number;
|
|
150
|
+
token_b_amount?: number;
|
|
151
|
+
lp_amount?: number;
|
|
152
|
+
timestamp: number;
|
|
153
|
+
}
|
|
154
|
+
interface PoolStats {
|
|
155
|
+
pool_id: string;
|
|
156
|
+
volume_24h: number;
|
|
157
|
+
trades_24h: number;
|
|
158
|
+
tvl: number;
|
|
159
|
+
}
|
|
160
|
+
interface PriceSnapshot {
|
|
161
|
+
pool_id: string;
|
|
162
|
+
timestamp: number;
|
|
163
|
+
block_height: number;
|
|
164
|
+
reserve_a: number;
|
|
165
|
+
reserve_b: number;
|
|
166
|
+
price_a_in_b: number;
|
|
167
|
+
price_b_in_a: number;
|
|
168
|
+
}
|
|
169
|
+
interface NftCollection {
|
|
170
|
+
collection_id: string;
|
|
171
|
+
symbol: string;
|
|
172
|
+
name: string;
|
|
173
|
+
creator: string;
|
|
174
|
+
description?: string;
|
|
175
|
+
image?: string;
|
|
176
|
+
max_supply?: number;
|
|
177
|
+
minted: number;
|
|
178
|
+
royalty_bps: number;
|
|
179
|
+
royalty_recipient: string;
|
|
180
|
+
frozen: boolean;
|
|
181
|
+
created_at: number;
|
|
182
|
+
}
|
|
183
|
+
interface NftToken {
|
|
184
|
+
collection_id: string;
|
|
185
|
+
token_id: number;
|
|
186
|
+
owner: string;
|
|
187
|
+
creator: string;
|
|
188
|
+
name: string;
|
|
189
|
+
metadata_uri?: string;
|
|
190
|
+
attributes?: unknown;
|
|
191
|
+
locked: boolean;
|
|
192
|
+
minted_at: number;
|
|
193
|
+
transferred_at: number;
|
|
194
|
+
}
|
|
195
|
+
interface Validator {
|
|
196
|
+
public_key: string;
|
|
197
|
+
stake: number;
|
|
198
|
+
status: string;
|
|
199
|
+
jailed_until: number;
|
|
200
|
+
uptime: number;
|
|
201
|
+
}
|
|
202
|
+
interface BridgeConfig {
|
|
203
|
+
enabled: boolean;
|
|
204
|
+
custodyAddress?: string;
|
|
205
|
+
chainId: number;
|
|
206
|
+
supportedTokens?: string[];
|
|
207
|
+
}
|
|
208
|
+
interface BridgeWithdrawal {
|
|
209
|
+
tx_id: string;
|
|
210
|
+
from_pub_key: string;
|
|
211
|
+
evm_address: string;
|
|
212
|
+
amount_units: number;
|
|
213
|
+
status: string;
|
|
214
|
+
created_at: number;
|
|
215
|
+
}
|
|
216
|
+
interface XrgeBridgeConfig {
|
|
217
|
+
enabled: boolean;
|
|
218
|
+
vaultAddress?: string;
|
|
219
|
+
tokenAddress?: string;
|
|
220
|
+
chainId: number;
|
|
221
|
+
}
|
|
222
|
+
interface MailMessage {
|
|
223
|
+
id: string;
|
|
224
|
+
from: string;
|
|
225
|
+
to: string;
|
|
226
|
+
subject: string;
|
|
227
|
+
body: string;
|
|
228
|
+
encrypted_subject?: string;
|
|
229
|
+
encrypted_body?: string;
|
|
230
|
+
reply_to_id?: string;
|
|
231
|
+
read: boolean;
|
|
232
|
+
folder: "inbox" | "sent" | "trash";
|
|
233
|
+
created_at: number;
|
|
234
|
+
}
|
|
235
|
+
interface SendMailParams {
|
|
236
|
+
from: string;
|
|
237
|
+
to: string;
|
|
238
|
+
subject: string;
|
|
239
|
+
body: string;
|
|
240
|
+
encrypted_subject: string;
|
|
241
|
+
encrypted_body: string;
|
|
242
|
+
reply_to_id?: string;
|
|
243
|
+
}
|
|
244
|
+
interface MessengerWallet {
|
|
245
|
+
id: string;
|
|
246
|
+
displayName: string;
|
|
247
|
+
signingPublicKey: string;
|
|
248
|
+
encryptionPublicKey: string;
|
|
249
|
+
created_at: number;
|
|
250
|
+
}
|
|
251
|
+
interface MessengerConversation {
|
|
252
|
+
id: string;
|
|
253
|
+
participants: string[];
|
|
254
|
+
created_at: number;
|
|
255
|
+
last_message_at?: string;
|
|
256
|
+
last_sender_id?: string;
|
|
257
|
+
last_message_preview?: string;
|
|
258
|
+
unread_count?: number;
|
|
259
|
+
}
|
|
260
|
+
interface MessengerMessage {
|
|
261
|
+
id: string;
|
|
262
|
+
conversation_id: string;
|
|
263
|
+
sender: string;
|
|
264
|
+
encrypted_content: string;
|
|
265
|
+
media_type?: string;
|
|
266
|
+
media_data?: string;
|
|
267
|
+
self_destruct?: boolean;
|
|
268
|
+
destruct_after_seconds?: number;
|
|
269
|
+
read?: boolean;
|
|
270
|
+
created_at: number;
|
|
271
|
+
}
|
|
272
|
+
interface TransferParams {
|
|
273
|
+
to: string;
|
|
274
|
+
amount: number;
|
|
275
|
+
fee?: number;
|
|
276
|
+
token?: string;
|
|
277
|
+
}
|
|
278
|
+
interface CreateTokenParams {
|
|
279
|
+
name: string;
|
|
280
|
+
symbol: string;
|
|
281
|
+
totalSupply: number;
|
|
282
|
+
fee?: number;
|
|
283
|
+
/** Token logo — URL or data URI (base64). Stored on-chain in token metadata. */
|
|
284
|
+
image?: string;
|
|
285
|
+
}
|
|
286
|
+
interface SwapParams {
|
|
287
|
+
tokenIn: string;
|
|
288
|
+
tokenOut: string;
|
|
289
|
+
amountIn: number;
|
|
290
|
+
minAmountOut: number;
|
|
291
|
+
}
|
|
292
|
+
interface CreatePoolParams {
|
|
293
|
+
tokenA: string;
|
|
294
|
+
tokenB: string;
|
|
295
|
+
amountA: number;
|
|
296
|
+
amountB: number;
|
|
297
|
+
}
|
|
298
|
+
interface AddLiquidityParams {
|
|
299
|
+
poolId: string;
|
|
300
|
+
amountA: number;
|
|
301
|
+
amountB: number;
|
|
302
|
+
}
|
|
303
|
+
interface RemoveLiquidityParams {
|
|
304
|
+
poolId: string;
|
|
305
|
+
lpAmount: number;
|
|
306
|
+
}
|
|
307
|
+
interface StakeParams {
|
|
308
|
+
amount: number;
|
|
309
|
+
fee?: number;
|
|
310
|
+
}
|
|
311
|
+
interface CreateNftCollectionParams {
|
|
312
|
+
symbol: string;
|
|
313
|
+
name: string;
|
|
314
|
+
maxSupply?: number;
|
|
315
|
+
royaltyBps?: number;
|
|
316
|
+
image?: string;
|
|
317
|
+
description?: string;
|
|
318
|
+
}
|
|
319
|
+
interface MintNftParams {
|
|
320
|
+
collectionId: string;
|
|
321
|
+
name: string;
|
|
322
|
+
metadataUri?: string;
|
|
323
|
+
attributes?: unknown;
|
|
324
|
+
}
|
|
325
|
+
interface BatchMintNftParams {
|
|
326
|
+
collectionId: string;
|
|
327
|
+
names: string[];
|
|
328
|
+
uris?: string[];
|
|
329
|
+
batchAttributes?: unknown[];
|
|
330
|
+
}
|
|
331
|
+
interface TransferNftParams {
|
|
332
|
+
collectionId: string;
|
|
333
|
+
tokenId: number;
|
|
334
|
+
to: string;
|
|
335
|
+
salePrice?: number;
|
|
336
|
+
}
|
|
337
|
+
interface BurnNftParams {
|
|
338
|
+
collectionId: string;
|
|
339
|
+
tokenId: number;
|
|
340
|
+
}
|
|
341
|
+
interface LockNftParams {
|
|
342
|
+
collectionId: string;
|
|
343
|
+
tokenId: number;
|
|
344
|
+
locked: boolean;
|
|
345
|
+
}
|
|
346
|
+
interface FreezeCollectionParams {
|
|
347
|
+
collectionId: string;
|
|
348
|
+
frozen: boolean;
|
|
349
|
+
}
|
|
350
|
+
interface BridgeWithdrawParams {
|
|
351
|
+
amount: number;
|
|
352
|
+
evmAddress: string;
|
|
353
|
+
fee?: number;
|
|
354
|
+
tokenSymbol?: string;
|
|
355
|
+
}
|
|
356
|
+
interface BridgeClaimParams {
|
|
357
|
+
evmTxHash: string;
|
|
358
|
+
evmAddress: string;
|
|
359
|
+
evmSignature: string;
|
|
360
|
+
recipientPubkey: string;
|
|
361
|
+
token?: "ETH" | "USDC";
|
|
362
|
+
}
|
|
363
|
+
interface XrgeBridgeClaimParams {
|
|
364
|
+
evmTxHash: string;
|
|
365
|
+
evmAddress: string;
|
|
366
|
+
amount: string;
|
|
367
|
+
recipientPubkey: string;
|
|
368
|
+
}
|
|
369
|
+
interface XrgeBridgeWithdrawParams {
|
|
370
|
+
amount: number;
|
|
371
|
+
evmAddress: string;
|
|
372
|
+
}
|
|
373
|
+
interface SwapQuoteParams {
|
|
374
|
+
poolId: string;
|
|
375
|
+
tokenIn: string;
|
|
376
|
+
tokenOut: string;
|
|
377
|
+
amountIn: number;
|
|
378
|
+
}
|
|
379
|
+
interface TokenMetadataUpdateParams {
|
|
380
|
+
symbol: string;
|
|
381
|
+
image?: string;
|
|
382
|
+
description?: string;
|
|
383
|
+
website?: string;
|
|
384
|
+
twitter?: string;
|
|
385
|
+
discord?: string;
|
|
386
|
+
}
|
|
387
|
+
interface ShieldParams {
|
|
388
|
+
/** Amount to shield (integer XRGE) */
|
|
389
|
+
amount: number;
|
|
390
|
+
}
|
|
391
|
+
interface ShieldedTransferParams {
|
|
392
|
+
/** Nullifiers of consumed input notes (hex) */
|
|
393
|
+
nullifiers: string[];
|
|
394
|
+
/** Commitments for output notes (hex) */
|
|
395
|
+
outputCommitments: string[];
|
|
396
|
+
/** STARK proof bytes (hex) */
|
|
397
|
+
proof: string;
|
|
398
|
+
/** Fee paid from the shielded pool */
|
|
399
|
+
shieldedFee?: number;
|
|
400
|
+
}
|
|
401
|
+
interface UnshieldParams {
|
|
402
|
+
/** Nullifiers of consumed notes (hex) */
|
|
403
|
+
nullifiers: string[];
|
|
404
|
+
/** Amount to unshield (integer XRGE) */
|
|
405
|
+
amount: number;
|
|
406
|
+
/** STARK proof bytes (hex) */
|
|
407
|
+
proof: string;
|
|
408
|
+
}
|
|
409
|
+
interface ShieldedStats {
|
|
410
|
+
success: boolean;
|
|
411
|
+
commitment_count: number;
|
|
412
|
+
nullifier_count: number;
|
|
413
|
+
active_notes: number;
|
|
414
|
+
}
|
|
415
|
+
interface RollupStatus {
|
|
416
|
+
pending_transfers: number;
|
|
417
|
+
completed_batches: number;
|
|
418
|
+
next_batch_id: number;
|
|
419
|
+
max_batch_size: number;
|
|
420
|
+
batch_timeout_secs: number;
|
|
421
|
+
current_state_root: string;
|
|
422
|
+
accounts_tracked: number;
|
|
423
|
+
}
|
|
424
|
+
interface RollupBatchResult {
|
|
425
|
+
batch_id: number;
|
|
426
|
+
transfer_count: number;
|
|
427
|
+
total_fees: number;
|
|
428
|
+
pre_state_root: string;
|
|
429
|
+
post_state_root: string;
|
|
430
|
+
proof_size_bytes: number;
|
|
431
|
+
proof_time_ms: number;
|
|
432
|
+
verified: boolean;
|
|
433
|
+
}
|
|
434
|
+
interface RollupSubmitParams {
|
|
435
|
+
sender: string;
|
|
436
|
+
receiver: string;
|
|
437
|
+
amount: number;
|
|
438
|
+
fee?: number;
|
|
439
|
+
}
|
|
440
|
+
interface RollupSubmitResult {
|
|
441
|
+
success: boolean;
|
|
442
|
+
queued: boolean;
|
|
443
|
+
batch_completed: boolean;
|
|
444
|
+
batch?: RollupBatchResult;
|
|
445
|
+
pending_transfers?: number;
|
|
446
|
+
max_batch_size?: number;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Client-side shielded transaction crypto primitives.
|
|
451
|
+
*
|
|
452
|
+
* Mirrors the Rust commitment.rs exactly:
|
|
453
|
+
* commitment = SHA-256("ROUGECHAIN_COMMITMENT_V1" || value || pubkey || randomness)
|
|
454
|
+
* nullifier = SHA-256("ROUGECHAIN_NULLIFIER_V1" || randomness || commitment)
|
|
455
|
+
*/
|
|
456
|
+
/** Generate 32 bytes of cryptographically secure randomness (hex-encoded). */
|
|
457
|
+
declare function generateRandomness(): string;
|
|
458
|
+
/**
|
|
459
|
+
* Compute a shielded note commitment.
|
|
460
|
+
*
|
|
461
|
+
* @param value - Note value in XRGE (integer)
|
|
462
|
+
* @param ownerPubKey - Owner's ML-DSA-65 public key (hex)
|
|
463
|
+
* @param randomness - 32-byte blinding factor (hex)
|
|
464
|
+
* @returns 32-byte commitment hash (hex)
|
|
465
|
+
*/
|
|
466
|
+
declare function computeCommitment(value: number, ownerPubKey: string, randomness: string): string;
|
|
467
|
+
/**
|
|
468
|
+
* Compute a nullifier for a shielded note.
|
|
469
|
+
*
|
|
470
|
+
* @param randomness - The note's blinding factor (hex)
|
|
471
|
+
* @param commitment - The note's commitment hash (hex)
|
|
472
|
+
* @returns 32-byte nullifier hash (hex)
|
|
473
|
+
*/
|
|
474
|
+
declare function computeNullifier(randomness: string, commitment: string): string;
|
|
475
|
+
/** A shielded note — kept locally by the owner (never sent to chain). */
|
|
476
|
+
interface ShieldedNote {
|
|
477
|
+
commitment: string;
|
|
478
|
+
nullifier: string;
|
|
479
|
+
value: number;
|
|
480
|
+
randomness: string;
|
|
481
|
+
ownerPubKey: string;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Create a new shielded note for a given value.
|
|
485
|
+
*
|
|
486
|
+
* @param value - XRGE amount (integer)
|
|
487
|
+
* @param ownerPubKey - Owner's public key (hex)
|
|
488
|
+
* @returns A ShieldedNote with all derived fields
|
|
489
|
+
*/
|
|
490
|
+
declare function createShieldedNote(value: number, ownerPubKey: string): ShieldedNote;
|
|
491
|
+
|
|
492
|
+
type FetchFn = typeof globalThis.fetch;
|
|
493
|
+
interface RougeChainOptions {
|
|
494
|
+
/** Custom fetch implementation (defaults to globalThis.fetch) */
|
|
495
|
+
fetch?: FetchFn;
|
|
496
|
+
/** Optional API key for authenticated endpoints */
|
|
497
|
+
apiKey?: string;
|
|
498
|
+
}
|
|
499
|
+
declare class RougeChain {
|
|
500
|
+
/** @internal */ readonly baseUrl: string;
|
|
501
|
+
/** @internal */ readonly fetchFn: FetchFn;
|
|
502
|
+
/** @internal */ readonly headers: Record<string, string>;
|
|
503
|
+
readonly nft: NftClient;
|
|
504
|
+
readonly dex: DexClient;
|
|
505
|
+
readonly bridge: BridgeClient;
|
|
506
|
+
readonly mail: MailClient;
|
|
507
|
+
readonly messenger: MessengerClient;
|
|
508
|
+
readonly shielded: ShieldedClient;
|
|
509
|
+
constructor(baseUrl: string, options?: RougeChainOptions);
|
|
510
|
+
/** @internal */
|
|
511
|
+
get<T = unknown>(path: string): Promise<T>;
|
|
512
|
+
/** @internal */
|
|
513
|
+
post<T = unknown>(path: string, body: unknown): Promise<T>;
|
|
514
|
+
/** @internal */
|
|
515
|
+
submitTx(endpoint: string, signedTx: SignedTransaction): Promise<ApiResponse>;
|
|
516
|
+
getStats(): Promise<NodeStats>;
|
|
517
|
+
getHealth(): Promise<{
|
|
518
|
+
status: string;
|
|
519
|
+
chain_id: string;
|
|
520
|
+
height: number;
|
|
521
|
+
}>;
|
|
522
|
+
getBlocks(opts?: {
|
|
523
|
+
limit?: number;
|
|
524
|
+
}): Promise<Block[]>;
|
|
525
|
+
getBlocksSummary(range?: "1h" | "24h" | "7d"): Promise<unknown>;
|
|
526
|
+
getBalance(publicKey: string): Promise<BalanceResponse>;
|
|
527
|
+
getTokenBalance(publicKey: string, token: string): Promise<number>;
|
|
528
|
+
getTransactions(opts?: {
|
|
529
|
+
limit?: number;
|
|
530
|
+
offset?: number;
|
|
531
|
+
}): Promise<unknown>;
|
|
532
|
+
getTokens(): Promise<TokenMetadata[]>;
|
|
533
|
+
getTokenMetadata(symbol: string): Promise<TokenMetadata>;
|
|
534
|
+
getTokenHolders(symbol: string): Promise<TokenHolder[]>;
|
|
535
|
+
getTokenTransactions(symbol: string): Promise<unknown>;
|
|
536
|
+
getValidators(): Promise<Validator[]>;
|
|
537
|
+
getValidatorStats(): Promise<unknown>;
|
|
538
|
+
getFinality(): Promise<{
|
|
539
|
+
finalized_height: number;
|
|
540
|
+
tip_height: number;
|
|
541
|
+
total_stake: number;
|
|
542
|
+
finalized_stake: number;
|
|
543
|
+
}>;
|
|
544
|
+
getPeers(): Promise<string[]>;
|
|
545
|
+
getBurnedTokens(): Promise<{
|
|
546
|
+
burned: Record<string, number>;
|
|
547
|
+
total_xrge_burned: number;
|
|
548
|
+
}>;
|
|
549
|
+
transfer(wallet: WalletKeys, params: TransferParams): Promise<ApiResponse>;
|
|
550
|
+
createToken(wallet: WalletKeys, params: CreateTokenParams): Promise<ApiResponse>;
|
|
551
|
+
stake(wallet: WalletKeys, params: StakeParams): Promise<ApiResponse>;
|
|
552
|
+
unstake(wallet: WalletKeys, params: StakeParams): Promise<ApiResponse>;
|
|
553
|
+
faucet(wallet: WalletKeys): Promise<ApiResponse>;
|
|
554
|
+
burn(wallet: WalletKeys, amount: number, fee?: number, token?: string): Promise<ApiResponse>;
|
|
555
|
+
updateTokenMetadata(wallet: WalletKeys, params: TokenMetadataUpdateParams): Promise<ApiResponse>;
|
|
556
|
+
claimTokenMetadata(wallet: WalletKeys, tokenSymbol: string): Promise<ApiResponse>;
|
|
557
|
+
/** Get the current rollup accumulator status. */
|
|
558
|
+
getRollupStatus(): Promise<RollupStatus>;
|
|
559
|
+
/** Submit a transfer into the rollup batch accumulator. */
|
|
560
|
+
submitRollupTransfer(params: RollupSubmitParams): Promise<RollupSubmitResult>;
|
|
561
|
+
/** Get the result of a completed rollup batch by ID. */
|
|
562
|
+
getRollupBatch(batchId: number): Promise<RollupBatchResult>;
|
|
563
|
+
}
|
|
564
|
+
declare class NftClient {
|
|
565
|
+
private readonly rc;
|
|
566
|
+
constructor(rc: RougeChain);
|
|
567
|
+
getCollections(): Promise<NftCollection[]>;
|
|
568
|
+
getCollection(collectionId: string): Promise<NftCollection>;
|
|
569
|
+
/**
|
|
570
|
+
* Poll until a collection exists on-chain (i.e. the create tx has been mined).
|
|
571
|
+
* Useful after `createCollection` since the tx goes to the mempool first.
|
|
572
|
+
* @returns the collection once found, or throws after the timeout.
|
|
573
|
+
*/
|
|
574
|
+
waitForCollection(collectionId: string, opts?: {
|
|
575
|
+
timeoutMs?: number;
|
|
576
|
+
pollMs?: number;
|
|
577
|
+
}): Promise<NftCollection>;
|
|
578
|
+
getTokens(collectionId: string, opts?: {
|
|
579
|
+
limit?: number;
|
|
580
|
+
offset?: number;
|
|
581
|
+
}): Promise<{
|
|
582
|
+
tokens: NftToken[];
|
|
583
|
+
total: number;
|
|
584
|
+
}>;
|
|
585
|
+
getToken(collectionId: string, tokenId: number): Promise<NftToken>;
|
|
586
|
+
getByOwner(pubkey: string): Promise<NftToken[]>;
|
|
587
|
+
createCollection(wallet: WalletKeys, params: CreateNftCollectionParams): Promise<ApiResponse>;
|
|
588
|
+
mint(wallet: WalletKeys, params: MintNftParams): Promise<ApiResponse>;
|
|
589
|
+
batchMint(wallet: WalletKeys, params: BatchMintNftParams): Promise<ApiResponse>;
|
|
590
|
+
transfer(wallet: WalletKeys, params: TransferNftParams): Promise<ApiResponse>;
|
|
591
|
+
burn(wallet: WalletKeys, params: BurnNftParams): Promise<ApiResponse>;
|
|
592
|
+
lock(wallet: WalletKeys, params: LockNftParams): Promise<ApiResponse>;
|
|
593
|
+
freezeCollection(wallet: WalletKeys, params: FreezeCollectionParams): Promise<ApiResponse>;
|
|
594
|
+
}
|
|
595
|
+
declare class DexClient {
|
|
596
|
+
private readonly rc;
|
|
597
|
+
constructor(rc: RougeChain);
|
|
598
|
+
getPools(): Promise<LiquidityPool[]>;
|
|
599
|
+
getPool(poolId: string): Promise<LiquidityPool>;
|
|
600
|
+
getPoolEvents(poolId: string): Promise<PoolEvent[]>;
|
|
601
|
+
getPriceHistory(poolId: string): Promise<PriceSnapshot[]>;
|
|
602
|
+
getPoolStats(poolId: string): Promise<PoolStats>;
|
|
603
|
+
quote(params: SwapQuoteParams): Promise<SwapQuote>;
|
|
604
|
+
swap(wallet: WalletKeys, params: SwapParams): Promise<ApiResponse>;
|
|
605
|
+
createPool(wallet: WalletKeys, params: CreatePoolParams): Promise<ApiResponse>;
|
|
606
|
+
addLiquidity(wallet: WalletKeys, params: AddLiquidityParams): Promise<ApiResponse>;
|
|
607
|
+
removeLiquidity(wallet: WalletKeys, params: RemoveLiquidityParams): Promise<ApiResponse>;
|
|
608
|
+
}
|
|
609
|
+
declare class BridgeClient {
|
|
610
|
+
private readonly rc;
|
|
611
|
+
constructor(rc: RougeChain);
|
|
612
|
+
getConfig(): Promise<BridgeConfig>;
|
|
613
|
+
getWithdrawals(): Promise<BridgeWithdrawal[]>;
|
|
614
|
+
/** Withdraw qETH/qUSDC — signed client-side, private key never sent to server */
|
|
615
|
+
withdraw(wallet: WalletKeys, params: BridgeWithdrawParams): Promise<ApiResponse>;
|
|
616
|
+
/** Claim qETH or qUSDC after depositing on Base Sepolia */
|
|
617
|
+
claim(params: BridgeClaimParams): Promise<ApiResponse>;
|
|
618
|
+
getXrgeConfig(): Promise<XrgeBridgeConfig>;
|
|
619
|
+
claimXrge(params: XrgeBridgeClaimParams): Promise<ApiResponse>;
|
|
620
|
+
withdrawXrge(wallet: WalletKeys, params: XrgeBridgeWithdrawParams): Promise<ApiResponse>;
|
|
621
|
+
getXrgeWithdrawals(): Promise<BridgeWithdrawal[]>;
|
|
622
|
+
}
|
|
623
|
+
declare class MailClient {
|
|
624
|
+
private readonly rc;
|
|
625
|
+
constructor(rc: RougeChain);
|
|
626
|
+
send(params: SendMailParams): Promise<ApiResponse>;
|
|
627
|
+
getInbox(walletId: string): Promise<MailMessage[]>;
|
|
628
|
+
getSent(walletId: string): Promise<MailMessage[]>;
|
|
629
|
+
getTrash(walletId: string): Promise<MailMessage[]>;
|
|
630
|
+
getMessage(id: string): Promise<MailMessage>;
|
|
631
|
+
move(messageId: string, folder: string): Promise<ApiResponse>;
|
|
632
|
+
markRead(messageId: string): Promise<ApiResponse>;
|
|
633
|
+
delete(id: string): Promise<ApiResponse>;
|
|
634
|
+
}
|
|
635
|
+
declare class MessengerClient {
|
|
636
|
+
private readonly rc;
|
|
637
|
+
constructor(rc: RougeChain);
|
|
638
|
+
getWallets(): Promise<MessengerWallet[]>;
|
|
639
|
+
registerWallet(opts: {
|
|
640
|
+
id: string;
|
|
641
|
+
displayName: string;
|
|
642
|
+
signingPublicKey: string;
|
|
643
|
+
encryptionPublicKey: string;
|
|
644
|
+
}): Promise<ApiResponse>;
|
|
645
|
+
getConversations(walletId: string, opts?: {
|
|
646
|
+
signingPublicKey?: string;
|
|
647
|
+
encryptionPublicKey?: string;
|
|
648
|
+
}): Promise<MessengerConversation[]>;
|
|
649
|
+
createConversation(participants: string[]): Promise<ApiResponse>;
|
|
650
|
+
getMessages(conversationId: string): Promise<MessengerMessage[]>;
|
|
651
|
+
sendMessage(conversationId: string, sender: string, encryptedContent: string, opts?: {
|
|
652
|
+
mediaType?: string;
|
|
653
|
+
mediaData?: string;
|
|
654
|
+
selfDestruct?: boolean;
|
|
655
|
+
destructAfterSeconds?: number;
|
|
656
|
+
}): Promise<ApiResponse>;
|
|
657
|
+
deleteMessage(messageId: string): Promise<ApiResponse>;
|
|
658
|
+
markRead(messageId: string): Promise<ApiResponse>;
|
|
659
|
+
}
|
|
660
|
+
declare class ShieldedClient {
|
|
661
|
+
private readonly rc;
|
|
662
|
+
constructor(rc: RougeChain);
|
|
663
|
+
getStats(): Promise<ShieldedStats>;
|
|
664
|
+
isNullifierSpent(nullifierHex: string): Promise<{
|
|
665
|
+
spent: boolean;
|
|
666
|
+
}>;
|
|
667
|
+
/**
|
|
668
|
+
* Shield public XRGE into a private note.
|
|
669
|
+
* Creates the commitment client-side, submits to the chain.
|
|
670
|
+
*
|
|
671
|
+
* @returns The ShieldedNote (keep this locally — it's the only way to spend the note)
|
|
672
|
+
*/
|
|
673
|
+
shield(wallet: WalletKeys, params: ShieldParams): Promise<ApiResponse & {
|
|
674
|
+
note?: ShieldedNote;
|
|
675
|
+
}>;
|
|
676
|
+
/**
|
|
677
|
+
* Transfer between shielded notes (private → private).
|
|
678
|
+
* Requires a pre-generated STARK proof.
|
|
679
|
+
*/
|
|
680
|
+
transfer(wallet: WalletKeys, params: ShieldedTransferParams): Promise<ApiResponse>;
|
|
681
|
+
/**
|
|
682
|
+
* Unshield a private note back to public XRGE.
|
|
683
|
+
* Requires a STARK proof of note ownership.
|
|
684
|
+
*/
|
|
685
|
+
unshield(wallet: WalletKeys, params: UnshieldParams): Promise<ApiResponse>;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
declare class Wallet implements WalletKeys {
|
|
689
|
+
readonly publicKey: string;
|
|
690
|
+
readonly privateKey: string;
|
|
691
|
+
private constructor();
|
|
692
|
+
/**
|
|
693
|
+
* Generate a new ML-DSA-65 keypair.
|
|
694
|
+
* Uses crypto.getRandomValues for secure randomness.
|
|
695
|
+
*/
|
|
696
|
+
static generate(): Wallet;
|
|
697
|
+
/**
|
|
698
|
+
* Restore a wallet from existing hex-encoded keys.
|
|
699
|
+
*/
|
|
700
|
+
static fromKeys(publicKey: string, privateKey: string): Wallet;
|
|
701
|
+
/**
|
|
702
|
+
* Export keys as a plain object (for serialization/storage).
|
|
703
|
+
*/
|
|
704
|
+
toJSON(): WalletKeys;
|
|
705
|
+
/**
|
|
706
|
+
* Derive the compact Bech32m address from the public key.
|
|
707
|
+
* Returns a ~63-character `rouge1...` string.
|
|
708
|
+
*/
|
|
709
|
+
address(): Promise<string>;
|
|
710
|
+
/**
|
|
711
|
+
* Verify that the keypair is valid by signing and verifying a test message.
|
|
712
|
+
*/
|
|
713
|
+
verify(): boolean;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
declare const BURN_ADDRESS = "XRGE_BURN_0x000000000000000000000000000000000000000000000000000000000000DEAD";
|
|
717
|
+
declare function serializePayload(payload: TransactionPayload): Uint8Array;
|
|
718
|
+
declare function signTransaction(payload: TransactionPayload, privateKey: string, publicKey: string): SignedTransaction;
|
|
719
|
+
declare function verifyTransaction(signedTx: SignedTransaction): boolean;
|
|
720
|
+
declare function isBurnAddress(address: string): boolean;
|
|
721
|
+
declare function createSignedTokenMetadataUpdate(wallet: WalletKeys, tokenSymbol: string, metadata: {
|
|
722
|
+
image?: string;
|
|
723
|
+
description?: string;
|
|
724
|
+
website?: string;
|
|
725
|
+
twitter?: string;
|
|
726
|
+
discord?: string;
|
|
727
|
+
}): SignedTransaction;
|
|
728
|
+
declare function createSignedTokenMetadataClaim(wallet: WalletKeys, tokenSymbol: string): SignedTransaction;
|
|
729
|
+
declare function createSignedBridgeWithdraw(wallet: WalletKeys, amount: number, evmAddress: string, tokenSymbol?: string, fee?: number): SignedTransaction;
|
|
730
|
+
declare function createSignedShield(wallet: WalletKeys, amount: number, commitment: string): SignedTransaction;
|
|
731
|
+
declare function createSignedShieldedTransfer(wallet: WalletKeys, nullifiers: string[], outputCommitments: string[], proof: string, shieldedFee?: number): SignedTransaction;
|
|
732
|
+
declare function createSignedUnshield(wallet: WalletKeys, nullifiers: string[], amount: number, proof: string): SignedTransaction;
|
|
733
|
+
|
|
734
|
+
declare function hexToBytes(hex: string): Uint8Array;
|
|
735
|
+
declare function bytesToHex(bytes: Uint8Array): string;
|
|
736
|
+
declare function generateNonce(): string;
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* RougeChain Bech32m Address Utilities for SDK
|
|
740
|
+
*
|
|
741
|
+
* Derives compact, human-readable addresses from PQC public keys:
|
|
742
|
+
* address = bech32m("rouge", SHA-256(raw_pubkey_bytes))
|
|
743
|
+
*
|
|
744
|
+
* Result: ~63-char address like "rouge1q8f3x7k2m4n9p..."
|
|
745
|
+
* Matches the Rust implementation in core/crypto/src/lib.rs exactly.
|
|
746
|
+
*/
|
|
747
|
+
/**
|
|
748
|
+
* Derive a compact Bech32m address from an ML-DSA-65 public key (hex).
|
|
749
|
+
* Returns a ~63-character string like "rouge1q8f3x7k2m4n9p..."
|
|
750
|
+
*/
|
|
751
|
+
declare function pubkeyToAddress(publicKeyHex: string): Promise<string>;
|
|
752
|
+
/**
|
|
753
|
+
* Decode a Bech32m address back to its 32-byte SHA-256 hash (hex).
|
|
754
|
+
*/
|
|
755
|
+
declare function addressToHash(address: string): string;
|
|
756
|
+
/**
|
|
757
|
+
* Check if a string is a valid RougeChain Bech32m address.
|
|
758
|
+
*/
|
|
759
|
+
declare function isRougeAddress(input: string): boolean;
|
|
760
|
+
/**
|
|
761
|
+
* Format an address for compact display: "rouge1q8f3...k9m2"
|
|
762
|
+
*/
|
|
763
|
+
declare function formatAddress(address: string, prefixLen?: number, suffixLen?: number): string;
|
|
764
|
+
|
|
765
|
+
export { type AddLiquidityParams, type ApiResponse, BURN_ADDRESS, type BalanceResponse, type BatchMintNftParams, type Block, type BlockHeader, type BridgeClaimParams, type BridgeConfig, type BridgeWithdrawParams, type BridgeWithdrawal, type BurnNftParams, type CreateNftCollectionParams, type CreatePoolParams, type CreateTokenParams, type FreezeCollectionParams, type LiquidityPool, type LockNftParams, type MailMessage, type MessengerConversation, type MessengerMessage, type MessengerWallet, type MintNftParams, type NftCollection, type NftToken, type NodeStats, type PoolEvent, type PoolStats, type PriceSnapshot, type RemoveLiquidityParams, type RollupBatchResult, type RollupStatus, type RollupSubmitParams, type RollupSubmitResult, RougeChain, type RougeChainOptions, type SendMailParams, type ShieldParams, type ShieldedNote, type ShieldedStats, type ShieldedTransferParams, type SignedTransaction, type StakeParams, type SwapParams, type SwapQuote, type SwapQuoteParams, type TokenHolder, type TokenMetadata, type TokenMetadataUpdateParams, type Transaction, type TransactionPayload, type TransactionType, type TransferNftParams, type TransferParams, type UnshieldParams, type Validator, Wallet, type WalletKeys, type XrgeBridgeClaimParams, type XrgeBridgeConfig, type XrgeBridgeWithdrawParams, addressToHash, bytesToHex, computeCommitment, computeNullifier, createShieldedNote, createSignedBridgeWithdraw, createSignedShield, createSignedShieldedTransfer, createSignedTokenMetadataClaim, createSignedTokenMetadataUpdate, createSignedUnshield, formatAddress, generateNonce, generateRandomness, hexToBytes, isBurnAddress, isRougeAddress, pubkeyToAddress, serializePayload, signTransaction, verifyTransaction };
|