Skip to content
Open
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: 3 additions & 0 deletions core/src/BaseExchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,9 @@ export interface ExchangeCredentials {

// Optional base URL override for venue API (e.g., proxy for geo-restricted venues)
baseUrl?: string;

// Optional blockchain RPC override for venues backed by an on-chain client.
rpcUrl?: string;
}

export interface ExchangeOptions {
Expand Down
3 changes: 2 additions & 1 deletion core/src/server/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,8 @@ export function createApp(options: CreateAppOptions = {}): Express {
credentials &&
(credentials.privateKey ||
credentials.apiKey ||
credentials.apiToken)
credentials.apiToken ||
credentials.rpcUrl)
) {
exchange = createExchange(exchangeName, credentials);
} else {
Expand Down
7 changes: 5 additions & 2 deletions core/src/server/exchange-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@ export function createExchange(
});
case "baozi":
return new BaoziExchange({
privateKey:
credentials?.privateKey || process.env.BAOZI_PRIVATE_KEY,
credentials: {
privateKey:
credentials?.privateKey || process.env.BAOZI_PRIVATE_KEY,
},
rpcUrl: credentials?.rpcUrl,
});
case "myriad":
return new MyriadExchange({
Expand Down
11 changes: 11 additions & 0 deletions core/test/unit/exchange-factory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const getFetcher = (exchange: unknown): Record<string, unknown> | undefined =>
const getBaseUrl = (exchange: unknown): string | undefined =>
(exchange as { baseUrl?: string }).baseUrl;

const getRpcEndpoint = (exchange: unknown): string | undefined =>
(exchange as { connection?: { rpcEndpoint?: string } }).connection?.rpcEndpoint;

const withEnv = <T>(env: NodeJS.ProcessEnv, run: () => T): T => {
const originalEnv = process.env;
process.env = { ...originalEnv, ...env };
Expand All @@ -24,6 +27,14 @@ const withEnv = <T>(env: NodeJS.ProcessEnv, run: () => T): T => {
};

describe('createExchange', () => {
test('baozi forwards a per-request RPC URL to its Solana connection', () => {
const exchange = createExchange('baozi', {
rpcUrl: 'https://baozi-rpc.test.local',
});

expect(getRpcEndpoint(exchange)).toBe('https://baozi-rpc.test.local');
});

test('kalshi-demo prefers demo credentials before production fallbacks', () => {
withEnv(
{
Expand Down