@microcosmmoney/portal-react 3.13.0 → 3.13.1
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/main-portal/components/mining/MiningModal.js +1 -1
- package/dist/main-portal/components/providers/SolanaWalletProvider.js +1 -1
- package/dist/main-portal/components/resources/public-mining-modal.js +1 -1
- package/dist/main-portal/hooks/useAuth.js +3 -2
- package/dist/main-portal/lib/api/index.d.ts +2 -9
- package/dist/main-portal/lib/api/index.js +17 -210
- package/package.json +1 -1
- package/dist/main-portal/hooks/useMarketData.d.ts +0 -9
- package/dist/main-portal/hooks/useMarketData.js +0 -32
- package/dist/main-portal/hooks/usePriceHistory.d.ts +0 -9
- package/dist/main-portal/hooks/usePriceHistory.js +0 -36
- package/dist/main-portal/lib/analytics/hooks.d.ts +0 -139
- package/dist/main-portal/lib/analytics/hooks.js +0 -277
- package/dist/main-portal/lib/analytics/index.d.ts +0 -2
- package/dist/main-portal/lib/analytics/index.js +0 -19
- package/dist/main-portal/lib/analytics/types.d.ts +0 -611
- package/dist/main-portal/lib/analytics/types.js +0 -2
- package/dist/main-portal/lib/api/account.d.ts +0 -39
- package/dist/main-portal/lib/api/account.js +0 -86
- package/dist/main-portal/lib/api/admin.d.ts +0 -78
- package/dist/main-portal/lib/api/admin.js +0 -195
- package/dist/main-portal/lib/api/analytics.d.ts +0 -217
- package/dist/main-portal/lib/api/analytics.js +0 -55
- package/dist/main-portal/lib/api/dexscreener.d.ts +0 -126
- package/dist/main-portal/lib/api/dexscreener.js +0 -139
- package/dist/main-portal/lib/api/geckoterminal.d.ts +0 -10
- package/dist/main-portal/lib/api/geckoterminal.js +0 -43
- package/dist/main-portal/lib/api/mcc-holders.d.ts +0 -130
- package/dist/main-portal/lib/api/mcc-holders.js +0 -47
- package/dist/main-portal/lib/api/org-service-proxy.d.ts +0 -7
- package/dist/main-portal/lib/api/org-service-proxy.js +0 -55
- package/dist/main-portal/lib/api/strategies.d.ts +0 -101
- package/dist/main-portal/lib/api/strategies.js +0 -87
- package/dist/main-portal/lib/exchanges/config.d.ts +0 -34
- package/dist/main-portal/lib/exchanges/config.js +0 -185
- package/dist/main-portal/lib/exchanges/hooks/index.d.ts +0 -5
- package/dist/main-portal/lib/exchanges/hooks/index.js +0 -10
- package/dist/main-portal/lib/exchanges/hooks/useBinanceData.d.ts +0 -15
- package/dist/main-portal/lib/exchanges/hooks/useBinanceData.js +0 -216
- package/dist/main-portal/lib/exchanges/hooks/useBinanceDialogs.d.ts +0 -32
- package/dist/main-portal/lib/exchanges/hooks/useBinanceDialogs.js +0 -395
- package/dist/main-portal/lib/exchanges/hooks/useUserExchanges.d.ts +0 -15
- package/dist/main-portal/lib/exchanges/hooks/useUserExchanges.js +0 -51
- package/dist/main-portal/lib/exchanges/index.d.ts +0 -4
- package/dist/main-portal/lib/exchanges/index.js +0 -21
- package/dist/main-portal/lib/exchanges/types.d.ts +0 -102
- package/dist/main-portal/lib/exchanges/types.js +0 -2
- package/dist/main-portal/lib/exchanges/utils.d.ts +0 -1
- package/dist/main-portal/lib/exchanges/utils.js +0 -10
- package/dist/main-portal/lib/gcp-secrets.d.ts +0 -7
- package/dist/main-portal/lib/gcp-secrets.js +0 -45
- package/dist/main-portal/lib/mockWallet.d.ts +0 -130
- package/dist/main-portal/lib/mockWallet.js +0 -284
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
interface Transaction {
|
|
2
|
-
type: string;
|
|
3
|
-
amount: number;
|
|
4
|
-
txHash: string;
|
|
5
|
-
timestamp: string;
|
|
6
|
-
balanceBefore?: number;
|
|
7
|
-
balanceAfter?: number;
|
|
8
|
-
to?: string;
|
|
9
|
-
from?: string;
|
|
10
|
-
}
|
|
11
|
-
interface TransferResult {
|
|
12
|
-
success: boolean;
|
|
13
|
-
txHash: string;
|
|
14
|
-
amount: number;
|
|
15
|
-
to?: string;
|
|
16
|
-
from?: string;
|
|
17
|
-
balanceBefore: number;
|
|
18
|
-
balanceAfter: number;
|
|
19
|
-
transaction: Transaction;
|
|
20
|
-
}
|
|
21
|
-
interface DepositResult {
|
|
22
|
-
success: boolean;
|
|
23
|
-
txHash: string;
|
|
24
|
-
amount: number;
|
|
25
|
-
balanceBefore: number;
|
|
26
|
-
balanceAfter: number;
|
|
27
|
-
transaction: Transaction;
|
|
28
|
-
}
|
|
29
|
-
interface WalletInfo {
|
|
30
|
-
userId: string;
|
|
31
|
-
balance: number;
|
|
32
|
-
transactionCount: number;
|
|
33
|
-
lastTransaction: Transaction | null;
|
|
34
|
-
isMock: boolean;
|
|
35
|
-
}
|
|
36
|
-
interface WalletExport {
|
|
37
|
-
userId: string;
|
|
38
|
-
balance: number;
|
|
39
|
-
transactions: Transaction[];
|
|
40
|
-
exportTime: string;
|
|
41
|
-
}
|
|
42
|
-
export declare function generateMockTxHash(): string;
|
|
43
|
-
export declare class PersistentMockWallet {
|
|
44
|
-
private userId;
|
|
45
|
-
private defaultBalance;
|
|
46
|
-
private storageKey;
|
|
47
|
-
private transactionsKey;
|
|
48
|
-
private balance;
|
|
49
|
-
private transactions;
|
|
50
|
-
constructor(userId: string, defaultBalance?: number);
|
|
51
|
-
private loadBalance;
|
|
52
|
-
private saveBalance;
|
|
53
|
-
private loadTransactions;
|
|
54
|
-
private saveTransactions;
|
|
55
|
-
private addTransaction;
|
|
56
|
-
getBalance(): number;
|
|
57
|
-
deposit(amount: number): DepositResult;
|
|
58
|
-
transfer(amount: number, to?: string): TransferResult;
|
|
59
|
-
refund(amount: number, from?: string): TransferResult;
|
|
60
|
-
reset(amount?: number): {
|
|
61
|
-
success: boolean;
|
|
62
|
-
newBalance: number;
|
|
63
|
-
};
|
|
64
|
-
clear(): void;
|
|
65
|
-
getTransactions(limit?: number): Transaction[];
|
|
66
|
-
getInfo(): WalletInfo;
|
|
67
|
-
hasEnough(amount: number): boolean;
|
|
68
|
-
export(): WalletExport;
|
|
69
|
-
import(data: WalletExport): void;
|
|
70
|
-
}
|
|
71
|
-
export declare class MemoryMockWallet {
|
|
72
|
-
private balance;
|
|
73
|
-
private transactions;
|
|
74
|
-
constructor(initialBalance?: number);
|
|
75
|
-
getBalance(): number;
|
|
76
|
-
deposit(amount: number): {
|
|
77
|
-
newBalance: number;
|
|
78
|
-
type: string;
|
|
79
|
-
amount: number;
|
|
80
|
-
txHash: string;
|
|
81
|
-
timestamp: string;
|
|
82
|
-
balanceBefore?: number;
|
|
83
|
-
balanceAfter?: number;
|
|
84
|
-
to?: string;
|
|
85
|
-
from?: string;
|
|
86
|
-
success: boolean;
|
|
87
|
-
};
|
|
88
|
-
transfer(amount: number, to?: string): {
|
|
89
|
-
newBalance: number;
|
|
90
|
-
type: string;
|
|
91
|
-
amount: number;
|
|
92
|
-
txHash: string;
|
|
93
|
-
timestamp: string;
|
|
94
|
-
balanceBefore?: number;
|
|
95
|
-
balanceAfter?: number;
|
|
96
|
-
to?: string;
|
|
97
|
-
from?: string;
|
|
98
|
-
success: boolean;
|
|
99
|
-
};
|
|
100
|
-
refund(amount: number, from?: string): {
|
|
101
|
-
newBalance: number;
|
|
102
|
-
type: string;
|
|
103
|
-
amount: number;
|
|
104
|
-
txHash: string;
|
|
105
|
-
timestamp: string;
|
|
106
|
-
balanceBefore?: number;
|
|
107
|
-
balanceAfter?: number;
|
|
108
|
-
to?: string;
|
|
109
|
-
from?: string;
|
|
110
|
-
success: boolean;
|
|
111
|
-
};
|
|
112
|
-
getTransactions(limit?: number): Transaction[];
|
|
113
|
-
hasEnough(amount: number): boolean;
|
|
114
|
-
}
|
|
115
|
-
export declare function createTestAccounts(): {
|
|
116
|
-
admin: PersistentMockWallet;
|
|
117
|
-
rich: PersistentMockWallet;
|
|
118
|
-
normal1: PersistentMockWallet;
|
|
119
|
-
normal2: PersistentMockWallet;
|
|
120
|
-
poor: PersistentMockWallet;
|
|
121
|
-
};
|
|
122
|
-
export declare function formatMCC(amount: number): string;
|
|
123
|
-
declare const _default: {
|
|
124
|
-
PersistentMockWallet: typeof PersistentMockWallet;
|
|
125
|
-
MemoryMockWallet: typeof MemoryMockWallet;
|
|
126
|
-
generateMockTxHash: typeof generateMockTxHash;
|
|
127
|
-
createTestAccounts: typeof createTestAccounts;
|
|
128
|
-
formatMCC: typeof formatMCC;
|
|
129
|
-
};
|
|
130
|
-
export default _default;
|
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MemoryMockWallet = exports.PersistentMockWallet = void 0;
|
|
4
|
-
exports.generateMockTxHash = generateMockTxHash;
|
|
5
|
-
exports.createTestAccounts = createTestAccounts;
|
|
6
|
-
exports.formatMCC = formatMCC;
|
|
7
|
-
function generateMockTxHash() {
|
|
8
|
-
const chars = '0123456789abcdef';
|
|
9
|
-
let hash = '0x';
|
|
10
|
-
for (let i = 0; i < 64; i++) {
|
|
11
|
-
hash += chars[Math.floor(Math.random() * 16)];
|
|
12
|
-
}
|
|
13
|
-
return hash;
|
|
14
|
-
}
|
|
15
|
-
class PersistentMockWallet {
|
|
16
|
-
constructor(userId, defaultBalance = 100000) {
|
|
17
|
-
this.balance = 0;
|
|
18
|
-
this.transactions = [];
|
|
19
|
-
if (!userId) {
|
|
20
|
-
throw new Error('userId is required');
|
|
21
|
-
}
|
|
22
|
-
this.userId = userId;
|
|
23
|
-
this.defaultBalance = defaultBalance;
|
|
24
|
-
this.storageKey = `mock_wallet_${userId}`;
|
|
25
|
-
this.transactionsKey = `mock_wallet_tx_${userId}`;
|
|
26
|
-
this.loadBalance();
|
|
27
|
-
this.loadTransactions();
|
|
28
|
-
}
|
|
29
|
-
loadBalance() {
|
|
30
|
-
if (typeof window === 'undefined') {
|
|
31
|
-
this.balance = this.defaultBalance;
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
const saved = localStorage.getItem(this.storageKey);
|
|
35
|
-
this.balance = saved ? parseFloat(saved) : this.defaultBalance;
|
|
36
|
-
}
|
|
37
|
-
saveBalance() {
|
|
38
|
-
if (typeof window === 'undefined')
|
|
39
|
-
return;
|
|
40
|
-
localStorage.setItem(this.storageKey, this.balance.toString());
|
|
41
|
-
}
|
|
42
|
-
loadTransactions() {
|
|
43
|
-
if (typeof window === 'undefined') {
|
|
44
|
-
this.transactions = [];
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const saved = localStorage.getItem(this.transactionsKey);
|
|
48
|
-
this.transactions = saved ? JSON.parse(saved) : [];
|
|
49
|
-
}
|
|
50
|
-
saveTransactions() {
|
|
51
|
-
if (typeof window === 'undefined')
|
|
52
|
-
return;
|
|
53
|
-
localStorage.setItem(this.transactionsKey, JSON.stringify(this.transactions));
|
|
54
|
-
}
|
|
55
|
-
addTransaction(type, amount, txHash, details = {}) {
|
|
56
|
-
const transaction = {
|
|
57
|
-
type,
|
|
58
|
-
amount,
|
|
59
|
-
txHash,
|
|
60
|
-
timestamp: new Date().toISOString(),
|
|
61
|
-
balanceBefore: this.balance,
|
|
62
|
-
balanceAfter: this.balance,
|
|
63
|
-
...details
|
|
64
|
-
};
|
|
65
|
-
this.transactions.unshift(transaction);
|
|
66
|
-
if (this.transactions.length > 100) {
|
|
67
|
-
this.transactions = this.transactions.slice(0, 100);
|
|
68
|
-
}
|
|
69
|
-
this.saveTransactions();
|
|
70
|
-
return transaction;
|
|
71
|
-
}
|
|
72
|
-
getBalance() {
|
|
73
|
-
return this.balance;
|
|
74
|
-
}
|
|
75
|
-
deposit(amount) {
|
|
76
|
-
if (amount <= 0) {
|
|
77
|
-
throw new Error('充值金额必须大于0');
|
|
78
|
-
}
|
|
79
|
-
const txHash = generateMockTxHash();
|
|
80
|
-
const balanceBefore = this.balance;
|
|
81
|
-
this.balance += amount;
|
|
82
|
-
this.saveBalance();
|
|
83
|
-
const transaction = this.addTransaction('deposit', amount, txHash, {
|
|
84
|
-
balanceBefore,
|
|
85
|
-
balanceAfter: this.balance
|
|
86
|
-
});
|
|
87
|
-
console.log(`✅ 模拟充值成功: ${amount} MCC`);
|
|
88
|
-
console.log(`Transaction Hash: ${txHash}`);
|
|
89
|
-
console.log(`新余额: ${this.balance} MCC`);
|
|
90
|
-
return {
|
|
91
|
-
success: true,
|
|
92
|
-
txHash,
|
|
93
|
-
amount,
|
|
94
|
-
balanceBefore,
|
|
95
|
-
balanceAfter: this.balance,
|
|
96
|
-
transaction
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
transfer(amount, to = 'contract') {
|
|
100
|
-
if (amount <= 0) {
|
|
101
|
-
throw new Error('转账金额必须大于0');
|
|
102
|
-
}
|
|
103
|
-
if (this.balance < amount) {
|
|
104
|
-
throw new Error(`余额不足! 当前余额: ${this.balance} MCC, 需要: ${amount} MCC`);
|
|
105
|
-
}
|
|
106
|
-
const txHash = generateMockTxHash();
|
|
107
|
-
const balanceBefore = this.balance;
|
|
108
|
-
this.balance -= amount;
|
|
109
|
-
this.saveBalance();
|
|
110
|
-
const transaction = this.addTransaction('transfer', amount, txHash, {
|
|
111
|
-
balanceBefore,
|
|
112
|
-
balanceAfter: this.balance,
|
|
113
|
-
to
|
|
114
|
-
});
|
|
115
|
-
console.log(`✅ 模拟转账成功: ${amount} MCC → ${to}`);
|
|
116
|
-
console.log(`Transaction Hash: ${txHash}`);
|
|
117
|
-
console.log(`剩余余额: ${this.balance} MCC`);
|
|
118
|
-
return {
|
|
119
|
-
success: true,
|
|
120
|
-
txHash,
|
|
121
|
-
amount,
|
|
122
|
-
to,
|
|
123
|
-
balanceBefore,
|
|
124
|
-
balanceAfter: this.balance,
|
|
125
|
-
transaction
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
refund(amount, from = 'contract') {
|
|
129
|
-
if (amount <= 0) {
|
|
130
|
-
throw new Error('退款金额必须大于0');
|
|
131
|
-
}
|
|
132
|
-
const txHash = generateMockTxHash();
|
|
133
|
-
const balanceBefore = this.balance;
|
|
134
|
-
this.balance += amount;
|
|
135
|
-
this.saveBalance();
|
|
136
|
-
const transaction = this.addTransaction('refund', amount, txHash, {
|
|
137
|
-
balanceBefore,
|
|
138
|
-
balanceAfter: this.balance,
|
|
139
|
-
from
|
|
140
|
-
});
|
|
141
|
-
console.log(`✅ 模拟退款成功: ${amount} MCC ← ${from}`);
|
|
142
|
-
console.log(`Transaction Hash: ${txHash}`);
|
|
143
|
-
console.log(`新余额: ${this.balance} MCC`);
|
|
144
|
-
return {
|
|
145
|
-
success: true,
|
|
146
|
-
txHash,
|
|
147
|
-
amount,
|
|
148
|
-
from,
|
|
149
|
-
balanceBefore,
|
|
150
|
-
balanceAfter: this.balance,
|
|
151
|
-
transaction
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
reset(amount = 100000) {
|
|
155
|
-
this.balance = amount;
|
|
156
|
-
this.saveBalance();
|
|
157
|
-
console.log(`🔄 余额已重置为: ${amount} MCC`);
|
|
158
|
-
return {
|
|
159
|
-
success: true,
|
|
160
|
-
newBalance: this.balance
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
clear() {
|
|
164
|
-
if (typeof window === 'undefined')
|
|
165
|
-
return;
|
|
166
|
-
localStorage.removeItem(this.storageKey);
|
|
167
|
-
localStorage.removeItem(this.transactionsKey);
|
|
168
|
-
this.balance = this.defaultBalance;
|
|
169
|
-
this.transactions = [];
|
|
170
|
-
console.log('🗑️ 钱包数据已清除');
|
|
171
|
-
}
|
|
172
|
-
getTransactions(limit = 10) {
|
|
173
|
-
return this.transactions.slice(0, limit);
|
|
174
|
-
}
|
|
175
|
-
getInfo() {
|
|
176
|
-
return {
|
|
177
|
-
userId: this.userId,
|
|
178
|
-
balance: this.balance,
|
|
179
|
-
transactionCount: this.transactions.length,
|
|
180
|
-
lastTransaction: this.transactions[0] || null,
|
|
181
|
-
isMock: true
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
hasEnough(amount) {
|
|
185
|
-
return this.balance >= amount;
|
|
186
|
-
}
|
|
187
|
-
export() {
|
|
188
|
-
return {
|
|
189
|
-
userId: this.userId,
|
|
190
|
-
balance: this.balance,
|
|
191
|
-
transactions: this.transactions,
|
|
192
|
-
exportTime: new Date().toISOString()
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
import(data) {
|
|
196
|
-
if (data.userId !== this.userId) {
|
|
197
|
-
throw new Error('用户ID不匹配');
|
|
198
|
-
}
|
|
199
|
-
this.balance = data.balance;
|
|
200
|
-
this.transactions = data.transactions || [];
|
|
201
|
-
this.saveBalance();
|
|
202
|
-
this.saveTransactions();
|
|
203
|
-
console.log('✅ 钱包数据导入成功');
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
exports.PersistentMockWallet = PersistentMockWallet;
|
|
207
|
-
class MemoryMockWallet {
|
|
208
|
-
constructor(initialBalance = 100000) {
|
|
209
|
-
this.balance = initialBalance;
|
|
210
|
-
this.transactions = [];
|
|
211
|
-
}
|
|
212
|
-
getBalance() {
|
|
213
|
-
return this.balance;
|
|
214
|
-
}
|
|
215
|
-
deposit(amount) {
|
|
216
|
-
if (amount <= 0)
|
|
217
|
-
throw new Error('充值金额必须大于0');
|
|
218
|
-
this.balance += amount;
|
|
219
|
-
const tx = {
|
|
220
|
-
type: 'deposit',
|
|
221
|
-
amount,
|
|
222
|
-
txHash: generateMockTxHash(),
|
|
223
|
-
timestamp: new Date().toISOString()
|
|
224
|
-
};
|
|
225
|
-
this.transactions.push(tx);
|
|
226
|
-
return { success: true, ...tx, newBalance: this.balance };
|
|
227
|
-
}
|
|
228
|
-
transfer(amount, to = 'contract') {
|
|
229
|
-
if (amount <= 0)
|
|
230
|
-
throw new Error('转账金额必须大于0');
|
|
231
|
-
if (this.balance < amount)
|
|
232
|
-
throw new Error('余额不足');
|
|
233
|
-
this.balance -= amount;
|
|
234
|
-
const tx = {
|
|
235
|
-
type: 'transfer',
|
|
236
|
-
amount,
|
|
237
|
-
to,
|
|
238
|
-
txHash: generateMockTxHash(),
|
|
239
|
-
timestamp: new Date().toISOString()
|
|
240
|
-
};
|
|
241
|
-
this.transactions.push(tx);
|
|
242
|
-
return { success: true, ...tx, newBalance: this.balance };
|
|
243
|
-
}
|
|
244
|
-
refund(amount, from = 'contract') {
|
|
245
|
-
if (amount <= 0)
|
|
246
|
-
throw new Error('退款金额必须大于0');
|
|
247
|
-
this.balance += amount;
|
|
248
|
-
const tx = {
|
|
249
|
-
type: 'refund',
|
|
250
|
-
amount,
|
|
251
|
-
from,
|
|
252
|
-
txHash: generateMockTxHash(),
|
|
253
|
-
timestamp: new Date().toISOString()
|
|
254
|
-
};
|
|
255
|
-
this.transactions.push(tx);
|
|
256
|
-
return { success: true, ...tx, newBalance: this.balance };
|
|
257
|
-
}
|
|
258
|
-
getTransactions(limit = 10) {
|
|
259
|
-
return this.transactions.slice(-limit).reverse();
|
|
260
|
-
}
|
|
261
|
-
hasEnough(amount) {
|
|
262
|
-
return this.balance >= amount;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
exports.MemoryMockWallet = MemoryMockWallet;
|
|
266
|
-
function createTestAccounts() {
|
|
267
|
-
return {
|
|
268
|
-
admin: new PersistentMockWallet('admin_test_001', Infinity),
|
|
269
|
-
rich: new PersistentMockWallet('user_rich_001', 500000),
|
|
270
|
-
normal1: new PersistentMockWallet('user_normal_001', 50000),
|
|
271
|
-
normal2: new PersistentMockWallet('user_normal_002', 50000),
|
|
272
|
-
poor: new PersistentMockWallet('user_poor_001', 5000)
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
function formatMCC(amount) {
|
|
276
|
-
return `${amount.toLocaleString()} MCC`;
|
|
277
|
-
}
|
|
278
|
-
exports.default = {
|
|
279
|
-
PersistentMockWallet,
|
|
280
|
-
MemoryMockWallet,
|
|
281
|
-
generateMockTxHash,
|
|
282
|
-
createTestAccounts,
|
|
283
|
-
formatMCC
|
|
284
|
-
};
|