feat: update settings for vault
This commit is contained in:
@@ -2,6 +2,7 @@ import {parseUsdtAmount} from './domain/amount.js';
|
||||
import type {EthereumSecret} from './secrets/VaultClient.js';
|
||||
|
||||
export const MAINNET_USDT_CONTRACT = '0xdAC17F958D2ee523a2206206994597C13D831ec7';
|
||||
export const ETH_RPC_URL = 'https://ethereum-rpc.publicnode.com';
|
||||
|
||||
export interface AppConfig {
|
||||
port: number;
|
||||
@@ -22,7 +23,7 @@ export interface AppConfig {
|
||||
export function loadConfig(env: NodeJS.ProcessEnv = process.env): AppConfig {
|
||||
return {
|
||||
port: readInteger(env.PORT, 3000),
|
||||
ethRpcUrl: env.ETH_RPC_URL,
|
||||
ethRpcUrl: env.ETH_RPC_URL ?? ETH_RPC_URL,
|
||||
hotWalletPrivateKey: readOptionalPlaceholder(env.HOT_WALLET_PRIVATE_KEY, '0xYOUR_PRIVATE_KEY'),
|
||||
usdtContractAddress: env.USDT_CONTRACT_ADDRESS ?? MAINNET_USDT_CONTRACT,
|
||||
maxTransferAmountUnits: parseUsdtAmount(env.MAX_TRANSFER_USDT ?? '1000'),
|
||||
|
||||
@@ -55,7 +55,7 @@ export class VaultClient {
|
||||
const [database, rabbitmq, ethereum] = await Promise.all([
|
||||
this.readSecret('database'),
|
||||
this.readSecret('rabbitmq'),
|
||||
this.readOptionalSecret('ethereum')
|
||||
this.readOptionalSecret('crypto')
|
||||
]);
|
||||
|
||||
return {
|
||||
@@ -103,7 +103,7 @@ export class VaultClient {
|
||||
try {
|
||||
return await this.readSecret(path);
|
||||
} catch (error) {
|
||||
if (error instanceof Error && error.message.includes('HTTP 404')) {
|
||||
if (error instanceof Error && (error.message.includes('HTTP 404') || error.message.includes('HTTP 403'))) {
|
||||
return null;
|
||||
}
|
||||
throw error;
|
||||
@@ -152,8 +152,10 @@ function parseRabbitMqSecret(raw: Record<string, unknown>): RabbitMqSecret {
|
||||
function parseEthereumSecret(raw: Record<string, unknown>): EthereumSecret {
|
||||
return {
|
||||
rpcUrl: optionalString(raw, 'rpc_url', 'ethereum'),
|
||||
hotWalletPrivateKey: optionalString(raw, 'hot_wallet_private_key', 'ethereum'),
|
||||
usdtContractAddress: optionalString(raw, 'usdt_contract_address', 'ethereum')
|
||||
hotWalletPrivateKey: optionalString(raw, 'hot_wallet_private_key', 'crypto'),
|
||||
usdtContractAddress:
|
||||
optionalString(raw, 'usdt_contract_address', 'crypto') ??
|
||||
optionalString(raw, 'usdt_contract_addres', 'crypto')
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user