|
| 1 | +/** |
| 2 | + * Multisig Escrow Types |
| 3 | + * |
| 4 | + * 2-of-3 multisig escrow: Depositor, Beneficiary, CoinPay (Arbiter). |
| 5 | + * CoinPay can never move funds alone — always requires 2 of 3 signers. |
| 6 | + */ |
| 7 | + |
| 8 | +// ── Chain Types ───────────────────────────────────────────── |
| 9 | + |
| 10 | +/** EVM chains supported by Safe adapter */ |
| 11 | +export type EvmChain = 'ETH' | 'POL' | 'BASE' | 'ARB' | 'OP' | 'BNB' | 'AVAX'; |
| 12 | + |
| 13 | +/** UTXO chains supported by BTC multisig adapter */ |
| 14 | +export type UtxoChain = 'BTC' | 'LTC' | 'DOGE'; |
| 15 | + |
| 16 | +/** Solana chain */ |
| 17 | +export type SolanaChain = 'SOL'; |
| 18 | + |
| 19 | +/** All chains supported by multisig */ |
| 20 | +export type MultisigChain = EvmChain | UtxoChain | SolanaChain; |
| 21 | + |
| 22 | +// ── Escrow Model ──────────────────────────────────────────── |
| 23 | + |
| 24 | +export type EscrowModel = 'custodial' | 'multisig_2of3'; |
| 25 | + |
| 26 | +export type MultisigEscrowStatus = |
| 27 | + | 'pending' |
| 28 | + | 'funded' |
| 29 | + | 'released' |
| 30 | + | 'settled' |
| 31 | + | 'disputed' |
| 32 | + | 'refunded' |
| 33 | + | 'expired'; |
| 34 | + |
| 35 | +export type DisputeStatus = |
| 36 | + | 'open' |
| 37 | + | 'under_review' |
| 38 | + | 'resolved_release' |
| 39 | + | 'resolved_refund'; |
| 40 | + |
| 41 | +export type ProposalType = 'release' | 'refund'; |
| 42 | + |
| 43 | +export type ProposalStatus = 'pending' | 'approved' | 'executed' | 'cancelled'; |
| 44 | + |
| 45 | +export type SignerRole = 'depositor' | 'beneficiary' | 'arbiter'; |
| 46 | + |
| 47 | +// ── Core Interfaces ───────────────────────────────────────── |
| 48 | + |
| 49 | +export interface MultisigParticipants { |
| 50 | + depositor_pubkey: string; |
| 51 | + beneficiary_pubkey: string; |
| 52 | + arbiter_pubkey: string; |
| 53 | +} |
| 54 | + |
| 55 | +export interface CreateMultisigEscrowInput { |
| 56 | + chain: MultisigChain; |
| 57 | + amount: number; |
| 58 | + depositor_pubkey: string; |
| 59 | + beneficiary_pubkey: string; |
| 60 | + arbiter_pubkey: string; |
| 61 | + metadata?: Record<string, unknown>; |
| 62 | + business_id?: string; |
| 63 | + expires_in_hours?: number; |
| 64 | +} |
| 65 | + |
| 66 | +export interface MultisigEscrow { |
| 67 | + id: string; |
| 68 | + escrow_model: 'multisig_2of3'; |
| 69 | + chain: MultisigChain; |
| 70 | + threshold: 2; |
| 71 | + depositor_pubkey: string; |
| 72 | + beneficiary_pubkey: string; |
| 73 | + arbiter_pubkey: string; |
| 74 | + escrow_address: string; |
| 75 | + chain_metadata: Record<string, unknown>; |
| 76 | + amount: number; |
| 77 | + amount_usd: number | null; |
| 78 | + status: MultisigEscrowStatus; |
| 79 | + dispute_status: DisputeStatus | null; |
| 80 | + dispute_reason: string | null; |
| 81 | + metadata: Record<string, unknown>; |
| 82 | + business_id: string | null; |
| 83 | + funded_at: string | null; |
| 84 | + settled_at: string | null; |
| 85 | + created_at: string; |
| 86 | + expires_at: string; |
| 87 | +} |
| 88 | + |
| 89 | +export interface MultisigProposal { |
| 90 | + id: string; |
| 91 | + escrow_id: string; |
| 92 | + proposal_type: ProposalType; |
| 93 | + to_address: string; |
| 94 | + amount: number; |
| 95 | + chain_tx_data: Record<string, unknown>; |
| 96 | + status: ProposalStatus; |
| 97 | + created_by: string; |
| 98 | + created_at: string; |
| 99 | + executed_at: string | null; |
| 100 | + tx_hash: string | null; |
| 101 | +} |
| 102 | + |
| 103 | +export interface MultisigSignature { |
| 104 | + id: string; |
| 105 | + proposal_id: string; |
| 106 | + signer_role: SignerRole; |
| 107 | + signer_pubkey: string; |
| 108 | + signature: string; |
| 109 | + signed_at: string; |
| 110 | +} |
| 111 | + |
| 112 | +// ── Adapter Interfaces ────────────────────────────────────── |
| 113 | + |
| 114 | +/** Result of creating a multisig wallet on-chain */ |
| 115 | +export interface CreateMultisigResult { |
| 116 | + escrow_address: string; |
| 117 | + chain_metadata: Record<string, unknown>; |
| 118 | +} |
| 119 | + |
| 120 | +/** Data needed to propose a transaction */ |
| 121 | +export interface ProposeTransactionInput { |
| 122 | + escrow_address: string; |
| 123 | + to_address: string; |
| 124 | + amount: number; |
| 125 | + chain_metadata: Record<string, unknown>; |
| 126 | +} |
| 127 | + |
| 128 | +/** Result of proposing a transaction */ |
| 129 | +export interface ProposeTransactionResult { |
| 130 | + tx_data: Record<string, unknown>; |
| 131 | + tx_hash_to_sign: string; |
| 132 | +} |
| 133 | + |
| 134 | +/** Result of adding a signature */ |
| 135 | +export interface AddSignatureResult { |
| 136 | + signatures_collected: number; |
| 137 | + threshold_met: boolean; |
| 138 | +} |
| 139 | + |
| 140 | +/** Result of broadcasting */ |
| 141 | +export interface BroadcastResult { |
| 142 | + tx_hash: string; |
| 143 | + success: boolean; |
| 144 | +} |
| 145 | + |
| 146 | +// ── API Response Types ────────────────────────────────────── |
| 147 | + |
| 148 | +export interface CreateMultisigEscrowResult { |
| 149 | + success: boolean; |
| 150 | + escrow?: MultisigEscrow; |
| 151 | + error?: string; |
| 152 | +} |
| 153 | + |
| 154 | +export interface ProposeResult { |
| 155 | + success: boolean; |
| 156 | + proposal?: MultisigProposal; |
| 157 | + tx_data?: Record<string, unknown>; |
| 158 | + error?: string; |
| 159 | +} |
| 160 | + |
| 161 | +export interface SignResult { |
| 162 | + success: boolean; |
| 163 | + signature?: MultisigSignature; |
| 164 | + signatures_collected?: number; |
| 165 | + threshold_met?: boolean; |
| 166 | + error?: string; |
| 167 | +} |
| 168 | + |
| 169 | +export interface BroadcastResultResponse { |
| 170 | + success: boolean; |
| 171 | + tx_hash?: string; |
| 172 | + proposal?: MultisigProposal; |
| 173 | + error?: string; |
| 174 | +} |
| 175 | + |
| 176 | +export interface DisputeResult { |
| 177 | + success: boolean; |
| 178 | + escrow?: MultisigEscrow; |
| 179 | + error?: string; |
| 180 | +} |
0 commit comments