@defuse-protocol/intents-sdk 0.56.1 → 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 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)}`);
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)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defuse-protocol/intents-sdk",
3
- "version": "0.56.1",
3
+ "version": "0.57.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "repository": {
@@ -45,8 +45,8 @@
45
45
  "ripple-address-codec": "^5.0.0",
46
46
  "valibot": "^1.0.0",
47
47
  "viem": "^2.0.0",
48
- "@defuse-protocol/internal-utils": "0.29.0",
49
- "@defuse-protocol/contract-types": "0.6.2"
48
+ "@defuse-protocol/contract-types": "0.6.2",
49
+ "@defuse-protocol/internal-utils": "0.29.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "tsdown": "0.19.0"