ProtocolViewer Contract
The ProtocolViewer is a utility contract that provides convenient view functions to query deposit and intent data from the Escrow and Orchestrator contracts. It aggregates data from multiple contracts into structured views.Overview
- Contract:
ProtocolViewer.sol - Inherits:
IProtocolViewer - Purpose: Aggregates and provides structured views of deposits and intents
Key State Variables
IEscrow
required
Immutable reference to the Escrow contract
IOrchestrator
required
Immutable reference to the Orchestrator contract
Constructor
address
required
Address of the Escrow contract
address
required
Address of the Orchestrator contract
View Functions
getDeposit
Gets details for a single deposit including payment methods, currencies, and available liquidity.uint256
The ID of the deposit
uint256
The deposit ID
IEscrow.Deposit
The core deposit struct from Escrow
uint256
Total available liquidity (remainingDeposits + reclaimable from expired intents)
PaymentMethodDataView[]
Array of payment method configurations including:
paymentMethod: Payment method identifierverificationData: Payment verification datacurrencies: Array of supported currencies with min conversion rates
bytes32[]
Array of active intent hashes for this deposit
getDepositFromIds
Gets deposit details for a list of deposit IDs.uint256[]
Array of deposit IDs
getIntent
Gets details for a single intent including the associated deposit.bytes32
The hash of the intent
bytes32
The intent hash
IOrchestrator.Intent
The intent struct from Orchestrator containing:
owner: Intent owner addressto: Recipient addressescrow: Escrow contract addressdepositId: Associated deposit IDamount: Intent amountpaymentMethod: Payment method identifierfiatCurrency: Fiat currency codeconversionRate: Conversion ratepayeeId: Payee identifiertimestamp: Creation timestampreferrer: Referrer addressreferrerFee: Referrer fee amountpostIntentHook: Post-intent hook addressdata: Additional hook data
DepositView
Full deposit view for the deposit associated with this intent
getIntents
Gets details for a list of intent hashes.bytes32[]
Array of intent hashes
getAccountIntents
Gets the active intents for a specific account.address
The account address
Data Structures
DepositView
PaymentMethodDataView
IntentView
Use Cases
Frontend Integration
The ProtocolViewer is ideal for frontend applications to:- Display deposit listings with all payment methods and available liquidity
- Show intent details with full context about the underlying deposit
- Track user activity by fetching all active intents for an account
- Batch data fetching to reduce RPC calls
Example: Building a Deposit Explorer
Example: User Dashboard
Best Practices
- Batch Queries: Use
getDepositFromIdsandgetIntentsto fetch multiple records in a single call - Check Availability: Always check
availableLiquidityandacceptingIntentsbefore allowing users to signal intents - Cache Results: The view functions are read-only, so results can be cached for a short period to reduce RPC load
- Gas Optimization: For very large arrays, consider implementing pagination on your frontend