zerc20-client-sdk 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -0
- package/dist/assets/abi/Verifier.json +2093 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/operations/receive/__tests__/redeemTransaction.test.js +38 -0
- package/dist/operations/receive/__tests__/redeemTransaction.test.js.map +1 -1
- package/dist/operations/receive/index.d.ts +1 -1
- package/dist/operations/receive/index.d.ts.map +1 -1
- package/dist/operations/receive/index.js.map +1 -1
- package/dist/operations/receive/redeemTransaction.d.ts +2 -1
- package/dist/operations/receive/redeemTransaction.d.ts.map +1 -1
- package/dist/operations/receive/redeemTransaction.js +11 -5
- package/dist/operations/receive/redeemTransaction.js.map +1 -1
- package/dist/operations/receive/types.d.ts +25 -2
- package/dist/operations/receive/types.d.ts.map +1 -1
- package/dist/operations/relay/__tests__/relay.test.d.ts +2 -0
- package/dist/operations/relay/__tests__/relay.test.d.ts.map +1 -0
- package/dist/operations/relay/__tests__/relay.test.js +270 -0
- package/dist/operations/relay/__tests__/relay.test.js.map +1 -0
- package/dist/operations/relay/index.d.ts +3 -0
- package/dist/operations/relay/index.d.ts.map +1 -0
- package/dist/operations/relay/index.js +2 -0
- package/dist/operations/relay/index.js.map +1 -0
- package/dist/operations/relay/relay.d.ts +18 -0
- package/dist/operations/relay/relay.d.ts.map +1 -0
- package/dist/operations/relay/relay.js +103 -0
- package/dist/operations/relay/relay.js.map +1 -0
- package/dist/operations/relay/types.d.ts +63 -0
- package/dist/operations/relay/types.d.ts.map +1 -0
- package/dist/operations/relay/types.js +2 -0
- package/dist/operations/relay/types.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -94,6 +94,7 @@ src/
|
|
|
94
94
|
│ ├── invoice.ts # Invoice creation
|
|
95
95
|
│ ├── teleport.ts # Single teleport proof
|
|
96
96
|
│ ├── teleportProof.ts # Batch teleport proof (Nova + Decider)
|
|
97
|
+
│ ├── relay/ # Relay node HTTP client (redeem/swap)
|
|
97
98
|
│ ├── liquidityManager/ # Wrap/unwrap with slippage protection
|
|
98
99
|
│ └── layerzeroScan/ # LayerZero message tracking & decoding
|
|
99
100
|
├── wasm/ # WASM runtime & bindings
|
|
@@ -170,6 +171,39 @@ const quote = await buildCrossUnwrapQuote({
|
|
|
170
171
|
});
|
|
171
172
|
```
|
|
172
173
|
|
|
174
|
+
### Relay Operations
|
|
175
|
+
|
|
176
|
+
Interact with a relay node for relayer-based redeem and token-to-native swap flows:
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
import {
|
|
180
|
+
estimateRelayFee,
|
|
181
|
+
fetchSwapQuote,
|
|
182
|
+
submitRelaySwap,
|
|
183
|
+
submitRelayTeleport,
|
|
184
|
+
} from "zerc20-client-sdk";
|
|
185
|
+
|
|
186
|
+
const fee = await estimateRelayFee("https://relay.example", 1);
|
|
187
|
+
|
|
188
|
+
const quote = await fetchSwapQuote("https://relay.example", 1, 1_000_000n);
|
|
189
|
+
if (quote.priceFallback) {
|
|
190
|
+
console.warn("Relay is using fallback oracle prices");
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
await submitRelaySwap("https://relay.example", {
|
|
194
|
+
chainId: 1,
|
|
195
|
+
tokenAmount: 1_000_000n,
|
|
196
|
+
minNativeAmount: 900_000n,
|
|
197
|
+
maxNativeAmount: quote.nativeAmount,
|
|
198
|
+
recipient: "0x...",
|
|
199
|
+
owner: "0x...",
|
|
200
|
+
permitDeadline: 1_700_000_000n,
|
|
201
|
+
permitV: 27,
|
|
202
|
+
permitR: "0x...",
|
|
203
|
+
permitS: "0x...",
|
|
204
|
+
});
|
|
205
|
+
```
|
|
206
|
+
|
|
173
207
|
### Adaptor Withdraw (Stuck Fund Recovery)
|
|
174
208
|
|
|
175
209
|
When a cross-chain unwrap fails (e.g. due to Stargate liquidity shortage), user funds may remain in the destination chain's Adaptor contract. The SDK provides functions to detect and recover these stuck funds:
|