@rougechain/sdk 0.3.6 → 0.4.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/index.d.ts DELETED
@@ -1,583 +0,0 @@
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";
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 NftCollection {
161
- collection_id: string;
162
- symbol: string;
163
- name: string;
164
- creator: string;
165
- description?: string;
166
- image?: string;
167
- max_supply?: number;
168
- minted: number;
169
- royalty_bps: number;
170
- royalty_recipient: string;
171
- frozen: boolean;
172
- created_at: number;
173
- }
174
- interface NftToken {
175
- collection_id: string;
176
- token_id: number;
177
- owner: string;
178
- creator: string;
179
- name: string;
180
- metadata_uri?: string;
181
- attributes?: unknown;
182
- locked: boolean;
183
- minted_at: number;
184
- transferred_at: number;
185
- }
186
- interface Validator {
187
- public_key: string;
188
- stake: number;
189
- status: string;
190
- jailed_until: number;
191
- uptime: number;
192
- }
193
- interface BridgeConfig {
194
- enabled: boolean;
195
- custodyAddress?: string;
196
- chainId: number;
197
- supportedTokens?: string[];
198
- }
199
- interface BridgeWithdrawal {
200
- tx_id: string;
201
- from_pub_key: string;
202
- evm_address: string;
203
- amount_units: number;
204
- status: string;
205
- created_at: number;
206
- }
207
- interface XrgeBridgeConfig {
208
- enabled: boolean;
209
- vaultAddress?: string;
210
- tokenAddress?: string;
211
- chainId: number;
212
- }
213
- interface MailMessage {
214
- id: string;
215
- from: string;
216
- to: string;
217
- subject: string;
218
- body: string;
219
- encrypted_subject?: string;
220
- encrypted_body?: string;
221
- reply_to_id?: string;
222
- read: boolean;
223
- folder: "inbox" | "sent" | "trash";
224
- created_at: number;
225
- }
226
- interface SendMailParams {
227
- from: string;
228
- to: string;
229
- subject: string;
230
- body: string;
231
- encrypted_subject: string;
232
- encrypted_body: string;
233
- reply_to_id?: string;
234
- }
235
- interface MessengerWallet {
236
- id: string;
237
- displayName: string;
238
- signingPublicKey: string;
239
- encryptionPublicKey: string;
240
- created_at: number;
241
- }
242
- interface MessengerConversation {
243
- id: string;
244
- participants: string[];
245
- created_at: number;
246
- last_message_at?: string;
247
- last_sender_id?: string;
248
- last_message_preview?: string;
249
- unread_count?: number;
250
- }
251
- interface MessengerMessage {
252
- id: string;
253
- conversation_id: string;
254
- sender: string;
255
- encrypted_content: string;
256
- media_type?: string;
257
- media_data?: string;
258
- self_destruct?: boolean;
259
- destruct_after_seconds?: number;
260
- read?: boolean;
261
- created_at: number;
262
- }
263
- interface TransferParams {
264
- to: string;
265
- amount: number;
266
- fee?: number;
267
- token?: string;
268
- }
269
- interface CreateTokenParams {
270
- name: string;
271
- symbol: string;
272
- totalSupply: number;
273
- fee?: number;
274
- /** Token logo — URL or data URI (base64). Stored on-chain in token metadata. */
275
- image?: string;
276
- }
277
- interface SwapParams {
278
- tokenIn: string;
279
- tokenOut: string;
280
- amountIn: number;
281
- minAmountOut: number;
282
- }
283
- interface CreatePoolParams {
284
- tokenA: string;
285
- tokenB: string;
286
- amountA: number;
287
- amountB: number;
288
- }
289
- interface AddLiquidityParams {
290
- poolId: string;
291
- amountA: number;
292
- amountB: number;
293
- }
294
- interface RemoveLiquidityParams {
295
- poolId: string;
296
- lpAmount: number;
297
- }
298
- interface StakeParams {
299
- amount: number;
300
- fee?: number;
301
- }
302
- interface CreateNftCollectionParams {
303
- symbol: string;
304
- name: string;
305
- maxSupply?: number;
306
- royaltyBps?: number;
307
- image?: string;
308
- description?: string;
309
- }
310
- interface MintNftParams {
311
- collectionId: string;
312
- name: string;
313
- metadataUri?: string;
314
- attributes?: unknown;
315
- }
316
- interface BatchMintNftParams {
317
- collectionId: string;
318
- names: string[];
319
- uris?: string[];
320
- batchAttributes?: unknown[];
321
- }
322
- interface TransferNftParams {
323
- collectionId: string;
324
- tokenId: number;
325
- to: string;
326
- salePrice?: number;
327
- }
328
- interface BurnNftParams {
329
- collectionId: string;
330
- tokenId: number;
331
- }
332
- interface LockNftParams {
333
- collectionId: string;
334
- tokenId: number;
335
- locked: boolean;
336
- }
337
- interface FreezeCollectionParams {
338
- collectionId: string;
339
- frozen: boolean;
340
- }
341
- interface BridgeWithdrawParams {
342
- amount: number;
343
- evmAddress: string;
344
- fee?: number;
345
- tokenSymbol?: string;
346
- }
347
- interface BridgeClaimParams {
348
- evmTxHash: string;
349
- evmAddress: string;
350
- evmSignature: string;
351
- recipientPubkey: string;
352
- token?: "ETH" | "USDC";
353
- }
354
- interface XrgeBridgeClaimParams {
355
- evmTxHash: string;
356
- evmAddress: string;
357
- amount: string;
358
- recipientPubkey: string;
359
- }
360
- interface XrgeBridgeWithdrawParams {
361
- amount: number;
362
- evmAddress: string;
363
- }
364
- interface SwapQuoteParams {
365
- poolId: string;
366
- tokenIn: string;
367
- tokenOut: string;
368
- amountIn: number;
369
- }
370
- interface TokenMetadataUpdateParams {
371
- symbol: string;
372
- image?: string;
373
- description?: string;
374
- website?: string;
375
- twitter?: string;
376
- discord?: string;
377
- }
378
-
379
- type FetchFn = typeof globalThis.fetch;
380
- interface RougeChainOptions {
381
- /** Custom fetch implementation (defaults to globalThis.fetch) */
382
- fetch?: FetchFn;
383
- /** Optional API key for authenticated endpoints */
384
- apiKey?: string;
385
- }
386
- declare class RougeChain {
387
- /** @internal */ readonly baseUrl: string;
388
- /** @internal */ readonly fetchFn: FetchFn;
389
- /** @internal */ readonly headers: Record<string, string>;
390
- readonly nft: NftClient;
391
- readonly dex: DexClient;
392
- readonly bridge: BridgeClient;
393
- readonly mail: MailClient;
394
- readonly messenger: MessengerClient;
395
- constructor(baseUrl: string, options?: RougeChainOptions);
396
- /** @internal */
397
- get<T = unknown>(path: string): Promise<T>;
398
- /** @internal */
399
- post<T = unknown>(path: string, body: unknown): Promise<T>;
400
- /** @internal */
401
- submitTx(endpoint: string, signedTx: SignedTransaction): Promise<ApiResponse>;
402
- getStats(): Promise<NodeStats>;
403
- getHealth(): Promise<{
404
- status: string;
405
- chain_id: string;
406
- height: number;
407
- }>;
408
- getBlocks(opts?: {
409
- limit?: number;
410
- }): Promise<Block[]>;
411
- getBlocksSummary(range?: "1h" | "24h" | "7d"): Promise<unknown>;
412
- getBalance(publicKey: string): Promise<BalanceResponse>;
413
- getTokenBalance(publicKey: string, token: string): Promise<number>;
414
- getTransactions(opts?: {
415
- limit?: number;
416
- offset?: number;
417
- }): Promise<unknown>;
418
- getTokens(): Promise<TokenMetadata[]>;
419
- getTokenMetadata(symbol: string): Promise<TokenMetadata>;
420
- getTokenHolders(symbol: string): Promise<TokenHolder[]>;
421
- getTokenTransactions(symbol: string): Promise<unknown>;
422
- getValidators(): Promise<Validator[]>;
423
- getValidatorStats(): Promise<unknown>;
424
- getFinality(): Promise<{
425
- finalized_height: number;
426
- tip_height: number;
427
- total_stake: number;
428
- finalized_stake: number;
429
- }>;
430
- getPeers(): Promise<string[]>;
431
- getBurnedTokens(): Promise<{
432
- burned: Record<string, number>;
433
- total_xrge_burned: number;
434
- }>;
435
- transfer(wallet: WalletKeys, params: TransferParams): Promise<ApiResponse>;
436
- createToken(wallet: WalletKeys, params: CreateTokenParams): Promise<ApiResponse>;
437
- stake(wallet: WalletKeys, params: StakeParams): Promise<ApiResponse>;
438
- unstake(wallet: WalletKeys, params: StakeParams): Promise<ApiResponse>;
439
- faucet(wallet: WalletKeys): Promise<ApiResponse>;
440
- burn(wallet: WalletKeys, amount: number, fee?: number, token?: string): Promise<ApiResponse>;
441
- updateTokenMetadata(wallet: WalletKeys, params: TokenMetadataUpdateParams): Promise<ApiResponse>;
442
- claimTokenMetadata(wallet: WalletKeys, tokenSymbol: string): Promise<ApiResponse>;
443
- }
444
- declare class NftClient {
445
- private readonly rc;
446
- constructor(rc: RougeChain);
447
- getCollections(): Promise<NftCollection[]>;
448
- getCollection(collectionId: string): Promise<NftCollection>;
449
- /**
450
- * Poll until a collection exists on-chain (i.e. the create tx has been mined).
451
- * Useful after `createCollection` since the tx goes to the mempool first.
452
- * @returns the collection once found, or throws after the timeout.
453
- */
454
- waitForCollection(collectionId: string, opts?: {
455
- timeoutMs?: number;
456
- pollMs?: number;
457
- }): Promise<NftCollection>;
458
- getTokens(collectionId: string, opts?: {
459
- limit?: number;
460
- offset?: number;
461
- }): Promise<{
462
- tokens: NftToken[];
463
- total: number;
464
- }>;
465
- getToken(collectionId: string, tokenId: number): Promise<NftToken>;
466
- getByOwner(pubkey: string): Promise<NftToken[]>;
467
- createCollection(wallet: WalletKeys, params: CreateNftCollectionParams): Promise<ApiResponse>;
468
- mint(wallet: WalletKeys, params: MintNftParams): Promise<ApiResponse>;
469
- batchMint(wallet: WalletKeys, params: BatchMintNftParams): Promise<ApiResponse>;
470
- transfer(wallet: WalletKeys, params: TransferNftParams): Promise<ApiResponse>;
471
- burn(wallet: WalletKeys, params: BurnNftParams): Promise<ApiResponse>;
472
- lock(wallet: WalletKeys, params: LockNftParams): Promise<ApiResponse>;
473
- freezeCollection(wallet: WalletKeys, params: FreezeCollectionParams): Promise<ApiResponse>;
474
- }
475
- declare class DexClient {
476
- private readonly rc;
477
- constructor(rc: RougeChain);
478
- getPools(): Promise<LiquidityPool[]>;
479
- getPool(poolId: string): Promise<LiquidityPool>;
480
- getPoolEvents(poolId: string): Promise<PoolEvent[]>;
481
- getPoolPrices(poolId: string): Promise<unknown>;
482
- getPoolStats(poolId: string): Promise<PoolStats>;
483
- quote(params: SwapQuoteParams): Promise<SwapQuote>;
484
- swap(wallet: WalletKeys, params: SwapParams): Promise<ApiResponse>;
485
- createPool(wallet: WalletKeys, params: CreatePoolParams): Promise<ApiResponse>;
486
- addLiquidity(wallet: WalletKeys, params: AddLiquidityParams): Promise<ApiResponse>;
487
- removeLiquidity(wallet: WalletKeys, params: RemoveLiquidityParams): Promise<ApiResponse>;
488
- }
489
- declare class BridgeClient {
490
- private readonly rc;
491
- constructor(rc: RougeChain);
492
- getConfig(): Promise<BridgeConfig>;
493
- getWithdrawals(): Promise<BridgeWithdrawal[]>;
494
- /** Withdraw qETH/qUSDC — signed client-side, private key never sent to server */
495
- withdraw(wallet: WalletKeys, params: BridgeWithdrawParams): Promise<ApiResponse>;
496
- /** Claim qETH or qUSDC after depositing on Base Sepolia */
497
- claim(params: BridgeClaimParams): Promise<ApiResponse>;
498
- getXrgeConfig(): Promise<XrgeBridgeConfig>;
499
- claimXrge(params: XrgeBridgeClaimParams): Promise<ApiResponse>;
500
- withdrawXrge(wallet: WalletKeys, params: XrgeBridgeWithdrawParams): Promise<ApiResponse>;
501
- getXrgeWithdrawals(): Promise<BridgeWithdrawal[]>;
502
- }
503
- declare class MailClient {
504
- private readonly rc;
505
- constructor(rc: RougeChain);
506
- send(params: SendMailParams): Promise<ApiResponse>;
507
- getInbox(walletId: string): Promise<MailMessage[]>;
508
- getSent(walletId: string): Promise<MailMessage[]>;
509
- getTrash(walletId: string): Promise<MailMessage[]>;
510
- getMessage(id: string): Promise<MailMessage>;
511
- move(messageId: string, folder: string): Promise<ApiResponse>;
512
- markRead(messageId: string): Promise<ApiResponse>;
513
- delete(id: string): Promise<ApiResponse>;
514
- }
515
- declare class MessengerClient {
516
- private readonly rc;
517
- constructor(rc: RougeChain);
518
- getWallets(): Promise<MessengerWallet[]>;
519
- registerWallet(opts: {
520
- id: string;
521
- displayName: string;
522
- signingPublicKey: string;
523
- encryptionPublicKey: string;
524
- }): Promise<ApiResponse>;
525
- getConversations(walletId: string, opts?: {
526
- signingPublicKey?: string;
527
- encryptionPublicKey?: string;
528
- }): Promise<MessengerConversation[]>;
529
- createConversation(participants: string[]): Promise<ApiResponse>;
530
- getMessages(conversationId: string): Promise<MessengerMessage[]>;
531
- sendMessage(conversationId: string, sender: string, encryptedContent: string, opts?: {
532
- mediaType?: string;
533
- mediaData?: string;
534
- selfDestruct?: boolean;
535
- destructAfterSeconds?: number;
536
- }): Promise<ApiResponse>;
537
- deleteMessage(messageId: string): Promise<ApiResponse>;
538
- markRead(messageId: string): Promise<ApiResponse>;
539
- }
540
-
541
- declare class Wallet implements WalletKeys {
542
- readonly publicKey: string;
543
- readonly privateKey: string;
544
- private constructor();
545
- /**
546
- * Generate a new ML-DSA-65 keypair.
547
- * Uses crypto.getRandomValues for secure randomness.
548
- */
549
- static generate(): Wallet;
550
- /**
551
- * Restore a wallet from existing hex-encoded keys.
552
- */
553
- static fromKeys(publicKey: string, privateKey: string): Wallet;
554
- /**
555
- * Export keys as a plain object (for serialization/storage).
556
- */
557
- toJSON(): WalletKeys;
558
- /**
559
- * Verify that the keypair is valid by signing and verifying a test message.
560
- */
561
- verify(): boolean;
562
- }
563
-
564
- declare const BURN_ADDRESS = "XRGE_BURN_0x000000000000000000000000000000000000000000000000000000000000DEAD";
565
- declare function serializePayload(payload: TransactionPayload): Uint8Array;
566
- declare function signTransaction(payload: TransactionPayload, privateKey: string, publicKey: string): SignedTransaction;
567
- declare function verifyTransaction(signedTx: SignedTransaction): boolean;
568
- declare function isBurnAddress(address: string): boolean;
569
- declare function createSignedTokenMetadataUpdate(wallet: WalletKeys, tokenSymbol: string, metadata: {
570
- image?: string;
571
- description?: string;
572
- website?: string;
573
- twitter?: string;
574
- discord?: string;
575
- }): SignedTransaction;
576
- declare function createSignedTokenMetadataClaim(wallet: WalletKeys, tokenSymbol: string): SignedTransaction;
577
- declare function createSignedBridgeWithdraw(wallet: WalletKeys, amount: number, evmAddress: string, tokenSymbol?: string, fee?: number): SignedTransaction;
578
-
579
- declare function hexToBytes(hex: string): Uint8Array;
580
- declare function bytesToHex(bytes: Uint8Array): string;
581
- declare function generateNonce(): string;
582
-
583
- 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 RemoveLiquidityParams, RougeChain, type RougeChainOptions, type SendMailParams, 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 Validator, Wallet, type WalletKeys, type XrgeBridgeClaimParams, type XrgeBridgeConfig, type XrgeBridgeWithdrawParams, bytesToHex, createSignedBridgeWithdraw, createSignedTokenMetadataClaim, createSignedTokenMetadataUpdate, generateNonce, hexToBytes, isBurnAddress, serializePayload, signTransaction, verifyTransaction };