@lifi/sdk-provider-solana 4.3.0 → 4.3.1
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 +8 -0
- package/dist/cjs/confirmation/abortableSleep.d.ts +4 -6
- package/dist/cjs/confirmation/abortableSleep.js +4 -6
- package/dist/cjs/confirmation/abortableSleep.js.map +1 -1
- package/dist/cjs/errors/parseSolanaErrors.js +9 -0
- package/dist/cjs/errors/parseSolanaErrors.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/confirmation/abortableSleep.d.ts +4 -6
- package/dist/esm/confirmation/abortableSleep.d.ts.map +1 -1
- package/dist/esm/confirmation/abortableSleep.js +4 -6
- package/dist/esm/confirmation/abortableSleep.js.map +1 -1
- package/dist/esm/errors/parseSolanaErrors.js +9 -0
- package/dist/esm/errors/parseSolanaErrors.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/confirmation/abortableSleep.ts +4 -6
- package/src/errors/parseSolanaErrors.ts +22 -0
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @lifi/sdk-provider-solana
|
|
2
2
|
|
|
3
|
+
## 4.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#499](https://github.com/lifinance/sdk/pull/499) [`2d60ab4`](https://github.com/lifinance/sdk/commit/2d60ab43af2ecd1c17a3bbb126de408952a46d80) Thanks [@chybisov](https://github.com/chybisov)! - A user rejection from a Wallet Standard wallet (code `4001`, or a message such as "User rejected the request") is now reported as `SignatureRejected` instead of `UnknownError`. An `AbortError` is not treated as a rejection.
|
|
8
|
+
- Updated dependencies [[`dcbbdcc`](https://github.com/lifinance/sdk/commit/dcbbdccc2684c4549cbfe06444698f11347206af), [`2d60ab4`](https://github.com/lifinance/sdk/commit/2d60ab43af2ecd1c17a3bbb126de408952a46d80), [`2d60ab4`](https://github.com/lifinance/sdk/commit/2d60ab43af2ecd1c17a3bbb126de408952a46d80), [`2d60ab4`](https://github.com/lifinance/sdk/commit/2d60ab43af2ecd1c17a3bbb126de408952a46d80), [`2d60ab4`](https://github.com/lifinance/sdk/commit/2d60ab43af2ecd1c17a3bbb126de408952a46d80), [`2d60ab4`](https://github.com/lifinance/sdk/commit/2d60ab43af2ecd1c17a3bbb126de408952a46d80)]:
|
|
9
|
+
- @lifi/sdk@4.10.0
|
|
10
|
+
|
|
3
11
|
## 4.3.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -2,16 +2,14 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Sleeps for `ms`, or until `signal` aborts - whichever comes first.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* timer abortable or unref'd would change behaviour for every caller in the
|
|
7
|
-
* repo. The confirmation branches need the abort, because both detached loops
|
|
5
|
+
* The confirmation branches need the abort, because both detached loops
|
|
8
6
|
* here sleep between iterations and a plain timer stays alive for the whole
|
|
9
7
|
* interval after the branch has already returned - one live timer per RPC,
|
|
10
8
|
* holding the Node event loop open past the end of a race.
|
|
11
9
|
*
|
|
12
|
-
* Never rejects on abort
|
|
13
|
-
*
|
|
14
|
-
* catch to every call site.
|
|
10
|
+
* Never rejects on abort, unlike `@lifi/sdk`'s `sleep(ms, { signal })`. The
|
|
11
|
+
* callers re-check `signal.aborted` and exit through their own loop
|
|
12
|
+
* condition, so a rejection here would only add a catch to every call site.
|
|
15
13
|
*/
|
|
16
14
|
export declare function abortableSleep(ms: number, signal: AbortSignal): Promise<void>;
|
|
17
15
|
//#endregion
|
|
@@ -3,16 +3,14 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
/**
|
|
4
4
|
* Sleeps for `ms`, or until `signal` aborts - whichever comes first.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* timer abortable or unref'd would change behaviour for every caller in the
|
|
8
|
-
* repo. The confirmation branches need the abort, because both detached loops
|
|
6
|
+
* The confirmation branches need the abort, because both detached loops
|
|
9
7
|
* here sleep between iterations and a plain timer stays alive for the whole
|
|
10
8
|
* interval after the branch has already returned - one live timer per RPC,
|
|
11
9
|
* holding the Node event loop open past the end of a race.
|
|
12
10
|
*
|
|
13
|
-
* Never rejects on abort
|
|
14
|
-
*
|
|
15
|
-
* catch to every call site.
|
|
11
|
+
* Never rejects on abort, unlike `@lifi/sdk`'s `sleep(ms, { signal })`. The
|
|
12
|
+
* callers re-check `signal.aborted` and exit through their own loop
|
|
13
|
+
* condition, so a rejection here would only add a catch to every call site.
|
|
16
14
|
*/
|
|
17
15
|
function abortableSleep(ms, signal) {
|
|
18
16
|
if (signal.aborted) return Promise.resolve();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abortableSleep.js","names":[],"sources":["../../../src/confirmation/abortableSleep.ts"],"sourcesContent":["/**\n * Sleeps for `ms`, or until `signal` aborts - whichever comes first.\n *\n *
|
|
1
|
+
{"version":3,"file":"abortableSleep.js","names":[],"sources":["../../../src/confirmation/abortableSleep.ts"],"sourcesContent":["/**\n * Sleeps for `ms`, or until `signal` aborts - whichever comes first.\n *\n * The confirmation branches need the abort, because both detached loops\n * here sleep between iterations and a plain timer stays alive for the whole\n * interval after the branch has already returned - one live timer per RPC,\n * holding the Node event loop open past the end of a race.\n *\n * Never rejects on abort, unlike `@lifi/sdk`'s `sleep(ms, { signal })`. The\n * callers re-check `signal.aborted` and exit through their own loop\n * condition, so a rejection here would only add a catch to every call site.\n */\nexport function abortableSleep(ms: number, signal: AbortSignal): Promise<void> {\n if (signal.aborted) {\n return Promise.resolve()\n }\n\n return new Promise<void>((resolve) => {\n const settle = (): void => {\n clearTimeout(timer)\n signal.removeEventListener('abort', settle)\n resolve()\n }\n\n const timer = setTimeout(settle, ms)\n signal.addEventListener('abort', settle, { once: true })\n })\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,SAAgB,eAAe,IAAY,QAAoC;CAC7E,IAAI,OAAO,SACT,OAAO,QAAQ,QAAQ;CAGzB,OAAO,IAAI,SAAe,YAAY;EACpC,MAAM,eAAqB;GACzB,aAAa,KAAK;GAClB,OAAO,oBAAoB,SAAS,MAAM;GAC1C,QAAQ;EACV;EAEA,MAAM,QAAQ,WAAW,QAAQ,EAAE;EACnC,OAAO,iBAAiB,SAAS,QAAQ,EAAE,MAAM,KAAK,CAAC;CACzD,CAAC;AACH"}
|
|
@@ -10,10 +10,19 @@ const parseSolanaErrors = async (e, step, action) => {
|
|
|
10
10
|
const baseError = handleSpecificErrors(e);
|
|
11
11
|
return new _lifi_sdk.SDKError(baseError, step, action);
|
|
12
12
|
};
|
|
13
|
+
const userRejectionMessage = /(^|\W)user\W+(has\W+)?(rejected|denied|cancell?ed)|\b(rejected|denied|cancell?ed)\W+by\W+(the\W+)?user\b/i;
|
|
14
|
+
/**
|
|
15
|
+
* The SDK calls the Wallet Standard features directly, so a wallet's own error
|
|
16
|
+
* arrives here unwrapped. Wallets report a rejection with the EIP-1193 code
|
|
17
|
+
* 4001 or only with a message. An `AbortError` is not a rejection: nothing
|
|
18
|
+
* says the user caused it. The SDK's own errors keep their code.
|
|
19
|
+
*/
|
|
20
|
+
const isUserRejection = (e) => !(e instanceof _lifi_sdk.BaseError) && (e.code === 4001 || typeof e.message === "string" && userRejectionMessage.test(e.message));
|
|
13
21
|
const handleSpecificErrors = (e) => {
|
|
14
22
|
if (e.name === "WalletSignTransactionError") return new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.SignatureRejected, e.message, e);
|
|
15
23
|
if (e.name === "SendTransactionError") return new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionFailed, e.message, e);
|
|
16
24
|
if (e.name === "TransactionExpiredBlockheightExceededError") return new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionExpired, e.message, e);
|
|
25
|
+
if (isUserRejection(e)) return new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.SignatureRejected, e.message, e);
|
|
17
26
|
if (e.message?.includes("simulate")) return new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionSimulationFailed, e.message, e);
|
|
18
27
|
if (e instanceof _lifi_sdk.BaseError) return e;
|
|
19
28
|
return new _lifi_sdk.UnknownError(e.message || _lifi_sdk.ErrorMessage.UnknownError, e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseSolanaErrors.js","names":["SDKError","
|
|
1
|
+
{"version":3,"file":"parseSolanaErrors.js","names":["SDKError","BaseError","TransactionError","LiFiErrorCode","UnknownError","ErrorMessage"],"sources":["../../../src/errors/parseSolanaErrors.ts"],"sourcesContent":["import {\n BaseError,\n ErrorMessage,\n type ExecutionAction,\n LiFiErrorCode,\n type LiFiStep,\n SDKError,\n TransactionError,\n UnknownError,\n} from '@lifi/sdk'\n\nexport const parseSolanaErrors = async (\n e: Error,\n step?: LiFiStep,\n action?: ExecutionAction\n): Promise<SDKError> => {\n if (e instanceof SDKError) {\n e.step = e.step ?? step\n e.action = e.action ?? action\n return e\n }\n\n const baseError = handleSpecificErrors(e)\n\n return new SDKError(baseError, step, action)\n}\n\n// Same pattern as bigmi's `isUserRejection`. It is anchored on \"user\", so a\n// refusal by a node or a host does not count as a rejection.\nconst userRejectionMessage =\n /(^|\\W)user\\W+(has\\W+)?(rejected|denied|cancell?ed)|\\b(rejected|denied|cancell?ed)\\W+by\\W+(the\\W+)?user\\b/i\n\n/**\n * The SDK calls the Wallet Standard features directly, so a wallet's own error\n * arrives here unwrapped. Wallets report a rejection with the EIP-1193 code\n * 4001 or only with a message. An `AbortError` is not a rejection: nothing\n * says the user caused it. The SDK's own errors keep their code.\n */\nconst isUserRejection = (e: any): boolean =>\n !(e instanceof BaseError) &&\n (e.code === 4001 ||\n (typeof e.message === 'string' && userRejectionMessage.test(e.message)))\n\nconst handleSpecificErrors = (e: any) => {\n if (e.name === 'WalletSignTransactionError') {\n return new TransactionError(LiFiErrorCode.SignatureRejected, e.message, e)\n }\n\n if (e.name === 'SendTransactionError') {\n return new TransactionError(LiFiErrorCode.TransactionFailed, e.message, e)\n }\n\n if (e.name === 'TransactionExpiredBlockheightExceededError') {\n return new TransactionError(LiFiErrorCode.TransactionExpired, e.message, e)\n }\n\n // After the name checks: a known error keeps its code, even when its\n // message quotes program logs that look like a rejection.\n if (isUserRejection(e)) {\n return new TransactionError(LiFiErrorCode.SignatureRejected, e.message, e)\n }\n\n if (e.message?.includes('simulate')) {\n return new TransactionError(\n LiFiErrorCode.TransactionSimulationFailed,\n e.message,\n e\n )\n }\n\n if (e instanceof BaseError) {\n return e\n }\n\n return new UnknownError(e.message || ErrorMessage.UnknownError, e)\n}\n"],"mappings":";;;AAWA,MAAa,oBAAoB,OAC/B,GACA,MACA,WACsB;CACtB,IAAI,aAAaA,UAAAA,UAAU;EACzB,EAAE,OAAO,EAAE,QAAQ;EACnB,EAAE,SAAS,EAAE,UAAU;EACvB,OAAO;CACT;CAEA,MAAM,YAAY,qBAAqB,CAAC;CAExC,OAAO,IAAIA,UAAAA,SAAS,WAAW,MAAM,MAAM;AAC7C;AAIA,MAAM,uBACJ;;;;;;;AAQF,MAAM,mBAAmB,MACvB,EAAE,aAAaC,UAAAA,eACd,EAAE,SAAS,QACT,OAAO,EAAE,YAAY,YAAY,qBAAqB,KAAK,EAAE,OAAO;AAEzE,MAAM,wBAAwB,MAAW;CACvC,IAAI,EAAE,SAAS,8BACb,OAAO,IAAIC,UAAAA,iBAAiBC,UAAAA,cAAc,mBAAmB,EAAE,SAAS,CAAC;CAG3E,IAAI,EAAE,SAAS,wBACb,OAAO,IAAID,UAAAA,iBAAiBC,UAAAA,cAAc,mBAAmB,EAAE,SAAS,CAAC;CAG3E,IAAI,EAAE,SAAS,8CACb,OAAO,IAAID,UAAAA,iBAAiBC,UAAAA,cAAc,oBAAoB,EAAE,SAAS,CAAC;CAK5E,IAAI,gBAAgB,CAAC,GACnB,OAAO,IAAID,UAAAA,iBAAiBC,UAAAA,cAAc,mBAAmB,EAAE,SAAS,CAAC;CAG3E,IAAI,EAAE,SAAS,SAAS,UAAU,GAChC,OAAO,IAAID,UAAAA,iBACTC,UAAAA,cAAc,6BACd,EAAE,SACF,CACF;CAGF,IAAI,aAAaF,UAAAA,WACf,OAAO;CAGT,OAAO,IAAIG,UAAAA,aAAa,EAAE,WAAWC,UAAAA,aAAa,cAAc,CAAC;AACnE"}
|
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-provider-solana'\nexport const version = '4.3.
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-solana'\nexport const version = '4.3.1'\n"],"mappings":";;AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
|
|
@@ -2,16 +2,14 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Sleeps for `ms`, or until `signal` aborts - whichever comes first.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* timer abortable or unref'd would change behaviour for every caller in the
|
|
7
|
-
* repo. The confirmation branches need the abort, because both detached loops
|
|
5
|
+
* The confirmation branches need the abort, because both detached loops
|
|
8
6
|
* here sleep between iterations and a plain timer stays alive for the whole
|
|
9
7
|
* interval after the branch has already returned - one live timer per RPC,
|
|
10
8
|
* holding the Node event loop open past the end of a race.
|
|
11
9
|
*
|
|
12
|
-
* Never rejects on abort
|
|
13
|
-
*
|
|
14
|
-
* catch to every call site.
|
|
10
|
+
* Never rejects on abort, unlike `@lifi/sdk`'s `sleep(ms, { signal })`. The
|
|
11
|
+
* callers re-check `signal.aborted` and exit through their own loop
|
|
12
|
+
* condition, so a rejection here would only add a catch to every call site.
|
|
15
13
|
*/
|
|
16
14
|
export declare function abortableSleep(ms: number, signal: AbortSignal): Promise<void>;
|
|
17
15
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abortableSleep.d.ts","names":[],"sources":["../../../src/confirmation/abortableSleep.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"abortableSleep.d.ts","names":[],"sources":["../../../src/confirmation/abortableSleep.ts"],"mappings":";;;;;;;;;;;;;wBAYgB,eAAe,YAAY,QAAQ,cAAc"}
|
|
@@ -2,16 +2,14 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Sleeps for `ms`, or until `signal` aborts - whichever comes first.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* timer abortable or unref'd would change behaviour for every caller in the
|
|
7
|
-
* repo. The confirmation branches need the abort, because both detached loops
|
|
5
|
+
* The confirmation branches need the abort, because both detached loops
|
|
8
6
|
* here sleep between iterations and a plain timer stays alive for the whole
|
|
9
7
|
* interval after the branch has already returned - one live timer per RPC,
|
|
10
8
|
* holding the Node event loop open past the end of a race.
|
|
11
9
|
*
|
|
12
|
-
* Never rejects on abort
|
|
13
|
-
*
|
|
14
|
-
* catch to every call site.
|
|
10
|
+
* Never rejects on abort, unlike `@lifi/sdk`'s `sleep(ms, { signal })`. The
|
|
11
|
+
* callers re-check `signal.aborted` and exit through their own loop
|
|
12
|
+
* condition, so a rejection here would only add a catch to every call site.
|
|
15
13
|
*/
|
|
16
14
|
function abortableSleep(ms, signal) {
|
|
17
15
|
if (signal.aborted) return Promise.resolve();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abortableSleep.js","names":[],"sources":["../../../src/confirmation/abortableSleep.ts"],"sourcesContent":["/**\n * Sleeps for `ms`, or until `signal` aborts - whichever comes first.\n *\n *
|
|
1
|
+
{"version":3,"file":"abortableSleep.js","names":[],"sources":["../../../src/confirmation/abortableSleep.ts"],"sourcesContent":["/**\n * Sleeps for `ms`, or until `signal` aborts - whichever comes first.\n *\n * The confirmation branches need the abort, because both detached loops\n * here sleep between iterations and a plain timer stays alive for the whole\n * interval after the branch has already returned - one live timer per RPC,\n * holding the Node event loop open past the end of a race.\n *\n * Never rejects on abort, unlike `@lifi/sdk`'s `sleep(ms, { signal })`. The\n * callers re-check `signal.aborted` and exit through their own loop\n * condition, so a rejection here would only add a catch to every call site.\n */\nexport function abortableSleep(ms: number, signal: AbortSignal): Promise<void> {\n if (signal.aborted) {\n return Promise.resolve()\n }\n\n return new Promise<void>((resolve) => {\n const settle = (): void => {\n clearTimeout(timer)\n signal.removeEventListener('abort', settle)\n resolve()\n }\n\n const timer = setTimeout(settle, ms)\n signal.addEventListener('abort', settle, { once: true })\n })\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,SAAgB,eAAe,IAAY,QAAoC;CAC7E,IAAI,OAAO,SACT,OAAO,QAAQ,QAAQ;CAGzB,OAAO,IAAI,SAAe,YAAY;EACpC,MAAM,eAAqB;GACzB,aAAa,KAAK;GAClB,OAAO,oBAAoB,SAAS,MAAM;GAC1C,QAAQ;EACV;EAEA,MAAM,QAAQ,WAAW,QAAQ,EAAE;EACnC,OAAO,iBAAiB,SAAS,QAAQ,EAAE,MAAM,KAAK,CAAC;CACzD,CAAC;AACH"}
|
|
@@ -9,10 +9,19 @@ const parseSolanaErrors = async (e, step, action) => {
|
|
|
9
9
|
const baseError = handleSpecificErrors(e);
|
|
10
10
|
return new SDKError(baseError, step, action);
|
|
11
11
|
};
|
|
12
|
+
const userRejectionMessage = /(^|\W)user\W+(has\W+)?(rejected|denied|cancell?ed)|\b(rejected|denied|cancell?ed)\W+by\W+(the\W+)?user\b/i;
|
|
13
|
+
/**
|
|
14
|
+
* The SDK calls the Wallet Standard features directly, so a wallet's own error
|
|
15
|
+
* arrives here unwrapped. Wallets report a rejection with the EIP-1193 code
|
|
16
|
+
* 4001 or only with a message. An `AbortError` is not a rejection: nothing
|
|
17
|
+
* says the user caused it. The SDK's own errors keep their code.
|
|
18
|
+
*/
|
|
19
|
+
const isUserRejection = (e) => !(e instanceof BaseError) && (e.code === 4001 || typeof e.message === "string" && userRejectionMessage.test(e.message));
|
|
12
20
|
const handleSpecificErrors = (e) => {
|
|
13
21
|
if (e.name === "WalletSignTransactionError") return new TransactionError(LiFiErrorCode.SignatureRejected, e.message, e);
|
|
14
22
|
if (e.name === "SendTransactionError") return new TransactionError(LiFiErrorCode.TransactionFailed, e.message, e);
|
|
15
23
|
if (e.name === "TransactionExpiredBlockheightExceededError") return new TransactionError(LiFiErrorCode.TransactionExpired, e.message, e);
|
|
24
|
+
if (isUserRejection(e)) return new TransactionError(LiFiErrorCode.SignatureRejected, e.message, e);
|
|
16
25
|
if (e.message?.includes("simulate")) return new TransactionError(LiFiErrorCode.TransactionSimulationFailed, e.message, e);
|
|
17
26
|
if (e instanceof BaseError) return e;
|
|
18
27
|
return new UnknownError(e.message || ErrorMessage.UnknownError, e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseSolanaErrors.js","names":[],"sources":["../../../src/errors/parseSolanaErrors.ts"],"sourcesContent":["import {\n BaseError,\n ErrorMessage,\n type ExecutionAction,\n LiFiErrorCode,\n type LiFiStep,\n SDKError,\n TransactionError,\n UnknownError,\n} from '@lifi/sdk'\n\nexport const parseSolanaErrors = async (\n e: Error,\n step?: LiFiStep,\n action?: ExecutionAction\n): Promise<SDKError> => {\n if (e instanceof SDKError) {\n e.step = e.step ?? step\n e.action = e.action ?? action\n return e\n }\n\n const baseError = handleSpecificErrors(e)\n\n return new SDKError(baseError, step, action)\n}\n\nconst handleSpecificErrors = (e: any) => {\n if (e.name === 'WalletSignTransactionError') {\n return new TransactionError(LiFiErrorCode.SignatureRejected, e.message, e)\n }\n\n if (e.name === 'SendTransactionError') {\n return new TransactionError(LiFiErrorCode.TransactionFailed, e.message, e)\n }\n\n if (e.name === 'TransactionExpiredBlockheightExceededError') {\n return new TransactionError(LiFiErrorCode.TransactionExpired, e.message, e)\n }\n\n if (e.message?.includes('simulate')) {\n return new TransactionError(\n LiFiErrorCode.TransactionSimulationFailed,\n e.message,\n e\n )\n }\n\n if (e instanceof BaseError) {\n return e\n }\n\n return new UnknownError(e.message || ErrorMessage.UnknownError, e)\n}\n"],"mappings":";;AAWA,MAAa,oBAAoB,OAC/B,GACA,MACA,WACsB;CACtB,IAAI,aAAa,UAAU;EACzB,EAAE,OAAO,EAAE,QAAQ;EACnB,EAAE,SAAS,EAAE,UAAU;EACvB,OAAO;CACT;CAEA,MAAM,YAAY,qBAAqB,CAAC;CAExC,OAAO,IAAI,SAAS,WAAW,MAAM,MAAM;AAC7C;
|
|
1
|
+
{"version":3,"file":"parseSolanaErrors.js","names":[],"sources":["../../../src/errors/parseSolanaErrors.ts"],"sourcesContent":["import {\n BaseError,\n ErrorMessage,\n type ExecutionAction,\n LiFiErrorCode,\n type LiFiStep,\n SDKError,\n TransactionError,\n UnknownError,\n} from '@lifi/sdk'\n\nexport const parseSolanaErrors = async (\n e: Error,\n step?: LiFiStep,\n action?: ExecutionAction\n): Promise<SDKError> => {\n if (e instanceof SDKError) {\n e.step = e.step ?? step\n e.action = e.action ?? action\n return e\n }\n\n const baseError = handleSpecificErrors(e)\n\n return new SDKError(baseError, step, action)\n}\n\n// Same pattern as bigmi's `isUserRejection`. It is anchored on \"user\", so a\n// refusal by a node or a host does not count as a rejection.\nconst userRejectionMessage =\n /(^|\\W)user\\W+(has\\W+)?(rejected|denied|cancell?ed)|\\b(rejected|denied|cancell?ed)\\W+by\\W+(the\\W+)?user\\b/i\n\n/**\n * The SDK calls the Wallet Standard features directly, so a wallet's own error\n * arrives here unwrapped. Wallets report a rejection with the EIP-1193 code\n * 4001 or only with a message. An `AbortError` is not a rejection: nothing\n * says the user caused it. The SDK's own errors keep their code.\n */\nconst isUserRejection = (e: any): boolean =>\n !(e instanceof BaseError) &&\n (e.code === 4001 ||\n (typeof e.message === 'string' && userRejectionMessage.test(e.message)))\n\nconst handleSpecificErrors = (e: any) => {\n if (e.name === 'WalletSignTransactionError') {\n return new TransactionError(LiFiErrorCode.SignatureRejected, e.message, e)\n }\n\n if (e.name === 'SendTransactionError') {\n return new TransactionError(LiFiErrorCode.TransactionFailed, e.message, e)\n }\n\n if (e.name === 'TransactionExpiredBlockheightExceededError') {\n return new TransactionError(LiFiErrorCode.TransactionExpired, e.message, e)\n }\n\n // After the name checks: a known error keeps its code, even when its\n // message quotes program logs that look like a rejection.\n if (isUserRejection(e)) {\n return new TransactionError(LiFiErrorCode.SignatureRejected, e.message, e)\n }\n\n if (e.message?.includes('simulate')) {\n return new TransactionError(\n LiFiErrorCode.TransactionSimulationFailed,\n e.message,\n e\n )\n }\n\n if (e instanceof BaseError) {\n return e\n }\n\n return new UnknownError(e.message || ErrorMessage.UnknownError, e)\n}\n"],"mappings":";;AAWA,MAAa,oBAAoB,OAC/B,GACA,MACA,WACsB;CACtB,IAAI,aAAa,UAAU;EACzB,EAAE,OAAO,EAAE,QAAQ;EACnB,EAAE,SAAS,EAAE,UAAU;EACvB,OAAO;CACT;CAEA,MAAM,YAAY,qBAAqB,CAAC;CAExC,OAAO,IAAI,SAAS,WAAW,MAAM,MAAM;AAC7C;AAIA,MAAM,uBACJ;;;;;;;AAQF,MAAM,mBAAmB,MACvB,EAAE,aAAa,eACd,EAAE,SAAS,QACT,OAAO,EAAE,YAAY,YAAY,qBAAqB,KAAK,EAAE,OAAO;AAEzE,MAAM,wBAAwB,MAAW;CACvC,IAAI,EAAE,SAAS,8BACb,OAAO,IAAI,iBAAiB,cAAc,mBAAmB,EAAE,SAAS,CAAC;CAG3E,IAAI,EAAE,SAAS,wBACb,OAAO,IAAI,iBAAiB,cAAc,mBAAmB,EAAE,SAAS,CAAC;CAG3E,IAAI,EAAE,SAAS,8CACb,OAAO,IAAI,iBAAiB,cAAc,oBAAoB,EAAE,SAAS,CAAC;CAK5E,IAAI,gBAAgB,CAAC,GACnB,OAAO,IAAI,iBAAiB,cAAc,mBAAmB,EAAE,SAAS,CAAC;CAG3E,IAAI,EAAE,SAAS,SAAS,UAAU,GAChC,OAAO,IAAI,iBACT,cAAc,6BACd,EAAE,SACF,CACF;CAGF,IAAI,aAAa,WACf,OAAO;CAGT,OAAO,IAAI,aAAa,EAAE,WAAW,aAAa,cAAc,CAAC;AACnE"}
|
package/dist/esm/version.d.ts
CHANGED
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-solana'\nexport const version = '4.3.
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-solana'\nexport const version = '4.3.1'\n"],"mappings":";AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/sdk-provider-solana",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.1",
|
|
4
4
|
"description": "LI.FI Solana SDK Provider for Any-to-Any Cross-Chain-Swap",
|
|
5
5
|
"homepage": "https://github.com/lifinance/sdk",
|
|
6
6
|
"bugs": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"./package.json": "./package.json"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@lifi/sdk": "4.
|
|
31
|
+
"@lifi/sdk": "4.10.0",
|
|
32
32
|
"@solana/kit": "^8.3.0",
|
|
33
33
|
"@solana/wallet-standard-features": "^1.5.0",
|
|
34
34
|
"@wallet-standard/base": "^1.1.1"
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Sleeps for `ms`, or until `signal` aborts - whichever comes first.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* timer abortable or unref'd would change behaviour for every caller in the
|
|
6
|
-
* repo. The confirmation branches need the abort, because both detached loops
|
|
4
|
+
* The confirmation branches need the abort, because both detached loops
|
|
7
5
|
* here sleep between iterations and a plain timer stays alive for the whole
|
|
8
6
|
* interval after the branch has already returned - one live timer per RPC,
|
|
9
7
|
* holding the Node event loop open past the end of a race.
|
|
10
8
|
*
|
|
11
|
-
* Never rejects on abort
|
|
12
|
-
*
|
|
13
|
-
* catch to every call site.
|
|
9
|
+
* Never rejects on abort, unlike `@lifi/sdk`'s `sleep(ms, { signal })`. The
|
|
10
|
+
* callers re-check `signal.aborted` and exit through their own loop
|
|
11
|
+
* condition, so a rejection here would only add a catch to every call site.
|
|
14
12
|
*/
|
|
15
13
|
export function abortableSleep(ms: number, signal: AbortSignal): Promise<void> {
|
|
16
14
|
if (signal.aborted) {
|
|
@@ -25,6 +25,22 @@ export const parseSolanaErrors = async (
|
|
|
25
25
|
return new SDKError(baseError, step, action)
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
// Same pattern as bigmi's `isUserRejection`. It is anchored on "user", so a
|
|
29
|
+
// refusal by a node or a host does not count as a rejection.
|
|
30
|
+
const userRejectionMessage =
|
|
31
|
+
/(^|\W)user\W+(has\W+)?(rejected|denied|cancell?ed)|\b(rejected|denied|cancell?ed)\W+by\W+(the\W+)?user\b/i
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The SDK calls the Wallet Standard features directly, so a wallet's own error
|
|
35
|
+
* arrives here unwrapped. Wallets report a rejection with the EIP-1193 code
|
|
36
|
+
* 4001 or only with a message. An `AbortError` is not a rejection: nothing
|
|
37
|
+
* says the user caused it. The SDK's own errors keep their code.
|
|
38
|
+
*/
|
|
39
|
+
const isUserRejection = (e: any): boolean =>
|
|
40
|
+
!(e instanceof BaseError) &&
|
|
41
|
+
(e.code === 4001 ||
|
|
42
|
+
(typeof e.message === 'string' && userRejectionMessage.test(e.message)))
|
|
43
|
+
|
|
28
44
|
const handleSpecificErrors = (e: any) => {
|
|
29
45
|
if (e.name === 'WalletSignTransactionError') {
|
|
30
46
|
return new TransactionError(LiFiErrorCode.SignatureRejected, e.message, e)
|
|
@@ -38,6 +54,12 @@ const handleSpecificErrors = (e: any) => {
|
|
|
38
54
|
return new TransactionError(LiFiErrorCode.TransactionExpired, e.message, e)
|
|
39
55
|
}
|
|
40
56
|
|
|
57
|
+
// After the name checks: a known error keeps its code, even when its
|
|
58
|
+
// message quotes program logs that look like a rejection.
|
|
59
|
+
if (isUserRejection(e)) {
|
|
60
|
+
return new TransactionError(LiFiErrorCode.SignatureRejected, e.message, e)
|
|
61
|
+
}
|
|
62
|
+
|
|
41
63
|
if (e.message?.includes('simulate')) {
|
|
42
64
|
return new TransactionError(
|
|
43
65
|
LiFiErrorCode.TransactionSimulationFailed,
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/sdk-provider-solana'
|
|
2
|
-
export const version = '4.3.
|
|
2
|
+
export const version = '4.3.1'
|