Development workflow for the Trustware SDK - a React provider and widget for cross-chain bridging and top-up routes. Includes local development setup, architecture understanding, and common development tasks.
This skill helps you work with the Trustware SDK, a React provider, widget, and headless API for cross-chain bridging and top-up routes. It powers seamless fund transfers across chains with typed APIs for quoting, route selection, and transaction execution.
First, ensure all dependencies are installed and the project passes validation:
```bash
npm install
npm run validate
```
The validation runs typechecking, strict linting, and format checks.
For active development with hot reloading:
```bash
npm run dev
```
This runs the SDK in watch mode, rebuilding automatically on changes.
To test SDK changes in the example webapp, use npm link:
**Step 1: Create the link from SDK**
```bash
nvm use 22
cd /path/to/trustware-sdk
npm link
```
**Step 2: Consume the link in example-webapp**
```bash
cd /path/to/example-webapp
npm link @trustware/sdk
```
**Step 3: Run both in parallel**
Terminal 1 (SDK watch mode):
```bash
cd /path/to/trustware-sdk
npm run dev
```
Terminal 2 (Example webapp):
```bash
cd /path/to/example-webapp
npm run dev
```
**Important**: After running `npm install` in example-webapp, the symlink may be replaced. Re-run `npm link @trustware/sdk` to restore the local link.
When ready to build:
```bash
npm run build
```
Output goes to `dist/` with ESM, CJS, and TypeScript declarations.
Ensure bundle stays within limits:
```bash
npm run size
```
Limit is 50 KB gzipped.
The TrustwareWidget follows an 8-state flow:
```
Welcome
→ ChainTokenSelection
→ AmountEntry
→ Quoting
→ WalletConnection
→ PaymentProcessing
→ Success/Failure
```
Each state is defined in `src/widget-v2/`.
WalletConnect is enabled by default with a built-in project ID. Users can:
**Critical**: Route amounts must be converted to the token's smallest unit (like wei for ETH) before sending to backend.
Location: `src/widget-v2/hooks/useRouteBuilder.ts`
```typescript
const decimals = selectedToken.decimals || 18;
const [whole, fraction = ""] = amount.split(".");
const paddedFraction = fraction.padEnd(decimals, "0").slice(0, decimals);
const fromAmountWei = (whole + paddedFraction).replace(/^0+/, "") || "0";
```
**Critical**: After getting a transaction hash from wallet, you must call `submitReceipt()` to notify the backend.
Location: `src/widget-v2/hooks/useTransactionSubmit.ts`
```typescript
// After sendRouteTransaction() returns hash
await submitReceipt(routeResult.intentId, hash);
```
Current UI uses:
Files: `src/widget-v2/styles.css`, `tailwind.config.js`
1. Create hook file in `src/hooks/`
2. Export from `src/hooks/index.ts`
3. Re-export from `src/index.ts` if public API
4. Add TypeScript types in `src/types/`
1. Locate state in `src/widget-v2/`
2. Update state machine logic if changing flow
3. Test all transitions (Welcome → Success/Failure)
4. Verify with example webapp
1. Modify files in `src/wallets/`
2. Test detection logic for all supported wallets
3. Verify WalletConnect flow if applicable
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/trustware-sdk-development/raw