@defuse-protocol/intents-sdk 0.27.0 → 0.28.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.cjs CHANGED
@@ -3,8 +3,9 @@ const require_route_enum = require('./src/constants/route-enum.cjs');
3
3
  const require_errors = require('./src/classes/errors.cjs');
4
4
  const require_caip2 = require('./src/lib/caip2.cjs');
5
5
  const require_bridge_name_enum = require('./src/constants/bridge-name-enum.cjs');
6
- const require_error = require('./src/bridges/hot-bridge/error.cjs');
7
- const require_error$1 = require('./src/bridges/omni-bridge/error.cjs');
6
+ const require_error = require('./src/bridges/direct-bridge/error.cjs');
7
+ const require_error$1 = require('./src/bridges/hot-bridge/error.cjs');
8
+ const require_error$2 = require('./src/bridges/omni-bridge/error.cjs');
8
9
  const require_route_config_factory = require('./src/lib/route-config-factory.cjs');
9
10
  const require_sdk = require('./src/sdk.cjs');
10
11
  const require_factories = require('./src/intents/intent-signer-impl/factories.cjs');
@@ -25,11 +26,12 @@ Object.defineProperty(exports, 'BaseError', {
25
26
  });
26
27
  exports.BridgeNameEnum = require_bridge_name_enum.BridgeNameEnum;
27
28
  exports.Chains = require_caip2.Chains;
28
- exports.FailedToFetchFeeError = require_error$1.FailedToFetchFeeError;
29
+ exports.DestinationExplicitNearAccountDoesntExistError = require_error.DestinationExplicitNearAccountDoesntExistError;
30
+ exports.FailedToFetchFeeError = require_error$2.FailedToFetchFeeError;
29
31
  exports.FeeExceedsAmountError = require_errors.FeeExceedsAmountError;
30
- exports.HotWithdrawalCancelledError = require_error.HotWithdrawalCancelledError;
31
- exports.HotWithdrawalNotFoundError = require_error.HotWithdrawalNotFoundError;
32
- exports.HotWithdrawalPendingError = require_error.HotWithdrawalPendingError;
32
+ exports.HotWithdrawalCancelledError = require_error$1.HotWithdrawalCancelledError;
33
+ exports.HotWithdrawalNotFoundError = require_error$1.HotWithdrawalNotFoundError;
34
+ exports.HotWithdrawalPendingError = require_error$1.HotWithdrawalPendingError;
33
35
  Object.defineProperty(exports, 'HttpRequestError', {
34
36
  enumerable: true,
35
37
  get: function () {
@@ -42,12 +44,12 @@ Object.defineProperty(exports, 'IntentSettlementError', {
42
44
  return __defuse_protocol_internal_utils.IntentSettlementError;
43
45
  }
44
46
  });
45
- exports.IntentsNearOmniAvailableBalanceTooLowError = require_error$1.IntentsNearOmniAvailableBalanceTooLowError;
47
+ exports.IntentsNearOmniAvailableBalanceTooLowError = require_error$2.IntentsNearOmniAvailableBalanceTooLowError;
46
48
  exports.IntentsSDK = require_sdk.IntentsSDK;
47
49
  exports.MinWithdrawalAmountError = require_errors.MinWithdrawalAmountError;
48
- exports.OmniTokenNormalisationCheckError = require_error$1.OmniTokenNormalisationCheckError;
49
- exports.OmniTransferDestinationChainHashNotFoundError = require_error$1.OmniTransferDestinationChainHashNotFoundError;
50
- exports.OmniTransferNotFoundError = require_error$1.OmniTransferNotFoundError;
50
+ exports.OmniTokenNormalisationCheckError = require_error$2.OmniTokenNormalisationCheckError;
51
+ exports.OmniTransferDestinationChainHashNotFoundError = require_error$2.OmniTransferDestinationChainHashNotFoundError;
52
+ exports.OmniTransferNotFoundError = require_error$2.OmniTransferNotFoundError;
51
53
  Object.defineProperty(exports, 'PoaWithdrawalInvariantError', {
52
54
  enumerable: true,
53
55
  get: function () {
@@ -91,7 +93,7 @@ Object.defineProperty(exports, 'TimeoutError', {
91
93
  return __defuse_protocol_internal_utils.TimeoutError;
92
94
  }
93
95
  });
94
- exports.TokenNotFoundInDestinationChainError = require_error$1.TokenNotFoundInDestinationChainError;
96
+ exports.TokenNotFoundInDestinationChainError = require_error$2.TokenNotFoundInDestinationChainError;
95
97
  exports.TrustlineNotFoundError = require_errors.TrustlineNotFoundError;
96
98
  exports.UnsupportedAssetIdError = require_errors.UnsupportedAssetIdError;
97
99
  exports.UnsupportedDestinationMemoError = require_errors.UnsupportedDestinationMemoError;
package/dist/index.d.cts CHANGED
@@ -9,7 +9,8 @@ import { IntentsSDK, IntentsSDKConfig } from "./src/sdk.cjs";
9
9
  import { createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem } from "./src/intents/intent-signer-impl/factories.cjs";
10
10
  import { createDefaultRoute, createHotBridgeRoute, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute } from "./src/lib/route-config-factory.cjs";
11
11
  import { FeeExceedsAmountError, FeeExceedsAmountErrorType, MinWithdrawalAmountError, MinWithdrawalAmountErrorType, TrustlineNotFoundError, TrustlineNotFoundErrorType, UnsupportedAssetIdError, UnsupportedAssetIdErrorType, UnsupportedDestinationMemoError, UnsupportedDestinationMemoErrorType } from "./src/classes/errors.cjs";
12
+ import { DestinationExplicitNearAccountDoesntExistError, DestinationExplicitNearAccountDoesntExistErrorType } from "./src/bridges/direct-bridge/error.cjs";
12
13
  import { HotWithdrawalCancelledError, HotWithdrawalCancelledErrorType, HotWithdrawalNotFoundError, HotWithdrawalNotFoundErrorType, HotWithdrawalPendingError, HotWithdrawalPendingErrorType } from "./src/bridges/hot-bridge/error.cjs";
13
14
  import { FailedToFetchFeeError, FailedToFetchFeeErrorType, IntentsNearOmniAvailableBalanceTooLowError, IntentsNearOmniAvailableBalanceTooLowErrorType, OmniTokenNormalisationCheckError, OmniTokenNormalisationCheckErrorType, OmniTransferDestinationChainHashNotFoundError, OmniTransferDestinationChainHashNotFoundErrorType, OmniTransferNotFoundError, OmniTransferNotFoundErrorType, TokenNotFoundInDestinationChainError, TokenNotFoundInDestinationChainErrorType } from "./src/bridges/omni-bridge/error.cjs";
14
15
  import { AssertionError, AssertionErrorType, BaseError, BaseErrorType, HttpRequestError, HttpRequestErrorType, ILogger, IntentSettlementError, IntentSettlementErrorType, NearIntentsEnv, PoaWithdrawalInvariantError, PoaWithdrawalInvariantErrorType, PoaWithdrawalNotFoundError, PoaWithdrawalNotFoundErrorType, PoaWithdrawalPendingError, PoaWithdrawalPendingErrorType, QuoteError, QuoteErrorType, RelayPublishError, RelayPublishErrorType, RetryOptions, RpcRequestError, RpcRequestErrorType, TimeoutError, TimeoutErrorType } from "@defuse-protocol/internal-utils";
15
- export { AssertionError, type AssertionErrorType, BaseError, type BaseErrorType, type BatchWithdrawalResult, BridgeNameEnum, type BridgeNameEnumValues, type Chain, Chains, FailedToFetchFeeError, type FailedToFetchFeeErrorType, type FeeEstimation, FeeExceedsAmountError, type FeeExceedsAmountErrorType, type HotBridgeRouteConfig, HotWithdrawalCancelledError, type HotWithdrawalCancelledErrorType, HotWithdrawalNotFoundError, type HotWithdrawalNotFoundErrorType, HotWithdrawalPendingError, type HotWithdrawalPendingErrorType, HttpRequestError, type HttpRequestErrorType, type IIntentSigner, type ILogger, type IntentPayload, type IntentPayloadFactory, type IntentPrimitive, type IntentPublishResult, type IntentRelayParamsFactory, IntentSettlementError, type IntentSettlementErrorType, type IntentSettlementStatus, IntentsNearOmniAvailableBalanceTooLowError, type IntentsNearOmniAvailableBalanceTooLowErrorType, IntentsSDK, type IntentsSDKConfig, type InternalTransferRouteConfig, MinWithdrawalAmountError, type MinWithdrawalAmountErrorType, type MultiPayload, type NearIntentsEnv, type NearTxInfo, type NearWithdrawalRouteConfig, type OmniBridgeRouteConfig, OmniTokenNormalisationCheckError, type OmniTokenNormalisationCheckErrorType, OmniTransferDestinationChainHashNotFoundError, type OmniTransferDestinationChainHashNotFoundErrorType, OmniTransferNotFoundError, type OmniTransferNotFoundErrorType, type OnBeforePublishIntentHook, type ParsedAssetInfo, type PoaBridgeRouteConfig, PoaWithdrawalInvariantError, type PoaWithdrawalInvariantErrorType, PoaWithdrawalNotFoundError, type PoaWithdrawalNotFoundErrorType, PoaWithdrawalPendingError, type PoaWithdrawalPendingErrorType, type ProcessWithdrawalArgs, QuoteError, type QuoteErrorType, RelayPublishError, type RelayPublishErrorType, type RetryOptions, type RouteConfig, RouteEnum, type RouteEnumValues, RpcRequestError, type RpcRequestErrorType, type SignAndSendArgs, type SignAndSendWithdrawalArgs, type SignedIntentsComposition, TimeoutError, type TimeoutErrorType, TokenNotFoundInDestinationChainError, type TokenNotFoundInDestinationChainErrorType, TrustlineNotFoundError, type TrustlineNotFoundErrorType, type TxInfo, type TxNoInfo, UnsupportedAssetIdError, type UnsupportedAssetIdErrorType, UnsupportedDestinationMemoError, type UnsupportedDestinationMemoErrorType, type VirtualChainRouteConfig, type WithdrawalIdentifier, type WithdrawalParams, type WithdrawalResult, createDefaultRoute, createHotBridgeRoute, createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute };
16
+ export { AssertionError, type AssertionErrorType, BaseError, type BaseErrorType, type BatchWithdrawalResult, BridgeNameEnum, type BridgeNameEnumValues, type Chain, Chains, DestinationExplicitNearAccountDoesntExistError, type DestinationExplicitNearAccountDoesntExistErrorType, FailedToFetchFeeError, type FailedToFetchFeeErrorType, type FeeEstimation, FeeExceedsAmountError, type FeeExceedsAmountErrorType, type HotBridgeRouteConfig, HotWithdrawalCancelledError, type HotWithdrawalCancelledErrorType, HotWithdrawalNotFoundError, type HotWithdrawalNotFoundErrorType, HotWithdrawalPendingError, type HotWithdrawalPendingErrorType, HttpRequestError, type HttpRequestErrorType, type IIntentSigner, type ILogger, type IntentPayload, type IntentPayloadFactory, type IntentPrimitive, type IntentPublishResult, type IntentRelayParamsFactory, IntentSettlementError, type IntentSettlementErrorType, type IntentSettlementStatus, IntentsNearOmniAvailableBalanceTooLowError, type IntentsNearOmniAvailableBalanceTooLowErrorType, IntentsSDK, type IntentsSDKConfig, type InternalTransferRouteConfig, MinWithdrawalAmountError, type MinWithdrawalAmountErrorType, type MultiPayload, type NearIntentsEnv, type NearTxInfo, type NearWithdrawalRouteConfig, type OmniBridgeRouteConfig, OmniTokenNormalisationCheckError, type OmniTokenNormalisationCheckErrorType, OmniTransferDestinationChainHashNotFoundError, type OmniTransferDestinationChainHashNotFoundErrorType, OmniTransferNotFoundError, type OmniTransferNotFoundErrorType, type OnBeforePublishIntentHook, type ParsedAssetInfo, type PoaBridgeRouteConfig, PoaWithdrawalInvariantError, type PoaWithdrawalInvariantErrorType, PoaWithdrawalNotFoundError, type PoaWithdrawalNotFoundErrorType, PoaWithdrawalPendingError, type PoaWithdrawalPendingErrorType, type ProcessWithdrawalArgs, QuoteError, type QuoteErrorType, RelayPublishError, type RelayPublishErrorType, type RetryOptions, type RouteConfig, RouteEnum, type RouteEnumValues, RpcRequestError, type RpcRequestErrorType, type SignAndSendArgs, type SignAndSendWithdrawalArgs, type SignedIntentsComposition, TimeoutError, type TimeoutErrorType, TokenNotFoundInDestinationChainError, type TokenNotFoundInDestinationChainErrorType, TrustlineNotFoundError, type TrustlineNotFoundErrorType, type TxInfo, type TxNoInfo, UnsupportedAssetIdError, type UnsupportedAssetIdErrorType, UnsupportedDestinationMemoError, type UnsupportedDestinationMemoErrorType, type VirtualChainRouteConfig, type WithdrawalIdentifier, type WithdrawalParams, type WithdrawalResult, createDefaultRoute, createHotBridgeRoute, createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute };
package/dist/index.d.ts CHANGED
@@ -9,7 +9,8 @@ import { IntentsSDK, IntentsSDKConfig } from "./src/sdk.js";
9
9
  import { createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem } from "./src/intents/intent-signer-impl/factories.js";
10
10
  import { createDefaultRoute, createHotBridgeRoute, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute } from "./src/lib/route-config-factory.js";
11
11
  import { FeeExceedsAmountError, FeeExceedsAmountErrorType, MinWithdrawalAmountError, MinWithdrawalAmountErrorType, TrustlineNotFoundError, TrustlineNotFoundErrorType, UnsupportedAssetIdError, UnsupportedAssetIdErrorType, UnsupportedDestinationMemoError, UnsupportedDestinationMemoErrorType } from "./src/classes/errors.js";
12
+ import { DestinationExplicitNearAccountDoesntExistError, DestinationExplicitNearAccountDoesntExistErrorType } from "./src/bridges/direct-bridge/error.js";
12
13
  import { HotWithdrawalCancelledError, HotWithdrawalCancelledErrorType, HotWithdrawalNotFoundError, HotWithdrawalNotFoundErrorType, HotWithdrawalPendingError, HotWithdrawalPendingErrorType } from "./src/bridges/hot-bridge/error.js";
13
14
  import { FailedToFetchFeeError, FailedToFetchFeeErrorType, IntentsNearOmniAvailableBalanceTooLowError, IntentsNearOmniAvailableBalanceTooLowErrorType, OmniTokenNormalisationCheckError, OmniTokenNormalisationCheckErrorType, OmniTransferDestinationChainHashNotFoundError, OmniTransferDestinationChainHashNotFoundErrorType, OmniTransferNotFoundError, OmniTransferNotFoundErrorType, TokenNotFoundInDestinationChainError, TokenNotFoundInDestinationChainErrorType } from "./src/bridges/omni-bridge/error.js";
14
15
  import { AssertionError, AssertionErrorType, BaseError, BaseErrorType, HttpRequestError, HttpRequestErrorType, ILogger, IntentSettlementError, IntentSettlementErrorType, NearIntentsEnv, PoaWithdrawalInvariantError, PoaWithdrawalInvariantErrorType, PoaWithdrawalNotFoundError, PoaWithdrawalNotFoundErrorType, PoaWithdrawalPendingError, PoaWithdrawalPendingErrorType, QuoteError, QuoteErrorType, RelayPublishError, RelayPublishErrorType, RetryOptions, RpcRequestError, RpcRequestErrorType, TimeoutError, TimeoutErrorType } from "@defuse-protocol/internal-utils";
15
- export { AssertionError, type AssertionErrorType, BaseError, type BaseErrorType, type BatchWithdrawalResult, BridgeNameEnum, type BridgeNameEnumValues, type Chain, Chains, FailedToFetchFeeError, type FailedToFetchFeeErrorType, type FeeEstimation, FeeExceedsAmountError, type FeeExceedsAmountErrorType, type HotBridgeRouteConfig, HotWithdrawalCancelledError, type HotWithdrawalCancelledErrorType, HotWithdrawalNotFoundError, type HotWithdrawalNotFoundErrorType, HotWithdrawalPendingError, type HotWithdrawalPendingErrorType, HttpRequestError, type HttpRequestErrorType, type IIntentSigner, type ILogger, type IntentPayload, type IntentPayloadFactory, type IntentPrimitive, type IntentPublishResult, type IntentRelayParamsFactory, IntentSettlementError, type IntentSettlementErrorType, type IntentSettlementStatus, IntentsNearOmniAvailableBalanceTooLowError, type IntentsNearOmniAvailableBalanceTooLowErrorType, IntentsSDK, type IntentsSDKConfig, type InternalTransferRouteConfig, MinWithdrawalAmountError, type MinWithdrawalAmountErrorType, type MultiPayload, type NearIntentsEnv, type NearTxInfo, type NearWithdrawalRouteConfig, type OmniBridgeRouteConfig, OmniTokenNormalisationCheckError, type OmniTokenNormalisationCheckErrorType, OmniTransferDestinationChainHashNotFoundError, type OmniTransferDestinationChainHashNotFoundErrorType, OmniTransferNotFoundError, type OmniTransferNotFoundErrorType, type OnBeforePublishIntentHook, type ParsedAssetInfo, type PoaBridgeRouteConfig, PoaWithdrawalInvariantError, type PoaWithdrawalInvariantErrorType, PoaWithdrawalNotFoundError, type PoaWithdrawalNotFoundErrorType, PoaWithdrawalPendingError, type PoaWithdrawalPendingErrorType, type ProcessWithdrawalArgs, QuoteError, type QuoteErrorType, RelayPublishError, type RelayPublishErrorType, type RetryOptions, type RouteConfig, RouteEnum, type RouteEnumValues, RpcRequestError, type RpcRequestErrorType, type SignAndSendArgs, type SignAndSendWithdrawalArgs, type SignedIntentsComposition, TimeoutError, type TimeoutErrorType, TokenNotFoundInDestinationChainError, type TokenNotFoundInDestinationChainErrorType, TrustlineNotFoundError, type TrustlineNotFoundErrorType, type TxInfo, type TxNoInfo, UnsupportedAssetIdError, type UnsupportedAssetIdErrorType, UnsupportedDestinationMemoError, type UnsupportedDestinationMemoErrorType, type VirtualChainRouteConfig, type WithdrawalIdentifier, type WithdrawalParams, type WithdrawalResult, createDefaultRoute, createHotBridgeRoute, createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute };
16
+ export { AssertionError, type AssertionErrorType, BaseError, type BaseErrorType, type BatchWithdrawalResult, BridgeNameEnum, type BridgeNameEnumValues, type Chain, Chains, DestinationExplicitNearAccountDoesntExistError, type DestinationExplicitNearAccountDoesntExistErrorType, FailedToFetchFeeError, type FailedToFetchFeeErrorType, type FeeEstimation, FeeExceedsAmountError, type FeeExceedsAmountErrorType, type HotBridgeRouteConfig, HotWithdrawalCancelledError, type HotWithdrawalCancelledErrorType, HotWithdrawalNotFoundError, type HotWithdrawalNotFoundErrorType, HotWithdrawalPendingError, type HotWithdrawalPendingErrorType, HttpRequestError, type HttpRequestErrorType, type IIntentSigner, type ILogger, type IntentPayload, type IntentPayloadFactory, type IntentPrimitive, type IntentPublishResult, type IntentRelayParamsFactory, IntentSettlementError, type IntentSettlementErrorType, type IntentSettlementStatus, IntentsNearOmniAvailableBalanceTooLowError, type IntentsNearOmniAvailableBalanceTooLowErrorType, IntentsSDK, type IntentsSDKConfig, type InternalTransferRouteConfig, MinWithdrawalAmountError, type MinWithdrawalAmountErrorType, type MultiPayload, type NearIntentsEnv, type NearTxInfo, type NearWithdrawalRouteConfig, type OmniBridgeRouteConfig, OmniTokenNormalisationCheckError, type OmniTokenNormalisationCheckErrorType, OmniTransferDestinationChainHashNotFoundError, type OmniTransferDestinationChainHashNotFoundErrorType, OmniTransferNotFoundError, type OmniTransferNotFoundErrorType, type OnBeforePublishIntentHook, type ParsedAssetInfo, type PoaBridgeRouteConfig, PoaWithdrawalInvariantError, type PoaWithdrawalInvariantErrorType, PoaWithdrawalNotFoundError, type PoaWithdrawalNotFoundErrorType, PoaWithdrawalPendingError, type PoaWithdrawalPendingErrorType, type ProcessWithdrawalArgs, QuoteError, type QuoteErrorType, RelayPublishError, type RelayPublishErrorType, type RetryOptions, type RouteConfig, RouteEnum, type RouteEnumValues, RpcRequestError, type RpcRequestErrorType, type SignAndSendArgs, type SignAndSendWithdrawalArgs, type SignedIntentsComposition, TimeoutError, type TimeoutErrorType, TokenNotFoundInDestinationChainError, type TokenNotFoundInDestinationChainErrorType, TrustlineNotFoundError, type TrustlineNotFoundErrorType, type TxInfo, type TxNoInfo, UnsupportedAssetIdError, type UnsupportedAssetIdErrorType, UnsupportedDestinationMemoError, type UnsupportedDestinationMemoErrorType, type VirtualChainRouteConfig, type WithdrawalIdentifier, type WithdrawalParams, type WithdrawalResult, createDefaultRoute, createHotBridgeRoute, createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute };
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@ import { RouteEnum } from "./src/constants/route-enum.js";
2
2
  import { FeeExceedsAmountError, MinWithdrawalAmountError, TrustlineNotFoundError, UnsupportedAssetIdError, UnsupportedDestinationMemoError } from "./src/classes/errors.js";
3
3
  import { Chains } from "./src/lib/caip2.js";
4
4
  import { BridgeNameEnum } from "./src/constants/bridge-name-enum.js";
5
+ import { DestinationExplicitNearAccountDoesntExistError } from "./src/bridges/direct-bridge/error.js";
5
6
  import { HotWithdrawalCancelledError, HotWithdrawalNotFoundError, HotWithdrawalPendingError } from "./src/bridges/hot-bridge/error.js";
6
7
  import { FailedToFetchFeeError, IntentsNearOmniAvailableBalanceTooLowError, OmniTokenNormalisationCheckError, OmniTransferDestinationChainHashNotFoundError, OmniTransferNotFoundError, TokenNotFoundInDestinationChainError } from "./src/bridges/omni-bridge/error.js";
7
8
  import { createDefaultRoute, createHotBridgeRoute, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute } from "./src/lib/route-config-factory.js";
@@ -9,4 +10,4 @@ import { IntentsSDK } from "./src/sdk.js";
9
10
  import { createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem } from "./src/intents/intent-signer-impl/factories.js";
10
11
  import { AssertionError, BaseError, HttpRequestError, IntentSettlementError, PoaWithdrawalInvariantError, PoaWithdrawalNotFoundError, PoaWithdrawalPendingError, QuoteError, RelayPublishError, RpcRequestError, TimeoutError } from "@defuse-protocol/internal-utils";
11
12
 
12
- export { AssertionError, BaseError, BridgeNameEnum, Chains, FailedToFetchFeeError, FeeExceedsAmountError, HotWithdrawalCancelledError, HotWithdrawalNotFoundError, HotWithdrawalPendingError, HttpRequestError, IntentSettlementError, IntentsNearOmniAvailableBalanceTooLowError, IntentsSDK, MinWithdrawalAmountError, OmniTokenNormalisationCheckError, OmniTransferDestinationChainHashNotFoundError, OmniTransferNotFoundError, PoaWithdrawalInvariantError, PoaWithdrawalNotFoundError, PoaWithdrawalPendingError, QuoteError, RelayPublishError, RouteEnum, RpcRequestError, TimeoutError, TokenNotFoundInDestinationChainError, TrustlineNotFoundError, UnsupportedAssetIdError, UnsupportedDestinationMemoError, createDefaultRoute, createHotBridgeRoute, createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute };
13
+ export { AssertionError, BaseError, BridgeNameEnum, Chains, DestinationExplicitNearAccountDoesntExistError, FailedToFetchFeeError, FeeExceedsAmountError, HotWithdrawalCancelledError, HotWithdrawalNotFoundError, HotWithdrawalPendingError, HttpRequestError, IntentSettlementError, IntentsNearOmniAvailableBalanceTooLowError, IntentsSDK, MinWithdrawalAmountError, OmniTokenNormalisationCheckError, OmniTransferDestinationChainHashNotFoundError, OmniTransferNotFoundError, PoaWithdrawalInvariantError, PoaWithdrawalNotFoundError, PoaWithdrawalPendingError, QuoteError, RelayPublishError, RouteEnum, RpcRequestError, TimeoutError, TokenNotFoundInDestinationChainError, TrustlineNotFoundError, UnsupportedAssetIdError, UnsupportedDestinationMemoError, createDefaultRoute, createHotBridgeRoute, createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute };
@@ -3,6 +3,8 @@ const require_route_enum = require('../../constants/route-enum.cjs');
3
3
  const require_direct_bridge_constants = require('./direct-bridge-constants.cjs');
4
4
  let __defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils");
5
5
  __defuse_protocol_internal_utils = require_rolldown_runtime.__toESM(__defuse_protocol_internal_utils);
6
+ let near_api_js_lib_providers = require("near-api-js/lib/providers");
7
+ near_api_js_lib_providers = require_rolldown_runtime.__toESM(near_api_js_lib_providers);
6
8
 
7
9
  //#region src/bridges/direct-bridge/direct-bridge-utils.ts
8
10
  function createWithdrawIntentPrimitive(params) {
@@ -25,7 +27,21 @@ function createWithdrawIntentPrimitive(params) {
25
27
  function withdrawalParamsInvariant(params) {
26
28
  (0, __defuse_protocol_internal_utils.assert)(!params.routeConfig ? true : params.routeConfig.route === require_route_enum.RouteEnum.NearWithdrawal, "Bridge is not direct");
27
29
  }
30
+ async function accountExistsInNEAR(provider, accountId) {
31
+ try {
32
+ await (0, __defuse_protocol_internal_utils.unwrapNearFailoverRpcProvider)(provider).query({
33
+ request_type: "view_account",
34
+ account_id: accountId,
35
+ finality: "final"
36
+ });
37
+ return true;
38
+ } catch (error) {
39
+ if (error instanceof near_api_js_lib_providers.TypedError && error.type === "AccountDoesNotExist") return false;
40
+ throw error;
41
+ }
42
+ }
28
43
 
29
44
  //#endregion
45
+ exports.accountExistsInNEAR = accountExistsInNEAR;
30
46
  exports.createWithdrawIntentPrimitive = createWithdrawIntentPrimitive;
31
47
  exports.withdrawalParamsInvariant = withdrawalParamsInvariant;
@@ -1,6 +1,7 @@
1
1
  import { RouteEnum } from "../../constants/route-enum.js";
2
2
  import { NEAR_NATIVE_ASSET_ID } from "./direct-bridge-constants.js";
3
- import { assert, utils } from "@defuse-protocol/internal-utils";
3
+ import { assert, unwrapNearFailoverRpcProvider, utils } from "@defuse-protocol/internal-utils";
4
+ import { TypedError } from "near-api-js/lib/providers";
4
5
 
5
6
  //#region src/bridges/direct-bridge/direct-bridge-utils.ts
6
7
  function createWithdrawIntentPrimitive(params) {
@@ -23,6 +24,19 @@ function createWithdrawIntentPrimitive(params) {
23
24
  function withdrawalParamsInvariant(params) {
24
25
  assert(!params.routeConfig ? true : params.routeConfig.route === RouteEnum.NearWithdrawal, "Bridge is not direct");
25
26
  }
27
+ async function accountExistsInNEAR(provider, accountId) {
28
+ try {
29
+ await unwrapNearFailoverRpcProvider(provider).query({
30
+ request_type: "view_account",
31
+ account_id: accountId,
32
+ finality: "final"
33
+ });
34
+ return true;
35
+ } catch (error) {
36
+ if (error instanceof TypedError && error.type === "AccountDoesNotExist") return false;
37
+ throw error;
38
+ }
39
+ }
26
40
 
27
41
  //#endregion
28
- export { createWithdrawIntentPrimitive, withdrawalParamsInvariant };
42
+ export { accountExistsInNEAR, createWithdrawIntentPrimitive, withdrawalParamsInvariant };
@@ -8,12 +8,23 @@ const require_validateAddress = require('../../lib/validateAddress.cjs');
8
8
  const require_bridge_name_enum = require('../../constants/bridge-name-enum.cjs');
9
9
  const require_direct_bridge_constants = require('./direct-bridge-constants.cjs');
10
10
  const require_direct_bridge_utils = require('./direct-bridge-utils.cjs');
11
+ const require_error = require('./error.cjs');
11
12
  let __defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils");
12
13
  __defuse_protocol_internal_utils = require_rolldown_runtime.__toESM(__defuse_protocol_internal_utils);
14
+ let lru_cache = require("lru-cache");
15
+ lru_cache = require_rolldown_runtime.__toESM(lru_cache);
13
16
 
14
17
  //#region src/bridges/direct-bridge/direct-bridge.ts
15
18
  var DirectBridge = class {
16
19
  constructor({ env, nearProvider, solverRelayApiKey }) {
20
+ this.storageDepositCache = new lru_cache.LRUCache({
21
+ max: 100,
22
+ ttl: 36e5
23
+ });
24
+ this.accountExistenceCache = new lru_cache.LRUCache({
25
+ max: 100,
26
+ ttl: 36e5
27
+ });
17
28
  this.env = env;
18
29
  this.nearProvider = nearProvider;
19
30
  this.solverRelayApiKey = solverRelayApiKey;
@@ -62,6 +73,7 @@ var DirectBridge = class {
62
73
  */
63
74
  async validateWithdrawal(args) {
64
75
  if (require_validateAddress.validateAddress(args.destinationAddress, require_caip2.Chains.Near) === false) throw new require_errors.InvalidDestinationAddressForWithdrawalError(args.destinationAddress, require_caip2.Chains.Near);
76
+ if (__defuse_protocol_internal_utils.utils.isImplicitAccount(args.destinationAddress) === false && await this.getCachedAccountExistenceCheck(args.destinationAddress) === false) throw new require_error.DestinationExplicitNearAccountDoesntExistError(args.destinationAddress);
65
77
  }
66
78
  async estimateWithdrawalFee(args) {
67
79
  require_direct_bridge_utils.withdrawalParamsInvariant(args.withdrawalParams);
@@ -71,14 +83,7 @@ var DirectBridge = class {
71
83
  amount: 0n,
72
84
  quote: null
73
85
  };
74
- const [minStorageBalance, userStorageBalance] = await Promise.all([(0, __defuse_protocol_internal_utils.getNearNep141MinStorageBalance)({
75
- contractId: tokenAccountId,
76
- nearProvider: this.nearProvider
77
- }), (0, __defuse_protocol_internal_utils.getNearNep141StorageBalance)({
78
- contractId: tokenAccountId,
79
- accountId: args.withdrawalParams.destinationAddress,
80
- nearProvider: this.nearProvider
81
- })]);
86
+ const [minStorageBalance, userStorageBalance] = await this.getCachedStorageDepositValue(tokenAccountId, args.withdrawalParams.destinationAddress);
82
87
  if (minStorageBalance <= userStorageBalance) return {
83
88
  amount: 0n,
84
89
  quote: null
@@ -99,6 +104,34 @@ var DirectBridge = class {
99
104
  quote: feeQuote
100
105
  };
101
106
  }
107
+ /**
108
+ * Gets storage deposit for a token to avoid frequent RPC calls.
109
+ */
110
+ async getCachedStorageDepositValue(contractId, accountId) {
111
+ const key = `${contractId}${accountId}`;
112
+ const cached = this.storageDepositCache.get(key);
113
+ if (cached !== void 0) return cached;
114
+ const result = await Promise.all([(0, __defuse_protocol_internal_utils.getNearNep141MinStorageBalance)({
115
+ contractId,
116
+ nearProvider: this.nearProvider
117
+ }), (0, __defuse_protocol_internal_utils.getNearNep141StorageBalance)({
118
+ contractId,
119
+ accountId,
120
+ nearProvider: this.nearProvider
121
+ })]);
122
+ if (result[1] >= result[0]) this.storageDepositCache.set(key, result);
123
+ return result;
124
+ }
125
+ /**
126
+ * Checks account existence to avoid frequent RPC calls.
127
+ */
128
+ async getCachedAccountExistenceCheck(accountId) {
129
+ const cached = this.accountExistenceCache.get(accountId);
130
+ if (cached !== void 0) return cached;
131
+ const exist = await require_direct_bridge_utils.accountExistsInNEAR(this.nearProvider, accountId);
132
+ if (exist) this.accountExistenceCache.set(accountId, exist);
133
+ return exist;
134
+ }
102
135
  async waitForWithdrawalCompletion(args) {
103
136
  return { hash: args.tx.hash };
104
137
  }
@@ -6,12 +6,22 @@ import { Chains } from "../../lib/caip2.js";
6
6
  import { validateAddress } from "../../lib/validateAddress.js";
7
7
  import { BridgeNameEnum } from "../../constants/bridge-name-enum.js";
8
8
  import { NEAR_NATIVE_ASSET_ID } from "./direct-bridge-constants.js";
9
- import { createWithdrawIntentPrimitive, withdrawalParamsInvariant } from "./direct-bridge-utils.js";
9
+ import { accountExistsInNEAR, createWithdrawIntentPrimitive, withdrawalParamsInvariant } from "./direct-bridge-utils.js";
10
+ import { DestinationExplicitNearAccountDoesntExistError } from "./error.js";
10
11
  import { assert, getNearNep141MinStorageBalance, getNearNep141StorageBalance, utils } from "@defuse-protocol/internal-utils";
12
+ import { LRUCache } from "lru-cache";
11
13
 
12
14
  //#region src/bridges/direct-bridge/direct-bridge.ts
13
15
  var DirectBridge = class {
14
16
  constructor({ env, nearProvider, solverRelayApiKey }) {
17
+ this.storageDepositCache = new LRUCache({
18
+ max: 100,
19
+ ttl: 36e5
20
+ });
21
+ this.accountExistenceCache = new LRUCache({
22
+ max: 100,
23
+ ttl: 36e5
24
+ });
15
25
  this.env = env;
16
26
  this.nearProvider = nearProvider;
17
27
  this.solverRelayApiKey = solverRelayApiKey;
@@ -60,6 +70,7 @@ var DirectBridge = class {
60
70
  */
61
71
  async validateWithdrawal(args) {
62
72
  if (validateAddress(args.destinationAddress, Chains.Near) === false) throw new InvalidDestinationAddressForWithdrawalError(args.destinationAddress, Chains.Near);
73
+ if (utils.isImplicitAccount(args.destinationAddress) === false && await this.getCachedAccountExistenceCheck(args.destinationAddress) === false) throw new DestinationExplicitNearAccountDoesntExistError(args.destinationAddress);
63
74
  }
64
75
  async estimateWithdrawalFee(args) {
65
76
  withdrawalParamsInvariant(args.withdrawalParams);
@@ -69,14 +80,7 @@ var DirectBridge = class {
69
80
  amount: 0n,
70
81
  quote: null
71
82
  };
72
- const [minStorageBalance, userStorageBalance] = await Promise.all([getNearNep141MinStorageBalance({
73
- contractId: tokenAccountId,
74
- nearProvider: this.nearProvider
75
- }), getNearNep141StorageBalance({
76
- contractId: tokenAccountId,
77
- accountId: args.withdrawalParams.destinationAddress,
78
- nearProvider: this.nearProvider
79
- })]);
83
+ const [minStorageBalance, userStorageBalance] = await this.getCachedStorageDepositValue(tokenAccountId, args.withdrawalParams.destinationAddress);
80
84
  if (minStorageBalance <= userStorageBalance) return {
81
85
  amount: 0n,
82
86
  quote: null
@@ -97,6 +101,34 @@ var DirectBridge = class {
97
101
  quote: feeQuote
98
102
  };
99
103
  }
104
+ /**
105
+ * Gets storage deposit for a token to avoid frequent RPC calls.
106
+ */
107
+ async getCachedStorageDepositValue(contractId, accountId) {
108
+ const key = `${contractId}${accountId}`;
109
+ const cached = this.storageDepositCache.get(key);
110
+ if (cached !== void 0) return cached;
111
+ const result = await Promise.all([getNearNep141MinStorageBalance({
112
+ contractId,
113
+ nearProvider: this.nearProvider
114
+ }), getNearNep141StorageBalance({
115
+ contractId,
116
+ accountId,
117
+ nearProvider: this.nearProvider
118
+ })]);
119
+ if (result[1] >= result[0]) this.storageDepositCache.set(key, result);
120
+ return result;
121
+ }
122
+ /**
123
+ * Checks account existence to avoid frequent RPC calls.
124
+ */
125
+ async getCachedAccountExistenceCheck(accountId) {
126
+ const cached = this.accountExistenceCache.get(accountId);
127
+ if (cached !== void 0) return cached;
128
+ const exist = await accountExistsInNEAR(this.nearProvider, accountId);
129
+ if (exist) this.accountExistenceCache.set(accountId, exist);
130
+ return exist;
131
+ }
100
132
  async waitForWithdrawalCompletion(args) {
101
133
  return { hash: args.tx.hash };
102
134
  }
@@ -0,0 +1,17 @@
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
+ let __defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils");
3
+ __defuse_protocol_internal_utils = require_rolldown_runtime.__toESM(__defuse_protocol_internal_utils);
4
+
5
+ //#region src/bridges/direct-bridge/error.ts
6
+ var DestinationExplicitNearAccountDoesntExistError = class extends __defuse_protocol_internal_utils.BaseError {
7
+ constructor(accountId) {
8
+ super("Destination explicit NEAR account doesn't exist.", {
9
+ metaMessages: [`Account Id: ${accountId}`],
10
+ name: "DestinationExplicitNearAccountDoesntExistError"
11
+ });
12
+ this.accountId = accountId;
13
+ }
14
+ };
15
+
16
+ //#endregion
17
+ exports.DestinationExplicitNearAccountDoesntExistError = DestinationExplicitNearAccountDoesntExistError;
@@ -0,0 +1,12 @@
1
+ import { BaseError } from "@defuse-protocol/internal-utils";
2
+
3
+ //#region src/bridges/direct-bridge/error.d.ts
4
+ type DestinationExplicitNearAccountDoesntExistErrorType = DestinationExplicitNearAccountDoesntExistError & {
5
+ name: "DestinationExplicitNearAccountDoesntExistError";
6
+ };
7
+ declare class DestinationExplicitNearAccountDoesntExistError extends BaseError {
8
+ accountId: string;
9
+ constructor(accountId: string);
10
+ }
11
+ //#endregion
12
+ export { DestinationExplicitNearAccountDoesntExistError, DestinationExplicitNearAccountDoesntExistErrorType };
@@ -0,0 +1,12 @@
1
+ import { BaseError } from "@defuse-protocol/internal-utils";
2
+
3
+ //#region src/bridges/direct-bridge/error.d.ts
4
+ type DestinationExplicitNearAccountDoesntExistErrorType = DestinationExplicitNearAccountDoesntExistError & {
5
+ name: "DestinationExplicitNearAccountDoesntExistError";
6
+ };
7
+ declare class DestinationExplicitNearAccountDoesntExistError extends BaseError {
8
+ accountId: string;
9
+ constructor(accountId: string);
10
+ }
11
+ //#endregion
12
+ export { DestinationExplicitNearAccountDoesntExistError, DestinationExplicitNearAccountDoesntExistErrorType };
@@ -0,0 +1,15 @@
1
+ import { BaseError } from "@defuse-protocol/internal-utils";
2
+
3
+ //#region src/bridges/direct-bridge/error.ts
4
+ var DestinationExplicitNearAccountDoesntExistError = class extends BaseError {
5
+ constructor(accountId) {
6
+ super("Destination explicit NEAR account doesn't exist.", {
7
+ metaMessages: [`Account Id: ${accountId}`],
8
+ name: "DestinationExplicitNearAccountDoesntExistError"
9
+ });
10
+ this.accountId = accountId;
11
+ }
12
+ };
13
+
14
+ //#endregion
15
+ export { DestinationExplicitNearAccountDoesntExistError };
@@ -10,14 +10,14 @@ const require_omni_bridge_constants = require('./omni-bridge-constants.cjs');
10
10
  const require_omni_bridge_utils = require('./omni-bridge-utils.cjs');
11
11
  let __defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils");
12
12
  __defuse_protocol_internal_utils = require_rolldown_runtime.__toESM(__defuse_protocol_internal_utils);
13
+ let lru_cache = require("lru-cache");
14
+ lru_cache = require_rolldown_runtime.__toESM(lru_cache);
13
15
  let __lifeomic_attempt = require("@lifeomic/attempt");
14
16
  __lifeomic_attempt = require_rolldown_runtime.__toESM(__lifeomic_attempt);
15
17
  let __isaacs_ttlcache = require("@isaacs/ttlcache");
16
18
  __isaacs_ttlcache = require_rolldown_runtime.__toESM(__isaacs_ttlcache);
17
19
  let omni_bridge_sdk = require("omni-bridge-sdk");
18
20
  omni_bridge_sdk = require_rolldown_runtime.__toESM(omni_bridge_sdk);
19
- let lru_cache = require("lru-cache");
20
- lru_cache = require_rolldown_runtime.__toESM(lru_cache);
21
21
 
22
22
  //#region src/bridges/omni-bridge/omni-bridge.ts
23
23
  var OmniBridge = class {
@@ -8,10 +8,10 @@ import { FailedToFetchFeeError, IntentsNearOmniAvailableBalanceTooLowError, Omni
8
8
  import { MIN_ALLOWED_STORAGE_BALANCE_FOR_INTENTS_NEAR, NEAR_NATIVE_ASSET_ID, OMNI_BRIDGE_CONTRACT } from "./omni-bridge-constants.js";
9
9
  import { caip2ToChainKind, chainKindToCaip2, createWithdrawIntentsPrimitive, getAccountOmniStorageBalance, getBridgedToken, getTokenDecimals, validateOmniToken } from "./omni-bridge-utils.js";
10
10
  import { RETRY_CONFIGS, assert, configsByEnvironment, getNearNep141MinStorageBalance, getNearNep141StorageBalance } from "@defuse-protocol/internal-utils";
11
+ import { LRUCache } from "lru-cache";
11
12
  import { retry } from "@lifeomic/attempt";
12
13
  import TTLCache from "@isaacs/ttlcache";
13
14
  import { ChainKind, OmniBridgeAPI, getChain, getMinimumTransferableAmount, isEvmChain, omniAddress, parseOriginChain, verifyTransferAmount } from "omni-bridge-sdk";
14
- import { LRUCache } from "lru-cache";
15
15
 
16
16
  //#region src/bridges/omni-bridge/omni-bridge.ts
17
17
  var OmniBridge = class {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defuse-protocol/intents-sdk",
3
- "version": "0.27.0",
3
+ "version": "0.28.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -39,7 +39,7 @@
39
39
  "valibot": "^1.0.0",
40
40
  "viem": "^2.0.0",
41
41
  "@defuse-protocol/contract-types": "0.1.2",
42
- "@defuse-protocol/internal-utils": "0.16.0"
42
+ "@defuse-protocol/internal-utils": "0.17.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "tsdown": "0.15.5",