@defuse-protocol/intents-sdk 0.46.1 → 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/hot-bridge/hot-bridge.cjs +70 -2
- package/dist/src/bridges/hot-bridge/hot-bridge.js +69 -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/bridges/omni-bridge/omni-bridge-utils.cjs +1 -1
- package/dist/src/bridges/omni-bridge/omni-bridge-utils.js +1 -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 +3 -3
- 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 };
|
|
@@ -12,14 +12,46 @@ const require_hot_bridge_utils = require('./hot-bridge-utils.cjs');
|
|
|
12
12
|
const require_hex = require('../../lib/hex.cjs');
|
|
13
13
|
let _defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils");
|
|
14
14
|
let _hot_labs_omni_sdk = require("@hot-labs/omni-sdk");
|
|
15
|
+
let lru_cache = require("lru-cache");
|
|
16
|
+
let valibot = require("valibot");
|
|
17
|
+
valibot = require_rolldown_runtime.__toESM(valibot);
|
|
15
18
|
|
|
16
19
|
//#region src/bridges/hot-bridge/hot-bridge.ts
|
|
17
|
-
|
|
20
|
+
const HotApiWithdrawalSchema = valibot.object({
|
|
21
|
+
hash: valibot.nullable(valibot.string()),
|
|
22
|
+
nonce: valibot.string(),
|
|
23
|
+
near_trx: valibot.string(),
|
|
24
|
+
verified_withdraw: valibot.boolean(),
|
|
25
|
+
chain_id: valibot.number()
|
|
26
|
+
});
|
|
27
|
+
const HotApiWithdrawalResponseSchema = valibot.object({
|
|
28
|
+
hash: valibot.nullable(valibot.string()),
|
|
29
|
+
nonce: valibot.string(),
|
|
30
|
+
near_trx: valibot.string(),
|
|
31
|
+
withdrawals: valibot.array(HotApiWithdrawalSchema)
|
|
32
|
+
});
|
|
33
|
+
var HotBridge = class HotBridge {
|
|
34
|
+
static {
|
|
35
|
+
this.API_FALLBACK_TIMEOUT_MS = 5e3;
|
|
36
|
+
}
|
|
37
|
+
static {
|
|
38
|
+
this.NEAR_RPC_TIMEOUT_MS = 1e4;
|
|
39
|
+
}
|
|
18
40
|
constructor({ envConfig, hotSdk, solverRelayApiKey }) {
|
|
19
41
|
this.route = require_route_enum.RouteEnum.HotBridge;
|
|
20
42
|
this.envConfig = envConfig;
|
|
21
43
|
this.hotSdk = hotSdk;
|
|
22
44
|
this.solverRelayApiKey = solverRelayApiKey;
|
|
45
|
+
this.noncesCache = new lru_cache.LRUCache({
|
|
46
|
+
max: 50,
|
|
47
|
+
ttl: 3600 * 1e3,
|
|
48
|
+
fetchMethod: async (_key, _staleValue, { context: tx }) => {
|
|
49
|
+
return (0, _defuse_protocol_internal_utils.withTimeout)(() => this.hotSdk.near.parseWithdrawalNonces(tx.hash, tx.accountId), { timeout: HotBridge.NEAR_RPC_TIMEOUT_MS });
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
getNoncesCacheKey(tx) {
|
|
54
|
+
return `${tx.hash}:${tx.accountId}`;
|
|
23
55
|
}
|
|
24
56
|
is(routeConfig) {
|
|
25
57
|
return routeConfig.route === require_route_enum.RouteEnum.HotBridge;
|
|
@@ -141,7 +173,10 @@ var HotBridge = class {
|
|
|
141
173
|
};
|
|
142
174
|
}
|
|
143
175
|
async describeWithdrawal(args) {
|
|
144
|
-
const
|
|
176
|
+
const cacheKey = this.getNoncesCacheKey(args.tx);
|
|
177
|
+
const nonces = await this.noncesCache.fetch(cacheKey, { context: args.tx });
|
|
178
|
+
if (nonces == null) throw new require_error.HotWithdrawalNotFoundError(args.tx.hash, args.index);
|
|
179
|
+
const nonce = nonces[args.index];
|
|
145
180
|
if (nonce == null) throw new require_error.HotWithdrawalNotFoundError(args.tx.hash, args.index);
|
|
146
181
|
const status = await this.hotSdk.getGaslessWithdrawStatus(nonce.toString());
|
|
147
182
|
if (status === require_hot_bridge_constants.HotWithdrawStatus.Canceled) return {
|
|
@@ -165,8 +200,41 @@ var HotBridge = class {
|
|
|
165
200
|
txHash: require_hot_bridge_utils.formatTxHash(status, args.landingChain)
|
|
166
201
|
};
|
|
167
202
|
}
|
|
203
|
+
const apiHash = await this.fetchWithdrawalHashFromApi(args.tx.hash, nonce, args.logger);
|
|
204
|
+
if (apiHash != null) return {
|
|
205
|
+
status: "completed",
|
|
206
|
+
txHash: require_hot_bridge_utils.formatTxHash(apiHash, args.landingChain)
|
|
207
|
+
};
|
|
168
208
|
return { status: "pending" };
|
|
169
209
|
}
|
|
210
|
+
async fetchWithdrawalHashFromApi(nearTxHash, nonce, logger) {
|
|
211
|
+
try {
|
|
212
|
+
const data = await (await (0, _defuse_protocol_internal_utils.withTimeout)(() => this.hotSdk.api.requestApi(`/api/v1/evm/bridge_withdrawal_hash?near_trx=${nearTxHash}`, { method: "GET" }), { timeout: HotBridge.API_FALLBACK_TIMEOUT_MS })).json();
|
|
213
|
+
const parseResult = valibot.safeParse(HotApiWithdrawalResponseSchema, data);
|
|
214
|
+
if (!parseResult.success) {
|
|
215
|
+
logger?.debug("HOT API response parse failed", { issues: parseResult.issues });
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
const withdrawal = parseResult.output.withdrawals.find((w) => w.nonce === nonce.toString());
|
|
219
|
+
if (withdrawal?.hash) {
|
|
220
|
+
const hash = withdrawal.hash.replace(/^0x/, "");
|
|
221
|
+
if (require_hex.default(hash)) {
|
|
222
|
+
logger?.info("HOT withdrawal hash found via API fallback", {
|
|
223
|
+
nearTxHash,
|
|
224
|
+
nonce: nonce.toString()
|
|
225
|
+
});
|
|
226
|
+
return hash;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return null;
|
|
230
|
+
} catch (error) {
|
|
231
|
+
logger?.debug("HOT API fallback failed", {
|
|
232
|
+
error,
|
|
233
|
+
nearTxHash
|
|
234
|
+
});
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
170
238
|
};
|
|
171
239
|
|
|
172
240
|
//#endregion
|
|
@@ -11,14 +11,45 @@ import { formatTxHash, getFeeAssetIdForChain, hotBlockchainInvariant, hotNetwork
|
|
|
11
11
|
import isHex from "../../lib/hex.js";
|
|
12
12
|
import { assert, withTimeout } from "@defuse-protocol/internal-utils";
|
|
13
13
|
import { OMNI_HOT_V2, utils as utils$1 } from "@hot-labs/omni-sdk";
|
|
14
|
+
import { LRUCache } from "lru-cache";
|
|
15
|
+
import * as v from "valibot";
|
|
14
16
|
|
|
15
17
|
//#region src/bridges/hot-bridge/hot-bridge.ts
|
|
16
|
-
|
|
18
|
+
const HotApiWithdrawalSchema = v.object({
|
|
19
|
+
hash: v.nullable(v.string()),
|
|
20
|
+
nonce: v.string(),
|
|
21
|
+
near_trx: v.string(),
|
|
22
|
+
verified_withdraw: v.boolean(),
|
|
23
|
+
chain_id: v.number()
|
|
24
|
+
});
|
|
25
|
+
const HotApiWithdrawalResponseSchema = v.object({
|
|
26
|
+
hash: v.nullable(v.string()),
|
|
27
|
+
nonce: v.string(),
|
|
28
|
+
near_trx: v.string(),
|
|
29
|
+
withdrawals: v.array(HotApiWithdrawalSchema)
|
|
30
|
+
});
|
|
31
|
+
var HotBridge$1 = class HotBridge$1 {
|
|
32
|
+
static {
|
|
33
|
+
this.API_FALLBACK_TIMEOUT_MS = 5e3;
|
|
34
|
+
}
|
|
35
|
+
static {
|
|
36
|
+
this.NEAR_RPC_TIMEOUT_MS = 1e4;
|
|
37
|
+
}
|
|
17
38
|
constructor({ envConfig, hotSdk, solverRelayApiKey }) {
|
|
18
39
|
this.route = RouteEnum.HotBridge;
|
|
19
40
|
this.envConfig = envConfig;
|
|
20
41
|
this.hotSdk = hotSdk;
|
|
21
42
|
this.solverRelayApiKey = solverRelayApiKey;
|
|
43
|
+
this.noncesCache = new LRUCache({
|
|
44
|
+
max: 50,
|
|
45
|
+
ttl: 3600 * 1e3,
|
|
46
|
+
fetchMethod: async (_key, _staleValue, { context: tx }) => {
|
|
47
|
+
return withTimeout(() => this.hotSdk.near.parseWithdrawalNonces(tx.hash, tx.accountId), { timeout: HotBridge$1.NEAR_RPC_TIMEOUT_MS });
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
getNoncesCacheKey(tx) {
|
|
52
|
+
return `${tx.hash}:${tx.accountId}`;
|
|
22
53
|
}
|
|
23
54
|
is(routeConfig) {
|
|
24
55
|
return routeConfig.route === RouteEnum.HotBridge;
|
|
@@ -140,7 +171,10 @@ var HotBridge$1 = class {
|
|
|
140
171
|
};
|
|
141
172
|
}
|
|
142
173
|
async describeWithdrawal(args) {
|
|
143
|
-
const
|
|
174
|
+
const cacheKey = this.getNoncesCacheKey(args.tx);
|
|
175
|
+
const nonces = await this.noncesCache.fetch(cacheKey, { context: args.tx });
|
|
176
|
+
if (nonces == null) throw new HotWithdrawalNotFoundError(args.tx.hash, args.index);
|
|
177
|
+
const nonce = nonces[args.index];
|
|
144
178
|
if (nonce == null) throw new HotWithdrawalNotFoundError(args.tx.hash, args.index);
|
|
145
179
|
const status = await this.hotSdk.getGaslessWithdrawStatus(nonce.toString());
|
|
146
180
|
if (status === HotWithdrawStatus.Canceled) return {
|
|
@@ -164,8 +198,41 @@ var HotBridge$1 = class {
|
|
|
164
198
|
txHash: formatTxHash(status, args.landingChain)
|
|
165
199
|
};
|
|
166
200
|
}
|
|
201
|
+
const apiHash = await this.fetchWithdrawalHashFromApi(args.tx.hash, nonce, args.logger);
|
|
202
|
+
if (apiHash != null) return {
|
|
203
|
+
status: "completed",
|
|
204
|
+
txHash: formatTxHash(apiHash, args.landingChain)
|
|
205
|
+
};
|
|
167
206
|
return { status: "pending" };
|
|
168
207
|
}
|
|
208
|
+
async fetchWithdrawalHashFromApi(nearTxHash, nonce, logger) {
|
|
209
|
+
try {
|
|
210
|
+
const data = await (await withTimeout(() => this.hotSdk.api.requestApi(`/api/v1/evm/bridge_withdrawal_hash?near_trx=${nearTxHash}`, { method: "GET" }), { timeout: HotBridge$1.API_FALLBACK_TIMEOUT_MS })).json();
|
|
211
|
+
const parseResult = v.safeParse(HotApiWithdrawalResponseSchema, data);
|
|
212
|
+
if (!parseResult.success) {
|
|
213
|
+
logger?.debug("HOT API response parse failed", { issues: parseResult.issues });
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
const withdrawal = parseResult.output.withdrawals.find((w) => w.nonce === nonce.toString());
|
|
217
|
+
if (withdrawal?.hash) {
|
|
218
|
+
const hash = withdrawal.hash.replace(/^0x/, "");
|
|
219
|
+
if (isHex(hash)) {
|
|
220
|
+
logger?.info("HOT withdrawal hash found via API fallback", {
|
|
221
|
+
nearTxHash,
|
|
222
|
+
nonce: nonce.toString()
|
|
223
|
+
});
|
|
224
|
+
return hash;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return null;
|
|
228
|
+
} catch (error) {
|
|
229
|
+
logger?.debug("HOT API fallback failed", {
|
|
230
|
+
error,
|
|
231
|
+
nearTxHash
|
|
232
|
+
});
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
169
236
|
};
|
|
170
237
|
|
|
171
238
|
//#endregion
|
|
@@ -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
|
}
|
|
@@ -3,9 +3,9 @@ const require_caip2 = require('../../lib/caip2.cjs');
|
|
|
3
3
|
const require_omni_bridge_constants = require('./omni-bridge-constants.cjs');
|
|
4
4
|
const require_poa_tokens_routable_through_omni_bridge = require('../../constants/poa-tokens-routable-through-omni-bridge.cjs');
|
|
5
5
|
let _defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils");
|
|
6
|
-
let omni_bridge_sdk = require("omni-bridge-sdk");
|
|
7
6
|
let valibot = require("valibot");
|
|
8
7
|
valibot = require_rolldown_runtime.__toESM(valibot);
|
|
8
|
+
let omni_bridge_sdk = require("omni-bridge-sdk");
|
|
9
9
|
|
|
10
10
|
//#region src/bridges/omni-bridge/omni-bridge-utils.ts
|
|
11
11
|
function createWithdrawIntentsPrimitive(params) {
|
|
@@ -2,8 +2,8 @@ import { Chains } from "../../lib/caip2.js";
|
|
|
2
2
|
import { MIN_GAS_AMOUNT, OMNI_BRIDGE_CONTRACT } from "./omni-bridge-constants.js";
|
|
3
3
|
import { POA_TOKENS_ROUTABLE_THROUGH_OMNI_BRIDGE } from "../../constants/poa-tokens-routable-through-omni-bridge.js";
|
|
4
4
|
import { assert, utils } from "@defuse-protocol/internal-utils";
|
|
5
|
-
import { ChainKind, calculateStorageAccountId, getChain, isBridgeToken, omniAddress } from "omni-bridge-sdk";
|
|
6
5
|
import * as v from "valibot";
|
|
6
|
+
import { ChainKind, calculateStorageAccountId, getChain, isBridgeToken, omniAddress } from "omni-bridge-sdk";
|
|
7
7
|
|
|
8
8
|
//#region src/bridges/omni-bridge/omni-bridge-utils.ts
|
|
9
9
|
function createWithdrawIntentsPrimitive(params) {
|
|
@@ -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": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"typescript": "^5"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@hot-labs/omni-sdk": "2.24.
|
|
34
|
+
"@hot-labs/omni-sdk": "2.24.7",
|
|
35
35
|
"@isaacs/ttlcache": "^1.0.0",
|
|
36
36
|
"@lifeomic/attempt": "^3.0.0",
|
|
37
37
|
"@near-js/accounts": "^2.0.1",
|
|
@@ -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