@cawabunga_aurora/bridge-sdk
v0.1.4
Published
The Bridge SDK for Defuse Protocol provides a comprehensive set of tools for interacting with various bridge implementations. It simplifies the process of transferring assets between different blockchains.
Readme
@cawabunga_aurora/bridge-sdk
The Bridge SDK for Defuse Protocol provides a comprehensive set of tools for interacting with various bridge implementations. It simplifies the process of transferring assets between different blockchains.
Features
- Support for multiple bridge implementations (Direct, Hot, POA)
- Withdrawal functionality (single and batch)
- Intent-based operations with customizable signers and relayers
- Fee estimation and validation
- TypeScript support with comprehensive type definitions
Installation
# Using npm
npm install @cawabunga_aurora/bridge-sdk
# Using yarn
yarn add @cawabunga_aurora/bridge-sdk
# Using pnpm
pnpm add @cawabunga_aurora/bridge-sdk
# Using bun
bun add @cawabunga_aurora/bridge-sdkQuick Start
import { BridgeSDK } from '@cawabunga_aurora/bridge-sdk';
// Initialize the SDK with appropriate bridges and intent handlers
const sdk = new BridgeSDK({
bridges: [...],
intentRelayer: {...},
intentSigner: {...}
});
// Create a withdrawal
const withdrawal = sdk.createWithdrawal({
withdrawalParams: {
// withdrawal parameters
}
});
// Execute the withdrawal
const result = await withdrawal.execute();Development
Prerequisites
- Bun (v1.2.13 or later)
Setup
# Install dependencies
bun installBuild
bun run buildDevelopment Mode
bun run devLint
bun run lintFormat
bun run formatAdvanced Usage
Working with Different Bridge Types
The SDK supports multiple bridge implementations:
import {
DirectBridge,
HotBridge,
PoaBridge
} from '@cawabunga_aurora/bridge-sdk';
// Initialize a direct bridge
const directBridge = new DirectBridge({...});
// Initialize a hot bridge
const hotBridge = new HotBridge({...});
// Initialize a POA bridge
const poaBridge = new PoaBridge({...});
// Use in the SDK
const sdk = new BridgeSDK({
bridges: [directBridge, hotBridge, poaBridge],
// ...other config
});Batch Withdrawals
const batchWithdrawal = sdk.createBatchWithdrawals({
withdrawalParams: [
// multiple withdrawal parameter objects
]
});
const results = await batchWithdrawal.execute();Custom Intent Handling
The SDK allows for custom intent payload and relay parameter factories:
const withdrawal = sdk.createWithdrawal({
withdrawalParams: {...},
intent: {
payload: (params) => { /* custom payload logic */ },
relayParams: (params) => { /* custom relay params logic */ }
}
});License
MIT
