@defuse-protocol/intents-sdk 0.56.0 → 0.57.0
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 +2 -0
- package/dist/src/sdk.cjs +11 -0
- package/dist/src/sdk.js +11 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -340,6 +340,8 @@ const batchFees = await sdk.estimateWithdrawalFee({
|
|
|
340
340
|
console.log('Batch fees:', batchFees); // Array of FeeEstimation objects
|
|
341
341
|
```
|
|
342
342
|
|
|
343
|
+
> **Note:** `estimateWithdrawalFee` also runs `validateWithdrawal` internally. If the withdrawal parameters are invalid (e.g. invalid destination address, amount below minimum, insufficient UTXOs), the bridge's `validateWithdrawal` will throw and the error will propagate from `estimateWithdrawalFee`.
|
|
344
|
+
|
|
343
345
|
## Advanced Usage
|
|
344
346
|
|
|
345
347
|
### Custom RPC URLs
|
package/dist/src/sdk.cjs
CHANGED
|
@@ -211,6 +211,15 @@ var IntentsSDK = class {
|
|
|
211
211
|
if (args.withdrawalParams.feeInclusive) {
|
|
212
212
|
if (args.withdrawalParams.amount <= fee.amount) throw new require_errors.FeeExceedsAmountError(fee, args.withdrawalParams.amount);
|
|
213
213
|
}
|
|
214
|
+
const actualAmount = args.withdrawalParams.feeInclusive ? args.withdrawalParams.amount - fee.amount : args.withdrawalParams.amount;
|
|
215
|
+
await bridge.validateWithdrawal({
|
|
216
|
+
assetId: args.withdrawalParams.assetId,
|
|
217
|
+
amount: actualAmount,
|
|
218
|
+
destinationAddress: args.withdrawalParams.destinationAddress,
|
|
219
|
+
feeEstimation: fee,
|
|
220
|
+
routeConfig: args.withdrawalParams.routeConfig,
|
|
221
|
+
logger: args.logger
|
|
222
|
+
});
|
|
214
223
|
return fee;
|
|
215
224
|
}
|
|
216
225
|
throw new Error(`Cannot determine bridge for withdrawal = ${(0, viem.stringify)(args.withdrawalParams)}`);
|
|
@@ -407,10 +416,12 @@ var IntentsSDK = class {
|
|
|
407
416
|
intent: args.intent,
|
|
408
417
|
logger: args.logger
|
|
409
418
|
});
|
|
419
|
+
args.logger?.info("Intent published", { intentHash });
|
|
410
420
|
const intentTx = await this.waitForIntentSettlement({
|
|
411
421
|
intentHash,
|
|
412
422
|
logger: args.logger
|
|
413
423
|
});
|
|
424
|
+
args.logger?.info("Intent settled", { txHash: intentTx.hash });
|
|
414
425
|
const destinationTx = await this.waitForWithdrawalCompletion({
|
|
415
426
|
withdrawalParams,
|
|
416
427
|
intentTx,
|
package/dist/src/sdk.js
CHANGED
|
@@ -209,6 +209,15 @@ var IntentsSDK = class {
|
|
|
209
209
|
if (args.withdrawalParams.feeInclusive) {
|
|
210
210
|
if (args.withdrawalParams.amount <= fee.amount) throw new FeeExceedsAmountError(fee, args.withdrawalParams.amount);
|
|
211
211
|
}
|
|
212
|
+
const actualAmount = args.withdrawalParams.feeInclusive ? args.withdrawalParams.amount - fee.amount : args.withdrawalParams.amount;
|
|
213
|
+
await bridge.validateWithdrawal({
|
|
214
|
+
assetId: args.withdrawalParams.assetId,
|
|
215
|
+
amount: actualAmount,
|
|
216
|
+
destinationAddress: args.withdrawalParams.destinationAddress,
|
|
217
|
+
feeEstimation: fee,
|
|
218
|
+
routeConfig: args.withdrawalParams.routeConfig,
|
|
219
|
+
logger: args.logger
|
|
220
|
+
});
|
|
212
221
|
return fee;
|
|
213
222
|
}
|
|
214
223
|
throw new Error(`Cannot determine bridge for withdrawal = ${stringify(args.withdrawalParams)}`);
|
|
@@ -405,10 +414,12 @@ var IntentsSDK = class {
|
|
|
405
414
|
intent: args.intent,
|
|
406
415
|
logger: args.logger
|
|
407
416
|
});
|
|
417
|
+
args.logger?.info("Intent published", { intentHash });
|
|
408
418
|
const intentTx = await this.waitForIntentSettlement({
|
|
409
419
|
intentHash,
|
|
410
420
|
logger: args.logger
|
|
411
421
|
});
|
|
422
|
+
args.logger?.info("Intent settled", { txHash: intentTx.hash });
|
|
412
423
|
const destinationTx = await this.waitForWithdrawalCompletion({
|
|
413
424
|
withdrawalParams,
|
|
414
425
|
intentTx,
|