@rougechain/sdk 0.1.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 +334 -0
- package/dist/index.cjs +664 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +441 -0
- package/dist/index.d.ts +441 -0
- package/dist/index.js +653 -0
- package/dist/index.js.map +1 -0
- package/package.json +44 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,441 @@
|
|
|
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";
|
|
11
|
+
interface TransactionPayload {
|
|
12
|
+
type: TransactionType;
|
|
13
|
+
from: string;
|
|
14
|
+
to?: string;
|
|
15
|
+
amount?: number;
|
|
16
|
+
fee?: number;
|
|
17
|
+
token?: string;
|
|
18
|
+
timestamp: number;
|
|
19
|
+
nonce: string;
|
|
20
|
+
token_name?: string;
|
|
21
|
+
token_symbol?: string;
|
|
22
|
+
initial_supply?: number;
|
|
23
|
+
token_in?: string;
|
|
24
|
+
token_out?: string;
|
|
25
|
+
amount_in?: number;
|
|
26
|
+
min_amount_out?: number;
|
|
27
|
+
pool_id?: string;
|
|
28
|
+
token_a?: string;
|
|
29
|
+
token_b?: string;
|
|
30
|
+
amount_a?: number;
|
|
31
|
+
amount_b?: number;
|
|
32
|
+
lp_amount?: number;
|
|
33
|
+
symbol?: string;
|
|
34
|
+
name?: string;
|
|
35
|
+
collectionId?: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
image?: string;
|
|
38
|
+
maxSupply?: number;
|
|
39
|
+
royaltyBps?: number;
|
|
40
|
+
tokenId?: number;
|
|
41
|
+
metadataUri?: string;
|
|
42
|
+
attributes?: unknown;
|
|
43
|
+
locked?: boolean;
|
|
44
|
+
frozen?: boolean;
|
|
45
|
+
salePrice?: number;
|
|
46
|
+
names?: string[];
|
|
47
|
+
uris?: string[];
|
|
48
|
+
batchAttributes?: unknown[];
|
|
49
|
+
}
|
|
50
|
+
interface SignedTransaction {
|
|
51
|
+
payload: TransactionPayload;
|
|
52
|
+
signature: string;
|
|
53
|
+
public_key: string;
|
|
54
|
+
}
|
|
55
|
+
interface BlockHeader {
|
|
56
|
+
version: number;
|
|
57
|
+
chain_id: string;
|
|
58
|
+
height: number;
|
|
59
|
+
time: number;
|
|
60
|
+
prev_hash: string;
|
|
61
|
+
tx_hash: string;
|
|
62
|
+
proposer_pub_key: string;
|
|
63
|
+
}
|
|
64
|
+
interface Transaction {
|
|
65
|
+
version: number;
|
|
66
|
+
tx_type: string;
|
|
67
|
+
from_pub_key: string;
|
|
68
|
+
target_pub_key?: string | null;
|
|
69
|
+
amount: number;
|
|
70
|
+
fee: number;
|
|
71
|
+
sig: string;
|
|
72
|
+
token_name?: string | null;
|
|
73
|
+
token_symbol?: string | null;
|
|
74
|
+
token_decimals?: number | null;
|
|
75
|
+
token_total_supply?: number | null;
|
|
76
|
+
pool_id?: string | null;
|
|
77
|
+
token_a_symbol?: string | null;
|
|
78
|
+
token_b_symbol?: string | null;
|
|
79
|
+
amount_a?: number | null;
|
|
80
|
+
amount_b?: number | null;
|
|
81
|
+
min_amount_out?: number | null;
|
|
82
|
+
swap_path?: string[] | null;
|
|
83
|
+
lp_amount?: number | null;
|
|
84
|
+
faucet?: boolean;
|
|
85
|
+
signed_payload?: string | null;
|
|
86
|
+
}
|
|
87
|
+
interface Block {
|
|
88
|
+
version: number;
|
|
89
|
+
header: BlockHeader;
|
|
90
|
+
txs: Transaction[];
|
|
91
|
+
proposer_sig: string;
|
|
92
|
+
hash: string;
|
|
93
|
+
}
|
|
94
|
+
interface NodeStats {
|
|
95
|
+
height: number;
|
|
96
|
+
peers: number;
|
|
97
|
+
network_height: number;
|
|
98
|
+
mining: boolean;
|
|
99
|
+
total_fees: number;
|
|
100
|
+
last_block_fees: number;
|
|
101
|
+
finalized_height: number;
|
|
102
|
+
ws_clients: number;
|
|
103
|
+
}
|
|
104
|
+
interface TokenMetadata {
|
|
105
|
+
symbol: string;
|
|
106
|
+
name: string;
|
|
107
|
+
creator: string;
|
|
108
|
+
image?: string;
|
|
109
|
+
description?: string;
|
|
110
|
+
website?: string;
|
|
111
|
+
twitter?: string;
|
|
112
|
+
discord?: string;
|
|
113
|
+
created_at: number;
|
|
114
|
+
updated_at: number;
|
|
115
|
+
}
|
|
116
|
+
interface TokenHolder {
|
|
117
|
+
address: string;
|
|
118
|
+
balance: number;
|
|
119
|
+
}
|
|
120
|
+
interface BalanceResponse {
|
|
121
|
+
balance: number;
|
|
122
|
+
token_balances: Record<string, number>;
|
|
123
|
+
lp_balances: Record<string, number>;
|
|
124
|
+
}
|
|
125
|
+
interface LiquidityPool {
|
|
126
|
+
pool_id: string;
|
|
127
|
+
token_a_symbol: string;
|
|
128
|
+
token_b_symbol: string;
|
|
129
|
+
reserve_a: number;
|
|
130
|
+
reserve_b: number;
|
|
131
|
+
total_lp: number;
|
|
132
|
+
fee_rate: number;
|
|
133
|
+
created_at: number;
|
|
134
|
+
}
|
|
135
|
+
interface SwapQuote {
|
|
136
|
+
amount_out: number;
|
|
137
|
+
price_impact: number;
|
|
138
|
+
path: string[];
|
|
139
|
+
}
|
|
140
|
+
interface PoolEvent {
|
|
141
|
+
event_type: string;
|
|
142
|
+
pool_id: string;
|
|
143
|
+
actor: string;
|
|
144
|
+
token_a_amount?: number;
|
|
145
|
+
token_b_amount?: number;
|
|
146
|
+
lp_amount?: number;
|
|
147
|
+
timestamp: number;
|
|
148
|
+
}
|
|
149
|
+
interface PoolStats {
|
|
150
|
+
pool_id: string;
|
|
151
|
+
volume_24h: number;
|
|
152
|
+
trades_24h: number;
|
|
153
|
+
tvl: number;
|
|
154
|
+
}
|
|
155
|
+
interface NftCollection {
|
|
156
|
+
collection_id: string;
|
|
157
|
+
symbol: string;
|
|
158
|
+
name: string;
|
|
159
|
+
creator: string;
|
|
160
|
+
description?: string;
|
|
161
|
+
image?: string;
|
|
162
|
+
max_supply?: number;
|
|
163
|
+
minted: number;
|
|
164
|
+
royalty_bps: number;
|
|
165
|
+
royalty_recipient: string;
|
|
166
|
+
frozen: boolean;
|
|
167
|
+
created_at: number;
|
|
168
|
+
}
|
|
169
|
+
interface NftToken {
|
|
170
|
+
collection_id: string;
|
|
171
|
+
token_id: number;
|
|
172
|
+
owner: string;
|
|
173
|
+
creator: string;
|
|
174
|
+
name: string;
|
|
175
|
+
metadata_uri?: string;
|
|
176
|
+
attributes?: unknown;
|
|
177
|
+
locked: boolean;
|
|
178
|
+
minted_at: number;
|
|
179
|
+
transferred_at: number;
|
|
180
|
+
}
|
|
181
|
+
interface Validator {
|
|
182
|
+
public_key: string;
|
|
183
|
+
stake: number;
|
|
184
|
+
status: string;
|
|
185
|
+
jailed_until: number;
|
|
186
|
+
uptime: number;
|
|
187
|
+
}
|
|
188
|
+
interface BridgeConfig {
|
|
189
|
+
enabled: boolean;
|
|
190
|
+
custodyAddress?: string;
|
|
191
|
+
chainId: number;
|
|
192
|
+
}
|
|
193
|
+
interface BridgeWithdrawal {
|
|
194
|
+
tx_id: string;
|
|
195
|
+
from_pub_key: string;
|
|
196
|
+
evm_address: string;
|
|
197
|
+
amount_units: number;
|
|
198
|
+
status: string;
|
|
199
|
+
created_at: number;
|
|
200
|
+
}
|
|
201
|
+
interface TransferParams {
|
|
202
|
+
to: string;
|
|
203
|
+
amount: number;
|
|
204
|
+
fee?: number;
|
|
205
|
+
token?: string;
|
|
206
|
+
}
|
|
207
|
+
interface CreateTokenParams {
|
|
208
|
+
name: string;
|
|
209
|
+
symbol: string;
|
|
210
|
+
totalSupply: number;
|
|
211
|
+
fee?: number;
|
|
212
|
+
}
|
|
213
|
+
interface SwapParams {
|
|
214
|
+
tokenIn: string;
|
|
215
|
+
tokenOut: string;
|
|
216
|
+
amountIn: number;
|
|
217
|
+
minAmountOut: number;
|
|
218
|
+
}
|
|
219
|
+
interface CreatePoolParams {
|
|
220
|
+
tokenA: string;
|
|
221
|
+
tokenB: string;
|
|
222
|
+
amountA: number;
|
|
223
|
+
amountB: number;
|
|
224
|
+
}
|
|
225
|
+
interface AddLiquidityParams {
|
|
226
|
+
poolId: string;
|
|
227
|
+
amountA: number;
|
|
228
|
+
amountB: number;
|
|
229
|
+
}
|
|
230
|
+
interface RemoveLiquidityParams {
|
|
231
|
+
poolId: string;
|
|
232
|
+
lpAmount: number;
|
|
233
|
+
}
|
|
234
|
+
interface StakeParams {
|
|
235
|
+
amount: number;
|
|
236
|
+
fee?: number;
|
|
237
|
+
}
|
|
238
|
+
interface CreateNftCollectionParams {
|
|
239
|
+
symbol: string;
|
|
240
|
+
name: string;
|
|
241
|
+
maxSupply?: number;
|
|
242
|
+
royaltyBps?: number;
|
|
243
|
+
image?: string;
|
|
244
|
+
description?: string;
|
|
245
|
+
}
|
|
246
|
+
interface MintNftParams {
|
|
247
|
+
collectionId: string;
|
|
248
|
+
name: string;
|
|
249
|
+
metadataUri?: string;
|
|
250
|
+
attributes?: unknown;
|
|
251
|
+
}
|
|
252
|
+
interface BatchMintNftParams {
|
|
253
|
+
collectionId: string;
|
|
254
|
+
names: string[];
|
|
255
|
+
uris?: string[];
|
|
256
|
+
batchAttributes?: unknown[];
|
|
257
|
+
}
|
|
258
|
+
interface TransferNftParams {
|
|
259
|
+
collectionId: string;
|
|
260
|
+
tokenId: number;
|
|
261
|
+
to: string;
|
|
262
|
+
salePrice?: number;
|
|
263
|
+
}
|
|
264
|
+
interface BurnNftParams {
|
|
265
|
+
collectionId: string;
|
|
266
|
+
tokenId: number;
|
|
267
|
+
}
|
|
268
|
+
interface LockNftParams {
|
|
269
|
+
collectionId: string;
|
|
270
|
+
tokenId: number;
|
|
271
|
+
locked: boolean;
|
|
272
|
+
}
|
|
273
|
+
interface FreezeCollectionParams {
|
|
274
|
+
collectionId: string;
|
|
275
|
+
frozen: boolean;
|
|
276
|
+
}
|
|
277
|
+
interface BridgeWithdrawParams {
|
|
278
|
+
amount: number;
|
|
279
|
+
evmAddress: string;
|
|
280
|
+
fee?: number;
|
|
281
|
+
}
|
|
282
|
+
interface SwapQuoteParams {
|
|
283
|
+
poolId: string;
|
|
284
|
+
tokenIn: string;
|
|
285
|
+
amountIn: number;
|
|
286
|
+
}
|
|
287
|
+
interface TokenMetadataUpdateParams {
|
|
288
|
+
symbol: string;
|
|
289
|
+
image?: string;
|
|
290
|
+
description?: string;
|
|
291
|
+
website?: string;
|
|
292
|
+
twitter?: string;
|
|
293
|
+
discord?: string;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
type FetchFn = typeof globalThis.fetch;
|
|
297
|
+
interface RougeChainOptions {
|
|
298
|
+
/** Custom fetch implementation (defaults to globalThis.fetch) */
|
|
299
|
+
fetch?: FetchFn;
|
|
300
|
+
/** Optional API key for authenticated endpoints */
|
|
301
|
+
apiKey?: string;
|
|
302
|
+
}
|
|
303
|
+
declare class RougeChain {
|
|
304
|
+
private readonly baseUrl;
|
|
305
|
+
private readonly fetchFn;
|
|
306
|
+
private readonly headers;
|
|
307
|
+
readonly nft: NftClient;
|
|
308
|
+
readonly dex: DexClient;
|
|
309
|
+
readonly bridge: BridgeClient;
|
|
310
|
+
constructor(baseUrl: string, options?: RougeChainOptions);
|
|
311
|
+
/** @internal */
|
|
312
|
+
get<T = unknown>(path: string): Promise<T>;
|
|
313
|
+
/** @internal */
|
|
314
|
+
post<T = unknown>(path: string, body: unknown): Promise<T>;
|
|
315
|
+
/** @internal */
|
|
316
|
+
submitTx(endpoint: string, signedTx: SignedTransaction): Promise<ApiResponse>;
|
|
317
|
+
getStats(): Promise<NodeStats>;
|
|
318
|
+
getHealth(): Promise<{
|
|
319
|
+
status: string;
|
|
320
|
+
chain_id: string;
|
|
321
|
+
height: number;
|
|
322
|
+
}>;
|
|
323
|
+
getBlocks(opts?: {
|
|
324
|
+
limit?: number;
|
|
325
|
+
}): Promise<Block[]>;
|
|
326
|
+
getBlocksSummary(range?: "1h" | "24h" | "7d"): Promise<unknown>;
|
|
327
|
+
getBalance(publicKey: string): Promise<BalanceResponse>;
|
|
328
|
+
getTokenBalance(publicKey: string, token: string): Promise<number>;
|
|
329
|
+
getTransactions(opts?: {
|
|
330
|
+
limit?: number;
|
|
331
|
+
offset?: number;
|
|
332
|
+
}): Promise<unknown>;
|
|
333
|
+
getTokens(): Promise<TokenMetadata[]>;
|
|
334
|
+
getTokenMetadata(symbol: string): Promise<TokenMetadata>;
|
|
335
|
+
getTokenHolders(symbol: string): Promise<TokenHolder[]>;
|
|
336
|
+
getTokenTransactions(symbol: string): Promise<unknown>;
|
|
337
|
+
getValidators(): Promise<Validator[]>;
|
|
338
|
+
getValidatorStats(): Promise<unknown>;
|
|
339
|
+
getFinality(): Promise<{
|
|
340
|
+
finalized_height: number;
|
|
341
|
+
tip_height: number;
|
|
342
|
+
total_stake: number;
|
|
343
|
+
finalized_stake: number;
|
|
344
|
+
}>;
|
|
345
|
+
getPeers(): Promise<string[]>;
|
|
346
|
+
getBurnedTokens(): Promise<{
|
|
347
|
+
burned: Record<string, number>;
|
|
348
|
+
total_xrge_burned: number;
|
|
349
|
+
}>;
|
|
350
|
+
transfer(wallet: WalletKeys, params: TransferParams): Promise<ApiResponse>;
|
|
351
|
+
createToken(wallet: WalletKeys, params: CreateTokenParams): Promise<ApiResponse>;
|
|
352
|
+
stake(wallet: WalletKeys, params: StakeParams): Promise<ApiResponse>;
|
|
353
|
+
unstake(wallet: WalletKeys, params: StakeParams): Promise<ApiResponse>;
|
|
354
|
+
faucet(wallet: WalletKeys): Promise<ApiResponse>;
|
|
355
|
+
burn(wallet: WalletKeys, amount: number, fee?: number, token?: string): Promise<ApiResponse>;
|
|
356
|
+
updateTokenMetadata(wallet: WalletKeys, params: TokenMetadataUpdateParams): Promise<ApiResponse>;
|
|
357
|
+
}
|
|
358
|
+
declare class NftClient {
|
|
359
|
+
private readonly rc;
|
|
360
|
+
constructor(rc: RougeChain);
|
|
361
|
+
getCollections(): Promise<NftCollection[]>;
|
|
362
|
+
getCollection(collectionId: string): Promise<NftCollection>;
|
|
363
|
+
getTokens(collectionId: string, opts?: {
|
|
364
|
+
limit?: number;
|
|
365
|
+
offset?: number;
|
|
366
|
+
}): Promise<{
|
|
367
|
+
tokens: NftToken[];
|
|
368
|
+
total: number;
|
|
369
|
+
}>;
|
|
370
|
+
getToken(collectionId: string, tokenId: number): Promise<NftToken>;
|
|
371
|
+
getByOwner(pubkey: string): Promise<NftToken[]>;
|
|
372
|
+
createCollection(wallet: WalletKeys, params: CreateNftCollectionParams): Promise<ApiResponse>;
|
|
373
|
+
mint(wallet: WalletKeys, params: MintNftParams): Promise<ApiResponse>;
|
|
374
|
+
batchMint(wallet: WalletKeys, params: BatchMintNftParams): Promise<ApiResponse>;
|
|
375
|
+
transfer(wallet: WalletKeys, params: TransferNftParams): Promise<ApiResponse>;
|
|
376
|
+
burn(wallet: WalletKeys, params: BurnNftParams): Promise<ApiResponse>;
|
|
377
|
+
lock(wallet: WalletKeys, params: LockNftParams): Promise<ApiResponse>;
|
|
378
|
+
freezeCollection(wallet: WalletKeys, params: FreezeCollectionParams): Promise<ApiResponse>;
|
|
379
|
+
}
|
|
380
|
+
declare class DexClient {
|
|
381
|
+
private readonly rc;
|
|
382
|
+
constructor(rc: RougeChain);
|
|
383
|
+
getPools(): Promise<LiquidityPool[]>;
|
|
384
|
+
getPool(poolId: string): Promise<LiquidityPool>;
|
|
385
|
+
getPoolEvents(poolId: string): Promise<PoolEvent[]>;
|
|
386
|
+
getPoolPrices(poolId: string): Promise<unknown>;
|
|
387
|
+
getPoolStats(poolId: string): Promise<PoolStats>;
|
|
388
|
+
quote(params: SwapQuoteParams): Promise<SwapQuote>;
|
|
389
|
+
swap(wallet: WalletKeys, params: SwapParams): Promise<ApiResponse>;
|
|
390
|
+
createPool(wallet: WalletKeys, params: CreatePoolParams): Promise<ApiResponse>;
|
|
391
|
+
addLiquidity(wallet: WalletKeys, params: AddLiquidityParams): Promise<ApiResponse>;
|
|
392
|
+
removeLiquidity(wallet: WalletKeys, params: RemoveLiquidityParams): Promise<ApiResponse>;
|
|
393
|
+
}
|
|
394
|
+
declare class BridgeClient {
|
|
395
|
+
private readonly rc;
|
|
396
|
+
constructor(rc: RougeChain);
|
|
397
|
+
getConfig(): Promise<BridgeConfig>;
|
|
398
|
+
getWithdrawals(): Promise<BridgeWithdrawal[]>;
|
|
399
|
+
withdraw(wallet: WalletKeys, params: BridgeWithdrawParams): Promise<ApiResponse>;
|
|
400
|
+
claim(params: {
|
|
401
|
+
evmTxHash: string;
|
|
402
|
+
evmAddress: string;
|
|
403
|
+
evmSignature: string;
|
|
404
|
+
recipientPubkey: string;
|
|
405
|
+
}): Promise<ApiResponse>;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
declare class Wallet implements WalletKeys {
|
|
409
|
+
readonly publicKey: string;
|
|
410
|
+
readonly privateKey: string;
|
|
411
|
+
private constructor();
|
|
412
|
+
/**
|
|
413
|
+
* Generate a new ML-DSA-65 keypair.
|
|
414
|
+
* Uses crypto.getRandomValues for secure randomness.
|
|
415
|
+
*/
|
|
416
|
+
static generate(): Wallet;
|
|
417
|
+
/**
|
|
418
|
+
* Restore a wallet from existing hex-encoded keys.
|
|
419
|
+
*/
|
|
420
|
+
static fromKeys(publicKey: string, privateKey: string): Wallet;
|
|
421
|
+
/**
|
|
422
|
+
* Export keys as a plain object (for serialization/storage).
|
|
423
|
+
*/
|
|
424
|
+
toJSON(): WalletKeys;
|
|
425
|
+
/**
|
|
426
|
+
* Verify that the keypair is valid by signing and verifying a test message.
|
|
427
|
+
*/
|
|
428
|
+
verify(): boolean;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
declare const BURN_ADDRESS = "XRGE_BURN_0x000000000000000000000000000000000000000000000000000000000000DEAD";
|
|
432
|
+
declare function serializePayload(payload: TransactionPayload): Uint8Array;
|
|
433
|
+
declare function signTransaction(payload: TransactionPayload, privateKey: string, publicKey: string): SignedTransaction;
|
|
434
|
+
declare function verifyTransaction(signedTx: SignedTransaction): boolean;
|
|
435
|
+
declare function isBurnAddress(address: string): boolean;
|
|
436
|
+
|
|
437
|
+
declare function hexToBytes(hex: string): Uint8Array;
|
|
438
|
+
declare function bytesToHex(bytes: Uint8Array): string;
|
|
439
|
+
declare function generateNonce(): string;
|
|
440
|
+
|
|
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 };
|