UNPKG

morphcredit-merchant-sdk

Version:

MorphCredit Merchant SDK for BNPL integration

96 lines (92 loc) 2.55 kB
import React$1 from 'react'; interface SDKConfig { rpcUrl: string; contracts: { scoreOracle: string; creditRegistry: string; lendingPool: string; bnplFactory: string; }; scoringService: string; networkId: number; gasLimit?: number; confirmations?: number; } interface SDKOptions { autoConnect?: boolean; enableLogging?: boolean; retryAttempts?: number; retryDelay?: number; /** * If true, skip pre-checking FACTORY_ROLE before calling createAgreement. * Useful on some RPCs/proxies where static calls may return empty data. */ skipRoleCheck?: boolean; } interface Offer { id: string; principal: bigint; installments: number; installmentAmount: bigint; totalCost: bigint; apr: number; dueDates: number[]; merchant: string; status: 'available' | 'expired' | 'unavailable'; tier: 'A' | 'B' | 'C' | 'D' | 'E'; features: { noLateFees?: boolean; earlyPayoff?: boolean; autoRepay?: boolean; }; } interface OfferRequest { address: string; amount: number; currency?: string; includeFeatures?: boolean; } interface TxResult { success: boolean; txHash: string; agreementId: string; blockNumber: number; gasUsed: number; gasPrice: bigint; error?: string; receipt?: any; } interface AgreementStatus { id: string; status: 'active' | 'completed' | 'defaulted' | 'written_off'; paidInstallments: number; totalInstallments: number; nextDueDate: number; nextAmount: bigint; remainingBalance: bigint; lastPaymentDate?: number; delinquencyDays: number; } interface MorphCreditError extends Error { code: string; details?: any; retryable: boolean; } interface MorphCreditButtonProps { amount: number; userAddress?: string; onSuccess?: (result: TxResult) => void; onError?: (error: MorphCreditError) => void; onOffersLoaded?: (offers: Offer[]) => void; onWalletConnect?: (address: string) => void; disabled?: boolean; className?: string; style?: React.CSSProperties; children?: React.ReactNode; variant?: 'primary' | 'secondary' | 'outline'; size?: 'sm' | 'md' | 'lg'; loading?: boolean; showOffers?: boolean; } declare const MorphCreditButton: React$1.FC<MorphCreditButtonProps>; export { type AgreementStatus as A, MorphCreditButton as M, type OfferRequest as O, type SDKConfig as S, type TxResult as T, type SDKOptions as a, type Offer as b };