After changing about commission dispatch and adding sharing card
This commit is contained in:
parent
380bbc8777
commit
2f982ce3d0
67
backend/src/controllers/shareCardController.ts
Normal file
67
backend/src/controllers/shareCardController.ts
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
import { Response } from 'express';
|
||||||
|
import { AuthRequest } from '../middleware/auth';
|
||||||
|
import * as shareCardService from '../services/shareCardService';
|
||||||
|
|
||||||
|
function sendError(res: Response, e: unknown, fallback: string): void {
|
||||||
|
if (e instanceof shareCardService.ShareCardError) {
|
||||||
|
res.status(e.status).json({ error: e.message });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
res.status(500).json({ error: e instanceof Error ? e.message : fallback });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getConfig(req: AuthRequest, res: Response): Promise<void> {
|
||||||
|
try {
|
||||||
|
const config = await shareCardService.getConfigForUser();
|
||||||
|
res.json(config);
|
||||||
|
} catch (e) {
|
||||||
|
sendError(res, e, 'Failed');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getBetShareCard(req: AuthRequest, res: Response): Promise<void> {
|
||||||
|
try {
|
||||||
|
const betId = String(req.params.betId || '');
|
||||||
|
const payload = await shareCardService.getSharePayloadForOwner(req.user!.userId, betId);
|
||||||
|
res.json(payload);
|
||||||
|
} catch (e) {
|
||||||
|
sendError(res, e, 'Failed');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function verifyShareCard(req: AuthRequest, res: Response): Promise<void> {
|
||||||
|
try {
|
||||||
|
const token = String(req.params.token || '');
|
||||||
|
const payload = await shareCardService.getPublicVerifyPayload(token);
|
||||||
|
res.json(payload);
|
||||||
|
} catch (e) {
|
||||||
|
sendError(res, e, 'Failed');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getAdminSettings(_req: AuthRequest, res: Response): Promise<void> {
|
||||||
|
try {
|
||||||
|
const settings = await shareCardService.getSettingsForAdmin();
|
||||||
|
res.json(settings);
|
||||||
|
} catch (e) {
|
||||||
|
sendError(res, e, 'Failed');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateAdminSettings(req: AuthRequest, res: Response): Promise<void> {
|
||||||
|
try {
|
||||||
|
const body = req.body as {
|
||||||
|
enabled?: boolean;
|
||||||
|
allowMainWallet?: boolean;
|
||||||
|
allowBonusWallet?: boolean;
|
||||||
|
allowTestWallet?: boolean;
|
||||||
|
allowWon?: boolean;
|
||||||
|
allowLost?: boolean;
|
||||||
|
allowRefunded?: boolean;
|
||||||
|
};
|
||||||
|
const settings = await shareCardService.updateSettings(body);
|
||||||
|
res.json(settings);
|
||||||
|
} catch (e) {
|
||||||
|
sendError(res, e, 'Update failed');
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2112,6 +2112,7 @@ BEGIN
|
|||||||
WHEN 'candle_predict_rounds' THEN 'high'
|
WHEN 'candle_predict_rounds' THEN 'high'
|
||||||
WHEN 'test_wallet_credits' THEN 'high'
|
WHEN 'test_wallet_credits' THEN 'high'
|
||||||
WHEN 'test_wallet_settings' THEN 'high'
|
WHEN 'test_wallet_settings' THEN 'high'
|
||||||
|
WHEN 'share_card_settings' THEN 'medium'
|
||||||
WHEN 'referral_program_settings' THEN 'high'
|
WHEN 'referral_program_settings' THEN 'high'
|
||||||
WHEN 'platform_bonus_pools' THEN 'high'
|
WHEN 'platform_bonus_pools' THEN 'high'
|
||||||
WHEN 'exchange_funding' THEN 'high'
|
WHEN 'exchange_funding' THEN 'high'
|
||||||
@ -2299,7 +2300,7 @@ BEGIN
|
|||||||
'hot_wallets', 'cold_wallets', 'ledger_adjustments',
|
'hot_wallets', 'cold_wallets', 'ledger_adjustments',
|
||||||
'candle_predict_config', 'candle_predict_intervals', 'candle_predict_multi_levels',
|
'candle_predict_config', 'candle_predict_intervals', 'candle_predict_multi_levels',
|
||||||
'candle_predict_bets', 'candle_predict_rounds', 'candle_predict_daily_revenue',
|
'candle_predict_bets', 'candle_predict_rounds', 'candle_predict_daily_revenue',
|
||||||
'test_wallet_credits', 'test_wallet_settings',
|
'test_wallet_credits', 'test_wallet_settings', 'share_card_settings',
|
||||||
'referral_program_settings', 'platform_bonus_pools', 'exchange_funding',
|
'referral_program_settings', 'platform_bonus_pools', 'exchange_funding',
|
||||||
'system_settings', 'withdrawal_locks', 'deposit_scanner_state',
|
'system_settings', 'withdrawal_locks', 'deposit_scanner_state',
|
||||||
'security_alerts', 'refresh_tokens',
|
'security_alerts', 'refresh_tokens',
|
||||||
@ -2454,3 +2455,20 @@ CREATE INDEX IF NOT EXISTS idx_referral_payouts_prediction_bet
|
|||||||
ON referral_commission_payouts (candle_predict_bet_id)
|
ON referral_commission_payouts (candle_predict_bet_id)
|
||||||
WHERE candle_predict_bet_id IS NOT NULL;
|
WHERE candle_predict_bet_id IS NOT NULL;
|
||||||
|
|
||||||
|
-- Share Cards: prediction result sharing (admin-configurable)
|
||||||
|
CREATE TABLE IF NOT EXISTS share_card_settings (
|
||||||
|
id INTEGER PRIMARY KEY DEFAULT 1 CHECK (id = 1),
|
||||||
|
enabled BOOLEAN NOT NULL DEFAULT TRUE,
|
||||||
|
allow_main_wallet BOOLEAN NOT NULL DEFAULT TRUE,
|
||||||
|
allow_bonus_wallet BOOLEAN NOT NULL DEFAULT TRUE,
|
||||||
|
allow_test_wallet BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
allow_won BOOLEAN NOT NULL DEFAULT TRUE,
|
||||||
|
allow_lost BOOLEAN NOT NULL DEFAULT TRUE,
|
||||||
|
allow_refunded BOOLEAN NOT NULL DEFAULT TRUE,
|
||||||
|
updated_at TIMESTAMPTZ DEFAULT NOW()
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO share_card_settings (id)
|
||||||
|
VALUES (1)
|
||||||
|
ON CONFLICT (id) DO NOTHING;
|
||||||
|
|
||||||
|
|||||||
@ -1686,6 +1686,7 @@ async function payOutBetsAtMaturity(
|
|||||||
stake_account_kind: parseStakeAccountKind(bet.stake_account_kind),
|
stake_account_kind: parseStakeAccountKind(bet.stake_account_kind),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
queuePredictionReferralCommission(bet, 'won');
|
||||||
} else {
|
} else {
|
||||||
await repo.updateBetOutcome(bet.id, 'lost', 0n);
|
await repo.updateBetOutcome(bet.id, 'lost', 0n);
|
||||||
if (countInDaily) housePnlRaw += stakeRaw;
|
if (countInDaily) housePnlRaw += stakeRaw;
|
||||||
@ -1701,6 +1702,7 @@ async function payOutBetsAtMaturity(
|
|||||||
predictionMode: bet.prediction_mode ?? 'single',
|
predictionMode: bet.prediction_mode ?? 'single',
|
||||||
intervalMinutes: bet.interval_minutes,
|
intervalMinutes: bet.interval_minutes,
|
||||||
});
|
});
|
||||||
|
queuePredictionReferralCommission(bet, 'lost');
|
||||||
}
|
}
|
||||||
queueUserAdminStatsRefresh(bet.user_id);
|
queueUserAdminStatsRefresh(bet.user_id);
|
||||||
}
|
}
|
||||||
@ -1854,6 +1856,27 @@ function parseStakeAccountKind(value: unknown): AccountKind {
|
|||||||
return 'main';
|
return 'main';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Referral prediction commissions only on terminal win/loss — never on neutral refund. */
|
||||||
|
function queuePredictionReferralCommission(
|
||||||
|
bet: {
|
||||||
|
id: string;
|
||||||
|
user_id: string;
|
||||||
|
stake_raw: string | number | bigint;
|
||||||
|
stake_account_kind?: string | null;
|
||||||
|
wallet_type_id: number;
|
||||||
|
},
|
||||||
|
betOutcome: 'won' | 'lost'
|
||||||
|
): void {
|
||||||
|
void processPredictionReferralCommissions({
|
||||||
|
betId: bet.id,
|
||||||
|
referredUserId: bet.user_id,
|
||||||
|
stakeRaw: BigInt(bet.stake_raw),
|
||||||
|
stakeAccountKind: parseStakeAccountKind(bet.stake_account_kind),
|
||||||
|
walletTypeId: bet.wallet_type_id,
|
||||||
|
betOutcome,
|
||||||
|
}).catch((e) => console.error('[referral] prediction commission failed:', e));
|
||||||
|
}
|
||||||
|
|
||||||
async function resolveDebitAccount(
|
async function resolveDebitAccount(
|
||||||
userId: string,
|
userId: string,
|
||||||
walletTypeId: number,
|
walletTypeId: number,
|
||||||
@ -2003,14 +2026,6 @@ export async function executePlaceBetInternal(
|
|||||||
|
|
||||||
queueUserAdminStatsRefresh(userId);
|
queueUserAdminStatsRefresh(userId);
|
||||||
|
|
||||||
void processPredictionReferralCommissions({
|
|
||||||
betId: bet.id,
|
|
||||||
referredUserId: userId,
|
|
||||||
stakeRaw,
|
|
||||||
stakeAccountKind,
|
|
||||||
walletTypeId: walletType.id,
|
|
||||||
}).catch((e) => console.error('[referral] prediction commission failed:', e));
|
|
||||||
|
|
||||||
const mapped = mapBet(bet);
|
const mapped = mapBet(bet);
|
||||||
if (config.redis.enabled) {
|
if (config.redis.enabled) {
|
||||||
const betVersion = await bumpUserBetVersionSafe(userId, interval.intervalMinutes);
|
const betVersion = await bumpUserBetVersionSafe(userId, interval.intervalMinutes);
|
||||||
@ -2426,14 +2441,6 @@ export async function placeMultiCandleBet(
|
|||||||
|
|
||||||
queueUserAdminStatsRefresh(userId);
|
queueUserAdminStatsRefresh(userId);
|
||||||
|
|
||||||
void processPredictionReferralCommissions({
|
|
||||||
betId: bet.id,
|
|
||||||
referredUserId: userId,
|
|
||||||
stakeRaw,
|
|
||||||
stakeAccountKind,
|
|
||||||
walletTypeId: walletType.id,
|
|
||||||
}).catch((e) => console.error('[referral] prediction commission failed:', e));
|
|
||||||
|
|
||||||
if (config.redis.enabled) {
|
if (config.redis.enabled) {
|
||||||
const betVersion = await bumpUserBetVersionSafe(userId, interval.intervalMinutes);
|
const betVersion = await bumpUserBetVersionSafe(userId, interval.intervalMinutes);
|
||||||
await publishRoundSnapshot(interval.intervalMinutes, timing.openMs);
|
await publishRoundSnapshot(interval.intervalMinutes, timing.openMs);
|
||||||
|
|||||||
@ -604,6 +604,21 @@ export async function getUserBetForRound(
|
|||||||
return rows[0] ?? null;
|
return rows[0] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type CandlePredictBetWithSettlement = CandlePredictBetRow & {
|
||||||
|
settled_at: Date | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export async function getBetById(betId: string): Promise<CandlePredictBetWithSettlement | null> {
|
||||||
|
const rows = await query<CandlePredictBetWithSettlement[]>(
|
||||||
|
`SELECT b.*, r.settled_at
|
||||||
|
FROM candle_predict_bets b
|
||||||
|
LEFT JOIN candle_predict_rounds r ON r.id = b.round_id
|
||||||
|
WHERE b.id = $1`,
|
||||||
|
[betId]
|
||||||
|
);
|
||||||
|
return rows[0] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
export async function listPendingBetsForRound(roundId: string): Promise<CandlePredictBetRow[]> {
|
export async function listPendingBetsForRound(roundId: string): Promise<CandlePredictBetRow[]> {
|
||||||
return query<CandlePredictBetRow[]>(
|
return query<CandlePredictBetRow[]>(
|
||||||
"SELECT * FROM candle_predict_bets WHERE round_id = $1 AND status = 'pending'",
|
"SELECT * FROM candle_predict_bets WHERE round_id = $1 AND status = 'pending'",
|
||||||
|
|||||||
65
backend/src/repositories/shareCardRepository.ts
Normal file
65
backend/src/repositories/shareCardRepository.ts
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/**
|
||||||
|
* Share card settings (single-row admin config for prediction result sharing).
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { query } from '../db/connection';
|
||||||
|
|
||||||
|
export type ShareCardSettingsRow = {
|
||||||
|
id: number;
|
||||||
|
enabled: boolean;
|
||||||
|
allow_main_wallet: boolean;
|
||||||
|
allow_bonus_wallet: boolean;
|
||||||
|
allow_test_wallet: boolean;
|
||||||
|
allow_won: boolean;
|
||||||
|
allow_lost: boolean;
|
||||||
|
allow_refunded: boolean;
|
||||||
|
updated_at: Date;
|
||||||
|
};
|
||||||
|
|
||||||
|
const SELECT_COLS = `id, enabled, allow_main_wallet, allow_bonus_wallet, allow_test_wallet,
|
||||||
|
allow_won, allow_lost, allow_refunded, updated_at`;
|
||||||
|
|
||||||
|
export async function getSettings(): Promise<ShareCardSettingsRow> {
|
||||||
|
const rows = await query<ShareCardSettingsRow[]>(
|
||||||
|
`SELECT ${SELECT_COLS} FROM share_card_settings WHERE id = 1`
|
||||||
|
);
|
||||||
|
if (!rows[0]) {
|
||||||
|
throw new Error('Share card settings are not configured');
|
||||||
|
}
|
||||||
|
return rows[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateSettings(input: {
|
||||||
|
enabled?: boolean;
|
||||||
|
allowMainWallet?: boolean;
|
||||||
|
allowBonusWallet?: boolean;
|
||||||
|
allowTestWallet?: boolean;
|
||||||
|
allowWon?: boolean;
|
||||||
|
allowLost?: boolean;
|
||||||
|
allowRefunded?: boolean;
|
||||||
|
}): Promise<ShareCardSettingsRow> {
|
||||||
|
const current = await getSettings();
|
||||||
|
const rows = await query<ShareCardSettingsRow[]>(
|
||||||
|
`UPDATE share_card_settings SET
|
||||||
|
enabled = COALESCE($1, enabled),
|
||||||
|
allow_main_wallet = COALESCE($2, allow_main_wallet),
|
||||||
|
allow_bonus_wallet = COALESCE($3, allow_bonus_wallet),
|
||||||
|
allow_test_wallet = COALESCE($4, allow_test_wallet),
|
||||||
|
allow_won = COALESCE($5, allow_won),
|
||||||
|
allow_lost = COALESCE($6, allow_lost),
|
||||||
|
allow_refunded = COALESCE($7, allow_refunded),
|
||||||
|
updated_at = NOW()
|
||||||
|
WHERE id = 1
|
||||||
|
RETURNING ${SELECT_COLS}`,
|
||||||
|
[
|
||||||
|
input.enabled ?? null,
|
||||||
|
input.allowMainWallet ?? null,
|
||||||
|
input.allowBonusWallet ?? null,
|
||||||
|
input.allowTestWallet ?? null,
|
||||||
|
input.allowWon ?? null,
|
||||||
|
input.allowLost ?? null,
|
||||||
|
input.allowRefunded ?? null,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
return rows[0] ?? current;
|
||||||
|
}
|
||||||
@ -72,6 +72,7 @@ import {
|
|||||||
advertisementCreateBodySchema,
|
advertisementCreateBodySchema,
|
||||||
advertisementUpdateBodySchema,
|
advertisementUpdateBodySchema,
|
||||||
testWalletConfigBodySchema,
|
testWalletConfigBodySchema,
|
||||||
|
shareCardSettingsBodySchema,
|
||||||
supportConversationUpdateBodySchema,
|
supportConversationUpdateBodySchema,
|
||||||
faqCategoryCreateBodySchema,
|
faqCategoryCreateBodySchema,
|
||||||
faqCategoryUpdateBodySchema,
|
faqCategoryUpdateBodySchema,
|
||||||
@ -109,6 +110,7 @@ import * as notificationController from '../controllers/notificationController';
|
|||||||
import * as referralController from '../controllers/referralController';
|
import * as referralController from '../controllers/referralController';
|
||||||
import * as adminCreditController from '../controllers/adminCreditController';
|
import * as adminCreditController from '../controllers/adminCreditController';
|
||||||
import * as testWalletController from '../controllers/testWalletController';
|
import * as testWalletController from '../controllers/testWalletController';
|
||||||
|
import * as shareCardController from '../controllers/shareCardController';
|
||||||
import * as countryController from '../controllers/countryController';
|
import * as countryController from '../controllers/countryController';
|
||||||
import * as presenceController from '../controllers/presenceController';
|
import * as presenceController from '../controllers/presenceController';
|
||||||
import * as supportController from '../controllers/supportController';
|
import * as supportController from '../controllers/supportController';
|
||||||
@ -161,6 +163,9 @@ router.get('/faq/files/:filename', faqController.getFaqFile);
|
|||||||
router.get('/games', gameController.listGames);
|
router.get('/games', gameController.listGames);
|
||||||
router.get('/advertisements', advertisementController.listAdvertisements);
|
router.get('/advertisements', advertisementController.listAdvertisements);
|
||||||
|
|
||||||
|
/** Public Share Card verification (HMAC token). */
|
||||||
|
router.get('/share-cards/verify/:token', shareCardController.verifyShareCard);
|
||||||
|
|
||||||
/** Support messaging — guests (visitor token) and optional authenticated users. */
|
/** Support messaging — guests (visitor token) and optional authenticated users. */
|
||||||
router.get('/support/files/:filename', supportController.getAttachment);
|
router.get('/support/files/:filename', supportController.getAttachment);
|
||||||
router.post('/support/conversations/current', optionalAuthMiddleware, supportController.getOrCreateConversation);
|
router.post('/support/conversations/current', optionalAuthMiddleware, supportController.getOrCreateConversation);
|
||||||
@ -202,6 +207,8 @@ router.get('/bonus/balances', referralController.getBonusBalances);
|
|||||||
router.post('/bonus/transfer-to-main', validateBody(bonusTransferBodySchema), referralController.transferBonusToMain);
|
router.post('/bonus/transfer-to-main', validateBody(bonusTransferBodySchema), referralController.transferBonusToMain);
|
||||||
router.get('/test-wallet', testWalletController.getTestWalletStatus);
|
router.get('/test-wallet', testWalletController.getTestWalletStatus);
|
||||||
router.post('/test-wallet/request-credits', validateBody(testWalletCreditBodySchema), testWalletController.requestTestCredits);
|
router.post('/test-wallet/request-credits', validateBody(testWalletCreditBodySchema), testWalletController.requestTestCredits);
|
||||||
|
router.get('/share-cards/config', shareCardController.getConfig);
|
||||||
|
router.get('/share-cards/bets/:betId', shareCardController.getBetShareCard);
|
||||||
router.get('/referral/me', referralController.getMyReferralInfo);
|
router.get('/referral/me', referralController.getMyReferralInfo);
|
||||||
router.get('/referral/dashboard', referralController.getMyReferralDashboard);
|
router.get('/referral/dashboard', referralController.getMyReferralDashboard);
|
||||||
router.get('/referral/commissions', referralController.getMyReferralCommissions);
|
router.get('/referral/commissions', referralController.getMyReferralCommissions);
|
||||||
@ -426,6 +433,8 @@ router.post('/admin/referral/pool/fund', requireRoles('admin'), requirePermissio
|
|||||||
router.get('/admin/test-wallet/config', requireRoles('admin'), requirePermissions('settings.admin'), testWalletController.getAdminConfig);
|
router.get('/admin/test-wallet/config', requireRoles('admin'), requirePermissions('settings.admin'), testWalletController.getAdminConfig);
|
||||||
router.patch('/admin/test-wallet/config', requireRoles('admin'), requirePermissions('settings.admin'), validateBody(testWalletConfigBodySchema), testWalletController.updateAdminConfig);
|
router.patch('/admin/test-wallet/config', requireRoles('admin'), requirePermissions('settings.admin'), validateBody(testWalletConfigBodySchema), testWalletController.updateAdminConfig);
|
||||||
router.get('/admin/test-wallet/credits', requireRoles('admin'), requirePermissions('settings.admin'), testWalletController.listAdminCredits);
|
router.get('/admin/test-wallet/credits', requireRoles('admin'), requirePermissions('settings.admin'), testWalletController.listAdminCredits);
|
||||||
|
router.get('/admin/share-cards/settings', requireRoles('admin'), requirePermissions('settings.admin'), shareCardController.getAdminSettings);
|
||||||
|
router.patch('/admin/share-cards/settings', requireRoles('admin'), requirePermissions('settings.admin'), validateBody(shareCardSettingsBodySchema), shareCardController.updateAdminSettings);
|
||||||
|
|
||||||
router.get('/admin/countries', requireRoles('admin'), requirePermissions('settings.admin'), countryController.listCountriesAdmin);
|
router.get('/admin/countries', requireRoles('admin'), requirePermissions('settings.admin'), countryController.listCountriesAdmin);
|
||||||
router.post('/admin/countries/sync', requireRoles('admin'), requirePermissions('settings.admin'), countryController.syncCountriesAdmin);
|
router.post('/admin/countries/sync', requireRoles('admin'), requirePermissions('settings.admin'), countryController.syncCountriesAdmin);
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import * as ledgerRepository from '../repositories/ledgerRepository';
|
|||||||
import type { RoundOutcome } from './candleGenerationService';
|
import type { RoundOutcome } from './candleGenerationService';
|
||||||
import { queueUserAdminStatsRefresh } from './userAdminStatsService';
|
import { queueUserAdminStatsRefresh } from './userAdminStatsService';
|
||||||
import * as predictionAuditService from './predictionAuditService';
|
import * as predictionAuditService from './predictionAuditService';
|
||||||
|
import { processPredictionReferralCommissions } from './referralService';
|
||||||
import { config } from '../config';
|
import { config } from '../config';
|
||||||
import { publishUserEvent } from '../realtime/redis/pubsub';
|
import { publishUserEvent } from '../realtime/redis/pubsub';
|
||||||
import { bumpUserBetVersionSafe } from '../realtime/redis/stateVersions';
|
import { bumpUserBetVersionSafe } from '../realtime/redis/stateVersions';
|
||||||
@ -26,6 +27,27 @@ function parseStakeAccountKind(value: unknown): AccountKind {
|
|||||||
return 'main';
|
return 'main';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Referral prediction commissions only on terminal win/loss — never on neutral refund. */
|
||||||
|
function queuePredictionReferralCommission(
|
||||||
|
bet: {
|
||||||
|
id: string;
|
||||||
|
user_id: string;
|
||||||
|
stake_raw: string | number | bigint;
|
||||||
|
stake_account_kind?: string | null;
|
||||||
|
wallet_type_id: number;
|
||||||
|
},
|
||||||
|
betOutcome: 'won' | 'lost'
|
||||||
|
): void {
|
||||||
|
void processPredictionReferralCommissions({
|
||||||
|
betId: bet.id,
|
||||||
|
referredUserId: bet.user_id,
|
||||||
|
stakeRaw: BigInt(bet.stake_raw),
|
||||||
|
stakeAccountKind: parseStakeAccountKind(bet.stake_account_kind),
|
||||||
|
walletTypeId: bet.wallet_type_id,
|
||||||
|
betOutcome,
|
||||||
|
}).catch((e) => console.error('[referral] prediction commission failed:', e));
|
||||||
|
}
|
||||||
|
|
||||||
async function creditGameOutcome(
|
async function creditGameOutcome(
|
||||||
bet: { user_id: string; wallet_type_id: number; id: string; stake_account_kind?: string },
|
bet: { user_id: string; wallet_type_id: number; id: string; stake_account_kind?: string },
|
||||||
amount: bigint,
|
amount: bigint,
|
||||||
@ -261,6 +283,7 @@ export async function processMultiBetsAtMaturity(
|
|||||||
predictionMode: 'multi_candle',
|
predictionMode: 'multi_candle',
|
||||||
intervalMinutes: bet.interval_minutes,
|
intervalMinutes: bet.interval_minutes,
|
||||||
});
|
});
|
||||||
|
queuePredictionReferralCommission(bet, 'lost');
|
||||||
queueUserAdminStatsRefresh(bet.user_id);
|
queueUserAdminStatsRefresh(bet.user_id);
|
||||||
await notifyMultiBetUpdate(bet.user_id, bet.interval_minutes, null);
|
await notifyMultiBetUpdate(bet.user_id, bet.interval_minutes, null);
|
||||||
continue;
|
continue;
|
||||||
@ -311,6 +334,7 @@ export async function processMultiBetsAtMaturity(
|
|||||||
stake_account_kind: parseStakeAccountKind(bet.stake_account_kind),
|
stake_account_kind: parseStakeAccountKind(bet.stake_account_kind),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
queuePredictionReferralCommission(bet, 'won');
|
||||||
queueUserAdminStatsRefresh(bet.user_id);
|
queueUserAdminStatsRefresh(bet.user_id);
|
||||||
await notifyMultiBetUpdate(bet.user_id, bet.interval_minutes, null);
|
await notifyMultiBetUpdate(bet.user_id, bet.interval_minutes, null);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,6 +38,7 @@ const TABLE_BASE_SEVERITY: Record<string, SecurityAlertSeverity> = {
|
|||||||
candle_predict_rounds: 'high',
|
candle_predict_rounds: 'high',
|
||||||
test_wallet_credits: 'high',
|
test_wallet_credits: 'high',
|
||||||
test_wallet_settings: 'high',
|
test_wallet_settings: 'high',
|
||||||
|
share_card_settings: 'medium',
|
||||||
referral_program_settings: 'high',
|
referral_program_settings: 'high',
|
||||||
platform_bonus_pools: 'high',
|
platform_bonus_pools: 'high',
|
||||||
exchange_funding: 'high',
|
exchange_funding: 'high',
|
||||||
|
|||||||
@ -459,9 +459,10 @@ export async function processFirstDepositReferralCommissions(input: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Credits multi-level referral commissions on each validated prediction (stake-based).
|
* Credits multi-level referral commissions on settled predictions (stake-based).
|
||||||
|
* Only won/lost settlements qualify — neutral (refund) must never trigger this.
|
||||||
* Pays immediately to the referrer bonus wallet after Sybil / caps / pool checks.
|
* Pays immediately to the referrer bonus wallet after Sybil / caps / pool checks.
|
||||||
* Test stakes are excluded; win/lose/refund do not affect the calculation.
|
* Test stakes are excluded. Deposit/withdrawal commission modes are unchanged.
|
||||||
*/
|
*/
|
||||||
export async function processPredictionReferralCommissions(input: {
|
export async function processPredictionReferralCommissions(input: {
|
||||||
betId: string;
|
betId: string;
|
||||||
@ -469,7 +470,10 @@ export async function processPredictionReferralCommissions(input: {
|
|||||||
stakeRaw: bigint;
|
stakeRaw: bigint;
|
||||||
stakeAccountKind: 'main' | 'bonus' | 'test';
|
stakeAccountKind: 'main' | 'bonus' | 'test';
|
||||||
walletTypeId: number;
|
walletTypeId: number;
|
||||||
|
/** Terminal bet outcome; neutral/refund must not call this. */
|
||||||
|
betOutcome: 'won' | 'lost';
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
|
if (input.betOutcome !== 'won' && input.betOutcome !== 'lost') return;
|
||||||
if (input.stakeAccountKind === 'test') return;
|
if (input.stakeAccountKind === 'test') return;
|
||||||
if (input.stakeRaw <= 0n) return;
|
if (input.stakeRaw <= 0n) return;
|
||||||
|
|
||||||
|
|||||||
258
backend/src/services/shareCardService.ts
Normal file
258
backend/src/services/shareCardService.ts
Normal file
@ -0,0 +1,258 @@
|
|||||||
|
/**
|
||||||
|
* Share Cards: eligibility, signed verify tokens, and share payloads for prediction results.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import crypto from 'crypto';
|
||||||
|
import { config } from '../config';
|
||||||
|
import { getPublicWebBaseUrl, buildReferralRegisterLink } from '../utils/publicWebUrl';
|
||||||
|
import * as shareCardRepository from '../repositories/shareCardRepository';
|
||||||
|
import * as candlePredictRepository from '../repositories/candlePredictRepository';
|
||||||
|
import * as referralRepository from '../repositories/referralRepository';
|
||||||
|
import type { ShareCardSettingsRow } from '../repositories/shareCardRepository';
|
||||||
|
|
||||||
|
export type ShareableBetStatus = 'won' | 'lost' | 'refunded';
|
||||||
|
export type StakeAccountKind = 'main' | 'bonus' | 'test';
|
||||||
|
|
||||||
|
const STAKE_DECIMALS = 6;
|
||||||
|
|
||||||
|
export function mapSettingsForClient(row: ShareCardSettingsRow) {
|
||||||
|
return {
|
||||||
|
enabled: row.enabled,
|
||||||
|
allowMainWallet: row.allow_main_wallet,
|
||||||
|
allowBonusWallet: row.allow_bonus_wallet,
|
||||||
|
allowTestWallet: row.allow_test_wallet,
|
||||||
|
allowWon: row.allow_won,
|
||||||
|
allowLost: row.allow_lost,
|
||||||
|
allowRefunded: row.allow_refunded,
|
||||||
|
updatedAt: row.updated_at.toISOString(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function canSharePredictionResult(
|
||||||
|
settings: ShareCardSettingsRow,
|
||||||
|
input: { stakeAccountKind: StakeAccountKind; status: string }
|
||||||
|
): boolean {
|
||||||
|
if (!settings.enabled) return false;
|
||||||
|
if (input.status !== 'won' && input.status !== 'lost' && input.status !== 'refunded') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (input.stakeAccountKind === 'main' && !settings.allow_main_wallet) return false;
|
||||||
|
if (input.stakeAccountKind === 'bonus' && !settings.allow_bonus_wallet) return false;
|
||||||
|
if (input.stakeAccountKind === 'test' && !settings.allow_test_wallet) return false;
|
||||||
|
if (input.status === 'won' && !settings.allow_won) return false;
|
||||||
|
if (input.status === 'lost' && !settings.allow_lost) return false;
|
||||||
|
if (input.status === 'refunded' && !settings.allow_refunded) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function rawToDisplay(raw: bigint): string {
|
||||||
|
const neg = raw < 0n;
|
||||||
|
const abs = neg ? -raw : raw;
|
||||||
|
const whole = abs / 10n ** BigInt(STAKE_DECIMALS);
|
||||||
|
const frac = (abs % 10n ** BigInt(STAKE_DECIMALS)).toString().padStart(STAKE_DECIMALS, '0');
|
||||||
|
const trimmed = frac.replace(/0+$/, '');
|
||||||
|
const body = trimmed ? `${whole}.${trimmed}` : whole.toString();
|
||||||
|
return neg ? `-${body}` : body;
|
||||||
|
}
|
||||||
|
|
||||||
|
function computeResultAmount(status: ShareableBetStatus, stakeRaw: bigint, payoutRaw: bigint): {
|
||||||
|
resultSignedDisplay: string;
|
||||||
|
resultRaw: string;
|
||||||
|
pnlSign: '+' | '-' | '';
|
||||||
|
} {
|
||||||
|
if (status === 'won') {
|
||||||
|
const pnl = payoutRaw - stakeRaw;
|
||||||
|
const display = rawToDisplay(pnl);
|
||||||
|
return {
|
||||||
|
resultSignedDisplay: pnl >= 0n ? `+${display}` : display,
|
||||||
|
resultRaw: pnl.toString(),
|
||||||
|
pnlSign: pnl >= 0n ? '+' : '-',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (status === 'lost') {
|
||||||
|
const display = rawToDisplay(stakeRaw);
|
||||||
|
return {
|
||||||
|
resultSignedDisplay: `-${display}`,
|
||||||
|
resultRaw: (-stakeRaw).toString(),
|
||||||
|
pnlSign: '-',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
resultSignedDisplay: '0',
|
||||||
|
resultRaw: '0',
|
||||||
|
pnlSign: '',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function b64url(buf: Buffer | string): string {
|
||||||
|
const b = typeof buf === 'string' ? Buffer.from(buf, 'utf8') : buf;
|
||||||
|
return b.toString('base64url');
|
||||||
|
}
|
||||||
|
|
||||||
|
function shareSecret(): string {
|
||||||
|
return process.env.SHARE_CARD_SECRET?.trim() || config.jwt.secret;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createShareVerifyToken(betId: string, userId: string): string {
|
||||||
|
const payload = b64url(JSON.stringify({ b: betId, u: userId, v: 1 }));
|
||||||
|
const sig = crypto.createHmac('sha256', shareSecret()).update(payload).digest();
|
||||||
|
return `${payload}.${b64url(sig)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function parseShareVerifyToken(
|
||||||
|
token: string
|
||||||
|
): { betId: string; userId: string } | null {
|
||||||
|
const parts = token.split('.');
|
||||||
|
if (parts.length !== 2) return null;
|
||||||
|
const [payload, sig] = parts;
|
||||||
|
if (!payload || !sig) return null;
|
||||||
|
const expected = b64url(crypto.createHmac('sha256', shareSecret()).update(payload).digest());
|
||||||
|
const a = Buffer.from(sig);
|
||||||
|
const b = Buffer.from(expected);
|
||||||
|
if (a.length !== b.length || !crypto.timingSafeEqual(a, b)) return null;
|
||||||
|
try {
|
||||||
|
const json = JSON.parse(Buffer.from(payload, 'base64url').toString('utf8')) as {
|
||||||
|
b?: string;
|
||||||
|
u?: string;
|
||||||
|
v?: number;
|
||||||
|
};
|
||||||
|
if (!json.b || !json.u) return null;
|
||||||
|
return { betId: json.b, userId: json.u };
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildShareVerifyUrl(token: string): string {
|
||||||
|
return `${getPublicWebBaseUrl()}/share/r/${encodeURIComponent(token)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildCardPayload(
|
||||||
|
bet: candlePredictRepository.CandlePredictBetWithSettlement,
|
||||||
|
opts: { includeReferral: boolean; referralCode: string | null }
|
||||||
|
) {
|
||||||
|
const status = bet.status as ShareableBetStatus;
|
||||||
|
const stakeRaw = BigInt(bet.stake_raw);
|
||||||
|
const payoutRaw = BigInt(bet.payout_raw);
|
||||||
|
const result = computeResultAmount(status, stakeRaw, payoutRaw);
|
||||||
|
const token = createShareVerifyToken(bet.id, bet.user_id);
|
||||||
|
const verifyUrl = buildShareVerifyUrl(token);
|
||||||
|
const registerUrl = opts.referralCode
|
||||||
|
? buildReferralRegisterLink(opts.referralCode)
|
||||||
|
: `${getPublicWebBaseUrl()}/register`;
|
||||||
|
|
||||||
|
return {
|
||||||
|
betId: bet.id,
|
||||||
|
gameName: 'Candle Predict',
|
||||||
|
direction: bet.direction,
|
||||||
|
sequence: bet.sequence_directions,
|
||||||
|
multiLevel: bet.multi_level,
|
||||||
|
predictionMode: bet.prediction_mode,
|
||||||
|
isAuto: bet.is_auto,
|
||||||
|
status,
|
||||||
|
stakeDisplay: Number(bet.stake_display),
|
||||||
|
stakeRaw: bet.stake_raw,
|
||||||
|
payoutRaw: bet.payout_raw,
|
||||||
|
resultSignedDisplay: result.resultSignedDisplay,
|
||||||
|
resultRaw: result.resultRaw,
|
||||||
|
pnlSign: result.pnlSign,
|
||||||
|
intervalMinutes: bet.interval_minutes,
|
||||||
|
stakeAccountKind: bet.stake_account_kind,
|
||||||
|
settledAt: bet.settled_at?.toISOString() ?? bet.created_at.toISOString(),
|
||||||
|
verifyUrl,
|
||||||
|
verifyToken: token,
|
||||||
|
referralCode: opts.includeReferral ? opts.referralCode : null,
|
||||||
|
registerUrl,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getConfigForUser() {
|
||||||
|
const settings = await shareCardRepository.getSettings();
|
||||||
|
return mapSettingsForClient(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getSettingsForAdmin() {
|
||||||
|
const settings = await shareCardRepository.getSettings();
|
||||||
|
return mapSettingsForClient(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateSettings(input: {
|
||||||
|
enabled?: boolean;
|
||||||
|
allowMainWallet?: boolean;
|
||||||
|
allowBonusWallet?: boolean;
|
||||||
|
allowTestWallet?: boolean;
|
||||||
|
allowWon?: boolean;
|
||||||
|
allowLost?: boolean;
|
||||||
|
allowRefunded?: boolean;
|
||||||
|
}) {
|
||||||
|
const row = await shareCardRepository.updateSettings(input);
|
||||||
|
return mapSettingsForClient(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ShareCardError extends Error {
|
||||||
|
status: number;
|
||||||
|
constructor(message: string, status = 400) {
|
||||||
|
super(message);
|
||||||
|
this.name = 'ShareCardError';
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getSharePayloadForOwner(userId: string, betId: string) {
|
||||||
|
const settings = await shareCardRepository.getSettings();
|
||||||
|
const bet = await candlePredictRepository.getBetById(betId);
|
||||||
|
if (!bet || bet.user_id !== userId) {
|
||||||
|
throw new ShareCardError('Prediction not found', 404);
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
!canSharePredictionResult(settings, {
|
||||||
|
stakeAccountKind: bet.stake_account_kind,
|
||||||
|
status: bet.status,
|
||||||
|
})
|
||||||
|
) {
|
||||||
|
throw new ShareCardError('Sharing is not available for this prediction', 403);
|
||||||
|
}
|
||||||
|
const referralCode = await referralRepository.getUserReferralCode(userId);
|
||||||
|
return buildCardPayload(bet, { includeReferral: true, referralCode });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getPublicVerifyPayload(token: string) {
|
||||||
|
const parsed = parseShareVerifyToken(token);
|
||||||
|
if (!parsed) {
|
||||||
|
throw new ShareCardError('Invalid or tampered share token', 400);
|
||||||
|
}
|
||||||
|
const settings = await shareCardRepository.getSettings();
|
||||||
|
if (!settings.enabled) {
|
||||||
|
throw new ShareCardError('Share cards are disabled', 404);
|
||||||
|
}
|
||||||
|
const bet = await candlePredictRepository.getBetById(parsed.betId);
|
||||||
|
if (!bet || bet.user_id !== parsed.userId) {
|
||||||
|
throw new ShareCardError('Prediction not found', 404);
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
!canSharePredictionResult(settings, {
|
||||||
|
stakeAccountKind: bet.stake_account_kind,
|
||||||
|
status: bet.status,
|
||||||
|
})
|
||||||
|
) {
|
||||||
|
throw new ShareCardError('This result is no longer shareable', 404);
|
||||||
|
}
|
||||||
|
const referralCode = await referralRepository.getUserReferralCode(bet.user_id);
|
||||||
|
const card = buildCardPayload(bet, { includeReferral: true, referralCode });
|
||||||
|
// Public verify: omit internal ids that aren't needed for marketing display
|
||||||
|
return {
|
||||||
|
authentic: true as const,
|
||||||
|
gameName: card.gameName,
|
||||||
|
direction: card.direction,
|
||||||
|
sequence: card.sequence,
|
||||||
|
multiLevel: card.multiLevel,
|
||||||
|
predictionMode: card.predictionMode,
|
||||||
|
status: card.status,
|
||||||
|
resultSignedDisplay: card.resultSignedDisplay,
|
||||||
|
stakeDisplay: card.stakeDisplay,
|
||||||
|
intervalMinutes: card.intervalMinutes,
|
||||||
|
settledAt: card.settledAt,
|
||||||
|
registerUrl: card.registerUrl,
|
||||||
|
referralCode: card.referralCode,
|
||||||
|
};
|
||||||
|
}
|
||||||
@ -13,7 +13,7 @@ describe('prediction referral commissions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('test stake kind is excluded by processPredictionReferralCommissions gate', async () => {
|
test('test stake kind is excluded by processPredictionReferralCommissions gate', async () => {
|
||||||
// Gate is the first check in processPredictionReferralCommissions; importing and calling
|
// Gate is an early check in processPredictionReferralCommissions; importing and calling
|
||||||
// with test stake must no-op without DB access when stakeAccountKind === 'test'.
|
// with test stake must no-op without DB access when stakeAccountKind === 'test'.
|
||||||
const { processPredictionReferralCommissions } = await import('../services/referralService');
|
const { processPredictionReferralCommissions } = await import('../services/referralService');
|
||||||
await processPredictionReferralCommissions({
|
await processPredictionReferralCommissions({
|
||||||
@ -22,6 +22,19 @@ describe('prediction referral commissions', () => {
|
|||||||
stakeRaw: 10_000_000n,
|
stakeRaw: 10_000_000n,
|
||||||
stakeAccountKind: 'test',
|
stakeAccountKind: 'test',
|
||||||
walletTypeId: 2,
|
walletTypeId: 2,
|
||||||
|
betOutcome: 'won',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('processPredictionReferralCommissions requires won/lost betOutcome', async () => {
|
||||||
|
const { processPredictionReferralCommissions } = await import('../services/referralService');
|
||||||
|
await processPredictionReferralCommissions({
|
||||||
|
betId: '00000000-0000-0000-0000-000000000001',
|
||||||
|
referredUserId: '00000000-0000-0000-0000-000000000002',
|
||||||
|
stakeRaw: 10_000_000n,
|
||||||
|
stakeAccountKind: 'main',
|
||||||
|
walletTypeId: 2,
|
||||||
|
betOutcome: 'refunded' as 'won',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
85
backend/src/tests/shareCardService.test.ts
Normal file
85
backend/src/tests/shareCardService.test.ts
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
import { describe, test } from 'node:test';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import {
|
||||||
|
canSharePredictionResult,
|
||||||
|
createShareVerifyToken,
|
||||||
|
parseShareVerifyToken,
|
||||||
|
} from '../services/shareCardService';
|
||||||
|
import type { ShareCardSettingsRow } from '../repositories/shareCardRepository';
|
||||||
|
|
||||||
|
function settings(partial: Partial<ShareCardSettingsRow> = {}): ShareCardSettingsRow {
|
||||||
|
return {
|
||||||
|
id: 1,
|
||||||
|
enabled: true,
|
||||||
|
allow_main_wallet: true,
|
||||||
|
allow_bonus_wallet: true,
|
||||||
|
allow_test_wallet: false,
|
||||||
|
allow_won: true,
|
||||||
|
allow_lost: true,
|
||||||
|
allow_refunded: true,
|
||||||
|
updated_at: new Date(),
|
||||||
|
...partial,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('share card eligibility', () => {
|
||||||
|
test('blocks when globally disabled', () => {
|
||||||
|
assert.equal(
|
||||||
|
canSharePredictionResult(settings({ enabled: false }), {
|
||||||
|
stakeAccountKind: 'main',
|
||||||
|
status: 'won',
|
||||||
|
}),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('blocks test wallet when disallowed', () => {
|
||||||
|
assert.equal(
|
||||||
|
canSharePredictionResult(settings(), { stakeAccountKind: 'test', status: 'won' }),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('blocks lost when allow_lost is false', () => {
|
||||||
|
assert.equal(
|
||||||
|
canSharePredictionResult(settings({ allow_lost: false }), {
|
||||||
|
stakeAccountKind: 'main',
|
||||||
|
status: 'lost',
|
||||||
|
}),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('allows main wallet won by default', () => {
|
||||||
|
assert.equal(
|
||||||
|
canSharePredictionResult(settings(), { stakeAccountKind: 'main', status: 'won' }),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('blocks pending bets', () => {
|
||||||
|
assert.equal(
|
||||||
|
canSharePredictionResult(settings(), { stakeAccountKind: 'main', status: 'pending' }),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('share card verify token', () => {
|
||||||
|
test('round-trips bet and user ids', () => {
|
||||||
|
const betId = '11111111-1111-1111-1111-111111111111';
|
||||||
|
const userId = '22222222-2222-2222-2222-222222222222';
|
||||||
|
const token = createShareVerifyToken(betId, userId);
|
||||||
|
const parsed = parseShareVerifyToken(token);
|
||||||
|
assert.deepEqual(parsed, { betId, userId });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('rejects tampered token', () => {
|
||||||
|
const token = createShareVerifyToken(
|
||||||
|
'11111111-1111-1111-1111-111111111111',
|
||||||
|
'22222222-2222-2222-2222-222222222222'
|
||||||
|
);
|
||||||
|
assert.equal(parseShareVerifyToken(token + 'x'), null);
|
||||||
|
assert.equal(parseShareVerifyToken('not-a-token'), null);
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -187,6 +187,18 @@ export const testWalletConfigBodySchema = atLeastOneField(
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const shareCardSettingsBodySchema = atLeastOneField(
|
||||||
|
z.object({
|
||||||
|
enabled: z.boolean().optional(),
|
||||||
|
allowMainWallet: z.boolean().optional(),
|
||||||
|
allowBonusWallet: z.boolean().optional(),
|
||||||
|
allowTestWallet: z.boolean().optional(),
|
||||||
|
allowWon: z.boolean().optional(),
|
||||||
|
allowLost: z.boolean().optional(),
|
||||||
|
allowRefunded: z.boolean().optional(),
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
// —— Support ——
|
// —— Support ——
|
||||||
|
|
||||||
export const supportConversationUpdateBodySchema = atLeastOneField(
|
export const supportConversationUpdateBodySchema = atLeastOneField(
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import '../../data/repositories/health_repository_impl.dart';
|
|||||||
import '../../data/repositories/notification_repository_impl.dart';
|
import '../../data/repositories/notification_repository_impl.dart';
|
||||||
import '../../data/repositories/prediction_repository_impl.dart';
|
import '../../data/repositories/prediction_repository_impl.dart';
|
||||||
import '../../data/repositories/referral_repository_impl.dart';
|
import '../../data/repositories/referral_repository_impl.dart';
|
||||||
|
import '../../data/repositories/share_card_repository.dart';
|
||||||
import '../../data/repositories/wallet_repository_impl.dart';
|
import '../../data/repositories/wallet_repository_impl.dart';
|
||||||
import '../../domain/repositories/advertisement_repository.dart';
|
import '../../domain/repositories/advertisement_repository.dart';
|
||||||
import '../../domain/repositories/faq_repository.dart';
|
import '../../domain/repositories/faq_repository.dart';
|
||||||
@ -59,6 +60,9 @@ Future<void> configureDependencies({AppConfig? config}) async {
|
|||||||
if (!sl.isRegistered<PredictionRepository>()) {
|
if (!sl.isRegistered<PredictionRepository>()) {
|
||||||
sl.registerLazySingleton<PredictionRepository>(() => PredictionRepositoryImpl(sl()));
|
sl.registerLazySingleton<PredictionRepository>(() => PredictionRepositoryImpl(sl()));
|
||||||
}
|
}
|
||||||
|
if (!sl.isRegistered<ShareCardRepository>()) {
|
||||||
|
sl.registerLazySingleton<ShareCardRepository>(() => ShareCardRepository(sl()));
|
||||||
|
}
|
||||||
if (!sl.isRegistered<ReferralRepository>()) {
|
if (!sl.isRegistered<ReferralRepository>()) {
|
||||||
sl.registerLazySingleton<ReferralRepository>(() => ReferralRepositoryImpl(sl()));
|
sl.registerLazySingleton<ReferralRepository>(() => ReferralRepositoryImpl(sl()));
|
||||||
}
|
}
|
||||||
|
|||||||
103
prediqo_mobile/lib/data/models/share_card_models.dart
Normal file
103
prediqo_mobile/lib/data/models/share_card_models.dart
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
class ShareCardConfig {
|
||||||
|
const ShareCardConfig({
|
||||||
|
required this.enabled,
|
||||||
|
required this.allowMainWallet,
|
||||||
|
required this.allowBonusWallet,
|
||||||
|
required this.allowTestWallet,
|
||||||
|
required this.allowWon,
|
||||||
|
required this.allowLost,
|
||||||
|
required this.allowRefunded,
|
||||||
|
});
|
||||||
|
|
||||||
|
final bool enabled;
|
||||||
|
final bool allowMainWallet;
|
||||||
|
final bool allowBonusWallet;
|
||||||
|
final bool allowTestWallet;
|
||||||
|
final bool allowWon;
|
||||||
|
final bool allowLost;
|
||||||
|
final bool allowRefunded;
|
||||||
|
|
||||||
|
factory ShareCardConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return ShareCardConfig(
|
||||||
|
enabled: json['enabled'] == true,
|
||||||
|
allowMainWallet: json['allowMainWallet'] != false,
|
||||||
|
allowBonusWallet: json['allowBonusWallet'] != false,
|
||||||
|
allowTestWallet: json['allowTestWallet'] == true,
|
||||||
|
allowWon: json['allowWon'] != false,
|
||||||
|
allowLost: json['allowLost'] != false,
|
||||||
|
allowRefunded: json['allowRefunded'] != false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isEligible({
|
||||||
|
required String? status,
|
||||||
|
required String? stakeAccountKind,
|
||||||
|
bool requireStatus = true,
|
||||||
|
}) {
|
||||||
|
if (!enabled) return false;
|
||||||
|
final kind = stakeAccountKind ?? 'main';
|
||||||
|
if (kind == 'main' && !allowMainWallet) return false;
|
||||||
|
if (kind == 'bonus' && !allowBonusWallet) return false;
|
||||||
|
if (kind == 'test' && !allowTestWallet) return false;
|
||||||
|
if (status == null || status.isEmpty) return !requireStatus;
|
||||||
|
if (status != 'won' && status != 'lost' && status != 'refunded') return false;
|
||||||
|
if (status == 'won' && !allowWon) return false;
|
||||||
|
if (status == 'lost' && !allowLost) return false;
|
||||||
|
if (status == 'refunded' && !allowRefunded) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ShareCardPayload {
|
||||||
|
const ShareCardPayload({
|
||||||
|
required this.betId,
|
||||||
|
required this.gameName,
|
||||||
|
required this.direction,
|
||||||
|
required this.status,
|
||||||
|
required this.resultSignedDisplay,
|
||||||
|
required this.stakeDisplay,
|
||||||
|
required this.intervalMinutes,
|
||||||
|
required this.settledAt,
|
||||||
|
required this.verifyUrl,
|
||||||
|
required this.predictionMode,
|
||||||
|
required this.isAuto,
|
||||||
|
this.sequence = const [],
|
||||||
|
});
|
||||||
|
|
||||||
|
final String betId;
|
||||||
|
final String gameName;
|
||||||
|
final String direction;
|
||||||
|
final String status;
|
||||||
|
final String resultSignedDisplay;
|
||||||
|
final num stakeDisplay;
|
||||||
|
final int intervalMinutes;
|
||||||
|
final String settledAt;
|
||||||
|
final String verifyUrl;
|
||||||
|
final String predictionMode;
|
||||||
|
final bool isAuto;
|
||||||
|
final List<String> sequence;
|
||||||
|
|
||||||
|
factory ShareCardPayload.fromJson(Map<String, dynamic> json) {
|
||||||
|
final seq = json['sequence'];
|
||||||
|
return ShareCardPayload(
|
||||||
|
betId: (json['betId'] ?? '').toString(),
|
||||||
|
gameName: (json['gameName'] ?? 'Candle Predict').toString(),
|
||||||
|
direction: (json['direction'] ?? 'long').toString(),
|
||||||
|
status: (json['status'] ?? '').toString(),
|
||||||
|
resultSignedDisplay: (json['resultSignedDisplay'] ?? '0').toString(),
|
||||||
|
stakeDisplay: json['stakeDisplay'] is num
|
||||||
|
? json['stakeDisplay'] as num
|
||||||
|
: num.tryParse('${json['stakeDisplay']}') ?? 0,
|
||||||
|
intervalMinutes: json['intervalMinutes'] is int
|
||||||
|
? json['intervalMinutes'] as int
|
||||||
|
: int.tryParse('${json['intervalMinutes']}') ?? 1,
|
||||||
|
settledAt: (json['settledAt'] ?? '').toString(),
|
||||||
|
verifyUrl: (json['verifyUrl'] ?? '').toString(),
|
||||||
|
predictionMode: (json['predictionMode'] ?? 'single').toString(),
|
||||||
|
isAuto: json['isAuto'] == true,
|
||||||
|
sequence: seq is List
|
||||||
|
? seq.map((e) => e.toString()).toList()
|
||||||
|
: const <String>[],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
import '../../core/errors/app_exception.dart';
|
||||||
|
import '../../core/network/api_client.dart';
|
||||||
|
import '../models/share_card_models.dart';
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
|
|
||||||
|
class ShareCardRepository {
|
||||||
|
ShareCardRepository(this._api);
|
||||||
|
|
||||||
|
final ApiClient _api;
|
||||||
|
ShareCardConfig? _cachedConfig;
|
||||||
|
DateTime? _cachedAt;
|
||||||
|
|
||||||
|
Future<ShareCardConfig> getConfig({bool force = false}) async {
|
||||||
|
final now = DateTime.now();
|
||||||
|
if (!force &&
|
||||||
|
_cachedConfig != null &&
|
||||||
|
_cachedAt != null &&
|
||||||
|
now.difference(_cachedAt!) < const Duration(minutes: 1)) {
|
||||||
|
return _cachedConfig!;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
final res = await _api.dio.get<Map<String, dynamic>>('/api/v1/share-cards/config');
|
||||||
|
final config = ShareCardConfig.fromJson(res.data ?? {});
|
||||||
|
_cachedConfig = config;
|
||||||
|
_cachedAt = now;
|
||||||
|
return config;
|
||||||
|
} on DioException catch (e) {
|
||||||
|
throw AppException.fromDio(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<ShareCardPayload> getBetShareCard(String betId) async {
|
||||||
|
try {
|
||||||
|
final res = await _api.dio.get<Map<String, dynamic>>(
|
||||||
|
'/api/v1/share-cards/bets/$betId',
|
||||||
|
);
|
||||||
|
return ShareCardPayload.fromJson(res.data ?? {});
|
||||||
|
} on DioException catch (e) {
|
||||||
|
throw AppException.fromDio(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -13,6 +13,7 @@ import '../bloc/prediction_bloc.dart';
|
|||||||
import 'widgets/candle_chart_widget.dart';
|
import 'widgets/candle_chart_widget.dart';
|
||||||
import 'widgets/multi_sequence_progress.dart';
|
import 'widgets/multi_sequence_progress.dart';
|
||||||
import 'widgets/prediction_bet_panel.dart';
|
import 'widgets/prediction_bet_panel.dart';
|
||||||
|
import '../../share_cards/presentation/share_result_widgets.dart';
|
||||||
|
|
||||||
class PredictionScreen extends StatefulWidget {
|
class PredictionScreen extends StatefulWidget {
|
||||||
const PredictionScreen({super.key});
|
const PredictionScreen({super.key});
|
||||||
@ -545,6 +546,11 @@ class _PredictionHistoryCard extends StatelessWidget {
|
|||||||
p.payoutDisplay > 0 ? '+${p.payoutDisplay}' : '',
|
p.payoutDisplay > 0 ? '+${p.payoutDisplay}' : '',
|
||||||
style: const TextStyle(color: AppColors.success, fontWeight: FontWeight.w700),
|
style: const TextStyle(color: AppColors.success, fontWeight: FontWeight.w700),
|
||||||
),
|
),
|
||||||
|
ShareResultIconButton(
|
||||||
|
betId: p.id,
|
||||||
|
status: p.status,
|
||||||
|
stakeAccountKind: p.stakeAccountKind,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
|
|||||||
@ -0,0 +1,347 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
import 'dart:ui' as ui;
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/rendering.dart';
|
||||||
|
import 'package:path_provider/path_provider.dart';
|
||||||
|
import 'package:qr_flutter/qr_flutter.dart';
|
||||||
|
import 'package:share_plus/share_plus.dart';
|
||||||
|
|
||||||
|
import '../../../core/di/injection.dart';
|
||||||
|
import '../../../core/theme/app_colors.dart';
|
||||||
|
import '../../../data/models/share_card_models.dart';
|
||||||
|
import '../../../data/repositories/share_card_repository.dart';
|
||||||
|
import '../../../l10n/app_strings.dart';
|
||||||
|
import '../../../shared/widgets/prediqo_logo.dart';
|
||||||
|
|
||||||
|
Future<void> openShareResultDialog(
|
||||||
|
BuildContext context, {
|
||||||
|
required String betId,
|
||||||
|
}) {
|
||||||
|
return showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (ctx) => _ShareResultDialog(betId: betId),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ShareResultDialog extends StatefulWidget {
|
||||||
|
const _ShareResultDialog({required this.betId});
|
||||||
|
final String betId;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<_ShareResultDialog> createState() => _ShareResultDialogState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ShareResultDialogState extends State<_ShareResultDialog> {
|
||||||
|
final _cardKey = GlobalKey();
|
||||||
|
ShareCardPayload? _payload;
|
||||||
|
String? _error;
|
||||||
|
bool _loading = true;
|
||||||
|
bool _busy = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_load();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _load() async {
|
||||||
|
setState(() {
|
||||||
|
_loading = true;
|
||||||
|
_error = null;
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
final payload = await sl<ShareCardRepository>().getBetShareCard(widget.betId);
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() {
|
||||||
|
_payload = payload;
|
||||||
|
_loading = false;
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() {
|
||||||
|
_error = e.toString();
|
||||||
|
_loading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _share() async {
|
||||||
|
final boundary =
|
||||||
|
_cardKey.currentContext?.findRenderObject() as RenderRepaintBoundary?;
|
||||||
|
final payload = _payload;
|
||||||
|
if (boundary == null || payload == null) return;
|
||||||
|
setState(() => _busy = true);
|
||||||
|
try {
|
||||||
|
final image = await boundary.toImage(pixelRatio: 3);
|
||||||
|
final bytes = await image.toByteData(format: ui.ImageByteFormat.png);
|
||||||
|
if (bytes == null) throw Exception('export failed');
|
||||||
|
final dir = await getTemporaryDirectory();
|
||||||
|
final file = File(
|
||||||
|
'${dir.path}/prediqo-${payload.status}-${payload.betId.substring(0, 8)}.png',
|
||||||
|
);
|
||||||
|
await file.writeAsBytes(bytes.buffer.asUint8List());
|
||||||
|
await SharePlus.instance.share(
|
||||||
|
ShareParams(
|
||||||
|
files: [XFile(file.path)],
|
||||||
|
text: payload.verifyUrl,
|
||||||
|
subject: 'Prediqo',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} catch (_) {
|
||||||
|
if (!mounted) return;
|
||||||
|
final s = context.strings;
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(content: Text(s.t('Could not export the card', 'Impossible d’exporter la carte'))),
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
if (mounted) setState(() => _busy = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final s = context.strings;
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text(s.t('Share card preview', 'Aperçu de la carte')),
|
||||||
|
content: SizedBox(
|
||||||
|
width: 360,
|
||||||
|
child: _loading
|
||||||
|
? const SizedBox(
|
||||||
|
height: 120,
|
||||||
|
child: Center(child: CircularProgressIndicator()),
|
||||||
|
)
|
||||||
|
: _error != null
|
||||||
|
? Text(_error!, style: const TextStyle(color: AppColors.danger))
|
||||||
|
: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
s.t(
|
||||||
|
'Review your card before sharing.',
|
||||||
|
'Vérifiez votre carte avant de partager.',
|
||||||
|
),
|
||||||
|
style: Theme.of(context).textTheme.bodySmall,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
if (_payload != null)
|
||||||
|
RepaintBoundary(
|
||||||
|
key: _cardKey,
|
||||||
|
child: ShareResultCard(payload: _payload!),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
child: Text(s.t('Cancel', 'Annuler')),
|
||||||
|
),
|
||||||
|
FilledButton.icon(
|
||||||
|
onPressed: _payload == null || _busy ? null : _share,
|
||||||
|
icon: const Icon(Icons.ios_share_rounded, size: 18),
|
||||||
|
label: Text(s.t('Share', 'Partager')),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ShareResultCard extends StatelessWidget {
|
||||||
|
const ShareResultCard({super.key, required this.payload});
|
||||||
|
final ShareCardPayload payload;
|
||||||
|
|
||||||
|
Color get _accent {
|
||||||
|
switch (payload.status) {
|
||||||
|
case 'won':
|
||||||
|
return const Color(0xFF3DDC97);
|
||||||
|
case 'lost':
|
||||||
|
return const Color(0xFFFF6B6B);
|
||||||
|
default:
|
||||||
|
return const Color(0xFFFFB020);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final s = context.strings;
|
||||||
|
final settled = DateTime.tryParse(payload.settledAt)?.toLocal();
|
||||||
|
final direction = payload.sequence.isNotEmpty
|
||||||
|
? payload.sequence.map(_dirLabel).join(' → ')
|
||||||
|
: _dirLabel(payload.direction);
|
||||||
|
final statusLabel = switch (payload.status) {
|
||||||
|
'won' => s.t('Won', 'Gagné'),
|
||||||
|
'lost' => s.t('Lost', 'Perdu'),
|
||||||
|
'refunded' => s.t('Refunded', 'Remboursé'),
|
||||||
|
_ => payload.status,
|
||||||
|
};
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
width: 320,
|
||||||
|
padding: const EdgeInsets.all(18),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(18),
|
||||||
|
gradient: const LinearGradient(
|
||||||
|
begin: Alignment.topLeft,
|
||||||
|
end: Alignment.bottomRight,
|
||||||
|
colors: [Color(0xFF0B1220), Color(0xFF142033), Color(0xFF0E1A2B)],
|
||||||
|
),
|
||||||
|
border: Border.all(color: Colors.white12),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
PrediqoLogo(
|
||||||
|
size: 32,
|
||||||
|
showWordmark: true,
|
||||||
|
wordmarkStyle: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.w900,
|
||||||
|
fontSize: 18,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
Text(
|
||||||
|
payload.gameName,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white70,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
fontSize: 11,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Text(
|
||||||
|
'${payload.resultSignedDisplay} USDT',
|
||||||
|
style: TextStyle(
|
||||||
|
color: _accent,
|
||||||
|
fontWeight: FontWeight.w900,
|
||||||
|
fontSize: 28,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
statusLabel,
|
||||||
|
style: TextStyle(color: _accent, fontWeight: FontWeight.w800),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
_row(s.t('Prediction', 'Prédiction'), direction),
|
||||||
|
_row(s.t('Interval', 'Intervalle'), '${payload.intervalMinutes} min'),
|
||||||
|
_row(s.t('Stake', 'Mise'), '${payload.stakeDisplay} USDT'),
|
||||||
|
if (settled != null)
|
||||||
|
_row(
|
||||||
|
s.t('Settled', 'Validé le'),
|
||||||
|
'${settled.day.toString().padLeft(2, '0')}/'
|
||||||
|
'${settled.month.toString().padLeft(2, '0')}/'
|
||||||
|
'${settled.year} '
|
||||||
|
'${settled.hour.toString().padLeft(2, '0')}:'
|
||||||
|
'${settled.minute.toString().padLeft(2, '0')}',
|
||||||
|
),
|
||||||
|
const SizedBox(height: 14),
|
||||||
|
const Divider(color: Colors.white12),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(6),
|
||||||
|
color: Colors.white,
|
||||||
|
child: QrImageView(
|
||||||
|
data: payload.verifyUrl,
|
||||||
|
size: 64,
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
s.t('Scan to verify · Authentic Prediqo result',
|
||||||
|
'Scanner pour vérifier · Résultat Prediqo authentique'),
|
||||||
|
style: const TextStyle(color: Colors.white70, fontSize: 11),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String _dirLabel(String d) => d == 'short' ? 'Short' : 'Long';
|
||||||
|
|
||||||
|
Widget _row(String label, String value) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 4),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Text(label, style: const TextStyle(color: Colors.white54, fontSize: 12)),
|
||||||
|
),
|
||||||
|
Text(value, style: const TextStyle(color: Colors.white, fontWeight: FontWeight.w700, fontSize: 12)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ShareResultIconButton extends StatefulWidget {
|
||||||
|
const ShareResultIconButton({
|
||||||
|
super.key,
|
||||||
|
required this.betId,
|
||||||
|
this.status,
|
||||||
|
this.stakeAccountKind,
|
||||||
|
this.requireStatus = true,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String betId;
|
||||||
|
final String? status;
|
||||||
|
final String? stakeAccountKind;
|
||||||
|
final bool requireStatus;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ShareResultIconButton> createState() => _ShareResultIconButtonState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ShareResultIconButtonState extends State<ShareResultIconButton> {
|
||||||
|
ShareCardConfig? _config;
|
||||||
|
bool _loaded = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_load();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _load() async {
|
||||||
|
try {
|
||||||
|
final config = await sl<ShareCardRepository>().getConfig();
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() {
|
||||||
|
_config = config;
|
||||||
|
_loaded = true;
|
||||||
|
});
|
||||||
|
} catch (_) {
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() => _loaded = true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
if (!_loaded || _config == null) return const SizedBox.shrink();
|
||||||
|
final ok = _config!.isEligible(
|
||||||
|
status: widget.status,
|
||||||
|
stakeAccountKind: widget.stakeAccountKind,
|
||||||
|
requireStatus: widget.requireStatus,
|
||||||
|
);
|
||||||
|
if (!ok) return const SizedBox.shrink();
|
||||||
|
return IconButton(
|
||||||
|
tooltip: context.strings.t('Share result', 'Partager le résultat'),
|
||||||
|
icon: const Icon(Icons.ios_share_rounded),
|
||||||
|
onPressed: () => openShareResultDialog(context, betId: widget.betId),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -18,6 +18,7 @@ import '../../../shared/widgets/app_snackbar.dart';
|
|||||||
import '../../../shared/widgets/pred_card.dart';
|
import '../../../shared/widgets/pred_card.dart';
|
||||||
import '../../wallet/bloc/wallet_bloc.dart';
|
import '../../wallet/bloc/wallet_bloc.dart';
|
||||||
import '../utils/transaction_display.dart';
|
import '../utils/transaction_display.dart';
|
||||||
|
import '../../share_cards/presentation/share_result_widgets.dart';
|
||||||
|
|
||||||
const _hideBalanceKey = 'wallet_hide_balance';
|
const _hideBalanceKey = 'wallet_hide_balance';
|
||||||
|
|
||||||
@ -1036,6 +1037,17 @@ class _PredictionTxTile extends StatelessWidget {
|
|||||||
color: credit ? AppColors.success : AppColors.danger,
|
color: credit ? AppColors.success : AppColors.danger,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if ((tx.metadata?['bet_id'] ?? '').toString().isNotEmpty)
|
||||||
|
ShareResultIconButton(
|
||||||
|
betId: (tx.metadata!['bet_id']).toString(),
|
||||||
|
status: tx.type == 'game_payout'
|
||||||
|
? 'won'
|
||||||
|
: tx.type == 'game_refund'
|
||||||
|
? 'refunded'
|
||||||
|
: null,
|
||||||
|
stakeAccountKind: stakeAccountKind(tx),
|
||||||
|
requireStatus: tx.type == 'game_payout' || tx.type == 'game_refund',
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -89,6 +89,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.19.1"
|
version: "1.19.1"
|
||||||
|
cross_file:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: cross_file
|
||||||
|
sha256: "28bb3ae56f117b5aec029d702a90f57d285cd975c3c5c281eaca38dbc47c5937"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.3.5+2"
|
||||||
crypto:
|
crypto:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -485,7 +493,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "1.9.1"
|
version: "1.9.1"
|
||||||
path_provider:
|
path_provider:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: path_provider
|
name: path_provider
|
||||||
sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd"
|
sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd"
|
||||||
@ -596,6 +604,22 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.1.0"
|
version: "4.1.0"
|
||||||
|
share_plus:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: share_plus
|
||||||
|
sha256: "223873d106614442ea6f20db5a038685cc5b32a2fba81cdecaefbbae0523f7fa"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "12.0.2"
|
||||||
|
share_plus_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: share_plus_platform_interface
|
||||||
|
sha256: "88023e53a13429bd65d8e85e11a9b484f49d4c190abbd96c7932b74d6927cc9a"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "6.1.0"
|
||||||
shared_preferences:
|
shared_preferences:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|||||||
@ -28,6 +28,8 @@ dependencies:
|
|||||||
uuid: ^4.5.1
|
uuid: ^4.5.1
|
||||||
url_launcher: ^6.3.2
|
url_launcher: ^6.3.2
|
||||||
package_info_plus: ^9.0.1
|
package_info_plus: ^9.0.1
|
||||||
|
share_plus: ^12.0.2
|
||||||
|
path_provider: ^2.1.5
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
7
prediqo_web/package-lock.json
generated
7
prediqo_web/package-lock.json
generated
@ -18,6 +18,7 @@
|
|||||||
"axios": "^1.11.0",
|
"axios": "^1.11.0",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"dompurify": "^3.4.11",
|
"dompurify": "^3.4.11",
|
||||||
|
"html-to-image": "^1.11.13",
|
||||||
"i18next": "^26.3.4",
|
"i18next": "^26.3.4",
|
||||||
"i18next-browser-languagedetector": "^8.2.1",
|
"i18next-browser-languagedetector": "^8.2.1",
|
||||||
"lightweight-charts": "^5.2.0",
|
"lightweight-charts": "^5.2.0",
|
||||||
@ -2395,6 +2396,12 @@
|
|||||||
"void-elements": "3.1.0"
|
"void-elements": "3.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/html-to-image": {
|
||||||
|
"version": "1.11.13",
|
||||||
|
"resolved": "https://registry.npmjs.org/html-to-image/-/html-to-image-1.11.13.tgz",
|
||||||
|
"integrity": "sha512-cuOPoI7WApyhBElTTb9oqsawRvZ0rHhaHwghRLlTuffoD1B2aDemlCruLeZrUIIdvG7gs9xeELEPm6PhuASqrg==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/i18next": {
|
"node_modules/i18next": {
|
||||||
"version": "26.3.4",
|
"version": "26.3.4",
|
||||||
"resolved": "https://registry.npmjs.org/i18next/-/i18next-26.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/i18next/-/i18next-26.3.4.tgz",
|
||||||
|
|||||||
@ -28,6 +28,7 @@
|
|||||||
"axios": "^1.11.0",
|
"axios": "^1.11.0",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"dompurify": "^3.4.11",
|
"dompurify": "^3.4.11",
|
||||||
|
"html-to-image": "^1.11.13",
|
||||||
"i18next": "^26.3.4",
|
"i18next": "^26.3.4",
|
||||||
"i18next-browser-languagedetector": "^8.2.1",
|
"i18next-browser-languagedetector": "^8.2.1",
|
||||||
"lightweight-charts": "^5.2.0",
|
"lightweight-charts": "^5.2.0",
|
||||||
|
|||||||
@ -26,6 +26,8 @@ import { ReferralAdminPage } from '../../features/referral/ReferralAdminPage';
|
|||||||
import { ReferralPage } from '../../features/referral/ReferralPage';
|
import { ReferralPage } from '../../features/referral/ReferralPage';
|
||||||
import { ReferralFraudDashboardPage } from '../../features/referral/ReferralFraudDashboardPage';
|
import { ReferralFraudDashboardPage } from '../../features/referral/ReferralFraudDashboardPage';
|
||||||
import { TestWalletAdminPage } from '../../features/test-wallet/TestWalletAdminPage';
|
import { TestWalletAdminPage } from '../../features/test-wallet/TestWalletAdminPage';
|
||||||
|
import { ShareCardsAdminPage } from '../../features/share-cards/ShareCardsAdminPage';
|
||||||
|
import { ShareResultVerifyPage } from '../../features/share-cards/ShareResultVerifyPage';
|
||||||
import { SecurityAdminPage } from '../../features/security/SecurityAdminPage';
|
import { SecurityAdminPage } from '../../features/security/SecurityAdminPage';
|
||||||
import { ReportsHubPage } from '../../features/reports/ReportsHubPage';
|
import { ReportsHubPage } from '../../features/reports/ReportsHubPage';
|
||||||
import { ReportDetailPage } from '../../features/reports/ReportDetailPage';
|
import { ReportDetailPage } from '../../features/reports/ReportDetailPage';
|
||||||
@ -66,6 +68,10 @@ export const router = createBrowserRouter([
|
|||||||
path: '/faq',
|
path: '/faq',
|
||||||
element: <FaqPublicPage />,
|
element: <FaqPublicPage />,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/share/r/:token',
|
||||||
|
element: <ShareResultVerifyPage />,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
element: <RequireAuth />,
|
element: <RequireAuth />,
|
||||||
@ -103,6 +109,7 @@ export const router = createBrowserRouter([
|
|||||||
{ path: 'admin/referral', element: <ReferralAdminPage /> },
|
{ path: 'admin/referral', element: <ReferralAdminPage /> },
|
||||||
{ path: 'admin/referral/fraud', element: <ReferralFraudDashboardPage /> },
|
{ path: 'admin/referral/fraud', element: <ReferralFraudDashboardPage /> },
|
||||||
{ path: 'admin/test-wallet', element: <TestWalletAdminPage /> },
|
{ path: 'admin/test-wallet', element: <TestWalletAdminPage /> },
|
||||||
|
{ path: 'admin/share-cards', element: <ShareCardsAdminPage /> },
|
||||||
{ path: 'admin/countries', element: <CountriesAdminPage /> },
|
{ path: 'admin/countries', element: <CountriesAdminPage /> },
|
||||||
{ path: 'admin/network', element: <NetworkStatusPage /> },
|
{ path: 'admin/network', element: <NetworkStatusPage /> },
|
||||||
],
|
],
|
||||||
|
|||||||
@ -26,6 +26,7 @@ import {
|
|||||||
useMyCandlePredictions,
|
useMyCandlePredictions,
|
||||||
} from '../hooks/useCandlePredict';
|
} from '../hooks/useCandlePredict';
|
||||||
import type { CandleDirection, CandlePredictPrediction, StakeAccountKind } from '../types';
|
import type { CandleDirection, CandlePredictPrediction, StakeAccountKind } from '../types';
|
||||||
|
import { ShareResultButton } from '../../share-cards/ShareResultButton';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
refreshKey?: string | null;
|
refreshKey?: string | null;
|
||||||
@ -482,6 +483,13 @@ export function RecentPredictionsPanel({
|
|||||||
bgcolor: `${statusColor(p.status)}14`,
|
bgcolor: `${statusColor(p.status)}14`,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
<Box sx={{ ml: 'auto' }}>
|
||||||
|
<ShareResultButton
|
||||||
|
betId={p.id}
|
||||||
|
status={p.status}
|
||||||
|
stakeAccountKind={p.stakeAccountKind}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Box sx={{ mb: 1 }}>
|
<Box sx={{ mb: 1 }}>
|
||||||
@ -547,6 +555,7 @@ export function RecentPredictionsPanel({
|
|||||||
<TableCell align="right" sx={{ width: 72 }}>
|
<TableCell align="right" sx={{ width: 72 }}>
|
||||||
{t(`${cols}.payout`)}
|
{t(`${cols}.payout`)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
<TableCell sx={{ width: 48 }} />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHead>
|
</TableHead>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
@ -601,12 +610,19 @@ export function RecentPredictionsPanel({
|
|||||||
<TableCell align="right" sx={{ whiteSpace: 'nowrap', fontWeight: 600 }}>
|
<TableCell align="right" sx={{ whiteSpace: 'nowrap', fontWeight: 600 }}>
|
||||||
{p.payoutDisplay > 0 ? p.payoutDisplay : '—'}
|
{p.payoutDisplay > 0 ? p.payoutDisplay : '—'}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<ShareResultButton
|
||||||
|
betId={p.id}
|
||||||
|
status={p.status}
|
||||||
|
stakeAccountKind={p.stakeAccountKind}
|
||||||
|
/>
|
||||||
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
{!items.length && (
|
{!items.length && (
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell colSpan={7} sx={{ opacity: 0.6 }}>
|
<TableCell colSpan={8} sx={{ opacity: 0.6 }}>
|
||||||
{t('candlePredict.recentPredictions.empty')}
|
{t('candlePredict.recentPredictions.empty')}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import CampaignRoundedIcon from '@mui/icons-material/CampaignRounded';
|
|||||||
import AccountBalanceWalletRoundedIcon from '@mui/icons-material/AccountBalanceWalletRounded';
|
import AccountBalanceWalletRoundedIcon from '@mui/icons-material/AccountBalanceWalletRounded';
|
||||||
import GroupAddRoundedIcon from '@mui/icons-material/GroupAddRounded';
|
import GroupAddRoundedIcon from '@mui/icons-material/GroupAddRounded';
|
||||||
import ScienceRoundedIcon from '@mui/icons-material/ScienceRounded';
|
import ScienceRoundedIcon from '@mui/icons-material/ScienceRounded';
|
||||||
|
import IosShareRoundedIcon from '@mui/icons-material/IosShareRounded';
|
||||||
import PublicRoundedIcon from '@mui/icons-material/PublicRounded';
|
import PublicRoundedIcon from '@mui/icons-material/PublicRounded';
|
||||||
import LanRoundedIcon from '@mui/icons-material/LanRounded';
|
import LanRoundedIcon from '@mui/icons-material/LanRounded';
|
||||||
import SecurityRoundedIcon from '@mui/icons-material/SecurityRounded';
|
import SecurityRoundedIcon from '@mui/icons-material/SecurityRounded';
|
||||||
@ -27,6 +28,7 @@ type OptionCardKey =
|
|||||||
| 'referral'
|
| 'referral'
|
||||||
| 'referralFraud'
|
| 'referralFraud'
|
||||||
| 'testWallet'
|
| 'testWallet'
|
||||||
|
| 'shareCards'
|
||||||
| 'security'
|
| 'security'
|
||||||
| 'network'
|
| 'network'
|
||||||
| 'faq'
|
| 'faq'
|
||||||
@ -108,6 +110,15 @@ const OPTION_CARDS: OptionCardConfig[] = [
|
|||||||
bg: 'rgba(76,175,80,0.16)',
|
bg: 'rgba(76,175,80,0.16)',
|
||||||
border: 'rgba(76,175,80,0.22)',
|
border: 'rgba(76,175,80,0.22)',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'shareCards',
|
||||||
|
path: '/admin/share-cards',
|
||||||
|
icon: IosShareRoundedIcon,
|
||||||
|
badgeKey: 'dynamic',
|
||||||
|
badgeColor: 'secondary',
|
||||||
|
bg: 'rgba(41,182,246,0.16)',
|
||||||
|
border: 'rgba(41,182,246,0.22)',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: 'security',
|
key: 'security',
|
||||||
path: '/admin/security',
|
path: '/admin/security',
|
||||||
|
|||||||
@ -273,6 +273,13 @@ export function ReferralAdminPage() {
|
|||||||
const anyCommissionMode = predictionOn || depositOn || withdrawalOn;
|
const anyCommissionMode = predictionOn || depositOn || withdrawalOn;
|
||||||
const programOn = Boolean(s?.enabled);
|
const programOn = Boolean(s?.enabled);
|
||||||
const showModeConfig = programOn && anyCommissionMode;
|
const showModeConfig = programOn && anyCommissionMode;
|
||||||
|
/** Pending = hold/auto-settle path used by deposit & withdrawal commissions only. */
|
||||||
|
const showPendingStats = depositOn || withdrawalOn;
|
||||||
|
const reviewQueueLen = reviewQ.data?.items.length ?? 0;
|
||||||
|
const reviewCount = Number(statsQ.data?.referralSummary.reviewCount ?? 0);
|
||||||
|
/** Review queue applies when Sybil can flag any mode (incl. prediction), or leftover items remain. */
|
||||||
|
const showReviewUi =
|
||||||
|
Boolean(s?.sybilDetectionEnabled) || reviewQueueLen > 0 || reviewCount > 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ minWidth: 0 }}>
|
<Box sx={{ minWidth: 0 }}>
|
||||||
@ -927,6 +934,7 @@ export function ReferralAdminPage() {
|
|||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{showReviewUi && (
|
||||||
<Card sx={{ borderRadius: 3, mb: 2 }}>
|
<Card sx={{ borderRadius: 3, mb: 2 }}>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<Typography variant="h6" sx={{ fontWeight: 800, mb: 2 }}>
|
<Typography variant="h6" sx={{ fontWeight: 800, mb: 2 }}>
|
||||||
@ -937,7 +945,7 @@ export function ReferralAdminPage() {
|
|||||||
{t('admin.referralAdmin.reviewLoadError')}
|
{t('admin.referralAdmin.reviewLoadError')}
|
||||||
</Alert>
|
</Alert>
|
||||||
)}
|
)}
|
||||||
{(reviewQ.data?.items.length ?? 0) === 0 ? (
|
{reviewQueueLen === 0 ? (
|
||||||
<Typography variant="body2" color="text.secondary">
|
<Typography variant="body2" color="text.secondary">
|
||||||
{t('admin.referralAdmin.noReview')}
|
{t('admin.referralAdmin.noReview')}
|
||||||
</Typography>
|
</Typography>
|
||||||
@ -1016,6 +1024,7 @@ export function ReferralAdminPage() {
|
|||||||
)}
|
)}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
)}
|
||||||
|
|
||||||
{stats && (
|
{stats && (
|
||||||
<Card sx={{ borderRadius: 3 }}>
|
<Card sx={{ borderRadius: 3 }}>
|
||||||
@ -1031,22 +1040,26 @@ export function ReferralAdminPage() {
|
|||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
<Chip label={t('admin.referralAdmin.payoutEvents', { count: stats.referralSummary.payoutCount })} />
|
<Chip label={t('admin.referralAdmin.payoutEvents', { count: stats.referralSummary.payoutCount })} />
|
||||||
<Chip
|
{showPendingStats && (
|
||||||
label={t('admin.referralAdmin.pending', {
|
<Chip
|
||||||
count: stats.referralSummary.pendingCount,
|
label={t('admin.referralAdmin.pending', {
|
||||||
amount: formatUsdtRaw(stats.referralSummary.pendingCommissions),
|
count: stats.referralSummary.pendingCount,
|
||||||
})}
|
amount: formatUsdtRaw(stats.referralSummary.pendingCommissions),
|
||||||
color="warning"
|
})}
|
||||||
variant="outlined"
|
color="warning"
|
||||||
/>
|
variant="outlined"
|
||||||
<Chip
|
/>
|
||||||
label={t('admin.referralAdmin.review', {
|
)}
|
||||||
count: stats.referralSummary.reviewCount,
|
{showReviewUi && (
|
||||||
amount: formatUsdtRaw(stats.referralSummary.reviewCommissions),
|
<Chip
|
||||||
})}
|
label={t('admin.referralAdmin.review', {
|
||||||
color="error"
|
count: stats.referralSummary.reviewCount,
|
||||||
variant="outlined"
|
amount: formatUsdtRaw(stats.referralSummary.reviewCommissions),
|
||||||
/>
|
})}
|
||||||
|
color="error"
|
||||||
|
variant="outlined"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
<Typography variant="subtitle2" sx={{ fontWeight: 700 }}>
|
<Typography variant="subtitle2" sx={{ fontWeight: 700 }}>
|
||||||
{t('admin.referralAdmin.byCountry')}
|
{t('admin.referralAdmin.byCountry')}
|
||||||
|
|||||||
201
prediqo_web/src/features/share-cards/ShareCardsAdminPage.tsx
Normal file
201
prediqo_web/src/features/share-cards/ShareCardsAdminPage.tsx
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
/**
|
||||||
|
* Admin configuration for Share Cards (prediction result sharing).
|
||||||
|
*/
|
||||||
|
import {
|
||||||
|
Alert,
|
||||||
|
Box,
|
||||||
|
Button,
|
||||||
|
Card,
|
||||||
|
CardContent,
|
||||||
|
Divider,
|
||||||
|
FormControlLabel,
|
||||||
|
Stack,
|
||||||
|
Switch,
|
||||||
|
Typography,
|
||||||
|
} from '@mui/material';
|
||||||
|
import IosShareRoundedIcon from '@mui/icons-material/IosShareRounded';
|
||||||
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { api } from '../../shared/services/api';
|
||||||
|
|
||||||
|
export type ShareCardSettings = {
|
||||||
|
enabled: boolean;
|
||||||
|
allowMainWallet: boolean;
|
||||||
|
allowBonusWallet: boolean;
|
||||||
|
allowTestWallet: boolean;
|
||||||
|
allowWon: boolean;
|
||||||
|
allowLost: boolean;
|
||||||
|
allowRefunded: boolean;
|
||||||
|
updatedAt: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function ShareCardsAdminPage() {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const qc = useQueryClient();
|
||||||
|
const [form, setForm] = useState<ShareCardSettings | null>(null);
|
||||||
|
|
||||||
|
const configQ = useQuery({
|
||||||
|
queryKey: ['admin-share-cards-settings'],
|
||||||
|
queryFn: async () => {
|
||||||
|
const res = await api.get<ShareCardSettings>('/api/v1/admin/share-cards/settings');
|
||||||
|
setForm(res.data);
|
||||||
|
return res.data;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (configQ.data && !form) setForm(configQ.data);
|
||||||
|
}, [configQ.data, form]);
|
||||||
|
|
||||||
|
const saveMut = useMutation({
|
||||||
|
mutationFn: async (body: Partial<ShareCardSettings>) => {
|
||||||
|
const res = await api.patch<ShareCardSettings>('/api/v1/admin/share-cards/settings', body);
|
||||||
|
return res.data;
|
||||||
|
},
|
||||||
|
onSuccess: (data) => {
|
||||||
|
setForm(data);
|
||||||
|
void qc.invalidateQueries({ queryKey: ['admin-share-cards-settings'] });
|
||||||
|
void qc.invalidateQueries({ queryKey: ['share-cards-config'] });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (configQ.isLoading || !form) {
|
||||||
|
return (
|
||||||
|
<Box sx={{ p: 2 }}>
|
||||||
|
<Typography>{t('admin.shareCards.loading')}</Typography>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box sx={{ minWidth: 0 }}>
|
||||||
|
<Stack direction="row" spacing={1.5} sx={{ alignItems: 'center', mb: 2 }}>
|
||||||
|
<IosShareRoundedIcon color="primary" />
|
||||||
|
<Box sx={{ flex: 1 }}>
|
||||||
|
<Typography variant="h4" sx={{ fontWeight: 900 }}>
|
||||||
|
{t('admin.shareCards.title')}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="body2" color="text.secondary">
|
||||||
|
{t('admin.shareCards.subtitle')}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
{configQ.isError && <Alert severity="error" sx={{ mb: 2 }}>{t('admin.shareCards.loadError')}</Alert>}
|
||||||
|
{saveMut.isError && <Alert severity="error" sx={{ mb: 2 }}>{t('admin.shareCards.saveFailed')}</Alert>}
|
||||||
|
{saveMut.isSuccess && <Alert severity="success" sx={{ mb: 2 }}>{t('admin.shareCards.saved')}</Alert>}
|
||||||
|
|
||||||
|
<Card sx={{ borderRadius: 3, mb: 2 }}>
|
||||||
|
<CardContent>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Switch
|
||||||
|
checked={form.enabled}
|
||||||
|
onChange={(e) => setForm({ ...form, enabled: e.target.checked })}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label={t('admin.shareCards.globalEnabled')}
|
||||||
|
/>
|
||||||
|
<Typography variant="caption" color="text.secondary" sx={{ display: 'block', mb: 2 }}>
|
||||||
|
{t('admin.shareCards.globalHelper')}
|
||||||
|
</Typography>
|
||||||
|
|
||||||
|
<Divider sx={{ my: 2 }} />
|
||||||
|
|
||||||
|
<Typography variant="subtitle2" sx={{ fontWeight: 800, mb: 1 }}>
|
||||||
|
{t('admin.shareCards.walletsTitle')}
|
||||||
|
</Typography>
|
||||||
|
<Stack spacing={0.5} sx={{ mb: 2 }}>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Switch
|
||||||
|
checked={form.allowMainWallet}
|
||||||
|
disabled={!form.enabled}
|
||||||
|
onChange={(e) => setForm({ ...form, allowMainWallet: e.target.checked })}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label={t('admin.shareCards.allowMain')}
|
||||||
|
/>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Switch
|
||||||
|
checked={form.allowBonusWallet}
|
||||||
|
disabled={!form.enabled}
|
||||||
|
onChange={(e) => setForm({ ...form, allowBonusWallet: e.target.checked })}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label={t('admin.shareCards.allowBonus')}
|
||||||
|
/>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Switch
|
||||||
|
checked={form.allowTestWallet}
|
||||||
|
disabled={!form.enabled}
|
||||||
|
onChange={(e) => setForm({ ...form, allowTestWallet: e.target.checked })}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label={t('admin.shareCards.allowTest')}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
<Divider sx={{ my: 2 }} />
|
||||||
|
|
||||||
|
<Typography variant="subtitle2" sx={{ fontWeight: 800, mb: 1 }}>
|
||||||
|
{t('admin.shareCards.outcomesTitle')}
|
||||||
|
</Typography>
|
||||||
|
<Stack spacing={0.5} sx={{ mb: 2 }}>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Switch
|
||||||
|
checked={form.allowWon}
|
||||||
|
disabled={!form.enabled}
|
||||||
|
onChange={(e) => setForm({ ...form, allowWon: e.target.checked })}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label={t('admin.shareCards.allowWon')}
|
||||||
|
/>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Switch
|
||||||
|
checked={form.allowLost}
|
||||||
|
disabled={!form.enabled}
|
||||||
|
onChange={(e) => setForm({ ...form, allowLost: e.target.checked })}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label={t('admin.shareCards.allowLost')}
|
||||||
|
/>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Switch
|
||||||
|
checked={form.allowRefunded}
|
||||||
|
disabled={!form.enabled}
|
||||||
|
onChange={(e) => setForm({ ...form, allowRefunded: e.target.checked })}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label={t('admin.shareCards.allowRefunded')}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
disabled={saveMut.isPending}
|
||||||
|
onClick={() =>
|
||||||
|
saveMut.mutate({
|
||||||
|
enabled: form.enabled,
|
||||||
|
allowMainWallet: form.allowMainWallet,
|
||||||
|
allowBonusWallet: form.allowBonusWallet,
|
||||||
|
allowTestWallet: form.allowTestWallet,
|
||||||
|
allowWon: form.allowWon,
|
||||||
|
allowLost: form.allowLost,
|
||||||
|
allowRefunded: form.allowRefunded,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{t('admin.shareCards.save')}
|
||||||
|
</Button>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
60
prediqo_web/src/features/share-cards/ShareResultButton.tsx
Normal file
60
prediqo_web/src/features/share-cards/ShareResultButton.tsx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/**
|
||||||
|
* Icon button that opens Share Card preview when config allows.
|
||||||
|
*/
|
||||||
|
import ShareRoundedIcon from '@mui/icons-material/ShareRounded';
|
||||||
|
import { IconButton, Tooltip } from '@mui/material';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { useShareCardConfig } from './hooks';
|
||||||
|
import { ShareResultDialog } from './ShareResultDialog';
|
||||||
|
import { isShareEligibleClient } from './types';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
betId: string;
|
||||||
|
status?: string | null;
|
||||||
|
stakeAccountKind?: string | null;
|
||||||
|
/** When true (default), status must be won/lost/refunded. Set false for wallet rows. */
|
||||||
|
requireStatus?: boolean;
|
||||||
|
size?: 'small' | 'medium';
|
||||||
|
};
|
||||||
|
|
||||||
|
export function ShareResultButton({
|
||||||
|
betId,
|
||||||
|
status,
|
||||||
|
stakeAccountKind,
|
||||||
|
requireStatus = true,
|
||||||
|
size = 'small',
|
||||||
|
}: Props) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const configQ = useShareCardConfig();
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
|
if (
|
||||||
|
!isShareEligibleClient(configQ.data, {
|
||||||
|
status,
|
||||||
|
stakeAccountKind,
|
||||||
|
requireStatus,
|
||||||
|
})
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Tooltip title={t('shareCard.share')}>
|
||||||
|
<IconButton
|
||||||
|
size={size}
|
||||||
|
color="primary"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
setOpen(true);
|
||||||
|
}}
|
||||||
|
aria-label={t('shareCard.share')}
|
||||||
|
>
|
||||||
|
<ShareRoundedIcon fontSize="inherit" />
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
<ShareResultDialog open={open} betId={betId} onClose={() => setOpen(false)} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
138
prediqo_web/src/features/share-cards/ShareResultCard.tsx
Normal file
138
prediqo_web/src/features/share-cards/ShareResultCard.tsx
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
/**
|
||||||
|
* Visual Share Card for prediction results (exported to PNG for social share).
|
||||||
|
*/
|
||||||
|
import type { Ref } from 'react';
|
||||||
|
import { Box, Stack, Typography } from '@mui/material';
|
||||||
|
import QRCode from 'react-qr-code';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { PrediqoLogo } from '../../shared/brand/PrediqoLogo';
|
||||||
|
import type { ShareCardPayload } from './types';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
payload: ShareCardPayload;
|
||||||
|
cardRef?: Ref<HTMLDivElement>;
|
||||||
|
};
|
||||||
|
|
||||||
|
const OUTCOME_COLOR: Record<ShareCardPayload['status'], string> = {
|
||||||
|
won: '#3DDC97',
|
||||||
|
lost: '#FF6B6B',
|
||||||
|
refunded: '#FFB020',
|
||||||
|
};
|
||||||
|
|
||||||
|
export function ShareResultCard({ payload, cardRef }: Props) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const accent = OUTCOME_COLOR[payload.status];
|
||||||
|
const directionLabel =
|
||||||
|
payload.predictionMode === 'multi_candle' && payload.sequence?.length
|
||||||
|
? payload.sequence.map((d) => t(`shareCard.direction.${d}`)).join(' → ')
|
||||||
|
: t(`shareCard.direction.${payload.direction}`);
|
||||||
|
const settled = new Date(payload.settledAt);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
ref={cardRef}
|
||||||
|
sx={{
|
||||||
|
width: 420,
|
||||||
|
maxWidth: '100%',
|
||||||
|
borderRadius: 3,
|
||||||
|
overflow: 'hidden',
|
||||||
|
background:
|
||||||
|
'linear-gradient(155deg, #0B1220 0%, #142033 45%, #0E1A2B 100%)',
|
||||||
|
border: '1px solid rgba(255,255,255,0.12)',
|
||||||
|
color: '#F5F7FA',
|
||||||
|
p: 2.5,
|
||||||
|
boxSizing: 'border-box',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Stack direction="row" sx={{ justifyContent: 'space-between', alignItems: 'center', mb: 2 }}>
|
||||||
|
<PrediqoLogo variant="wordmark" size={36} wordmarkSx={{ color: '#F5F7FA' }} />
|
||||||
|
<Typography variant="caption" sx={{ opacity: 0.7, fontWeight: 700, letterSpacing: 0.6 }}>
|
||||||
|
{payload.gameName}
|
||||||
|
</Typography>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
<Typography
|
||||||
|
sx={{
|
||||||
|
fontSize: 42,
|
||||||
|
fontWeight: 900,
|
||||||
|
lineHeight: 1.05,
|
||||||
|
color: accent,
|
||||||
|
letterSpacing: 0.5,
|
||||||
|
mb: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{payload.resultSignedDisplay}{' '}
|
||||||
|
<Typography component="span" sx={{ fontSize: 18, fontWeight: 700, opacity: 0.85 }}>
|
||||||
|
USDT
|
||||||
|
</Typography>
|
||||||
|
</Typography>
|
||||||
|
|
||||||
|
<Typography sx={{ fontWeight: 800, color: accent, mb: 2 }}>
|
||||||
|
{t(`shareCard.status.${payload.status}`)}
|
||||||
|
</Typography>
|
||||||
|
|
||||||
|
<Stack spacing={0.75} sx={{ mb: 2.5 }}>
|
||||||
|
<Row label={t('shareCard.prediction')} value={directionLabel} />
|
||||||
|
<Row
|
||||||
|
label={t('shareCard.interval')}
|
||||||
|
value={t('shareCard.intervalValue', { minutes: payload.intervalMinutes })}
|
||||||
|
/>
|
||||||
|
<Row label={t('shareCard.stake')} value={`${payload.stakeDisplay} USDT`} />
|
||||||
|
<Row
|
||||||
|
label={t('shareCard.settledAt')}
|
||||||
|
value={settled.toLocaleString(undefined, {
|
||||||
|
dateStyle: 'medium',
|
||||||
|
timeStyle: 'short',
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
{payload.isAuto ? <Row label={t('shareCard.mode')} value={t('shareCard.modeAuto')} /> : null}
|
||||||
|
{payload.predictionMode === 'multi_candle' ? (
|
||||||
|
<Row label={t('shareCard.mode')} value={t('shareCard.modeMulti')} />
|
||||||
|
) : null}
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
spacing={2}
|
||||||
|
sx={{
|
||||||
|
alignItems: 'center',
|
||||||
|
pt: 1.5,
|
||||||
|
borderTop: '1px solid rgba(255,255,255,0.1)',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
p: 1,
|
||||||
|
borderRadius: 1.5,
|
||||||
|
backgroundColor: '#fff',
|
||||||
|
display: 'grid',
|
||||||
|
placeItems: 'center',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<QRCode value={payload.verifyUrl} size={72} />
|
||||||
|
</Box>
|
||||||
|
<Box sx={{ flex: 1, minWidth: 0 }}>
|
||||||
|
<Typography variant="caption" sx={{ fontWeight: 800, display: 'block' }}>
|
||||||
|
{t('shareCard.verifyTitle')}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="caption" sx={{ opacity: 0.7 }}>
|
||||||
|
{t('shareCard.verifyHint')}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
</Stack>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function Row({ label, value }: { label: string; value: string }) {
|
||||||
|
return (
|
||||||
|
<Stack direction="row" spacing={2} sx={{ justifyContent: 'space-between' }}>
|
||||||
|
<Typography variant="body2" sx={{ opacity: 0.65 }}>
|
||||||
|
{label}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="body2" sx={{ fontWeight: 700, textAlign: 'right' }}>
|
||||||
|
{value}
|
||||||
|
</Typography>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
194
prediqo_web/src/features/share-cards/ShareResultDialog.tsx
Normal file
194
prediqo_web/src/features/share-cards/ShareResultDialog.tsx
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
/**
|
||||||
|
* Preview dialog: load share payload, show card, then share/download PNG.
|
||||||
|
*/
|
||||||
|
import CloseRoundedIcon from '@mui/icons-material/CloseRounded';
|
||||||
|
import DownloadRoundedIcon from '@mui/icons-material/DownloadRounded';
|
||||||
|
import ShareRoundedIcon from '@mui/icons-material/ShareRounded';
|
||||||
|
import {
|
||||||
|
Alert,
|
||||||
|
Box,
|
||||||
|
Button,
|
||||||
|
CircularProgress,
|
||||||
|
Dialog,
|
||||||
|
DialogActions,
|
||||||
|
DialogContent,
|
||||||
|
DialogTitle,
|
||||||
|
IconButton,
|
||||||
|
Stack,
|
||||||
|
Typography,
|
||||||
|
} from '@mui/material';
|
||||||
|
import { toPng } from 'html-to-image';
|
||||||
|
import { useEffect, useRef, useState } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import axios from 'axios';
|
||||||
|
import { copyTextToClipboard } from '../../shared/utils/clipboard';
|
||||||
|
import { fetchShareCardPayload } from './hooks';
|
||||||
|
import { ShareResultCard } from './ShareResultCard';
|
||||||
|
import type { ShareCardPayload } from './types';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
open: boolean;
|
||||||
|
betId: string | null;
|
||||||
|
onClose: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
function errorMessage(e: unknown, fallback: string): string {
|
||||||
|
if (axios.isAxiosError(e)) {
|
||||||
|
const data = e.response?.data as { error?: string } | undefined;
|
||||||
|
if (data?.error) return data.error;
|
||||||
|
}
|
||||||
|
if (e instanceof Error && e.message) return e.message;
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function shareOrDownloadPng(blob: Blob, filename: string, verifyUrl: string): Promise<void> {
|
||||||
|
const file = new File([blob], filename, { type: 'image/png' });
|
||||||
|
const nav = navigator as Navigator & {
|
||||||
|
share?: (data: ShareData) => Promise<void>;
|
||||||
|
canShare?: (data: ShareData) => boolean;
|
||||||
|
};
|
||||||
|
if (nav.share && (!nav.canShare || nav.canShare({ files: [file] }))) {
|
||||||
|
try {
|
||||||
|
await nav.share({
|
||||||
|
files: [file],
|
||||||
|
title: 'Prediqo',
|
||||||
|
text: verifyUrl,
|
||||||
|
url: verifyUrl,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
} catch {
|
||||||
|
/* fall through to download */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.href = url;
|
||||||
|
a.download = filename;
|
||||||
|
a.click();
|
||||||
|
URL.revokeObjectURL(url);
|
||||||
|
await copyTextToClipboard(verifyUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ShareResultDialog({ open, betId, onClose }: Props) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const cardRef = useRef<HTMLDivElement>(null);
|
||||||
|
const [payload, setPayload] = useState<ShareCardPayload | null>(null);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
const [busy, setBusy] = useState(false);
|
||||||
|
const [hint, setHint] = useState<string | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!open || !betId) {
|
||||||
|
setPayload(null);
|
||||||
|
setError(null);
|
||||||
|
setHint(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let cancelled = false;
|
||||||
|
setLoading(true);
|
||||||
|
setError(null);
|
||||||
|
void fetchShareCardPayload(betId)
|
||||||
|
.then((data) => {
|
||||||
|
if (!cancelled) setPayload(data);
|
||||||
|
})
|
||||||
|
.catch((e: unknown) => {
|
||||||
|
if (!cancelled) {
|
||||||
|
setError(errorMessage(e, t('shareCard.loadError')));
|
||||||
|
setPayload(null);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
if (!cancelled) setLoading(false);
|
||||||
|
});
|
||||||
|
return () => {
|
||||||
|
cancelled = true;
|
||||||
|
};
|
||||||
|
}, [open, betId, t]);
|
||||||
|
|
||||||
|
const exportPng = async (share: boolean) => {
|
||||||
|
if (!cardRef.current || !payload) return;
|
||||||
|
setBusy(true);
|
||||||
|
setHint(null);
|
||||||
|
try {
|
||||||
|
const dataUrl = await toPng(cardRef.current, {
|
||||||
|
cacheBust: true,
|
||||||
|
pixelRatio: 2,
|
||||||
|
backgroundColor: '#0B1220',
|
||||||
|
});
|
||||||
|
const res = await fetch(dataUrl);
|
||||||
|
const blob = await res.blob();
|
||||||
|
const filename = `prediqo-${payload.status}-${payload.betId.slice(0, 8)}.png`;
|
||||||
|
if (share) {
|
||||||
|
await shareOrDownloadPng(blob, filename, payload.verifyUrl);
|
||||||
|
setHint(t('shareCard.sharedOrDownloaded'));
|
||||||
|
} else {
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.href = url;
|
||||||
|
a.download = filename;
|
||||||
|
a.click();
|
||||||
|
URL.revokeObjectURL(url);
|
||||||
|
setHint(t('shareCard.downloaded'));
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
setHint(t('shareCard.exportFailed'));
|
||||||
|
} finally {
|
||||||
|
setBusy(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog open={open} onClose={onClose} maxWidth="sm" fullWidth>
|
||||||
|
<DialogTitle sx={{ pr: 6 }}>
|
||||||
|
{t('shareCard.previewTitle')}
|
||||||
|
<IconButton
|
||||||
|
onClick={onClose}
|
||||||
|
sx={{ position: 'absolute', right: 8, top: 8 }}
|
||||||
|
aria-label={t('shareCard.cancel')}
|
||||||
|
>
|
||||||
|
<CloseRoundedIcon />
|
||||||
|
</IconButton>
|
||||||
|
</DialogTitle>
|
||||||
|
<DialogContent>
|
||||||
|
<Typography variant="body2" color="text.secondary" sx={{ mb: 2 }}>
|
||||||
|
{t('shareCard.previewHint')}
|
||||||
|
</Typography>
|
||||||
|
{loading && (
|
||||||
|
<Box sx={{ display: 'grid', placeItems: 'center', py: 6 }}>
|
||||||
|
<CircularProgress size={32} />
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
{error && <Alert severity="error">{error}</Alert>}
|
||||||
|
{payload && (
|
||||||
|
<Stack sx={{ alignItems: 'center' }}>
|
||||||
|
<ShareResultCard payload={payload} cardRef={cardRef} />
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
{hint && (
|
||||||
|
<Alert severity="info" sx={{ mt: 2 }}>
|
||||||
|
{hint}
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions sx={{ px: 3, pb: 2 }}>
|
||||||
|
<Button onClick={onClose}>{t('shareCard.cancel')}</Button>
|
||||||
|
<Button
|
||||||
|
startIcon={<DownloadRoundedIcon />}
|
||||||
|
disabled={!payload || busy}
|
||||||
|
onClick={() => void exportPng(false)}
|
||||||
|
>
|
||||||
|
{t('shareCard.download')}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
startIcon={<ShareRoundedIcon />}
|
||||||
|
disabled={!payload || busy}
|
||||||
|
onClick={() => void exportPng(true)}
|
||||||
|
>
|
||||||
|
{t('shareCard.share')}
|
||||||
|
</Button>
|
||||||
|
</DialogActions>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
101
prediqo_web/src/features/share-cards/ShareResultVerifyPage.tsx
Normal file
101
prediqo_web/src/features/share-cards/ShareResultVerifyPage.tsx
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
/**
|
||||||
|
* Public authenticity page for shared prediction result cards.
|
||||||
|
*/
|
||||||
|
import {
|
||||||
|
Alert,
|
||||||
|
Box,
|
||||||
|
Button,
|
||||||
|
CircularProgress,
|
||||||
|
Paper,
|
||||||
|
Stack,
|
||||||
|
Typography,
|
||||||
|
} from '@mui/material';
|
||||||
|
import { useQuery } from '@tanstack/react-query';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { Link as RouterLink, useParams } from 'react-router-dom';
|
||||||
|
import { PrediqoLogo } from '../../shared/brand/PrediqoLogo';
|
||||||
|
import { api } from '../../shared/services/api';
|
||||||
|
import type { ShareCardVerifyPayload } from './types';
|
||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
|
function errorMessage(e: unknown, fallback: string): string {
|
||||||
|
if (axios.isAxiosError(e)) {
|
||||||
|
const data = e.response?.data as { error?: string } | undefined;
|
||||||
|
if (data?.error) return data.error;
|
||||||
|
}
|
||||||
|
if (e instanceof Error && e.message) return e.message;
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ShareResultVerifyPage() {
|
||||||
|
const { token = '' } = useParams<{ token: string }>();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const q = useQuery({
|
||||||
|
queryKey: ['share-cards-verify', token],
|
||||||
|
enabled: Boolean(token),
|
||||||
|
queryFn: async () => {
|
||||||
|
const res = await api.get<ShareCardVerifyPayload>(
|
||||||
|
`/api/v1/share-cards/verify/${encodeURIComponent(token)}`
|
||||||
|
);
|
||||||
|
return res.data;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
minHeight: '100vh',
|
||||||
|
display: 'grid',
|
||||||
|
placeItems: 'center',
|
||||||
|
px: 2,
|
||||||
|
py: 4,
|
||||||
|
background: 'linear-gradient(160deg, #0B1220 0%, #16253A 100%)',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Paper sx={{ width: '100%', maxWidth: 480, borderRadius: 3, p: 3 }}>
|
||||||
|
<Stack spacing={2} sx={{ alignItems: 'flex-start' }}>
|
||||||
|
<PrediqoLogo variant="wordmark" size={40} />
|
||||||
|
<Typography variant="h5" sx={{ fontWeight: 900 }}>
|
||||||
|
{t('shareCard.verifyPageTitle')}
|
||||||
|
</Typography>
|
||||||
|
|
||||||
|
{q.isLoading && <CircularProgress size={28} />}
|
||||||
|
{q.isError && (
|
||||||
|
<Alert severity="error">
|
||||||
|
{errorMessage(q.error, t('shareCard.verifyInvalid'))}
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
{q.data && (
|
||||||
|
<>
|
||||||
|
<Alert severity="success">{t('shareCard.verifyAuthentic')}</Alert>
|
||||||
|
<Typography sx={{ fontSize: 36, fontWeight: 900 }}>
|
||||||
|
{q.data.resultSignedDisplay} USDT
|
||||||
|
</Typography>
|
||||||
|
<Typography sx={{ fontWeight: 700 }}>
|
||||||
|
{t(`shareCard.status.${q.data.status}`)} · {q.data.gameName}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="body2" color="text.secondary">
|
||||||
|
{t(`shareCard.direction.${q.data.direction}`)} ·{' '}
|
||||||
|
{t('shareCard.intervalValue', { minutes: q.data.intervalMinutes })} ·{' '}
|
||||||
|
{new Date(q.data.settledAt).toLocaleString()}
|
||||||
|
</Typography>
|
||||||
|
<Button
|
||||||
|
component={RouterLink}
|
||||||
|
to={
|
||||||
|
q.data.referralCode
|
||||||
|
? `/register?ref=${encodeURIComponent(q.data.referralCode)}`
|
||||||
|
: '/register'
|
||||||
|
}
|
||||||
|
variant="contained"
|
||||||
|
fullWidth
|
||||||
|
>
|
||||||
|
{t('shareCard.joinCta')}
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
</Paper>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
20
prediqo_web/src/features/share-cards/hooks.ts
Normal file
20
prediqo_web/src/features/share-cards/hooks.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { useQuery } from '@tanstack/react-query';
|
||||||
|
import { api } from '../../shared/services/api';
|
||||||
|
import type { ShareCardConfig, ShareCardPayload } from './types';
|
||||||
|
|
||||||
|
export function useShareCardConfig(enabled = true) {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ['share-cards-config'],
|
||||||
|
enabled,
|
||||||
|
staleTime: 60_000,
|
||||||
|
queryFn: async () => {
|
||||||
|
const res = await api.get<ShareCardConfig>('/api/v1/share-cards/config');
|
||||||
|
return res.data;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchShareCardPayload(betId: string): Promise<ShareCardPayload> {
|
||||||
|
const res = await api.get<ShareCardPayload>(`/api/v1/share-cards/bets/${betId}`);
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
72
prediqo_web/src/features/share-cards/types.ts
Normal file
72
prediqo_web/src/features/share-cards/types.ts
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
export type ShareCardConfig = {
|
||||||
|
enabled: boolean;
|
||||||
|
allowMainWallet: boolean;
|
||||||
|
allowBonusWallet: boolean;
|
||||||
|
allowTestWallet: boolean;
|
||||||
|
allowWon: boolean;
|
||||||
|
allowLost: boolean;
|
||||||
|
allowRefunded: boolean;
|
||||||
|
updatedAt?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ShareCardPayload = {
|
||||||
|
betId: string;
|
||||||
|
gameName: string;
|
||||||
|
direction: 'short' | 'long';
|
||||||
|
sequence: ('short' | 'long')[] | null;
|
||||||
|
multiLevel: number | null;
|
||||||
|
predictionMode: string;
|
||||||
|
isAuto: boolean;
|
||||||
|
status: 'won' | 'lost' | 'refunded';
|
||||||
|
stakeDisplay: number;
|
||||||
|
stakeRaw: string;
|
||||||
|
payoutRaw: string;
|
||||||
|
resultSignedDisplay: string;
|
||||||
|
resultRaw: string;
|
||||||
|
pnlSign: '+' | '-' | '';
|
||||||
|
intervalMinutes: number;
|
||||||
|
stakeAccountKind: 'main' | 'bonus' | 'test';
|
||||||
|
settledAt: string;
|
||||||
|
verifyUrl: string;
|
||||||
|
verifyToken: string;
|
||||||
|
referralCode: string | null;
|
||||||
|
registerUrl: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ShareCardVerifyPayload = {
|
||||||
|
authentic: true;
|
||||||
|
gameName: string;
|
||||||
|
direction: 'short' | 'long';
|
||||||
|
sequence: ('short' | 'long')[] | null;
|
||||||
|
multiLevel: number | null;
|
||||||
|
predictionMode: string;
|
||||||
|
status: 'won' | 'lost' | 'refunded';
|
||||||
|
resultSignedDisplay: string;
|
||||||
|
stakeDisplay: number;
|
||||||
|
intervalMinutes: number;
|
||||||
|
settledAt: string;
|
||||||
|
registerUrl: string;
|
||||||
|
referralCode: string | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function isShareEligibleClient(
|
||||||
|
config: ShareCardConfig | null | undefined,
|
||||||
|
input: { stakeAccountKind?: string | null; status?: string | null; requireStatus?: boolean }
|
||||||
|
): boolean {
|
||||||
|
if (!config?.enabled) return false;
|
||||||
|
const kind = input.stakeAccountKind ?? 'main';
|
||||||
|
if (kind === 'main' && !config.allowMainWallet) return false;
|
||||||
|
if (kind === 'bonus' && !config.allowBonusWallet) return false;
|
||||||
|
if (kind === 'test' && !config.allowTestWallet) return false;
|
||||||
|
|
||||||
|
const status = input.status;
|
||||||
|
if (!status) {
|
||||||
|
// Wallet activity may not know outcome yet; allow button if wallets pass.
|
||||||
|
return input.requireStatus === false;
|
||||||
|
}
|
||||||
|
if (status !== 'won' && status !== 'lost' && status !== 'refunded') return false;
|
||||||
|
if (status === 'won' && !config.allowWon) return false;
|
||||||
|
if (status === 'lost' && !config.allowLost) return false;
|
||||||
|
if (status === 'refunded' && !config.allowRefunded) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
@ -23,6 +23,7 @@ import type { BalanceEntry, WalletTransaction } from '../types';
|
|||||||
import { coinColors, coinSymbol } from '../utils/coinDisplay';
|
import { coinColors, coinSymbol } from '../utils/coinDisplay';
|
||||||
import { isCredit, txLabel, txStatusLabel } from '../utils/transactionDisplay';
|
import { isCredit, txLabel, txStatusLabel } from '../utils/transactionDisplay';
|
||||||
import { rawToHuman, shortSymbol } from '../utils/walletFormat';
|
import { rawToHuman, shortSymbol } from '../utils/walletFormat';
|
||||||
|
import { ShareResultButton } from '../../share-cards/ShareResultButton';
|
||||||
|
|
||||||
type TransactionListProps = {
|
type TransactionListProps = {
|
||||||
transactions: WalletTransaction[];
|
transactions: WalletTransaction[];
|
||||||
@ -36,6 +37,27 @@ type TransactionListProps = {
|
|||||||
emptyHint?: string;
|
emptyHint?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function predictionShareMeta(tx: WalletTransaction): {
|
||||||
|
betId: string;
|
||||||
|
status?: 'won' | 'lost' | 'refunded';
|
||||||
|
stakeAccountKind?: string;
|
||||||
|
} | null {
|
||||||
|
const betId = tx.metadata?.bet_id;
|
||||||
|
if (!betId) return null;
|
||||||
|
if (tx.type !== 'game_stake' && tx.type !== 'game_payout' && tx.type !== 'game_refund') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const stakeAccountKind = tx.metadata?.stake_account_kind;
|
||||||
|
if (tx.type === 'game_payout') {
|
||||||
|
return { betId, status: 'won', stakeAccountKind };
|
||||||
|
}
|
||||||
|
if (tx.type === 'game_refund') {
|
||||||
|
return { betId, status: 'refunded', stakeAccountKind };
|
||||||
|
}
|
||||||
|
// Stake row: outcome unknown until settle (lost has no payout row).
|
||||||
|
return { betId, stakeAccountKind };
|
||||||
|
}
|
||||||
|
|
||||||
/** Maps wallet_type_id to wallet type metadata for display. */
|
/** Maps wallet_type_id to wallet type metadata for display. */
|
||||||
function walletTypeById(
|
function walletTypeById(
|
||||||
balances: BalanceEntry[],
|
balances: BalanceEntry[],
|
||||||
@ -109,6 +131,7 @@ export function TransactionList({
|
|||||||
<TableCell align="right">{t('common.amount')}</TableCell>
|
<TableCell align="right">{t('common.amount')}</TableCell>
|
||||||
<TableCell>{t('common.status')}</TableCell>
|
<TableCell>{t('common.status')}</TableCell>
|
||||||
<TableCell>{t('common.date')}</TableCell>
|
<TableCell>{t('common.date')}</TableCell>
|
||||||
|
<TableCell sx={{ width: 48 }} />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHead>
|
</TableHead>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
@ -119,6 +142,7 @@ export function TransactionList({
|
|||||||
const credit = isCredit(tx);
|
const credit = isCredit(tx);
|
||||||
const [c1, c2] = coinColors(code);
|
const [c1, c2] = coinColors(code);
|
||||||
const human = rawToHuman(tx.amount, decimals);
|
const human = rawToHuman(tx.amount, decimals);
|
||||||
|
const share = predictionShareMeta(tx);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow key={tx.id} hover>
|
<TableRow key={tx.id} hover>
|
||||||
@ -175,6 +199,16 @@ export function TransactionList({
|
|||||||
{dayjs(tx.created_at).format('YYYY-MM-DD HH:mm')}
|
{dayjs(tx.created_at).format('YYYY-MM-DD HH:mm')}
|
||||||
</Typography>
|
</Typography>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
{share ? (
|
||||||
|
<ShareResultButton
|
||||||
|
betId={share.betId}
|
||||||
|
status={share.status}
|
||||||
|
stakeAccountKind={share.stakeAccountKind}
|
||||||
|
requireStatus={Boolean(share.status)}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@ -57,9 +57,16 @@ export type WalletTransaction = {
|
|||||||
confirmations: number;
|
confirmations: number;
|
||||||
required_confirmations: number;
|
required_confirmations: number;
|
||||||
metadata: {
|
metadata: {
|
||||||
direction?: 'in' | 'out';
|
direction?: 'in' | 'out' | 'short' | 'long';
|
||||||
to_user_id?: string;
|
to_user_id?: string;
|
||||||
reference?: string;
|
reference?: string;
|
||||||
|
bet_id?: string;
|
||||||
|
stake_account_kind?: 'main' | 'bonus' | 'test';
|
||||||
|
outcome?: string;
|
||||||
|
round_id?: string;
|
||||||
|
candle_open_ms?: number;
|
||||||
|
interval_minutes?: number;
|
||||||
|
prediction_mode?: string;
|
||||||
} | null;
|
} | null;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
updated_at: string;
|
updated_at: string;
|
||||||
|
|||||||
@ -214,6 +214,40 @@ export const en = {
|
|||||||
playNow: 'Play now',
|
playNow: 'Play now',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
shareCard: {
|
||||||
|
share: 'Share result',
|
||||||
|
cancel: 'Cancel',
|
||||||
|
download: 'Download',
|
||||||
|
previewTitle: 'Share card preview',
|
||||||
|
previewHint: 'Review your card before sharing. Sharing is only available after this preview.',
|
||||||
|
loadError: 'Unable to load this result for sharing.',
|
||||||
|
downloaded: 'Card downloaded.',
|
||||||
|
sharedOrDownloaded: 'Shared (or downloaded). Verify link copied when possible.',
|
||||||
|
exportFailed: 'Could not export the card image.',
|
||||||
|
prediction: 'Prediction',
|
||||||
|
interval: 'Interval',
|
||||||
|
intervalValue: '{{minutes}} min',
|
||||||
|
stake: 'Stake',
|
||||||
|
settledAt: 'Settled',
|
||||||
|
mode: 'Mode',
|
||||||
|
modeAuto: 'Auto',
|
||||||
|
modeMulti: 'Multi-candle',
|
||||||
|
verifyTitle: 'Scan to verify',
|
||||||
|
verifyHint: 'Authentic Prediqo result',
|
||||||
|
verifyPageTitle: 'Verified prediction result',
|
||||||
|
verifyAuthentic: 'This Prediqo result is authentic.',
|
||||||
|
verifyInvalid: 'This share link is invalid or no longer available.',
|
||||||
|
joinCta: 'Join Prediqo',
|
||||||
|
status: {
|
||||||
|
won: 'Won',
|
||||||
|
lost: 'Lost',
|
||||||
|
refunded: 'Refunded',
|
||||||
|
},
|
||||||
|
direction: {
|
||||||
|
short: 'Short',
|
||||||
|
long: 'Long',
|
||||||
|
},
|
||||||
|
},
|
||||||
wallet: {
|
wallet: {
|
||||||
title: 'Wallet',
|
title: 'Wallet',
|
||||||
subtitle:
|
subtitle:
|
||||||
@ -870,6 +904,10 @@ export const en = {
|
|||||||
title: 'Test wallet',
|
title: 'Test wallet',
|
||||||
description: 'Credit amounts, request limits, cooldowns, and grant history for practice play.',
|
description: 'Credit amounts, request limits, cooldowns, and grant history for practice play.',
|
||||||
},
|
},
|
||||||
|
shareCards: {
|
||||||
|
title: 'Share Cards',
|
||||||
|
description: 'Allow players to share prediction results with preview cards and authenticity QR.',
|
||||||
|
},
|
||||||
security: {
|
security: {
|
||||||
title: 'Security',
|
title: 'Security',
|
||||||
description: 'Integrity checks, security alerts, in-app notifications, and approved ledger credits.',
|
description: 'Integrity checks, security alerts, in-app notifications, and approved ledger credits.',
|
||||||
@ -1671,6 +1709,26 @@ export const en = {
|
|||||||
amount: 'Amount',
|
amount: 'Amount',
|
||||||
noHistory: 'No test credits granted yet.',
|
noHistory: 'No test credits granted yet.',
|
||||||
},
|
},
|
||||||
|
shareCards: {
|
||||||
|
title: 'Share Cards',
|
||||||
|
subtitle:
|
||||||
|
'Control which prediction results players can share as social cards with an authenticity QR.',
|
||||||
|
loading: 'Loading Share Card settings…',
|
||||||
|
loadError: 'Failed to load Share Card settings.',
|
||||||
|
globalEnabled: 'Enable Share Cards',
|
||||||
|
globalHelper: 'When off, share buttons are hidden everywhere.',
|
||||||
|
walletsTitle: 'Allowed stake wallets',
|
||||||
|
allowMain: 'Main wallet',
|
||||||
|
allowBonus: 'Bonus wallet',
|
||||||
|
allowTest: 'Test wallet',
|
||||||
|
outcomesTitle: 'Allowed outcomes',
|
||||||
|
allowWon: 'Won',
|
||||||
|
allowLost: 'Lost',
|
||||||
|
allowRefunded: 'Refunded (neutral)',
|
||||||
|
save: 'Save settings',
|
||||||
|
saveFailed: 'Save failed',
|
||||||
|
saved: 'Settings saved.',
|
||||||
|
},
|
||||||
network: {
|
network: {
|
||||||
title: 'Network & environment',
|
title: 'Network & environment',
|
||||||
subtitle:
|
subtitle:
|
||||||
@ -1691,7 +1749,7 @@ export const en = {
|
|||||||
referredVerified: 'Referred user must have verified email (before payout)',
|
referredVerified: 'Referred user must have verified email (before payout)',
|
||||||
commissionHold: 'Commission hold (days)',
|
commissionHold: 'Commission hold (days)',
|
||||||
commissionHoldHelper:
|
commissionHoldHelper:
|
||||||
'Delay after first deposit / withdrawal before legacy commissions can be paid (prediction commissions pay immediately)',
|
'Delay after first deposit / withdrawal before legacy commissions can be paid (prediction commissions pay immediately on win/loss settle)',
|
||||||
minPredictions: 'Min real-money predictions (referred user, legacy hold settlement)',
|
minPredictions: 'Min real-money predictions (referred user, legacy hold settlement)',
|
||||||
maxPendingDays: 'Max pending days',
|
maxPendingDays: 'Max pending days',
|
||||||
maxPendingHelper: 'Expire unpaid commissions if eligibility is still not met',
|
maxPendingHelper: 'Expire unpaid commissions if eligibility is still not met',
|
||||||
@ -1700,12 +1758,12 @@ export const en = {
|
|||||||
'Enable one or more modes. Mode-specific settings appear below only when that mode is on. You can switch modes anytime without reimplementing logic.',
|
'Enable one or more modes. Mode-specific settings appear below only when that mode is on. You can switch modes anytime without reimplementing logic.',
|
||||||
noModeSelected:
|
noModeSelected:
|
||||||
'No commission mode is enabled. Turn on Prediction, Deposit, and/or Withdrawal to configure payouts.',
|
'No commission mode is enabled. Turn on Prediction, Deposit, and/or Withdrawal to configure payouts.',
|
||||||
predictionCommissions: 'Prediction commissions (on stake at place)',
|
predictionCommissions: 'Prediction commissions (on stake when settled win/loss)',
|
||||||
depositCommissions: 'Deposit commissions (legacy — first deposit of referred users)',
|
depositCommissions: 'Deposit commissions (legacy — first deposit of referred users)',
|
||||||
withdrawalCommissions: 'Withdrawal commissions (legacy — prediction gains from main account only)',
|
withdrawalCommissions: 'Withdrawal commissions (legacy — prediction gains from main account only)',
|
||||||
predictionSectionTitle: 'Prediction mode settings',
|
predictionSectionTitle: 'Prediction mode settings',
|
||||||
predictionSectionHelper:
|
predictionSectionHelper:
|
||||||
'Commission = % of the referred user’s stake at place (main/bonus). Paid immediately to the referrer bonus wallet after Sybil / caps / pool checks. Test stakes are excluded. Win/lose/refund do not change the amount. Hold days and min predictions do not apply.',
|
'Commission = % of the referred user’s stake, credited only when the prediction settles as won or lost (not on neutral/refund). Paid immediately to the referrer bonus wallet after Sybil / caps / pool checks. Test stakes are excluded. Hold days and min predictions do not apply.',
|
||||||
depositSectionTitle: 'Deposit mode settings',
|
depositSectionTitle: 'Deposit mode settings',
|
||||||
depositSectionHelper:
|
depositSectionHelper:
|
||||||
'Commission = % of the referred user’s first qualifying deposit. Held until eligibility (predictions + hold days), then paid to the referrer bonus wallet.',
|
'Commission = % of the referred user’s first qualifying deposit. Held until eligibility (predictions + hold days), then paid to the referrer bonus wallet.',
|
||||||
|
|||||||
@ -220,6 +220,41 @@ export const fr = {
|
|||||||
playNow: 'Jouer',
|
playNow: 'Jouer',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
shareCard: {
|
||||||
|
share: 'Partager le résultat',
|
||||||
|
cancel: 'Annuler',
|
||||||
|
download: 'Télécharger',
|
||||||
|
previewTitle: 'Aperçu de la carte',
|
||||||
|
previewHint:
|
||||||
|
'Vérifiez votre carte avant de partager. Le partage n’est possible qu’après cet aperçu.',
|
||||||
|
loadError: 'Impossible de charger ce résultat pour le partage.',
|
||||||
|
downloaded: 'Carte téléchargée.',
|
||||||
|
sharedOrDownloaded: 'Partagé (ou téléchargé). Lien de vérification copié si possible.',
|
||||||
|
exportFailed: 'Impossible d’exporter l’image de la carte.',
|
||||||
|
prediction: 'Prédiction',
|
||||||
|
interval: 'Intervalle',
|
||||||
|
intervalValue: '{{minutes}} min',
|
||||||
|
stake: 'Mise',
|
||||||
|
settledAt: 'Validé le',
|
||||||
|
mode: 'Mode',
|
||||||
|
modeAuto: 'Auto',
|
||||||
|
modeMulti: 'Multi-bougies',
|
||||||
|
verifyTitle: 'Scanner pour vérifier',
|
||||||
|
verifyHint: 'Résultat Prediqo authentique',
|
||||||
|
verifyPageTitle: 'Résultat de prédiction vérifié',
|
||||||
|
verifyAuthentic: 'Ce résultat Prediqo est authentique.',
|
||||||
|
verifyInvalid: 'Ce lien de partage est invalide ou n’est plus disponible.',
|
||||||
|
joinCta: 'Rejoindre Prediqo',
|
||||||
|
status: {
|
||||||
|
won: 'Gagné',
|
||||||
|
lost: 'Perdu',
|
||||||
|
refunded: 'Remboursé',
|
||||||
|
},
|
||||||
|
direction: {
|
||||||
|
short: 'Short',
|
||||||
|
long: 'Long',
|
||||||
|
},
|
||||||
|
},
|
||||||
wallet: {
|
wallet: {
|
||||||
title: 'Portefeuille',
|
title: 'Portefeuille',
|
||||||
subtitle:
|
subtitle:
|
||||||
@ -883,6 +918,11 @@ export const fr = {
|
|||||||
title: 'Wallet de test',
|
title: 'Wallet de test',
|
||||||
description: 'Montants de crédit, limites de demande, délais et historique pour le jeu d’essai.',
|
description: 'Montants de crédit, limites de demande, délais et historique pour le jeu d’essai.',
|
||||||
},
|
},
|
||||||
|
shareCards: {
|
||||||
|
title: 'Share Cards',
|
||||||
|
description:
|
||||||
|
'Autoriser les joueurs à partager leurs résultats de prédiction avec carte et QR d’authenticité.',
|
||||||
|
},
|
||||||
security: {
|
security: {
|
||||||
title: 'Sécurité',
|
title: 'Sécurité',
|
||||||
description: 'Contrôles d’intégrité, alertes sécurité, notifications in-app et crédits grand livre approuvés.',
|
description: 'Contrôles d’intégrité, alertes sécurité, notifications in-app et crédits grand livre approuvés.',
|
||||||
@ -1685,6 +1725,26 @@ export const fr = {
|
|||||||
amount: 'Montant',
|
amount: 'Montant',
|
||||||
noHistory: 'Aucun crédit de test accordé pour l’instant.',
|
noHistory: 'Aucun crédit de test accordé pour l’instant.',
|
||||||
},
|
},
|
||||||
|
shareCards: {
|
||||||
|
title: 'Share Cards',
|
||||||
|
subtitle:
|
||||||
|
'Contrôlez quels résultats de prédiction les joueurs peuvent partager avec une carte et un QR d’authenticité.',
|
||||||
|
loading: 'Chargement des paramètres Share Cards…',
|
||||||
|
loadError: 'Impossible de charger les paramètres Share Cards.',
|
||||||
|
globalEnabled: 'Activer les Share Cards',
|
||||||
|
globalHelper: 'Si désactivé, les boutons de partage sont masqués partout.',
|
||||||
|
walletsTitle: 'Wallets de mise autorisés',
|
||||||
|
allowMain: 'Wallet principal',
|
||||||
|
allowBonus: 'Wallet bonus',
|
||||||
|
allowTest: 'Wallet de test',
|
||||||
|
outcomesTitle: 'Résultats autorisés',
|
||||||
|
allowWon: 'Gagné',
|
||||||
|
allowLost: 'Perdu',
|
||||||
|
allowRefunded: 'Remboursé (neutre)',
|
||||||
|
save: 'Enregistrer les paramètres',
|
||||||
|
saveFailed: 'Échec de l’enregistrement',
|
||||||
|
saved: 'Paramètres enregistrés.',
|
||||||
|
},
|
||||||
network: {
|
network: {
|
||||||
title: 'Réseau & environnement',
|
title: 'Réseau & environnement',
|
||||||
subtitle:
|
subtitle:
|
||||||
@ -1705,7 +1765,7 @@ export const fr = {
|
|||||||
referredVerified: 'Le filleul doit avoir un e-mail vérifié (avant paiement)',
|
referredVerified: 'Le filleul doit avoir un e-mail vérifié (avant paiement)',
|
||||||
commissionHold: 'Délai de rétention commission (jours)',
|
commissionHold: 'Délai de rétention commission (jours)',
|
||||||
commissionHoldHelper:
|
commissionHoldHelper:
|
||||||
'Délai après le premier dépôt / retrait avant paiement des commissions legacy (les commissions prédiction sont payées immédiatement)',
|
'Délai après le premier dépôt / retrait avant paiement des commissions legacy (les commissions prédiction sont payées immédiatement au règlement gain/perte)',
|
||||||
minPredictions: 'Prédictions argent réel min (filleul, règlement hold legacy)',
|
minPredictions: 'Prédictions argent réel min (filleul, règlement hold legacy)',
|
||||||
maxPendingDays: 'Jours max en attente',
|
maxPendingDays: 'Jours max en attente',
|
||||||
maxPendingHelper: 'Expirer les commissions impayées si l’éligibilité n’est toujours pas atteinte',
|
maxPendingHelper: 'Expirer les commissions impayées si l’éligibilité n’est toujours pas atteinte',
|
||||||
@ -1714,12 +1774,12 @@ export const fr = {
|
|||||||
'Activez un ou plusieurs modes. Les paramètres propres à un mode n’apparaissent que s’il est activé. Vous pouvez changer de mode à tout moment.',
|
'Activez un ou plusieurs modes. Les paramètres propres à un mode n’apparaissent que s’il est activé. Vous pouvez changer de mode à tout moment.',
|
||||||
noModeSelected:
|
noModeSelected:
|
||||||
'Aucun mode de commission n’est activé. Activez Prédiction, Dépôt et/ou Retrait pour configurer les paiements.',
|
'Aucun mode de commission n’est activé. Activez Prédiction, Dépôt et/ou Retrait pour configurer les paiements.',
|
||||||
predictionCommissions: 'Commissions sur prédiction (sur la mise à la place)',
|
predictionCommissions: 'Commissions sur prédiction (sur la mise au règlement gain/perte)',
|
||||||
depositCommissions: 'Commissions sur dépôt (legacy — premier dépôt des filleuls)',
|
depositCommissions: 'Commissions sur dépôt (legacy — premier dépôt des filleuls)',
|
||||||
withdrawalCommissions: 'Commissions sur retrait (legacy — gains prédictions compte principal uniquement)',
|
withdrawalCommissions: 'Commissions sur retrait (legacy — gains prédictions compte principal uniquement)',
|
||||||
predictionSectionTitle: 'Paramètres du mode prédiction',
|
predictionSectionTitle: 'Paramètres du mode prédiction',
|
||||||
predictionSectionHelper:
|
predictionSectionHelper:
|
||||||
'Commission = % de la mise du filleul à la place (principal/bonus). Crédit immédiat sur le wallet bonus du parrain après contrôles Sybil / plafonds / pool. Les mises test sont exclues. Win/lose/refund ne changent pas le montant. Délai de rétention et min. prédictions ne s’appliquent pas.',
|
'Commission = % de la mise du filleul, créditée uniquement si la prédiction se règle en gagné ou perdu (pas en neutre/remboursement). Crédit immédiat sur le wallet bonus du parrain après contrôles Sybil / plafonds / pool. Les mises test sont exclues. Délai de rétention et min. prédictions ne s’appliquent pas.',
|
||||||
depositSectionTitle: 'Paramètres du mode dépôt',
|
depositSectionTitle: 'Paramètres du mode dépôt',
|
||||||
depositSectionHelper:
|
depositSectionHelper:
|
||||||
'Commission = % du premier dépôt éligible du filleul. Mise en attente jusqu’à éligibilité (prédictions + délai), puis crédit sur le wallet bonus du parrain.',
|
'Commission = % du premier dépôt éligible du filleul. Mise en attente jusqu’à éligibilité (prédictions + délai), puis crédit sur le wallet bonus du parrain.',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user