@lifi/sdk 4.10.0 → 4.12.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/CHANGELOG.md +39 -0
- package/README.md +9 -0
- package/dist/cjs/client/createClient.js +6 -4
- package/dist/cjs/client/createClient.js.map +1 -1
- package/dist/cjs/client/findProvider.d.ts +10 -0
- package/dist/cjs/client/findProvider.js +11 -0
- package/dist/cjs/client/findProvider.js.map +1 -0
- package/dist/cjs/core/BaseStepExecutor.d.ts +1 -1
- package/dist/cjs/core/BaseStepExecutor.js +21 -9
- package/dist/cjs/core/BaseStepExecutor.js.map +1 -1
- package/dist/cjs/core/StatusManager.d.ts +10 -0
- package/dist/cjs/core/StatusManager.js +107 -3
- package/dist/cjs/core/StatusManager.js.map +1 -1
- package/dist/cjs/core/execution.js +30 -14
- package/dist/cjs/core/execution.js.map +1 -1
- package/dist/cjs/core/executionState.d.ts +34 -2
- package/dist/cjs/core/executionState.js +44 -1
- package/dist/cjs/core/executionState.js.map +1 -1
- package/dist/cjs/core/prepareRestart.js +14 -6
- package/dist/cjs/core/prepareRestart.js.map +1 -1
- package/dist/cjs/core/tasks/WaitForTransactionStatusTask.js +4 -2
- package/dist/cjs/core/tasks/WaitForTransactionStatusTask.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/getStepStatusRequest.d.ts +10 -0
- package/dist/cjs/core/tasks/helpers/getStepStatusRequest.js +20 -0
- package/dist/cjs/core/tasks/helpers/getStepStatusRequest.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/isKnownToStatusApi.d.ts +21 -0
- package/dist/cjs/core/tasks/helpers/isKnownToStatusApi.js +44 -0
- package/dist/cjs/core/tasks/helpers/isKnownToStatusApi.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/waitForTransactionStatus.d.ts +22 -1
- package/dist/cjs/core/tasks/helpers/waitForTransactionStatus.js +76 -17
- package/dist/cjs/core/tasks/helpers/waitForTransactionStatus.js.map +1 -1
- package/dist/cjs/core/transactionState.d.ts +123 -0
- package/dist/cjs/core/transactionState.js +167 -0
- package/dist/cjs/core/transactionState.js.map +1 -0
- package/dist/cjs/errors/constants.d.ts +2 -1
- package/dist/cjs/errors/constants.js +1 -0
- package/dist/cjs/errors/constants.js.map +1 -1
- package/dist/cjs/errors/errors.d.ts +13 -2
- package/dist/cjs/errors/errors.js +5 -2
- package/dist/cjs/errors/errors.js.map +1 -1
- package/dist/cjs/index.d.ts +5 -2
- package/dist/cjs/index.js +14 -0
- package/dist/cjs/types/core.d.ts +56 -3
- package/dist/cjs/types/execution.d.ts +8 -0
- package/dist/cjs/utils/checkPackageUpdates.js +1 -1
- package/dist/cjs/utils/waitForResult.d.ts +3 -1
- package/dist/cjs/utils/waitForResult.js +15 -10
- package/dist/cjs/utils/waitForResult.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/actions/getRoutes.d.ts.map +1 -1
- package/dist/esm/actions/index.d.ts.map +1 -1
- package/dist/esm/client/createClient.d.ts.map +1 -1
- package/dist/esm/client/createClient.js +6 -4
- package/dist/esm/client/createClient.js.map +1 -1
- package/dist/esm/client/findProvider.d.ts +10 -0
- package/dist/esm/client/findProvider.d.ts.map +1 -0
- package/dist/esm/client/findProvider.js +10 -0
- package/dist/esm/client/findProvider.js.map +1 -0
- package/dist/esm/core/BaseStepExecutor.d.ts +1 -1
- package/dist/esm/core/BaseStepExecutor.d.ts.map +1 -1
- package/dist/esm/core/BaseStepExecutor.js +22 -10
- package/dist/esm/core/BaseStepExecutor.js.map +1 -1
- package/dist/esm/core/StatusManager.d.ts +10 -0
- package/dist/esm/core/StatusManager.d.ts.map +1 -1
- package/dist/esm/core/StatusManager.js +107 -3
- package/dist/esm/core/StatusManager.js.map +1 -1
- package/dist/esm/core/execution.d.ts.map +1 -1
- package/dist/esm/core/execution.js +30 -14
- package/dist/esm/core/execution.js.map +1 -1
- package/dist/esm/core/executionState.d.ts +34 -2
- package/dist/esm/core/executionState.d.ts.map +1 -1
- package/dist/esm/core/executionState.js +44 -1
- package/dist/esm/core/executionState.js.map +1 -1
- package/dist/esm/core/prepareRestart.d.ts.map +1 -1
- package/dist/esm/core/prepareRestart.js +14 -6
- package/dist/esm/core/prepareRestart.js.map +1 -1
- package/dist/esm/core/tasks/WaitForTransactionStatusTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/WaitForTransactionStatusTask.js +4 -2
- package/dist/esm/core/tasks/WaitForTransactionStatusTask.js.map +1 -1
- package/dist/esm/core/tasks/helpers/getStepStatusRequest.d.ts +10 -0
- package/dist/esm/core/tasks/helpers/getStepStatusRequest.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/getStepStatusRequest.js +19 -0
- package/dist/esm/core/tasks/helpers/getStepStatusRequest.js.map +1 -0
- package/dist/esm/core/tasks/helpers/isKnownToStatusApi.d.ts +21 -0
- package/dist/esm/core/tasks/helpers/isKnownToStatusApi.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/isKnownToStatusApi.js +43 -0
- package/dist/esm/core/tasks/helpers/isKnownToStatusApi.js.map +1 -0
- package/dist/esm/core/tasks/helpers/waitForTransactionStatus.d.ts +22 -1
- package/dist/esm/core/tasks/helpers/waitForTransactionStatus.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/waitForTransactionStatus.js +76 -18
- package/dist/esm/core/tasks/helpers/waitForTransactionStatus.js.map +1 -1
- package/dist/esm/core/transactionState.d.ts +123 -0
- package/dist/esm/core/transactionState.d.ts.map +1 -0
- package/dist/esm/core/transactionState.js +155 -0
- package/dist/esm/core/transactionState.js.map +1 -0
- package/dist/esm/errors/constants.d.ts +2 -1
- package/dist/esm/errors/constants.d.ts.map +1 -1
- package/dist/esm/errors/constants.js +1 -0
- package/dist/esm/errors/constants.js.map +1 -1
- package/dist/esm/errors/errors.d.ts +13 -2
- package/dist/esm/errors/errors.d.ts.map +1 -1
- package/dist/esm/errors/errors.js +5 -2
- package/dist/esm/errors/errors.js.map +1 -1
- package/dist/esm/index.d.ts +5 -2
- package/dist/esm/index.js +4 -1
- package/dist/esm/types/actions.d.ts.map +1 -1
- package/dist/esm/types/core.d.ts +56 -3
- package/dist/esm/types/core.d.ts.map +1 -1
- package/dist/esm/types/execution.d.ts +8 -0
- package/dist/esm/types/execution.d.ts.map +1 -1
- package/dist/esm/utils/checkPackageUpdates.js +1 -1
- package/dist/esm/utils/waitForResult.d.ts +3 -1
- package/dist/esm/utils/waitForResult.d.ts.map +1 -1
- package/dist/esm/utils/waitForResult.js +15 -10
- package/dist/esm/utils/waitForResult.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/package.json +2 -2
- package/src/client/createClient.ts +12 -4
- package/src/client/findProvider.ts +21 -0
- package/src/core/BaseStepExecutor.ts +40 -6
- package/src/core/StatusManager.ts +214 -2
- package/src/core/execution.ts +69 -20
- package/src/core/executionState.ts +84 -1
- package/src/core/prepareRestart.ts +29 -13
- package/src/core/tasks/WaitForTransactionStatusTask.ts +10 -1
- package/src/core/tasks/helpers/getStepStatusRequest.ts +20 -0
- package/src/core/tasks/helpers/isKnownToStatusApi.ts +57 -0
- package/src/core/tasks/helpers/waitForTransactionStatus.ts +128 -17
- package/src/core/transactionState.ts +200 -0
- package/src/errors/constants.ts +1 -0
- package/src/errors/errors.ts +21 -2
- package/src/index.ts +14 -0
- package/src/types/core.ts +57 -3
- package/src/types/execution.ts +8 -0
- package/src/utils/waitForResult.ts +16 -6
- package/src/version.ts +1 -1
|
@@ -5,7 +5,7 @@ const checkPackageUpdates = async (packageName, packageVersion) => {
|
|
|
5
5
|
try {
|
|
6
6
|
const pkgName = packageName ?? "@lifi/sdk";
|
|
7
7
|
const latestVersion = (await (await fetch(`https://registry.npmjs.org/${pkgName}/latest`)).json()).version;
|
|
8
|
-
const currentVersion = packageVersion ?? "4.
|
|
8
|
+
const currentVersion = packageVersion ?? "4.12.0";
|
|
9
9
|
if (latestVersion > currentVersion) console.warn(`${pkgName}: new package version is available. Please update as soon as possible to enjoy the newest features. Current version: ${currentVersion}. Latest version: ${latestVersion}.`);
|
|
10
10
|
} catch (_error) {}
|
|
11
11
|
};
|
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
* @param interval The timeout in milliseconds between retries, or a function that receives the current poll count and returns the interval. Defaults to 5000
|
|
6
6
|
* @param maxRetries Maximum number of calls that throw before the error is rethrown, defaults to 3
|
|
7
7
|
* @param shouldRetry Optional predicate to determine if an error should trigger a retry
|
|
8
|
+
* @param signal Optional signal that ends the wait: no call starts after it aborts, and the sleep between calls ends at once
|
|
8
9
|
* @returns The result of the fn function
|
|
9
10
|
* @throws The error of fn if maximum retries is reached, or if shouldRetry returns false
|
|
11
|
+
* @throws The abort reason of `signal` once it aborts
|
|
10
12
|
*/
|
|
11
|
-
export declare const waitForResult: <T>(fn: () => Promise<T | undefined>, interval?: number | ((poll: number) => number), maxRetries?: number, shouldRetry?: (count: number, error: unknown) => boolean) => Promise<T>;
|
|
13
|
+
export declare const waitForResult: <T>(fn: () => Promise<T | undefined>, interval?: number | ((poll: number) => number), maxRetries?: number, shouldRetry?: (count: number, error: unknown) => boolean, signal?: AbortSignal) => Promise<T>;
|
|
12
14
|
//#endregion
|
|
13
15
|
//# sourceMappingURL=waitForResult.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_utils_abort = require("./abort.js");
|
|
2
3
|
const require_utils_sleep = require("./sleep.js");
|
|
3
4
|
//#region src/utils/waitForResult.ts
|
|
4
5
|
/**
|
|
@@ -7,26 +8,30 @@ const require_utils_sleep = require("./sleep.js");
|
|
|
7
8
|
* @param interval The timeout in milliseconds between retries, or a function that receives the current poll count and returns the interval. Defaults to 5000
|
|
8
9
|
* @param maxRetries Maximum number of calls that throw before the error is rethrown, defaults to 3
|
|
9
10
|
* @param shouldRetry Optional predicate to determine if an error should trigger a retry
|
|
11
|
+
* @param signal Optional signal that ends the wait: no call starts after it aborts, and the sleep between calls ends at once
|
|
10
12
|
* @returns The result of the fn function
|
|
11
13
|
* @throws The error of fn if maximum retries is reached, or if shouldRetry returns false
|
|
14
|
+
* @throws The abort reason of `signal` once it aborts
|
|
12
15
|
*/
|
|
13
|
-
const waitForResult = async (fn, interval = 5e3, maxRetries = 3, shouldRetry = () => true) => {
|
|
16
|
+
const waitForResult = async (fn, interval = 5e3, maxRetries = 3, shouldRetry = () => true, signal) => {
|
|
14
17
|
let result;
|
|
15
18
|
let attempts = 0;
|
|
16
19
|
let polls = 0;
|
|
17
20
|
const getInterval = typeof interval === "function" ? interval : () => interval;
|
|
18
|
-
while (!result)
|
|
19
|
-
|
|
21
|
+
while (!result) {
|
|
22
|
+
if (signal?.aborted) throw require_utils_abort.getAbortError(signal);
|
|
23
|
+
try {
|
|
24
|
+
result = await fn();
|
|
25
|
+
} catch (error) {
|
|
26
|
+
if (signal?.aborted) throw require_utils_abort.getAbortError(signal);
|
|
27
|
+
if (!shouldRetry(attempts, error)) throw error;
|
|
28
|
+
attempts++;
|
|
29
|
+
if (attempts === maxRetries) throw error;
|
|
30
|
+
}
|
|
20
31
|
if (!result) {
|
|
21
|
-
await require_utils_sleep.sleep(getInterval(polls));
|
|
32
|
+
await require_utils_sleep.sleep(getInterval(polls), { signal });
|
|
22
33
|
polls++;
|
|
23
34
|
}
|
|
24
|
-
} catch (error) {
|
|
25
|
-
if (!shouldRetry(attempts, error)) throw error;
|
|
26
|
-
attempts++;
|
|
27
|
-
if (attempts === maxRetries) throw error;
|
|
28
|
-
await require_utils_sleep.sleep(getInterval(polls));
|
|
29
|
-
polls++;
|
|
30
35
|
}
|
|
31
36
|
return result;
|
|
32
37
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waitForResult.js","names":["sleep"],"sources":["../../../src/utils/waitForResult.ts"],"sourcesContent":["import { sleep } from './sleep.js'\n\n/**\n * Repeatedly calls a given asynchronous function until it resolves with a truthy value\n * @param fn The function that should be repeated. A falsy result means \"no result yet\" and polls again, with no limit on the number of polls\n * @param interval The timeout in milliseconds between retries, or a function that receives the current poll count and returns the interval. Defaults to 5000\n * @param maxRetries Maximum number of calls that throw before the error is rethrown, defaults to 3\n * @param shouldRetry Optional predicate to determine if an error should trigger a retry\n * @returns The result of the fn function\n * @throws The error of fn if maximum retries is reached, or if shouldRetry returns false\n */\nexport const waitForResult = async <T>(\n fn: () => Promise<T | undefined>,\n interval: number | ((poll: number) => number) = 5000,\n maxRetries = 3,\n shouldRetry: (count: number, error: unknown) => boolean = () => true\n): Promise<T> => {\n let result: T | undefined\n let attempts = 0\n let polls = 0\n\n const getInterval = typeof interval === 'function' ? interval : () => interval\n\n while (!result) {\n try {\n result = await fn()\n if (
|
|
1
|
+
{"version":3,"file":"waitForResult.js","names":["getAbortError","sleep"],"sources":["../../../src/utils/waitForResult.ts"],"sourcesContent":["import { getAbortError } from './abort.js'\nimport { sleep } from './sleep.js'\n\n/**\n * Repeatedly calls a given asynchronous function until it resolves with a truthy value\n * @param fn The function that should be repeated. A falsy result means \"no result yet\" and polls again, with no limit on the number of polls\n * @param interval The timeout in milliseconds between retries, or a function that receives the current poll count and returns the interval. Defaults to 5000\n * @param maxRetries Maximum number of calls that throw before the error is rethrown, defaults to 3\n * @param shouldRetry Optional predicate to determine if an error should trigger a retry\n * @param signal Optional signal that ends the wait: no call starts after it aborts, and the sleep between calls ends at once\n * @returns The result of the fn function\n * @throws The error of fn if maximum retries is reached, or if shouldRetry returns false\n * @throws The abort reason of `signal` once it aborts\n */\nexport const waitForResult = async <T>(\n fn: () => Promise<T | undefined>,\n interval: number | ((poll: number) => number) = 5000,\n maxRetries = 3,\n shouldRetry: (count: number, error: unknown) => boolean = () => true,\n signal?: AbortSignal\n): Promise<T> => {\n let result: T | undefined\n let attempts = 0\n let polls = 0\n\n const getInterval = typeof interval === 'function' ? interval : () => interval\n\n while (!result) {\n if (signal?.aborted) {\n throw getAbortError(signal)\n }\n try {\n result = await fn()\n } catch (error) {\n // An error of a call that the abort cut short is not a reason to retry.\n if (signal?.aborted) {\n throw getAbortError(signal)\n }\n if (!shouldRetry(attempts, error)) {\n throw error\n }\n attempts++\n if (attempts === maxRetries) {\n throw error\n }\n }\n if (!result) {\n // Rejects at once, also when the signal aborted during the call.\n await sleep(getInterval(polls), { signal })\n polls++\n }\n }\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;AAcA,MAAa,gBAAgB,OAC3B,IACA,WAAgD,KAChD,aAAa,GACb,oBAAgE,MAChE,WACe;CACf,IAAI;CACJ,IAAI,WAAW;CACf,IAAI,QAAQ;CAEZ,MAAM,cAAc,OAAO,aAAa,aAAa,iBAAiB;CAEtE,OAAO,CAAC,QAAQ;EACd,IAAI,QAAQ,SACV,MAAMA,oBAAAA,cAAc,MAAM;EAE5B,IAAI;GACF,SAAS,MAAM,GAAG;EACpB,SAAS,OAAO;GAEd,IAAI,QAAQ,SACV,MAAMA,oBAAAA,cAAc,MAAM;GAE5B,IAAI,CAAC,YAAY,UAAU,KAAK,GAC9B,MAAM;GAER;GACA,IAAI,aAAa,YACf,MAAM;EAEV;EACA,IAAI,CAAC,QAAQ;GAEX,MAAMC,oBAAAA,MAAM,YAAY,KAAK,GAAG,EAAE,OAAO,CAAC;GAC1C;EACF;CACF;CAEA,OAAO;AACT"}
|
package/dist/cjs/version.d.ts
CHANGED
package/dist/cjs/version.js
CHANGED
package/dist/cjs/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk'\nexport const version = '4.
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk'\nexport const version = '4.12.0'\n"],"mappings":";;AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRoutes.d.ts","names":[],"sources":["../../../src/actions/getRoutes.ts"],"mappings":";;;;;;;;;;;;qBAgBa,YACX,QAAQ,WACR,
|
|
1
|
+
{"version":3,"file":"getRoutes.d.ts","names":["RoutesRequest"],"sources":["../../../src/actions/getRoutes.ts"],"mappings":";;;;;;;;;;;;qBAgBa,YACX,QAAQ,WACR,QAAQA,iBACR,UAAU,mBACT,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/actions/index.ts"],"mappings":";;;;;;YA8DY;;;;;;;EAOV,YACE,SAAS,eACT,UAAU,mBACP,QAAQ;;;;;;;EAQb,iBACE,QAAQ,oBACR,UAAU,mBACP,QAAQ;;;;;;;EAQb,wBACE,QAAQ,2BACR,UAAU,mBACP,QAAQ;;;;;;;EAQb,uBACE,QAAQ,0BACR,UAAU,mBACP,QAAQ;;;;;;;EAQb,wBACE,cACA,YAAY,cACT;;;;;;;EAQL,WACE,QAAQ,kBAAkB,cAC1B,UAAU,mBACP,QAAQ;;;;;;;EAQb,8BACE,QAAQ,oBACR,UAAU,mBACP,QAAQ;;;;;;;EAQb,kBACE,QAAQ,wBACR,UAAU,mBACP,QAAQ;;;;;;;;;EAUb,YACE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["RoutesRequest"],"sources":["../../../src/actions/index.ts"],"mappings":";;;;;;YA8DY;;;;;;;EAOV,YACE,SAAS,eACT,UAAU,mBACP,QAAQ;;;;;;;EAQb,iBACE,QAAQ,oBACR,UAAU,mBACP,QAAQ;;;;;;;EAQb,wBACE,QAAQ,2BACR,UAAU,mBACP,QAAQ;;;;;;;EAQb,uBACE,QAAQ,0BACR,UAAU,mBACP,QAAQ;;;;;;;EAQb,wBACE,cACA,YAAY,cACT;;;;;;;EAQL,WACE,QAAQ,kBAAkB,cAC1B,UAAU,mBACP,QAAQ;;;;;;;EAQb,8BACE,QAAQ,oBACR,UAAU,mBACP,QAAQ;;;;;;;EAQb,kBACE,QAAQ,wBACR,UAAU,mBACP,QAAQ;;;;;;;;;EAUb,YACE,QAAQA,iBACR,UAAU,mBACP,QAAQ;;;;;;;EAQb,YACE,QAAQ,0BACR,UAAU,mBACP,QAAQ;;;;;;;;EASb,qBACE,QAAQ,iBACR,UAAU,mBACP,QAAQ;;;;;;;;EASb,WACE,OAAO,WAAW,SAClB,eACA,UAAU,mBACP,QAAQ;;;;;;;EAQb,kBACE,uBACA,OAAO,UACJ,QAAQ;;;;;;;EAQb,mBACE,uBACA,QAAQ,YACL,QAAQ;;;;;;;EAQb,0BACE,uBACA;KAAoC,kBAAA;QACjC;KACgB,kBAAA;;;;;;;;EASrB;KAEI,SAAS;MAAkB;OAC3B,UAAU,iBACT,QAAQ;KAET,QAAQ;MAAkB;OAC1B,UAAU,iBACT,QAAQ;;;;;;;;EASb,WACE,SAAS,cACT,UAAU,mBACP,QAAQ;;;;;;;EAQb,wBACE,QAAQ,6BACR,UAAU,mBACP,QAAQ;;;;;;;EAQb,mBACE,QAAQ,cACR,UAAU,mBACP,QAAQ;;;;;;;EAQb,qBACE,QAAQ,sBACR,UAAU,mBACP,QAAQ;;wBAGC,QAAQ,QAAQ,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClient.d.ts","names":[],"sources":["../../../src/client/createClient.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"createClient.d.ts","names":[],"sources":["../../../src/client/createClient.ts"],"mappings":";;wBAoBgB,aAAa,SAAS,YAAY"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { name, version } from "../version.js";
|
|
2
2
|
import { checkPackageUpdates } from "../utils/checkPackageUpdates.js";
|
|
3
|
+
import { findProvider } from "./findProvider.js";
|
|
3
4
|
import { getClientStorage } from "./getClientStorage.js";
|
|
4
5
|
//#region src/client/createClient.ts
|
|
6
|
+
const providerScope = (provider) => provider.chainIds ? `${provider.type}:${[...provider.chainIds].sort().join(",")}` : provider.type;
|
|
5
7
|
function createClient(options) {
|
|
6
8
|
if (!options.integrator) throw new Error("Integrator not found. Please see documentation https://docs.li.fi/integrate-li.fi-js-sdk/set-up-the-sdk");
|
|
7
9
|
if (!options.disableVersionCheck && process.env.NODE_ENV === "development") checkPackageUpdates(name, version);
|
|
@@ -38,12 +40,12 @@ function createClient(options) {
|
|
|
38
40
|
get providers() {
|
|
39
41
|
return _providers;
|
|
40
42
|
},
|
|
41
|
-
getProvider(type) {
|
|
42
|
-
return this.providers
|
|
43
|
+
getProvider(type, chainId) {
|
|
44
|
+
return findProvider(this.providers, type, chainId);
|
|
43
45
|
},
|
|
44
46
|
setProviders(newProviders) {
|
|
45
|
-
const providerMap = new Map(this.providers.map((provider) => [provider
|
|
46
|
-
for (const provider of newProviders) providerMap.set(provider
|
|
47
|
+
const providerMap = new Map(this.providers.map((provider) => [providerScope(provider), provider]));
|
|
48
|
+
for (const provider of newProviders) providerMap.set(providerScope(provider), provider);
|
|
47
49
|
_providers = Array.from(providerMap.values());
|
|
48
50
|
},
|
|
49
51
|
setChains(chains) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClient.js","names":[],"sources":["../../../src/client/createClient.ts"],"sourcesContent":["import type { ChainId, ChainType, ExtendedChain } from '@lifi/types'\nimport type {\n RPCUrls,\n SDKBaseConfig,\n SDKClient,\n SDKConfig,\n SDKProvider,\n} from '../types/core.js'\nimport { checkPackageUpdates } from '../utils/checkPackageUpdates.js'\nimport { name, version } from '../version.js'\nimport { getClientStorage } from './getClientStorage.js'\n\nexport function createClient(options: SDKConfig): SDKClient {\n if (!options.integrator) {\n throw new Error(\n 'Integrator not found. Please see documentation https://docs.li.fi/integrate-li.fi-js-sdk/set-up-the-sdk'\n )\n }\n\n if (!options.disableVersionCheck && process.env.NODE_ENV === 'development') {\n checkPackageUpdates(name, version)\n }\n\n const { providers, rpcUrls, ...configOptions } = options\n\n // Role entries split once, here: the config keeps plain read lists, so\n // everything that reads `config.rpcUrls` sees `string[]` as before.\n const readRpcUrls: RPCUrls = {}\n const writeRpcUrls: RPCUrls = {}\n const bundleRpcUrls: RPCUrls = {}\n let hasRoles = false\n for (const key in rpcUrls) {\n const chainId = Number(key) as ChainId\n const entry = rpcUrls[chainId]\n if (Array.isArray(entry)) {\n readRpcUrls[chainId] = entry\n } else if (entry) {\n hasRoles = true\n if (entry.read) {\n readRpcUrls[chainId] = entry.read\n }\n if (entry.write?.length) {\n writeRpcUrls[chainId] = entry.write\n }\n if (entry.bundle?.length) {\n bundleRpcUrls[chainId] = entry.bundle\n }\n }\n }\n\n const _config: SDKBaseConfig = {\n ...configOptions,\n apiUrl: configOptions?.apiUrl ?? 'https://li.quest/v1',\n // Plain lists only: the caller's own object, exactly as before.\n rpcUrls: hasRoles ? readRpcUrls : ((rpcUrls ?? {}) as RPCUrls),\n debug: configOptions?.debug ?? false,\n preloadChains: configOptions?.preloadChains ?? true,\n integrator: configOptions?.integrator ?? 'lifi-sdk',\n }\n\n let _providers: SDKProvider[] = providers ?? []\n const _storage = getClientStorage(_config)\n\n const client: SDKClient = {\n get config() {\n return _config\n },\n get providers() {\n return _providers\n },\n getProvider(type: ChainType) {\n return this.providers
|
|
1
|
+
{"version":3,"file":"createClient.js","names":[],"sources":["../../../src/client/createClient.ts"],"sourcesContent":["import type { ChainId, ChainType, ExtendedChain } from '@lifi/types'\nimport type {\n RPCUrls,\n SDKBaseConfig,\n SDKClient,\n SDKConfig,\n SDKProvider,\n} from '../types/core.js'\nimport { checkPackageUpdates } from '../utils/checkPackageUpdates.js'\nimport { name, version } from '../version.js'\nimport { findProvider } from './findProvider.js'\nimport { getClientStorage } from './getClientStorage.js'\n\n// A provider replaces only one that serves the same chains. A provider that\n// lists no chains keeps the bare type, so even an empty list stays apart.\nconst providerScope = (provider: SDKProvider): string =>\n provider.chainIds\n ? `${provider.type}:${[...provider.chainIds].sort().join(',')}`\n : provider.type\n\nexport function createClient(options: SDKConfig): SDKClient {\n if (!options.integrator) {\n throw new Error(\n 'Integrator not found. Please see documentation https://docs.li.fi/integrate-li.fi-js-sdk/set-up-the-sdk'\n )\n }\n\n if (!options.disableVersionCheck && process.env.NODE_ENV === 'development') {\n checkPackageUpdates(name, version)\n }\n\n const { providers, rpcUrls, ...configOptions } = options\n\n // Role entries split once, here: the config keeps plain read lists, so\n // everything that reads `config.rpcUrls` sees `string[]` as before.\n const readRpcUrls: RPCUrls = {}\n const writeRpcUrls: RPCUrls = {}\n const bundleRpcUrls: RPCUrls = {}\n let hasRoles = false\n for (const key in rpcUrls) {\n const chainId = Number(key) as ChainId\n const entry = rpcUrls[chainId]\n if (Array.isArray(entry)) {\n readRpcUrls[chainId] = entry\n } else if (entry) {\n hasRoles = true\n if (entry.read) {\n readRpcUrls[chainId] = entry.read\n }\n if (entry.write?.length) {\n writeRpcUrls[chainId] = entry.write\n }\n if (entry.bundle?.length) {\n bundleRpcUrls[chainId] = entry.bundle\n }\n }\n }\n\n const _config: SDKBaseConfig = {\n ...configOptions,\n apiUrl: configOptions?.apiUrl ?? 'https://li.quest/v1',\n // Plain lists only: the caller's own object, exactly as before.\n rpcUrls: hasRoles ? readRpcUrls : ((rpcUrls ?? {}) as RPCUrls),\n debug: configOptions?.debug ?? false,\n preloadChains: configOptions?.preloadChains ?? true,\n integrator: configOptions?.integrator ?? 'lifi-sdk',\n }\n\n let _providers: SDKProvider[] = providers ?? []\n const _storage = getClientStorage(_config)\n\n const client: SDKClient = {\n get config() {\n return _config\n },\n get providers() {\n return _providers\n },\n getProvider(type: ChainType, chainId?: ChainId) {\n return findProvider(this.providers, type, chainId)\n },\n setProviders(newProviders: SDKProvider[]) {\n const providerMap = new Map(\n this.providers.map((provider) => [providerScope(provider), provider])\n )\n for (const provider of newProviders) {\n providerMap.set(providerScope(provider), provider)\n }\n _providers = Array.from(providerMap.values())\n },\n setChains(chains: ExtendedChain[]) {\n _storage.setChains(chains)\n },\n async getChains() {\n return await _storage.getChains()\n },\n async getChainById(chainId: ChainId) {\n const chains = await this.getChains()\n const chain = chains?.find((chain) => chain.id === chainId)\n if (!chain) {\n throw new Error(`ChainId ${chainId} not found`)\n }\n return chain\n },\n async getRpcUrls() {\n return await _storage.getRpcUrls()\n },\n async getRpcUrlsByChainId(chainId: ChainId) {\n const rpcUrls = await this.getRpcUrls()\n const chainRpcUrls = rpcUrls[chainId]\n if (!chainRpcUrls?.length) {\n throw new Error(`RPC URL not found for chainId: ${chainId}`)\n }\n return chainRpcUrls\n },\n async getWriteRpcUrlsByChainId(chainId: ChainId) {\n return writeRpcUrls[chainId] ?? []\n },\n async getBundleRpcUrlsByChainId(chainId: ChainId) {\n return bundleRpcUrls[chainId] ?? []\n },\n }\n\n function extend<TClient extends SDKClient>(\n base: TClient\n ): <TExtensions extends Record<string, any>>(\n extendFn: (client: TClient) => TExtensions\n ) => TClient & TExtensions {\n return (extendFn) => {\n const extensions = extendFn(base)\n // Copy descriptors rather than spreading. `config` and `providers` are\n // accessors over closure variables, and `setProviders` reassigns\n // `_providers` — so a spread would freeze the extension on the values\n // those getters happened to return at extend time, leaving it with a\n // provider list that never updates.\n const extended = Object.defineProperties(\n {},\n {\n ...Object.getOwnPropertyDescriptors(base),\n ...Object.getOwnPropertyDescriptors(extensions),\n }\n ) as TClient & typeof extensions\n\n // Preserve the extend function for further extensions\n return Object.assign(extended, {\n extend: extend(extended),\n })\n }\n }\n\n return Object.assign(client, { extend: extend(client) })\n}\n"],"mappings":";;;;;AAeA,MAAM,iBAAiB,aACrB,SAAS,WACL,GAAG,SAAS,KAAK,GAAG,CAAC,GAAG,SAAS,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,MAC1D,SAAS;AAEf,SAAgB,aAAa,SAA+B;CAC1D,IAAI,CAAC,QAAQ,YACX,MAAM,IAAI,MACR,yGACF;CAGF,IAAI,CAAC,QAAQ,uBAAuB,QAAQ,IAAI,aAAa,eAC3D,oBAAoB,MAAM,OAAO;CAGnC,MAAM,EA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MADO,KAAK,UAAU,EAAA,EACd,MAAM,UAAU,MAAM,OAAO,OAAO;GAC1D,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,WAAW,QAAQ,WAAW;GAEhD,OAAO;EACT;EACA,MAAM,aAAa;GACjB,OAAO,MAAM,SAAS,WAAW;EACnC;EACA,MAAM,oBAAoB,SAAkB;GAE1C,MAAM,gBAAe,MADC,KAAK,WAAW,EAAA,CACT;GAC7B,IAAI,CAAC,cAAc,QACjB,MAAM,IAAI,MAAM,kCAAkC,SAAS;GAE7D,OAAO;EACT;EACA,MAAM,yBAAyB,SAAkB;GAC/C,OAAO,aAAa,YAAY,CAAC;EACnC;EACA,MAAM,0BAA0B,SAAkB;GAChD,OAAO,cAAc,YAAY,CAAC;EACpC;CACF;CAEA,SAAS,OACP,MAGyB;EACzB,QAAQ,aAAa;GACnB,MAAM,aAAa,SAAS,IAAI;GAMhC,MAAM,WAAW,OAAO,iBACtB,CAAC,GACD;IACE,GAAG,OAAO,0BAA0B,IAAI;IACxC,GAAG,OAAO,0BAA0B,UAAU;GAChD,CACF;GAGA,OAAO,OAAO,OAAO,UAAU,EAC7B,QAAQ,OAAO,QAAQ,EACzB,CAAC;EACH;CACF;CAEA,OAAO,OAAO,OAAO,QAAQ,EAAE,QAAQ,OAAO,MAAM,EAAE,CAAC;AACzD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SDKProvider } from "../types/core.js";
|
|
2
|
+
import { ChainId, ChainType } from "@lifi/types";
|
|
3
|
+
//#region src/client/findProvider.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The provider that serves a chain: the one that lists `chainId` in its
|
|
6
|
+
* `chainIds`, otherwise the provider of `chainType` that lists no chains.
|
|
7
|
+
*/
|
|
8
|
+
export declare const findProvider: <T extends Pick<SDKProvider, "type" | "chainIds">>(providers: readonly T[], chainType: ChainType, chainId?: ChainId) => T | undefined;
|
|
9
|
+
//#endregion
|
|
10
|
+
//# sourceMappingURL=findProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findProvider.d.ts","names":[],"sources":["../../../src/client/findProvider.ts"],"mappings":";;;;;;;qBAOa,eAAgB,UAAU,KAAK,mCAC1C,oBAAoB,KACpB,WAAW,WACX,UAAU,YACT"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/client/findProvider.ts
|
|
2
|
+
/**
|
|
3
|
+
* The provider that serves a chain: the one that lists `chainId` in its
|
|
4
|
+
* `chainIds`, otherwise the provider of `chainType` that lists no chains.
|
|
5
|
+
*/
|
|
6
|
+
const findProvider = (providers, chainType, chainId) => (chainId === void 0 ? void 0 : providers.find((provider) => provider.type === chainType && provider.chainIds?.includes(chainId))) ?? providers.find((provider) => provider.type === chainType && !provider.chainIds);
|
|
7
|
+
//#endregion
|
|
8
|
+
export { findProvider };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=findProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findProvider.js","names":[],"sources":["../../../src/client/findProvider.ts"],"sourcesContent":["import type { ChainId, ChainType } from '@lifi/types'\nimport type { SDKProvider } from '../types/core.js'\n\n/**\n * The provider that serves a chain: the one that lists `chainId` in its\n * `chainIds`, otherwise the provider of `chainType` that lists no chains.\n */\nexport const findProvider = <T extends Pick<SDKProvider, 'type' | 'chainIds'>>(\n providers: readonly T[],\n chainType: ChainType,\n chainId?: ChainId\n): T | undefined =>\n (chainId === undefined\n ? undefined\n : providers.find(\n (provider) =>\n provider.type === chainType && provider.chainIds?.includes(chainId)\n )) ??\n providers.find(\n (provider) => provider.type === chainType && !provider.chainIds\n )\n"],"mappings":";;;;;AAOA,MAAa,gBACX,WACA,WACA,aAEC,YAAY,KAAA,IACT,KAAA,IACA,UAAU,MACP,aACC,SAAS,SAAS,aAAa,SAAS,UAAU,SAAS,OAAO,CACtE,MACJ,UAAU,MACP,aAAa,SAAS,SAAS,aAAa,CAAC,SAAS,QACzD"}
|
|
@@ -16,7 +16,7 @@ export declare abstract class BaseStepExecutor implements StepExecutor {
|
|
|
16
16
|
abstract createContext(baseContext: StepExecutorBaseContext): Promise<StepExecutorContext>;
|
|
17
17
|
abstract createPipeline(context: StepExecutorContext): TaskPipeline;
|
|
18
18
|
abstract parseErrors(error: Error, step?: LiFiStepExtended, action?: ExecutionAction, retryParams?: ExecuteStepRetryParams): Promise<SDKError | ExecuteStepRetryError>;
|
|
19
|
-
executeStep: (client: SDKClient, step: LiFiStepExtended, retryParams?: ExecuteStepRetryParams) => Promise<LiFiStepExtended>;
|
|
19
|
+
executeStep: (client: SDKClient, step: LiFiStepExtended, retryParams?: ExecuteStepRetryParams, signal?: AbortSignal) => Promise<LiFiStepExtended>;
|
|
20
20
|
}
|
|
21
21
|
//#endregion
|
|
22
22
|
//# sourceMappingURL=BaseStepExecutor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseStepExecutor.d.ts","names":[],"sources":["../../../src/core/BaseStepExecutor.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"BaseStepExecutor.d.ts","names":[],"sources":["../../../src/core/BaseStepExecutor.ts"],"mappings":";;;;;;;8BAgCsB,4BAA4B;YACtC,mBAAmB;YACnB,eAAe;EAEzB;EACA;EAEA,YAAY,SAAS;EAKrB,iBAAkB,WAAW;UAUrB;WAyBC,cACP,aAAa,0BACZ,QAAQ;WAEF,eAAe,SAAS,sBAAsB;WAE9C,YACP,OAAO,OACP,OAAO,kBACP,SAAS,iBACT,cAAc,yBACb,QAAQ,WAAW;EAEtB,cACE,QAAQ,WACR,MAAM,kBACN,cAAc,wBACd,SAAS,gBACR,QAAQ"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SDKError } from "../errors/SDKError.js";
|
|
2
|
+
import { BaseError } from "../errors/baseError.js";
|
|
3
|
+
import { ExecuteStepRetryError, UnknownError } from "../errors/errors.js";
|
|
4
|
+
import { hasStepOpenTransaction, isFinalTransactionError, transactionConflictError } from "./transactionState.js";
|
|
2
5
|
import { StatusManager } from "./StatusManager.js";
|
|
3
6
|
//#region src/core/BaseStepExecutor.ts
|
|
4
7
|
const defaultInteractionSettings = {
|
|
@@ -24,7 +27,7 @@ var BaseStepExecutor = class {
|
|
|
24
27
|
this.statusManager.allowUpdates(interactionSettings.allowUpdates);
|
|
25
28
|
this.allowExecution = interactionSettings.allowExecution;
|
|
26
29
|
};
|
|
27
|
-
createBaseContext = async (client, step, retryParams) => {
|
|
30
|
+
createBaseContext = async (client, step, retryParams, signal) => {
|
|
28
31
|
const fromChain = await client.getChainById(step.action.fromChainId);
|
|
29
32
|
const toChain = await client.getChainById(step.action.toChainId);
|
|
30
33
|
return {
|
|
@@ -36,24 +39,33 @@ var BaseStepExecutor = class {
|
|
|
36
39
|
retryParams,
|
|
37
40
|
statusManager: this.statusManager,
|
|
38
41
|
executionOptions: this.executionOptions,
|
|
39
|
-
allowUserInteraction: this.allowUserInteraction
|
|
42
|
+
allowUserInteraction: this.allowUserInteraction,
|
|
43
|
+
signal
|
|
40
44
|
};
|
|
41
45
|
};
|
|
42
|
-
executeStep = async (client, step, retryParams) => {
|
|
46
|
+
executeStep = async (client, step, retryParams, signal) => {
|
|
43
47
|
try {
|
|
44
48
|
step.execution = this.statusManager.initializeExecution(step);
|
|
45
|
-
const baseContext = await this.createBaseContext(client, step, retryParams);
|
|
49
|
+
const baseContext = await this.createBaseContext(client, step, retryParams, signal);
|
|
46
50
|
const context = await this.createContext(baseContext);
|
|
47
51
|
await this.createPipeline(context).run(context);
|
|
48
52
|
return step;
|
|
49
53
|
} catch (error) {
|
|
50
54
|
const action = step.execution?.actions?.at(-1);
|
|
51
|
-
|
|
55
|
+
let isFinal = isFinalTransactionError(error);
|
|
56
|
+
let parsed = await this.parseErrors(error, step, action, retryParams);
|
|
57
|
+
if (parsed instanceof ExecuteStepRetryError && hasStepOpenTransaction(step)) {
|
|
58
|
+
parsed = new SDKError(error instanceof ExecuteStepRetryError ? transactionConflictError() : error instanceof BaseError ? error : new UnknownError(error?.message || parsed.message, error), step, action);
|
|
59
|
+
isFinal = false;
|
|
60
|
+
}
|
|
52
61
|
if (!(parsed instanceof ExecuteStepRetryError)) {
|
|
53
|
-
if (action) this.statusManager.updateAction(step, action.type, "FAILED", {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
if (action) this.statusManager.updateAction(step, action.type, "FAILED", {
|
|
63
|
+
error: {
|
|
64
|
+
message: parsed.cause?.message,
|
|
65
|
+
code: parsed.code
|
|
66
|
+
},
|
|
67
|
+
...isFinal && { txFinal: true }
|
|
68
|
+
});
|
|
57
69
|
else this.statusManager.updateExecution(step, {
|
|
58
70
|
status: "FAILED",
|
|
59
71
|
error: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseStepExecutor.js","names":[],"sources":["../../../src/core/BaseStepExecutor.ts"],"sourcesContent":["import { ExecuteStepRetryError } from '../errors/errors.js'\nimport
|
|
1
|
+
{"version":3,"file":"BaseStepExecutor.js","names":[],"sources":["../../../src/core/BaseStepExecutor.ts"],"sourcesContent":["import { BaseError } from '../errors/baseError.js'\nimport { ExecuteStepRetryError, UnknownError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type {\n ExecuteStepRetryParams,\n ExecutionAction,\n ExecutionOptions,\n InteractionSettings,\n LiFiStepExtended,\n SDKClient,\n StepExecutor,\n StepExecutorOptions,\n} from '../types/core.js'\nimport type {\n StepExecutorBaseContext,\n StepExecutorContext,\n} from '../types/execution.js'\nimport { StatusManager } from './StatusManager.js'\nimport type { TaskPipeline } from './TaskPipeline.js'\nimport {\n hasStepOpenTransaction,\n isFinalTransactionError,\n transactionConflictError,\n} from './transactionState.js'\n\n// Please be careful when changing the defaults as it may break the behavior (e.g., background execution)\nconst defaultInteractionSettings = {\n allowInteraction: true,\n allowUpdates: true,\n allowExecution: true,\n}\n\nexport abstract class BaseStepExecutor implements StepExecutor {\n protected executionOptions?: ExecutionOptions\n protected statusManager: StatusManager\n\n public allowUserInteraction = true\n public allowExecution = true\n\n constructor(options: StepExecutorOptions) {\n this.statusManager = new StatusManager(options.routeId)\n this.executionOptions = options.executionOptions\n }\n\n setInteraction = (settings?: InteractionSettings): void => {\n const interactionSettings = {\n ...defaultInteractionSettings,\n ...settings,\n }\n this.allowUserInteraction = interactionSettings.allowInteraction\n this.statusManager.allowUpdates(interactionSettings.allowUpdates)\n this.allowExecution = interactionSettings.allowExecution\n }\n\n private createBaseContext = async (\n client: SDKClient,\n step: LiFiStepExtended,\n retryParams?: ExecuteStepRetryParams,\n signal?: AbortSignal\n ): Promise<StepExecutorBaseContext> => {\n const fromChain = await client.getChainById(step.action.fromChainId)\n const toChain = await client.getChainById(step.action.toChainId)\n\n const isBridgeExecution = fromChain.id !== toChain.id\n\n return {\n client,\n step,\n fromChain,\n toChain,\n isBridgeExecution,\n retryParams,\n statusManager: this.statusManager,\n executionOptions: this.executionOptions,\n allowUserInteraction: this.allowUserInteraction,\n signal,\n }\n }\n\n abstract createContext(\n baseContext: StepExecutorBaseContext\n ): Promise<StepExecutorContext>\n\n abstract createPipeline(context: StepExecutorContext): TaskPipeline\n\n abstract parseErrors(\n error: Error,\n step?: LiFiStepExtended,\n action?: ExecutionAction,\n retryParams?: ExecuteStepRetryParams\n ): Promise<SDKError | ExecuteStepRetryError>\n\n executeStep = async (\n client: SDKClient,\n step: LiFiStepExtended,\n retryParams?: ExecuteStepRetryParams,\n signal?: AbortSignal\n ): Promise<LiFiStepExtended> => {\n try {\n step.execution = this.statusManager.initializeExecution(step)\n\n const baseContext = await this.createBaseContext(\n client,\n step,\n retryParams,\n signal\n )\n const context = await this.createContext(baseContext)\n const pipeline = this.createPipeline(context)\n\n await pipeline.run(context)\n\n return step\n } catch (error: any) {\n // Derive failing action from last in execution.actions\n const action = step.execution?.actions?.at(-1)\n // Read before parsing: parsers may rebuild the error and drop the marker.\n let isFinal = isFinalTransactionError(error)\n let parsed = await this.parseErrors(error, step, action, retryParams)\n if (\n parsed instanceof ExecuteStepRetryError &&\n hasStepOpenTransaction(step)\n ) {\n // A retry runs the step again on an empty execution, which would erase\n // the hash of a transaction that may still land. Fail with the original\n // error instead, and keep the outcome unknown so a resume re-checks it.\n // A BaseError keeps its code, so the widget shows its text. A replay\n // that a task asked for has no error of its own: it fails as a sign\n // task fails for the same state (`TransactionConflict`).\n parsed = new SDKError(\n error instanceof ExecuteStepRetryError\n ? transactionConflictError()\n : error instanceof BaseError\n ? error\n : new UnknownError(error?.message || parsed.message, error),\n step,\n action\n )\n isFinal = false\n }\n if (!(parsed instanceof ExecuteStepRetryError)) {\n if (action) {\n this.statusManager.updateAction(step, action.type, 'FAILED', {\n error: {\n message: parsed.cause?.message,\n code: parsed.code,\n },\n ...(isFinal && { txFinal: true }),\n })\n } else {\n this.statusManager.updateExecution(step, {\n status: 'FAILED',\n error: {\n message: parsed.cause?.message,\n code: parsed.code,\n },\n })\n }\n }\n throw parsed\n }\n }\n}\n"],"mappings":";;;;;;AA0BA,MAAM,6BAA6B;CACjC,kBAAkB;CAClB,cAAc;CACd,gBAAgB;AAClB;AAEA,IAAsB,mBAAtB,MAA+D;CAC7D;CACA;CAEA,uBAA8B;CAC9B,iBAAwB;CAExB,YAAY,SAA8B;EACxC,KAAK,gBAAgB,IAAI,cAAc,QAAQ,OAAO;EACtD,KAAK,mBAAmB,QAAQ;CAClC;CAEA,kBAAkB,aAAyC;EACzD,MAAM,sBAAsB;GAC1B,GAAG;GACH,GAAG;EACL;EACA,KAAK,uBAAuB,oBAAoB;EAChD,KAAK,cAAc,aAAa,oBAAoB,YAAY;EAChE,KAAK,iBAAiB,oBAAoB;CAC5C;CAEA,oBAA4B,OAC1B,QACA,MACA,aACA,WACqC;EACrC,MAAM,YAAY,MAAM,OAAO,aAAa,KAAK,OAAO,WAAW;EACnE,MAAM,UAAU,MAAM,OAAO,aAAa,KAAK,OAAO,SAAS;EAI/D,OAAO;GACL;GACA;GACA;GACA;GACA,mBAPwB,UAAU,OAAO,QAAQ;GAQjD;GACA,eAAe,KAAK;GACpB,kBAAkB,KAAK;GACvB,sBAAsB,KAAK;GAC3B;EACF;CACF;CAeA,cAAc,OACZ,QACA,MACA,aACA,WAC8B;EAC9B,IAAI;GACF,KAAK,YAAY,KAAK,cAAc,oBAAoB,IAAI;GAE5D,MAAM,cAAc,MAAM,KAAK,kBAC7B,QACA,MACA,aACA,MACF;GACA,MAAM,UAAU,MAAM,KAAK,cAAc,WAAW;GAGpD,MAFiB,KAAK,eAAe,OAExB,CAAC,CAAC,IAAI,OAAO;GAE1B,OAAO;EACT,SAAS,OAAY;GAEnB,MAAM,SAAS,KAAK,WAAW,SAAS,GAAG,EAAE;GAE7C,IAAI,UAAU,wBAAwB,KAAK;GAC3C,IAAI,SAAS,MAAM,KAAK,YAAY,OAAO,MAAM,QAAQ,WAAW;GACpE,IACE,kBAAkB,yBAClB,uBAAuB,IAAI,GAC3B;IAOA,SAAS,IAAI,SACX,iBAAiB,wBACb,yBAAyB,IACzB,iBAAiB,YACf,QACA,IAAI,aAAa,OAAO,WAAW,OAAO,SAAS,KAAK,GAC9D,MACA,MACF;IACA,UAAU;GACZ;GACA,IAAI,EAAE,kBAAkB,wBAAwB;IAC9C,IAAI,QACF,KAAK,cAAc,aAAa,MAAM,OAAO,MAAM,UAAU;KAC3D,OAAO;MACL,SAAS,OAAO,OAAO;MACvB,MAAM,OAAO;KACf;KACA,GAAI,WAAW,EAAE,SAAS,KAAK;IACjC,CAAC;SAED,KAAK,cAAc,gBAAgB,MAAM;KACvC,QAAQ;KACR,OAAO;MACL,SAAS,OAAO,OAAO;MACvB,MAAM,OAAO;KACf;IACF,CAAC;GAEL;GACA,MAAM;EACR;CACF;AACF"}
|
|
@@ -13,6 +13,7 @@ type ActionProps = {
|
|
|
13
13
|
export declare class StatusManager {
|
|
14
14
|
private readonly routeId;
|
|
15
15
|
private shouldUpdate;
|
|
16
|
+
private stoppedExecution?;
|
|
16
17
|
constructor(routeId: string);
|
|
17
18
|
/**
|
|
18
19
|
* Initializes the execution object of a Step.
|
|
@@ -66,6 +67,15 @@ export declare class StatusManager {
|
|
|
66
67
|
}>) => ExecutionAction;
|
|
67
68
|
updateStepInRoute: (step: LiFiStep) => LiFiStep;
|
|
68
69
|
allowUpdates(value: boolean): void;
|
|
70
|
+
/**
|
|
71
|
+
* A write of transaction data after `stopRouteExecution`. With a newer
|
|
72
|
+
* execution of the same route id running, the transaction is merged into
|
|
73
|
+
* it. If no execution of the route started since the stop, the kept route
|
|
74
|
+
* is updated and the kept hook is called. If a newer execution started and
|
|
75
|
+
* ended since the stop, the transaction is merged into the route of the
|
|
76
|
+
* last ended execution, and its hook is called.
|
|
77
|
+
*/
|
|
78
|
+
private deliverLateTransactionData;
|
|
69
79
|
}
|
|
70
80
|
//#endregion
|
|
71
81
|
//# sourceMappingURL=StatusManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatusManager.d.ts","names":[],"sources":["../../../src/core/StatusManager.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"StatusManager.d.ts","names":[],"sources":["../../../src/core/StatusManager.ts"],"mappings":";;;KAmBK;EACH,MAAM;EACN,MAAM;EACN,SAAS;EACT,QAAQ;;;;;qBA6GG;mBACM;UACT;UACA;EAER,YAAY;;;;;;EASZ,sBAAuB,MAAM,qBAAmB;;;;;;;EAiChD,gBACE,MAAM,kBACN,WAAW,QAAQ,aAClB;;;;;;;EAkBH,WACE,MAAM,kBACN,MAAM,sBACL;;;;;;;;;;EAmBH,iBACE,MACA,MACA,SACA,UACC,gBAAc;;;;;;;;;EAyBjB,qBACE,MACA,MACA,SACA,UACC,gBAAc;;;;;;;;;EA0BjB,eACE,MAAM,kBACN,MAAM,qBACN,QAAQ,uBACR,SAAS,QAAQ;IAAoB;SACpC;EAgEH,oBAAqB,MAAM,aAAW;EA6BtC,aAAa;;;;;;;;;UA0BL"}
|
|
@@ -1,12 +1,67 @@
|
|
|
1
1
|
import { getActionMessage } from "./actionMessages.js";
|
|
2
2
|
import { executionState } from "./executionState.js";
|
|
3
|
+
import { CLEARED_TRANSACTION_FIELDS, TRANSACTION_ACTION_TYPES, hasOpenTransaction, hasStepOpenTransaction } from "./transactionState.js";
|
|
3
4
|
//#region src/core/StatusManager.ts
|
|
4
5
|
/**
|
|
6
|
+
* A write is transaction data when it changes one of these fields. `txLink`,
|
|
7
|
+
* `signedAt` and `callCount` travel with such a write but never trigger one:
|
|
8
|
+
* the status poll rewrites `txLink` every few seconds, and `callCount` comes
|
|
9
|
+
* only with a `taskId`.
|
|
10
|
+
*/
|
|
11
|
+
const TRANSACTION_KEYS = [
|
|
12
|
+
"txHash",
|
|
13
|
+
"txHex",
|
|
14
|
+
"taskId",
|
|
15
|
+
"txFinal"
|
|
16
|
+
];
|
|
17
|
+
const readTransaction = (action) => ({
|
|
18
|
+
txHash: action.txHash,
|
|
19
|
+
txHex: action.txHex,
|
|
20
|
+
taskId: action.taskId,
|
|
21
|
+
txFinal: action.txFinal
|
|
22
|
+
});
|
|
23
|
+
/** True when the write changed a transaction field, also to `undefined`. */
|
|
24
|
+
const changesTransaction = (before, action) => TRANSACTION_KEYS.some((key) => action[key] !== before[key]);
|
|
25
|
+
/**
|
|
26
|
+
* Copies a late transaction into the route of a newer execution of the same
|
|
27
|
+
* route id, running or ended. The step's objects are changed in place: a
|
|
28
|
+
* running executor holds them, so its selector and its pre-sign guard see
|
|
29
|
+
* the transaction. Returns true when something changed.
|
|
30
|
+
*/
|
|
31
|
+
const mergeLateTransaction = (liveRoute, lateStep, lateAction) => {
|
|
32
|
+
if (!hasOpenTransaction(lateAction)) return false;
|
|
33
|
+
const liveStep = liveRoute.steps.find((routeStep) => routeStep.id === lateStep.id);
|
|
34
|
+
if (!liveStep) return false;
|
|
35
|
+
if (!liveStep.execution) liveStep.execution = {
|
|
36
|
+
startedAt: Date.now(),
|
|
37
|
+
status: "PENDING",
|
|
38
|
+
actions: [structuredClone(lateAction)]
|
|
39
|
+
};
|
|
40
|
+
else {
|
|
41
|
+
const liveAction = liveStep.execution.actions.find((action) => action.type === lateAction.type);
|
|
42
|
+
if (!liveAction) liveStep.execution.actions.push(structuredClone(lateAction));
|
|
43
|
+
else if (hasOpenTransaction(liveAction)) return false;
|
|
44
|
+
else Object.assign(liveAction, {
|
|
45
|
+
txHash: lateAction.txHash,
|
|
46
|
+
txLink: lateAction.txLink,
|
|
47
|
+
txHex: lateAction.txHex,
|
|
48
|
+
txFinal: lateAction.txFinal,
|
|
49
|
+
taskId: lateAction.taskId,
|
|
50
|
+
callCount: lateAction.callCount,
|
|
51
|
+
txType: lateAction.txType
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const signedAt = lateStep.execution?.signedAt;
|
|
55
|
+
if (TRANSACTION_ACTION_TYPES.includes(lateAction.type) && signedAt !== void 0) liveStep.execution.signedAt = signedAt;
|
|
56
|
+
return true;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
5
59
|
* Manages status updates of a route and provides various functions for tracking actions.
|
|
6
60
|
*/
|
|
7
61
|
var StatusManager = class {
|
|
8
62
|
routeId;
|
|
9
63
|
shouldUpdate = true;
|
|
64
|
+
stoppedExecution;
|
|
10
65
|
constructor(routeId) {
|
|
11
66
|
this.routeId = routeId;
|
|
12
67
|
}
|
|
@@ -27,7 +82,7 @@ var StatusManager = class {
|
|
|
27
82
|
if (step.execution.status === "FAILED") {
|
|
28
83
|
step.execution.startedAt = Date.now();
|
|
29
84
|
step.execution.status = "PENDING";
|
|
30
|
-
step.execution.signedAt = void 0;
|
|
85
|
+
if (!hasStepOpenTransaction(step)) step.execution.signedAt = void 0;
|
|
31
86
|
step.execution.error = void 0;
|
|
32
87
|
this.updateStepInRoute(step);
|
|
33
88
|
}
|
|
@@ -88,7 +143,11 @@ var StatusManager = class {
|
|
|
88
143
|
* @returns The updated or newly created action.
|
|
89
144
|
*/
|
|
90
145
|
initializeAction = ({ step, type, chainId, status }) => {
|
|
91
|
-
|
|
146
|
+
const action = this.findAction(step, type);
|
|
147
|
+
if (action) return this.updateAction(step, type, status, {
|
|
148
|
+
error: void 0,
|
|
149
|
+
...action.status === "FAILED" && action.txFinal === true && CLEARED_TRANSACTION_FIELDS
|
|
150
|
+
});
|
|
92
151
|
return this.createAction({
|
|
93
152
|
step,
|
|
94
153
|
type,
|
|
@@ -108,6 +167,7 @@ var StatusManager = class {
|
|
|
108
167
|
if (!step.execution) throw new Error("Can't update an empty step execution.");
|
|
109
168
|
const currentAction = this.findAction(step, type);
|
|
110
169
|
if (!currentAction) throw new Error("Can't find an action for the given type.");
|
|
170
|
+
const transactionBefore = this.shouldUpdate ? void 0 : readTransaction(currentAction);
|
|
111
171
|
switch (status) {
|
|
112
172
|
case "CANCELLED": break;
|
|
113
173
|
case "FAILED":
|
|
@@ -130,7 +190,8 @@ var StatusManager = class {
|
|
|
130
190
|
Object.assign(currentAction, rest);
|
|
131
191
|
}
|
|
132
192
|
step.execution.actions = [...step.execution.actions.filter((action) => action.status === "DONE"), ...step.execution.actions.filter((action) => action.status !== "DONE")];
|
|
133
|
-
this.
|
|
193
|
+
if (transactionBefore && changesTransaction(transactionBefore, currentAction)) this.deliverLateTransactionData(step, currentAction);
|
|
194
|
+
else this.updateStepInRoute(step);
|
|
134
195
|
return currentAction;
|
|
135
196
|
};
|
|
136
197
|
updateStepInRoute = (step) => {
|
|
@@ -148,6 +209,49 @@ var StatusManager = class {
|
|
|
148
209
|
};
|
|
149
210
|
allowUpdates(value) {
|
|
150
211
|
this.shouldUpdate = value;
|
|
212
|
+
if (value) {
|
|
213
|
+
this.stoppedExecution = void 0;
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const data = executionState.get(this.routeId);
|
|
217
|
+
if (data) this.stoppedExecution = {
|
|
218
|
+
route: data.route,
|
|
219
|
+
updateRouteHook: data.executionOptions?.updateRouteHook,
|
|
220
|
+
startCount: executionState.startCount(this.routeId)
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* A write of transaction data after `stopRouteExecution`. With a newer
|
|
225
|
+
* execution of the same route id running, the transaction is merged into
|
|
226
|
+
* it. If no execution of the route started since the stop, the kept route
|
|
227
|
+
* is updated and the kept hook is called. If a newer execution started and
|
|
228
|
+
* ended since the stop, the transaction is merged into the route of the
|
|
229
|
+
* last ended execution, and its hook is called.
|
|
230
|
+
*/
|
|
231
|
+
deliverLateTransactionData(step, lateAction) {
|
|
232
|
+
const stopped = this.stoppedExecution;
|
|
233
|
+
if (!stopped) return;
|
|
234
|
+
try {
|
|
235
|
+
const live = executionState.get(this.routeId);
|
|
236
|
+
if (live) {
|
|
237
|
+
if (mergeLateTransaction(live.route, step, lateAction)) live.executionOptions?.updateRouteHook?.(live.route);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
if (executionState.startCount(this.routeId) !== stopped.startCount) {
|
|
241
|
+
const ended = executionState.lastEnded(this.routeId);
|
|
242
|
+
if (ended && mergeLateTransaction(ended.route, step, lateAction)) ended.updateRouteHook?.(ended.route);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
const stepIndex = stopped.route.steps.findIndex((routeStep) => routeStep.id === step.id);
|
|
246
|
+
if (stepIndex === -1) return;
|
|
247
|
+
stopped.route.steps[stepIndex] = {
|
|
248
|
+
...stopped.route.steps[stepIndex],
|
|
249
|
+
...step
|
|
250
|
+
};
|
|
251
|
+
stopped.updateRouteHook?.(stopped.route);
|
|
252
|
+
} catch (error) {
|
|
253
|
+
if (process.env.NODE_ENV === "development") console.debug("Delivering late transaction data failed.", error);
|
|
254
|
+
}
|
|
151
255
|
}
|
|
152
256
|
};
|
|
153
257
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatusManager.js","names":[],"sources":["../../../src/core/StatusManager.ts"],"sourcesContent":["import type { ChainId, LiFiStep } from '@lifi/types'\nimport type {\n Execution,\n ExecutionAction,\n ExecutionActionStatus,\n ExecutionActionType,\n LiFiStepExtended,\n} from '../types/core.js'\nimport { getActionMessage } from './actionMessages.js'\nimport { executionState } from './executionState.js'\n\ntype ActionProps = {\n step: LiFiStepExtended\n type: ExecutionActionType\n chainId: ChainId\n status: ExecutionActionStatus\n}\n\n/**\n * Manages status updates of a route and provides various functions for tracking actions.\n */\nexport class StatusManager {\n private readonly routeId: string\n private shouldUpdate = true\n\n constructor(routeId: string) {\n this.routeId = routeId\n }\n\n /**\n * Initializes the execution object of a Step.\n * @param step The current step in execution\n * @returns The initialized execution object for this step\n */\n initializeExecution = (step: LiFiStepExtended): Execution => {\n if (!step.execution) {\n step.execution = {\n startedAt: Date.now(),\n status: 'PENDING',\n actions: [],\n }\n this.updateStepInRoute(step)\n }\n\n // Change status to PENDING after resuming from FAILED\n if (step.execution.status === 'FAILED') {\n step.execution.startedAt = Date.now()\n step.execution.status = 'PENDING'\n step.execution.signedAt = undefined\n step.execution.error = undefined\n this.updateStepInRoute(step)\n }\n\n return step.execution\n }\n\n /**\n * Updates the execution object of a Step.\n * @param step The current step in execution\n * @param execution Partial execution data to merge\n * @returns The step with the updated execution object\n */\n updateExecution(\n step: LiFiStepExtended,\n execution: Partial<Execution>\n ): LiFiStep {\n if (!step.execution) {\n throw Error(\"Can't update empty execution.\")\n }\n step.execution = {\n ...step.execution,\n ...execution,\n }\n this.updateStepInRoute(step)\n return step\n }\n\n /**\n * Finds an action of the specified type in the step's execution\n * @param step The step to search in\n * @param type The action type to find\n * @returns The found action or undefined if not found\n */\n findAction(\n step: LiFiStepExtended,\n type: ExecutionActionType\n ): ExecutionAction | undefined {\n if (!step.execution?.actions) {\n throw new Error(\"Execution hasn't been initialized.\")\n }\n\n const action = step.execution.actions.find((p) => p.type === type)\n\n return action\n }\n\n /**\n * Create and push a new action into the execution.\n * Caller is responsible for ensuring an action of this type does not already exist.\n * @param step The step that should contain the new action.\n * @param type Type of the action.\n * @param chainId Chain Id of the action.\n * @param status The initial status for the new action.\n * @returns The created action.\n */\n createAction = ({\n step,\n type,\n chainId,\n status,\n }: ActionProps): ExecutionAction => {\n if (!step.execution) {\n throw new Error(\"Execution hasn't been initialized.\")\n }\n\n const newAction: ExecutionAction = {\n type,\n message: getActionMessage(type, status),\n status,\n chainId,\n }\n\n step.execution.actions.push(newAction)\n this.updateStepInRoute(step)\n return newAction\n }\n\n /**\n * Find an existing action by type and update it, or create a new one if none exists.\n * @param step The step that should contain the action.\n * @param type Type of the action. Used to identify already existing actions.\n * @param chainId Chain Id of the action (used when creating).\n * @param status The status to set on the found or newly created action.\n * @returns The updated or newly created action.\n */\n initializeAction = ({\n step,\n type,\n chainId,\n status,\n }: ActionProps): ExecutionAction => {\n const action = this.findAction(step, type)\n\n if (action) {\n return this.updateAction(step, type, status, {\n error: undefined,\n })\n }\n\n return this.createAction({ step, type, chainId, status })\n }\n\n /**\n * Update an action object.\n * @param step The step where the action should be updated\n * @param type The action type to update\n * @param status The status the action gets.\n * @param [params] Additional parameters to append to the action.\n * @returns The updated action\n */\n updateAction = (\n step: LiFiStepExtended,\n type: ExecutionActionType,\n status: ExecutionActionStatus,\n params?: Partial<ExecutionAction & { signedAt?: number }>\n ): ExecutionAction => {\n if (!step.execution) {\n throw new Error(\"Can't update an empty step execution.\")\n }\n const currentAction = this.findAction(step, type)\n\n if (!currentAction) {\n throw new Error(\"Can't find an action for the given type.\")\n }\n\n switch (status) {\n case 'CANCELLED':\n break\n case 'FAILED':\n step.execution.status = 'FAILED'\n if (params?.error) {\n step.execution.error = params.error\n }\n break\n case 'DONE':\n break\n case 'PENDING':\n step.execution.status = 'PENDING'\n if (params?.signedAt) {\n step.execution.signedAt = params.signedAt\n }\n break\n case 'RESET_REQUIRED':\n case 'MESSAGE_REQUIRED':\n case 'ACTION_REQUIRED':\n step.execution.status = 'ACTION_REQUIRED'\n break\n default:\n break\n }\n\n currentAction.status = status\n currentAction.message = getActionMessage(type, status)\n // set extra parameters or overwrite the standard params set in the switch statement\n if (params) {\n const { signedAt: _signedAt, ...rest } = params\n Object.assign(currentAction, rest)\n }\n // Sort actions, the ones with DONE status go first\n step.execution.actions = [\n ...step.execution.actions.filter((action) => action.status === 'DONE'),\n ...step.execution.actions.filter((action) => action.status !== 'DONE'),\n ]\n this.updateStepInRoute(step) // updates the step in the route\n return currentAction\n }\n\n updateStepInRoute = (step: LiFiStep): LiFiStep => {\n if (!this.shouldUpdate) {\n return step\n }\n const data = executionState.get(this.routeId)\n\n if (!data) {\n throw new Error('Execution data not found.')\n }\n\n const stepIndex = data.route.steps.findIndex(\n (routeStep) => routeStep.id === step.id\n )\n\n if (stepIndex === -1) {\n throw new Error(\"Couldn't find a step to update.\")\n }\n\n data.route.steps[stepIndex] = { ...data.route.steps[stepIndex], ...step }\n\n data.executionOptions?.updateRouteHook?.(data.route)\n return data.route.steps[stepIndex]\n }\n\n allowUpdates(value: boolean): void {\n this.shouldUpdate = value\n }\n}\n"],"mappings":";;;;;;AAqBA,IAAa,gBAAb,MAA2B;CACzB;CACA,eAAuB;CAEvB,YAAY,SAAiB;EAC3B,KAAK,UAAU;CACjB;;;;;;CAOA,uBAAuB,SAAsC;EAC3D,IAAI,CAAC,KAAK,WAAW;GACnB,KAAK,YAAY;IACf,WAAW,KAAK,IAAI;IACpB,QAAQ;IACR,SAAS,CAAC;GACZ;GACA,KAAK,kBAAkB,IAAI;EAC7B;EAGA,IAAI,KAAK,UAAU,WAAW,UAAU;GACtC,KAAK,UAAU,YAAY,KAAK,IAAI;GACpC,KAAK,UAAU,SAAS;GACxB,KAAK,UAAU,WAAW,KAAA;GAC1B,KAAK,UAAU,QAAQ,KAAA;GACvB,KAAK,kBAAkB,IAAI;EAC7B;EAEA,OAAO,KAAK;CACd;;;;;;;CAQA,gBACE,MACA,WACU;EACV,IAAI,CAAC,KAAK,WACR,MAAM,MAAM,+BAA+B;EAE7C,KAAK,YAAY;GACf,GAAG,KAAK;GACR,GAAG;EACL;EACA,KAAK,kBAAkB,IAAI;EAC3B,OAAO;CACT;;;;;;;CAQA,W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AAG,SAAS;GACzC,OAAO,OAAO,eAAe,IAAI;EACnC;EAEA,KAAK,UAAU,UAAU,CACvB,GAAG,KAAK,UAAU,QAAQ,QAAQ,WAAW,OAAO,WAAW,MAAM,GACrE,GAAG,KAAK,UAAU,QAAQ,QAAQ,WAAW,OAAO,WAAW,MAAM,CACvE;EACA,KAAK,kBAAkB,IAAI;EAC3B,OAAO;CACT;CAEA,qBAAqB,SAA6B;EAChD,IAAI,CAAC,KAAK,cACR,OAAO;EAET,MAAM,OAAO,eAAe,IAAI,KAAK,OAAO;EAE5C,IAAI,CAAC,MACH,MAAM,IAAI,MAAM,2BAA2B;EAG7C,MAAM,YAAY,KAAK,MAAM,MAAM,WAChC,cAAc,UAAU,OAAO,KAAK,EACvC;EAEA,IAAI,cAAc,IAChB,MAAM,IAAI,MAAM,iCAAiC;EAGnD,KAAK,MAAM,MAAM,aAAa;GAAE,GAAG,KAAK,MAAM,MAAM;GAAY,GAAG;EAAK;EAExE,KAAK,kBAAkB,kBAAkB,KAAK,KAAK;EACnD,OAAO,KAAK,MAAM,MAAM;CAC1B;CAEA,aAAa,OAAsB;EACjC,KAAK,eAAe;CACtB;AACF"}
|
|
1
|
+
{"version":3,"file":"StatusManager.js","names":[],"sources":["../../../src/core/StatusManager.ts"],"sourcesContent":["import type { ChainId, LiFiStep } from '@lifi/types'\nimport type {\n Execution,\n ExecutionAction,\n ExecutionActionStatus,\n ExecutionActionType,\n LiFiStepExtended,\n RouteExtended,\n UpdateRouteHook,\n} from '../types/core.js'\nimport { getActionMessage } from './actionMessages.js'\nimport { executionState } from './executionState.js'\nimport {\n CLEARED_TRANSACTION_FIELDS,\n hasOpenTransaction,\n hasStepOpenTransaction,\n TRANSACTION_ACTION_TYPES,\n} from './transactionState.js'\n\ntype ActionProps = {\n step: LiFiStepExtended\n type: ExecutionActionType\n chainId: ChainId\n status: ExecutionActionStatus\n}\n\n/**\n * The route and hook of an execution that `stopRouteExecution` ended. A task\n * that was still running (e.g. waiting in the wallet prompt) writes its\n * transaction data later; without these the write would never reach the\n * integrator, and a resume of the stored route would sign again.\n * `startCount` is `executionState.startCount` at the stop.\n */\ntype StoppedExecution = {\n route: RouteExtended\n updateRouteHook?: UpdateRouteHook\n startCount: number\n}\n\n/**\n * A write is transaction data when it changes one of these fields. `txLink`,\n * `signedAt` and `callCount` travel with such a write but never trigger one:\n * the status poll rewrites `txLink` every few seconds, and `callCount` comes\n * only with a `taskId`.\n */\nconst TRANSACTION_KEYS = ['txHash', 'txHex', 'taskId', 'txFinal'] as const\n\ntype TransactionFields = Pick<\n ExecutionAction,\n (typeof TRANSACTION_KEYS)[number]\n>\n\nconst readTransaction = (action: ExecutionAction): TransactionFields => ({\n txHash: action.txHash,\n txHex: action.txHex,\n taskId: action.taskId,\n txFinal: action.txFinal,\n})\n\n/** True when the write changed a transaction field, also to `undefined`. */\nconst changesTransaction = (\n before: TransactionFields,\n action: ExecutionAction\n): boolean => TRANSACTION_KEYS.some((key) => action[key] !== before[key])\n\n/**\n * Copies a late transaction into the route of a newer execution of the same\n * route id, running or ended. The step's objects are changed in place: a\n * running executor holds them, so its selector and its pre-sign guard see\n * the transaction. Returns true when something changed.\n */\nconst mergeLateTransaction = (\n liveRoute: RouteExtended,\n lateStep: LiFiStepExtended,\n lateAction: ExecutionAction\n): boolean => {\n // Cleared or final: the newer execution needs nothing from it.\n if (!hasOpenTransaction(lateAction)) {\n return false\n }\n const liveStep = liveRoute.steps.find(\n (routeStep) => routeStep.id === lateStep.id\n )\n if (!liveStep) {\n return false\n }\n if (!liveStep.execution) {\n liveStep.execution = {\n startedAt: Date.now(),\n status: 'PENDING',\n actions: [structuredClone(lateAction)],\n }\n } else {\n const liveAction = liveStep.execution.actions.find(\n (action) => action.type === lateAction.type\n )\n if (!liveAction) {\n liveStep.execution.actions.push(structuredClone(lateAction))\n } else if (hasOpenTransaction(liveAction)) {\n // The live action already has an open transaction (its own, or one\n // merged earlier); it is kept.\n return false\n } else {\n // Every field of `CLEARED_TRANSACTION_FIELDS`, so a stale `txFinal`\n // goes and the action is open. `txType` goes with them: the live one\n // described no open transaction.\n Object.assign(liveAction, {\n txHash: lateAction.txHash,\n txLink: lateAction.txLink,\n txHex: lateAction.txHex,\n txFinal: lateAction.txFinal,\n taskId: lateAction.taskId,\n callCount: lateAction.callCount,\n txType: lateAction.txType,\n })\n }\n }\n // `signedAt` is the signing time of the step's own transaction: an\n // allowance does not set it, and a write without one keeps the live time.\n const signedAt = lateStep.execution?.signedAt\n if (\n TRANSACTION_ACTION_TYPES.includes(lateAction.type) &&\n signedAt !== undefined\n ) {\n liveStep.execution.signedAt = signedAt\n }\n return true\n}\n\n/**\n * Manages status updates of a route and provides various functions for tracking actions.\n */\nexport class StatusManager {\n private readonly routeId: string\n private shouldUpdate = true\n private stoppedExecution?: StoppedExecution\n\n constructor(routeId: string) {\n this.routeId = routeId\n }\n\n /**\n * Initializes the execution object of a Step.\n * @param step The current step in execution\n * @returns The initialized execution object for this step\n */\n initializeExecution = (step: LiFiStepExtended): Execution => {\n if (!step.execution) {\n step.execution = {\n startedAt: Date.now(),\n status: 'PENDING',\n actions: [],\n }\n this.updateStepInRoute(step)\n }\n\n // Change status to PENDING after resuming from FAILED\n if (step.execution.status === 'FAILED') {\n step.execution.startedAt = Date.now()\n step.execution.status = 'PENDING'\n // Keep the signing time while a signed transaction may still land: the\n // resume path uses it to decide when stored bytes are too old to resend\n // or old enough to be declared dropped.\n if (!hasStepOpenTransaction(step)) {\n step.execution.signedAt = undefined\n }\n step.execution.error = undefined\n this.updateStepInRoute(step)\n }\n\n return step.execution\n }\n\n /**\n * Updates the execution object of a Step.\n * @param step The current step in execution\n * @param execution Partial execution data to merge\n * @returns The step with the updated execution object\n */\n updateExecution(\n step: LiFiStepExtended,\n execution: Partial<Execution>\n ): LiFiStep {\n if (!step.execution) {\n throw Error(\"Can't update empty execution.\")\n }\n step.execution = {\n ...step.execution,\n ...execution,\n }\n this.updateStepInRoute(step)\n return step\n }\n\n /**\n * Finds an action of the specified type in the step's execution\n * @param step The step to search in\n * @param type The action type to find\n * @returns The found action or undefined if not found\n */\n findAction(\n step: LiFiStepExtended,\n type: ExecutionActionType\n ): ExecutionAction | undefined {\n if (!step.execution?.actions) {\n throw new Error(\"Execution hasn't been initialized.\")\n }\n\n const action = step.execution.actions.find((p) => p.type === type)\n\n return action\n }\n\n /**\n * Create and push a new action into the execution.\n * Caller is responsible for ensuring an action of this type does not already exist.\n * @param step The step that should contain the new action.\n * @param type Type of the action.\n * @param chainId Chain Id of the action.\n * @param status The initial status for the new action.\n * @returns The created action.\n */\n createAction = ({\n step,\n type,\n chainId,\n status,\n }: ActionProps): ExecutionAction => {\n if (!step.execution) {\n throw new Error(\"Execution hasn't been initialized.\")\n }\n\n const newAction: ExecutionAction = {\n type,\n message: getActionMessage(type, status),\n status,\n chainId,\n }\n\n step.execution.actions.push(newAction)\n this.updateStepInRoute(step)\n return newAction\n }\n\n /**\n * Find an existing action by type and update it, or create a new one if none exists.\n * @param step The step that should contain the action.\n * @param type Type of the action. Used to identify already existing actions.\n * @param chainId Chain Id of the action (used when creating).\n * @param status The status to set on the found or newly created action.\n * @returns The updated or newly created action.\n */\n initializeAction = ({\n step,\n type,\n chainId,\n status,\n }: ActionProps): ExecutionAction => {\n const action = this.findAction(step, type)\n\n if (action) {\n return this.updateAction(step, type, status, {\n error: undefined,\n // A final outcome is dead. A new attempt starts without its data, so\n // the pre-sign guard does not mistake it for an open transaction (the\n // route was run again without `prepareRestart`, e.g. `executeRoute`).\n ...(action.status === 'FAILED' &&\n action.txFinal === true &&\n CLEARED_TRANSACTION_FIELDS),\n })\n }\n\n return this.createAction({ step, type, chainId, status })\n }\n\n /**\n * Update an action object.\n * @param step The step where the action should be updated\n * @param type The action type to update\n * @param status The status the action gets.\n * @param [params] Additional parameters to append to the action.\n * @returns The updated action\n */\n updateAction = (\n step: LiFiStepExtended,\n type: ExecutionActionType,\n status: ExecutionActionStatus,\n params?: Partial<ExecutionAction & { signedAt?: number }>\n ): ExecutionAction => {\n if (!step.execution) {\n throw new Error(\"Can't update an empty step execution.\")\n }\n const currentAction = this.findAction(step, type)\n\n if (!currentAction) {\n throw new Error(\"Can't find an action for the given type.\")\n }\n // Read before the write: after a stop, only a write that changes the\n // transaction reaches the integrator.\n const transactionBefore = this.shouldUpdate\n ? undefined\n : readTransaction(currentAction)\n\n switch (status) {\n case 'CANCELLED':\n break\n case 'FAILED':\n step.execution.status = 'FAILED'\n if (params?.error) {\n step.execution.error = params.error\n }\n break\n case 'DONE':\n break\n case 'PENDING':\n step.execution.status = 'PENDING'\n if (params?.signedAt) {\n step.execution.signedAt = params.signedAt\n }\n break\n case 'RESET_REQUIRED':\n case 'MESSAGE_REQUIRED':\n case 'ACTION_REQUIRED':\n step.execution.status = 'ACTION_REQUIRED'\n break\n default:\n break\n }\n\n currentAction.status = status\n currentAction.message = getActionMessage(type, status)\n // set extra parameters or overwrite the standard params set in the switch statement\n if (params) {\n const { signedAt: _signedAt, ...rest } = params\n Object.assign(currentAction, rest)\n }\n // Sort actions, the ones with DONE status go first\n step.execution.actions = [\n ...step.execution.actions.filter((action) => action.status === 'DONE'),\n ...step.execution.actions.filter((action) => action.status !== 'DONE'),\n ]\n if (\n transactionBefore &&\n changesTransaction(transactionBefore, currentAction)\n ) {\n this.deliverLateTransactionData(step, currentAction)\n } else {\n this.updateStepInRoute(step) // updates the step in the route\n }\n return currentAction\n }\n\n updateStepInRoute = (step: LiFiStep): LiFiStep => {\n if (!this.shouldUpdate) {\n return step\n }\n const data = executionState.get(this.routeId)\n\n if (!data) {\n throw new Error('Execution data not found.')\n }\n\n const stepIndex = data.route.steps.findIndex(\n (routeStep) => routeStep.id === step.id\n )\n\n if (stepIndex === -1) {\n throw new Error(\"Couldn't find a step to update.\")\n }\n\n // A shallow copy on purpose: the route's step must keep sharing the\n // step's `execution` object. `mergeLateTransaction` changes the live\n // route in place, and the running sign task's check after the wallet\n // must see the merge (pinned by the stop-and-resume race test in\n // `sdk-provider-ethereum/src/core/flows/reload.unit.spec.ts`).\n data.route.steps[stepIndex] = { ...data.route.steps[stepIndex], ...step }\n\n data.executionOptions?.updateRouteHook?.(data.route)\n return data.route.steps[stepIndex]\n }\n\n allowUpdates(value: boolean): void {\n this.shouldUpdate = value\n if (value) {\n this.stoppedExecution = undefined\n return\n }\n // `stopRouteExecution` turns updates off right before it deletes the\n // execution state, so the state is still here to keep.\n const data = executionState.get(this.routeId)\n if (data) {\n this.stoppedExecution = {\n route: data.route,\n updateRouteHook: data.executionOptions?.updateRouteHook,\n startCount: executionState.startCount(this.routeId),\n }\n }\n }\n\n /**\n * A write of transaction data after `stopRouteExecution`. With a newer\n * execution of the same route id running, the transaction is merged into\n * it. If no execution of the route started since the stop, the kept route\n * is updated and the kept hook is called. If a newer execution started and\n * ended since the stop, the transaction is merged into the route of the\n * last ended execution, and its hook is called.\n */\n private deliverLateTransactionData(\n step: LiFiStepExtended,\n lateAction: ExecutionAction\n ): void {\n const stopped = this.stoppedExecution\n if (!stopped) {\n return\n }\n // A late write must never fail the task that made it: its catch block\n // would mark the action FAILED while the transaction may still land.\n try {\n // Always a newer execution: `stopRouteExecution` deleted this one.\n const live = executionState.get(this.routeId)\n if (live) {\n if (mergeLateTransaction(live.route, step, lateAction)) {\n live.executionOptions?.updateRouteHook?.(live.route)\n }\n return\n }\n // A newer execution started and ended since the stop: the integrator\n // stored its route, which the kept one would roll back. The late\n // transaction goes into that route instead. With the records of the\n // route freed (no run in flight, `startCount` 0) the write is dropped.\n if (executionState.startCount(this.routeId) !== stopped.startCount) {\n const ended = executionState.lastEnded(this.routeId)\n if (ended && mergeLateTransaction(ended.route, step, lateAction)) {\n ended.updateRouteHook?.(ended.route)\n }\n return\n }\n const stepIndex = stopped.route.steps.findIndex(\n (routeStep) => routeStep.id === step.id\n )\n if (stepIndex === -1) {\n return\n }\n stopped.route.steps[stepIndex] = {\n ...stopped.route.steps[stepIndex],\n ...step,\n }\n stopped.updateRouteHook?.(stopped.route)\n } catch (error) {\n // Not rethrown, see above. The integrator's hook can throw here, so\n // the error is reported in development, as other swallowed errors are.\n if (process.env.NODE_ENV === 'development') {\n console.debug('Delivering late transaction data failed.', error)\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;AA6CA,MAAM,mBAAmB;CAAC;CAAU;CAAS;CAAU;AAAS;AAOhE,MAAM,mBAAmB,YAAgD;CACvE,QAAQ,OAAO;CACf,OAAO,OAAO;CACd,QAAQ,OAAO;CACf,SAAS,OAAO;AAClB;;AAGA,MAAM,sBACJ,QACA,WACY,iBAAiB,MAAM,QAAQ,OAAO,SAAS,OAAO,IAAI;;;;;;;AAQxE,MAAM,wBACJ,WACA,UACA,eACY;CAEZ,IAAI,CAAC,mBAAmB,UAAU,GAChC,OAAO;CAET,MAAM,WAAW,UAAU,MAAM,MAC9B,cAAc,UAAU,OAAO,SAAS,EAC3C;CACA,IAAI,CAAC,UACH,OAAO;CAET,IAAI,CAAC,SAAS,WACZ,SAAS,YAAY;EACnB,WAAW,KAAK,IAAI;EACpB,QAAQ;EACR,SAAS,CAAC,gBAAgB,UAAU,CAAC;CACvC;MACK;EACL,MAAM,aAAa,SAAS,UAAU,QAAQ,MAC3C,WAAW,OAAO,SAAS,WAAW,IACzC;EACA,IAAI,CAAC,YACH,SAAS,UAAU,QAAQ,KAAK,gBAAgB,UAAU,CAAC;OACtD,IAAI,mBAAmB,UAAU,GAGtC,OAAO;OAKP,OAAO,OAAO,YAAY;GACxB,QAAQ,WAAW;GACnB,QAAQ,WAAW;GACnB,OAAO,WAAW;GAClB,SAAS,WAAW;GACpB,QAAQ,WAAW;GACnB,WAAW,WAAW;GACtB,QAAQ,WAAW;EACrB,CAAC;CAEL;CAGA,MAAM,WAAW,SAAS,WAAW;CACrC,IACE,yBAAyB,SAAS,WAAW,IAAI,KACjD,aAAa,KAAA,GAEb,SAAS,UAAU,WAAW;CAEhC,OAAO;AACT;;;;AAKA,IAAa,gBAAb,MAA2B;CACzB;CACA,eAAuB;CACvB;CAEA,YAAY,SAA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aAAa,eAC3B,QAAQ,MAAM,4CAA4C,KAAK;EAEnE;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.d.ts","names":[],"sources":["../../../src/core/execution.ts"],"mappings":";;;;;;;;;;;qBAqBa,eACX,QAAQ,WACR,OAAO,OACP,mBAAmB,qBAClB,QAAQ;;;;;;;;;qBA4BE,cACX,QAAQ,WACR,OAAO,OACP,mBAAmB,qBAClB,QAAQ;;;;;;
|
|
1
|
+
{"version":3,"file":"execution.d.ts","names":[],"sources":["../../../src/core/execution.ts"],"mappings":";;;;;;;;;;;qBAqBa,eACX,QAAQ,WACR,OAAO,OACP,mBAAmB,qBAClB,QAAQ;;;;;;;;;qBA4BE,cACX,QAAQ,WACR,OAAO,OACP,mBAAmB,qBAClB,QAAQ;;;;;;qBAoKE,uBACX,OAAO,OACP,SAAS;;;;;;qBA2BE,qBAAsB,OAAO,UAAQ;;;;;qBA4BrC,uBAAsB;;;;;;qBAWtB,iBAAkB,oBAAkB"}
|