@cowprotocol/sdk-bridging 0.11.0 → 0.12.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/dist/index.d.mts CHANGED
@@ -428,7 +428,7 @@ interface BestQuoteProviderContext extends MultiQuoteContext {
428
428
  bestResult: {
429
429
  current: MultiQuoteResult | null;
430
430
  };
431
- firstError: {
431
+ bestError: {
432
432
  current: MultiQuoteResult | null;
433
433
  };
434
434
  }
@@ -443,8 +443,10 @@ declare enum BridgeQuoteErrors {
443
443
  QUOTE_ERROR = "QUOTE_ERROR",
444
444
  NO_ROUTES = "NO_ROUTES",
445
445
  INVALID_BRIDGE = "INVALID_BRIDGE",
446
- QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS = "QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS"
446
+ QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS = "QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS",
447
+ SELL_AMOUNT_TOO_SMALL = "SELL_AMOUNT_TOO_SMALL"
447
448
  }
449
+ declare const BridgeQuoteErrorPriorities: Record<BridgeQuoteErrors, number>;
448
450
  declare class BridgeProviderQuoteError extends Error {
449
451
  readonly context?: unknown | undefined;
450
452
  constructor(message: BridgeQuoteErrors, context?: unknown | undefined);
@@ -1294,4 +1296,4 @@ declare class NearIntentsBridgeProvider implements ReceiverAccountBridgeProvider
1294
1296
  } | null>;
1295
1297
  }
1296
1298
 
1297
- export { AcrossBridgeProvider, type AcrossBridgeProviderOptions, type AcrossQuoteResult, type BestQuoteProgressCallback, type BestQuoteProviderContext, type BridgeCallDetails, type BridgeCosts, type BridgeDeposit, type BridgeHook, BridgeOrderParsingError, type BridgeProvider, BridgeProviderError, type BridgeProviderInfo, BridgeProviderQuoteError, type BridgeProviderType, type BridgeQuoteAmountsAndCosts, type BridgeQuoteAndPost, BridgeQuoteErrors, type BridgeQuoteResult, type BridgeQuoteResults, BridgeStatus, type BridgeStatusResult, type BridgingDepositParams, BridgingSdk, BungeeBridgeProvider, type BungeeBridgeProviderOptions, type BungeeQuoteResult, type BuyTokensParams, COW_SHED_PROXY_CREATION_GAS, type CrossChainOrder, type CrossChainQuoteAndPost, DEFAULT_EXTRA_GAS_FOR_HOOK_ESTIMATION, DEFAULT_EXTRA_GAS_PROXY_CREATION, DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION, type DefaultBridgeProvider, type GetProviderBuyTokens, HOOK_DAPP_BRIDGE_PROVIDER_PREFIX, type HookBridgeProvider, type MultiQuoteOptions, type MultiQuoteProgressCallback, type MultiQuoteRequest, type MultiQuoteResult, NearIntentsBridgeProvider, type NearIntentsBridgeProviderOptions, type NearIntentsQuoteResult, type ProviderQuoteContext, type QuoteBridgeRequest, type QuoteBridgeRequestWithoutAmount, RAW_PROVIDERS_FILES_PATH, type ReceiverAccountBridgeProvider, assertIsBridgeQuoteAndPost, assertIsQuoteAndPost, getCrossChainOrder, getPostHooks, isAppDoc, isBridgeQuoteAndPost, isHookBridgeProvider, isQuoteAndPost, isReceiverAccountBridgeProvider };
1299
+ export { AcrossBridgeProvider, type AcrossBridgeProviderOptions, type AcrossQuoteResult, type BestQuoteProgressCallback, type BestQuoteProviderContext, type BridgeCallDetails, type BridgeCosts, type BridgeDeposit, type BridgeHook, BridgeOrderParsingError, type BridgeProvider, BridgeProviderError, type BridgeProviderInfo, BridgeProviderQuoteError, type BridgeProviderType, type BridgeQuoteAmountsAndCosts, type BridgeQuoteAndPost, BridgeQuoteErrorPriorities, BridgeQuoteErrors, type BridgeQuoteResult, type BridgeQuoteResults, BridgeStatus, type BridgeStatusResult, type BridgingDepositParams, BridgingSdk, BungeeBridgeProvider, type BungeeBridgeProviderOptions, type BungeeQuoteResult, type BuyTokensParams, COW_SHED_PROXY_CREATION_GAS, type CrossChainOrder, type CrossChainQuoteAndPost, DEFAULT_EXTRA_GAS_FOR_HOOK_ESTIMATION, DEFAULT_EXTRA_GAS_PROXY_CREATION, DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION, type DefaultBridgeProvider, type GetProviderBuyTokens, HOOK_DAPP_BRIDGE_PROVIDER_PREFIX, type HookBridgeProvider, type MultiQuoteOptions, type MultiQuoteProgressCallback, type MultiQuoteRequest, type MultiQuoteResult, NearIntentsBridgeProvider, type NearIntentsBridgeProviderOptions, type NearIntentsQuoteResult, type ProviderQuoteContext, type QuoteBridgeRequest, type QuoteBridgeRequestWithoutAmount, RAW_PROVIDERS_FILES_PATH, type ReceiverAccountBridgeProvider, assertIsBridgeQuoteAndPost, assertIsQuoteAndPost, getCrossChainOrder, getPostHooks, isAppDoc, isBridgeQuoteAndPost, isHookBridgeProvider, isQuoteAndPost, isReceiverAccountBridgeProvider };
package/dist/index.d.ts CHANGED
@@ -428,7 +428,7 @@ interface BestQuoteProviderContext extends MultiQuoteContext {
428
428
  bestResult: {
429
429
  current: MultiQuoteResult | null;
430
430
  };
431
- firstError: {
431
+ bestError: {
432
432
  current: MultiQuoteResult | null;
433
433
  };
434
434
  }
@@ -443,8 +443,10 @@ declare enum BridgeQuoteErrors {
443
443
  QUOTE_ERROR = "QUOTE_ERROR",
444
444
  NO_ROUTES = "NO_ROUTES",
445
445
  INVALID_BRIDGE = "INVALID_BRIDGE",
446
- QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS = "QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS"
446
+ QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS = "QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS",
447
+ SELL_AMOUNT_TOO_SMALL = "SELL_AMOUNT_TOO_SMALL"
447
448
  }
449
+ declare const BridgeQuoteErrorPriorities: Record<BridgeQuoteErrors, number>;
448
450
  declare class BridgeProviderQuoteError extends Error {
449
451
  readonly context?: unknown | undefined;
450
452
  constructor(message: BridgeQuoteErrors, context?: unknown | undefined);
@@ -1294,4 +1296,4 @@ declare class NearIntentsBridgeProvider implements ReceiverAccountBridgeProvider
1294
1296
  } | null>;
1295
1297
  }
1296
1298
 
1297
- export { AcrossBridgeProvider, type AcrossBridgeProviderOptions, type AcrossQuoteResult, type BestQuoteProgressCallback, type BestQuoteProviderContext, type BridgeCallDetails, type BridgeCosts, type BridgeDeposit, type BridgeHook, BridgeOrderParsingError, type BridgeProvider, BridgeProviderError, type BridgeProviderInfo, BridgeProviderQuoteError, type BridgeProviderType, type BridgeQuoteAmountsAndCosts, type BridgeQuoteAndPost, BridgeQuoteErrors, type BridgeQuoteResult, type BridgeQuoteResults, BridgeStatus, type BridgeStatusResult, type BridgingDepositParams, BridgingSdk, BungeeBridgeProvider, type BungeeBridgeProviderOptions, type BungeeQuoteResult, type BuyTokensParams, COW_SHED_PROXY_CREATION_GAS, type CrossChainOrder, type CrossChainQuoteAndPost, DEFAULT_EXTRA_GAS_FOR_HOOK_ESTIMATION, DEFAULT_EXTRA_GAS_PROXY_CREATION, DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION, type DefaultBridgeProvider, type GetProviderBuyTokens, HOOK_DAPP_BRIDGE_PROVIDER_PREFIX, type HookBridgeProvider, type MultiQuoteOptions, type MultiQuoteProgressCallback, type MultiQuoteRequest, type MultiQuoteResult, NearIntentsBridgeProvider, type NearIntentsBridgeProviderOptions, type NearIntentsQuoteResult, type ProviderQuoteContext, type QuoteBridgeRequest, type QuoteBridgeRequestWithoutAmount, RAW_PROVIDERS_FILES_PATH, type ReceiverAccountBridgeProvider, assertIsBridgeQuoteAndPost, assertIsQuoteAndPost, getCrossChainOrder, getPostHooks, isAppDoc, isBridgeQuoteAndPost, isHookBridgeProvider, isQuoteAndPost, isReceiverAccountBridgeProvider };
1299
+ export { AcrossBridgeProvider, type AcrossBridgeProviderOptions, type AcrossQuoteResult, type BestQuoteProgressCallback, type BestQuoteProviderContext, type BridgeCallDetails, type BridgeCosts, type BridgeDeposit, type BridgeHook, BridgeOrderParsingError, type BridgeProvider, BridgeProviderError, type BridgeProviderInfo, BridgeProviderQuoteError, type BridgeProviderType, type BridgeQuoteAmountsAndCosts, type BridgeQuoteAndPost, BridgeQuoteErrorPriorities, BridgeQuoteErrors, type BridgeQuoteResult, type BridgeQuoteResults, BridgeStatus, type BridgeStatusResult, type BridgingDepositParams, BridgingSdk, BungeeBridgeProvider, type BungeeBridgeProviderOptions, type BungeeQuoteResult, type BuyTokensParams, COW_SHED_PROXY_CREATION_GAS, type CrossChainOrder, type CrossChainQuoteAndPost, DEFAULT_EXTRA_GAS_FOR_HOOK_ESTIMATION, DEFAULT_EXTRA_GAS_PROXY_CREATION, DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION, type DefaultBridgeProvider, type GetProviderBuyTokens, HOOK_DAPP_BRIDGE_PROVIDER_PREFIX, type HookBridgeProvider, type MultiQuoteOptions, type MultiQuoteProgressCallback, type MultiQuoteRequest, type MultiQuoteResult, NearIntentsBridgeProvider, type NearIntentsBridgeProviderOptions, type NearIntentsQuoteResult, type ProviderQuoteContext, type QuoteBridgeRequest, type QuoteBridgeRequestWithoutAmount, RAW_PROVIDERS_FILES_PATH, type ReceiverAccountBridgeProvider, assertIsBridgeQuoteAndPost, assertIsQuoteAndPost, getCrossChainOrder, getPostHooks, isAppDoc, isBridgeQuoteAndPost, isHookBridgeProvider, isQuoteAndPost, isReceiverAccountBridgeProvider };
package/dist/index.js CHANGED
@@ -34,6 +34,7 @@ __export(src_exports, {
34
34
  BridgeOrderParsingError: () => BridgeOrderParsingError,
35
35
  BridgeProviderError: () => BridgeProviderError,
36
36
  BridgeProviderQuoteError: () => BridgeProviderQuoteError,
37
+ BridgeQuoteErrorPriorities: () => BridgeQuoteErrorPriorities,
37
38
  BridgeQuoteErrors: () => BridgeQuoteErrors,
38
39
  BridgeStatus: () => BridgeStatus,
39
40
  BridgingSdk: () => BridgingSdk,
@@ -78,8 +79,21 @@ var BridgeQuoteErrors = /* @__PURE__ */ ((BridgeQuoteErrors2) => {
78
79
  BridgeQuoteErrors2["NO_ROUTES"] = "NO_ROUTES";
79
80
  BridgeQuoteErrors2["INVALID_BRIDGE"] = "INVALID_BRIDGE";
80
81
  BridgeQuoteErrors2["QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS"] = "QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS";
82
+ BridgeQuoteErrors2["SELL_AMOUNT_TOO_SMALL"] = "SELL_AMOUNT_TOO_SMALL";
81
83
  return BridgeQuoteErrors2;
82
84
  })(BridgeQuoteErrors || {});
85
+ var BridgeQuoteErrorPriorities = {
86
+ ["SELL_AMOUNT_TOO_SMALL" /* SELL_AMOUNT_TOO_SMALL */]: 10,
87
+ ["ONLY_SELL_ORDER_SUPPORTED" /* ONLY_SELL_ORDER_SUPPORTED */]: 9,
88
+ ["NO_INTERMEDIATE_TOKENS" /* NO_INTERMEDIATE_TOKENS */]: 1,
89
+ ["API_ERROR" /* API_ERROR */]: 1,
90
+ ["INVALID_API_JSON_RESPONSE" /* INVALID_API_JSON_RESPONSE */]: 1,
91
+ ["TX_BUILD_ERROR" /* TX_BUILD_ERROR */]: 1,
92
+ ["QUOTE_ERROR" /* QUOTE_ERROR */]: 1,
93
+ ["NO_ROUTES" /* NO_ROUTES */]: 1,
94
+ ["INVALID_BRIDGE" /* INVALID_BRIDGE */]: 1,
95
+ ["QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS" /* QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS */]: 1
96
+ };
83
97
  var BridgeProviderQuoteError = class extends Error {
84
98
  constructor(message, context) {
85
99
  super(message);
@@ -949,6 +963,25 @@ function resolveProvidersToQuery(providerDappIds, providers) {
949
963
  return provider;
950
964
  });
951
965
  }
966
+ function getErrorPriority(error) {
967
+ if (!error)
968
+ return 0;
969
+ if (error instanceof BridgeProviderQuoteError) {
970
+ return BridgeQuoteErrorPriorities[error.message] ?? 0;
971
+ }
972
+ return 0;
973
+ }
974
+ function isBetterError(error1, error2) {
975
+ if (!error2 || !error2.error) {
976
+ return !!error1?.error;
977
+ }
978
+ if (!error1?.error) {
979
+ return false;
980
+ }
981
+ const priority1 = getErrorPriority(error1.error);
982
+ const priority2 = getErrorPriority(error2.error);
983
+ return priority1 > priority2;
984
+ }
952
985
 
953
986
  // src/BridgingSdk/strategies/MultiQuoteStrategy.ts
954
987
  var DEFAULT_TOTAL_TIMEOUT_MS = 4e4;
@@ -1055,7 +1088,7 @@ var BestQuoteStrategy = class extends BaseBestQuoteStrategy {
1055
1088
  providerTimeout = DEFAULT_PROVIDER_TIMEOUT_MS2
1056
1089
  } = options || {};
1057
1090
  const bestResult = { current: null };
1058
- const firstError = { current: null };
1091
+ const bestError = { current: null };
1059
1092
  const promises = [];
1060
1093
  for (const provider of providersToQuery) {
1061
1094
  const context = {
@@ -1065,16 +1098,16 @@ var BestQuoteStrategy = class extends BaseBestQuoteStrategy {
1065
1098
  providerTimeout,
1066
1099
  onQuoteResult,
1067
1100
  bestResult,
1068
- firstError
1101
+ bestError
1069
1102
  };
1070
1103
  const promise = this.createBestQuoteProviderPromise(context, tradingSdk);
1071
1104
  promises.push(promise);
1072
1105
  }
1073
1106
  await executeProviderQuotes(promises, totalTimeout, providers);
1074
- return bestResult.current || firstError.current;
1107
+ return bestResult.current || bestError.current;
1075
1108
  }
1076
1109
  createBestQuoteProviderPromise(context, tradingSdk) {
1077
- const { provider, quoteBridgeRequest, advancedSettings, providerTimeout, onQuoteResult, bestResult, firstError } = context;
1110
+ const { provider, quoteBridgeRequest, advancedSettings, providerTimeout, onQuoteResult, bestResult, bestError } = context;
1078
1111
  return (async () => {
1079
1112
  try {
1080
1113
  const baseParams = {
@@ -1107,8 +1140,8 @@ var BestQuoteStrategy = class extends BaseBestQuoteStrategy {
1107
1140
  quote: null,
1108
1141
  error: error instanceof Error ? error : new BridgeProviderError(String(error), {})
1109
1142
  };
1110
- if (!firstError.current) {
1111
- firstError.current = errorResult;
1143
+ if (isBetterError(errorResult, bestError.current)) {
1144
+ bestError.current = errorResult;
1112
1145
  }
1113
1146
  }
1114
1147
  })();
@@ -4949,7 +4982,22 @@ var NearIntentsApi = class {
4949
4982
  return this.cachedTokens;
4950
4983
  }
4951
4984
  async getQuote(request) {
4952
- return await import_one_click_sdk_typescript.OneClickService.getQuote(request);
4985
+ try {
4986
+ return await import_one_click_sdk_typescript.OneClickService.getQuote(request);
4987
+ } catch (error) {
4988
+ if (error instanceof import_one_click_sdk_typescript.ApiError) {
4989
+ const message = error.body?.message;
4990
+ if (message && typeof message === "string" && message.toLowerCase().includes("amount is too low")) {
4991
+ const minAmountMatch = message.match(/try at least (\d+)/);
4992
+ const minAmount = minAmountMatch ? minAmountMatch[1] : void 0;
4993
+ throw new BridgeProviderQuoteError("SELL_AMOUNT_TOO_SMALL" /* SELL_AMOUNT_TOO_SMALL */, {
4994
+ originalMessage: message,
4995
+ minAmount
4996
+ });
4997
+ }
4998
+ }
4999
+ throw error;
5000
+ }
4953
5001
  }
4954
5002
  async getStatus(depositAddress) {
4955
5003
  return await import_one_click_sdk_typescript.OneClickService.getExecutionStatus(depositAddress);
@@ -5345,6 +5393,7 @@ var NearIntentsBridgeProvider = class {
5345
5393
  BridgeOrderParsingError,
5346
5394
  BridgeProviderError,
5347
5395
  BridgeProviderQuoteError,
5396
+ BridgeQuoteErrorPriorities,
5348
5397
  BridgeQuoteErrors,
5349
5398
  BridgeStatus,
5350
5399
  BridgingSdk,
package/dist/index.mjs CHANGED
@@ -19,8 +19,21 @@ var BridgeQuoteErrors = /* @__PURE__ */ ((BridgeQuoteErrors2) => {
19
19
  BridgeQuoteErrors2["NO_ROUTES"] = "NO_ROUTES";
20
20
  BridgeQuoteErrors2["INVALID_BRIDGE"] = "INVALID_BRIDGE";
21
21
  BridgeQuoteErrors2["QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS"] = "QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS";
22
+ BridgeQuoteErrors2["SELL_AMOUNT_TOO_SMALL"] = "SELL_AMOUNT_TOO_SMALL";
22
23
  return BridgeQuoteErrors2;
23
24
  })(BridgeQuoteErrors || {});
25
+ var BridgeQuoteErrorPriorities = {
26
+ ["SELL_AMOUNT_TOO_SMALL" /* SELL_AMOUNT_TOO_SMALL */]: 10,
27
+ ["ONLY_SELL_ORDER_SUPPORTED" /* ONLY_SELL_ORDER_SUPPORTED */]: 9,
28
+ ["NO_INTERMEDIATE_TOKENS" /* NO_INTERMEDIATE_TOKENS */]: 1,
29
+ ["API_ERROR" /* API_ERROR */]: 1,
30
+ ["INVALID_API_JSON_RESPONSE" /* INVALID_API_JSON_RESPONSE */]: 1,
31
+ ["TX_BUILD_ERROR" /* TX_BUILD_ERROR */]: 1,
32
+ ["QUOTE_ERROR" /* QUOTE_ERROR */]: 1,
33
+ ["NO_ROUTES" /* NO_ROUTES */]: 1,
34
+ ["INVALID_BRIDGE" /* INVALID_BRIDGE */]: 1,
35
+ ["QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS" /* QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS */]: 1
36
+ };
24
37
  var BridgeProviderQuoteError = class extends Error {
25
38
  constructor(message, context) {
26
39
  super(message);
@@ -894,6 +907,25 @@ function resolveProvidersToQuery(providerDappIds, providers) {
894
907
  return provider;
895
908
  });
896
909
  }
910
+ function getErrorPriority(error) {
911
+ if (!error)
912
+ return 0;
913
+ if (error instanceof BridgeProviderQuoteError) {
914
+ return BridgeQuoteErrorPriorities[error.message] ?? 0;
915
+ }
916
+ return 0;
917
+ }
918
+ function isBetterError(error1, error2) {
919
+ if (!error2 || !error2.error) {
920
+ return !!error1?.error;
921
+ }
922
+ if (!error1?.error) {
923
+ return false;
924
+ }
925
+ const priority1 = getErrorPriority(error1.error);
926
+ const priority2 = getErrorPriority(error2.error);
927
+ return priority1 > priority2;
928
+ }
897
929
 
898
930
  // src/BridgingSdk/strategies/MultiQuoteStrategy.ts
899
931
  var DEFAULT_TOTAL_TIMEOUT_MS = 4e4;
@@ -1000,7 +1032,7 @@ var BestQuoteStrategy = class extends BaseBestQuoteStrategy {
1000
1032
  providerTimeout = DEFAULT_PROVIDER_TIMEOUT_MS2
1001
1033
  } = options || {};
1002
1034
  const bestResult = { current: null };
1003
- const firstError = { current: null };
1035
+ const bestError = { current: null };
1004
1036
  const promises = [];
1005
1037
  for (const provider of providersToQuery) {
1006
1038
  const context = {
@@ -1010,16 +1042,16 @@ var BestQuoteStrategy = class extends BaseBestQuoteStrategy {
1010
1042
  providerTimeout,
1011
1043
  onQuoteResult,
1012
1044
  bestResult,
1013
- firstError
1045
+ bestError
1014
1046
  };
1015
1047
  const promise = this.createBestQuoteProviderPromise(context, tradingSdk);
1016
1048
  promises.push(promise);
1017
1049
  }
1018
1050
  await executeProviderQuotes(promises, totalTimeout, providers);
1019
- return bestResult.current || firstError.current;
1051
+ return bestResult.current || bestError.current;
1020
1052
  }
1021
1053
  createBestQuoteProviderPromise(context, tradingSdk) {
1022
- const { provider, quoteBridgeRequest, advancedSettings, providerTimeout, onQuoteResult, bestResult, firstError } = context;
1054
+ const { provider, quoteBridgeRequest, advancedSettings, providerTimeout, onQuoteResult, bestResult, bestError } = context;
1023
1055
  return (async () => {
1024
1056
  try {
1025
1057
  const baseParams = {
@@ -1052,8 +1084,8 @@ var BestQuoteStrategy = class extends BaseBestQuoteStrategy {
1052
1084
  quote: null,
1053
1085
  error: error instanceof Error ? error : new BridgeProviderError(String(error), {})
1054
1086
  };
1055
- if (!firstError.current) {
1056
- firstError.current = errorResult;
1087
+ if (isBetterError(errorResult, bestError.current)) {
1088
+ bestError.current = errorResult;
1057
1089
  }
1058
1090
  }
1059
1091
  })();
@@ -4898,7 +4930,7 @@ import { OrderKind as OrderKind6 } from "@cowprotocol/sdk-order-book";
4898
4930
  import { QuoteRequest } from "@defuse-protocol/one-click-sdk-typescript";
4899
4931
 
4900
4932
  // src/providers/near-intents/NearIntentsApi.ts
4901
- import { OneClickService, OpenAPI } from "@defuse-protocol/one-click-sdk-typescript";
4933
+ import { ApiError, OneClickService, OpenAPI } from "@defuse-protocol/one-click-sdk-typescript";
4902
4934
  var NearIntentsApi = class {
4903
4935
  cachedTokens = [];
4904
4936
  async getTokens() {
@@ -4909,7 +4941,22 @@ var NearIntentsApi = class {
4909
4941
  return this.cachedTokens;
4910
4942
  }
4911
4943
  async getQuote(request) {
4912
- return await OneClickService.getQuote(request);
4944
+ try {
4945
+ return await OneClickService.getQuote(request);
4946
+ } catch (error) {
4947
+ if (error instanceof ApiError) {
4948
+ const message = error.body?.message;
4949
+ if (message && typeof message === "string" && message.toLowerCase().includes("amount is too low")) {
4950
+ const minAmountMatch = message.match(/try at least (\d+)/);
4951
+ const minAmount = minAmountMatch ? minAmountMatch[1] : void 0;
4952
+ throw new BridgeProviderQuoteError("SELL_AMOUNT_TOO_SMALL" /* SELL_AMOUNT_TOO_SMALL */, {
4953
+ originalMessage: message,
4954
+ minAmount
4955
+ });
4956
+ }
4957
+ }
4958
+ throw error;
4959
+ }
4913
4960
  }
4914
4961
  async getStatus(depositAddress) {
4915
4962
  return await OneClickService.getExecutionStatus(depositAddress);
@@ -5304,6 +5351,7 @@ export {
5304
5351
  BridgeOrderParsingError,
5305
5352
  BridgeProviderError,
5306
5353
  BridgeProviderQuoteError,
5354
+ BridgeQuoteErrorPriorities,
5307
5355
  BridgeQuoteErrors,
5308
5356
  BridgeStatus,
5309
5357
  BridgingSdk,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cowprotocol/sdk-bridging",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "Bridging for CoW Protocol",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -16,14 +16,14 @@
16
16
  "dependencies": {
17
17
  "@defuse-protocol/one-click-sdk-typescript": "0.1.1-0.2",
18
18
  "json-stable-stringify": "^1.3.0",
19
- "@cowprotocol/sdk-app-data": "4.3.5",
19
+ "@cowprotocol/sdk-app-data": "4.3.6",
20
20
  "@cowprotocol/sdk-common": "0.4.0",
21
- "@cowprotocol/sdk-contracts-ts": "0.8.0",
22
- "@cowprotocol/sdk-config": "0.6.1",
23
- "@cowprotocol/sdk-order-book": "0.4.3",
24
- "@cowprotocol/sdk-cow-shed": "0.2.7",
25
- "@cowprotocol/sdk-trading": "0.7.0",
26
- "@cowprotocol/sdk-weiroll": "0.1.10"
21
+ "@cowprotocol/sdk-contracts-ts": "0.8.1",
22
+ "@cowprotocol/sdk-config": "0.6.2",
23
+ "@cowprotocol/sdk-order-book": "0.4.4",
24
+ "@cowprotocol/sdk-trading": "0.7.1",
25
+ "@cowprotocol/sdk-cow-shed": "0.2.8",
26
+ "@cowprotocol/sdk-weiroll": "0.1.11"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/jest": "^29.4.0",
@@ -41,7 +41,7 @@
41
41
  "@cow-sdk/typescript-config": "0.0.0-beta.0",
42
42
  "@cowprotocol/sdk-ethers-v5-adapter": "0.3.0",
43
43
  "@cowprotocol/sdk-ethers-v6-adapter": "0.3.0",
44
- "@cowprotocol/sdk-order-signing": "0.1.20",
44
+ "@cowprotocol/sdk-order-signing": "0.1.21",
45
45
  "@cowprotocol/sdk-viem-adapter": "0.3.0"
46
46
  },
47
47
  "scripts": {