@defuse-protocol/intents-sdk 0.43.3 → 0.44.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 +143 -21
- package/dist/index.cjs +19 -18
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +7 -5
- package/dist/src/bridges/aurora-engine-bridge/aurora-engine-bridge-utils.cjs +5 -5
- package/dist/src/bridges/aurora-engine-bridge/aurora-engine-bridge.cjs +24 -12
- package/dist/src/bridges/aurora-engine-bridge/aurora-engine-bridge.js +19 -7
- package/dist/src/bridges/direct-bridge/direct-bridge-utils.cjs +5 -5
- package/dist/src/bridges/direct-bridge/direct-bridge.cjs +22 -10
- package/dist/src/bridges/direct-bridge/direct-bridge.js +16 -4
- package/dist/src/bridges/direct-bridge/error.cjs +2 -2
- package/dist/src/bridges/hot-bridge/error.cjs +4 -26
- package/dist/src/bridges/hot-bridge/error.d.cts +1 -17
- package/dist/src/bridges/hot-bridge/error.d.ts +1 -17
- package/dist/src/bridges/hot-bridge/error.js +1 -21
- package/dist/src/bridges/hot-bridge/hot-bridge-utils.cjs +10 -10
- package/dist/src/bridges/hot-bridge/hot-bridge.cjs +46 -32
- package/dist/src/bridges/hot-bridge/hot-bridge.js +38 -24
- package/dist/src/bridges/intents-bridge/intents-bridge.cjs +18 -4
- package/dist/src/bridges/intents-bridge/intents-bridge.js +18 -4
- package/dist/src/bridges/omni-bridge/error.cjs +6 -27
- package/dist/src/bridges/omni-bridge/error.d.cts +1 -16
- package/dist/src/bridges/omni-bridge/error.d.ts +1 -16
- package/dist/src/bridges/omni-bridge/error.js +1 -20
- package/dist/src/bridges/omni-bridge/omni-bridge-utils.cjs +12 -7
- package/dist/src/bridges/omni-bridge/omni-bridge-utils.js +5 -1
- package/dist/src/bridges/omni-bridge/omni-bridge.cjs +72 -54
- package/dist/src/bridges/omni-bridge/omni-bridge.js +47 -29
- package/dist/src/bridges/poa-bridge/poa-bridge-utils.cjs +2 -2
- package/dist/src/bridges/poa-bridge/poa-bridge.cjs +79 -26
- package/dist/src/bridges/poa-bridge/poa-bridge.js +66 -13
- package/dist/src/classes/errors.cjs +7 -7
- package/dist/src/constants/poa-tokens-routable-through-omni-bridge.cjs +17 -0
- package/dist/src/constants/poa-tokens-routable-through-omni-bridge.d.cts +12 -0
- package/dist/src/constants/poa-tokens-routable-through-omni-bridge.d.ts +12 -0
- package/dist/src/constants/poa-tokens-routable-through-omni-bridge.js +16 -0
- package/dist/src/constants/withdrawal-timing.cjs +57 -0
- package/dist/src/constants/withdrawal-timing.js +56 -0
- package/dist/src/core/withdrawal-watcher.cjs +83 -0
- package/dist/src/core/withdrawal-watcher.d.cts +18 -0
- package/dist/src/core/withdrawal-watcher.d.ts +18 -0
- package/dist/src/core/withdrawal-watcher.js +79 -0
- package/dist/src/intents/expirable-nonce.cjs +3 -3
- package/dist/src/intents/intent-executer-impl/intent-executer.cjs +7 -4
- package/dist/src/intents/intent-executer-impl/intent-executer.js +5 -2
- package/dist/src/intents/intent-hash.cjs +2 -2
- package/dist/src/intents/intent-hashes/erc191.cjs +2 -2
- package/dist/src/intents/intent-hashes/nep413.cjs +2 -2
- package/dist/src/intents/intent-hashes/raw-ed25519.cjs +2 -2
- package/dist/src/intents/intent-hashes/sep53.cjs +4 -4
- package/dist/src/intents/intent-hashes/tip191.cjs +2 -2
- package/dist/src/intents/intent-hashes/ton-connect.cjs +2 -2
- package/dist/src/intents/intent-hashes/webauthn.cjs +2 -2
- package/dist/src/intents/intent-payload-builder.cjs +4 -4
- package/dist/src/intents/intent-relayer-impl/intent-relayer-public.cjs +7 -7
- package/dist/src/intents/intent-relayer-impl/intent-relayer-public.js +1 -1
- package/dist/src/intents/intent-signer-impl/intent-signer-near-keypair.cjs +2 -2
- package/dist/src/intents/intent-signer-impl/intent-signer-nep413.cjs +3 -3
- package/dist/src/intents/intent-signer-impl/intent-signer-viem.cjs +3 -3
- package/dist/src/intents/interfaces/intent-relayer.d.cts +2 -1
- package/dist/src/intents/interfaces/intent-relayer.d.ts +2 -1
- package/dist/src/intents/salt-manager.cjs +5 -5
- package/dist/src/lib/array.cjs +2 -2
- package/dist/src/lib/caip2.cjs +4 -4
- package/dist/src/lib/configure-rpc-config.cjs +3 -3
- package/dist/src/lib/estimate-fee.cjs +6 -6
- package/dist/src/lib/parse-defuse-asset-id.cjs +2 -2
- package/dist/src/lib/route-config-factory.cjs +2 -5
- package/dist/src/lib/route-config-factory.d.cts +1 -1
- package/dist/src/lib/route-config-factory.d.ts +1 -1
- package/dist/src/lib/route-config-factory.js +2 -5
- package/dist/src/lib/tokensUsdPricesHttpClient/apis.cjs +3 -3
- package/dist/src/lib/validateAddress.cjs +18 -18
- package/dist/src/sdk.cjs +96 -47
- package/dist/src/sdk.d.cts +72 -11
- package/dist/src/sdk.d.ts +72 -11
- package/dist/src/sdk.js +85 -36
- package/dist/src/shared-types.d.cts +49 -15
- package/dist/src/shared-types.d.ts +49 -15
- package/package.json +4 -6
- package/dist/src/lib/route-config.cjs +0 -19
- package/dist/src/lib/route-config.js +0 -19
|
@@ -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,
|
|
8
|
+
import { ILogger, solverRelay } from "@defuse-protocol/internal-utils";
|
|
9
9
|
|
|
10
10
|
//#region src/shared-types.d.ts
|
|
11
11
|
interface IntentPublishResult {
|
|
@@ -106,7 +106,6 @@ type ProcessWithdrawalArgs<T extends WithdrawalParams | WithdrawalParams[]> = {
|
|
|
106
106
|
signedIntents?: SignedIntentsComposition;
|
|
107
107
|
};
|
|
108
108
|
referral?: string;
|
|
109
|
-
retryOptions?: RetryOptions;
|
|
110
109
|
logger?: ILogger;
|
|
111
110
|
};
|
|
112
111
|
interface IIntentsSDK {
|
|
@@ -114,6 +113,8 @@ interface IIntentsSDK {
|
|
|
114
113
|
signAndSendIntent(args: SignAndSendArgs): Promise<IntentPublishResult>;
|
|
115
114
|
waitForIntentSettlement(args: {
|
|
116
115
|
intentHash: IntentHash;
|
|
116
|
+
/** AbortSignal for cancellation/timeout. Use AbortSignal.timeout(ms) for timeout. */
|
|
117
|
+
signal?: AbortSignal;
|
|
117
118
|
logger?: ILogger;
|
|
118
119
|
}): Promise<NearTxInfo>;
|
|
119
120
|
getIntentStatus(args: {
|
|
@@ -140,16 +141,15 @@ interface IIntentsSDK {
|
|
|
140
141
|
withdrawalParams: WithdrawalParams;
|
|
141
142
|
intentTx: NearTxInfo;
|
|
142
143
|
signal?: AbortSignal;
|
|
143
|
-
retryOptions?: RetryOptions;
|
|
144
144
|
logger?: ILogger;
|
|
145
145
|
}): Promise<TxInfo | TxNoInfo>;
|
|
146
146
|
waitForWithdrawalCompletion(args: {
|
|
147
147
|
withdrawalParams: WithdrawalParams[];
|
|
148
148
|
intentTx: NearTxInfo;
|
|
149
149
|
signal?: AbortSignal;
|
|
150
|
-
retryOptions?: RetryOptions;
|
|
151
150
|
logger?: ILogger;
|
|
152
151
|
}): Promise<Array<TxInfo | TxNoInfo>>;
|
|
152
|
+
createWithdrawalCompletionPromises(params: CreateWithdrawalCompletionPromisesParams): Array<Promise<TxInfo | TxNoInfo>>;
|
|
153
153
|
createWithdrawalIntents(args: {
|
|
154
154
|
withdrawalParams: WithdrawalParams;
|
|
155
155
|
feeEstimation: FeeEstimation;
|
|
@@ -176,6 +176,12 @@ interface TxInfo {
|
|
|
176
176
|
interface TxNoInfo {
|
|
177
177
|
hash: null;
|
|
178
178
|
}
|
|
179
|
+
interface CreateWithdrawalCompletionPromisesParams {
|
|
180
|
+
withdrawalParams: WithdrawalParams[];
|
|
181
|
+
intentTx: NearTxInfo;
|
|
182
|
+
signal?: AbortSignal;
|
|
183
|
+
logger?: ILogger;
|
|
184
|
+
}
|
|
179
185
|
interface WithdrawalParams {
|
|
180
186
|
assetId: string;
|
|
181
187
|
amount: bigint;
|
|
@@ -201,7 +207,6 @@ type VirtualChainRouteConfig = {
|
|
|
201
207
|
};
|
|
202
208
|
type PoaBridgeRouteConfig = {
|
|
203
209
|
route: RouteEnum["PoaBridge"];
|
|
204
|
-
chain: Chain;
|
|
205
210
|
};
|
|
206
211
|
type HotBridgeRouteConfig = {
|
|
207
212
|
route: RouteEnum["HotBridge"];
|
|
@@ -266,7 +271,7 @@ interface FeeEstimation {
|
|
|
266
271
|
underlyingFees: UnderlyingFees;
|
|
267
272
|
}
|
|
268
273
|
interface Bridge {
|
|
269
|
-
|
|
274
|
+
readonly route: RouteEnumValues;
|
|
270
275
|
supports(params: Pick<WithdrawalParams, "assetId" | "routeConfig">): Promise<boolean>;
|
|
271
276
|
parseAssetId(assetId: string): ParsedAssetInfo | null;
|
|
272
277
|
/**
|
|
@@ -295,22 +300,51 @@ interface Bridge {
|
|
|
295
300
|
feeEstimation: FeeEstimation;
|
|
296
301
|
referral?: string;
|
|
297
302
|
}): Promise<IntentPrimitive[]>;
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
303
|
+
/**
|
|
304
|
+
* Creates a complete withdrawal identifier with all required info.
|
|
305
|
+
* Derives landingChain from withdrawalParams.routeConfig.chain if available, otherwise from assetId.
|
|
306
|
+
*/
|
|
307
|
+
createWithdrawalIdentifier(args: {
|
|
301
308
|
withdrawalParams: WithdrawalParams;
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
309
|
+
index: number;
|
|
310
|
+
tx: NearTxInfo;
|
|
311
|
+
}): WithdrawalIdentifier;
|
|
312
|
+
/**
|
|
313
|
+
* One-shot status check for a withdrawal.
|
|
314
|
+
* Returns the current status without polling.
|
|
315
|
+
*/
|
|
316
|
+
describeWithdrawal(args: WithdrawalIdentifier & {
|
|
305
317
|
logger?: ILogger;
|
|
306
|
-
}): Promise<
|
|
318
|
+
}): Promise<WithdrawalStatus>;
|
|
307
319
|
}
|
|
308
320
|
interface WithdrawalIdentifier {
|
|
309
|
-
|
|
321
|
+
/** Actual chain where funds arrive; Near for virtual/internal routes */
|
|
322
|
+
landingChain: Chain;
|
|
323
|
+
/** Per-bridge withdrawal sequence number */
|
|
310
324
|
index: number;
|
|
311
325
|
withdrawalParams: WithdrawalParams;
|
|
312
326
|
tx: NearTxInfo;
|
|
313
327
|
}
|
|
328
|
+
/**
|
|
329
|
+
* Represents the current state of a withdrawal as returned by bridge adapters.
|
|
330
|
+
*
|
|
331
|
+
* Error handling follows AWS SDK "describe" API patterns:
|
|
332
|
+
* - **Thrown errors**: Infrastructure failures (network, auth, service unavailable).
|
|
333
|
+
* Meaning: "I couldn't check the status."
|
|
334
|
+
* - **`failed` status**: Job-level failure reported by the bridge.
|
|
335
|
+
* Meaning: "I checked, and the withdrawal failed."
|
|
336
|
+
*
|
|
337
|
+
* @see https://docs.aws.amazon.com/AmazonS3/latest/userguide/batch-ops-job-status.html
|
|
338
|
+
*/
|
|
339
|
+
type WithdrawalStatus = {
|
|
340
|
+
status: "pending";
|
|
341
|
+
} | {
|
|
342
|
+
status: "completed";
|
|
343
|
+
txHash: string | null;
|
|
344
|
+
} | {
|
|
345
|
+
status: "failed";
|
|
346
|
+
reason: string;
|
|
347
|
+
};
|
|
314
348
|
type ParsedAssetInfo = ({
|
|
315
349
|
blockchain: Chain;
|
|
316
350
|
bridgeName: BridgeNameEnumValues;
|
|
@@ -334,4 +368,4 @@ type RPCEndpointMap = Record<typeof Chains.Near | HotBridgeEVMChain, string[]> &
|
|
|
334
368
|
type DeepPartial<T> = T extends object ? T extends Array<infer U> ? Array<DeepPartial<U>> : T extends Function ? T : { [P in keyof T]?: DeepPartial<T[P]> } : T;
|
|
335
369
|
type PartialRPCEndpointMap = DeepPartial<RPCEndpointMap>;
|
|
336
370
|
//#endregion
|
|
337
|
-
export { BatchWithdrawalResult, Bridge, FeeEstimation, HotBridgeRouteConfig, IIntentsSDK, IntentPublishResult, IntentSettlementStatus, InternalTransferRouteConfig, NearTxInfo, NearWithdrawalRouteConfig, OmniBridgeRouteConfig, ParsedAssetInfo, PartialRPCEndpointMap, PoaBridgeRouteConfig, ProcessWithdrawalArgs, QuoteOptions, RouteConfig, SignAndSendArgs, SignAndSendWithdrawalArgs, SignedIntentsComposition, TxInfo, TxNoInfo, VirtualChainRouteConfig, WithdrawalIdentifier, WithdrawalParams, WithdrawalResult };
|
|
371
|
+
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.44.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -47,15 +47,13 @@
|
|
|
47
47
|
"ripple-address-codec": "^5.0.0",
|
|
48
48
|
"valibot": "^1.0.0",
|
|
49
49
|
"viem": "^2.0.0",
|
|
50
|
-
"@defuse-protocol/
|
|
51
|
-
"@defuse-protocol/
|
|
50
|
+
"@defuse-protocol/internal-utils": "0.22.0",
|
|
51
|
+
"@defuse-protocol/contract-types": "0.4.3"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"tsdown": "0.15.5"
|
|
55
|
-
"vitest": "2.1.2"
|
|
54
|
+
"tsdown": "0.15.5"
|
|
56
55
|
},
|
|
57
56
|
"scripts": {
|
|
58
|
-
"test": "vitest --passWithNoTests",
|
|
59
57
|
"build": "tsdown",
|
|
60
58
|
"dev": "tsdown --watch",
|
|
61
59
|
"lint": "biome check .",
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const require_bridge_name_enum = require('../constants/bridge-name-enum.cjs');
|
|
2
|
-
const require_route_config_factory = require('./route-config-factory.cjs');
|
|
3
|
-
|
|
4
|
-
//#region src/lib/route-config.ts
|
|
5
|
-
function determineRouteConfig(sdk, withdrawalParams) {
|
|
6
|
-
if (withdrawalParams.routeConfig != null) return withdrawalParams.routeConfig;
|
|
7
|
-
const parseAssetId = sdk.parseAssetId(withdrawalParams.assetId);
|
|
8
|
-
const bridgeName = parseAssetId.bridgeName;
|
|
9
|
-
switch (bridgeName) {
|
|
10
|
-
case require_bridge_name_enum.BridgeNameEnum.Hot: return require_route_config_factory.createHotBridgeRoute(parseAssetId.blockchain);
|
|
11
|
-
case require_bridge_name_enum.BridgeNameEnum.Poa: return require_route_config_factory.createPoaBridgeRoute(parseAssetId.blockchain);
|
|
12
|
-
case require_bridge_name_enum.BridgeNameEnum.Omni: return require_route_config_factory.createOmniBridgeRoute(parseAssetId.blockchain);
|
|
13
|
-
case require_bridge_name_enum.BridgeNameEnum.None: return require_route_config_factory.createNearWithdrawalRoute();
|
|
14
|
-
default: throw new Error(`Unexpected bridge = ${bridgeName}`);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
exports.determineRouteConfig = determineRouteConfig;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { BridgeNameEnum } from "../constants/bridge-name-enum.js";
|
|
2
|
-
import { createHotBridgeRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute } from "./route-config-factory.js";
|
|
3
|
-
|
|
4
|
-
//#region src/lib/route-config.ts
|
|
5
|
-
function determineRouteConfig(sdk, withdrawalParams) {
|
|
6
|
-
if (withdrawalParams.routeConfig != null) return withdrawalParams.routeConfig;
|
|
7
|
-
const parseAssetId = sdk.parseAssetId(withdrawalParams.assetId);
|
|
8
|
-
const bridgeName = parseAssetId.bridgeName;
|
|
9
|
-
switch (bridgeName) {
|
|
10
|
-
case BridgeNameEnum.Hot: return createHotBridgeRoute(parseAssetId.blockchain);
|
|
11
|
-
case BridgeNameEnum.Poa: return createPoaBridgeRoute(parseAssetId.blockchain);
|
|
12
|
-
case BridgeNameEnum.Omni: return createOmniBridgeRoute(parseAssetId.blockchain);
|
|
13
|
-
case BridgeNameEnum.None: return createNearWithdrawalRoute();
|
|
14
|
-
default: throw new Error(`Unexpected bridge = ${bridgeName}`);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
export { determineRouteConfig };
|