@numen-crypto/contract 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 +54 -0
- package/dist/index.cjs +740 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2448 -0
- package/dist/index.d.ts +2448 -0
- package/dist/index.js +683 -0
- package/dist/index.js.map +1 -0
- package/package.json +43 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,683 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// src/constants/error-codes.ts
|
|
4
|
+
var ERROR_CODE = {
|
|
5
|
+
// generic
|
|
6
|
+
VALIDATION: "VALIDATION",
|
|
7
|
+
NOT_FOUND: "NOT_FOUND",
|
|
8
|
+
CONFLICT: "CONFLICT",
|
|
9
|
+
UNAUTHORIZED: "UNAUTHORIZED",
|
|
10
|
+
FORBIDDEN: "FORBIDDEN",
|
|
11
|
+
RATE_LIMITED: "RATE_LIMITED",
|
|
12
|
+
INTERNAL: "INTERNAL",
|
|
13
|
+
// auth
|
|
14
|
+
EMAIL_TAKEN: "EMAIL_TAKEN",
|
|
15
|
+
REFERRER_NOT_FOUND: "REFERRER_NOT_FOUND",
|
|
16
|
+
INVALID_CREDENTIALS: "INVALID_CREDENTIALS",
|
|
17
|
+
SESSION_INVALID: "SESSION_INVALID",
|
|
18
|
+
SESSION_EXPIRED: "SESSION_EXPIRED",
|
|
19
|
+
TOTP_REQUIRED: "TOTP_REQUIRED",
|
|
20
|
+
TOTP_ALREADY_ENABLED: "TOTP_ALREADY_ENABLED",
|
|
21
|
+
// wallet / purchase / withdrawal (reserved for next slices)
|
|
22
|
+
INSUFFICIENT_BALANCE: "INSUFFICIENT_BALANCE",
|
|
23
|
+
PURCHASE_LIMIT_EXCEEDED: "PURCHASE_LIMIT_EXCEEDED",
|
|
24
|
+
SALE_PHASE_INACTIVE: "SALE_PHASE_INACTIVE",
|
|
25
|
+
WITHDRAWAL_COOLOFF: "WITHDRAWAL_COOLOFF",
|
|
26
|
+
// bonus
|
|
27
|
+
BONUS_ALREADY_CLAIMED: "BONUS_ALREADY_CLAIMED",
|
|
28
|
+
// account linking
|
|
29
|
+
LINK_PROVIDER_DISABLED: "LINK_PROVIDER_DISABLED",
|
|
30
|
+
LINK_VERIFICATION_FAILED: "LINK_VERIFICATION_FAILED",
|
|
31
|
+
LINK_ALREADY_USED: "LINK_ALREADY_USED"
|
|
32
|
+
};
|
|
33
|
+
var MONEY_REGEX = /^-?\d+(\.\d{1,18})?$/;
|
|
34
|
+
var MoneyStringSchema = z.string().regex(MONEY_REGEX, "invalid money string (max 18 fractional digits)");
|
|
35
|
+
var PositiveMoneyStringSchema = MoneyStringSchema.refine(
|
|
36
|
+
(v) => !v.startsWith("-") && Number.parseFloat(v) > 0,
|
|
37
|
+
"must be positive"
|
|
38
|
+
);
|
|
39
|
+
var UuidSchema = z.string().uuid();
|
|
40
|
+
var ErrorResponseSchema = z.object({
|
|
41
|
+
error: z.object({
|
|
42
|
+
code: z.string(),
|
|
43
|
+
message: z.string()
|
|
44
|
+
}),
|
|
45
|
+
requestId: z.string().optional()
|
|
46
|
+
});
|
|
47
|
+
var PaginationQuerySchema = z.object({
|
|
48
|
+
page: z.coerce.number().int().min(1).default(1),
|
|
49
|
+
pageSize: z.coerce.number().int().min(1).max(100).default(20)
|
|
50
|
+
});
|
|
51
|
+
function PaginatedSchema(item) {
|
|
52
|
+
return z.object({
|
|
53
|
+
items: z.array(item),
|
|
54
|
+
total: z.number().int().nonnegative(),
|
|
55
|
+
page: z.number().int().min(1),
|
|
56
|
+
pageSize: z.number().int().min(1)
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
var UserStatusSchema = z.enum(["pending", "active", "suspended", "deleted"]);
|
|
60
|
+
var UserProfileSchema = z.object({
|
|
61
|
+
id: z.string().uuid(),
|
|
62
|
+
email: z.string().email(),
|
|
63
|
+
displayName: z.string().nullable(),
|
|
64
|
+
avatarUrl: z.string().url().nullable(),
|
|
65
|
+
referrerId: z.string().uuid().nullable(),
|
|
66
|
+
rankId: z.string().uuid().nullable(),
|
|
67
|
+
status: UserStatusSchema,
|
|
68
|
+
totpEnabled: z.boolean(),
|
|
69
|
+
createdAt: z.string().datetime()
|
|
70
|
+
});
|
|
71
|
+
var SessionInfoSchema = z.object({
|
|
72
|
+
id: z.string(),
|
|
73
|
+
ip: z.string().nullable(),
|
|
74
|
+
userAgent: z.string().nullable(),
|
|
75
|
+
createdAt: z.string().datetime(),
|
|
76
|
+
lastSeenAt: z.string().datetime(),
|
|
77
|
+
current: z.boolean()
|
|
78
|
+
});
|
|
79
|
+
var ASSET_SYMBOLS = ["NMN", "USDT", "BTC", "ETH", "BNB", "TRX", "SOL"];
|
|
80
|
+
var AssetSymbolSchema = z.enum(ASSET_SYMBOLS);
|
|
81
|
+
var DEPOSITABLE_ASSETS = ["USDT", "BTC", "ETH", "BNB", "TRX", "SOL"];
|
|
82
|
+
var DepositableAssetSchema = z.enum(DEPOSITABLE_ASSETS);
|
|
83
|
+
var TOKEN_ASSET = "NMN";
|
|
84
|
+
var FUNDING_ASSET = "USDT";
|
|
85
|
+
var AssetBalanceSchema = z.object({
|
|
86
|
+
asset: AssetSymbolSchema,
|
|
87
|
+
name: z.string(),
|
|
88
|
+
networks: z.array(z.string()),
|
|
89
|
+
depositable: z.boolean(),
|
|
90
|
+
available: MoneyStringSchema,
|
|
91
|
+
locked: MoneyStringSchema,
|
|
92
|
+
usdValue: MoneyStringSchema,
|
|
93
|
+
isZero: z.boolean()
|
|
94
|
+
});
|
|
95
|
+
var WalletOverviewSchema = z.object({
|
|
96
|
+
totalUsd: MoneyStringSchema,
|
|
97
|
+
assets: z.array(AssetBalanceSchema)
|
|
98
|
+
});
|
|
99
|
+
var TransactionTypeSchema = z.enum([
|
|
100
|
+
"DEPOSIT",
|
|
101
|
+
"WITHDRAWAL",
|
|
102
|
+
"BUY",
|
|
103
|
+
"SELL",
|
|
104
|
+
"COMMISSION",
|
|
105
|
+
"BONUS",
|
|
106
|
+
"ADJUSTMENT"
|
|
107
|
+
]);
|
|
108
|
+
var TransactionStatusSchema = z.enum([
|
|
109
|
+
"PENDING",
|
|
110
|
+
"PROCESSING",
|
|
111
|
+
"COMPLETED",
|
|
112
|
+
"FAILED",
|
|
113
|
+
"CANCELLED"
|
|
114
|
+
]);
|
|
115
|
+
var TransactionSchema = z.object({
|
|
116
|
+
id: z.string().uuid(),
|
|
117
|
+
type: TransactionTypeSchema,
|
|
118
|
+
asset: AssetSymbolSchema,
|
|
119
|
+
amount: MoneyStringSchema,
|
|
120
|
+
status: TransactionStatusSchema,
|
|
121
|
+
reference: z.string().nullable(),
|
|
122
|
+
createdAt: z.string().datetime()
|
|
123
|
+
});
|
|
124
|
+
var DepositAddressSchema = z.object({
|
|
125
|
+
asset: DepositableAssetSchema,
|
|
126
|
+
network: z.string(),
|
|
127
|
+
address: z.string(),
|
|
128
|
+
minAmount: MoneyStringSchema,
|
|
129
|
+
confirmations: z.number().int().nonnegative()
|
|
130
|
+
});
|
|
131
|
+
var PartnerLevelSchema = z.object({
|
|
132
|
+
level: z.number().int().min(1).max(10),
|
|
133
|
+
partners: z.number().int().nonnegative()
|
|
134
|
+
});
|
|
135
|
+
var PartnersOverviewSchema = z.object({
|
|
136
|
+
referralCode: z.string(),
|
|
137
|
+
totalPartners: z.number().int().nonnegative(),
|
|
138
|
+
directPartners: z.number().int().nonnegative(),
|
|
139
|
+
networkTurnover: MoneyStringSchema,
|
|
140
|
+
affiliateIncome: MoneyStringSchema,
|
|
141
|
+
levels: z.array(PartnerLevelSchema)
|
|
142
|
+
});
|
|
143
|
+
var RankDefSchema = z.object({
|
|
144
|
+
name: z.string(),
|
|
145
|
+
order: z.number().int().nonnegative(),
|
|
146
|
+
minTurnover: MoneyStringSchema
|
|
147
|
+
});
|
|
148
|
+
var UserRankSchema = z.object({
|
|
149
|
+
name: z.string(),
|
|
150
|
+
order: z.number().int().nonnegative(),
|
|
151
|
+
minTurnover: MoneyStringSchema,
|
|
152
|
+
nextName: z.string().nullable(),
|
|
153
|
+
nextMinTurnover: MoneyStringSchema.nullable(),
|
|
154
|
+
progressPct: z.string()
|
|
155
|
+
});
|
|
156
|
+
var EarningsOverviewSchema = z.object({
|
|
157
|
+
tokenBalance: MoneyStringSchema,
|
|
158
|
+
tokenPrice: MoneyStringSchema,
|
|
159
|
+
tokenValueUsd: MoneyStringSchema,
|
|
160
|
+
affiliateIncome: MoneyStringSchema,
|
|
161
|
+
networkTurnover: MoneyStringSchema,
|
|
162
|
+
rank: UserRankSchema
|
|
163
|
+
});
|
|
164
|
+
var UserSettingsSchema = z.object({
|
|
165
|
+
notifyTrades: z.boolean(),
|
|
166
|
+
notifyByEmail: z.boolean(),
|
|
167
|
+
withdrawalEmailConfirm: z.boolean()
|
|
168
|
+
});
|
|
169
|
+
var DailyBonusDaySchema = z.object({
|
|
170
|
+
dayIndex: z.number().int().min(1),
|
|
171
|
+
rewardNmn: MoneyStringSchema,
|
|
172
|
+
surprise: z.boolean()
|
|
173
|
+
});
|
|
174
|
+
var DailyBonusStatusSchema = z.object({
|
|
175
|
+
currentStreak: z.number().int().nonnegative(),
|
|
176
|
+
cycleLength: z.number().int().positive(),
|
|
177
|
+
claimableToday: z.boolean(),
|
|
178
|
+
todayDayIndex: z.number().int().min(1),
|
|
179
|
+
nextRewardNmn: MoneyStringSchema,
|
|
180
|
+
days: z.array(DailyBonusDaySchema)
|
|
181
|
+
});
|
|
182
|
+
var DailyBonusClaimResultSchema = z.object({
|
|
183
|
+
claimed: z.boolean(),
|
|
184
|
+
dayIndex: z.number().int().min(1),
|
|
185
|
+
rewardNmn: MoneyStringSchema,
|
|
186
|
+
currentStreak: z.number().int().positive()
|
|
187
|
+
});
|
|
188
|
+
var NotificationTypeSchema = z.enum([
|
|
189
|
+
"TRADE_EXECUTED",
|
|
190
|
+
"DEPOSIT_CREDITED",
|
|
191
|
+
"COMMISSION_ACCRUED",
|
|
192
|
+
"WITHDRAWAL_SENT",
|
|
193
|
+
"BONUS_CLAIMED",
|
|
194
|
+
"SYSTEM"
|
|
195
|
+
]);
|
|
196
|
+
var NotificationSchema = z.object({
|
|
197
|
+
id: z.string().uuid(),
|
|
198
|
+
type: NotificationTypeSchema,
|
|
199
|
+
title: z.string(),
|
|
200
|
+
body: z.string(),
|
|
201
|
+
read: z.boolean(),
|
|
202
|
+
meta: z.record(z.unknown()).nullable(),
|
|
203
|
+
createdAt: z.string().datetime()
|
|
204
|
+
});
|
|
205
|
+
var LeaderboardPeriodSchema = z.enum(["week", "month", "year", "all"]);
|
|
206
|
+
var LeaderboardEntrySchema = z.object({
|
|
207
|
+
rank: z.number().int().positive(),
|
|
208
|
+
userId: z.string().uuid(),
|
|
209
|
+
displayName: z.string(),
|
|
210
|
+
line: z.number().int().min(1).max(10).nullable(),
|
|
211
|
+
partners: z.number().int().nonnegative(),
|
|
212
|
+
turnoverUsd: MoneyStringSchema,
|
|
213
|
+
changePct: z.number(),
|
|
214
|
+
isSelf: z.boolean()
|
|
215
|
+
});
|
|
216
|
+
var LeaderboardSchema = z.object({
|
|
217
|
+
period: LeaderboardPeriodSchema,
|
|
218
|
+
items: z.array(LeaderboardEntrySchema),
|
|
219
|
+
self: LeaderboardEntrySchema.nullable()
|
|
220
|
+
});
|
|
221
|
+
var LinkProviderSchema = z.enum(["telegram", "google"]);
|
|
222
|
+
var LinkedAccountSchema = z.object({
|
|
223
|
+
provider: LinkProviderSchema,
|
|
224
|
+
providerUserId: z.string(),
|
|
225
|
+
displayName: z.string().nullable(),
|
|
226
|
+
linkedAt: z.string().datetime()
|
|
227
|
+
});
|
|
228
|
+
var IncomePeriodSchema = z.enum(["week", "month", "year", "all"]);
|
|
229
|
+
var PartnerAccrualSchema = z.object({
|
|
230
|
+
id: z.string().uuid(),
|
|
231
|
+
level: z.number().int().min(1).max(10),
|
|
232
|
+
sourceUserId: z.string().uuid(),
|
|
233
|
+
sourceName: z.string(),
|
|
234
|
+
amountUsd: MoneyStringSchema,
|
|
235
|
+
createdAt: z.string().datetime()
|
|
236
|
+
});
|
|
237
|
+
var MonthlyPricePointSchema = z.object({
|
|
238
|
+
month: z.string(),
|
|
239
|
+
fromPrice: MoneyStringSchema,
|
|
240
|
+
toPrice: MoneyStringSchema,
|
|
241
|
+
holdingGrowthUsd: MoneyStringSchema
|
|
242
|
+
});
|
|
243
|
+
var IncomeOverviewSchema = z.object({
|
|
244
|
+
period: IncomePeriodSchema,
|
|
245
|
+
tokenGrowthIncomeUsd: MoneyStringSchema,
|
|
246
|
+
tokenGrowthPct: z.number(),
|
|
247
|
+
affiliateIncomeNmn: MoneyStringSchema,
|
|
248
|
+
affiliateIncomeUsd: MoneyStringSchema,
|
|
249
|
+
totalEarnedUsd: MoneyStringSchema,
|
|
250
|
+
partnerAccruals: z.array(PartnerAccrualSchema),
|
|
251
|
+
monthlyPrice: z.array(MonthlyPricePointSchema)
|
|
252
|
+
});
|
|
253
|
+
var WithdrawalStatusSchema = z.enum([
|
|
254
|
+
"AWAITING_CONFIRM",
|
|
255
|
+
"AWAITING_COOLOFF",
|
|
256
|
+
"QUEUED",
|
|
257
|
+
"SENT",
|
|
258
|
+
"CONFIRMED",
|
|
259
|
+
"FAILED",
|
|
260
|
+
"CANCELLED"
|
|
261
|
+
]);
|
|
262
|
+
var WithdrawalSchema = z.object({
|
|
263
|
+
id: z.string().uuid(),
|
|
264
|
+
asset: AssetSymbolSchema,
|
|
265
|
+
amount: MoneyStringSchema,
|
|
266
|
+
address: z.string(),
|
|
267
|
+
status: WithdrawalStatusSchema,
|
|
268
|
+
createdAt: z.string().datetime()
|
|
269
|
+
});
|
|
270
|
+
var TokenPriceSchema = z.object({
|
|
271
|
+
price: MoneyStringSchema,
|
|
272
|
+
change24hPct: z.string(),
|
|
273
|
+
tradeIndex: z.number().int().nonnegative(),
|
|
274
|
+
updatedAt: z.string().datetime()
|
|
275
|
+
});
|
|
276
|
+
var ChartPeriodSchema = z.enum(["day", "week", "month", "year"]);
|
|
277
|
+
var ChartPointSchema = z.object({
|
|
278
|
+
t: z.string().datetime(),
|
|
279
|
+
price: MoneyStringSchema
|
|
280
|
+
});
|
|
281
|
+
var SwapSideSchema = z.enum(["BUY", "SELL"]);
|
|
282
|
+
var TradeResultSchema = z.object({
|
|
283
|
+
tradeId: z.string().uuid(),
|
|
284
|
+
side: SwapSideSchema,
|
|
285
|
+
usdtAmount: MoneyStringSchema,
|
|
286
|
+
nmnAmount: MoneyStringSchema,
|
|
287
|
+
price: MoneyStringSchema,
|
|
288
|
+
feeUsdt: MoneyStringSchema
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
// src/commands/command.types.ts
|
|
292
|
+
function endpoint(method, path, summary) {
|
|
293
|
+
return { method, path, summary };
|
|
294
|
+
}
|
|
295
|
+
var RegisterCommand;
|
|
296
|
+
((RegisterCommand2) => {
|
|
297
|
+
RegisterCommand2.endpointDetails = endpoint("POST", "/auth/register", "Register a new user");
|
|
298
|
+
RegisterCommand2.RequestSchema = z.object({
|
|
299
|
+
email: z.string().email().max(254),
|
|
300
|
+
password: z.string().min(12).max(128),
|
|
301
|
+
referralCode: z.string().min(4).max(64).optional()
|
|
302
|
+
});
|
|
303
|
+
RegisterCommand2.ResponseSchema = z.object({
|
|
304
|
+
userId: z.string().uuid()
|
|
305
|
+
});
|
|
306
|
+
})(RegisterCommand || (RegisterCommand = {}));
|
|
307
|
+
var LoginCommand;
|
|
308
|
+
((LoginCommand2) => {
|
|
309
|
+
LoginCommand2.endpointDetails = endpoint("POST", "/auth/login", "Login with email and password");
|
|
310
|
+
LoginCommand2.RequestSchema = z.object({
|
|
311
|
+
email: z.string().email().max(254),
|
|
312
|
+
password: z.string().min(1).max(128),
|
|
313
|
+
totp: z.string().regex(/^\d{6}$/).optional()
|
|
314
|
+
});
|
|
315
|
+
LoginCommand2.ResponseSchema = z.object({
|
|
316
|
+
user: UserProfileSchema
|
|
317
|
+
});
|
|
318
|
+
})(LoginCommand || (LoginCommand = {}));
|
|
319
|
+
var LogoutCommand;
|
|
320
|
+
((LogoutCommand2) => {
|
|
321
|
+
LogoutCommand2.endpointDetails = endpoint("POST", "/auth/logout", "Terminate the current session");
|
|
322
|
+
LogoutCommand2.RequestSchema = z.object({
|
|
323
|
+
allDevices: z.boolean().optional().default(false)
|
|
324
|
+
});
|
|
325
|
+
LogoutCommand2.ResponseSchema = z.void();
|
|
326
|
+
})(LogoutCommand || (LogoutCommand = {}));
|
|
327
|
+
var MeCommand;
|
|
328
|
+
((MeCommand2) => {
|
|
329
|
+
MeCommand2.endpointDetails = endpoint("GET", "/auth/me", "Get the current authenticated user");
|
|
330
|
+
MeCommand2.ResponseSchema = z.object({
|
|
331
|
+
user: UserProfileSchema
|
|
332
|
+
});
|
|
333
|
+
})(MeCommand || (MeCommand = {}));
|
|
334
|
+
var SetupTotpCommand;
|
|
335
|
+
((SetupTotpCommand2) => {
|
|
336
|
+
SetupTotpCommand2.endpointDetails = endpoint("POST", "/auth/totp/setup", "Begin TOTP enrollment");
|
|
337
|
+
SetupTotpCommand2.ResponseSchema = z.object({
|
|
338
|
+
secret: z.string(),
|
|
339
|
+
otpauthUrl: z.string()
|
|
340
|
+
});
|
|
341
|
+
})(SetupTotpCommand || (SetupTotpCommand = {}));
|
|
342
|
+
var ConfirmTotpCommand;
|
|
343
|
+
((ConfirmTotpCommand2) => {
|
|
344
|
+
ConfirmTotpCommand2.endpointDetails = endpoint("POST", "/auth/totp/confirm", "Confirm and enable TOTP");
|
|
345
|
+
ConfirmTotpCommand2.RequestSchema = z.object({
|
|
346
|
+
secret: z.string().min(16).max(128),
|
|
347
|
+
otp: z.string().regex(/^\d{6}$/)
|
|
348
|
+
});
|
|
349
|
+
ConfirmTotpCommand2.ResponseSchema = z.void();
|
|
350
|
+
})(ConfirmTotpCommand || (ConfirmTotpCommand = {}));
|
|
351
|
+
|
|
352
|
+
// src/commands/wallet/get-wallet.command.ts
|
|
353
|
+
var GetWalletCommand;
|
|
354
|
+
((GetWalletCommand2) => {
|
|
355
|
+
GetWalletCommand2.endpointDetails = endpoint("GET", "/wallet", "Get wallet overview with all asset balances");
|
|
356
|
+
GetWalletCommand2.ResponseSchema = WalletOverviewSchema;
|
|
357
|
+
})(GetWalletCommand || (GetWalletCommand = {}));
|
|
358
|
+
|
|
359
|
+
// src/commands/wallet/get-transactions.command.ts
|
|
360
|
+
var GetTransactionsCommand;
|
|
361
|
+
((GetTransactionsCommand2) => {
|
|
362
|
+
GetTransactionsCommand2.endpointDetails = endpoint("GET", "/wallet/transactions", "List the user transaction history");
|
|
363
|
+
GetTransactionsCommand2.QuerySchema = PaginationQuerySchema.extend({
|
|
364
|
+
type: TransactionTypeSchema.optional()
|
|
365
|
+
});
|
|
366
|
+
GetTransactionsCommand2.ResponseSchema = PaginatedSchema(TransactionSchema);
|
|
367
|
+
})(GetTransactionsCommand || (GetTransactionsCommand = {}));
|
|
368
|
+
var DepositAddressCommand;
|
|
369
|
+
((DepositAddressCommand2) => {
|
|
370
|
+
DepositAddressCommand2.endpointDetails = endpoint(
|
|
371
|
+
"POST",
|
|
372
|
+
"/wallet/deposit-address",
|
|
373
|
+
"Get a deposit address for the given asset"
|
|
374
|
+
);
|
|
375
|
+
DepositAddressCommand2.RequestSchema = z.object({
|
|
376
|
+
asset: DepositableAssetSchema,
|
|
377
|
+
network: z.string().min(2).max(32)
|
|
378
|
+
});
|
|
379
|
+
DepositAddressCommand2.ResponseSchema = DepositAddressSchema;
|
|
380
|
+
})(DepositAddressCommand || (DepositAddressCommand = {}));
|
|
381
|
+
|
|
382
|
+
// src/commands/token/get-price.command.ts
|
|
383
|
+
var GetTokenPriceCommand;
|
|
384
|
+
((GetTokenPriceCommand2) => {
|
|
385
|
+
GetTokenPriceCommand2.endpointDetails = endpoint("GET", "/token/price", "Current NMN price and 24h change");
|
|
386
|
+
GetTokenPriceCommand2.ResponseSchema = TokenPriceSchema;
|
|
387
|
+
})(GetTokenPriceCommand || (GetTokenPriceCommand = {}));
|
|
388
|
+
var GetTokenChartCommand;
|
|
389
|
+
((GetTokenChartCommand2) => {
|
|
390
|
+
GetTokenChartCommand2.endpointDetails = endpoint("GET", "/token/chart", "NMN price chart points for a period");
|
|
391
|
+
GetTokenChartCommand2.QuerySchema = z.object({
|
|
392
|
+
period: ChartPeriodSchema.default("day")
|
|
393
|
+
});
|
|
394
|
+
GetTokenChartCommand2.ResponseSchema = z.object({
|
|
395
|
+
period: ChartPeriodSchema,
|
|
396
|
+
points: z.array(ChartPointSchema)
|
|
397
|
+
});
|
|
398
|
+
})(GetTokenChartCommand || (GetTokenChartCommand = {}));
|
|
399
|
+
var SwapCommand;
|
|
400
|
+
((SwapCommand2) => {
|
|
401
|
+
SwapCommand2.endpointDetails = endpoint("POST", "/swap", "Buy or sell NMN against USDT at the live price");
|
|
402
|
+
SwapCommand2.RequestSchema = z.object({
|
|
403
|
+
side: SwapSideSchema,
|
|
404
|
+
amount: PositiveMoneyStringSchema,
|
|
405
|
+
maxPrice: PositiveMoneyStringSchema.optional(),
|
|
406
|
+
idempotencyKey: z.string().min(8).max(128)
|
|
407
|
+
});
|
|
408
|
+
SwapCommand2.ResponseSchema = TradeResultSchema;
|
|
409
|
+
})(SwapCommand || (SwapCommand = {}));
|
|
410
|
+
|
|
411
|
+
// src/commands/partners/get-partners.command.ts
|
|
412
|
+
var GetPartnersCommand;
|
|
413
|
+
((GetPartnersCommand2) => {
|
|
414
|
+
GetPartnersCommand2.endpointDetails = endpoint("GET", "/partners", "Affiliate network overview with 10 levels");
|
|
415
|
+
GetPartnersCommand2.ResponseSchema = PartnersOverviewSchema;
|
|
416
|
+
})(GetPartnersCommand || (GetPartnersCommand = {}));
|
|
417
|
+
var GetRanksCommand;
|
|
418
|
+
((GetRanksCommand2) => {
|
|
419
|
+
GetRanksCommand2.endpointDetails = endpoint("GET", "/ranks", "List all rank tiers");
|
|
420
|
+
GetRanksCommand2.ResponseSchema = z.object({
|
|
421
|
+
ranks: z.array(RankDefSchema)
|
|
422
|
+
});
|
|
423
|
+
})(GetRanksCommand || (GetRanksCommand = {}));
|
|
424
|
+
|
|
425
|
+
// src/commands/earnings/get-earnings.command.ts
|
|
426
|
+
var GetEarningsCommand;
|
|
427
|
+
((GetEarningsCommand2) => {
|
|
428
|
+
GetEarningsCommand2.endpointDetails = endpoint("GET", "/earnings", "Earnings overview: token growth + affiliate + rank");
|
|
429
|
+
GetEarningsCommand2.ResponseSchema = EarningsOverviewSchema;
|
|
430
|
+
})(GetEarningsCommand || (GetEarningsCommand = {}));
|
|
431
|
+
var RequestWithdrawalCommand;
|
|
432
|
+
((RequestWithdrawalCommand2) => {
|
|
433
|
+
RequestWithdrawalCommand2.endpointDetails = endpoint("POST", "/withdrawals", "Request a withdrawal to an external address");
|
|
434
|
+
RequestWithdrawalCommand2.RequestSchema = z.object({
|
|
435
|
+
asset: DepositableAssetSchema,
|
|
436
|
+
amount: PositiveMoneyStringSchema,
|
|
437
|
+
address: z.string().min(8).max(256),
|
|
438
|
+
totp: z.string().regex(/^\d{6}$/).optional(),
|
|
439
|
+
idempotencyKey: z.string().min(8).max(128)
|
|
440
|
+
});
|
|
441
|
+
RequestWithdrawalCommand2.ResponseSchema = z.object({
|
|
442
|
+
withdrawalId: z.string().uuid(),
|
|
443
|
+
status: WithdrawalStatusSchema
|
|
444
|
+
});
|
|
445
|
+
})(RequestWithdrawalCommand || (RequestWithdrawalCommand = {}));
|
|
446
|
+
var ListWithdrawalsCommand;
|
|
447
|
+
((ListWithdrawalsCommand2) => {
|
|
448
|
+
ListWithdrawalsCommand2.endpointDetails = endpoint("GET", "/withdrawals", "List the user withdrawals");
|
|
449
|
+
ListWithdrawalsCommand2.ResponseSchema = z.object({
|
|
450
|
+
items: z.array(WithdrawalSchema)
|
|
451
|
+
});
|
|
452
|
+
})(ListWithdrawalsCommand || (ListWithdrawalsCommand = {}));
|
|
453
|
+
var CancelWithdrawalCommand;
|
|
454
|
+
((CancelWithdrawalCommand2) => {
|
|
455
|
+
CancelWithdrawalCommand2.endpointDetails = endpoint("POST", "/withdrawals/:id/cancel", "Cancel a pending withdrawal");
|
|
456
|
+
CancelWithdrawalCommand2.ResponseSchema = z.object({
|
|
457
|
+
status: WithdrawalStatusSchema
|
|
458
|
+
});
|
|
459
|
+
})(CancelWithdrawalCommand || (CancelWithdrawalCommand = {}));
|
|
460
|
+
var ConfirmWithdrawalCommand;
|
|
461
|
+
((ConfirmWithdrawalCommand2) => {
|
|
462
|
+
ConfirmWithdrawalCommand2.endpointDetails = endpoint("POST", "/withdrawals/:id/confirm", "Confirm a withdrawal with the email token");
|
|
463
|
+
ConfirmWithdrawalCommand2.RequestSchema = z.object({
|
|
464
|
+
token: z.string().min(6).max(128)
|
|
465
|
+
});
|
|
466
|
+
ConfirmWithdrawalCommand2.ResponseSchema = z.object({
|
|
467
|
+
status: WithdrawalStatusSchema
|
|
468
|
+
});
|
|
469
|
+
})(ConfirmWithdrawalCommand || (ConfirmWithdrawalCommand = {}));
|
|
470
|
+
var AVATAR_CONTENT_TYPES = ["image/png", "image/jpeg", "image/webp", "image/gif"];
|
|
471
|
+
var AvatarContentTypeSchema = z.enum(AVATAR_CONTENT_TYPES);
|
|
472
|
+
var RequestEmailChangeCommand;
|
|
473
|
+
((RequestEmailChangeCommand2) => {
|
|
474
|
+
RequestEmailChangeCommand2.endpointDetails = endpoint("POST", "/settings/email/request", "Start an email change (sends a code)");
|
|
475
|
+
RequestEmailChangeCommand2.RequestSchema = z.object({
|
|
476
|
+
newEmail: z.string().email().max(254)
|
|
477
|
+
});
|
|
478
|
+
RequestEmailChangeCommand2.ResponseSchema = z.object({ sent: z.boolean() });
|
|
479
|
+
})(RequestEmailChangeCommand || (RequestEmailChangeCommand = {}));
|
|
480
|
+
var ConfirmEmailChangeCommand;
|
|
481
|
+
((ConfirmEmailChangeCommand2) => {
|
|
482
|
+
ConfirmEmailChangeCommand2.endpointDetails = endpoint("POST", "/settings/email/confirm", "Confirm an email change with the code");
|
|
483
|
+
ConfirmEmailChangeCommand2.RequestSchema = z.object({
|
|
484
|
+
code: z.string().regex(/^\d{6}$/)
|
|
485
|
+
});
|
|
486
|
+
ConfirmEmailChangeCommand2.ResponseSchema = z.object({ email: z.string().email() });
|
|
487
|
+
})(ConfirmEmailChangeCommand || (ConfirmEmailChangeCommand = {}));
|
|
488
|
+
var DisableTotpCommand;
|
|
489
|
+
((DisableTotpCommand2) => {
|
|
490
|
+
DisableTotpCommand2.endpointDetails = endpoint("POST", "/auth/totp/disable", "Disable TOTP two-factor auth");
|
|
491
|
+
DisableTotpCommand2.RequestSchema = z.object({
|
|
492
|
+
totp: z.string().regex(/^\d{6}$/)
|
|
493
|
+
});
|
|
494
|
+
DisableTotpCommand2.ResponseSchema = z.void();
|
|
495
|
+
})(DisableTotpCommand || (DisableTotpCommand = {}));
|
|
496
|
+
var UpdateProfileCommand;
|
|
497
|
+
((UpdateProfileCommand2) => {
|
|
498
|
+
UpdateProfileCommand2.endpointDetails = endpoint("PATCH", "/settings/profile", "Update display name and avatar");
|
|
499
|
+
UpdateProfileCommand2.RequestSchema = z.object({
|
|
500
|
+
displayName: z.string().min(2).max(48).nullable().optional(),
|
|
501
|
+
avatarKey: z.string().max(256).nullable().optional()
|
|
502
|
+
}).refine((v) => v.displayName !== void 0 || v.avatarKey !== void 0, "no fields to update");
|
|
503
|
+
UpdateProfileCommand2.ResponseSchema = UserProfileSchema;
|
|
504
|
+
})(UpdateProfileCommand || (UpdateProfileCommand = {}));
|
|
505
|
+
var AvatarUploadUrlCommand;
|
|
506
|
+
((AvatarUploadUrlCommand2) => {
|
|
507
|
+
AvatarUploadUrlCommand2.endpointDetails = endpoint("POST", "/settings/avatar/upload-url", "Get a presigned avatar upload URL");
|
|
508
|
+
AvatarUploadUrlCommand2.RequestSchema = z.object({
|
|
509
|
+
contentType: AvatarContentTypeSchema
|
|
510
|
+
});
|
|
511
|
+
AvatarUploadUrlCommand2.ResponseSchema = z.object({
|
|
512
|
+
key: z.string(),
|
|
513
|
+
uploadUrl: z.string().url(),
|
|
514
|
+
publicUrl: z.string().url(),
|
|
515
|
+
expiresInSec: z.number().int().positive(),
|
|
516
|
+
maxBytes: z.number().int().positive()
|
|
517
|
+
});
|
|
518
|
+
})(AvatarUploadUrlCommand || (AvatarUploadUrlCommand = {}));
|
|
519
|
+
var GetSettingsCommand;
|
|
520
|
+
((GetSettingsCommand2) => {
|
|
521
|
+
GetSettingsCommand2.endpointDetails = endpoint("GET", "/settings", "Get user preferences");
|
|
522
|
+
GetSettingsCommand2.ResponseSchema = UserSettingsSchema;
|
|
523
|
+
})(GetSettingsCommand || (GetSettingsCommand = {}));
|
|
524
|
+
var UpdateSettingsCommand;
|
|
525
|
+
((UpdateSettingsCommand2) => {
|
|
526
|
+
UpdateSettingsCommand2.endpointDetails = endpoint("PATCH", "/settings", "Update user preferences");
|
|
527
|
+
UpdateSettingsCommand2.RequestSchema = z.object({
|
|
528
|
+
notifyTrades: z.boolean().optional(),
|
|
529
|
+
notifyByEmail: z.boolean().optional(),
|
|
530
|
+
withdrawalEmailConfirm: z.boolean().optional()
|
|
531
|
+
}).refine((v) => Object.keys(v).length > 0, "no fields to update");
|
|
532
|
+
UpdateSettingsCommand2.ResponseSchema = UserSettingsSchema;
|
|
533
|
+
})(UpdateSettingsCommand || (UpdateSettingsCommand = {}));
|
|
534
|
+
|
|
535
|
+
// src/commands/bonus/bonus.command.ts
|
|
536
|
+
var GetDailyBonusCommand;
|
|
537
|
+
((GetDailyBonusCommand2) => {
|
|
538
|
+
GetDailyBonusCommand2.endpointDetails = endpoint("GET", "/bonus/daily", "Daily bonus status and current streak");
|
|
539
|
+
GetDailyBonusCommand2.ResponseSchema = DailyBonusStatusSchema;
|
|
540
|
+
})(GetDailyBonusCommand || (GetDailyBonusCommand = {}));
|
|
541
|
+
var ClaimDailyBonusCommand;
|
|
542
|
+
((ClaimDailyBonusCommand2) => {
|
|
543
|
+
ClaimDailyBonusCommand2.endpointDetails = endpoint("POST", "/bonus/daily/claim", "Claim today's daily bonus");
|
|
544
|
+
ClaimDailyBonusCommand2.ResponseSchema = DailyBonusClaimResultSchema;
|
|
545
|
+
})(ClaimDailyBonusCommand || (ClaimDailyBonusCommand = {}));
|
|
546
|
+
var GetLeaderboardCommand;
|
|
547
|
+
((GetLeaderboardCommand2) => {
|
|
548
|
+
GetLeaderboardCommand2.endpointDetails = endpoint("GET", "/leaderboard", "Top partners ranked by network turnover");
|
|
549
|
+
GetLeaderboardCommand2.QuerySchema = z.object({
|
|
550
|
+
period: LeaderboardPeriodSchema.default("month"),
|
|
551
|
+
limit: z.coerce.number().int().min(1).max(100).default(20)
|
|
552
|
+
});
|
|
553
|
+
GetLeaderboardCommand2.ResponseSchema = LeaderboardSchema;
|
|
554
|
+
})(GetLeaderboardCommand || (GetLeaderboardCommand = {}));
|
|
555
|
+
var GetIncomeCommand;
|
|
556
|
+
((GetIncomeCommand2) => {
|
|
557
|
+
GetIncomeCommand2.endpointDetails = endpoint("GET", "/income", "Income overview: token growth + affiliate earnings");
|
|
558
|
+
GetIncomeCommand2.QuerySchema = z.object({
|
|
559
|
+
period: IncomePeriodSchema.default("month")
|
|
560
|
+
});
|
|
561
|
+
GetIncomeCommand2.ResponseSchema = IncomeOverviewSchema;
|
|
562
|
+
})(GetIncomeCommand || (GetIncomeCommand = {}));
|
|
563
|
+
var ListNotificationsCommand;
|
|
564
|
+
((ListNotificationsCommand2) => {
|
|
565
|
+
ListNotificationsCommand2.endpointDetails = endpoint("GET", "/notifications", "List in-app notifications");
|
|
566
|
+
ListNotificationsCommand2.QuerySchema = PaginationQuerySchema.extend({
|
|
567
|
+
unreadOnly: z.union([z.boolean(), z.string()]).optional().transform((v) => v === true || v === "true" || v === "1")
|
|
568
|
+
});
|
|
569
|
+
ListNotificationsCommand2.ResponseSchema = PaginatedSchema(NotificationSchema).extend({
|
|
570
|
+
unread: z.number().int().nonnegative()
|
|
571
|
+
});
|
|
572
|
+
})(ListNotificationsCommand || (ListNotificationsCommand = {}));
|
|
573
|
+
var MarkNotificationsReadCommand;
|
|
574
|
+
((MarkNotificationsReadCommand2) => {
|
|
575
|
+
MarkNotificationsReadCommand2.endpointDetails = endpoint("POST", "/notifications/read", "Mark notifications as read");
|
|
576
|
+
MarkNotificationsReadCommand2.RequestSchema = z.object({
|
|
577
|
+
ids: z.array(z.string().uuid()).max(500).optional(),
|
|
578
|
+
all: z.boolean().optional()
|
|
579
|
+
});
|
|
580
|
+
MarkNotificationsReadCommand2.ResponseSchema = z.object({ updated: z.number().int().nonnegative() });
|
|
581
|
+
})(MarkNotificationsReadCommand || (MarkNotificationsReadCommand = {}));
|
|
582
|
+
var ListLinkedAccountsCommand;
|
|
583
|
+
((ListLinkedAccountsCommand2) => {
|
|
584
|
+
ListLinkedAccountsCommand2.endpointDetails = endpoint("GET", "/settings/links", "List linked external accounts");
|
|
585
|
+
ListLinkedAccountsCommand2.ResponseSchema = z.object({ items: z.array(LinkedAccountSchema) });
|
|
586
|
+
})(ListLinkedAccountsCommand || (ListLinkedAccountsCommand = {}));
|
|
587
|
+
var LinkTelegramCommand;
|
|
588
|
+
((LinkTelegramCommand2) => {
|
|
589
|
+
LinkTelegramCommand2.endpointDetails = endpoint("POST", "/settings/link/telegram", "Link a Telegram account (login widget)");
|
|
590
|
+
LinkTelegramCommand2.RequestSchema = z.object({
|
|
591
|
+
id: z.union([z.number(), z.string()]),
|
|
592
|
+
auth_date: z.union([z.number(), z.string()]),
|
|
593
|
+
hash: z.string(),
|
|
594
|
+
first_name: z.string().optional(),
|
|
595
|
+
last_name: z.string().optional(),
|
|
596
|
+
username: z.string().optional(),
|
|
597
|
+
photo_url: z.string().optional()
|
|
598
|
+
});
|
|
599
|
+
LinkTelegramCommand2.ResponseSchema = LinkedAccountSchema;
|
|
600
|
+
})(LinkTelegramCommand || (LinkTelegramCommand = {}));
|
|
601
|
+
var LinkGoogleCommand;
|
|
602
|
+
((LinkGoogleCommand2) => {
|
|
603
|
+
LinkGoogleCommand2.endpointDetails = endpoint("POST", "/settings/link/google", "Link a Google account (ID token)");
|
|
604
|
+
LinkGoogleCommand2.RequestSchema = z.object({ idToken: z.string().min(10) });
|
|
605
|
+
LinkGoogleCommand2.ResponseSchema = LinkedAccountSchema;
|
|
606
|
+
})(LinkGoogleCommand || (LinkGoogleCommand = {}));
|
|
607
|
+
var UnlinkAccountCommand;
|
|
608
|
+
((UnlinkAccountCommand2) => {
|
|
609
|
+
UnlinkAccountCommand2.endpointDetails = endpoint("DELETE", "/settings/link/:provider", "Unlink an external account");
|
|
610
|
+
UnlinkAccountCommand2.ParamsSchema = z.object({ provider: LinkProviderSchema });
|
|
611
|
+
UnlinkAccountCommand2.ResponseSchema = z.void();
|
|
612
|
+
})(UnlinkAccountCommand || (UnlinkAccountCommand = {}));
|
|
613
|
+
|
|
614
|
+
// src/api/routes.ts
|
|
615
|
+
var REST_API = {
|
|
616
|
+
AUTH: {
|
|
617
|
+
REGISTER: "/auth/register",
|
|
618
|
+
LOGIN: "/auth/login",
|
|
619
|
+
LOGOUT: "/auth/logout",
|
|
620
|
+
ME: "/auth/me",
|
|
621
|
+
TOTP_SETUP: "/auth/totp/setup",
|
|
622
|
+
TOTP_CONFIRM: "/auth/totp/confirm"
|
|
623
|
+
},
|
|
624
|
+
WALLET: {
|
|
625
|
+
OVERVIEW: "/wallet",
|
|
626
|
+
TRANSACTIONS: "/wallet/transactions",
|
|
627
|
+
DEPOSIT_ADDRESS: "/wallet/deposit-address"
|
|
628
|
+
},
|
|
629
|
+
TOKEN: {
|
|
630
|
+
PRICE: "/token/price",
|
|
631
|
+
CHART: "/token/chart"
|
|
632
|
+
},
|
|
633
|
+
SWAP: {
|
|
634
|
+
EXECUTE: "/swap"
|
|
635
|
+
},
|
|
636
|
+
PARTNERS: {
|
|
637
|
+
OVERVIEW: "/partners"
|
|
638
|
+
},
|
|
639
|
+
RANKS: {
|
|
640
|
+
LIST: "/ranks"
|
|
641
|
+
},
|
|
642
|
+
EARNINGS: {
|
|
643
|
+
OVERVIEW: "/earnings"
|
|
644
|
+
},
|
|
645
|
+
WITHDRAWALS: {
|
|
646
|
+
REQUEST: "/withdrawals",
|
|
647
|
+
LIST: "/withdrawals",
|
|
648
|
+
CANCEL: "/withdrawals/:id/cancel",
|
|
649
|
+
CONFIRM: "/withdrawals/:id/confirm"
|
|
650
|
+
},
|
|
651
|
+
SETTINGS: {
|
|
652
|
+
EMAIL_REQUEST: "/settings/email/request",
|
|
653
|
+
EMAIL_CONFIRM: "/settings/email/confirm",
|
|
654
|
+
TOTP_DISABLE: "/auth/totp/disable",
|
|
655
|
+
PROFILE: "/settings/profile",
|
|
656
|
+
AVATAR_UPLOAD_URL: "/settings/avatar/upload-url",
|
|
657
|
+
PREFERENCES: "/settings",
|
|
658
|
+
LINKS: "/settings/links",
|
|
659
|
+
LINK_TELEGRAM: "/settings/link/telegram",
|
|
660
|
+
LINK_GOOGLE: "/settings/link/google",
|
|
661
|
+
UNLINK: "/settings/link/:provider"
|
|
662
|
+
},
|
|
663
|
+
BONUS: {
|
|
664
|
+
DAILY: "/bonus/daily",
|
|
665
|
+
DAILY_CLAIM: "/bonus/daily/claim"
|
|
666
|
+
},
|
|
667
|
+
LEADERBOARD: {
|
|
668
|
+
OVERVIEW: "/leaderboard"
|
|
669
|
+
},
|
|
670
|
+
INCOME: {
|
|
671
|
+
OVERVIEW: "/income"
|
|
672
|
+
},
|
|
673
|
+
NOTIFICATIONS: {
|
|
674
|
+
LIST: "/notifications",
|
|
675
|
+
READ: "/notifications/read"
|
|
676
|
+
}
|
|
677
|
+
};
|
|
678
|
+
var API_PREFIX = "/api";
|
|
679
|
+
var API_VERSION = "v1";
|
|
680
|
+
|
|
681
|
+
export { API_PREFIX, API_VERSION, ASSET_SYMBOLS, AVATAR_CONTENT_TYPES, AssetBalanceSchema, AssetSymbolSchema, AvatarContentTypeSchema, AvatarUploadUrlCommand, CancelWithdrawalCommand, ChartPeriodSchema, ChartPointSchema, ClaimDailyBonusCommand, ConfirmEmailChangeCommand, ConfirmTotpCommand, ConfirmWithdrawalCommand, DEPOSITABLE_ASSETS, DailyBonusClaimResultSchema, DailyBonusDaySchema, DailyBonusStatusSchema, DepositAddressCommand, DepositAddressSchema, DepositableAssetSchema, DisableTotpCommand, ERROR_CODE, EarningsOverviewSchema, ErrorResponseSchema, FUNDING_ASSET, GetDailyBonusCommand, GetEarningsCommand, GetIncomeCommand, GetLeaderboardCommand, GetPartnersCommand, GetRanksCommand, GetSettingsCommand, GetTokenChartCommand, GetTokenPriceCommand, GetTransactionsCommand, GetWalletCommand, IncomeOverviewSchema, IncomePeriodSchema, LeaderboardEntrySchema, LeaderboardPeriodSchema, LeaderboardSchema, LinkGoogleCommand, LinkProviderSchema, LinkTelegramCommand, LinkedAccountSchema, ListLinkedAccountsCommand, ListNotificationsCommand, ListWithdrawalsCommand, LoginCommand, LogoutCommand, MONEY_REGEX, MarkNotificationsReadCommand, MeCommand, MoneyStringSchema, MonthlyPricePointSchema, NotificationSchema, NotificationTypeSchema, PaginatedSchema, PaginationQuerySchema, PartnerAccrualSchema, PartnerLevelSchema, PartnersOverviewSchema, PositiveMoneyStringSchema, REST_API, RankDefSchema, RegisterCommand, RequestEmailChangeCommand, RequestWithdrawalCommand, SessionInfoSchema, SetupTotpCommand, SwapCommand, SwapSideSchema, TOKEN_ASSET, TokenPriceSchema, TradeResultSchema, TransactionSchema, TransactionStatusSchema, TransactionTypeSchema, UnlinkAccountCommand, UpdateProfileCommand, UpdateSettingsCommand, UserProfileSchema, UserRankSchema, UserSettingsSchema, UserStatusSchema, UuidSchema, WalletOverviewSchema, WithdrawalSchema, WithdrawalStatusSchema, endpoint };
|
|
682
|
+
//# sourceMappingURL=index.js.map
|
|
683
|
+
//# sourceMappingURL=index.js.map
|