@defuse-protocol/intents-sdk 0.47.0 → 0.48.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.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/src/bridges/intents-bridge/intents-bridge.cjs +2 -1
- package/dist/src/bridges/intents-bridge/intents-bridge.js +2 -1
- package/dist/src/lib/configure-rpc-config.cjs +24 -4
- package/dist/src/lib/configure-rpc-config.js +25 -5
- package/dist/src/sdk.cjs +4 -3
- package/dist/src/sdk.js +5 -4
- package/dist/src/shared-types.d.cts +16 -7
- package/dist/src/shared-types.d.ts +16 -7
- package/package.json +2 -2
- package/dist/src/lib/object.cjs +0 -10
- package/dist/src/lib/object.js +0 -9
package/dist/index.d.cts
CHANGED
|
@@ -18,5 +18,5 @@ import { HotWithdrawalApiFeeRequestTimeoutError, HotWithdrawalApiFeeRequestTimeo
|
|
|
18
18
|
import { InsufficientUtxoForOmniBridgeWithdrawalError, InsufficientUtxoForOmniBridgeWithdrawalErrorType, IntentsNearOmniAvailableBalanceTooLowError, IntentsNearOmniAvailableBalanceTooLowErrorType, InvalidFeeValueError, InvalidFeeValueErrorType, OmniWithdrawalApiFeeRequestTimeoutError, OmniWithdrawalApiFeeRequestTimeoutErrorType, TokenNotFoundInDestinationChainError, TokenNotFoundInDestinationChainErrorType } from "./src/bridges/omni-bridge/error.cjs";
|
|
19
19
|
import { computeIntentHash } from "./src/intents/intent-hash.cjs";
|
|
20
20
|
import { validateAddress } from "./src/lib/validateAddress.cjs";
|
|
21
|
-
import { AssertionError, AssertionErrorType, BaseError, BaseErrorType, EnvConfig, 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";
|
|
22
|
-
export { AssertionError, type AssertionErrorType, BaseError, type BaseErrorType, type BatchWithdrawalResult, BridgeNameEnum, type BridgeNameEnumValues, type Chain, Chains, DestinationExplicitNearAccountDoesntExistError, type DestinationExplicitNearAccountDoesntExistErrorType, type EnvConfig, 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 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, 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 };
|
|
21
|
+
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";
|
|
22
|
+
export { AssertionError, type AssertionErrorType, BaseError, type BaseErrorType, type BatchWithdrawalResult, BridgeNameEnum, type BridgeNameEnumValues, type Chain, Chains, DestinationExplicitNearAccountDoesntExistError, type DestinationExplicitNearAccountDoesntExistErrorType, type EnvConfig, 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 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -18,5 +18,5 @@ import { HotWithdrawalApiFeeRequestTimeoutError, HotWithdrawalApiFeeRequestTimeo
|
|
|
18
18
|
import { InsufficientUtxoForOmniBridgeWithdrawalError, InsufficientUtxoForOmniBridgeWithdrawalErrorType, IntentsNearOmniAvailableBalanceTooLowError, IntentsNearOmniAvailableBalanceTooLowErrorType, InvalidFeeValueError, InvalidFeeValueErrorType, OmniWithdrawalApiFeeRequestTimeoutError, OmniWithdrawalApiFeeRequestTimeoutErrorType, TokenNotFoundInDestinationChainError, TokenNotFoundInDestinationChainErrorType } from "./src/bridges/omni-bridge/error.js";
|
|
19
19
|
import { computeIntentHash } from "./src/intents/intent-hash.js";
|
|
20
20
|
import { validateAddress } from "./src/lib/validateAddress.js";
|
|
21
|
-
import { AssertionError, AssertionErrorType, BaseError, BaseErrorType, EnvConfig, 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";
|
|
22
|
-
export { AssertionError, type AssertionErrorType, BaseError, type BaseErrorType, type BatchWithdrawalResult, BridgeNameEnum, type BridgeNameEnumValues, type Chain, Chains, DestinationExplicitNearAccountDoesntExistError, type DestinationExplicitNearAccountDoesntExistErrorType, type EnvConfig, 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 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, 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 };
|
|
21
|
+
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";
|
|
22
|
+
export { AssertionError, type AssertionErrorType, BaseError, type BaseErrorType, type BatchWithdrawalResult, BridgeNameEnum, type BridgeNameEnumValues, type Chain, Chains, DestinationExplicitNearAccountDoesntExistError, type DestinationExplicitNearAccountDoesntExistErrorType, type EnvConfig, 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 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 };
|
|
@@ -22,7 +22,8 @@ var IntentsBridge = class {
|
|
|
22
22
|
const intents = [{
|
|
23
23
|
intent: "transfer",
|
|
24
24
|
receiver_id: args.withdrawalParams.destinationAddress,
|
|
25
|
-
tokens: { [args.withdrawalParams.assetId]: args.withdrawalParams.amount.toString() }
|
|
25
|
+
tokens: { [args.withdrawalParams.assetId]: args.withdrawalParams.amount.toString() },
|
|
26
|
+
memo: args.withdrawalParams.destinationMemo
|
|
26
27
|
}];
|
|
27
28
|
return Promise.resolve(intents);
|
|
28
29
|
}
|
|
@@ -22,7 +22,8 @@ var IntentsBridge = class {
|
|
|
22
22
|
const intents = [{
|
|
23
23
|
intent: "transfer",
|
|
24
24
|
receiver_id: args.withdrawalParams.destinationAddress,
|
|
25
|
-
tokens: { [args.withdrawalParams.assetId]: args.withdrawalParams.amount.toString() }
|
|
25
|
+
tokens: { [args.withdrawalParams.assetId]: args.withdrawalParams.amount.toString() },
|
|
26
|
+
memo: args.withdrawalParams.destinationMemo
|
|
26
27
|
}];
|
|
27
28
|
return Promise.resolve(intents);
|
|
28
29
|
}
|
|
@@ -1,17 +1,37 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_caip2 = require('./caip2.cjs');
|
|
3
|
-
const require_object = require('./object.cjs');
|
|
4
3
|
let _defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils");
|
|
5
4
|
|
|
6
5
|
//#region src/lib/configure-rpc-config.ts
|
|
6
|
+
/**
|
|
7
|
+
* Configures EVM RPC URLs by merging defaults with user-provided URLs.
|
|
8
|
+
* Extracts plain URL strings for compatibility with external SDKs.
|
|
9
|
+
*/
|
|
7
10
|
function configureEvmRpcUrls(defaultRpcUrls, userRpcUrls, supportedChains) {
|
|
8
|
-
const evmRpcUrls =
|
|
11
|
+
const evmRpcUrls = {};
|
|
12
|
+
for (const caip2 of supportedChains) {
|
|
13
|
+
const endpoints = userRpcUrls?.[caip2] ?? defaultRpcUrls[caip2];
|
|
14
|
+
if (endpoints) {
|
|
15
|
+
const chainId = require_caip2.getEIP155ChainId(caip2);
|
|
16
|
+
evmRpcUrls[chainId] = (0, _defuse_protocol_internal_utils.extractRpcUrls)(endpoints);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
9
19
|
for (const [chainId, urls] of Object.entries(evmRpcUrls)) (0, _defuse_protocol_internal_utils.assert)(urls.length > 0, `EVM RPC URLs for chain ${chainId} are not provided`);
|
|
10
20
|
return evmRpcUrls;
|
|
11
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Configures Stellar RPC URLs by merging defaults with user-provided URLs.
|
|
24
|
+
* Extracts plain URL strings for compatibility with external SDKs.
|
|
25
|
+
*/
|
|
12
26
|
function configureStellarRpcUrls(defaultRpcUrls, userRpcUrls) {
|
|
13
|
-
const
|
|
14
|
-
|
|
27
|
+
const soroban = userRpcUrls?.[require_caip2.Chains.Stellar]?.soroban ?? defaultRpcUrls.soroban;
|
|
28
|
+
const horizon = userRpcUrls?.[require_caip2.Chains.Stellar]?.horizon ?? defaultRpcUrls.horizon;
|
|
29
|
+
const stellarRpcUrls = {
|
|
30
|
+
soroban: (0, _defuse_protocol_internal_utils.extractRpcUrls)(soroban),
|
|
31
|
+
horizon: (0, _defuse_protocol_internal_utils.extractRpcUrls)(horizon)
|
|
32
|
+
};
|
|
33
|
+
(0, _defuse_protocol_internal_utils.assert)(stellarRpcUrls.soroban.length > 0, "Stellar Soroban RPC URL is not provided");
|
|
34
|
+
(0, _defuse_protocol_internal_utils.assert)(stellarRpcUrls.horizon.length > 0, "Stellar Horizon RPC URL is not provided");
|
|
15
35
|
return stellarRpcUrls;
|
|
16
36
|
}
|
|
17
37
|
|
|
@@ -1,16 +1,36 @@
|
|
|
1
1
|
import { Chains, getEIP155ChainId } from "./caip2.js";
|
|
2
|
-
import {
|
|
3
|
-
import { assert } from "@defuse-protocol/internal-utils";
|
|
2
|
+
import { assert, extractRpcUrls } from "@defuse-protocol/internal-utils";
|
|
4
3
|
|
|
5
4
|
//#region src/lib/configure-rpc-config.ts
|
|
5
|
+
/**
|
|
6
|
+
* Configures EVM RPC URLs by merging defaults with user-provided URLs.
|
|
7
|
+
* Extracts plain URL strings for compatibility with external SDKs.
|
|
8
|
+
*/
|
|
6
9
|
function configureEvmRpcUrls(defaultRpcUrls, userRpcUrls, supportedChains) {
|
|
7
|
-
const evmRpcUrls =
|
|
10
|
+
const evmRpcUrls = {};
|
|
11
|
+
for (const caip2 of supportedChains) {
|
|
12
|
+
const endpoints = userRpcUrls?.[caip2] ?? defaultRpcUrls[caip2];
|
|
13
|
+
if (endpoints) {
|
|
14
|
+
const chainId = getEIP155ChainId(caip2);
|
|
15
|
+
evmRpcUrls[chainId] = extractRpcUrls(endpoints);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
8
18
|
for (const [chainId, urls] of Object.entries(evmRpcUrls)) assert(urls.length > 0, `EVM RPC URLs for chain ${chainId} are not provided`);
|
|
9
19
|
return evmRpcUrls;
|
|
10
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Configures Stellar RPC URLs by merging defaults with user-provided URLs.
|
|
23
|
+
* Extracts plain URL strings for compatibility with external SDKs.
|
|
24
|
+
*/
|
|
11
25
|
function configureStellarRpcUrls(defaultRpcUrls, userRpcUrls) {
|
|
12
|
-
const
|
|
13
|
-
|
|
26
|
+
const soroban = userRpcUrls?.[Chains.Stellar]?.soroban ?? defaultRpcUrls.soroban;
|
|
27
|
+
const horizon = userRpcUrls?.[Chains.Stellar]?.horizon ?? defaultRpcUrls.horizon;
|
|
28
|
+
const stellarRpcUrls = {
|
|
29
|
+
soroban: extractRpcUrls(soroban),
|
|
30
|
+
horizon: extractRpcUrls(horizon)
|
|
31
|
+
};
|
|
32
|
+
assert(stellarRpcUrls.soroban.length > 0, "Stellar Soroban RPC URL is not provided");
|
|
33
|
+
assert(stellarRpcUrls.horizon.length > 0, "Stellar Horizon RPC URL is not provided");
|
|
14
34
|
return stellarRpcUrls;
|
|
15
35
|
}
|
|
16
36
|
|
package/dist/src/sdk.cjs
CHANGED
|
@@ -32,9 +32,10 @@ var IntentsSDK = class {
|
|
|
32
32
|
this.envConfig = (0, _defuse_protocol_internal_utils.resolveEnvConfig)(args.env);
|
|
33
33
|
this.referral = args.referral;
|
|
34
34
|
this.solverRelayApiKey = args.solverRelayApiKey;
|
|
35
|
-
const
|
|
36
|
-
(0, _defuse_protocol_internal_utils.assert)(
|
|
37
|
-
const nearProvider = (0, _defuse_protocol_internal_utils.nearFailoverRpcProvider)({ urls:
|
|
35
|
+
const nearRpcEndpoints = args.rpc?.[require_caip2.Chains.Near] ?? _defuse_protocol_internal_utils.PUBLIC_NEAR_RPC_URLS;
|
|
36
|
+
(0, _defuse_protocol_internal_utils.assert)(nearRpcEndpoints.length > 0, "NEAR RPC URLs are not provided");
|
|
37
|
+
const nearProvider = (0, _defuse_protocol_internal_utils.nearFailoverRpcProvider)({ urls: nearRpcEndpoints });
|
|
38
|
+
const nearRpcUrls = (0, _defuse_protocol_internal_utils.extractRpcUrls)(nearRpcEndpoints);
|
|
38
39
|
const stellarRpcUrls = require_configure_rpc_config.configureStellarRpcUrls(require_public_rpc_urls.PUBLIC_STELLAR_RPC_URLS, args.rpc);
|
|
39
40
|
const evmRpcUrls = require_configure_rpc_config.configureEvmRpcUrls(require_public_rpc_urls.PUBLIC_EVM_RPC_URLS, args.rpc, require_hot_bridge_chains.HotBridgeEVMChains);
|
|
40
41
|
/**
|
package/dist/src/sdk.js
CHANGED
|
@@ -19,7 +19,7 @@ import { configureEvmRpcUrls, configureStellarRpcUrls } from "./lib/configure-rp
|
|
|
19
19
|
import { createWithdrawalIdentifiers, watchWithdrawal } from "./core/withdrawal-watcher.js";
|
|
20
20
|
import { SaltManager } from "./intents/salt-manager.js";
|
|
21
21
|
import { IntentPayloadBuilder } from "./intents/intent-payload-builder.js";
|
|
22
|
-
import { PUBLIC_NEAR_RPC_URLS, RelayPublishError, assert, nearFailoverRpcProvider, resolveEnvConfig, solverRelay } from "@defuse-protocol/internal-utils";
|
|
22
|
+
import { PUBLIC_NEAR_RPC_URLS, RelayPublishError, assert, extractRpcUrls, nearFailoverRpcProvider, resolveEnvConfig, solverRelay } from "@defuse-protocol/internal-utils";
|
|
23
23
|
import { HotBridge } from "@hot-labs/omni-sdk";
|
|
24
24
|
import { stringify } from "viem";
|
|
25
25
|
import * as v from "valibot";
|
|
@@ -30,9 +30,10 @@ var IntentsSDK = class {
|
|
|
30
30
|
this.envConfig = resolveEnvConfig(args.env);
|
|
31
31
|
this.referral = args.referral;
|
|
32
32
|
this.solverRelayApiKey = args.solverRelayApiKey;
|
|
33
|
-
const
|
|
34
|
-
assert(
|
|
35
|
-
const nearProvider = nearFailoverRpcProvider({ urls:
|
|
33
|
+
const nearRpcEndpoints = args.rpc?.[Chains.Near] ?? PUBLIC_NEAR_RPC_URLS;
|
|
34
|
+
assert(nearRpcEndpoints.length > 0, "NEAR RPC URLs are not provided");
|
|
35
|
+
const nearProvider = nearFailoverRpcProvider({ urls: nearRpcEndpoints });
|
|
36
|
+
const nearRpcUrls = extractRpcUrls(nearRpcEndpoints);
|
|
36
37
|
const stellarRpcUrls = configureStellarRpcUrls(PUBLIC_STELLAR_RPC_URLS, args.rpc);
|
|
37
38
|
const evmRpcUrls = configureEvmRpcUrls(PUBLIC_EVM_RPC_URLS, args.rpc, HotBridgeEVMChains);
|
|
38
39
|
/**
|
|
@@ -5,7 +5,7 @@ import { IntentHash, IntentPayloadFactory, IntentPrimitive, IntentRelayParamsFac
|
|
|
5
5
|
import { IIntentSigner } from "./intents/interfaces/intent-signer.cjs";
|
|
6
6
|
import { OnBeforePublishIntentHook } from "./intents/intent-executer-impl/intent-executer.cjs";
|
|
7
7
|
import { Chain, Chains } from "./lib/caip2.cjs";
|
|
8
|
-
import { ILogger, solverRelay } from "@defuse-protocol/internal-utils";
|
|
8
|
+
import { ILogger, RpcEndpoint, solverRelay } from "@defuse-protocol/internal-utils";
|
|
9
9
|
|
|
10
10
|
//#region src/shared-types.d.ts
|
|
11
11
|
interface IntentPublishResult {
|
|
@@ -194,7 +194,10 @@ interface WithdrawalParams {
|
|
|
194
194
|
amount: bigint;
|
|
195
195
|
destinationAddress: string;
|
|
196
196
|
/**
|
|
197
|
-
*
|
|
197
|
+
* Optional memo attached to the withdrawal.
|
|
198
|
+
* - XRP Ledger: included in the transaction memo field
|
|
199
|
+
* - Internal transfers (intents): passed as memo in the transfer intent
|
|
200
|
+
* - Stellar, TON: NOT SUPPORTED (will throw error)
|
|
198
201
|
*/
|
|
199
202
|
destinationMemo?: string | undefined;
|
|
200
203
|
feeInclusive: boolean;
|
|
@@ -368,11 +371,17 @@ type ParsedAssetInfo = ({
|
|
|
368
371
|
} | {
|
|
369
372
|
address: string;
|
|
370
373
|
});
|
|
371
|
-
type RPCEndpointMap = Record<typeof Chains.Near | HotBridgeEVMChain,
|
|
372
|
-
soroban:
|
|
373
|
-
horizon:
|
|
374
|
+
type RPCEndpointMap = Record<typeof Chains.Near | HotBridgeEVMChain, RpcEndpoint[]> & { [K in typeof Chains.Stellar]: {
|
|
375
|
+
soroban: RpcEndpoint[];
|
|
376
|
+
horizon: RpcEndpoint[];
|
|
374
377
|
} };
|
|
375
|
-
|
|
376
|
-
|
|
378
|
+
/**
|
|
379
|
+
* Partial RPC endpoint map where each chain's URLs are optional,
|
|
380
|
+
* but individual RpcEndpoint items remain valid (not deeply partial).
|
|
381
|
+
*/
|
|
382
|
+
type PartialRPCEndpointMap = { [K in keyof RPCEndpointMap]?: K extends typeof Chains.Stellar ? {
|
|
383
|
+
soroban?: RpcEndpoint[];
|
|
384
|
+
horizon?: RpcEndpoint[];
|
|
385
|
+
} : RpcEndpoint[] };
|
|
377
386
|
//#endregion
|
|
378
387
|
export { BatchWithdrawalResult, Bridge, CreateWithdrawalCompletionPromisesParams, FeeEstimation, HotBridgeRouteConfig, IIntentsSDK, IntentPublishResult, IntentSettlementStatus, InternalTransferRouteConfig, NearTxInfo, NearWithdrawalRouteConfig, OmniBridgeRouteConfig, ParsedAssetInfo, PartialRPCEndpointMap, PoaBridgeRouteConfig, ProcessWithdrawalArgs, QuoteOptions, RouteConfig, SignAndSendArgs, SignAndSendWithdrawalArgs, SignedIntentsComposition, TxInfo, TxNoInfo, VirtualChainRouteConfig, WithdrawalIdentifier, WithdrawalParams, WithdrawalResult };
|
|
@@ -5,7 +5,7 @@ import { IntentHash, IntentPayloadFactory, IntentPrimitive, IntentRelayParamsFac
|
|
|
5
5
|
import { IIntentSigner } from "./intents/interfaces/intent-signer.js";
|
|
6
6
|
import { OnBeforePublishIntentHook } from "./intents/intent-executer-impl/intent-executer.js";
|
|
7
7
|
import { Chain, Chains } from "./lib/caip2.js";
|
|
8
|
-
import { ILogger, solverRelay } from "@defuse-protocol/internal-utils";
|
|
8
|
+
import { ILogger, RpcEndpoint, solverRelay } from "@defuse-protocol/internal-utils";
|
|
9
9
|
|
|
10
10
|
//#region src/shared-types.d.ts
|
|
11
11
|
interface IntentPublishResult {
|
|
@@ -194,7 +194,10 @@ interface WithdrawalParams {
|
|
|
194
194
|
amount: bigint;
|
|
195
195
|
destinationAddress: string;
|
|
196
196
|
/**
|
|
197
|
-
*
|
|
197
|
+
* Optional memo attached to the withdrawal.
|
|
198
|
+
* - XRP Ledger: included in the transaction memo field
|
|
199
|
+
* - Internal transfers (intents): passed as memo in the transfer intent
|
|
200
|
+
* - Stellar, TON: NOT SUPPORTED (will throw error)
|
|
198
201
|
*/
|
|
199
202
|
destinationMemo?: string | undefined;
|
|
200
203
|
feeInclusive: boolean;
|
|
@@ -368,11 +371,17 @@ type ParsedAssetInfo = ({
|
|
|
368
371
|
} | {
|
|
369
372
|
address: string;
|
|
370
373
|
});
|
|
371
|
-
type RPCEndpointMap = Record<typeof Chains.Near | HotBridgeEVMChain,
|
|
372
|
-
soroban:
|
|
373
|
-
horizon:
|
|
374
|
+
type RPCEndpointMap = Record<typeof Chains.Near | HotBridgeEVMChain, RpcEndpoint[]> & { [K in typeof Chains.Stellar]: {
|
|
375
|
+
soroban: RpcEndpoint[];
|
|
376
|
+
horizon: RpcEndpoint[];
|
|
374
377
|
} };
|
|
375
|
-
|
|
376
|
-
|
|
378
|
+
/**
|
|
379
|
+
* Partial RPC endpoint map where each chain's URLs are optional,
|
|
380
|
+
* but individual RpcEndpoint items remain valid (not deeply partial).
|
|
381
|
+
*/
|
|
382
|
+
type PartialRPCEndpointMap = { [K in keyof RPCEndpointMap]?: K extends typeof Chains.Stellar ? {
|
|
383
|
+
soroban?: RpcEndpoint[];
|
|
384
|
+
horizon?: RpcEndpoint[];
|
|
385
|
+
} : RpcEndpoint[] };
|
|
377
386
|
//#endregion
|
|
378
387
|
export { BatchWithdrawalResult, Bridge, CreateWithdrawalCompletionPromisesParams, FeeEstimation, HotBridgeRouteConfig, IIntentsSDK, IntentPublishResult, IntentSettlementStatus, InternalTransferRouteConfig, NearTxInfo, NearWithdrawalRouteConfig, OmniBridgeRouteConfig, ParsedAssetInfo, PartialRPCEndpointMap, PoaBridgeRouteConfig, ProcessWithdrawalArgs, QuoteOptions, RouteConfig, SignAndSendArgs, SignAndSendWithdrawalArgs, SignedIntentsComposition, TxInfo, TxNoInfo, VirtualChainRouteConfig, WithdrawalIdentifier, WithdrawalParams, WithdrawalResult };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defuse-protocol/intents-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.48.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"valibot": "^1.0.0",
|
|
49
49
|
"viem": "^2.0.0",
|
|
50
50
|
"@defuse-protocol/contract-types": "0.5.0",
|
|
51
|
-
"@defuse-protocol/internal-utils": "0.
|
|
51
|
+
"@defuse-protocol/internal-utils": "0.25.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"tsdown": "0.19.0"
|
package/dist/src/lib/object.cjs
DELETED