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
2,721 changes: 903 additions & 1,818 deletions contracts/claims-processor/src/lib.rs

Large diffs are not rendered by default.

1,922 changes: 609 additions & 1,313 deletions contracts/claims-processor/src/test.rs

Large diffs are not rendered by default.

1,980 changes: 570 additions & 1,410 deletions contracts/claims-processor/src/test_advanced.rs

Large diffs are not rendered by default.

1,038 changes: 388 additions & 650 deletions contracts/claims-processor/src/test_integration.rs

Large diffs are not rendered by default.

175 changes: 0 additions & 175 deletions contracts/claims-processor/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,178 +195,3 @@ pub struct ContractUpgraded {
pub old_version: u32,
pub new_version: u32,
}

#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct GuardiansUpdated {
pub guardians: Vec<Address>,
pub threshold: u32,
}

#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct UpgradeApproved {
pub new_wasm_hash: BytesN<32>,
pub approver: Address,
pub approvals: u32,
pub threshold: u32,
}

/// A pending contract-upgrade action awaiting guardian approvals.
#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct PendingUpgrade {
pub new_wasm_hash: BytesN<32>,
pub new_version: u32,
pub approvals: Vec<Address>,
}

/// A pending admin-transfer proposal awaiting guardian approvals.
#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct PendingAdminChange {
pub new_admin: Address,
pub approvals: Vec<Address>,
}

#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct AdminUpdated {
pub new_admin: Address,
}

/// oracle-verifier.
#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct CrossChainAttestation {
/// Which chain this observation came from.
pub chain_id: Symbol,
/// The registered attestor that submitted it.
pub attestor: Address,
/// The observed value, in the same fixed-point units as
/// `Policy.trigger_threshold`.
pub observed_value: i128,
/// Hash of the off-chain proof (light-client proof, relayer message,
/// oracle report) backing `observed_value`. Opaque to the contract —
/// kept for audit/dispute purposes, not verified on-chain.
pub proof_hash: BytesN<32>,
/// Unix timestamp of the observation.
pub timestamp: u64,
}

#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct CrossChainAttestorAdded {
pub chain_id: Symbol,
pub attestor: Address,
}

#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct CrossChainAttestorRemoved {
pub chain_id: Symbol,
pub attestor: Address,
}

#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct CrossChainAttestationSubmitted {
pub policy_id: u128,
pub chain_id: Symbol,
pub attestor: Address,
pub observed_value: i128,
pub timestamp: u64,
}

#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct InstallmentPayoutScheduled {
pub claim_id: u128,
pub policy_id: u128,
pub claimant: Address,
pub total_amount: i128,
pub num_installments: u32,
pub interval_seconds: u64,
pub first_installment_at: u64,
}

#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct InstallmentPaid {
pub claim_id: u128,
pub claimant: Address,
pub amount: i128,
pub paid_count: u32,
pub total_installments: u32,
}

/// Emitted when the payout delay configuration is updated.
#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct PayoutDelayUpdated {
pub delay_seconds: u64,
}

/// Supported payout currencies for claim settlements.
#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum PayoutCurrency {
/// Default USDC (7-decimal)
USDC,
/// Alternative stablecoin (address stored separately)
Custom(Address),
}

/// Multi-currency payout configuration for a claim.
#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct PayoutOption {
/// Currency to pay out in.
pub currency: PayoutCurrency,
/// Exchange rate (basis points) relative to USDC. 10000 = 1:1 parity.
/// Used to convert USDC coverage amounts to equivalent other-currency amounts.
pub exchange_rate_bps: u32,
/// Whether this payout option is currently enabled.
pub enabled: bool,
}

/// Record of available payout currencies and their exchange rates.
#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct PayoutCurrencyRegistry {
/// Address of the USDC token contract (default payout currency).
pub usdc_token: Address,
/// Optional alternative payout currencies with their exchange rates.
pub alt_currencies: Vec<Address>,
/// Exchange rates for alt currencies (index matches alt_currencies).
pub exchange_rates_bps: Vec<u32>,
}

/// Emitted when a new payout currency is registered.
#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct PayoutCurrencyAdded {
pub token: Address,
pub exchange_rate_bps: u32,
}

/// Emitted when a payout currency's exchange rate is updated.
#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct PayoutCurrencyRateUpdated {
pub token: Address,
pub old_rate_bps: u32,
pub new_rate_bps: u32,
}

/// Emitted when a claim is paid out in an alternate currency.
#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ClaimPaidInAlternativeCurrency {
pub claim_id: u128,
pub claimant: Address,
pub usdc_equivalent: i128,
pub token: Address,
pub actual_amount: i128,
pub exchange_rate_bps: u32,
}
Loading
Loading