@lifi/sdk-provider-solana 4.3.8 → 4.3.9
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 +6 -0
- package/dist/cjs/errors/parseSolanaErrors.js +6 -3
- 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/errors/parseSolanaErrors.js +6 -3
- 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 +1 -1
- package/src/errors/parseSolanaErrors.ts +12 -3
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @lifi/sdk-provider-solana
|
|
2
2
|
|
|
3
|
+
## 4.3.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#555](https://github.com/lifinance/sdk/pull/555) [`e2541bd`](https://github.com/lifinance/sdk/commit/e2541bde4b5fcd6b73d2711644b4aa86216a0362) Thanks [@chybisov](https://github.com/chybisov)! - A wallet error with only the text "Transaction canceled" now gets the code `SignatureRejected` (1012), not `UnknownError` (1000). The SDK already uses this code when the user rejects a sign request. Apps can then show the rejection message and do not report the cancel as a failure.
|
|
8
|
+
|
|
3
9
|
## 4.3.8
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -11,13 +11,16 @@ const parseSolanaErrors = async (e, step, action) => {
|
|
|
11
11
|
return new _lifi_sdk.SDKError(baseError, step, action);
|
|
12
12
|
};
|
|
13
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
|
+
const walletCancelMessage = /^transaction (was )?cancell?ed\.?$/i;
|
|
14
15
|
/**
|
|
15
16
|
* The SDK calls the Wallet Standard features directly, so a wallet's own error
|
|
16
17
|
* arrives here unwrapped. Wallets report a rejection with the EIP-1193 code
|
|
17
|
-
* 4001 or only with a message.
|
|
18
|
-
*
|
|
18
|
+
* 4001 or only with a message. A wallet cancel is a rejection too: the prompt
|
|
19
|
+
* was open and the wallet sent nothing, as with `WalletSignTransactionError`.
|
|
20
|
+
* An `AbortError` is not a rejection: nothing says the user caused it. The
|
|
21
|
+
* SDK's own errors keep their code.
|
|
19
22
|
*/
|
|
20
|
-
const isUserRejection = (e) => !(e instanceof _lifi_sdk.BaseError) && (e.code === 4001 || typeof e.message === "string" && userRejectionMessage.test(e.message));
|
|
23
|
+
const isUserRejection = (e) => !(e instanceof _lifi_sdk.BaseError) && (e.code === 4001 || typeof e.message === "string" && (userRejectionMessage.test(e.message) || walletCancelMessage.test(e.message.trim())));
|
|
21
24
|
const handleSpecificErrors = (e) => {
|
|
22
25
|
if (e.name === "WalletSignTransactionError") return new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.SignatureRejected, e.message, e);
|
|
23
26
|
if (e.name === "SendTransactionError") return new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionFailed, e.message, e);
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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// Some wallets report a Cancel on the sign prompt only with this text (an\n// Android in-app wallet). The whole message must match, so a longer error that\n// starts with these words does not count.\nconst walletCancelMessage = /^transaction (was )?cancell?ed\\.?$/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. A wallet cancel is a rejection too: the prompt\n * was open and the wallet sent nothing, as with `WalletSignTransactionError`.\n * An `AbortError` is not a rejection: nothing says the user caused it. The\n * 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' &&\n (userRejectionMessage.test(e.message) ||\n walletCancelMessage.test(e.message.trim()))))\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;AAKF,MAAM,sBAAsB;;;;;;;;;AAU5B,MAAM,mBAAmB,MACvB,EAAE,aAAaC,UAAAA,eACd,EAAE,SAAS,QACT,OAAO,EAAE,YAAY,aACnB,qBAAqB,KAAK,EAAE,OAAO,KAClC,oBAAoB,KAAK,EAAE,QAAQ,KAAK,CAAC;AAEjD,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
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/sdk-provider-solana";
|
|
2
|
-
export declare const version = "4.3.
|
|
2
|
+
export declare const version = "4.3.9";
|
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.9'\n"],"mappings":";;AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
|
|
@@ -10,13 +10,16 @@ const parseSolanaErrors = async (e, step, action) => {
|
|
|
10
10
|
return new SDKError(baseError, step, action);
|
|
11
11
|
};
|
|
12
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
|
+
const walletCancelMessage = /^transaction (was )?cancell?ed\.?$/i;
|
|
13
14
|
/**
|
|
14
15
|
* The SDK calls the Wallet Standard features directly, so a wallet's own error
|
|
15
16
|
* arrives here unwrapped. Wallets report a rejection with the EIP-1193 code
|
|
16
|
-
* 4001 or only with a message.
|
|
17
|
-
*
|
|
17
|
+
* 4001 or only with a message. A wallet cancel is a rejection too: the prompt
|
|
18
|
+
* was open and the wallet sent nothing, as with `WalletSignTransactionError`.
|
|
19
|
+
* An `AbortError` is not a rejection: nothing says the user caused it. The
|
|
20
|
+
* SDK's own errors keep their code.
|
|
18
21
|
*/
|
|
19
|
-
const isUserRejection = (e) => !(e instanceof BaseError) && (e.code === 4001 || typeof e.message === "string" && userRejectionMessage.test(e.message));
|
|
22
|
+
const isUserRejection = (e) => !(e instanceof BaseError) && (e.code === 4001 || typeof e.message === "string" && (userRejectionMessage.test(e.message) || walletCancelMessage.test(e.message.trim())));
|
|
20
23
|
const handleSpecificErrors = (e) => {
|
|
21
24
|
if (e.name === "WalletSignTransactionError") return new TransactionError(LiFiErrorCode.SignatureRejected, e.message, e);
|
|
22
25
|
if (e.name === "SendTransactionError") return new TransactionError(LiFiErrorCode.TransactionFailed, e.message, 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\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
|
|
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// Some wallets report a Cancel on the sign prompt only with this text (an\n// Android in-app wallet). The whole message must match, so a longer error that\n// starts with these words does not count.\nconst walletCancelMessage = /^transaction (was )?cancell?ed\\.?$/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. A wallet cancel is a rejection too: the prompt\n * was open and the wallet sent nothing, as with `WalletSignTransactionError`.\n * An `AbortError` is not a rejection: nothing says the user caused it. The\n * 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' &&\n (userRejectionMessage.test(e.message) ||\n walletCancelMessage.test(e.message.trim()))))\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;AAKF,MAAM,sBAAsB;;;;;;;;;AAU5B,MAAM,mBAAmB,MACvB,EAAE,aAAa,eACd,EAAE,SAAS,QACT,OAAO,EAAE,YAAY,aACnB,qBAAqB,KAAK,EAAE,OAAO,KAClC,oBAAoB,KAAK,EAAE,QAAQ,KAAK,CAAC;AAEjD,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.9'\n"],"mappings":";AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
|
package/package.json
CHANGED
|
@@ -30,16 +30,25 @@ export const parseSolanaErrors = async (
|
|
|
30
30
|
const userRejectionMessage =
|
|
31
31
|
/(^|\W)user\W+(has\W+)?(rejected|denied|cancell?ed)|\b(rejected|denied|cancell?ed)\W+by\W+(the\W+)?user\b/i
|
|
32
32
|
|
|
33
|
+
// Some wallets report a Cancel on the sign prompt only with this text (an
|
|
34
|
+
// Android in-app wallet). The whole message must match, so a longer error that
|
|
35
|
+
// starts with these words does not count.
|
|
36
|
+
const walletCancelMessage = /^transaction (was )?cancell?ed\.?$/i
|
|
37
|
+
|
|
33
38
|
/**
|
|
34
39
|
* The SDK calls the Wallet Standard features directly, so a wallet's own error
|
|
35
40
|
* arrives here unwrapped. Wallets report a rejection with the EIP-1193 code
|
|
36
|
-
* 4001 or only with a message.
|
|
37
|
-
*
|
|
41
|
+
* 4001 or only with a message. A wallet cancel is a rejection too: the prompt
|
|
42
|
+
* was open and the wallet sent nothing, as with `WalletSignTransactionError`.
|
|
43
|
+
* An `AbortError` is not a rejection: nothing says the user caused it. The
|
|
44
|
+
* SDK's own errors keep their code.
|
|
38
45
|
*/
|
|
39
46
|
const isUserRejection = (e: any): boolean =>
|
|
40
47
|
!(e instanceof BaseError) &&
|
|
41
48
|
(e.code === 4001 ||
|
|
42
|
-
(typeof e.message === 'string' &&
|
|
49
|
+
(typeof e.message === 'string' &&
|
|
50
|
+
(userRejectionMessage.test(e.message) ||
|
|
51
|
+
walletCancelMessage.test(e.message.trim()))))
|
|
43
52
|
|
|
44
53
|
const handleSpecificErrors = (e: any) => {
|
|
45
54
|
if (e.name === 'WalletSignTransactionError') {
|
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.9'
|