import * as neverthrow from 'neverthrow'; import { Result, ResultAsync } from 'neverthrow'; import { Address, WalletClient, TransactionReceipt } from 'viem'; import { z } from 'zod'; import * as react_jsx_runtime from 'react/jsx-runtime'; import { ReactNode } from 'react'; declare class SdkError extends Error { readonly code: TCode; readonly cause?: unknown; readonly context?: Record; constructor(message: string, options: { code: TCode; cause?: unknown; context?: Record; }); } type ZkkycErrorCode = "VALIDATION_ERROR" | "CONTRACT_READ_ERROR" | "ENCODE_ERROR" | "RECLAIM_INIT_FAILED" | "RECLAIM_SESSION_NOT_FOUND" | "RECLAIM_PROOF_GENERATION_FAILED" | "RECLAIM_PROOF_INVALID" | "RECLAIM_POLLING_ABORTED" | "ZK_PASSPORT_INIT_FAILED" | "ZK_PASSPORT_REJECTED" | "ZK_PASSPORT_VERIFICATION_FAILED" | "ZK_PASSPORT_ABORTED" | "SIMPLE_KYC_SESSION_FAILED" | "SIMPLE_KYC_REDEEM_FAILED" | "LIVENESS_SESSION_FAILED" | "LIVENESS_REDEEM_FAILED" | "BVN_ONBOARD_FAILED" | "BVN_SUBMIT_FAILED" | "BVN_OTP_SEND_FAILED" | "BVN_OTP_CONFIRM_FAILED" | "BVN_ATTESTATION_FAILED" | "BVN_SESSION_EXPIRED" | "PEER_DEPENDENCY_MISSING"; declare class ZkkycError extends SdkError { constructor(message: string, options: { code: ZkkycErrorCode; cause?: unknown; context?: Record; }); } declare const ZodAnonAadharProofParamsSchema: z.ZodObject<{ nullifierSeed: z.ZodBigInt; nullifier: z.ZodBigInt; timestamp: z.ZodBigInt; signal: z.ZodBigInt; revealArray: z.ZodTuple<[z.ZodBigInt, z.ZodBigInt, z.ZodBigInt, z.ZodBigInt], null>; packedGroth16Proof: z.ZodTuple<[z.ZodBigInt, z.ZodBigInt, z.ZodBigInt, z.ZodBigInt, z.ZodBigInt, z.ZodBigInt, z.ZodBigInt, z.ZodBigInt], null>; }, z.core.$strip>; type AnonAadharProofParams = z.infer; declare const ZodSocialVerifyParamsSchema: z.ZodObject<{ _socialName: z.ZodString; proofs: z.ZodArray; signedClaim: z.ZodObject<{ claim: z.ZodObject<{ identifier: z.ZodString; owner: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>; timestampS: z.ZodNumber; epoch: z.ZodNumber; }, z.core.$strip>; signatures: z.ZodArray; }, z.core.$strip>; }, z.core.$strip>>; }, z.core.$strip>; type SocialVerifyParams = z.infer; declare const ZodZkPassportRegisterParamsSchema: z.ZodObject<{ params: z.ZodObject<{ version: z.ZodString; proofVerificationData: z.ZodObject<{ vkeyHash: z.ZodString; proof: z.ZodString; publicInputs: z.ZodArray; }, z.core.$strip>; committedInputs: z.ZodString; serviceConfig: z.ZodObject<{ validityPeriodInSeconds: z.ZodNumber; domain: z.ZodString; scope: z.ZodString; devMode: z.ZodBoolean; }, z.core.$strip>; }, z.core.$strip>; isIDCard: z.ZodBoolean; }, z.core.$strip>; type ZkPassportRegisterParams = z.infer; declare const ZodSimpleKycSubmitParamsSchema: z.ZodObject<{ nullifier: z.ZodString; limit: z.ZodBigInt; expiry: z.ZodBigInt; signature: z.ZodString; }, z.core.$strip>; type SimpleKycSubmitParams = z.infer; declare const ZodBvnSubmitParamsSchema: z.ZodObject<{ nullifier: z.ZodString; limit: z.ZodBigInt; expiry: z.ZodBigInt; signature: z.ZodString; }, z.core.$strip>; type BvnSubmitParams = z.infer; declare const ZodLivenessSubmitParamsSchema: z.ZodObject<{ nullifier: z.ZodString; limit: z.ZodBigInt; expiry: z.ZodBigInt; signature: z.ZodString; }, z.core.$strip>; type LivenessSubmitParams = z.infer; interface Zkkyc { prepareSocialVerify(params: SocialVerifyParams): Result<{ to: Address; data: `0x${string}`; }, ZkkycError>; prepareSubmitAnonAadharProof(params: AnonAadharProofParams): Result<{ to: Address; data: `0x${string}`; }, ZkkycError>; prepareZkPassportRegister(params: ZkPassportRegisterParams): Result<{ to: Address; data: `0x${string}`; }, ZkkycError>; prepareSubmitKycAttestation(params: SimpleKycSubmitParams): Result<{ to: Address; data: `0x${string}`; }, ZkkycError>; prepareSubmitBvnAttestation(params: BvnSubmitParams): Result<{ to: Address; data: `0x${string}`; }, ZkkycError>; prepareSubmitLivenessAttestation(params: LivenessSubmitParams): Result<{ to: Address; data: `0x${string}`; }, ZkkycError>; } /** * Minimal viem PublicClient interface — consumers pass their own client. * The SDK uses `readContract` for single reads and `multicall` where available * to batch multiple reads into one RPC round-trip. */ interface PublicClientLike { readContract(args: { address: Address; abi: readonly unknown[]; functionName: string; args: readonly unknown[]; }): Promise; multicall?(args: { contracts: readonly { address: Address; abi: readonly unknown[]; functionName: string; args?: readonly unknown[]; }[]; allowFailure?: boolean; }): Promise; } type StakeErrorCode = "VALIDATION_ERROR" | "CONTRACT_READ_ERROR" | "TX_SUBMISSION_FAILED" | "RECEIPT_TIMEOUT" | "TX_REVERTED"; declare class StakeError extends SdkError { constructor(message: string, options: { code: StakeErrorCode; cause?: unknown; context?: Record; }); } declare const ZodGetUserStakeParamsSchema: z.ZodObject<{ user: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>; }, z.core.$strip>; type GetUserStakeParams = z.infer; declare const ZodGetStakeBoostConfigParamsSchema: z.ZodObject<{ currency: z.ZodEnum<{ IDR: "IDR"; INR: "INR"; BRL: "BRL"; ARS: "ARS"; MEX: "MEX"; VEN: "VEN"; BOB: "BOB"; EUR: "EUR"; NGN: "NGN"; USD: "USD"; COP: "COP"; CUP: "CUP"; ECU: "ECU"; PEN: "PEN"; PHP: "PHP"; }>; }, z.core.$strip>; type GetStakeBoostConfigParams = z.infer; declare const ZodGetP2pTokenBalanceParamsSchema: z.ZodObject<{ address: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>; }, z.core.$strip>; type GetP2pTokenBalanceParams = z.infer; declare const ZodStakeParamsSchema: z.ZodObject<{ tokens: z.ZodBigInt; }, z.core.$strip>; type StakeParams = z.infer; declare const ZodTopUpParamsSchema: z.ZodObject<{ tokens: z.ZodBigInt; }, z.core.$strip>; type TopUpParams = z.infer; /** * Stake lifecycle state for a user. * 0 — None: no active stake. * 1 — Active: stake is live. * 2 — CooldownRequested: unstake requested; awaiting cooldown end. * 3 — Seized: stake was forcefully seized. */ type StakeStatus = "none" | "active" | "cooldown" | "seized"; /** Normalized on-chain stake record for a user. */ interface UserStake { /** Currently staked token amount (raw bigint, token decimals). */ readonly stakedAmount: bigint; /** Unix seconds when cooldown ends (0 if not in cooldown). */ readonly cooldownEnd: bigint; /** Lifecycle status decoded from the on-chain enum. */ readonly status: StakeStatus; } /** * Per-currency boost config — how many tokens map to 1 USD of boost, and the * cap on USD-denominated boost a stake can unlock. */ interface StakeBoostConfig { readonly tokensPerUsdNumerator: bigint; readonly tokensPerUsdDenominator: bigint; readonly maxBoostUsd: bigint; } /** Global stake boost configuration shared across all users. */ interface StakeBoostGlobals { readonly p2pToken: Address; readonly fraudReserve: Address; readonly maxStakeTokens: bigint; readonly normalCooldown: bigint; readonly blacklistCooldown: bigint; readonly tokenDecimals: number; readonly totalStaked: bigint; } interface PreparedTx$1 { readonly to: `0x${string}`; readonly data: `0x${string}`; readonly value: bigint; } interface TxResult$1 { readonly hash: `0x${string}`; readonly receipt?: TransactionReceipt; } interface ExecuteBase$1 { readonly walletClient: WalletClient; readonly waitForReceipt?: boolean; } interface CancelUnstakeAction { prepare(): ResultAsync; execute(params: ExecuteBase$1): ResultAsync; } interface ClaimUnstakeAction { prepare(): ResultAsync; execute(params: ExecuteBase$1): ResultAsync; } interface RequestUnstakeAction { prepare(): ResultAsync; execute(params: ExecuteBase$1): ResultAsync; } interface StakeAction { prepare(params: StakeParams): ResultAsync; execute(params: StakeParams & ExecuteBase$1): ResultAsync; } interface TopUpAction { prepare(params: TopUpParams): ResultAsync; execute(params: TopUpParams & ExecuteBase$1): ResultAsync; } interface StakeClient { /** Reads the on-chain stake record for a user (stakedAmount, cooldownEnd, status). */ getUserStake(params: GetUserStakeParams): ResultAsync; /** Reads the per-currency stake boost config (tokens-per-USD, max boost). */ getStakeBoostConfig(params: GetStakeBoostConfigParams): ResultAsync; /** Reads global stake boost configuration (token addr, cooldowns, totals). */ getStakeBoostGlobals(): ResultAsync; /** Reads the P2P token (ERC20) balance for a given address (raw bigint). */ getP2pTokenBalance(params: GetP2pTokenBalanceParams): ResultAsync; readonly stake: StakeAction; readonly topUp: TopUpAction; readonly requestUnstake: RequestUnstakeAction; readonly cancelUnstake: CancelUnstakeAction; readonly claimUnstake: ClaimUnstakeAction; } type OrdersErrorCode = "VALIDATION_ERROR" | "INVALID_ORDER_ID" | "INVALID_GET_ORDERS_PARAMS" | "INVALID_FEE_CONFIG_PARAMS" | "INVALID_PLACEMENT_LIMITS_PARAMS" | "ORDER_NOT_FOUND" | "CONTRACT_READ_FAILED" | "SUBGRAPH_REQUEST_FAILED" | "SUBGRAPH_VALIDATION_FAILED" | "MALFORMED_ORDER" | "CIRCLE_SELECTION_FAILED" | "ENCRYPTION_FAILED" | "RELAY_IDENTITY_CORRUPT" | "RELAY_IDENTITY_STORE_FAILED" | "TX_SUBMISSION_FAILED" | "RECEIPT_TIMEOUT" | "TX_REVERTED" | "EVENT_WATCH_FAILED"; declare class OrdersError extends SdkError { constructor(message: string, options: { code: OrdersErrorCode; cause?: unknown; context?: Record; }); } interface Logger { debug(message: string, data?: Record): void; info(message: string, data?: Record): void; warn(message: string, data?: Record): void; error(message: string, data?: Record): void; } interface RelayIdentity { readonly address: `0x${string}`; readonly publicKey: string; readonly privateKey: `0x${string}`; } interface RelayIdentityStore { get(): Promise; set(identity: RelayIdentity): Promise; } declare const ZodGetOrderParamsSchema: z.ZodObject<{ orderId: z.ZodBigInt; }, z.core.$strip>; type GetOrderParams = z.infer; declare const ZodGetFeeConfigParamsSchema: z.ZodObject<{ currency: z.ZodEnum<{ IDR: "IDR"; INR: "INR"; BRL: "BRL"; ARS: "ARS"; MEX: "MEX"; VEN: "VEN"; BOB: "BOB"; EUR: "EUR"; NGN: "NGN"; USD: "USD"; COP: "COP"; CUP: "CUP"; ECU: "ECU"; PEN: "PEN"; PHP: "PHP"; }>; }, z.core.$strip>; type GetFeeConfigParams = z.infer; declare const ZodGetPlacementLimitsParamsSchema: z.ZodObject<{ userAddress: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>; }, z.core.$strip>; type GetPlacementLimitsParams = z.infer; declare const ZodGetOrdersParamsSchema: z.ZodObject<{ userAddress: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>; skip: z.ZodDefault; limit: z.ZodDefault; }, z.core.$strip>; type GetOrdersParams = z.input; declare const ZodPlaceOrderParamsSchema: z.ZodObject<{ orderType: z.ZodNumber; currency: z.ZodEnum<{ IDR: "IDR"; INR: "INR"; BRL: "BRL"; ARS: "ARS"; MEX: "MEX"; VEN: "VEN"; BOB: "BOB"; EUR: "EUR"; NGN: "NGN"; USD: "USD"; COP: "COP"; CUP: "CUP"; ECU: "ECU"; PEN: "PEN"; PHP: "PHP"; }>; user: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>; amount: z.ZodBigInt; fiatAmount: z.ZodBigInt; fiatAmountLimit: z.ZodDefault>; recipientAddr: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>; preferredPaymentChannelConfigId: z.ZodOptional; pubKey: z.ZodOptional; }, z.core.$strip>; type PlaceOrderParams = z.input; declare const ZodCancelOrderParamsSchema: z.ZodObject<{ orderId: z.ZodBigInt; }, z.core.$strip>; type CancelOrderParams = z.infer; declare const ZodSetSellOrderUpiParamsSchema: z.ZodObject<{ orderId: z.ZodBigInt; paymentAddress: z.ZodString; merchantPublicKey: z.ZodString; updatedAmount: z.ZodBigInt; }, z.core.$strip>; type SetSellOrderUpiParams = z.infer; declare const ZodRaiseDisputeParamsSchema: z.ZodObject<{ orderId: z.ZodBigInt; redactTransId: z.ZodBigInt; }, z.core.$strip>; type RaiseDisputeParams = z.infer; declare const ZodApproveUsdcParamsSchema: z.ZodObject<{ amount: z.ZodBigInt; }, z.core.$strip>; type ApproveUsdcParams = z.infer; declare const ZodPaidBuyOrderParamsSchema: z.ZodObject<{ orderId: z.ZodBigInt; }, z.core.$strip>; type PaidBuyOrderParams = z.infer; type OrderType = "buy" | "sell" | "pay"; type OrderStatus = "placed" | "accepted" | "paid" | "completed" | "cancelled"; type DisputeStatus = "none" | "open" | "resolved"; /** * Normalized order record returned by both `getOrder` and `getOrders`. * Amounts are 6-decimal bigints; timestamps are unix seconds. */ interface Order { orderId: bigint; type: OrderType; status: OrderStatus; usdcAmount: bigint; fiatAmount: bigint; actualUsdcAmount: bigint; actualFiatAmount: bigint; currency: string; user: Address; recipient: Address; acceptedMerchant: Address; placedAt: bigint; acceptedAt: bigint; paidAt: bigint; completedAt: bigint; circleId: bigint; fixedFeePaid: bigint; tipsPaid: bigint; disputeStatus: DisputeStatus; /** * Encrypted UPI / payment address that the merchant published for this order * (set when the merchant accepts a buy order). Empty string until set. * Decrypt with `decryptPaymentAddress`. */ encUpi: string; /** * Encrypted merchant UPI for the seller-side flow (set by `setSellOrderUpi`). * Empty string until set. */ encMerchantUpi: string; /** Public key associated with the order, used for ECIES encryption setup. */ pubkey: string; } /** * Per-currency small-order fee config read from the Diamond. * Amounts are 6-decimal bigints. */ interface FeeConfig { /** Order amounts at or below this threshold are billed the fixed fee. */ smallOrderThreshold: bigint; /** Fixed fee applied to small orders (6 decimals). */ smallOrderFixedFee: bigint; } /** * Whether a daily placement cap is actually in force. * - `enforced` — a cap is set and the contract will reject placements past it. * - `unlimited` — the cap is explicitly zero, which the contract reads as no * cap at all (sell/pay only; a zero buy cap blocks every buy instead). * - `unknown` — no cap has been indexed yet, so nothing here should be shown * as a limit. Let the contract be the judge. */ type PlacementLimitState = "enforced" | "unlimited" | "unknown"; /** * One daily placement bucket. `used` counts every order placed today INCLUDING * ones that were later cancelled — the on-chain counter is never credited back, * so cancelling does not free up an allowance. */ interface PlacementBucket { used: number; /** The cap itself. Null unless `state` is `enforced`. */ limit: number | null; /** `limit - used`, floored at zero. Null unless `state` is `enforced`. */ remaining: number | null; state: PlacementLimitState; } /** * Per-user daily order placement allowances, read from the subgraph. SELL and * PAY draw on one shared bucket; BUY has its own. Both reset at UTC midnight. */ interface PlacementLimits { /** UTC day these counts belong to (unix seconds / 86400). */ dayIndex: number; /** Unix seconds at which the buckets reset (the next UTC midnight). */ resetsAt: number; buy: PlacementBucket; sellPay: PlacementBucket; } interface PreparedTxMeta { readonly circleId?: bigint; readonly relayIdentity?: RelayIdentity; } interface PreparedTx { readonly to: `0x${string}`; readonly data: `0x${string}`; readonly value: bigint; readonly meta?: PreparedTxMeta; } interface TxResultMeta extends PreparedTxMeta { /** * Populated on `placeOrder.execute({ waitForReceipt: true })` — the orderId * parsed from the `OrderPlaced` event in the receipt's logs. Undefined when * `waitForReceipt` is not set (no receipt means no logs to parse). */ readonly orderId?: bigint; } interface TxResult { readonly hash: `0x${string}`; readonly receipt?: TransactionReceipt; readonly meta?: TxResultMeta; } interface ExecuteBase { readonly walletClient: WalletClient; readonly waitForReceipt?: boolean; } type OrderEvent = { readonly type: "placed"; readonly orderId: bigint; readonly user: Address; readonly orderType: 0 | 1 | 2; readonly blockNumber: bigint; readonly txHash: `0x${string}`; } | { readonly type: "accepted"; readonly orderId: bigint; readonly merchant: Address; readonly blockNumber: bigint; readonly txHash: `0x${string}`; } | { readonly type: "paid"; readonly orderId: bigint; readonly blockNumber: bigint; readonly txHash: `0x${string}`; } | { readonly type: "completed"; readonly orderId: bigint; readonly blockNumber: bigint; readonly txHash: `0x${string}`; } | { readonly type: "cancelled"; readonly orderId: bigint; readonly blockNumber: bigint; readonly txHash: `0x${string}`; }; interface ApproveUsdcAction { prepare(params: ApproveUsdcParams): ResultAsync; execute(params: ApproveUsdcParams & ExecuteBase): ResultAsync; } interface CancelOrderAction { prepare(params: CancelOrderParams): ResultAsync; execute(params: CancelOrderParams & ExecuteBase): ResultAsync; } interface PaidBuyOrderAction { prepare(params: PaidBuyOrderParams): ResultAsync; execute(params: PaidBuyOrderParams & ExecuteBase): ResultAsync; } interface PlaceOrderAction { prepare(params: PlaceOrderParams): ResultAsync; execute(params: PlaceOrderParams & ExecuteBase): ResultAsync; } interface RaiseDisputeAction { prepare(params: RaiseDisputeParams): ResultAsync; execute(params: RaiseDisputeParams & ExecuteBase): ResultAsync; } interface SetSellOrderUpiAction { prepare(params: SetSellOrderUpiParams): ResultAsync; execute(params: SetSellOrderUpiParams & ExecuteBase): ResultAsync; } interface WatchEventsParams { readonly user?: Address; readonly onEvent: (event: OrderEvent) => void; readonly onError?: (error: OrdersError) => void; } type WatchEvents = (params: WatchEventsParams) => () => void; interface OrdersClient { /** Reads a single order by id from the Diamond contract. */ getOrder(params: GetOrderParams): ResultAsync; /** * Lists orders created by `userAddress` from the subgraph, newest first. * Defaults: `skip = 0`, `limit = 20`. Max `limit` is 100. */ getOrders(params: GetOrdersParams): ResultAsync; /** * Reads the per-currency small-order fee config from the Diamond via * multicall: threshold (below which the fixed fee applies) and the fixed * fee itself. Both are 6-decimal bigints. */ getFeeConfig(params: GetFeeConfigParams): ResultAsync; /** * Reads the user's daily order placement allowances from the subgraph — how * many buy and sell/pay orders they have placed today and the caps in force. * Cancelled orders still count; SELL and PAY share one bucket. * * Advisory only: the subgraph lags the chain, so use it to warn or disable a * button, never as the final word on whether a placement will succeed. */ getPlacementLimits(params: GetPlacementLimitsParams): ResultAsync; readonly placeOrder: PlaceOrderAction; readonly cancelOrder: CancelOrderAction; readonly setSellOrderUpi: SetSellOrderUpiAction; readonly raiseDispute: RaiseDisputeAction; readonly approveUsdc: ApproveUsdcAction; readonly paidBuyOrder: PaidBuyOrderAction; watchEvents: WatchEvents; /** * Decrypts an `encUpi` / `encMerchantUpi` ciphertext from an order using the * relay identity resolved from the configured store. Returns the plaintext * payment address. */ decryptPaymentAddress(params: { encrypted: string; }): ResultAsync; /** * Signs `paymentAddress` with the resolved relay identity and ECIES-encrypts * the payload for `recipientPublicKey`. Returns the hex-stringified ciphertext * suitable for on-chain storage (e.g. as the merchant's encUpi when calling * `setSellOrderUpi`). */ encryptPaymentAddress(params: { paymentAddress: string; recipientPublicKey: string; }): ResultAsync; } type PricesErrorCode = "VALIDATION_ERROR" | "CONTRACT_READ_ERROR"; declare class PricesError extends SdkError { constructor(message: string, options: { code: PricesErrorCode; cause?: unknown; context?: Record; }); } /** * Shared param shape for every currency-scoped read in this module * (`getPriceConfig`, `getReputationPerUsdcLimit`). All methods take `{ currency }`. */ declare const ZodCurrencyScopedParamsSchema: z.ZodObject<{ currency: z.ZodEnum<{ IDR: "IDR"; INR: "INR"; BRL: "BRL"; ARS: "ARS"; MEX: "MEX"; VEN: "VEN"; BOB: "BOB"; EUR: "EUR"; NGN: "NGN"; USD: "USD"; COP: "COP"; CUP: "CUP"; ECU: "ECU"; PEN: "PEN"; PHP: "PHP"; }>; }, z.core.$strip>; type CurrencyScopedParams = z.infer; interface PriceConfig { readonly buyPrice: bigint; readonly sellPrice: bigint; readonly buyPriceOffset: bigint; readonly baseSpread: bigint; } /** * Per-currency USDC transaction limit granted per Reputation Point (RP). * Default is 1 RP = 2 USDC everywhere except India (INR), which has its own * multiplier set on-chain. * * multiplier = denominator / numerator // USDC per RP */ interface ReputationLimit { readonly numerator: bigint; readonly denominator: bigint; /** USDC per Reputation Point, computed from the rational form. */ readonly multiplier: number; } interface Prices { /** Reads buy/sell price config for a given currency (raw bigint, 6 decimals). */ getPriceConfig(params: CurrencyScopedParams): ResultAsync; /** * Reads the per-currency USDC transaction limit granted per Reputation Point * (RP). Default is 1 RP = 2 USDC everywhere except INR, which uses its own * on-chain multiplier. */ getReputationPerUsdcLimit(params: CurrencyScopedParams): ResultAsync; } type ProfileErrorCode = "VALIDATION_ERROR" | "CONTRACT_READ_ERROR"; declare class ProfileError extends SdkError { constructor(message: string, options: { code: ProfileErrorCode; cause?: unknown; context?: Record; }); } declare const ZodUsdcBalanceParamsSchema: z.ZodObject<{ address: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>; }, z.core.$strip>; type UsdcBalanceParams = z.infer; declare const ZodUsdcAllowanceParamsSchema: z.ZodObject<{ owner: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>; }, z.core.$strip>; type UsdcAllowanceParams = z.infer; declare const ZodGetBalancesParamsSchema: z.ZodObject<{ address: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>; currency: z.ZodEnum<{ IDR: "IDR"; INR: "INR"; BRL: "BRL"; ARS: "ARS"; MEX: "MEX"; VEN: "VEN"; BOB: "BOB"; EUR: "EUR"; NGN: "NGN"; USD: "USD"; COP: "COP"; CUP: "CUP"; ECU: "ECU"; PEN: "PEN"; PHP: "PHP"; }>; }, z.core.$strip>; type GetBalancesParams = z.infer; declare const ZodTxLimitsParamsSchema: z.ZodObject<{ address: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>; currency: z.ZodEnum<{ IDR: "IDR"; INR: "INR"; BRL: "BRL"; ARS: "ARS"; MEX: "MEX"; VEN: "VEN"; BOB: "BOB"; EUR: "EUR"; NGN: "NGN"; USD: "USD"; COP: "COP"; CUP: "CUP"; ECU: "ECU"; PEN: "PEN"; PHP: "PHP"; }>; }, z.core.$strip>; type TxLimitsParams = z.infer; interface TxLimits { readonly buyLimit: number; readonly sellLimit: number; } interface Balances { /** USDC balance formatted to a number. */ readonly usdc: number; /** Fiat equivalent: usdc * sellPrice. */ readonly fiat: number; /** The sell price used for conversion. */ readonly sellPrice: number; } interface Profile { /** Reads the USDC balance for a given address (raw bigint, 6 decimals). */ getUsdcBalance(params: UsdcBalanceParams): ResultAsync; /** Reads the USDC allowance `owner → diamond` (raw bigint, 6 decimals). */ getUsdcAllowance(params: UsdcAllowanceParams): ResultAsync; /** Fetches USDC and fiat balance in parallel for a given address and currency. */ getBalances(params: GetBalancesParams): ResultAsync; /** Reads buy and sell transaction limits for a given address and currency. */ getTxLimits(params: TxLimitsParams): ResultAsync; } type FraudEngineErrorCode = "API_ERROR" | "ENCRYPTION_ERROR" | "SIGNING_ERROR" | "VALIDATION_ERROR" | "NETWORK_ERROR" | "PLACE_ORDER_ERROR"; declare class FraudEngineError extends SdkError { constructor(message: string, options: { code: FraudEngineErrorCode; cause?: unknown; context?: Record; }); } interface FraudEngineSigner { /** * The subject address tracked by the fraud engine — the wallet that places * on-chain orders and appears in reports, watchlist, and risk scoring. * * - For thirdweb smart wallets (ERC-4337 / account abstraction) this is the * smart account address. * - For plain EOA wallets this is the same address that produces signatures. */ readonly address: string; /** * The address of the key that actually produces the EIP-191 signature. * Defaults to {@link address} when omitted. * * Set this only when the tracked subject is a smart wallet whose admin EOA * is the real signer (smart wallet contracts cannot sign EIP-191 directly). * In that case, {@link address} is the smart wallet and `signerAddress` is * the admin EOA. */ readonly signerAddress?: string; signMessage(message: string): Promise; } interface DeviceDetails { readonly userAgent: string; readonly platform: string; readonly language: string; readonly languages: string[]; readonly screenWidth: number; readonly screenHeight: number; readonly devicePixelRatio: number; readonly timezone: string; readonly timezoneOffset: number; readonly cookiesEnabled: boolean; readonly doNotTrack: string | null; readonly online: boolean; readonly connectionType?: string; readonly deviceMemory?: number; readonly hardwareConcurrency?: number; readonly touchSupport: boolean; readonly maxTouchPoints: number; readonly vendor: string; readonly appVersion: string; readonly colorDepth: number; readonly pixelDepth: number; readonly ip?: string; readonly seonSession?: string; } interface BuyOrderDetails { readonly cryptoAmount: number; readonly fiatAmount: number; readonly currency: string; readonly recipientAddress: string; readonly fee: number; readonly amountAfterFee: number; readonly paymentMethod?: string; readonly estimatedProcessingTime?: string; } interface UserDetails { readonly currency?: string; readonly country?: string; readonly language?: string; readonly loginMethod?: "email" | "google" | "phone" | "passkey" | "unknown"; readonly loginEmail?: string; readonly loginPhone?: string; } interface FraudCheckResult { readonly approved: boolean; readonly activityLogId: number; readonly message: string; /** * Link an on-chain order ID to this activity log record. * Call after the buy order is placed on-chain (fire-and-forget). * The signer and activityLogId are captured internally — just pass the orderId. */ linkOrder(orderId: string): neverthrow.ResultAsync; } interface LinkOrderResult { readonly success: boolean; readonly message: string; } interface FingerprintLogResult { readonly success: boolean; readonly message: string; } type ProcessBuyOrderResult = { readonly status: "placed"; readonly orderId: string; } | { readonly status: "rejected"; readonly message: string; }; interface FraudEngine { init(): Promise; /** * Low-level: run fraud check only. Returns result with `linkOrder()` for manual linking. * For most consumers, prefer `processBuyOrder()` which handles the full flow. */ checkBuyOrder(params: { signer: FraudEngineSigner; orderDetails: BuyOrderDetails; userDetails?: UserDetails; orderSource?: string; }): neverthrow.ResultAsync; /** * Full orchestration: fraud check → place order → auto-link. * * - Runs fraud check on all buy orders (backend handles currency-specific logic). * If rejected, returns `{ status: "rejected" }` without calling `placeOrder`. * If approved, calls `placeOrder`, auto-links activity log, returns `{ status: "placed", orderId }`. * - Fail-open: if fraud check API errors, still calls `placeOrder` (no linking since no activityLogId). * - Linking is fire-and-forget: if link fails, order is already placed — error is logged, not propagated. */ processBuyOrder(params: { signer: FraudEngineSigner; orderDetails: BuyOrderDetails; userDetails?: UserDetails; orderSource?: string; placeOrder: () => Promise; }): neverthrow.ResultAsync; logFingerprint(params: { signer: FraudEngineSigner; }): neverthrow.ResultAsync; getFingerprint(): Promise<{ visitorId: string; confidence: number; } | null>; getDeviceDetails(): Promise; cleanupSeonStorage(): void; } interface FraudEngineSdkConfig { readonly apiUrl: string; readonly encryptionKey: string; readonly seonRegion?: string; } interface OrdersSdkConfig { readonly relayIdentityStore?: RelayIdentityStore; readonly relayIdentity?: RelayIdentity; } interface SdkConfig { readonly publicClient: PublicClientLike; readonly subgraphUrl: string; readonly diamondAddress: Address; readonly usdcAddress: Address; readonly p2pTokenAddress: Address; readonly reputationManagerAddress?: Address; readonly fraudEngine?: FraudEngineSdkConfig; readonly orders?: OrdersSdkConfig; readonly logger?: Logger; } interface Sdk { readonly profile: Profile; readonly prices: Prices; readonly orders: OrdersClient; readonly stake: StakeClient; readonly zkkyc?: Zkkyc; readonly fraudEngine?: FraudEngine; } /** * Provides Profile, Orders, Zkkyc, and FraudEngine instances to all children. * * Object props (`publicClient`, `logger`) are captured on mount and do **not** trigger * re-instantiation on subsequent renders. To swap them (e.g. switching chains), remount * the provider with a React `key`: * * ```tsx * * ``` * * Primitive props (`subgraphUrl`, `diamondAddress`, etc.) are compared by value and will * trigger re-instantiation when they actually change. */ declare function SdkProvider({ children, ...config }: SdkConfig & { readonly children: ReactNode; }): react_jsx_runtime.JSX.Element; /** Returns the full SDK object from the nearest SdkProvider. */ declare function useSdk(): Sdk; /** Returns the Profile instance from the nearest SdkProvider. */ declare function useProfile(): Profile; /** Returns the Prices instance from the nearest SdkProvider. */ declare function usePrices(): Prices; /** Returns the Orders instance from the nearest SdkProvider. */ declare function useOrders(): OrdersClient; /** Returns the Stake instance from the nearest SdkProvider. */ declare function useStake(): StakeClient; /** Returns the Zkkyc instance from the nearest SdkProvider. */ declare function useZkkyc(): Zkkyc; /** Returns the FraudEngine instance from the nearest SdkProvider. */ declare function useFraudEngine(): FraudEngine; interface UsePlacementLimitsParams { /** Omit or pass undefined while no wallet is connected — no request is made. */ readonly userAddress?: Address; /** Optional polling interval in ms. Omit for no polling. */ readonly pollMs?: number; } interface UsePlacementLimitsResult { limits: PlacementLimits | null; isLoading: boolean; error: OrdersError | null; /** Refetches immediately. Call after a placement lands so the count catches up. */ refresh: () => void; } /** * Reads the user's daily order placement allowances and keeps them fresh: * refetches on address change, on an optional interval, and once the UTC day * rolls over so a form left open across midnight stops showing a spent bucket. * * Advisory only — the subgraph lags the chain, so use this to warn or disable a * control, never to decide whether a placement is legal. */ declare function usePlacementLimits(params: UsePlacementLimitsParams): UsePlacementLimitsResult; /** * Subscribes to Diamond order lifecycle events for the lifetime of the * component. Unsubscribes automatically on unmount or when `user` changes. * * Callbacks are captured in refs so consumers may pass inline arrow * functions without causing the underlying subscriptions to thrash on * every render. */ declare function useWatchOrders(params: WatchEventsParams): void; interface UseFingerprintResult { data: { visitorId: string; confidence: number; } | null; error: Error | null; isLoading: boolean; } declare function useFingerprint(enabled: boolean): UseFingerprintResult; export { type FraudEngineSdkConfig, type OrdersSdkConfig, type SdkConfig, SdkProvider, type UsePlacementLimitsParams, type UsePlacementLimitsResult, useFingerprint, useFraudEngine, useOrders, usePlacementLimits, usePrices, useProfile, useSdk, useStake, useWatchOrders, useZkkyc };