@rougechain/sdk 0.1.0 → 0.2.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.cts CHANGED
@@ -7,7 +7,7 @@ interface ApiResponse<T = unknown> {
7
7
  error?: string;
8
8
  data?: T;
9
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";
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";
11
11
  interface TransactionPayload {
12
12
  type: TransactionType;
13
13
  from: string;
@@ -15,6 +15,8 @@ interface TransactionPayload {
15
15
  amount?: number;
16
16
  fee?: number;
17
17
  token?: string;
18
+ tokenSymbol?: string;
19
+ evmAddress?: string;
18
20
  timestamp: number;
19
21
  nonce: string;
20
22
  token_name?: string;
@@ -189,6 +191,7 @@ interface BridgeConfig {
189
191
  enabled: boolean;
190
192
  custodyAddress?: string;
191
193
  chainId: number;
194
+ supportedTokens?: string[];
192
195
  }
193
196
  interface BridgeWithdrawal {
194
197
  tx_id: string;
@@ -198,6 +201,56 @@ interface BridgeWithdrawal {
198
201
  status: string;
199
202
  created_at: number;
200
203
  }
204
+ interface XrgeBridgeConfig {
205
+ enabled: boolean;
206
+ vaultAddress?: string;
207
+ tokenAddress?: string;
208
+ chainId: number;
209
+ }
210
+ interface MailMessage {
211
+ id: string;
212
+ from: string;
213
+ to: string;
214
+ subject: string;
215
+ body: string;
216
+ encrypted_subject?: string;
217
+ encrypted_body?: string;
218
+ reply_to_id?: string;
219
+ read: boolean;
220
+ folder: "inbox" | "sent" | "trash";
221
+ created_at: number;
222
+ }
223
+ interface SendMailParams {
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
+ }
232
+ interface MessengerWallet {
233
+ wallet_id: string;
234
+ display_name?: string;
235
+ encryption_public_key?: string;
236
+ created_at: number;
237
+ }
238
+ interface MessengerConversation {
239
+ id: string;
240
+ participants: string[];
241
+ created_at: number;
242
+ }
243
+ interface MessengerMessage {
244
+ id: string;
245
+ conversation_id: string;
246
+ sender: string;
247
+ encrypted_content: string;
248
+ media_type?: string;
249
+ media_data?: string;
250
+ self_destruct?: boolean;
251
+ read?: boolean;
252
+ created_at: number;
253
+ }
201
254
  interface TransferParams {
202
255
  to: string;
203
256
  amount: number;
@@ -278,6 +331,24 @@ interface BridgeWithdrawParams {
278
331
  amount: number;
279
332
  evmAddress: string;
280
333
  fee?: number;
334
+ tokenSymbol?: string;
335
+ }
336
+ interface BridgeClaimParams {
337
+ evmTxHash: string;
338
+ evmAddress: string;
339
+ evmSignature: string;
340
+ recipientPubkey: string;
341
+ token?: "ETH" | "USDC";
342
+ }
343
+ interface XrgeBridgeClaimParams {
344
+ evmTxHash: string;
345
+ evmAddress: string;
346
+ amount: string;
347
+ recipientPubkey: string;
348
+ }
349
+ interface XrgeBridgeWithdrawParams {
350
+ amount: number;
351
+ evmAddress: string;
281
352
  }
282
353
  interface SwapQuoteParams {
283
354
  poolId: string;
@@ -301,12 +372,14 @@ interface RougeChainOptions {
301
372
  apiKey?: string;
302
373
  }
303
374
  declare class RougeChain {
304
- private readonly baseUrl;
305
- private readonly fetchFn;
306
- private readonly headers;
375
+ /** @internal */ readonly baseUrl: string;
376
+ /** @internal */ readonly fetchFn: FetchFn;
377
+ /** @internal */ readonly headers: Record<string, string>;
307
378
  readonly nft: NftClient;
308
379
  readonly dex: DexClient;
309
380
  readonly bridge: BridgeClient;
381
+ readonly mail: MailClient;
382
+ readonly messenger: MessengerClient;
310
383
  constructor(baseUrl: string, options?: RougeChainOptions);
311
384
  /** @internal */
312
385
  get<T = unknown>(path: string): Promise<T>;
@@ -396,13 +469,41 @@ declare class BridgeClient {
396
469
  constructor(rc: RougeChain);
397
470
  getConfig(): Promise<BridgeConfig>;
398
471
  getWithdrawals(): Promise<BridgeWithdrawal[]>;
472
+ /** Withdraw qETH/qUSDC — signed client-side, private key never sent to server */
399
473
  withdraw(wallet: WalletKeys, params: BridgeWithdrawParams): Promise<ApiResponse>;
400
- claim(params: {
401
- evmTxHash: string;
402
- evmAddress: string;
403
- evmSignature: string;
404
- recipientPubkey: string;
474
+ /** Claim qETH or qUSDC after depositing on Base Sepolia */
475
+ claim(params: BridgeClaimParams): Promise<ApiResponse>;
476
+ getXrgeConfig(): Promise<XrgeBridgeConfig>;
477
+ claimXrge(params: XrgeBridgeClaimParams): Promise<ApiResponse>;
478
+ withdrawXrge(wallet: WalletKeys, params: XrgeBridgeWithdrawParams): Promise<ApiResponse>;
479
+ getXrgeWithdrawals(): Promise<BridgeWithdrawal[]>;
480
+ }
481
+ declare class MailClient {
482
+ private readonly rc;
483
+ constructor(rc: RougeChain);
484
+ send(params: SendMailParams): Promise<ApiResponse>;
485
+ getInbox(walletId: string): Promise<MailMessage[]>;
486
+ getSent(walletId: string): Promise<MailMessage[]>;
487
+ getTrash(walletId: string): Promise<MailMessage[]>;
488
+ getMessage(id: string): Promise<MailMessage>;
489
+ move(messageId: string, folder: string): Promise<ApiResponse>;
490
+ markRead(messageId: string): Promise<ApiResponse>;
491
+ delete(id: string): Promise<ApiResponse>;
492
+ }
493
+ declare class MessengerClient {
494
+ private readonly rc;
495
+ constructor(rc: RougeChain);
496
+ getWallets(): Promise<MessengerWallet[]>;
497
+ registerWallet(walletId: string, displayName?: string, encryptionPublicKey?: string): Promise<ApiResponse>;
498
+ getConversations(walletId: string): Promise<MessengerConversation[]>;
499
+ createConversation(participants: string[]): Promise<ApiResponse>;
500
+ getMessages(conversationId: string): Promise<MessengerMessage[]>;
501
+ sendMessage(conversationId: string, sender: string, encryptedContent: string, opts?: {
502
+ mediaType?: string;
503
+ mediaData?: string;
504
+ selfDestruct?: boolean;
405
505
  }): Promise<ApiResponse>;
506
+ markRead(messageId: string): Promise<ApiResponse>;
406
507
  }
407
508
 
408
509
  declare class Wallet implements WalletKeys {
@@ -433,9 +534,10 @@ declare function serializePayload(payload: TransactionPayload): Uint8Array;
433
534
  declare function signTransaction(payload: TransactionPayload, privateKey: string, publicKey: string): SignedTransaction;
434
535
  declare function verifyTransaction(signedTx: SignedTransaction): boolean;
435
536
  declare function isBurnAddress(address: string): boolean;
537
+ declare function createSignedBridgeWithdraw(wallet: WalletKeys, amount: number, evmAddress: string, tokenSymbol?: string, fee?: number): SignedTransaction;
436
538
 
437
539
  declare function hexToBytes(hex: string): Uint8Array;
438
540
  declare function bytesToHex(bytes: Uint8Array): string;
439
541
  declare function generateNonce(): string;
440
542
 
441
- export { type AddLiquidityParams, type ApiResponse, BURN_ADDRESS, type BalanceResponse, type BatchMintNftParams, type Block, type BlockHeader, type BridgeConfig, type BridgeWithdrawParams, type BridgeWithdrawal, type BurnNftParams, type CreateNftCollectionParams, type CreatePoolParams, type CreateTokenParams, type FreezeCollectionParams, type LiquidityPool, type LockNftParams, type MintNftParams, type NftCollection, type NftToken, type NodeStats, type PoolEvent, type PoolStats, type RemoveLiquidityParams, RougeChain, type RougeChainOptions, 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, bytesToHex, generateNonce, hexToBytes, isBurnAddress, serializePayload, signTransaction, verifyTransaction };
543
+ 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, generateNonce, hexToBytes, isBurnAddress, serializePayload, signTransaction, verifyTransaction };
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ interface ApiResponse<T = unknown> {
7
7
  error?: string;
8
8
  data?: T;
9
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";
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";
11
11
  interface TransactionPayload {
12
12
  type: TransactionType;
13
13
  from: string;
@@ -15,6 +15,8 @@ interface TransactionPayload {
15
15
  amount?: number;
16
16
  fee?: number;
17
17
  token?: string;
18
+ tokenSymbol?: string;
19
+ evmAddress?: string;
18
20
  timestamp: number;
19
21
  nonce: string;
20
22
  token_name?: string;
@@ -189,6 +191,7 @@ interface BridgeConfig {
189
191
  enabled: boolean;
190
192
  custodyAddress?: string;
191
193
  chainId: number;
194
+ supportedTokens?: string[];
192
195
  }
193
196
  interface BridgeWithdrawal {
194
197
  tx_id: string;
@@ -198,6 +201,56 @@ interface BridgeWithdrawal {
198
201
  status: string;
199
202
  created_at: number;
200
203
  }
204
+ interface XrgeBridgeConfig {
205
+ enabled: boolean;
206
+ vaultAddress?: string;
207
+ tokenAddress?: string;
208
+ chainId: number;
209
+ }
210
+ interface MailMessage {
211
+ id: string;
212
+ from: string;
213
+ to: string;
214
+ subject: string;
215
+ body: string;
216
+ encrypted_subject?: string;
217
+ encrypted_body?: string;
218
+ reply_to_id?: string;
219
+ read: boolean;
220
+ folder: "inbox" | "sent" | "trash";
221
+ created_at: number;
222
+ }
223
+ interface SendMailParams {
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
+ }
232
+ interface MessengerWallet {
233
+ wallet_id: string;
234
+ display_name?: string;
235
+ encryption_public_key?: string;
236
+ created_at: number;
237
+ }
238
+ interface MessengerConversation {
239
+ id: string;
240
+ participants: string[];
241
+ created_at: number;
242
+ }
243
+ interface MessengerMessage {
244
+ id: string;
245
+ conversation_id: string;
246
+ sender: string;
247
+ encrypted_content: string;
248
+ media_type?: string;
249
+ media_data?: string;
250
+ self_destruct?: boolean;
251
+ read?: boolean;
252
+ created_at: number;
253
+ }
201
254
  interface TransferParams {
202
255
  to: string;
203
256
  amount: number;
@@ -278,6 +331,24 @@ interface BridgeWithdrawParams {
278
331
  amount: number;
279
332
  evmAddress: string;
280
333
  fee?: number;
334
+ tokenSymbol?: string;
335
+ }
336
+ interface BridgeClaimParams {
337
+ evmTxHash: string;
338
+ evmAddress: string;
339
+ evmSignature: string;
340
+ recipientPubkey: string;
341
+ token?: "ETH" | "USDC";
342
+ }
343
+ interface XrgeBridgeClaimParams {
344
+ evmTxHash: string;
345
+ evmAddress: string;
346
+ amount: string;
347
+ recipientPubkey: string;
348
+ }
349
+ interface XrgeBridgeWithdrawParams {
350
+ amount: number;
351
+ evmAddress: string;
281
352
  }
282
353
  interface SwapQuoteParams {
283
354
  poolId: string;
@@ -301,12 +372,14 @@ interface RougeChainOptions {
301
372
  apiKey?: string;
302
373
  }
303
374
  declare class RougeChain {
304
- private readonly baseUrl;
305
- private readonly fetchFn;
306
- private readonly headers;
375
+ /** @internal */ readonly baseUrl: string;
376
+ /** @internal */ readonly fetchFn: FetchFn;
377
+ /** @internal */ readonly headers: Record<string, string>;
307
378
  readonly nft: NftClient;
308
379
  readonly dex: DexClient;
309
380
  readonly bridge: BridgeClient;
381
+ readonly mail: MailClient;
382
+ readonly messenger: MessengerClient;
310
383
  constructor(baseUrl: string, options?: RougeChainOptions);
311
384
  /** @internal */
312
385
  get<T = unknown>(path: string): Promise<T>;
@@ -396,13 +469,41 @@ declare class BridgeClient {
396
469
  constructor(rc: RougeChain);
397
470
  getConfig(): Promise<BridgeConfig>;
398
471
  getWithdrawals(): Promise<BridgeWithdrawal[]>;
472
+ /** Withdraw qETH/qUSDC — signed client-side, private key never sent to server */
399
473
  withdraw(wallet: WalletKeys, params: BridgeWithdrawParams): Promise<ApiResponse>;
400
- claim(params: {
401
- evmTxHash: string;
402
- evmAddress: string;
403
- evmSignature: string;
404
- recipientPubkey: string;
474
+ /** Claim qETH or qUSDC after depositing on Base Sepolia */
475
+ claim(params: BridgeClaimParams): Promise<ApiResponse>;
476
+ getXrgeConfig(): Promise<XrgeBridgeConfig>;
477
+ claimXrge(params: XrgeBridgeClaimParams): Promise<ApiResponse>;
478
+ withdrawXrge(wallet: WalletKeys, params: XrgeBridgeWithdrawParams): Promise<ApiResponse>;
479
+ getXrgeWithdrawals(): Promise<BridgeWithdrawal[]>;
480
+ }
481
+ declare class MailClient {
482
+ private readonly rc;
483
+ constructor(rc: RougeChain);
484
+ send(params: SendMailParams): Promise<ApiResponse>;
485
+ getInbox(walletId: string): Promise<MailMessage[]>;
486
+ getSent(walletId: string): Promise<MailMessage[]>;
487
+ getTrash(walletId: string): Promise<MailMessage[]>;
488
+ getMessage(id: string): Promise<MailMessage>;
489
+ move(messageId: string, folder: string): Promise<ApiResponse>;
490
+ markRead(messageId: string): Promise<ApiResponse>;
491
+ delete(id: string): Promise<ApiResponse>;
492
+ }
493
+ declare class MessengerClient {
494
+ private readonly rc;
495
+ constructor(rc: RougeChain);
496
+ getWallets(): Promise<MessengerWallet[]>;
497
+ registerWallet(walletId: string, displayName?: string, encryptionPublicKey?: string): Promise<ApiResponse>;
498
+ getConversations(walletId: string): Promise<MessengerConversation[]>;
499
+ createConversation(participants: string[]): Promise<ApiResponse>;
500
+ getMessages(conversationId: string): Promise<MessengerMessage[]>;
501
+ sendMessage(conversationId: string, sender: string, encryptedContent: string, opts?: {
502
+ mediaType?: string;
503
+ mediaData?: string;
504
+ selfDestruct?: boolean;
405
505
  }): Promise<ApiResponse>;
506
+ markRead(messageId: string): Promise<ApiResponse>;
406
507
  }
407
508
 
408
509
  declare class Wallet implements WalletKeys {
@@ -433,9 +534,10 @@ declare function serializePayload(payload: TransactionPayload): Uint8Array;
433
534
  declare function signTransaction(payload: TransactionPayload, privateKey: string, publicKey: string): SignedTransaction;
434
535
  declare function verifyTransaction(signedTx: SignedTransaction): boolean;
435
536
  declare function isBurnAddress(address: string): boolean;
537
+ declare function createSignedBridgeWithdraw(wallet: WalletKeys, amount: number, evmAddress: string, tokenSymbol?: string, fee?: number): SignedTransaction;
436
538
 
437
539
  declare function hexToBytes(hex: string): Uint8Array;
438
540
  declare function bytesToHex(bytes: Uint8Array): string;
439
541
  declare function generateNonce(): string;
440
542
 
441
- export { type AddLiquidityParams, type ApiResponse, BURN_ADDRESS, type BalanceResponse, type BatchMintNftParams, type Block, type BlockHeader, type BridgeConfig, type BridgeWithdrawParams, type BridgeWithdrawal, type BurnNftParams, type CreateNftCollectionParams, type CreatePoolParams, type CreateTokenParams, type FreezeCollectionParams, type LiquidityPool, type LockNftParams, type MintNftParams, type NftCollection, type NftToken, type NodeStats, type PoolEvent, type PoolStats, type RemoveLiquidityParams, RougeChain, type RougeChainOptions, 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, bytesToHex, generateNonce, hexToBytes, isBurnAddress, serializePayload, signTransaction, verifyTransaction };
543
+ 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, generateNonce, hexToBytes, isBurnAddress, serializePayload, signTransaction, verifyTransaction };
package/dist/index.js CHANGED
@@ -120,6 +120,16 @@ function createSignedBurn(wallet, amount, fee = 1, token = "XRGE") {
120
120
  token
121
121
  });
122
122
  }
123
+ function createSignedBridgeWithdraw(wallet, amount, evmAddress, tokenSymbol = "qETH", fee = 0.1) {
124
+ const evm = evmAddress.startsWith("0x") ? evmAddress : `0x${evmAddress}`;
125
+ return buildAndSign(wallet, {
126
+ type: "bridge_withdraw",
127
+ amount,
128
+ fee,
129
+ tokenSymbol,
130
+ evmAddress: evm
131
+ });
132
+ }
123
133
  function createSignedNftCreateCollection(wallet, symbol, name, opts = {}) {
124
134
  return buildAndSign(wallet, {
125
135
  type: "nft_create_collection",
@@ -200,6 +210,8 @@ var RougeChain = class {
200
210
  this.nft = new NftClient(this);
201
211
  this.dex = new DexClient(this);
202
212
  this.bridge = new BridgeClient(this);
213
+ this.mail = new MailClient(this);
214
+ this.messenger = new MessengerClient(this);
203
215
  }
204
216
  // ===== Internal helpers =====
205
217
  /** @internal */
@@ -545,7 +557,8 @@ var BridgeClient = class {
545
557
  return {
546
558
  enabled: data.enabled === true,
547
559
  custodyAddress: data.custodyAddress,
548
- chainId: data.chainId ?? 84532
560
+ chainId: data.chainId ?? 84532,
561
+ supportedTokens: data.supportedTokens
549
562
  };
550
563
  } catch {
551
564
  return { enabled: false, chainId: 84532 };
@@ -557,17 +570,25 @@ var BridgeClient = class {
557
570
  );
558
571
  return data.withdrawals;
559
572
  }
573
+ /** Withdraw qETH/qUSDC — signed client-side, private key never sent to server */
560
574
  async withdraw(wallet, params) {
561
575
  try {
562
- const evm = params.evmAddress.startsWith("0x") ? params.evmAddress : `0x${params.evmAddress}`;
576
+ const tokenSymbol = params.tokenSymbol ?? "qETH";
577
+ const signed = createSignedBridgeWithdraw(
578
+ wallet,
579
+ params.amount,
580
+ params.evmAddress,
581
+ tokenSymbol,
582
+ params.fee
583
+ );
563
584
  const data = await this.rc.post(
564
585
  "/bridge/withdraw",
565
586
  {
566
- fromPrivateKey: wallet.privateKey,
567
587
  fromPublicKey: wallet.publicKey,
568
588
  amountUnits: params.amount,
569
- evmAddress: evm,
570
- fee: params.fee
589
+ evmAddress: signed.payload.evmAddress,
590
+ signature: signed.signature,
591
+ payload: signed.payload
571
592
  }
572
593
  );
573
594
  return {
@@ -582,6 +603,7 @@ var BridgeClient = class {
582
603
  };
583
604
  }
584
605
  }
606
+ /** Claim qETH or qUSDC after depositing on Base Sepolia */
585
607
  async claim(params) {
586
608
  try {
587
609
  const data = await this.rc.post(
@@ -590,7 +612,8 @@ var BridgeClient = class {
590
612
  evmTxHash: params.evmTxHash.startsWith("0x") ? params.evmTxHash : `0x${params.evmTxHash}`,
591
613
  evmAddress: params.evmAddress.startsWith("0x") ? params.evmAddress : `0x${params.evmAddress}`,
592
614
  evmSignature: params.evmSignature,
593
- recipientRougechainPubkey: params.recipientPubkey
615
+ recipientRougechainPubkey: params.recipientPubkey,
616
+ token: params.token ?? "ETH"
594
617
  }
595
618
  );
596
619
  return {
@@ -605,6 +628,213 @@ var BridgeClient = class {
605
628
  };
606
629
  }
607
630
  }
631
+ // ── XRGE Bridge ──
632
+ async getXrgeConfig() {
633
+ try {
634
+ const data = await this.rc.get("/bridge/xrge/config");
635
+ return {
636
+ enabled: data.enabled === true,
637
+ vaultAddress: data.vaultAddress,
638
+ tokenAddress: data.tokenAddress,
639
+ chainId: data.chainId ?? 84532
640
+ };
641
+ } catch {
642
+ return { enabled: false, chainId: 84532 };
643
+ }
644
+ }
645
+ async claimXrge(params) {
646
+ try {
647
+ const data = await this.rc.post(
648
+ "/bridge/xrge/claim",
649
+ {
650
+ evmTxHash: params.evmTxHash.startsWith("0x") ? params.evmTxHash : `0x${params.evmTxHash}`,
651
+ evmAddress: params.evmAddress.startsWith("0x") ? params.evmAddress : `0x${params.evmAddress}`,
652
+ amount: params.amount,
653
+ recipientRougechainPubkey: params.recipientPubkey
654
+ }
655
+ );
656
+ return {
657
+ success: data.success === true,
658
+ error: data.error,
659
+ data
660
+ };
661
+ } catch (e) {
662
+ return { success: false, error: e instanceof Error ? e.message : String(e) };
663
+ }
664
+ }
665
+ async withdrawXrge(wallet, params) {
666
+ try {
667
+ const signed = createSignedBridgeWithdraw(
668
+ wallet,
669
+ params.amount,
670
+ params.evmAddress,
671
+ "XRGE",
672
+ 0.1
673
+ );
674
+ const data = await this.rc.post(
675
+ "/bridge/xrge/withdraw",
676
+ {
677
+ fromPublicKey: wallet.publicKey,
678
+ amount: params.amount,
679
+ evmAddress: signed.payload.evmAddress,
680
+ signature: signed.signature,
681
+ payload: signed.payload
682
+ }
683
+ );
684
+ return {
685
+ success: data.success === true,
686
+ error: data.error,
687
+ data
688
+ };
689
+ } catch (e) {
690
+ return { success: false, error: e instanceof Error ? e.message : String(e) };
691
+ }
692
+ }
693
+ async getXrgeWithdrawals() {
694
+ try {
695
+ const data = await this.rc.get(
696
+ "/bridge/xrge/withdrawals"
697
+ );
698
+ return data.withdrawals;
699
+ } catch {
700
+ return [];
701
+ }
702
+ }
703
+ };
704
+ var MailClient = class {
705
+ constructor(rc) {
706
+ this.rc = rc;
707
+ }
708
+ async send(params) {
709
+ try {
710
+ const data = await this.rc.post("/mail/send", params);
711
+ return { success: data.success === true, error: data.error, data };
712
+ } catch (e) {
713
+ return { success: false, error: e instanceof Error ? e.message : String(e) };
714
+ }
715
+ }
716
+ async getInbox(walletId) {
717
+ const data = await this.rc.get(
718
+ `/mail/inbox?walletId=${encodeURIComponent(walletId)}`
719
+ );
720
+ return data.messages ?? [];
721
+ }
722
+ async getSent(walletId) {
723
+ const data = await this.rc.get(
724
+ `/mail/sent?walletId=${encodeURIComponent(walletId)}`
725
+ );
726
+ return data.messages ?? [];
727
+ }
728
+ async getTrash(walletId) {
729
+ const data = await this.rc.get(
730
+ `/mail/trash?walletId=${encodeURIComponent(walletId)}`
731
+ );
732
+ return data.messages ?? [];
733
+ }
734
+ async getMessage(id) {
735
+ return this.rc.get(`/mail/message/${encodeURIComponent(id)}`);
736
+ }
737
+ async move(messageId, folder) {
738
+ try {
739
+ const data = await this.rc.post("/mail/move", {
740
+ messageId,
741
+ folder
742
+ });
743
+ return { success: data.success === true, error: data.error };
744
+ } catch (e) {
745
+ return { success: false, error: e instanceof Error ? e.message : String(e) };
746
+ }
747
+ }
748
+ async markRead(messageId) {
749
+ try {
750
+ const data = await this.rc.post("/mail/read", {
751
+ messageId
752
+ });
753
+ return { success: data.success === true, error: data.error };
754
+ } catch (e) {
755
+ return { success: false, error: e instanceof Error ? e.message : String(e) };
756
+ }
757
+ }
758
+ async delete(id) {
759
+ try {
760
+ const res = await this.rc.fetchFn(
761
+ `${this.rc.baseUrl}/mail/${encodeURIComponent(id)}`,
762
+ { method: "DELETE", headers: this.rc.headers }
763
+ );
764
+ const data = await res.json();
765
+ return { success: data.success === true, error: data.error };
766
+ } catch (e) {
767
+ return { success: false, error: e instanceof Error ? e.message : String(e) };
768
+ }
769
+ }
770
+ };
771
+ var MessengerClient = class {
772
+ constructor(rc) {
773
+ this.rc = rc;
774
+ }
775
+ async getWallets() {
776
+ const data = await this.rc.get("/messenger/wallets");
777
+ return data.wallets ?? [];
778
+ }
779
+ async registerWallet(walletId, displayName, encryptionPublicKey) {
780
+ try {
781
+ const data = await this.rc.post("/messenger/wallets/register", {
782
+ wallet_id: walletId,
783
+ display_name: displayName,
784
+ encryption_public_key: encryptionPublicKey
785
+ });
786
+ return { success: data.success === true, error: data.error };
787
+ } catch (e) {
788
+ return { success: false, error: e instanceof Error ? e.message : String(e) };
789
+ }
790
+ }
791
+ async getConversations(walletId) {
792
+ const data = await this.rc.get(
793
+ `/messenger/conversations?walletId=${encodeURIComponent(walletId)}`
794
+ );
795
+ return data.conversations ?? [];
796
+ }
797
+ async createConversation(participants) {
798
+ try {
799
+ const data = await this.rc.post("/messenger/conversations", {
800
+ participants
801
+ });
802
+ return { success: data.success === true, error: data.error, data };
803
+ } catch (e) {
804
+ return { success: false, error: e instanceof Error ? e.message : String(e) };
805
+ }
806
+ }
807
+ async getMessages(conversationId) {
808
+ const data = await this.rc.get(
809
+ `/messenger/messages?conversationId=${encodeURIComponent(conversationId)}`
810
+ );
811
+ return data.messages ?? [];
812
+ }
813
+ async sendMessage(conversationId, sender, encryptedContent, opts = {}) {
814
+ try {
815
+ const data = await this.rc.post("/messenger/messages", {
816
+ conversation_id: conversationId,
817
+ sender,
818
+ encrypted_content: encryptedContent,
819
+ media_type: opts.mediaType,
820
+ media_data: opts.mediaData,
821
+ self_destruct: opts.selfDestruct
822
+ });
823
+ return { success: data.success === true, error: data.error, data };
824
+ } catch (e) {
825
+ return { success: false, error: e instanceof Error ? e.message : String(e) };
826
+ }
827
+ }
828
+ async markRead(messageId) {
829
+ try {
830
+ const data = await this.rc.post("/messenger/messages/read", {
831
+ message_id: messageId
832
+ });
833
+ return { success: data.success === true, error: data.error };
834
+ } catch (e) {
835
+ return { success: false, error: e instanceof Error ? e.message : String(e) };
836
+ }
837
+ }
608
838
  };
609
839
  var Wallet = class _Wallet {
610
840
  constructor(publicKey, privateKey) {
@@ -648,6 +878,6 @@ var Wallet = class _Wallet {
648
878
  }
649
879
  };
650
880
 
651
- export { BURN_ADDRESS, RougeChain, Wallet, bytesToHex, generateNonce, hexToBytes, isBurnAddress, serializePayload, signTransaction, verifyTransaction };
881
+ export { BURN_ADDRESS, RougeChain, Wallet, bytesToHex, createSignedBridgeWithdraw, generateNonce, hexToBytes, isBurnAddress, serializePayload, signTransaction, verifyTransaction };
652
882
  //# sourceMappingURL=index.js.map
653
883
  //# sourceMappingURL=index.js.map