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
5 changes: 3 additions & 2 deletions src/stellar/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {
Transaction,
TransactionBuilder,
} from '@stellar/stellar-sdk';
import { config } from '../config';
import { TransactionResult } from './types';

const RPC_URL = process.env.STELLAR_RPC_URL || 'https://soroban-testnet.stellar.org';
export function resolveNetworkPassphrase(network: string | undefined): string {
switch (network?.toLowerCase()) {
case 'mainnet':
Expand All @@ -23,7 +23,8 @@ export function resolveNetworkPassphrase(network: string | undefined): string {
}
}

const NETWORK_PASSPHRASE = resolveNetworkPassphrase(process.env.STELLAR_NETWORK);
const RPC_URL = config.stellar.rpcUrl;
const NETWORK_PASSPHRASE = resolveNetworkPassphrase(config.stellar.network);

let agentKeypair: Keypair | null = null;
let rpcServer: rpc.Server | null = null;
Expand Down
3 changes: 2 additions & 1 deletion src/stellar/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import {
} from '@stellar/stellar-sdk';
import { getRpcServer, getNetworkPassphrase, getAgentKeypair, submitTransaction, waitForConfirmation } from './client';
import { getKeypairForUser } from './wallet';
import { config } from '../config';
import { OnChainBalance, TransactionResult } from './types';

const VAULT_CONTRACT_ID = process.env.VAULT_CONTRACT_ID || '';
const VAULT_CONTRACT_ID = config.stellar.vaultContractId;
const STROOPS_PER_TOKEN = 10_000_000n;

export type VaultWriteMethod = 'deposit' | 'withdraw';
Expand Down
11 changes: 6 additions & 5 deletions src/stellar/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
recordDbOperation
} from '../utils/metrics';

const VAULT_CONTRACT_ID = process.env.VAULT_CONTRACT_ID || '';
const VAULT_CONTRACT_ID = config.stellar.vaultContractId;
const POLL_INTERVAL_MS = 5000;

const prisma = new PrismaClient();
Expand Down Expand Up @@ -147,10 +147,11 @@ export function extractProtocolName(event: ContractEvent): string {
* Extract network from config (canonical source of truth).
*/
function extractNetwork(): Network {
const n = config.stellar.network.toUpperCase();
if (n === 'TESTNET') return Network.TESTNET;
if (n === 'FUTURENET') return Network.FUTURENET;
return Network.MAINNET;
switch (config.stellar.network) {
case 'testnet': return Network.TESTNET;
case 'futurenet': return Network.FUTURENET;
case 'mainnet': return Network.MAINNET;
}
}

/**
Expand Down
Loading