games_app/backend/dist-test-faq/services/shareCardService.d.ts

230 lines
7.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Share Cards: eligibility, signed verify tokens, and share payloads
* for prediction results and wallet operations (deposit / withdrawal / transfer).
*/
import * as candlePredictRepository from '../repositories/candlePredictRepository';
import type { ShareCardSettingsRow } from '../repositories/shareCardRepository';
export type ShareableBetStatus = 'won' | 'lost' | 'refunded';
export type StakeAccountKind = 'main' | 'bonus' | 'test';
export type ShareableWalletOpType = 'deposit' | 'withdrawal' | 'transfer' | 'bonus' | 'admin_adjustment';
export declare function mapSettingsForClient(row: ShareCardSettingsRow, extras?: {
hasDeposited?: boolean;
}): {
enabled: boolean;
allowMainWallet: boolean;
allowBonusWallet: boolean;
allowTestWallet: boolean;
allowWon: boolean;
allowLost: boolean;
allowRefunded: boolean;
walletOpsEnabled: boolean;
allowDeposit: boolean;
allowWithdrawal: boolean;
allowTransfer: boolean;
testWalletShareRequiresRealDeposit: boolean;
referrerMustHaveDeposited: boolean;
hasDeposited: boolean;
updatedAt: string;
};
/** Ledger row used to decide whether a user has ever deposited real funds. */
export type LedgerActivityRow = {
type: string;
status: string;
};
/**
* A real-funds deposit is a ledger `deposit` that reached `completed`.
* Test-wallet credits, bonus grants, admin adjustments, pending/failed
* deposits, and the current Main Wallet balance are ignored.
*/
export declare function isConfirmedRealDeposit(tx: LedgerActivityRow): boolean;
export declare function hasConfirmedRealDeposit(history: LedgerActivityRow[]): boolean;
export declare function canSharePredictionResult(settings: ShareCardSettingsRow, input: {
stakeAccountKind: StakeAccountKind;
status: string;
testWalletShareRequiresRealDeposit?: boolean;
hasDeposited?: boolean;
}): boolean;
export declare function canShareWalletOperation(settings: ShareCardSettingsRow, input: {
type: string;
}): boolean;
/**
* Amount shown on share cards — matches Wallet/Recent Predictions UI:
* - won: full payout (stake + profit), e.g. +9.5
* - lost: −stake
* - refunded: +payout when stake is returned, else 0
*/
export declare function computeResultAmount(status: ShareableBetStatus, stakeRaw: bigint, payoutRaw: bigint): {
resultSignedDisplay: string;
resultRaw: string;
pnlSign: '+' | '-' | '';
};
export type ShareTokenKind = 'bet' | 'tx';
export declare function createShareVerifyToken(kind: ShareTokenKind, resourceId: string, userId: string): string;
/** @deprecated Prefer createShareVerifyToken('bet', ...) — kept for call-site clarity. */
export declare function createBetShareVerifyToken(betId: string, userId: string): string;
export declare function parseShareVerifyToken(token: string): {
kind: ShareTokenKind;
id: string;
userId: string;
} | null;
export declare function buildShareVerifyUrl(token: string): string;
export declare function getConfigForUser(userId: string): Promise<{
enabled: boolean;
allowMainWallet: boolean;
allowBonusWallet: boolean;
allowTestWallet: boolean;
allowWon: boolean;
allowLost: boolean;
allowRefunded: boolean;
walletOpsEnabled: boolean;
allowDeposit: boolean;
allowWithdrawal: boolean;
allowTransfer: boolean;
testWalletShareRequiresRealDeposit: boolean;
referrerMustHaveDeposited: boolean;
hasDeposited: boolean;
updatedAt: string;
}>;
export declare function getSettingsForAdmin(): Promise<{
enabled: boolean;
allowMainWallet: boolean;
allowBonusWallet: boolean;
allowTestWallet: boolean;
allowWon: boolean;
allowLost: boolean;
allowRefunded: boolean;
walletOpsEnabled: boolean;
allowDeposit: boolean;
allowWithdrawal: boolean;
allowTransfer: boolean;
testWalletShareRequiresRealDeposit: boolean;
referrerMustHaveDeposited: boolean;
hasDeposited: boolean;
updatedAt: string;
}>;
export declare function updateSettings(input: {
enabled?: boolean;
allowMainWallet?: boolean;
allowBonusWallet?: boolean;
allowTestWallet?: boolean;
allowWon?: boolean;
allowLost?: boolean;
allowRefunded?: boolean;
walletOpsEnabled?: boolean;
allowDeposit?: boolean;
allowWithdrawal?: boolean;
allowTransfer?: boolean;
testWalletShareRequiresRealDeposit?: boolean;
}): Promise<{
enabled: boolean;
allowMainWallet: boolean;
allowBonusWallet: boolean;
allowTestWallet: boolean;
allowWon: boolean;
allowLost: boolean;
allowRefunded: boolean;
walletOpsEnabled: boolean;
allowDeposit: boolean;
allowWithdrawal: boolean;
allowTransfer: boolean;
testWalletShareRequiresRealDeposit: boolean;
referrerMustHaveDeposited: boolean;
hasDeposited: boolean;
updatedAt: string;
}>;
export declare class ShareCardError extends Error {
status: number;
constructor(message: string, status?: number);
}
export declare function getSharePayloadForOwner(userId: string, betId: string): Promise<{
kind: "prediction";
betId: string;
gameName: string;
direction: "short" | "long";
sequence: ("short" | "long")[] | null;
multiLevel: number | null;
predictionMode: candlePredictRepository.PredictionMode;
isAuto: boolean;
status: ShareableBetStatus;
stakeDisplay: number;
stakeRaw: string;
payoutRaw: string;
resultSignedDisplay: string;
resultRaw: string;
pnlSign: "" | "-" | "+";
intervalMinutes: number;
stakeAccountKind: "test" | "main" | "bonus";
settledAt: string;
verifyUrl: string;
verifyToken: string;
referralCode: string | null;
registerUrl: string;
}>;
export declare function getWalletOpSharePayloadForOwner(userId: string, transactionId: string): Promise<{
kind: "wallet";
transactionId: string;
operationType: ShareableWalletOpType;
status: "pending" | "pending_approval" | "broadcasting" | "confirming" | "completed" | "failed" | "ledger_finalize_failed";
amountRaw: string;
amountDisplay: string;
amountSignedDisplay: string;
feeRaw: string;
assetCode: string;
assetSymbol: string;
assetName: string;
network: string | null;
createdAt: string;
blockchainTxId: string | null;
verifyUrl: string;
verifyToken: string;
referralCode: string | null;
registerUrl: string;
}>;
export declare function getPublicVerifyPayload(token: string): Promise<{
authentic: true;
kind: "wallet";
operationType: ShareableWalletOpType;
status: "pending" | "pending_approval" | "broadcasting" | "confirming" | "completed" | "failed" | "ledger_finalize_failed";
amountSignedDisplay: string;
amountDisplay: string;
assetSymbol: string;
assetCode: string;
network: string | null;
createdAt: string;
registerUrl: string;
referralCode: string | null;
gameName?: undefined;
direction?: undefined;
sequence?: undefined;
multiLevel?: undefined;
predictionMode?: undefined;
isAuto?: undefined;
resultSignedDisplay?: undefined;
stakeDisplay?: undefined;
intervalMinutes?: undefined;
settledAt?: undefined;
} | {
authentic: true;
kind: "prediction";
gameName: string;
direction: "short" | "long";
sequence: ("short" | "long")[] | null;
multiLevel: number | null;
predictionMode: candlePredictRepository.PredictionMode;
isAuto: boolean;
status: ShareableBetStatus;
resultSignedDisplay: string;
stakeDisplay: number;
intervalMinutes: number;
settledAt: string;
registerUrl: string;
referralCode: string | null;
operationType?: undefined;
amountSignedDisplay?: undefined;
amountDisplay?: undefined;
assetSymbol?: undefined;
assetCode?: undefined;
network?: undefined;
createdAt?: undefined;
}>;
//# sourceMappingURL=shareCardService.d.ts.map