@microcosmmoney/auth-core 1.0.3 → 1.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/dist/api-client.js +7 -1
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +199 -9
- package/package.json +1 -1
package/dist/api-client.js
CHANGED
|
@@ -34,7 +34,13 @@ class ApiClient {
|
|
|
34
34
|
}
|
|
35
35
|
const data = await response.json();
|
|
36
36
|
if (!response.ok) {
|
|
37
|
-
|
|
37
|
+
const detail = data.detail;
|
|
38
|
+
const msg = typeof detail === 'string'
|
|
39
|
+
? detail
|
|
40
|
+
: typeof detail === 'object' && detail !== null
|
|
41
|
+
? (detail.msg || detail.message || JSON.stringify(detail))
|
|
42
|
+
: (data.error?.message || data.message || `API error ${response.status}`);
|
|
43
|
+
throw new Error(msg);
|
|
38
44
|
}
|
|
39
45
|
return data;
|
|
40
46
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export { Storage, STORAGE_KEYS } from './storage';
|
|
|
4
4
|
export { ApiClient } from './api-client';
|
|
5
5
|
export { MicrocosmAPI } from './open-api';
|
|
6
6
|
export type { MicrocosmAPIConfig } from './open-api';
|
|
7
|
-
export type { MicrocosmAuthConfig, ResolvedConfig, User, TokenData, AuthState, LoginOptions, TokenExchangeResponse, UserProfileResponse, ApiResponse, MCDBalance, MCCBalance, MCCPrice, Wallet, TokenPortfolio, MCCLock, MiningRatio, MiningDistribution, BuybackQuote, BuybackRecord, Territory, TerritorySummary, TerritoryStats, TerritoryMember, Proposal, ProposalDetail, VoteResult, VotePower, AuctionBid, MCDTransaction, MCDReward, MiningRequest, MiningConfirmData, MiningRequestResult, MiningConfig, BuybackRecordInput, ReincarnationConfig, MCCHistoryRecord, CycleHistory, AuctionHistory, } from './types';
|
|
7
|
+
export type { MicrocosmAuthConfig, ResolvedConfig, User, TokenData, AuthState, LoginOptions, TokenExchangeResponse, UserProfileResponse, ApiResponse, MCDBalance, MCCBalance, MCCWalletBalance, MCCPrice, Wallet, TokenPortfolio, MCCLock, MiningRatio, MiningDistribution, BuybackQuote, BuybackRecord, Territory, TerritorySummary, TerritoryStats, TerritoryMember, Proposal, ProposalDetail, VoteResult, VotePower, AuctionBid, MCDTransaction, MCDReward, MiningRequest, MiningConfirmData, MiningRequestResult, MiningConfig, BuybackRecordInput, ReincarnationConfig, MCCHistoryRecord, CycleHistory, AuctionHistory, PaginatedResult, MCCStats, MiningStats, TechTreeNode, TechTree, TechTreeBonus, UserStats, Organization, OrganizationTreeNode, MiningRecord, MiningHistoryItem, PriceHistoryPoint, Auction, AuctionDetail, AuctionCreateInput, TerritoryIncome, TerritoryKPI, UserLevel, DashboardMarketSummary, DashboardUserSummary, PublicMiningRequest, UnitType, } from './types';
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type UnitType = 'station' | 'matrix' | 'sector' | 'system';
|
|
1
2
|
export interface MicrocosmAuthConfig {
|
|
2
3
|
clientId: string;
|
|
3
4
|
redirectUri: string;
|
|
@@ -65,20 +66,30 @@ export interface MCDBalance {
|
|
|
65
66
|
available_balance: string;
|
|
66
67
|
frozen_balance: string;
|
|
67
68
|
}
|
|
69
|
+
export interface MCCWalletBalance {
|
|
70
|
+
wallet_address: string;
|
|
71
|
+
is_primary: boolean;
|
|
72
|
+
balance: number;
|
|
73
|
+
raw_balance: number;
|
|
74
|
+
}
|
|
68
75
|
export interface MCCBalance {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
wallet_address?: string;
|
|
76
|
+
balance: number;
|
|
77
|
+
raw_balance: number;
|
|
78
|
+
decimals: number;
|
|
79
|
+
symbol: string;
|
|
80
|
+
wallet_address?: string | null;
|
|
81
|
+
wallets?: MCCWalletBalance[];
|
|
82
|
+
mint?: string;
|
|
74
83
|
}
|
|
75
84
|
export interface MCCPrice {
|
|
76
85
|
price: number;
|
|
77
|
-
price_change_24h?: number;
|
|
78
|
-
volume_24h?: number;
|
|
79
|
-
market_cap?: number;
|
|
86
|
+
price_change_24h?: number | null;
|
|
87
|
+
volume_24h?: number | null;
|
|
88
|
+
market_cap?: number | null;
|
|
80
89
|
source: string;
|
|
81
90
|
updated_at: string;
|
|
91
|
+
buyback_price?: number;
|
|
92
|
+
premium_rate?: number;
|
|
82
93
|
}
|
|
83
94
|
export interface Wallet {
|
|
84
95
|
wallet_address: string;
|
|
@@ -124,6 +135,12 @@ export interface BuybackQuote {
|
|
|
124
135
|
buyback_price: number;
|
|
125
136
|
usdc_amount: number;
|
|
126
137
|
premium_amount: number;
|
|
138
|
+
fee?: number;
|
|
139
|
+
fee_rate?: number;
|
|
140
|
+
slippage?: number;
|
|
141
|
+
net_amount?: number;
|
|
142
|
+
vault_type?: string;
|
|
143
|
+
pool_remaining?: number;
|
|
127
144
|
}
|
|
128
145
|
export interface BuybackRecord {
|
|
129
146
|
mcc_amount: number;
|
|
@@ -137,7 +154,7 @@ export interface Territory {
|
|
|
137
154
|
unit_id: string;
|
|
138
155
|
unit_name: string;
|
|
139
156
|
short_id?: string;
|
|
140
|
-
unit_type:
|
|
157
|
+
unit_type: UnitType;
|
|
141
158
|
description?: string;
|
|
142
159
|
location?: string;
|
|
143
160
|
image_url?: string;
|
|
@@ -190,9 +207,17 @@ export interface VotePower {
|
|
|
190
207
|
vote_power: number;
|
|
191
208
|
user_rank?: string;
|
|
192
209
|
cost_per_vote_mcc?: number;
|
|
210
|
+
mcd_cost_per_vote?: number;
|
|
193
211
|
mcc_balance?: number;
|
|
194
212
|
max_votes?: number;
|
|
195
213
|
can_vote: boolean;
|
|
214
|
+
reason?: string;
|
|
215
|
+
source?: string;
|
|
216
|
+
details?: {
|
|
217
|
+
base_power?: number;
|
|
218
|
+
mcc_bonus?: number;
|
|
219
|
+
level_bonus?: number;
|
|
220
|
+
};
|
|
196
221
|
}
|
|
197
222
|
export interface AuctionBid {
|
|
198
223
|
bid_id?: string;
|
|
@@ -290,3 +315,168 @@ export interface AuctionHistory {
|
|
|
290
315
|
status: string;
|
|
291
316
|
ended_at: string;
|
|
292
317
|
}
|
|
318
|
+
export interface PaginatedResult<T> {
|
|
319
|
+
records: T[];
|
|
320
|
+
total: number;
|
|
321
|
+
page: number;
|
|
322
|
+
page_size: number;
|
|
323
|
+
}
|
|
324
|
+
export interface MCCStats {
|
|
325
|
+
total_supply: number;
|
|
326
|
+
circulating_supply: number;
|
|
327
|
+
holder_count: number;
|
|
328
|
+
total_mined: number;
|
|
329
|
+
price?: number;
|
|
330
|
+
market_cap?: number | null;
|
|
331
|
+
locked_amount?: number;
|
|
332
|
+
}
|
|
333
|
+
export interface MiningStats {
|
|
334
|
+
total_mined: number;
|
|
335
|
+
total_paid: number;
|
|
336
|
+
mining_count: number;
|
|
337
|
+
today_mined: number;
|
|
338
|
+
last_30d_mined: number;
|
|
339
|
+
active_days_30d: number;
|
|
340
|
+
last_mined_at: string | null;
|
|
341
|
+
}
|
|
342
|
+
export interface TechTreeNode {
|
|
343
|
+
node_id: string;
|
|
344
|
+
name: string;
|
|
345
|
+
level: number;
|
|
346
|
+
max_level: number;
|
|
347
|
+
unlocked: boolean;
|
|
348
|
+
prerequisites?: string[];
|
|
349
|
+
bonus?: Record<string, number>;
|
|
350
|
+
}
|
|
351
|
+
export interface TechTree {
|
|
352
|
+
nodes: TechTreeNode[];
|
|
353
|
+
total_unlocked: number;
|
|
354
|
+
total_nodes: number;
|
|
355
|
+
}
|
|
356
|
+
export interface TechTreeBonus {
|
|
357
|
+
bonus_multiplier: number;
|
|
358
|
+
active_bonuses?: Record<string, number>;
|
|
359
|
+
}
|
|
360
|
+
export interface UserStats {
|
|
361
|
+
total_users: number;
|
|
362
|
+
by_level: {
|
|
363
|
+
recruit: number;
|
|
364
|
+
prospect: number;
|
|
365
|
+
miner: number;
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
export interface Organization {
|
|
369
|
+
id: string;
|
|
370
|
+
name: string;
|
|
371
|
+
unit_type: UnitType;
|
|
372
|
+
parent_id?: string | null;
|
|
373
|
+
depth?: number;
|
|
374
|
+
children_count?: number;
|
|
375
|
+
member_count?: number;
|
|
376
|
+
children?: Organization[];
|
|
377
|
+
}
|
|
378
|
+
export interface OrganizationTreeNode {
|
|
379
|
+
id: string;
|
|
380
|
+
name: string;
|
|
381
|
+
unit_type: UnitType;
|
|
382
|
+
depth: number;
|
|
383
|
+
children: OrganizationTreeNode[];
|
|
384
|
+
member_count?: number;
|
|
385
|
+
vault_balance?: number;
|
|
386
|
+
}
|
|
387
|
+
export interface MiningRecord {
|
|
388
|
+
mcc_amount: number;
|
|
389
|
+
paid_amount: number;
|
|
390
|
+
stablecoin: string;
|
|
391
|
+
tx_signature: string;
|
|
392
|
+
mined_at: string | null;
|
|
393
|
+
status?: string;
|
|
394
|
+
}
|
|
395
|
+
export interface MiningHistoryItem {
|
|
396
|
+
mcc_amount: number;
|
|
397
|
+
usdc_amount: number;
|
|
398
|
+
stablecoin: string;
|
|
399
|
+
mining_price: number;
|
|
400
|
+
tx_signature: string;
|
|
401
|
+
wallet_address?: string;
|
|
402
|
+
status: string;
|
|
403
|
+
created_at: string;
|
|
404
|
+
}
|
|
405
|
+
export interface PriceHistoryPoint {
|
|
406
|
+
timestamp: string;
|
|
407
|
+
price: number;
|
|
408
|
+
volume?: number;
|
|
409
|
+
}
|
|
410
|
+
export interface Auction {
|
|
411
|
+
auction_id: number;
|
|
412
|
+
unit_name: string;
|
|
413
|
+
unit_type: UnitType;
|
|
414
|
+
starting_price: number;
|
|
415
|
+
current_bid?: number;
|
|
416
|
+
bid_count: number;
|
|
417
|
+
status: string;
|
|
418
|
+
start_time: string;
|
|
419
|
+
end_time: string;
|
|
420
|
+
}
|
|
421
|
+
export interface AuctionDetail extends Auction {
|
|
422
|
+
description?: string;
|
|
423
|
+
unit_id?: string;
|
|
424
|
+
winner_wallet?: string;
|
|
425
|
+
bids?: AuctionBid[];
|
|
426
|
+
deposit_amount?: number;
|
|
427
|
+
min_increment?: number;
|
|
428
|
+
}
|
|
429
|
+
export interface AuctionCreateInput {
|
|
430
|
+
unit_id: string;
|
|
431
|
+
unit_name: string;
|
|
432
|
+
unit_type: UnitType;
|
|
433
|
+
starting_price: number;
|
|
434
|
+
deposit_amount: number;
|
|
435
|
+
duration_hours: number;
|
|
436
|
+
description?: string;
|
|
437
|
+
}
|
|
438
|
+
export interface TerritoryIncome {
|
|
439
|
+
date: string;
|
|
440
|
+
amount: number;
|
|
441
|
+
source: string;
|
|
442
|
+
territory_id?: string;
|
|
443
|
+
}
|
|
444
|
+
export interface TerritoryKPI {
|
|
445
|
+
date: string;
|
|
446
|
+
kpi_score: number;
|
|
447
|
+
member_count: number;
|
|
448
|
+
vault_balance: number;
|
|
449
|
+
daily_distribution: number;
|
|
450
|
+
mining_activity: number;
|
|
451
|
+
}
|
|
452
|
+
export interface UserLevel {
|
|
453
|
+
level: string;
|
|
454
|
+
title?: string | null;
|
|
455
|
+
upgrade_progress?: {
|
|
456
|
+
current_days?: number;
|
|
457
|
+
required_days?: number;
|
|
458
|
+
percentage?: number;
|
|
459
|
+
};
|
|
460
|
+
mining_weight?: Record<string, number>;
|
|
461
|
+
}
|
|
462
|
+
export interface DashboardMarketSummary {
|
|
463
|
+
price_usd: number;
|
|
464
|
+
price_change_24h: number;
|
|
465
|
+
volume_24h: number;
|
|
466
|
+
liquidity_usd: number;
|
|
467
|
+
fdv: number;
|
|
468
|
+
market_cap: number;
|
|
469
|
+
}
|
|
470
|
+
export interface DashboardUserSummary {
|
|
471
|
+
level: string;
|
|
472
|
+
title?: string | null;
|
|
473
|
+
mcc_balance: number;
|
|
474
|
+
mcd_balance?: number;
|
|
475
|
+
territory_id?: string | null;
|
|
476
|
+
mining_count?: number;
|
|
477
|
+
}
|
|
478
|
+
export interface PublicMiningRequest {
|
|
479
|
+
wallet_address: string;
|
|
480
|
+
mcc_amount: number;
|
|
481
|
+
stablecoin?: string;
|
|
482
|
+
}
|