@microcosmmoney/auth-core 1.0.0 → 1.0.2

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 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, } from './types';
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, } from './types';
@@ -13,23 +13,51 @@ export declare class MicrocosmAPI {
13
13
  getPrice: () => Promise<ApiRes<any>>;
14
14
  getStats: () => Promise<ApiRes<any>>;
15
15
  getBalance: (token: string) => Promise<ApiRes<any>>;
16
+ getBalanceByAddress: (address: string) => Promise<ApiRes<any>>;
17
+ getLocks: (token: string) => Promise<ApiRes<any>>;
16
18
  getHolders: () => Promise<ApiRes<any>>;
17
19
  getMiningHistory: (days?: number) => Promise<ApiRes<any>>;
18
20
  };
19
21
  readonly mcd: {
20
22
  getBalance: (token: string) => Promise<ApiRes<any>>;
21
23
  getStats: () => Promise<ApiRes<any>>;
24
+ getTransactions: (token: string, params?: {
25
+ page?: number;
26
+ page_size?: number;
27
+ type?: string;
28
+ }) => Promise<ApiRes<any>>;
29
+ getRewards: (token: string, params?: {
30
+ page?: number;
31
+ page_size?: number;
32
+ start_date?: string;
33
+ end_date?: string;
34
+ }) => Promise<ApiRes<any>>;
35
+ };
36
+ readonly wallets: {
37
+ list: (token: string) => Promise<ApiRes<any>>;
38
+ getTokens: (address: string) => Promise<ApiRes<any>>;
22
39
  };
23
40
  readonly reincarnation: {
24
41
  getPool: () => Promise<ApiRes<any>>;
25
42
  getBuybackPrice: () => Promise<ApiRes<any>>;
43
+ getQuote: (mccAmount: number) => Promise<ApiRes<any>>;
44
+ getUserHistory: (token: string, params?: {
45
+ page?: number;
46
+ page_size?: number;
47
+ }) => Promise<ApiRes<any>>;
26
48
  };
27
49
  readonly mining: {
28
50
  getRecords: (token: string, params?: {
29
- limit?: number;
30
- offset?: number;
51
+ page?: number;
52
+ page_size?: number;
31
53
  }) => Promise<ApiRes<any>>;
32
54
  getStats: (token: string) => Promise<ApiRes<any>>;
55
+ getGlobalStats: () => Promise<ApiRes<any>>;
56
+ getRatio: () => Promise<ApiRes<any>>;
57
+ getDistribution: (token: string, params?: {
58
+ page?: number;
59
+ page_size?: number;
60
+ }) => Promise<ApiRes<any>>;
33
61
  };
34
62
  readonly users: {
35
63
  getProfile: (token: string) => Promise<ApiRes<any>>;
@@ -39,17 +67,63 @@ export declare class MicrocosmAPI {
39
67
  getMarket: () => Promise<ApiRes<any>>;
40
68
  getPlatform: () => Promise<ApiRes<any>>;
41
69
  getUserSummary: (wallet: string) => Promise<ApiRes<any>>;
70
+ getUserStats: () => Promise<ApiRes<any>>;
71
+ getTerritoryStats: () => Promise<ApiRes<any>>;
72
+ getMiningHistory: (days?: number) => Promise<ApiRes<any>>;
73
+ };
74
+ readonly territories: {
75
+ list: (token: string, params?: {
76
+ unit_type?: string;
77
+ parent_id?: string;
78
+ page?: number;
79
+ page_size?: number;
80
+ }) => Promise<ApiRes<any>>;
81
+ getSummary: (token: string) => Promise<ApiRes<any>>;
82
+ getDetail: (token: string, id: string) => Promise<ApiRes<any>>;
83
+ getStats: (token: string, id: string) => Promise<ApiRes<any>>;
84
+ getMembers: (token: string, id: string, params?: {
85
+ page?: number;
86
+ page_size?: number;
87
+ }) => Promise<ApiRes<any>>;
88
+ getIncomeChart: (token: string, id: string, period?: string) => Promise<ApiRes<any>>;
89
+ getKpiHistory: (token: string, id: string) => Promise<ApiRes<any>>;
90
+ getMemberRanking: (token: string, id: string, params?: {
91
+ page?: number;
92
+ page_size?: number;
93
+ }) => Promise<ApiRes<any>>;
42
94
  };
43
95
  readonly territory: {
44
96
  getCollection: () => Promise<ApiRes<any>>;
45
97
  getNft: (mint: string) => Promise<ApiRes<any>>;
46
98
  getUserNfts: (wallet: string) => Promise<ApiRes<any>>;
47
99
  };
100
+ readonly voting: {
101
+ getProposals: (token: string, params?: {
102
+ status?: string;
103
+ page?: number;
104
+ page_size?: number;
105
+ }) => Promise<ApiRes<any>>;
106
+ getDetail: (token: string, id: string) => Promise<ApiRes<any>>;
107
+ getPower: (token: string) => Promise<ApiRes<any>>;
108
+ createProposal: (token: string, data: {
109
+ title: string;
110
+ description: string;
111
+ proposal_type?: string;
112
+ voting_hours?: number;
113
+ options: string[];
114
+ }) => Promise<ApiRes<any>>;
115
+ castVote: (token: string, proposalId: string, data: {
116
+ option_index: number;
117
+ vote_count?: number;
118
+ }) => Promise<ApiRes<any>>;
119
+ };
48
120
  readonly auctions: {
49
121
  getConfig: () => Promise<ApiRes<any>>;
50
122
  getActive: () => Promise<ApiRes<any>>;
51
123
  getDetails: (id: number) => Promise<ApiRes<any>>;
52
124
  getBids: (id: number) => Promise<ApiRes<any>>;
125
+ getMyBids: (token: string) => Promise<ApiRes<any>>;
126
+ placeBid: (token: string, auctionId: number, bidAmount: number) => Promise<ApiRes<any>>;
53
127
  };
54
128
  readonly techTree: {
55
129
  getConfig: () => Promise<ApiRes<any>>;
package/dist/open-api.js CHANGED
@@ -41,23 +41,56 @@ class MicrocosmAPI {
41
41
  getPrice: () => request(this.base, '/mcc/price'),
42
42
  getStats: () => request(this.base, '/mcc/stats'),
43
43
  getBalance: (token) => request(this.base, '/mcc/balance', token),
44
+ getBalanceByAddress: (address) => request(this.base, `/mcc/balance/${address}`),
45
+ getLocks: (token) => request(this.base, '/mcc/locks', token),
44
46
  getHolders: () => request(this.base, '/reincarnation/holders'),
45
47
  getMiningHistory: (days = 30) => request(this.base, `/reincarnation/mining-history?days=${days}`),
46
48
  };
47
49
  this.mcd = {
48
50
  getBalance: (token) => request(this.base, '/mcd/balance', token),
49
51
  getStats: () => request(this.base, '/mcd/stats'),
52
+ getTransactions: (token, params) => {
53
+ const p = params || {};
54
+ let qs = `?page=${p.page || 1}&page_size=${p.page_size || 20}`;
55
+ if (p.type)
56
+ qs += `&type=${p.type}`;
57
+ return request(this.base, `/mcd/transactions${qs}`, token);
58
+ },
59
+ getRewards: (token, params) => {
60
+ const p = params || {};
61
+ let qs = `?page=${p.page || 1}&page_size=${p.page_size || 20}`;
62
+ if (p.start_date)
63
+ qs += `&start_date=${p.start_date}`;
64
+ if (p.end_date)
65
+ qs += `&end_date=${p.end_date}`;
66
+ return request(this.base, `/mcd/rewards${qs}`, token);
67
+ },
68
+ };
69
+ this.wallets = {
70
+ list: (token) => request(this.base, '/wallets', token),
71
+ getTokens: (address) => request(this.base, `/wallets/${address}/tokens`),
50
72
  };
51
73
  this.reincarnation = {
52
74
  getPool: () => request(this.base, '/reincarnation/pool'),
53
75
  getBuybackPrice: () => request(this.base, '/reincarnation/buyback-price'),
76
+ getQuote: (mccAmount) => postRequest(this.base, '/reincarnation/quote', { mcc_amount: mccAmount }),
77
+ getUserHistory: (token, params) => {
78
+ const p = params || {};
79
+ return request(this.base, `/reincarnation/user-history?page=${p.page || 1}&page_size=${p.page_size || 20}`, token);
80
+ },
54
81
  };
55
82
  this.mining = {
56
83
  getRecords: (token, params) => {
57
- const qs = params ? `?limit=${params.limit || 20}&offset=${params.offset || 0}` : '';
58
- return request(this.base, `/mining/records${qs}`, token);
84
+ const p = params || {};
85
+ return request(this.base, `/mining/records?page=${p.page || 1}&page_size=${p.page_size || 20}`, token);
59
86
  },
60
87
  getStats: (token) => request(this.base, '/mining/stats', token),
88
+ getGlobalStats: () => request(this.base, '/mining/global-stats'),
89
+ getRatio: () => request(this.base, '/mining/ratio'),
90
+ getDistribution: (token, params) => {
91
+ const p = params || {};
92
+ return request(this.base, `/mining/distribution?page=${p.page || 1}&page_size=${p.page_size || 20}`, token);
93
+ },
61
94
  };
62
95
  this.users = {
63
96
  getProfile: (token) => request(this.base, '/users/me', token),
@@ -67,17 +100,59 @@ class MicrocosmAPI {
67
100
  getMarket: () => request(this.base, '/dashboard/market'),
68
101
  getPlatform: () => request(this.base, '/dashboard/platform'),
69
102
  getUserSummary: (wallet) => request(this.base, `/dashboard/user/${wallet}`),
103
+ getUserStats: () => request(this.base, '/dashboard/stats/users'),
104
+ getTerritoryStats: () => request(this.base, '/dashboard/stats/territories'),
105
+ getMiningHistory: (days = 30) => request(this.base, `/dashboard/stats/mining-history?days=${days}`),
106
+ };
107
+ this.territories = {
108
+ list: (token, params) => {
109
+ const p = params || {};
110
+ let qs = `?page=${p.page || 1}&page_size=${p.page_size || 20}`;
111
+ if (p.unit_type)
112
+ qs += `&unit_type=${p.unit_type}`;
113
+ if (p.parent_id)
114
+ qs += `&parent_id=${p.parent_id}`;
115
+ return request(this.base, `/territories${qs}`, token);
116
+ },
117
+ getSummary: (token) => request(this.base, '/territories/summary', token),
118
+ getDetail: (token, id) => request(this.base, `/territories/${id}`, token),
119
+ getStats: (token, id) => request(this.base, `/territories/${id}/stats`, token),
120
+ getMembers: (token, id, params) => {
121
+ const p = params || {};
122
+ return request(this.base, `/territories/${id}/members?page=${p.page || 1}&page_size=${p.page_size || 20}`, token);
123
+ },
124
+ getIncomeChart: (token, id, period = '30d') => request(this.base, `/territories/${id}/income-chart?period=${period}`, token),
125
+ getKpiHistory: (token, id) => request(this.base, `/territories/${id}/kpi-history`, token),
126
+ getMemberRanking: (token, id, params) => {
127
+ const p = params || {};
128
+ return request(this.base, `/territories/${id}/member-ranking?page=${p.page || 1}&page_size=${p.page_size || 20}`, token);
129
+ },
70
130
  };
71
131
  this.territory = {
72
132
  getCollection: () => request(this.base, '/territory/collection'),
73
133
  getNft: (mint) => request(this.base, `/territory/nft/${mint}`),
74
134
  getUserNfts: (wallet) => request(this.base, `/territory/nfts/${wallet}`),
75
135
  };
136
+ this.voting = {
137
+ getProposals: (token, params) => {
138
+ const p = params || {};
139
+ let qs = `?page=${p.page || 1}&page_size=${p.page_size || 20}`;
140
+ if (p.status)
141
+ qs += `&status=${p.status}`;
142
+ return request(this.base, `/voting/proposals${qs}`, token);
143
+ },
144
+ getDetail: (token, id) => request(this.base, `/voting/proposals/${id}`, token),
145
+ getPower: (token) => request(this.base, '/voting/power', token),
146
+ createProposal: (token, data) => postRequest(this.base, '/voting/proposals', data, token),
147
+ castVote: (token, proposalId, data) => postRequest(this.base, `/voting/proposals/${proposalId}/vote`, data, token),
148
+ };
76
149
  this.auctions = {
77
150
  getConfig: () => request(this.base, '/auction-solana/config'),
78
151
  getActive: () => request(this.base, '/auction-solana/active'),
79
152
  getDetails: (id) => request(this.base, `/auction-solana/auction/${id}`),
80
153
  getBids: (id) => request(this.base, `/auction-solana/auction/${id}/bids`),
154
+ getMyBids: (token) => request(this.base, '/auction-solana/my-bids', token),
155
+ placeBid: (token, auctionId, bidAmount) => postRequest(this.base, `/auction-solana/auction/${auctionId}/bid`, { bid_amount: bidAmount }, token),
81
156
  };
82
157
  this.techTree = {
83
158
  getConfig: () => request(this.base, '/tech-tree/config'),
package/dist/types.d.ts CHANGED
@@ -80,3 +80,141 @@ export interface MCCPrice {
80
80
  source: string;
81
81
  updated_at: string;
82
82
  }
83
+ export interface Wallet {
84
+ wallet_address: string;
85
+ wallet_type: string;
86
+ is_primary: boolean;
87
+ created_at: string;
88
+ }
89
+ export interface TokenPortfolio {
90
+ sol_balance?: number;
91
+ mcc_balance?: number;
92
+ usdt_balance?: number;
93
+ usdc_balance?: number;
94
+ [key: string]: number | undefined;
95
+ }
96
+ export interface MCCLock {
97
+ lock_id: string;
98
+ amount: number;
99
+ reason: string;
100
+ lock_start: string;
101
+ lock_end: string;
102
+ status: string;
103
+ }
104
+ export interface MiningRatio {
105
+ current_stage?: number;
106
+ total_minted?: number;
107
+ ratio?: number;
108
+ usdc_per_mcc?: number;
109
+ current_rate?: number;
110
+ }
111
+ export interface MiningDistribution {
112
+ user_mcc: number;
113
+ team_mcc: number;
114
+ magistrate_mcc: number;
115
+ vault_mcd: number;
116
+ source: string;
117
+ territory_id?: string;
118
+ tx_signature?: string;
119
+ created_at: string;
120
+ }
121
+ export interface BuybackQuote {
122
+ mcc_amount: number;
123
+ market_price: number;
124
+ buyback_price: number;
125
+ usdc_amount: number;
126
+ premium_amount: number;
127
+ }
128
+ export interface BuybackRecord {
129
+ mcc_amount: number;
130
+ usdc_amount: number;
131
+ stablecoin: string;
132
+ tx_signature?: string;
133
+ buyback_price?: number;
134
+ created_at: string;
135
+ }
136
+ export interface Territory {
137
+ unit_id: string;
138
+ unit_name: string;
139
+ short_id?: string;
140
+ unit_type: string;
141
+ description?: string;
142
+ location?: string;
143
+ image_url?: string;
144
+ parent_id?: string;
145
+ member_count?: number;
146
+ max_capacity?: number;
147
+ vault_balance?: number;
148
+ manager_uid?: string;
149
+ }
150
+ export interface TerritorySummary {
151
+ total_stations: number;
152
+ total_members: number;
153
+ total_vault_mcd: number;
154
+ avg_kpi_score?: number;
155
+ }
156
+ export interface TerritoryStats {
157
+ member_count: number;
158
+ max_capacity: number;
159
+ vault_mcd: number;
160
+ occupancy_rate: number;
161
+ }
162
+ export interface TerritoryMember {
163
+ uid: string;
164
+ display_name?: string;
165
+ level?: string;
166
+ mcd_received?: number;
167
+ joined_at?: string;
168
+ }
169
+ export interface Proposal {
170
+ id: string;
171
+ title: string;
172
+ description: string;
173
+ proposal_type: string;
174
+ status: string;
175
+ options: string[];
176
+ min_votes?: number;
177
+ ends_at: string;
178
+ created_at: string;
179
+ }
180
+ export interface ProposalDetail extends Proposal {
181
+ vote_results: VoteResult[];
182
+ }
183
+ export interface VoteResult {
184
+ option: string;
185
+ votes: number;
186
+ mcc_total: number;
187
+ voter_count: number;
188
+ }
189
+ export interface VotePower {
190
+ vote_power: number;
191
+ user_rank?: string;
192
+ cost_per_vote_mcc?: number;
193
+ mcc_balance?: number;
194
+ max_votes?: number;
195
+ can_vote: boolean;
196
+ }
197
+ export interface AuctionBid {
198
+ bid_id?: string;
199
+ auction_id: number;
200
+ unit_name?: string;
201
+ bid_amount: number;
202
+ deposit_amount?: number;
203
+ status: string;
204
+ created_at: string;
205
+ }
206
+ export interface MCDTransaction {
207
+ id: string;
208
+ tx_type: string;
209
+ amount: number;
210
+ from_account_type?: string;
211
+ to_account_type?: string;
212
+ created_at: string;
213
+ }
214
+ export interface MCDReward {
215
+ id: string;
216
+ reward_date: string;
217
+ territory_id?: string;
218
+ mcd_received: number;
219
+ created_at: string;
220
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microcosmmoney/auth-core",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Microcosm OAuth 2.0 authentication core library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",