Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,6 @@ REALUNIT_BANK_IBAN=
REALUNIT_BANK_BIC=
REALUNIT_BANK_NAME=

CUSTOM_BALANCE_ASSETS=
CUSTOM_BALANCE_ADDRESSES=

REQUEST_KNOWN_IPS=

CRON_JOB_DELAY=
5 changes: 0 additions & 5 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,11 +625,6 @@ export class Configuration {
apiKey: process.env.COIN_GECKO_API_KEY,
};

financialLog = {
customAssets: process.env.CUSTOM_BALANCE_ASSETS?.split(';') ?? [], // asset uniqueName
customAddresses: process.env.CUSTOM_BALANCE_ADDRESSES?.split(';') ?? [],
};

payment = {
timeoutDelay: +(process.env.PAYMENT_TIMEOUT_DELAY ?? 0),
evmSeed: process.env.PAYMENT_EVM_SEED,
Expand Down
8 changes: 8 additions & 0 deletions src/shared/models/ip-log/ip-log.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ export class IpLogService {
return this.ipLogRepo.save(ipLog);
}

async getByUserDataId(userDataId: number, limit = 50): Promise<IpLog[]> {
return this.ipLogRepo.find({
where: { userData: { id: userDataId } },
order: { created: 'DESC' },
take: limit,
});
}

async getLoginCountries(userDataId: number, dateFrom: Date, dateTo = new Date()): Promise<string[]> {
const nearestLog = await this.idCache.get(Util.isoDate(dateFrom), () =>
this.ipLogRepo.findOne({ where: { created: LessThanOrEqual(dateFrom) }, order: { id: 'DESC' } }),
Expand Down
4 changes: 4 additions & 0 deletions src/shared/models/setting/setting-schema.registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export const SettingSchemaRegistry: Record<string, SettingSchema> = {

// IP Blacklist
ipBlacklist: 'string[]',

// Custom Balance Settings
customBalanceAddresses: 'string[]',
customBalanceAssets: 'string[]', // asset unique name
};

export function isArraySchema(schema: SettingSchema): schema is ArraySchema {
Expand Down
10 changes: 9 additions & 1 deletion src/shared/models/setting/setting.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { validate } from 'class-validator';
import { Process } from 'src/shared/services/process.service';
import { CustomSignUpFeesDto } from './dto/custom-sign-up-fees.dto';
import { UpdateProcessDto } from './dto/update-process.dto';
import { isArraySchema, isPrimitiveSchema, SettingSchema, SettingSchemaRegistry } from './setting-schema.registry';
import { Setting } from './setting.entity';
import { SettingRepository } from './setting.repository';
import { isArraySchema, isPrimitiveSchema, SettingSchema, SettingSchemaRegistry } from './setting-schema.registry';

@Injectable()
export class SettingService {
Expand Down Expand Up @@ -104,6 +104,14 @@ export class SettingService {
return this.getObjCached<string[]>('ipBlacklist', []);
}

async getCustomBalanceSettings(): Promise<{ addresses: string[]; assets: string[] }> {
const [addresses, assets] = await Promise.all([
this.getObjCached<string[]>('customBalanceAddresses', []),
this.getObjCached<string[]>('customBalanceAssets', []),
]);
return { addresses, assets };
}

async addIpToBlacklist(ip: string): Promise<void> {
const ipBlacklist = await this.getIpBlacklist();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,14 @@ export class BuyFiatService {
return this.buyFiatRepo.findOne({ where: { transaction: { id: transactionId } }, relations });
}

async getBuyFiatsByTransactionIds(transactionIds: number[]): Promise<BuyFiat[]> {
if (!transactionIds.length) return [];
return this.buyFiatRepo.find({
where: { transaction: { id: In(transactionIds) } },
relations: { transaction: true, fiatOutput: { bankTx: true } },
});
}

async getBuyFiat(from: Date, relations?: FindOptionsRelations<BuyFiat>): Promise<BuyFiat[]> {
return this.buyFiatRepo.find({ where: { transaction: { created: MoreThan(from) } }, relations });
}
Expand Down
75 changes: 75 additions & 0 deletions src/subdomains/generic/support/dto/user-data-support.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class BankTxSupportInfo {
type: BankTxType;
name?: string;
iban?: string;
remittanceInfo?: string;
}

export class UserSupportInfo {
Expand All @@ -45,6 +46,8 @@ export class TransactionSupportInfo {
sourceType: string;
amountInChf?: number;
amlCheck?: string;
chargebackDate?: Date;
amlReason?: string;
created: Date;
}

Expand Down Expand Up @@ -87,23 +90,33 @@ export class BankDataSupportInfo {
id: number;
iban: string;
name: string;
type?: string;
status?: string;
approved: boolean;
manualApproved?: boolean;
active: boolean;
comment?: string;
created: Date;
}

export class BuySupportInfo {
id: number;
iban?: string;
bankUsage: string;
assetName: string;
blockchain: string;
volume: number;
active: boolean;
created: Date;
}

export class SellSupportInfo {
id: number;
iban: string;
fiatName?: string;
volume: number;
active: boolean;
created: Date;
}

export class TransactionListEntry {
Expand Down Expand Up @@ -177,12 +190,74 @@ export class RecommendationGraph {
rootId: number;
}

export class SupportMessageSupportInfo {
author: string;
message?: string;
created: Date;
}

export class SupportIssueSupportInfo {
id: number;
uid: string;
type: string;
state: string;
reason: string;
name: string;
clerk?: string;
department?: string;
information?: string;
messages: SupportMessageSupportInfo[];
transaction?: {
id: number;
uid: string;
type?: string;
sourceType: string;
amountInChf?: number;
amlCheck?: string;
};
limitRequest?: {
limit: number;
acceptedLimit?: number;
decision?: string;
fundOrigin: string;
};
created: Date;
}

export class CryptoInputSupportInfo {
id: number;
transactionId?: number;
inTxId: string;
inTxExplorerUrl?: string;
status?: string;
amount: number;
assetName?: string;
blockchain?: string;
senderAddresses?: string;
returnTxId?: string;
returnTxExplorerUrl?: string;
purpose?: string;
}

export class IpLogSupportInfo {
id: number;
ip: string;
country?: string;
url: string;
result: boolean;
created: Date;
}

export class UserDataSupportInfoDetails {
userData: UserData;
kycFiles: KycFile[];
kycSteps: KycStepSupportInfo[];
kycLogs: KycLogSupportInfo[];
transactions: TransactionSupportInfo[];
bankTxs: BankTxSupportInfo[];
cryptoInputs: CryptoInputSupportInfo[];
ipLogs: IpLogSupportInfo[];
supportIssues: SupportIssueSupportInfo[];
users: UserSupportInfo[];
bankDatas: BankDataSupportInfo[];
buyRoutes: BuySupportInfo[];
Expand Down
2 changes: 2 additions & 0 deletions src/subdomains/generic/support/support.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { BankTxModule } from 'src/subdomains/supporting/bank-tx/bank-tx.module';
import { PayInModule } from 'src/subdomains/supporting/payin/payin.module';
import { PaymentModule } from 'src/subdomains/supporting/payment/payment.module';
import { TransactionModule } from 'src/subdomains/supporting/payment/transaction.module';
import { SupportIssueModule } from 'src/subdomains/supporting/support-issue/support-issue.module';
import { KycModule } from '../kyc/kyc.module';
import { UserModule } from '../user/user.module';
import { SupportController } from './support.controller';
Expand All @@ -23,6 +24,7 @@ import { SupportService } from './support.service';
BankTxModule,
KycModule,
TransactionModule,
SupportIssueModule,
forwardRef(() => PaymentModule),
],
controllers: [SupportController],
Expand Down
Loading
Loading