Advanced Usage
Provider Executor
For more complex scenarios, you can use the ProviderExecutor to manage multiple providers:
import { createProviderExecutor } from "@wonderland/interop";
const executor = createProviderExecutor([acrossProvider, sampleProvider]);
// The executor can be used to get quotes from multiple providers
// and execute transactions across different protocols
Error Handling
The package includes specific error types for better error handling:
import {
UnsupportedAction,
UnsupportedChainId,
UnsupportedProtocol,
} from "@wonderland/interop";
try {
// Your cross-chain operations here
} catch (error) {
if (error instanceof UnsupportedProtocol) {
// Handle unsupported protocol error
} else if (error instanceof UnsupportedAction) {
// Handle unsupported action error
} else if (error instanceof UnsupportedChainId) {
// Handle unsupported chain ID error
}
}
Best Practices
- Always validate quotes before executing transactions
- Use the appropriate provider for your use case
- Handle errors appropriately using the provided error types
- Consider using the ProviderExecutor for complex scenarios
- Test your implementation using the sample provider before moving to production
Supported Actions
The package supports two main actions:
crossChainTransfer: Transfer tokens between different chainscrossChainSwap: Swap tokens between different chains