@rougechain/sdk 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +210 -209
- package/dist/index.cjs +278 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +126 -10
- package/dist/index.d.ts +126 -10
- package/dist/index.js +276 -33
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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" | "update_token_metadata" | "claim_token_metadata";
|
|
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;
|
|
@@ -46,6 +48,9 @@ interface TransactionPayload {
|
|
|
46
48
|
names?: string[];
|
|
47
49
|
uris?: string[];
|
|
48
50
|
batchAttributes?: unknown[];
|
|
51
|
+
website?: string;
|
|
52
|
+
twitter?: string;
|
|
53
|
+
discord?: string;
|
|
49
54
|
}
|
|
50
55
|
interface SignedTransaction {
|
|
51
56
|
payload: TransactionPayload;
|
|
@@ -189,6 +194,7 @@ interface BridgeConfig {
|
|
|
189
194
|
enabled: boolean;
|
|
190
195
|
custodyAddress?: string;
|
|
191
196
|
chainId: number;
|
|
197
|
+
supportedTokens?: string[];
|
|
192
198
|
}
|
|
193
199
|
interface BridgeWithdrawal {
|
|
194
200
|
tx_id: string;
|
|
@@ -198,6 +204,56 @@ interface BridgeWithdrawal {
|
|
|
198
204
|
status: string;
|
|
199
205
|
created_at: number;
|
|
200
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
|
+
wallet_id: string;
|
|
237
|
+
display_name?: string;
|
|
238
|
+
encryption_public_key?: string;
|
|
239
|
+
created_at: number;
|
|
240
|
+
}
|
|
241
|
+
interface MessengerConversation {
|
|
242
|
+
id: string;
|
|
243
|
+
participants: string[];
|
|
244
|
+
created_at: number;
|
|
245
|
+
}
|
|
246
|
+
interface MessengerMessage {
|
|
247
|
+
id: string;
|
|
248
|
+
conversation_id: string;
|
|
249
|
+
sender: string;
|
|
250
|
+
encrypted_content: string;
|
|
251
|
+
media_type?: string;
|
|
252
|
+
media_data?: string;
|
|
253
|
+
self_destruct?: boolean;
|
|
254
|
+
read?: boolean;
|
|
255
|
+
created_at: number;
|
|
256
|
+
}
|
|
201
257
|
interface TransferParams {
|
|
202
258
|
to: string;
|
|
203
259
|
amount: number;
|
|
@@ -209,6 +265,8 @@ interface CreateTokenParams {
|
|
|
209
265
|
symbol: string;
|
|
210
266
|
totalSupply: number;
|
|
211
267
|
fee?: number;
|
|
268
|
+
/** Token logo — URL or data URI (base64). Stored on-chain in token metadata. */
|
|
269
|
+
image?: string;
|
|
212
270
|
}
|
|
213
271
|
interface SwapParams {
|
|
214
272
|
tokenIn: string;
|
|
@@ -278,6 +336,24 @@ interface BridgeWithdrawParams {
|
|
|
278
336
|
amount: number;
|
|
279
337
|
evmAddress: string;
|
|
280
338
|
fee?: number;
|
|
339
|
+
tokenSymbol?: string;
|
|
340
|
+
}
|
|
341
|
+
interface BridgeClaimParams {
|
|
342
|
+
evmTxHash: string;
|
|
343
|
+
evmAddress: string;
|
|
344
|
+
evmSignature: string;
|
|
345
|
+
recipientPubkey: string;
|
|
346
|
+
token?: "ETH" | "USDC";
|
|
347
|
+
}
|
|
348
|
+
interface XrgeBridgeClaimParams {
|
|
349
|
+
evmTxHash: string;
|
|
350
|
+
evmAddress: string;
|
|
351
|
+
amount: string;
|
|
352
|
+
recipientPubkey: string;
|
|
353
|
+
}
|
|
354
|
+
interface XrgeBridgeWithdrawParams {
|
|
355
|
+
amount: number;
|
|
356
|
+
evmAddress: string;
|
|
281
357
|
}
|
|
282
358
|
interface SwapQuoteParams {
|
|
283
359
|
poolId: string;
|
|
@@ -301,12 +377,14 @@ interface RougeChainOptions {
|
|
|
301
377
|
apiKey?: string;
|
|
302
378
|
}
|
|
303
379
|
declare class RougeChain {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
380
|
+
/** @internal */ readonly baseUrl: string;
|
|
381
|
+
/** @internal */ readonly fetchFn: FetchFn;
|
|
382
|
+
/** @internal */ readonly headers: Record<string, string>;
|
|
307
383
|
readonly nft: NftClient;
|
|
308
384
|
readonly dex: DexClient;
|
|
309
385
|
readonly bridge: BridgeClient;
|
|
386
|
+
readonly mail: MailClient;
|
|
387
|
+
readonly messenger: MessengerClient;
|
|
310
388
|
constructor(baseUrl: string, options?: RougeChainOptions);
|
|
311
389
|
/** @internal */
|
|
312
390
|
get<T = unknown>(path: string): Promise<T>;
|
|
@@ -354,6 +432,7 @@ declare class RougeChain {
|
|
|
354
432
|
faucet(wallet: WalletKeys): Promise<ApiResponse>;
|
|
355
433
|
burn(wallet: WalletKeys, amount: number, fee?: number, token?: string): Promise<ApiResponse>;
|
|
356
434
|
updateTokenMetadata(wallet: WalletKeys, params: TokenMetadataUpdateParams): Promise<ApiResponse>;
|
|
435
|
+
claimTokenMetadata(wallet: WalletKeys, tokenSymbol: string): Promise<ApiResponse>;
|
|
357
436
|
}
|
|
358
437
|
declare class NftClient {
|
|
359
438
|
private readonly rc;
|
|
@@ -396,13 +475,41 @@ declare class BridgeClient {
|
|
|
396
475
|
constructor(rc: RougeChain);
|
|
397
476
|
getConfig(): Promise<BridgeConfig>;
|
|
398
477
|
getWithdrawals(): Promise<BridgeWithdrawal[]>;
|
|
478
|
+
/** Withdraw qETH/qUSDC — signed client-side, private key never sent to server */
|
|
399
479
|
withdraw(wallet: WalletKeys, params: BridgeWithdrawParams): Promise<ApiResponse>;
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
480
|
+
/** Claim qETH or qUSDC after depositing on Base Sepolia */
|
|
481
|
+
claim(params: BridgeClaimParams): Promise<ApiResponse>;
|
|
482
|
+
getXrgeConfig(): Promise<XrgeBridgeConfig>;
|
|
483
|
+
claimXrge(params: XrgeBridgeClaimParams): Promise<ApiResponse>;
|
|
484
|
+
withdrawXrge(wallet: WalletKeys, params: XrgeBridgeWithdrawParams): Promise<ApiResponse>;
|
|
485
|
+
getXrgeWithdrawals(): Promise<BridgeWithdrawal[]>;
|
|
486
|
+
}
|
|
487
|
+
declare class MailClient {
|
|
488
|
+
private readonly rc;
|
|
489
|
+
constructor(rc: RougeChain);
|
|
490
|
+
send(params: SendMailParams): Promise<ApiResponse>;
|
|
491
|
+
getInbox(walletId: string): Promise<MailMessage[]>;
|
|
492
|
+
getSent(walletId: string): Promise<MailMessage[]>;
|
|
493
|
+
getTrash(walletId: string): Promise<MailMessage[]>;
|
|
494
|
+
getMessage(id: string): Promise<MailMessage>;
|
|
495
|
+
move(messageId: string, folder: string): Promise<ApiResponse>;
|
|
496
|
+
markRead(messageId: string): Promise<ApiResponse>;
|
|
497
|
+
delete(id: string): Promise<ApiResponse>;
|
|
498
|
+
}
|
|
499
|
+
declare class MessengerClient {
|
|
500
|
+
private readonly rc;
|
|
501
|
+
constructor(rc: RougeChain);
|
|
502
|
+
getWallets(): Promise<MessengerWallet[]>;
|
|
503
|
+
registerWallet(walletId: string, displayName?: string, encryptionPublicKey?: string): Promise<ApiResponse>;
|
|
504
|
+
getConversations(walletId: string): Promise<MessengerConversation[]>;
|
|
505
|
+
createConversation(participants: string[]): Promise<ApiResponse>;
|
|
506
|
+
getMessages(conversationId: string): Promise<MessengerMessage[]>;
|
|
507
|
+
sendMessage(conversationId: string, sender: string, encryptedContent: string, opts?: {
|
|
508
|
+
mediaType?: string;
|
|
509
|
+
mediaData?: string;
|
|
510
|
+
selfDestruct?: boolean;
|
|
405
511
|
}): Promise<ApiResponse>;
|
|
512
|
+
markRead(messageId: string): Promise<ApiResponse>;
|
|
406
513
|
}
|
|
407
514
|
|
|
408
515
|
declare class Wallet implements WalletKeys {
|
|
@@ -433,9 +540,18 @@ declare function serializePayload(payload: TransactionPayload): Uint8Array;
|
|
|
433
540
|
declare function signTransaction(payload: TransactionPayload, privateKey: string, publicKey: string): SignedTransaction;
|
|
434
541
|
declare function verifyTransaction(signedTx: SignedTransaction): boolean;
|
|
435
542
|
declare function isBurnAddress(address: string): boolean;
|
|
543
|
+
declare function createSignedTokenMetadataUpdate(wallet: WalletKeys, tokenSymbol: string, metadata: {
|
|
544
|
+
image?: string;
|
|
545
|
+
description?: string;
|
|
546
|
+
website?: string;
|
|
547
|
+
twitter?: string;
|
|
548
|
+
discord?: string;
|
|
549
|
+
}): SignedTransaction;
|
|
550
|
+
declare function createSignedTokenMetadataClaim(wallet: WalletKeys, tokenSymbol: string): SignedTransaction;
|
|
551
|
+
declare function createSignedBridgeWithdraw(wallet: WalletKeys, amount: number, evmAddress: string, tokenSymbol?: string, fee?: number): SignedTransaction;
|
|
436
552
|
|
|
437
553
|
declare function hexToBytes(hex: string): Uint8Array;
|
|
438
554
|
declare function bytesToHex(bytes: Uint8Array): string;
|
|
439
555
|
declare function generateNonce(): string;
|
|
440
556
|
|
|
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 };
|
|
557
|
+
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 };
|
package/dist/index.js
CHANGED
|
@@ -26,7 +26,7 @@ function serializePayload(payload) {
|
|
|
26
26
|
}
|
|
27
27
|
function signTransaction(payload, privateKey, publicKey) {
|
|
28
28
|
const payloadBytes = serializePayload(payload);
|
|
29
|
-
const signature = ml_dsa65.sign(hexToBytes(privateKey)
|
|
29
|
+
const signature = ml_dsa65.sign(payloadBytes, hexToBytes(privateKey));
|
|
30
30
|
return {
|
|
31
31
|
payload,
|
|
32
32
|
signature: bytesToHex(signature),
|
|
@@ -37,9 +37,9 @@ function verifyTransaction(signedTx) {
|
|
|
37
37
|
try {
|
|
38
38
|
const payloadBytes = serializePayload(signedTx.payload);
|
|
39
39
|
return ml_dsa65.verify(
|
|
40
|
-
hexToBytes(signedTx.
|
|
40
|
+
hexToBytes(signedTx.signature),
|
|
41
41
|
payloadBytes,
|
|
42
|
-
hexToBytes(signedTx.
|
|
42
|
+
hexToBytes(signedTx.public_key)
|
|
43
43
|
);
|
|
44
44
|
} catch {
|
|
45
45
|
return false;
|
|
@@ -60,13 +60,31 @@ function buildAndSign(wallet, payload) {
|
|
|
60
60
|
function createSignedTransfer(wallet, to, amount, fee = 1, token = "XRGE") {
|
|
61
61
|
return buildAndSign(wallet, { type: "transfer", to, amount, fee, token });
|
|
62
62
|
}
|
|
63
|
-
function createSignedTokenCreation(wallet, tokenName, tokenSymbol, initialSupply, fee = 10) {
|
|
63
|
+
function createSignedTokenCreation(wallet, tokenName, tokenSymbol, initialSupply, fee = 10, image) {
|
|
64
64
|
return buildAndSign(wallet, {
|
|
65
65
|
type: "create_token",
|
|
66
66
|
token_name: tokenName,
|
|
67
67
|
token_symbol: tokenSymbol,
|
|
68
68
|
initial_supply: initialSupply,
|
|
69
|
-
fee
|
|
69
|
+
fee,
|
|
70
|
+
...image ? { image } : {}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function createSignedTokenMetadataUpdate(wallet, tokenSymbol, metadata) {
|
|
74
|
+
return buildAndSign(wallet, {
|
|
75
|
+
type: "update_token_metadata",
|
|
76
|
+
token_symbol: tokenSymbol,
|
|
77
|
+
...metadata.image !== void 0 ? { image: metadata.image } : {},
|
|
78
|
+
...metadata.description !== void 0 ? { description: metadata.description } : {},
|
|
79
|
+
...metadata.website !== void 0 ? { website: metadata.website } : {},
|
|
80
|
+
...metadata.twitter !== void 0 ? { twitter: metadata.twitter } : {},
|
|
81
|
+
...metadata.discord !== void 0 ? { discord: metadata.discord } : {}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function createSignedTokenMetadataClaim(wallet, tokenSymbol) {
|
|
85
|
+
return buildAndSign(wallet, {
|
|
86
|
+
type: "claim_token_metadata",
|
|
87
|
+
token_symbol: tokenSymbol
|
|
70
88
|
});
|
|
71
89
|
}
|
|
72
90
|
function createSignedSwap(wallet, tokenIn, tokenOut, amountIn, minAmountOut) {
|
|
@@ -120,6 +138,16 @@ function createSignedBurn(wallet, amount, fee = 1, token = "XRGE") {
|
|
|
120
138
|
token
|
|
121
139
|
});
|
|
122
140
|
}
|
|
141
|
+
function createSignedBridgeWithdraw(wallet, amount, evmAddress, tokenSymbol = "qETH", fee = 0.1) {
|
|
142
|
+
const evm = evmAddress.startsWith("0x") ? evmAddress : `0x${evmAddress}`;
|
|
143
|
+
return buildAndSign(wallet, {
|
|
144
|
+
type: "bridge_withdraw",
|
|
145
|
+
amount,
|
|
146
|
+
fee,
|
|
147
|
+
tokenSymbol,
|
|
148
|
+
evmAddress: evm
|
|
149
|
+
});
|
|
150
|
+
}
|
|
123
151
|
function createSignedNftCreateCollection(wallet, symbol, name, opts = {}) {
|
|
124
152
|
return buildAndSign(wallet, {
|
|
125
153
|
type: "nft_create_collection",
|
|
@@ -200,6 +228,8 @@ var RougeChain = class {
|
|
|
200
228
|
this.nft = new NftClient(this);
|
|
201
229
|
this.dex = new DexClient(this);
|
|
202
230
|
this.bridge = new BridgeClient(this);
|
|
231
|
+
this.mail = new MailClient(this);
|
|
232
|
+
this.messenger = new MessengerClient(this);
|
|
203
233
|
}
|
|
204
234
|
// ===== Internal helpers =====
|
|
205
235
|
/** @internal */
|
|
@@ -334,7 +364,8 @@ var RougeChain = class {
|
|
|
334
364
|
params.name,
|
|
335
365
|
params.symbol,
|
|
336
366
|
params.totalSupply,
|
|
337
|
-
params.fee
|
|
367
|
+
params.fee,
|
|
368
|
+
params.image
|
|
338
369
|
);
|
|
339
370
|
return this.submitTx("/v2/token/create", tx);
|
|
340
371
|
}
|
|
@@ -355,24 +386,18 @@ var RougeChain = class {
|
|
|
355
386
|
return this.submitTx("/v2/transfer", tx);
|
|
356
387
|
}
|
|
357
388
|
async updateTokenMetadata(wallet, params) {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
} catch (e) {
|
|
371
|
-
return {
|
|
372
|
-
success: false,
|
|
373
|
-
error: e instanceof Error ? e.message : String(e)
|
|
374
|
-
};
|
|
375
|
-
}
|
|
389
|
+
const tx = createSignedTokenMetadataUpdate(wallet, params.symbol, {
|
|
390
|
+
image: params.image,
|
|
391
|
+
description: params.description,
|
|
392
|
+
website: params.website,
|
|
393
|
+
twitter: params.twitter,
|
|
394
|
+
discord: params.discord
|
|
395
|
+
});
|
|
396
|
+
return this.submitTx("/v2/token/metadata/update", tx);
|
|
397
|
+
}
|
|
398
|
+
async claimTokenMetadata(wallet, tokenSymbol) {
|
|
399
|
+
const tx = createSignedTokenMetadataClaim(wallet, tokenSymbol);
|
|
400
|
+
return this.submitTx("/v2/token/metadata/claim", tx);
|
|
376
401
|
}
|
|
377
402
|
};
|
|
378
403
|
var NftClient = class {
|
|
@@ -545,7 +570,8 @@ var BridgeClient = class {
|
|
|
545
570
|
return {
|
|
546
571
|
enabled: data.enabled === true,
|
|
547
572
|
custodyAddress: data.custodyAddress,
|
|
548
|
-
chainId: data.chainId ?? 84532
|
|
573
|
+
chainId: data.chainId ?? 84532,
|
|
574
|
+
supportedTokens: data.supportedTokens
|
|
549
575
|
};
|
|
550
576
|
} catch {
|
|
551
577
|
return { enabled: false, chainId: 84532 };
|
|
@@ -557,17 +583,25 @@ var BridgeClient = class {
|
|
|
557
583
|
);
|
|
558
584
|
return data.withdrawals;
|
|
559
585
|
}
|
|
586
|
+
/** Withdraw qETH/qUSDC — signed client-side, private key never sent to server */
|
|
560
587
|
async withdraw(wallet, params) {
|
|
561
588
|
try {
|
|
562
|
-
const
|
|
589
|
+
const tokenSymbol = params.tokenSymbol ?? "qETH";
|
|
590
|
+
const signed = createSignedBridgeWithdraw(
|
|
591
|
+
wallet,
|
|
592
|
+
params.amount,
|
|
593
|
+
params.evmAddress,
|
|
594
|
+
tokenSymbol,
|
|
595
|
+
params.fee
|
|
596
|
+
);
|
|
563
597
|
const data = await this.rc.post(
|
|
564
598
|
"/bridge/withdraw",
|
|
565
599
|
{
|
|
566
|
-
fromPrivateKey: wallet.privateKey,
|
|
567
600
|
fromPublicKey: wallet.publicKey,
|
|
568
601
|
amountUnits: params.amount,
|
|
569
|
-
evmAddress:
|
|
570
|
-
|
|
602
|
+
evmAddress: signed.payload.evmAddress,
|
|
603
|
+
signature: signed.signature,
|
|
604
|
+
payload: signed.payload
|
|
571
605
|
}
|
|
572
606
|
);
|
|
573
607
|
return {
|
|
@@ -582,6 +616,7 @@ var BridgeClient = class {
|
|
|
582
616
|
};
|
|
583
617
|
}
|
|
584
618
|
}
|
|
619
|
+
/** Claim qETH or qUSDC after depositing on Base Sepolia */
|
|
585
620
|
async claim(params) {
|
|
586
621
|
try {
|
|
587
622
|
const data = await this.rc.post(
|
|
@@ -590,7 +625,8 @@ var BridgeClient = class {
|
|
|
590
625
|
evmTxHash: params.evmTxHash.startsWith("0x") ? params.evmTxHash : `0x${params.evmTxHash}`,
|
|
591
626
|
evmAddress: params.evmAddress.startsWith("0x") ? params.evmAddress : `0x${params.evmAddress}`,
|
|
592
627
|
evmSignature: params.evmSignature,
|
|
593
|
-
recipientRougechainPubkey: params.recipientPubkey
|
|
628
|
+
recipientRougechainPubkey: params.recipientPubkey,
|
|
629
|
+
token: params.token ?? "ETH"
|
|
594
630
|
}
|
|
595
631
|
);
|
|
596
632
|
return {
|
|
@@ -605,6 +641,213 @@ var BridgeClient = class {
|
|
|
605
641
|
};
|
|
606
642
|
}
|
|
607
643
|
}
|
|
644
|
+
// ── XRGE Bridge ──
|
|
645
|
+
async getXrgeConfig() {
|
|
646
|
+
try {
|
|
647
|
+
const data = await this.rc.get("/bridge/xrge/config");
|
|
648
|
+
return {
|
|
649
|
+
enabled: data.enabled === true,
|
|
650
|
+
vaultAddress: data.vaultAddress,
|
|
651
|
+
tokenAddress: data.tokenAddress,
|
|
652
|
+
chainId: data.chainId ?? 84532
|
|
653
|
+
};
|
|
654
|
+
} catch {
|
|
655
|
+
return { enabled: false, chainId: 84532 };
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
async claimXrge(params) {
|
|
659
|
+
try {
|
|
660
|
+
const data = await this.rc.post(
|
|
661
|
+
"/bridge/xrge/claim",
|
|
662
|
+
{
|
|
663
|
+
evmTxHash: params.evmTxHash.startsWith("0x") ? params.evmTxHash : `0x${params.evmTxHash}`,
|
|
664
|
+
evmAddress: params.evmAddress.startsWith("0x") ? params.evmAddress : `0x${params.evmAddress}`,
|
|
665
|
+
amount: params.amount,
|
|
666
|
+
recipientRougechainPubkey: params.recipientPubkey
|
|
667
|
+
}
|
|
668
|
+
);
|
|
669
|
+
return {
|
|
670
|
+
success: data.success === true,
|
|
671
|
+
error: data.error,
|
|
672
|
+
data
|
|
673
|
+
};
|
|
674
|
+
} catch (e) {
|
|
675
|
+
return { success: false, error: e instanceof Error ? e.message : String(e) };
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
async withdrawXrge(wallet, params) {
|
|
679
|
+
try {
|
|
680
|
+
const signed = createSignedBridgeWithdraw(
|
|
681
|
+
wallet,
|
|
682
|
+
params.amount,
|
|
683
|
+
params.evmAddress,
|
|
684
|
+
"XRGE",
|
|
685
|
+
0.1
|
|
686
|
+
);
|
|
687
|
+
const data = await this.rc.post(
|
|
688
|
+
"/bridge/xrge/withdraw",
|
|
689
|
+
{
|
|
690
|
+
fromPublicKey: wallet.publicKey,
|
|
691
|
+
amount: params.amount,
|
|
692
|
+
evmAddress: signed.payload.evmAddress,
|
|
693
|
+
signature: signed.signature,
|
|
694
|
+
payload: signed.payload
|
|
695
|
+
}
|
|
696
|
+
);
|
|
697
|
+
return {
|
|
698
|
+
success: data.success === true,
|
|
699
|
+
error: data.error,
|
|
700
|
+
data
|
|
701
|
+
};
|
|
702
|
+
} catch (e) {
|
|
703
|
+
return { success: false, error: e instanceof Error ? e.message : String(e) };
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
async getXrgeWithdrawals() {
|
|
707
|
+
try {
|
|
708
|
+
const data = await this.rc.get(
|
|
709
|
+
"/bridge/xrge/withdrawals"
|
|
710
|
+
);
|
|
711
|
+
return data.withdrawals;
|
|
712
|
+
} catch {
|
|
713
|
+
return [];
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
var MailClient = class {
|
|
718
|
+
constructor(rc) {
|
|
719
|
+
this.rc = rc;
|
|
720
|
+
}
|
|
721
|
+
async send(params) {
|
|
722
|
+
try {
|
|
723
|
+
const data = await this.rc.post("/mail/send", params);
|
|
724
|
+
return { success: data.success === true, error: data.error, data };
|
|
725
|
+
} catch (e) {
|
|
726
|
+
return { success: false, error: e instanceof Error ? e.message : String(e) };
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
async getInbox(walletId) {
|
|
730
|
+
const data = await this.rc.get(
|
|
731
|
+
`/mail/inbox?walletId=${encodeURIComponent(walletId)}`
|
|
732
|
+
);
|
|
733
|
+
return data.messages ?? [];
|
|
734
|
+
}
|
|
735
|
+
async getSent(walletId) {
|
|
736
|
+
const data = await this.rc.get(
|
|
737
|
+
`/mail/sent?walletId=${encodeURIComponent(walletId)}`
|
|
738
|
+
);
|
|
739
|
+
return data.messages ?? [];
|
|
740
|
+
}
|
|
741
|
+
async getTrash(walletId) {
|
|
742
|
+
const data = await this.rc.get(
|
|
743
|
+
`/mail/trash?walletId=${encodeURIComponent(walletId)}`
|
|
744
|
+
);
|
|
745
|
+
return data.messages ?? [];
|
|
746
|
+
}
|
|
747
|
+
async getMessage(id) {
|
|
748
|
+
return this.rc.get(`/mail/message/${encodeURIComponent(id)}`);
|
|
749
|
+
}
|
|
750
|
+
async move(messageId, folder) {
|
|
751
|
+
try {
|
|
752
|
+
const data = await this.rc.post("/mail/move", {
|
|
753
|
+
messageId,
|
|
754
|
+
folder
|
|
755
|
+
});
|
|
756
|
+
return { success: data.success === true, error: data.error };
|
|
757
|
+
} catch (e) {
|
|
758
|
+
return { success: false, error: e instanceof Error ? e.message : String(e) };
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
async markRead(messageId) {
|
|
762
|
+
try {
|
|
763
|
+
const data = await this.rc.post("/mail/read", {
|
|
764
|
+
messageId
|
|
765
|
+
});
|
|
766
|
+
return { success: data.success === true, error: data.error };
|
|
767
|
+
} catch (e) {
|
|
768
|
+
return { success: false, error: e instanceof Error ? e.message : String(e) };
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
async delete(id) {
|
|
772
|
+
try {
|
|
773
|
+
const res = await this.rc.fetchFn(
|
|
774
|
+
`${this.rc.baseUrl}/mail/${encodeURIComponent(id)}`,
|
|
775
|
+
{ method: "DELETE", headers: this.rc.headers }
|
|
776
|
+
);
|
|
777
|
+
const data = await res.json();
|
|
778
|
+
return { success: data.success === true, error: data.error };
|
|
779
|
+
} catch (e) {
|
|
780
|
+
return { success: false, error: e instanceof Error ? e.message : String(e) };
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
var MessengerClient = class {
|
|
785
|
+
constructor(rc) {
|
|
786
|
+
this.rc = rc;
|
|
787
|
+
}
|
|
788
|
+
async getWallets() {
|
|
789
|
+
const data = await this.rc.get("/messenger/wallets");
|
|
790
|
+
return data.wallets ?? [];
|
|
791
|
+
}
|
|
792
|
+
async registerWallet(walletId, displayName, encryptionPublicKey) {
|
|
793
|
+
try {
|
|
794
|
+
const data = await this.rc.post("/messenger/wallets/register", {
|
|
795
|
+
wallet_id: walletId,
|
|
796
|
+
display_name: displayName,
|
|
797
|
+
encryption_public_key: encryptionPublicKey
|
|
798
|
+
});
|
|
799
|
+
return { success: data.success === true, error: data.error };
|
|
800
|
+
} catch (e) {
|
|
801
|
+
return { success: false, error: e instanceof Error ? e.message : String(e) };
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
async getConversations(walletId) {
|
|
805
|
+
const data = await this.rc.get(
|
|
806
|
+
`/messenger/conversations?walletId=${encodeURIComponent(walletId)}`
|
|
807
|
+
);
|
|
808
|
+
return data.conversations ?? [];
|
|
809
|
+
}
|
|
810
|
+
async createConversation(participants) {
|
|
811
|
+
try {
|
|
812
|
+
const data = await this.rc.post("/messenger/conversations", {
|
|
813
|
+
participants
|
|
814
|
+
});
|
|
815
|
+
return { success: data.success === true, error: data.error, data };
|
|
816
|
+
} catch (e) {
|
|
817
|
+
return { success: false, error: e instanceof Error ? e.message : String(e) };
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
async getMessages(conversationId) {
|
|
821
|
+
const data = await this.rc.get(
|
|
822
|
+
`/messenger/messages?conversationId=${encodeURIComponent(conversationId)}`
|
|
823
|
+
);
|
|
824
|
+
return data.messages ?? [];
|
|
825
|
+
}
|
|
826
|
+
async sendMessage(conversationId, sender, encryptedContent, opts = {}) {
|
|
827
|
+
try {
|
|
828
|
+
const data = await this.rc.post("/messenger/messages", {
|
|
829
|
+
conversation_id: conversationId,
|
|
830
|
+
sender,
|
|
831
|
+
encrypted_content: encryptedContent,
|
|
832
|
+
media_type: opts.mediaType,
|
|
833
|
+
media_data: opts.mediaData,
|
|
834
|
+
self_destruct: opts.selfDestruct
|
|
835
|
+
});
|
|
836
|
+
return { success: data.success === true, error: data.error, data };
|
|
837
|
+
} catch (e) {
|
|
838
|
+
return { success: false, error: e instanceof Error ? e.message : String(e) };
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
async markRead(messageId) {
|
|
842
|
+
try {
|
|
843
|
+
const data = await this.rc.post("/messenger/messages/read", {
|
|
844
|
+
message_id: messageId
|
|
845
|
+
});
|
|
846
|
+
return { success: data.success === true, error: data.error };
|
|
847
|
+
} catch (e) {
|
|
848
|
+
return { success: false, error: e instanceof Error ? e.message : String(e) };
|
|
849
|
+
}
|
|
850
|
+
}
|
|
608
851
|
};
|
|
609
852
|
var Wallet = class _Wallet {
|
|
610
853
|
constructor(publicKey, privateKey) {
|
|
@@ -640,14 +883,14 @@ var Wallet = class _Wallet {
|
|
|
640
883
|
verify() {
|
|
641
884
|
try {
|
|
642
885
|
const msg = new TextEncoder().encode("rougechain-verify");
|
|
643
|
-
const sig = ml_dsa65.sign(hexToBytes(this.privateKey)
|
|
644
|
-
return ml_dsa65.verify(hexToBytes(this.publicKey)
|
|
886
|
+
const sig = ml_dsa65.sign(msg, hexToBytes(this.privateKey));
|
|
887
|
+
return ml_dsa65.verify(sig, msg, hexToBytes(this.publicKey));
|
|
645
888
|
} catch {
|
|
646
889
|
return false;
|
|
647
890
|
}
|
|
648
891
|
}
|
|
649
892
|
};
|
|
650
893
|
|
|
651
|
-
export { BURN_ADDRESS, RougeChain, Wallet, bytesToHex, generateNonce, hexToBytes, isBurnAddress, serializePayload, signTransaction, verifyTransaction };
|
|
894
|
+
export { BURN_ADDRESS, RougeChain, Wallet, bytesToHex, createSignedBridgeWithdraw, createSignedTokenMetadataClaim, createSignedTokenMetadataUpdate, generateNonce, hexToBytes, isBurnAddress, serializePayload, signTransaction, verifyTransaction };
|
|
652
895
|
//# sourceMappingURL=index.js.map
|
|
653
896
|
//# sourceMappingURL=index.js.map
|