Environment variables

This commit is contained in:
2026-10-20 16:24:01 -04:00
parent 4cac26d84b
commit 7734d8ae90
29 changed files with 267 additions and 38 deletions
+10 -6
View File
@@ -19,10 +19,11 @@ export const custodyActionSchema = z.discriminatedUnion('type', [
z.object({ type: z.literal('activity'), offset: z.number().int().min(0).max(10000).default(0) }).strict(),
z.object({ type: z.literal('mock-credit') }).strict(),
z.object({ type: z.literal('list'), cardHash: hex, sequence: z.number().int().nonnegative().safe(),
priceAtomicXmr: amount, feeBps: z.number().int().min(0).max(5000) }).strict(),
priceAtomicXmr: amount, feeBps: z.number().int().min(0).max(5000),
hostFeeAddress: z.string().regex(/^[1-9A-HJ-NP-Za-km-z]{95}$/).optional() }).strict(),
z.object({ type: z.literal('cancel-listing'), listingId: id }).strict(),
z.object({ type: z.literal('reserve'), listingId: id, priceAtomicXmr: amount,
feeBps: z.number().int().min(0).max(5000) }).strict(),
feeBps: z.number().int().min(0).max(5000), hostFeeAddress: z.string().regex(/^[1-9A-HJ-NP-Za-km-z]{95}$/).optional() }).strict(),
z.object({ type: z.literal('cancel-reservation'), orderId: id }).strict(),
// No real Monero address accepted or generated in this phase.
z.object({ type: z.literal('withdraw'), destination: z.literal('mock-external'), amountAtomicXmr: amount,
@@ -44,18 +45,21 @@ export function custodyMessage(c: Omit<CustodyCommand, 'signature'>): string {
: a.type === 'withdraw' ? [a.destination, 'XMR', a.amountAtomicXmr, a.maxFeeAtomicXmr]
: a.type === 'cancel-withdrawal' ? [a.withdrawalId]
: a.type === 'activity' ? [a.offset] : [MOCK_CREDIT_ATOMIC];
const fees: (string | number)[] = [ADDITIONAL_MARKET_FEE.bps, ADDITIONAL_MARKET_FEE.address];
if ((a.type === 'list' || a.type === 'reserve') && a.hostFeeAddress !== undefined) fees.push('host-fee-recipient-v1', a.hostFeeAddress);
return JSON.stringify(['wikideck-custody-command-v1', c.version, c.mode, c.policy, c.network,
c.chainId, c.custodianId, c.actor, c.publicKey, c.nonce, c.expiresAt, a.type, terms,
[ADDITIONAL_MARKET_FEE.bps, ADDITIONAL_MARKET_FEE.address]]);
fees]);
}
export type CustodyInfo = { enabled: true; mode: 'sandbox'; policy: typeof CUSTODY_POLICY;
network: typeof NETWORK; chainId: string; custodianId: string; feeBps: number;
liveDeposits: false; liveWithdrawals: false; nftSettlement: false };
liveDeposits: false; liveWithdrawals: false; nftSettlement: false;
marketEnabled?: boolean; tradingEnabled?: boolean; hostFeeAddress?: string };
export type CustodyListing = { id: string; seller: string; cardHash: string; sequence: number;
title: string; priceAtomicXmr: string; feeBps: number; status: 'open' | 'reserved' | 'cancelled' | 'sold'; createdAt: number };
title: string; priceAtomicXmr: string; feeBps: number; status: 'open' | 'reserved' | 'cancelled' | 'sold'; createdAt: number; hostFeeAddress?: string };
export type CustodyOrder = { id: string; listingId: string; seller: string; buyer: string; cardHash: string;
sequence: number; grossAtomicXmr: string; sellerAtomicXmr: string; authorAtomicXmr: string;
hostAtomicXmr: string; authorAddress: string; status: 'awaiting-lock' | 'cancelled' | 'settled'; createdAt: number };
hostAtomicXmr: string; authorAddress: string; status: 'awaiting-lock' | 'cancelled' | 'settled'; createdAt: number; hostFeeAddress?: string };
export type CustodyWithdrawal = { id: string; actor: string; destination: 'mock-external';
amountAtomicXmr: string; maxFeeAtomicXmr: string; status: 'reserved' | 'prepared' | 'complete' | 'cancelled';
attemptId?: string; transactionId?: string; feeAtomicXmr?: string; createdAt: number };