@defuse-protocol/intents-sdk 0.56.1 → 0.58.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/index.cjs +3 -0
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/src/bridges/poa-bridge/errors.cjs +28 -0
- package/dist/src/bridges/poa-bridge/errors.d.cts +19 -0
- package/dist/src/bridges/poa-bridge/errors.d.ts +19 -0
- package/dist/src/bridges/poa-bridge/errors.js +26 -0
- package/dist/src/bridges/poa-bridge/poa-bridge.cjs +22 -4
- package/dist/src/bridges/poa-bridge/poa-bridge.js +23 -5
- package/dist/src/constants/public-rpc-urls.cjs +3 -1
- package/dist/src/constants/public-rpc-urls.js +2 -1
- package/dist/src/lib/configure-rpc-config.cjs +10 -1
- package/dist/src/lib/configure-rpc-config.js +9 -1
- package/dist/src/sdk.cjs +11 -0
- package/dist/src/sdk.js +13 -2
- package/dist/src/shared-types.d.cts +1 -1
- package/dist/src/shared-types.d.ts +1 -1
- package/package.json +3 -3
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/index.cjs
CHANGED
|
@@ -8,6 +8,7 @@ const require_error = require('./src/bridges/direct-bridge/error.cjs');
|
|
|
8
8
|
const require_error$1 = require('./src/bridges/hot-bridge/error.cjs');
|
|
9
9
|
const require_error$2 = require('./src/bridges/omni-bridge/error.cjs');
|
|
10
10
|
const require_poa_tokens_routable_through_omni_bridge = require('./src/constants/poa-tokens-routable-through-omni-bridge.cjs');
|
|
11
|
+
const require_errors$1 = require('./src/bridges/poa-bridge/errors.cjs');
|
|
11
12
|
const require_intent_hash = require('./src/intents/intent-hash.cjs');
|
|
12
13
|
const require_expirable_nonce = require('./src/intents/expirable-nonce.cjs');
|
|
13
14
|
const require_withdrawal_watcher = require('./src/core/withdrawal-watcher.cjs');
|
|
@@ -110,6 +111,8 @@ Object.defineProperty(exports, 'VersionedNonceBuilder', {
|
|
|
110
111
|
});
|
|
111
112
|
exports.WithdrawalFailedError = require_withdrawal_watcher.WithdrawalFailedError;
|
|
112
113
|
exports.WithdrawalWatchError = require_withdrawal_watcher.WithdrawalWatchError;
|
|
114
|
+
exports.XrplDepositAuthEnabledError = require_errors$1.XrplDepositAuthEnabledError;
|
|
115
|
+
exports.XrplDestinationTagRequiredError = require_errors$1.XrplDestinationTagRequiredError;
|
|
113
116
|
exports.computeIntentHash = require_intent_hash.computeIntentHash;
|
|
114
117
|
exports.createDefaultRoute = require_route_config_factory.createDefaultRoute;
|
|
115
118
|
exports.createHotBridgeRoute = require_route_config_factory.createHotBridgeRoute;
|
package/dist/index.d.cts
CHANGED
|
@@ -18,7 +18,8 @@ import { FeeExceedsAmountError, FeeExceedsAmountErrorType, MinWithdrawalAmountEr
|
|
|
18
18
|
import { DestinationExplicitNearAccountDoesntExistError, DestinationExplicitNearAccountDoesntExistErrorType } from "./src/bridges/direct-bridge/error.cjs";
|
|
19
19
|
import { HotWithdrawalApiFeeRequestTimeoutError, HotWithdrawalApiFeeRequestTimeoutErrorType, HotWithdrawalNotFoundError, HotWithdrawalNotFoundErrorType } from "./src/bridges/hot-bridge/error.cjs";
|
|
20
20
|
import { InsufficientUtxoForOmniBridgeWithdrawalError, InsufficientUtxoForOmniBridgeWithdrawalErrorType, IntentsNearOmniAvailableBalanceTooLowError, IntentsNearOmniAvailableBalanceTooLowErrorType, InvalidFeeValueError, InvalidFeeValueErrorType, OmniWithdrawalApiFeeRequestTimeoutError, OmniWithdrawalApiFeeRequestTimeoutErrorType, TokenNotFoundInDestinationChainError, TokenNotFoundInDestinationChainErrorType } from "./src/bridges/omni-bridge/error.cjs";
|
|
21
|
+
import { XrplDepositAuthEnabledError, XrplDepositAuthEnabledErrorType, XrplDestinationTagRequiredError, XrplDestinationTagRequiredErrorType } from "./src/bridges/poa-bridge/errors.cjs";
|
|
21
22
|
import { computeIntentHash } from "./src/intents/intent-hash.cjs";
|
|
22
23
|
import { validateAddress } from "./src/lib/validateAddress.cjs";
|
|
23
24
|
import { AssertionError, AssertionErrorType, BaseError, BaseErrorType, EnvConfig, HttpRequestError, HttpRequestErrorType, ILogger, IntentSettlementError, IntentSettlementErrorType, NearIntentsEnv, PoaWithdrawalInvariantError, PoaWithdrawalInvariantErrorType, PoaWithdrawalNotFoundError, PoaWithdrawalNotFoundErrorType, PoaWithdrawalPendingError, PoaWithdrawalPendingErrorType, QuoteError, QuoteErrorType, RelayPublishError, RelayPublishErrorType, RetryOptions, RpcEndpoint, RpcEndpointConfig, RpcRequestError, RpcRequestErrorType, TimeoutError, TimeoutErrorType } from "@defuse-protocol/internal-utils";
|
|
24
|
-
export { AssertionError, type AssertionErrorType, BaseError, type BaseErrorType, type BatchWithdrawalResult, BridgeNameEnum, type BridgeNameEnumValues, type Chain, Chains, DestinationExplicitNearAccountDoesntExistError, type DestinationExplicitNearAccountDoesntExistErrorType, type EnvConfig, type Erc191RawPayload, type FeeEstimation, FeeExceedsAmountError, type FeeExceedsAmountErrorType, type HotBridgeRouteConfig, HotWithdrawalApiFeeRequestTimeoutError, type HotWithdrawalApiFeeRequestTimeoutErrorType, HotWithdrawalNotFoundError, type HotWithdrawalNotFoundErrorType, HttpRequestError, type HttpRequestErrorType, type IIntentSigner, type ILogger, InsufficientUtxoForOmniBridgeWithdrawalError, type InsufficientUtxoForOmniBridgeWithdrawalErrorType, type IntentPayload, IntentPayloadBuilder, type IntentPayloadFactory, type IntentPrimitive, type IntentPublishResult, type IntentRelayParamsFactory, IntentSettlementError, type IntentSettlementErrorType, type IntentSettlementStatus, IntentsNearOmniAvailableBalanceTooLowError, type IntentsNearOmniAvailableBalanceTooLowErrorType, IntentsSDK, type IntentsSDKConfig, type InternalTransferRouteConfig, InvalidFeeValueError, type InvalidFeeValueErrorType, MinWithdrawalAmountError, type MinWithdrawalAmountErrorType, type MultiPayload, type NearIntentsEnv, type NearTxInfo, type NearWithdrawalRouteConfig, type Nep413RawPayload, type OmniBridgeRouteConfig, OmniWithdrawalApiFeeRequestTimeoutError, type OmniWithdrawalApiFeeRequestTimeoutErrorType, type OnBeforePublishIntentHook, POA_TOKENS_ROUTABLE_THROUGH_OMNI_BRIDGE, 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, type RpcEndpoint, type RpcEndpointConfig, 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, VersionedNonceBuilder, type VirtualChainRouteConfig, WithdrawalFailedError, type WithdrawalFailedErrorType, type WithdrawalIdentifier, type WithdrawalParams, type WithdrawalResult, WithdrawalWatchError, type WithdrawalWatchErrorType, computeIntentHash, createDefaultRoute, createHotBridgeRoute, createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute, validateAddress as validateAddressFormat };
|
|
25
|
+
export { AssertionError, type AssertionErrorType, BaseError, type BaseErrorType, type BatchWithdrawalResult, BridgeNameEnum, type BridgeNameEnumValues, type Chain, Chains, DestinationExplicitNearAccountDoesntExistError, type DestinationExplicitNearAccountDoesntExistErrorType, type EnvConfig, type Erc191RawPayload, type FeeEstimation, FeeExceedsAmountError, type FeeExceedsAmountErrorType, type HotBridgeRouteConfig, HotWithdrawalApiFeeRequestTimeoutError, type HotWithdrawalApiFeeRequestTimeoutErrorType, HotWithdrawalNotFoundError, type HotWithdrawalNotFoundErrorType, HttpRequestError, type HttpRequestErrorType, type IIntentSigner, type ILogger, InsufficientUtxoForOmniBridgeWithdrawalError, type InsufficientUtxoForOmniBridgeWithdrawalErrorType, type IntentPayload, IntentPayloadBuilder, type IntentPayloadFactory, type IntentPrimitive, type IntentPublishResult, type IntentRelayParamsFactory, IntentSettlementError, type IntentSettlementErrorType, type IntentSettlementStatus, IntentsNearOmniAvailableBalanceTooLowError, type IntentsNearOmniAvailableBalanceTooLowErrorType, IntentsSDK, type IntentsSDKConfig, type InternalTransferRouteConfig, InvalidFeeValueError, type InvalidFeeValueErrorType, MinWithdrawalAmountError, type MinWithdrawalAmountErrorType, type MultiPayload, type NearIntentsEnv, type NearTxInfo, type NearWithdrawalRouteConfig, type Nep413RawPayload, type OmniBridgeRouteConfig, OmniWithdrawalApiFeeRequestTimeoutError, type OmniWithdrawalApiFeeRequestTimeoutErrorType, type OnBeforePublishIntentHook, POA_TOKENS_ROUTABLE_THROUGH_OMNI_BRIDGE, 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, type RpcEndpoint, type RpcEndpointConfig, 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, VersionedNonceBuilder, type VirtualChainRouteConfig, WithdrawalFailedError, type WithdrawalFailedErrorType, type WithdrawalIdentifier, type WithdrawalParams, type WithdrawalResult, WithdrawalWatchError, type WithdrawalWatchErrorType, XrplDepositAuthEnabledError, type XrplDepositAuthEnabledErrorType, XrplDestinationTagRequiredError, type XrplDestinationTagRequiredErrorType, computeIntentHash, createDefaultRoute, createHotBridgeRoute, createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute, validateAddress as validateAddressFormat };
|
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,8 @@ import { FeeExceedsAmountError, FeeExceedsAmountErrorType, MinWithdrawalAmountEr
|
|
|
18
18
|
import { DestinationExplicitNearAccountDoesntExistError, DestinationExplicitNearAccountDoesntExistErrorType } from "./src/bridges/direct-bridge/error.js";
|
|
19
19
|
import { HotWithdrawalApiFeeRequestTimeoutError, HotWithdrawalApiFeeRequestTimeoutErrorType, HotWithdrawalNotFoundError, HotWithdrawalNotFoundErrorType } from "./src/bridges/hot-bridge/error.js";
|
|
20
20
|
import { InsufficientUtxoForOmniBridgeWithdrawalError, InsufficientUtxoForOmniBridgeWithdrawalErrorType, IntentsNearOmniAvailableBalanceTooLowError, IntentsNearOmniAvailableBalanceTooLowErrorType, InvalidFeeValueError, InvalidFeeValueErrorType, OmniWithdrawalApiFeeRequestTimeoutError, OmniWithdrawalApiFeeRequestTimeoutErrorType, TokenNotFoundInDestinationChainError, TokenNotFoundInDestinationChainErrorType } from "./src/bridges/omni-bridge/error.js";
|
|
21
|
+
import { XrplDepositAuthEnabledError, XrplDepositAuthEnabledErrorType, XrplDestinationTagRequiredError, XrplDestinationTagRequiredErrorType } from "./src/bridges/poa-bridge/errors.js";
|
|
21
22
|
import { computeIntentHash } from "./src/intents/intent-hash.js";
|
|
22
23
|
import { validateAddress } from "./src/lib/validateAddress.js";
|
|
23
24
|
import { AssertionError, AssertionErrorType, BaseError, BaseErrorType, EnvConfig, HttpRequestError, HttpRequestErrorType, ILogger, IntentSettlementError, IntentSettlementErrorType, NearIntentsEnv, PoaWithdrawalInvariantError, PoaWithdrawalInvariantErrorType, PoaWithdrawalNotFoundError, PoaWithdrawalNotFoundErrorType, PoaWithdrawalPendingError, PoaWithdrawalPendingErrorType, QuoteError, QuoteErrorType, RelayPublishError, RelayPublishErrorType, RetryOptions, RpcEndpoint, RpcEndpointConfig, RpcRequestError, RpcRequestErrorType, TimeoutError, TimeoutErrorType } from "@defuse-protocol/internal-utils";
|
|
24
|
-
export { AssertionError, type AssertionErrorType, BaseError, type BaseErrorType, type BatchWithdrawalResult, BridgeNameEnum, type BridgeNameEnumValues, type Chain, Chains, DestinationExplicitNearAccountDoesntExistError, type DestinationExplicitNearAccountDoesntExistErrorType, type EnvConfig, type Erc191RawPayload, type FeeEstimation, FeeExceedsAmountError, type FeeExceedsAmountErrorType, type HotBridgeRouteConfig, HotWithdrawalApiFeeRequestTimeoutError, type HotWithdrawalApiFeeRequestTimeoutErrorType, HotWithdrawalNotFoundError, type HotWithdrawalNotFoundErrorType, HttpRequestError, type HttpRequestErrorType, type IIntentSigner, type ILogger, InsufficientUtxoForOmniBridgeWithdrawalError, type InsufficientUtxoForOmniBridgeWithdrawalErrorType, type IntentPayload, IntentPayloadBuilder, type IntentPayloadFactory, type IntentPrimitive, type IntentPublishResult, type IntentRelayParamsFactory, IntentSettlementError, type IntentSettlementErrorType, type IntentSettlementStatus, IntentsNearOmniAvailableBalanceTooLowError, type IntentsNearOmniAvailableBalanceTooLowErrorType, IntentsSDK, type IntentsSDKConfig, type InternalTransferRouteConfig, InvalidFeeValueError, type InvalidFeeValueErrorType, MinWithdrawalAmountError, type MinWithdrawalAmountErrorType, type MultiPayload, type NearIntentsEnv, type NearTxInfo, type NearWithdrawalRouteConfig, type Nep413RawPayload, type OmniBridgeRouteConfig, OmniWithdrawalApiFeeRequestTimeoutError, type OmniWithdrawalApiFeeRequestTimeoutErrorType, type OnBeforePublishIntentHook, POA_TOKENS_ROUTABLE_THROUGH_OMNI_BRIDGE, 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, type RpcEndpoint, type RpcEndpointConfig, 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, VersionedNonceBuilder, type VirtualChainRouteConfig, WithdrawalFailedError, type WithdrawalFailedErrorType, type WithdrawalIdentifier, type WithdrawalParams, type WithdrawalResult, WithdrawalWatchError, type WithdrawalWatchErrorType, computeIntentHash, createDefaultRoute, createHotBridgeRoute, createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute, validateAddress as validateAddressFormat };
|
|
25
|
+
export { AssertionError, type AssertionErrorType, BaseError, type BaseErrorType, type BatchWithdrawalResult, BridgeNameEnum, type BridgeNameEnumValues, type Chain, Chains, DestinationExplicitNearAccountDoesntExistError, type DestinationExplicitNearAccountDoesntExistErrorType, type EnvConfig, type Erc191RawPayload, type FeeEstimation, FeeExceedsAmountError, type FeeExceedsAmountErrorType, type HotBridgeRouteConfig, HotWithdrawalApiFeeRequestTimeoutError, type HotWithdrawalApiFeeRequestTimeoutErrorType, HotWithdrawalNotFoundError, type HotWithdrawalNotFoundErrorType, HttpRequestError, type HttpRequestErrorType, type IIntentSigner, type ILogger, InsufficientUtxoForOmniBridgeWithdrawalError, type InsufficientUtxoForOmniBridgeWithdrawalErrorType, type IntentPayload, IntentPayloadBuilder, type IntentPayloadFactory, type IntentPrimitive, type IntentPublishResult, type IntentRelayParamsFactory, IntentSettlementError, type IntentSettlementErrorType, type IntentSettlementStatus, IntentsNearOmniAvailableBalanceTooLowError, type IntentsNearOmniAvailableBalanceTooLowErrorType, IntentsSDK, type IntentsSDKConfig, type InternalTransferRouteConfig, InvalidFeeValueError, type InvalidFeeValueErrorType, MinWithdrawalAmountError, type MinWithdrawalAmountErrorType, type MultiPayload, type NearIntentsEnv, type NearTxInfo, type NearWithdrawalRouteConfig, type Nep413RawPayload, type OmniBridgeRouteConfig, OmniWithdrawalApiFeeRequestTimeoutError, type OmniWithdrawalApiFeeRequestTimeoutErrorType, type OnBeforePublishIntentHook, POA_TOKENS_ROUTABLE_THROUGH_OMNI_BRIDGE, 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, type RpcEndpoint, type RpcEndpointConfig, 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, VersionedNonceBuilder, type VirtualChainRouteConfig, WithdrawalFailedError, type WithdrawalFailedErrorType, type WithdrawalIdentifier, type WithdrawalParams, type WithdrawalResult, WithdrawalWatchError, type WithdrawalWatchErrorType, XrplDepositAuthEnabledError, type XrplDepositAuthEnabledErrorType, XrplDestinationTagRequiredError, type XrplDestinationTagRequiredErrorType, computeIntentHash, createDefaultRoute, createHotBridgeRoute, createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute, validateAddress as validateAddressFormat };
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import { DestinationExplicitNearAccountDoesntExistError } from "./src/bridges/di
|
|
|
7
7
|
import { HotWithdrawalApiFeeRequestTimeoutError, HotWithdrawalNotFoundError } from "./src/bridges/hot-bridge/error.js";
|
|
8
8
|
import { InsufficientUtxoForOmniBridgeWithdrawalError, IntentsNearOmniAvailableBalanceTooLowError, InvalidFeeValueError, OmniWithdrawalApiFeeRequestTimeoutError, TokenNotFoundInDestinationChainError } from "./src/bridges/omni-bridge/error.js";
|
|
9
9
|
import { POA_TOKENS_ROUTABLE_THROUGH_OMNI_BRIDGE } from "./src/constants/poa-tokens-routable-through-omni-bridge.js";
|
|
10
|
+
import { XrplDepositAuthEnabledError, XrplDestinationTagRequiredError } from "./src/bridges/poa-bridge/errors.js";
|
|
10
11
|
import { computeIntentHash } from "./src/intents/intent-hash.js";
|
|
11
12
|
import { VersionedNonceBuilder } from "./src/intents/expirable-nonce.js";
|
|
12
13
|
import { WithdrawalFailedError, WithdrawalWatchError } from "./src/core/withdrawal-watcher.js";
|
|
@@ -16,4 +17,4 @@ import { createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSi
|
|
|
16
17
|
import { createDefaultRoute, createHotBridgeRoute, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute } from "./src/lib/route-config-factory.js";
|
|
17
18
|
import { AssertionError, BaseError, HttpRequestError, IntentSettlementError, PoaWithdrawalInvariantError, PoaWithdrawalNotFoundError, PoaWithdrawalPendingError, QuoteError, RelayPublishError, RpcRequestError, TimeoutError } from "@defuse-protocol/internal-utils";
|
|
18
19
|
|
|
19
|
-
export { AssertionError, BaseError, BridgeNameEnum, Chains, DestinationExplicitNearAccountDoesntExistError, FeeExceedsAmountError, HotWithdrawalApiFeeRequestTimeoutError, HotWithdrawalNotFoundError, HttpRequestError, InsufficientUtxoForOmniBridgeWithdrawalError, IntentPayloadBuilder, IntentSettlementError, IntentsNearOmniAvailableBalanceTooLowError, IntentsSDK, InvalidFeeValueError, MinWithdrawalAmountError, OmniWithdrawalApiFeeRequestTimeoutError, POA_TOKENS_ROUTABLE_THROUGH_OMNI_BRIDGE, PoaWithdrawalInvariantError, PoaWithdrawalNotFoundError, PoaWithdrawalPendingError, QuoteError, RelayPublishError, RouteEnum, RpcRequestError, TimeoutError, TokenNotFoundInDestinationChainError, TrustlineNotFoundError, UnsupportedAssetIdError, UnsupportedDestinationMemoError, VersionedNonceBuilder, WithdrawalFailedError, WithdrawalWatchError, computeIntentHash, createDefaultRoute, createHotBridgeRoute, createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute, validateAddress as validateAddressFormat };
|
|
20
|
+
export { AssertionError, BaseError, BridgeNameEnum, Chains, DestinationExplicitNearAccountDoesntExistError, FeeExceedsAmountError, HotWithdrawalApiFeeRequestTimeoutError, HotWithdrawalNotFoundError, HttpRequestError, InsufficientUtxoForOmniBridgeWithdrawalError, IntentPayloadBuilder, IntentSettlementError, IntentsNearOmniAvailableBalanceTooLowError, IntentsSDK, InvalidFeeValueError, MinWithdrawalAmountError, OmniWithdrawalApiFeeRequestTimeoutError, POA_TOKENS_ROUTABLE_THROUGH_OMNI_BRIDGE, PoaWithdrawalInvariantError, PoaWithdrawalNotFoundError, PoaWithdrawalPendingError, QuoteError, RelayPublishError, RouteEnum, RpcRequestError, TimeoutError, TokenNotFoundInDestinationChainError, TrustlineNotFoundError, UnsupportedAssetIdError, UnsupportedDestinationMemoError, VersionedNonceBuilder, WithdrawalFailedError, WithdrawalWatchError, XrplDepositAuthEnabledError, XrplDestinationTagRequiredError, computeIntentHash, createDefaultRoute, createHotBridgeRoute, createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute, validateAddress as validateAddressFormat };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let _defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils");
|
|
3
|
+
|
|
4
|
+
//#region src/bridges/poa-bridge/errors.ts
|
|
5
|
+
var XrplDestinationTagRequiredError = class extends _defuse_protocol_internal_utils.BaseError {
|
|
6
|
+
constructor(destinationAddress) {
|
|
7
|
+
super("Destination address only accepts transfers with a destination tag.", {
|
|
8
|
+
metaMessages: [`Destination address: ${destinationAddress}`],
|
|
9
|
+
name: "XrplDestinationTagRequiredError",
|
|
10
|
+
details: `Address ${destinationAddress} has the RequireDestTag flag set and cannot receive transfers without a destination tag.`
|
|
11
|
+
});
|
|
12
|
+
this.destinationAddress = destinationAddress;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var XrplDepositAuthEnabledError = class extends _defuse_protocol_internal_utils.BaseError {
|
|
16
|
+
constructor(destinationAddress) {
|
|
17
|
+
super("Destination address has deposit authorization enabled and cannot receive payments from unauthorized senders.", {
|
|
18
|
+
metaMessages: [`Destination address: ${destinationAddress}`],
|
|
19
|
+
name: "XrplDepositAuthEnabledError",
|
|
20
|
+
details: `Address ${destinationAddress} has the DepositAuth flag set and only accepts payments from preauthorized senders.`
|
|
21
|
+
});
|
|
22
|
+
this.destinationAddress = destinationAddress;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
exports.XrplDepositAuthEnabledError = XrplDepositAuthEnabledError;
|
|
28
|
+
exports.XrplDestinationTagRequiredError = XrplDestinationTagRequiredError;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseError } from "@defuse-protocol/internal-utils";
|
|
2
|
+
|
|
3
|
+
//#region src/bridges/poa-bridge/errors.d.ts
|
|
4
|
+
type XrplDestinationTagRequiredErrorType = XrplDestinationTagRequiredError & {
|
|
5
|
+
name: "XrplDestinationTagRequiredError";
|
|
6
|
+
};
|
|
7
|
+
declare class XrplDestinationTagRequiredError extends BaseError {
|
|
8
|
+
destinationAddress: string;
|
|
9
|
+
constructor(destinationAddress: string);
|
|
10
|
+
}
|
|
11
|
+
type XrplDepositAuthEnabledErrorType = XrplDepositAuthEnabledError & {
|
|
12
|
+
name: "XrplDepositAuthEnabledError";
|
|
13
|
+
};
|
|
14
|
+
declare class XrplDepositAuthEnabledError extends BaseError {
|
|
15
|
+
destinationAddress: string;
|
|
16
|
+
constructor(destinationAddress: string);
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { XrplDepositAuthEnabledError, XrplDepositAuthEnabledErrorType, XrplDestinationTagRequiredError, XrplDestinationTagRequiredErrorType };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseError } from "@defuse-protocol/internal-utils";
|
|
2
|
+
|
|
3
|
+
//#region src/bridges/poa-bridge/errors.d.ts
|
|
4
|
+
type XrplDestinationTagRequiredErrorType = XrplDestinationTagRequiredError & {
|
|
5
|
+
name: "XrplDestinationTagRequiredError";
|
|
6
|
+
};
|
|
7
|
+
declare class XrplDestinationTagRequiredError extends BaseError {
|
|
8
|
+
destinationAddress: string;
|
|
9
|
+
constructor(destinationAddress: string);
|
|
10
|
+
}
|
|
11
|
+
type XrplDepositAuthEnabledErrorType = XrplDepositAuthEnabledError & {
|
|
12
|
+
name: "XrplDepositAuthEnabledError";
|
|
13
|
+
};
|
|
14
|
+
declare class XrplDepositAuthEnabledError extends BaseError {
|
|
15
|
+
destinationAddress: string;
|
|
16
|
+
constructor(destinationAddress: string);
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { XrplDepositAuthEnabledError, XrplDepositAuthEnabledErrorType, XrplDestinationTagRequiredError, XrplDestinationTagRequiredErrorType };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BaseError } from "@defuse-protocol/internal-utils";
|
|
2
|
+
|
|
3
|
+
//#region src/bridges/poa-bridge/errors.ts
|
|
4
|
+
var XrplDestinationTagRequiredError = class extends BaseError {
|
|
5
|
+
constructor(destinationAddress) {
|
|
6
|
+
super("Destination address only accepts transfers with a destination tag.", {
|
|
7
|
+
metaMessages: [`Destination address: ${destinationAddress}`],
|
|
8
|
+
name: "XrplDestinationTagRequiredError",
|
|
9
|
+
details: `Address ${destinationAddress} has the RequireDestTag flag set and cannot receive transfers without a destination tag.`
|
|
10
|
+
});
|
|
11
|
+
this.destinationAddress = destinationAddress;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var XrplDepositAuthEnabledError = class extends BaseError {
|
|
15
|
+
constructor(destinationAddress) {
|
|
16
|
+
super("Destination address has deposit authorization enabled and cannot receive payments from unauthorized senders.", {
|
|
17
|
+
metaMessages: [`Destination address: ${destinationAddress}`],
|
|
18
|
+
name: "XrplDepositAuthEnabledError",
|
|
19
|
+
details: `Address ${destinationAddress} has the DepositAuth flag set and only accepts payments from preauthorized senders.`
|
|
20
|
+
});
|
|
21
|
+
this.destinationAddress = destinationAddress;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { XrplDepositAuthEnabledError, XrplDestinationTagRequiredError };
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_errors = require('../../classes/errors.cjs');
|
|
3
3
|
const require_route_enum = require('../../constants/route-enum.cjs');
|
|
4
|
+
const require_caip2 = require('../../lib/caip2.cjs');
|
|
4
5
|
const require_estimate_fee = require('../../lib/estimate-fee.cjs');
|
|
5
6
|
const require_parse_defuse_asset_id = require('../../lib/parse-defuse-asset-id.cjs');
|
|
6
7
|
const require_validateAddress = require('../../lib/validateAddress.cjs');
|
|
7
8
|
const require_bridge_name_enum = require('../../constants/bridge-name-enum.cjs');
|
|
8
9
|
const require_poa_tokens_routable_through_omni_bridge = require('../../constants/poa-tokens-routable-through-omni-bridge.cjs');
|
|
10
|
+
const require_errors$1 = require('./errors.cjs');
|
|
9
11
|
const require_poa_bridge_utils = require('./poa-bridge-utils.cjs');
|
|
10
12
|
let _defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils");
|
|
11
13
|
let _isaacs_ttlcache = require("@isaacs/ttlcache");
|
|
@@ -13,10 +15,11 @@ _isaacs_ttlcache = require_rolldown_runtime.__toESM(_isaacs_ttlcache);
|
|
|
13
15
|
|
|
14
16
|
//#region src/bridges/poa-bridge/poa-bridge.ts
|
|
15
17
|
var PoaBridge = class {
|
|
16
|
-
constructor({ envConfig, routeMigratedPoaTokensThroughOmniBridge }) {
|
|
18
|
+
constructor({ envConfig, xrplRpcUrls, routeMigratedPoaTokensThroughOmniBridge }) {
|
|
17
19
|
this.route = require_route_enum.RouteEnum.PoaBridge;
|
|
18
20
|
this.supportedTokensCache = new _isaacs_ttlcache.default({ ttl: 30 * 1e3 });
|
|
19
21
|
this.envConfig = envConfig;
|
|
22
|
+
this.xrplRpcUrls = xrplRpcUrls;
|
|
20
23
|
this.routeMigratedPoaTokensThroughOmniBridge = routeMigratedPoaTokensThroughOmniBridge ?? false;
|
|
21
24
|
}
|
|
22
25
|
getPoaBridgeBaseURL() {
|
|
@@ -72,9 +75,24 @@ var PoaBridge = class {
|
|
|
72
75
|
if (require_validateAddress.validateAddress(args.destinationAddress, assetInfo.blockchain) === false) throw new require_errors.InvalidDestinationAddressForWithdrawalError(args.destinationAddress, assetInfo.blockchain);
|
|
73
76
|
const { tokens } = await this.getCachedSupportedTokens([require_poa_bridge_utils.toPoaNetwork(assetInfo.blockchain)], args.logger);
|
|
74
77
|
const tokenInfo = tokens.find((token) => token.intents_token_id === args.assetId);
|
|
75
|
-
if (tokenInfo
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
if (tokenInfo == null) throw new require_errors.UnsupportedAssetIdError(args.assetId, "`assetId` is not supported in PoA bridge.");
|
|
79
|
+
const minWithdrawalAmount = BigInt(tokenInfo.min_withdrawal_amount);
|
|
80
|
+
if (args.amount < minWithdrawalAmount) throw new require_errors.MinWithdrawalAmountError(minWithdrawalAmount, args.amount, args.assetId);
|
|
81
|
+
if (assetInfo.blockchain === require_caip2.Chains.XRPL) {
|
|
82
|
+
const xrplRpcUrl = this.xrplRpcUrls[0];
|
|
83
|
+
(0, _defuse_protocol_internal_utils.assert)(xrplRpcUrl, "No XRPL RPC URL configured");
|
|
84
|
+
const xrplConfig = {
|
|
85
|
+
baseURL: xrplRpcUrl,
|
|
86
|
+
logger: args.logger
|
|
87
|
+
};
|
|
88
|
+
const isXrp = assetInfo.contractId === "xrp.omft.near";
|
|
89
|
+
try {
|
|
90
|
+
const accountInfo = await _defuse_protocol_internal_utils.xrpl.httpClient.getAccountInfo(args.destinationAddress, xrplConfig);
|
|
91
|
+
if (accountInfo.account_flags.requireDestinationTag) throw new require_errors$1.XrplDestinationTagRequiredError(args.destinationAddress);
|
|
92
|
+
if (accountInfo.account_flags.depositAuth) throw new require_errors$1.XrplDepositAuthEnabledError(args.destinationAddress);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
if (!(isXrp && error instanceof _defuse_protocol_internal_utils.xrpl.httpClient.XrplAccountNotFundedError)) throw error;
|
|
95
|
+
}
|
|
78
96
|
}
|
|
79
97
|
}
|
|
80
98
|
async estimateWithdrawalFee(args) {
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { InvalidDestinationAddressForWithdrawalError, MinWithdrawalAmountError, UnsupportedAssetIdError } from "../../classes/errors.js";
|
|
2
2
|
import { RouteEnum } from "../../constants/route-enum.js";
|
|
3
|
+
import { Chains } from "../../lib/caip2.js";
|
|
3
4
|
import { getUnderlyingFee } from "../../lib/estimate-fee.js";
|
|
4
5
|
import { parseDefuseAssetId } from "../../lib/parse-defuse-asset-id.js";
|
|
5
6
|
import { validateAddress } from "../../lib/validateAddress.js";
|
|
6
7
|
import { BridgeNameEnum } from "../../constants/bridge-name-enum.js";
|
|
7
8
|
import { POA_TOKENS_ROUTABLE_THROUGH_OMNI_BRIDGE } from "../../constants/poa-tokens-routable-through-omni-bridge.js";
|
|
9
|
+
import { XrplDepositAuthEnabledError, XrplDestinationTagRequiredError } from "./errors.js";
|
|
8
10
|
import { contractIdToCaip2, createWithdrawIntentPrimitive, toPoaNetwork } from "./poa-bridge-utils.js";
|
|
9
|
-
import { RpcRequestError, assert, poaBridge, utils } from "@defuse-protocol/internal-utils";
|
|
11
|
+
import { RpcRequestError, assert, poaBridge, utils, xrpl } from "@defuse-protocol/internal-utils";
|
|
10
12
|
import TTLCache from "@isaacs/ttlcache";
|
|
11
13
|
|
|
12
14
|
//#region src/bridges/poa-bridge/poa-bridge.ts
|
|
13
15
|
var PoaBridge = class {
|
|
14
|
-
constructor({ envConfig, routeMigratedPoaTokensThroughOmniBridge }) {
|
|
16
|
+
constructor({ envConfig, xrplRpcUrls, routeMigratedPoaTokensThroughOmniBridge }) {
|
|
15
17
|
this.route = RouteEnum.PoaBridge;
|
|
16
18
|
this.supportedTokensCache = new TTLCache({ ttl: 30 * 1e3 });
|
|
17
19
|
this.envConfig = envConfig;
|
|
20
|
+
this.xrplRpcUrls = xrplRpcUrls;
|
|
18
21
|
this.routeMigratedPoaTokensThroughOmniBridge = routeMigratedPoaTokensThroughOmniBridge ?? false;
|
|
19
22
|
}
|
|
20
23
|
getPoaBridgeBaseURL() {
|
|
@@ -70,9 +73,24 @@ var PoaBridge = class {
|
|
|
70
73
|
if (validateAddress(args.destinationAddress, assetInfo.blockchain) === false) throw new InvalidDestinationAddressForWithdrawalError(args.destinationAddress, assetInfo.blockchain);
|
|
71
74
|
const { tokens } = await this.getCachedSupportedTokens([toPoaNetwork(assetInfo.blockchain)], args.logger);
|
|
72
75
|
const tokenInfo = tokens.find((token) => token.intents_token_id === args.assetId);
|
|
73
|
-
if (tokenInfo
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
if (tokenInfo == null) throw new UnsupportedAssetIdError(args.assetId, "`assetId` is not supported in PoA bridge.");
|
|
77
|
+
const minWithdrawalAmount = BigInt(tokenInfo.min_withdrawal_amount);
|
|
78
|
+
if (args.amount < minWithdrawalAmount) throw new MinWithdrawalAmountError(minWithdrawalAmount, args.amount, args.assetId);
|
|
79
|
+
if (assetInfo.blockchain === Chains.XRPL) {
|
|
80
|
+
const xrplRpcUrl = this.xrplRpcUrls[0];
|
|
81
|
+
assert(xrplRpcUrl, "No XRPL RPC URL configured");
|
|
82
|
+
const xrplConfig = {
|
|
83
|
+
baseURL: xrplRpcUrl,
|
|
84
|
+
logger: args.logger
|
|
85
|
+
};
|
|
86
|
+
const isXrp = assetInfo.contractId === "xrp.omft.near";
|
|
87
|
+
try {
|
|
88
|
+
const accountInfo = await xrpl.httpClient.getAccountInfo(args.destinationAddress, xrplConfig);
|
|
89
|
+
if (accountInfo.account_flags.requireDestinationTag) throw new XrplDestinationTagRequiredError(args.destinationAddress);
|
|
90
|
+
if (accountInfo.account_flags.depositAuth) throw new XrplDepositAuthEnabledError(args.destinationAddress);
|
|
91
|
+
} catch (error) {
|
|
92
|
+
if (!(isXrp && error instanceof xrpl.httpClient.XrplAccountNotFundedError)) throw error;
|
|
93
|
+
}
|
|
76
94
|
}
|
|
77
95
|
}
|
|
78
96
|
async estimateWithdrawalFee(args) {
|
|
@@ -19,7 +19,9 @@ const PUBLIC_STELLAR_RPC_URLS = {
|
|
|
19
19
|
soroban: ["https://mainnet.sorobanrpc.com"],
|
|
20
20
|
horizon: ["https://horizon.stellar.org"]
|
|
21
21
|
};
|
|
22
|
+
const PUBLIC_XRPL_RPC_URLS = ["https://xrplcluster.com/"];
|
|
22
23
|
|
|
23
24
|
//#endregion
|
|
24
25
|
exports.PUBLIC_EVM_RPC_URLS = PUBLIC_EVM_RPC_URLS;
|
|
25
|
-
exports.PUBLIC_STELLAR_RPC_URLS = PUBLIC_STELLAR_RPC_URLS;
|
|
26
|
+
exports.PUBLIC_STELLAR_RPC_URLS = PUBLIC_STELLAR_RPC_URLS;
|
|
27
|
+
exports.PUBLIC_XRPL_RPC_URLS = PUBLIC_XRPL_RPC_URLS;
|
|
@@ -19,6 +19,7 @@ const PUBLIC_STELLAR_RPC_URLS = {
|
|
|
19
19
|
soroban: ["https://mainnet.sorobanrpc.com"],
|
|
20
20
|
horizon: ["https://horizon.stellar.org"]
|
|
21
21
|
};
|
|
22
|
+
const PUBLIC_XRPL_RPC_URLS = ["https://xrplcluster.com/"];
|
|
22
23
|
|
|
23
24
|
//#endregion
|
|
24
|
-
export { PUBLIC_EVM_RPC_URLS, PUBLIC_STELLAR_RPC_URLS };
|
|
25
|
+
export { PUBLIC_EVM_RPC_URLS, PUBLIC_STELLAR_RPC_URLS, PUBLIC_XRPL_RPC_URLS };
|
|
@@ -34,7 +34,16 @@ function configureStellarRpcUrls(defaultRpcUrls, userRpcUrls) {
|
|
|
34
34
|
(0, _defuse_protocol_internal_utils.assert)(stellarRpcUrls.horizon.length > 0, "Stellar Horizon RPC URL is not provided");
|
|
35
35
|
return stellarRpcUrls;
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Configures XRPL RPC URLs by merging defaults with user-provided URLs.
|
|
39
|
+
*/
|
|
40
|
+
function configureXrplRpcUrls(defaultRpcUrls, userRpcUrls) {
|
|
41
|
+
const urls = (0, _defuse_protocol_internal_utils.extractRpcUrls)(userRpcUrls?.[require_caip2.Chains.XRPL] ?? defaultRpcUrls);
|
|
42
|
+
(0, _defuse_protocol_internal_utils.assert)(urls.length > 0, "XRPL RPC URL is not provided");
|
|
43
|
+
return urls;
|
|
44
|
+
}
|
|
37
45
|
|
|
38
46
|
//#endregion
|
|
39
47
|
exports.configureEvmRpcUrls = configureEvmRpcUrls;
|
|
40
|
-
exports.configureStellarRpcUrls = configureStellarRpcUrls;
|
|
48
|
+
exports.configureStellarRpcUrls = configureStellarRpcUrls;
|
|
49
|
+
exports.configureXrplRpcUrls = configureXrplRpcUrls;
|
|
@@ -33,6 +33,14 @@ function configureStellarRpcUrls(defaultRpcUrls, userRpcUrls) {
|
|
|
33
33
|
assert(stellarRpcUrls.horizon.length > 0, "Stellar Horizon RPC URL is not provided");
|
|
34
34
|
return stellarRpcUrls;
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Configures XRPL RPC URLs by merging defaults with user-provided URLs.
|
|
38
|
+
*/
|
|
39
|
+
function configureXrplRpcUrls(defaultRpcUrls, userRpcUrls) {
|
|
40
|
+
const urls = extractRpcUrls(userRpcUrls?.[Chains.XRPL] ?? defaultRpcUrls);
|
|
41
|
+
assert(urls.length > 0, "XRPL RPC URL is not provided");
|
|
42
|
+
return urls;
|
|
43
|
+
}
|
|
36
44
|
|
|
37
45
|
//#endregion
|
|
38
|
-
export { configureEvmRpcUrls, configureStellarRpcUrls };
|
|
46
|
+
export { configureEvmRpcUrls, configureStellarRpcUrls, configureXrplRpcUrls };
|
package/dist/src/sdk.cjs
CHANGED
|
@@ -39,6 +39,7 @@ var IntentsSDK = class {
|
|
|
39
39
|
const nearRpcUrls = (0, _defuse_protocol_internal_utils.extractRpcUrls)(nearRpcEndpoints);
|
|
40
40
|
const stellarRpcUrls = require_configure_rpc_config.configureStellarRpcUrls(require_public_rpc_urls.PUBLIC_STELLAR_RPC_URLS, args.rpc);
|
|
41
41
|
const evmRpcUrls = require_configure_rpc_config.configureEvmRpcUrls(require_public_rpc_urls.PUBLIC_EVM_RPC_URLS, args.rpc, require_hot_bridge_chains.HotBridgeEVMChains);
|
|
42
|
+
const xrplRpcUrls = require_configure_rpc_config.configureXrplRpcUrls(require_public_rpc_urls.PUBLIC_XRPL_RPC_URLS, args.rpc);
|
|
42
43
|
/**
|
|
43
44
|
* Order of bridges matters, because the first bridge that supports the `withdrawalParams` will be used.
|
|
44
45
|
* More specific bridges should be placed before more generic ones.
|
|
@@ -52,6 +53,7 @@ var IntentsSDK = class {
|
|
|
52
53
|
}),
|
|
53
54
|
new require_poa_bridge.PoaBridge({
|
|
54
55
|
envConfig: this.envConfig,
|
|
56
|
+
xrplRpcUrls,
|
|
55
57
|
routeMigratedPoaTokensThroughOmniBridge: args.features?.routeMigratedPoaTokensThroughOmniBridge
|
|
56
58
|
}),
|
|
57
59
|
new require_hot_bridge.HotBridge({
|
|
@@ -211,6 +213,15 @@ var IntentsSDK = class {
|
|
|
211
213
|
if (args.withdrawalParams.feeInclusive) {
|
|
212
214
|
if (args.withdrawalParams.amount <= fee.amount) throw new require_errors.FeeExceedsAmountError(fee, args.withdrawalParams.amount);
|
|
213
215
|
}
|
|
216
|
+
const actualAmount = args.withdrawalParams.feeInclusive ? args.withdrawalParams.amount - fee.amount : args.withdrawalParams.amount;
|
|
217
|
+
await bridge.validateWithdrawal({
|
|
218
|
+
assetId: args.withdrawalParams.assetId,
|
|
219
|
+
amount: actualAmount,
|
|
220
|
+
destinationAddress: args.withdrawalParams.destinationAddress,
|
|
221
|
+
feeEstimation: fee,
|
|
222
|
+
routeConfig: args.withdrawalParams.routeConfig,
|
|
223
|
+
logger: args.logger
|
|
224
|
+
});
|
|
214
225
|
return fee;
|
|
215
226
|
}
|
|
216
227
|
throw new Error(`Cannot determine bridge for withdrawal = ${(0, viem.stringify)(args.withdrawalParams)}`);
|
package/dist/src/sdk.js
CHANGED
|
@@ -8,14 +8,14 @@ import { HotBridge as HotBridge$1 } from "./bridges/hot-bridge/hot-bridge.js";
|
|
|
8
8
|
import { IntentsBridge } from "./bridges/intents-bridge/intents-bridge.js";
|
|
9
9
|
import { OmniBridge } from "./bridges/omni-bridge/omni-bridge.js";
|
|
10
10
|
import { PoaBridge } from "./bridges/poa-bridge/poa-bridge.js";
|
|
11
|
-
import { PUBLIC_EVM_RPC_URLS, PUBLIC_STELLAR_RPC_URLS } from "./constants/public-rpc-urls.js";
|
|
11
|
+
import { PUBLIC_EVM_RPC_URLS, PUBLIC_STELLAR_RPC_URLS, PUBLIC_XRPL_RPC_URLS } from "./constants/public-rpc-urls.js";
|
|
12
12
|
import { VersionedNonceBuilder, saltedNonceSchema } from "./intents/expirable-nonce.js";
|
|
13
13
|
import { DEFAULT_DEADLINE_MS } from "./intents/intent-payload-factory.js";
|
|
14
14
|
import { IntentExecuter } from "./intents/intent-executer-impl/intent-executer.js";
|
|
15
15
|
import { IntentRelayerPublic } from "./intents/intent-relayer-impl/intent-relayer-public.js";
|
|
16
16
|
import { noopIntentSigner } from "./intents/intent-signer-impl/intent-signer-noop.js";
|
|
17
17
|
import { zip } from "./lib/array.js";
|
|
18
|
-
import { configureEvmRpcUrls, configureStellarRpcUrls } from "./lib/configure-rpc-config.js";
|
|
18
|
+
import { configureEvmRpcUrls, configureStellarRpcUrls, configureXrplRpcUrls } from "./lib/configure-rpc-config.js";
|
|
19
19
|
import { createWithdrawalIdentifiers, watchWithdrawal } from "./core/withdrawal-watcher.js";
|
|
20
20
|
import { SaltManager, StaticSaltManager } from "./intents/salt-manager.js";
|
|
21
21
|
import { IntentPayloadBuilder } from "./intents/intent-payload-builder.js";
|
|
@@ -37,6 +37,7 @@ var IntentsSDK = class {
|
|
|
37
37
|
const nearRpcUrls = extractRpcUrls(nearRpcEndpoints);
|
|
38
38
|
const stellarRpcUrls = configureStellarRpcUrls(PUBLIC_STELLAR_RPC_URLS, args.rpc);
|
|
39
39
|
const evmRpcUrls = configureEvmRpcUrls(PUBLIC_EVM_RPC_URLS, args.rpc, HotBridgeEVMChains);
|
|
40
|
+
const xrplRpcUrls = configureXrplRpcUrls(PUBLIC_XRPL_RPC_URLS, args.rpc);
|
|
40
41
|
/**
|
|
41
42
|
* Order of bridges matters, because the first bridge that supports the `withdrawalParams` will be used.
|
|
42
43
|
* More specific bridges should be placed before more generic ones.
|
|
@@ -50,6 +51,7 @@ var IntentsSDK = class {
|
|
|
50
51
|
}),
|
|
51
52
|
new PoaBridge({
|
|
52
53
|
envConfig: this.envConfig,
|
|
54
|
+
xrplRpcUrls,
|
|
53
55
|
routeMigratedPoaTokensThroughOmniBridge: args.features?.routeMigratedPoaTokensThroughOmniBridge
|
|
54
56
|
}),
|
|
55
57
|
new HotBridge$1({
|
|
@@ -209,6 +211,15 @@ var IntentsSDK = class {
|
|
|
209
211
|
if (args.withdrawalParams.feeInclusive) {
|
|
210
212
|
if (args.withdrawalParams.amount <= fee.amount) throw new FeeExceedsAmountError(fee, args.withdrawalParams.amount);
|
|
211
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
|
+
});
|
|
212
223
|
return fee;
|
|
213
224
|
}
|
|
214
225
|
throw new Error(`Cannot determine bridge for withdrawal = ${stringify(args.withdrawalParams)}`);
|
|
@@ -371,7 +371,7 @@ type ParsedAssetInfo = ({
|
|
|
371
371
|
} | {
|
|
372
372
|
address: string;
|
|
373
373
|
});
|
|
374
|
-
type RPCEndpointMap = Record<typeof Chains.Near | HotBridgeEVMChain, RpcEndpoint[]> & { [K in typeof Chains.Stellar]: {
|
|
374
|
+
type RPCEndpointMap = Record<typeof Chains.Near | HotBridgeEVMChain | typeof Chains.XRPL, RpcEndpoint[]> & { [K in typeof Chains.Stellar]: {
|
|
375
375
|
soroban: RpcEndpoint[];
|
|
376
376
|
horizon: RpcEndpoint[];
|
|
377
377
|
} };
|
|
@@ -371,7 +371,7 @@ type ParsedAssetInfo = ({
|
|
|
371
371
|
} | {
|
|
372
372
|
address: string;
|
|
373
373
|
});
|
|
374
|
-
type RPCEndpointMap = Record<typeof Chains.Near | HotBridgeEVMChain, RpcEndpoint[]> & { [K in typeof Chains.Stellar]: {
|
|
374
|
+
type RPCEndpointMap = Record<typeof Chains.Near | HotBridgeEVMChain | typeof Chains.XRPL, RpcEndpoint[]> & { [K in typeof Chains.Stellar]: {
|
|
375
375
|
soroban: RpcEndpoint[];
|
|
376
376
|
horizon: RpcEndpoint[];
|
|
377
377
|
} };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defuse-protocol/intents-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.58.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/
|
|
49
|
-
"@defuse-protocol/
|
|
48
|
+
"@defuse-protocol/contract-types": "0.6.2",
|
|
49
|
+
"@defuse-protocol/internal-utils": "0.30.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"tsdown": "0.19.0"
|