@getpara/viem-v2-integration 2.18.0 → 2.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/aa/index.js +15 -2
- package/dist/cjs/aa/types.js +2 -13
- package/dist/cjs/aa/utils.js +4 -4
- package/dist/esm/aa/index.js +8 -1
- package/dist/esm/aa/types.js +1 -12
- package/dist/esm/aa/utils.js +1 -1
- package/dist/types/aa/index.d.ts +2 -1
- package/dist/types/aa/types.d.ts +4 -21
- package/package.json +3 -3
- package/dist/cjs/aa/errors.js +0 -105
- package/dist/esm/aa/errors.js +0 -80
- package/dist/types/aa/errors.d.ts +0 -22
package/dist/cjs/aa/index.js
CHANGED
|
@@ -2,6 +2,10 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
5
9
|
var __copyProps = (to, from, except, desc) => {
|
|
6
10
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
11
|
for (let key of __getOwnPropNames(from))
|
|
@@ -13,13 +17,22 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
13
17
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
19
|
var aa_exports = {};
|
|
20
|
+
__export(aa_exports, {
|
|
21
|
+
SMART_ACCOUNT_ERROR_CODES: () => import_core_sdk.SMART_ACCOUNT_ERROR_CODES,
|
|
22
|
+
SmartAccountError: () => import_core_sdk.SmartAccountError,
|
|
23
|
+
classifyProviderError: () => import_core_sdk.classifyProviderError,
|
|
24
|
+
wrapProviderError: () => import_core_sdk.wrapProviderError
|
|
25
|
+
});
|
|
16
26
|
module.exports = __toCommonJS(aa_exports);
|
|
17
27
|
__reExport(aa_exports, require("./types.js"), module.exports);
|
|
18
|
-
__reExport(aa_exports, require("./errors.js"), module.exports);
|
|
19
28
|
__reExport(aa_exports, require("./utils.js"), module.exports);
|
|
29
|
+
var import_core_sdk = require("@getpara/core-sdk");
|
|
20
30
|
// Annotate the CommonJS export names for ESM import in node:
|
|
21
31
|
0 && (module.exports = {
|
|
32
|
+
SMART_ACCOUNT_ERROR_CODES,
|
|
33
|
+
SmartAccountError,
|
|
34
|
+
classifyProviderError,
|
|
35
|
+
wrapProviderError,
|
|
22
36
|
...require("./types.js"),
|
|
23
|
-
...require("./errors.js"),
|
|
24
37
|
...require("./utils.js")
|
|
25
38
|
});
|
package/dist/cjs/aa/types.js
CHANGED
|
@@ -17,23 +17,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
var types_exports = {};
|
|
19
19
|
__export(types_exports, {
|
|
20
|
-
SMART_ACCOUNT_PROVIDERS: () => SMART_ACCOUNT_PROVIDERS,
|
|
20
|
+
SMART_ACCOUNT_PROVIDERS: () => import_core_sdk.SMART_ACCOUNT_PROVIDERS,
|
|
21
21
|
isSmartAccount4337: () => isSmartAccount4337,
|
|
22
22
|
isSmartAccount7702: () => isSmartAccount7702
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(types_exports);
|
|
25
|
-
|
|
26
|
-
"ALCHEMY",
|
|
27
|
-
"ZERODEV",
|
|
28
|
-
"BICONOMY",
|
|
29
|
-
"GELATO",
|
|
30
|
-
"PIMLICO",
|
|
31
|
-
"SAFE",
|
|
32
|
-
"THIRDWEB",
|
|
33
|
-
"RHINESTONE",
|
|
34
|
-
"PORTO",
|
|
35
|
-
"CDP"
|
|
36
|
-
];
|
|
25
|
+
var import_core_sdk = require("@getpara/core-sdk");
|
|
37
26
|
function isSmartAccount7702(account) {
|
|
38
27
|
return account.mode === "7702";
|
|
39
28
|
}
|
package/dist/cjs/aa/utils.js
CHANGED
|
@@ -64,7 +64,7 @@ __export(utils_exports, {
|
|
|
64
64
|
});
|
|
65
65
|
module.exports = __toCommonJS(utils_exports);
|
|
66
66
|
var import_viemWalletClient = require("../viemWalletClient.js");
|
|
67
|
-
var
|
|
67
|
+
var import_core_sdk = require("@getpara/core-sdk");
|
|
68
68
|
function isExternalWallet(signer) {
|
|
69
69
|
return !!signer && typeof signer === "object" && "transport" in signer && "account" in signer;
|
|
70
70
|
}
|
|
@@ -107,7 +107,7 @@ function ensureExternalWalletChain(signer, chain, provider) {
|
|
|
107
107
|
if (!isExternalWallet(signer)) return;
|
|
108
108
|
const currentChainId = yield signer.getChainId();
|
|
109
109
|
if (currentChainId !== chain.id) {
|
|
110
|
-
throw new
|
|
110
|
+
throw new import_core_sdk.SmartAccountError({
|
|
111
111
|
code: "CHAIN_MISMATCH",
|
|
112
112
|
message: `External wallet is on chain ${currentChainId} but smart account targets chain ${chain.id} (${chain.name}). Switch your wallet to the correct network before sending transactions.`,
|
|
113
113
|
provider
|
|
@@ -140,7 +140,7 @@ function resolveSigner(para, params) {
|
|
|
140
140
|
}
|
|
141
141
|
function rejectExternalWallet7702(signer, provider) {
|
|
142
142
|
if (!signer || !isExternalWallet(signer)) return;
|
|
143
|
-
throw new
|
|
143
|
+
throw new import_core_sdk.SmartAccountError({
|
|
144
144
|
code: "INVALID_CONFIG",
|
|
145
145
|
message: "EIP-7702 mode is not supported with external wallets. External wallets add an EIP-191 prefix to all signatures, which is incompatible with the raw ecrecover required by EIP-7702 authorization. Use an embedded Para wallet for 7702 mode, or use 4337 mode which works with any wallet.",
|
|
146
146
|
provider
|
|
@@ -148,7 +148,7 @@ function rejectExternalWallet7702(signer, provider) {
|
|
|
148
148
|
}
|
|
149
149
|
function assertAccountAddress(address, clientLabel, provider) {
|
|
150
150
|
if (!address) {
|
|
151
|
-
throw new
|
|
151
|
+
throw new import_core_sdk.SmartAccountError({
|
|
152
152
|
code: "MISSING_ACCOUNT_ADDRESS",
|
|
153
153
|
message: `${clientLabel} did not return a smart account address. Verify your configuration.`,
|
|
154
154
|
provider
|
package/dist/esm/aa/index.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import "../chunk-6FNC3XMI.js";
|
|
1
2
|
export * from "./types.js";
|
|
2
|
-
export * from "./errors.js";
|
|
3
3
|
export * from "./utils.js";
|
|
4
|
+
import { SMART_ACCOUNT_ERROR_CODES, SmartAccountError, classifyProviderError, wrapProviderError } from "@getpara/core-sdk";
|
|
5
|
+
export {
|
|
6
|
+
SMART_ACCOUNT_ERROR_CODES,
|
|
7
|
+
SmartAccountError,
|
|
8
|
+
classifyProviderError,
|
|
9
|
+
wrapProviderError
|
|
10
|
+
};
|
package/dist/esm/aa/types.js
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
1
|
import "../chunk-6FNC3XMI.js";
|
|
2
|
-
|
|
3
|
-
"ALCHEMY",
|
|
4
|
-
"ZERODEV",
|
|
5
|
-
"BICONOMY",
|
|
6
|
-
"GELATO",
|
|
7
|
-
"PIMLICO",
|
|
8
|
-
"SAFE",
|
|
9
|
-
"THIRDWEB",
|
|
10
|
-
"RHINESTONE",
|
|
11
|
-
"PORTO",
|
|
12
|
-
"CDP"
|
|
13
|
-
];
|
|
2
|
+
import { SMART_ACCOUNT_PROVIDERS } from "@getpara/core-sdk";
|
|
14
3
|
function isSmartAccount7702(account) {
|
|
15
4
|
return account.mode === "7702";
|
|
16
5
|
}
|
package/dist/esm/aa/utils.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
__spreadValues
|
|
5
5
|
} from "../chunk-6FNC3XMI.js";
|
|
6
6
|
import { createParaAccount } from "../viemWalletClient.js";
|
|
7
|
-
import { SmartAccountError } from "
|
|
7
|
+
import { SmartAccountError } from "@getpara/core-sdk";
|
|
8
8
|
function isExternalWallet(signer) {
|
|
9
9
|
return !!signer && typeof signer === "object" && "transport" in signer && "account" in signer;
|
|
10
10
|
}
|
package/dist/types/aa/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export * from './types.js';
|
|
2
|
-
export * from './errors.js';
|
|
3
2
|
export * from './utils.js';
|
|
3
|
+
export { SMART_ACCOUNT_ERROR_CODES, SmartAccountError, classifyProviderError, wrapProviderError } from '@getpara/core-sdk';
|
|
4
|
+
export type { SmartAccountErrorCode } from '@getpara/core-sdk';
|
package/dist/types/aa/types.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type ParaCore from '@getpara/core-sdk';
|
|
2
|
+
import { SMART_ACCOUNT_PROVIDERS } from '@getpara/core-sdk';
|
|
3
|
+
import type { SmartAccountMode, SmartAccountModeParam, SmartAccountProvider } from '@getpara/core-sdk';
|
|
2
4
|
import type { Chain, Hex, LocalAccount, TransactionReceipt, WalletClient } from 'viem';
|
|
5
|
+
export { SMART_ACCOUNT_PROVIDERS };
|
|
6
|
+
export type { SmartAccountMode, SmartAccountModeParam, SmartAccountProvider };
|
|
3
7
|
/**
|
|
4
8
|
* Base configuration shared by all smart account implementations.
|
|
5
9
|
*/
|
|
@@ -64,32 +68,11 @@ export type CreateSmartAccountParams<T extends BaseSmartAccountConfig> = T & {
|
|
|
64
68
|
/** Para SDK instance */
|
|
65
69
|
para: ParaCore;
|
|
66
70
|
};
|
|
67
|
-
/**
|
|
68
|
-
* Smart account mode — the two execution models supported by AA providers.
|
|
69
|
-
* - '4337': EIP-4337 UserOperations via bundler
|
|
70
|
-
* - '7702': EIP-7702 EOA delegation (type 4 transactions)
|
|
71
|
-
*/
|
|
72
|
-
export type SmartAccountMode = '4337' | '7702';
|
|
73
71
|
/**
|
|
74
72
|
* Maps a mode literal to the corresponding SmartAccount type.
|
|
75
73
|
* When mode is the full union or undefined, returns the union.
|
|
76
74
|
*/
|
|
77
75
|
export type SmartAccountForMode<TMode extends SmartAccountMode | undefined, TClient = any> = TMode extends '7702' ? SmartAccount7702<TClient> : TMode extends '4337' ? SmartAccount4337<TClient> : SmartAccount<TClient>;
|
|
78
|
-
/**
|
|
79
|
-
* Mixin for params that support choosing between 4337 and 7702 execution modes.
|
|
80
|
-
*/
|
|
81
|
-
export interface SmartAccountModeParam {
|
|
82
|
-
/**
|
|
83
|
-
* Account mode: EIP-4337 (bundler) or EIP-7702 (EOA delegation)
|
|
84
|
-
* @default '4337'
|
|
85
|
-
*/
|
|
86
|
-
mode?: SmartAccountMode;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* All supported AA provider names.
|
|
90
|
-
*/
|
|
91
|
-
export declare const SMART_ACCOUNT_PROVIDERS: readonly ["ALCHEMY", "ZERODEV", "BICONOMY", "GELATO", "PIMLICO", "SAFE", "THIRDWEB", "RHINESTONE", "PORTO", "CDP"];
|
|
92
|
-
export type SmartAccountProvider = (typeof SMART_ACCOUNT_PROVIDERS)[number];
|
|
93
76
|
/**
|
|
94
77
|
* Transaction parameters
|
|
95
78
|
*/
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/viem-v2-integration",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.20.0",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@getpara/core-sdk": "2.
|
|
5
|
+
"@getpara/core-sdk": "2.20.0"
|
|
6
6
|
},
|
|
7
7
|
"devDependencies": {
|
|
8
8
|
"typescript": "^5.8.3",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"dist",
|
|
25
25
|
"package.json"
|
|
26
26
|
],
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "a8443bcc4018864f5e582f238ade1bb3b4e121f4",
|
|
28
28
|
"main": "dist/cjs/index.js",
|
|
29
29
|
"module": "dist/esm/index.js",
|
|
30
30
|
"peerDependencies": {
|
package/dist/cjs/aa/errors.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var errors_exports = {};
|
|
19
|
-
__export(errors_exports, {
|
|
20
|
-
SMART_ACCOUNT_ERROR_CODES: () => SMART_ACCOUNT_ERROR_CODES,
|
|
21
|
-
SmartAccountError: () => SmartAccountError,
|
|
22
|
-
classifyProviderError: () => classifyProviderError,
|
|
23
|
-
wrapProviderError: () => wrapProviderError
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(errors_exports);
|
|
26
|
-
const SMART_ACCOUNT_ERROR_CODES = [
|
|
27
|
-
"MISSING_CHAIN",
|
|
28
|
-
"MISSING_ACCOUNT_ADDRESS",
|
|
29
|
-
"MISSING_API_KEY",
|
|
30
|
-
"INVALID_CONFIG",
|
|
31
|
-
// Authorization (7702)
|
|
32
|
-
"AUTHORIZATION_FAILED",
|
|
33
|
-
"DELEGATION_CONFLICT",
|
|
34
|
-
"AUTHORIZATION_NONCE_MISMATCH",
|
|
35
|
-
// Chain
|
|
36
|
-
"CHAIN_MISMATCH",
|
|
37
|
-
// Transaction Submission
|
|
38
|
-
"BUNDLER_REJECTED",
|
|
39
|
-
"GAS_ESTIMATION_FAILED",
|
|
40
|
-
"SPONSORSHIP_DENIED",
|
|
41
|
-
// Transaction Receipt
|
|
42
|
-
"RECEIPT_TIMEOUT",
|
|
43
|
-
"TRANSACTION_REVERTED",
|
|
44
|
-
"RECEIPT_MISSING",
|
|
45
|
-
// Provider
|
|
46
|
-
"PROVIDER_UNREACHABLE",
|
|
47
|
-
"PROVIDER_RATE_LIMITED",
|
|
48
|
-
"PROVIDER_ERROR"
|
|
49
|
-
];
|
|
50
|
-
class SmartAccountError extends Error {
|
|
51
|
-
constructor(params) {
|
|
52
|
-
super(params.message);
|
|
53
|
-
this.name = "SmartAccountError";
|
|
54
|
-
this.code = params.code;
|
|
55
|
-
this.provider = params.provider;
|
|
56
|
-
if (params.cause !== void 0) {
|
|
57
|
-
this.cause = params.cause;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
function classifyProviderError(error) {
|
|
62
|
-
var _a;
|
|
63
|
-
const msg = (error instanceof Error ? (_a = error.message) != null ? _a : String(error) : String(error)).toLowerCase();
|
|
64
|
-
if (msg.includes("rate limit") || msg.includes("429")) {
|
|
65
|
-
return "PROVIDER_RATE_LIMITED";
|
|
66
|
-
}
|
|
67
|
-
if (msg.includes("gas") && (msg.includes("estimate") || msg.includes("estimation"))) {
|
|
68
|
-
return "GAS_ESTIMATION_FAILED";
|
|
69
|
-
}
|
|
70
|
-
if (msg.includes("paymaster") || msg.includes("sponsor")) {
|
|
71
|
-
return "SPONSORSHIP_DENIED";
|
|
72
|
-
}
|
|
73
|
-
if (msg.includes("useroperation") && (msg.includes("reverted") || msg.includes("rejected") || msg.includes("failed"))) {
|
|
74
|
-
return "BUNDLER_REJECTED";
|
|
75
|
-
}
|
|
76
|
-
if (msg.includes("nonce") && msg.includes("authorization")) {
|
|
77
|
-
return "AUTHORIZATION_NONCE_MISMATCH";
|
|
78
|
-
}
|
|
79
|
-
if (msg.includes("nonce") || msg.includes("aa25") || msg.includes("aa10")) {
|
|
80
|
-
return "BUNDLER_REJECTED";
|
|
81
|
-
}
|
|
82
|
-
if (msg.includes("authorization") || msg.includes("delegation")) {
|
|
83
|
-
return "AUTHORIZATION_FAILED";
|
|
84
|
-
}
|
|
85
|
-
if (msg.includes("econnrefused") || msg.includes("fetch failed") || msg.includes("network") || msg.includes("timeout")) {
|
|
86
|
-
return "PROVIDER_UNREACHABLE";
|
|
87
|
-
}
|
|
88
|
-
return "PROVIDER_ERROR";
|
|
89
|
-
}
|
|
90
|
-
function wrapProviderError(error, provider) {
|
|
91
|
-
var _a;
|
|
92
|
-
if (error instanceof SmartAccountError) {
|
|
93
|
-
return error;
|
|
94
|
-
}
|
|
95
|
-
const code = classifyProviderError(error);
|
|
96
|
-
const message = error instanceof Error ? (_a = error.message) != null ? _a : String(error) : String(error);
|
|
97
|
-
return new SmartAccountError({ code, message, provider, cause: error });
|
|
98
|
-
}
|
|
99
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
100
|
-
0 && (module.exports = {
|
|
101
|
-
SMART_ACCOUNT_ERROR_CODES,
|
|
102
|
-
SmartAccountError,
|
|
103
|
-
classifyProviderError,
|
|
104
|
-
wrapProviderError
|
|
105
|
-
});
|
package/dist/esm/aa/errors.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import "../chunk-6FNC3XMI.js";
|
|
2
|
-
const SMART_ACCOUNT_ERROR_CODES = [
|
|
3
|
-
"MISSING_CHAIN",
|
|
4
|
-
"MISSING_ACCOUNT_ADDRESS",
|
|
5
|
-
"MISSING_API_KEY",
|
|
6
|
-
"INVALID_CONFIG",
|
|
7
|
-
// Authorization (7702)
|
|
8
|
-
"AUTHORIZATION_FAILED",
|
|
9
|
-
"DELEGATION_CONFLICT",
|
|
10
|
-
"AUTHORIZATION_NONCE_MISMATCH",
|
|
11
|
-
// Chain
|
|
12
|
-
"CHAIN_MISMATCH",
|
|
13
|
-
// Transaction Submission
|
|
14
|
-
"BUNDLER_REJECTED",
|
|
15
|
-
"GAS_ESTIMATION_FAILED",
|
|
16
|
-
"SPONSORSHIP_DENIED",
|
|
17
|
-
// Transaction Receipt
|
|
18
|
-
"RECEIPT_TIMEOUT",
|
|
19
|
-
"TRANSACTION_REVERTED",
|
|
20
|
-
"RECEIPT_MISSING",
|
|
21
|
-
// Provider
|
|
22
|
-
"PROVIDER_UNREACHABLE",
|
|
23
|
-
"PROVIDER_RATE_LIMITED",
|
|
24
|
-
"PROVIDER_ERROR"
|
|
25
|
-
];
|
|
26
|
-
class SmartAccountError extends Error {
|
|
27
|
-
constructor(params) {
|
|
28
|
-
super(params.message);
|
|
29
|
-
this.name = "SmartAccountError";
|
|
30
|
-
this.code = params.code;
|
|
31
|
-
this.provider = params.provider;
|
|
32
|
-
if (params.cause !== void 0) {
|
|
33
|
-
this.cause = params.cause;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
function classifyProviderError(error) {
|
|
38
|
-
var _a;
|
|
39
|
-
const msg = (error instanceof Error ? (_a = error.message) != null ? _a : String(error) : String(error)).toLowerCase();
|
|
40
|
-
if (msg.includes("rate limit") || msg.includes("429")) {
|
|
41
|
-
return "PROVIDER_RATE_LIMITED";
|
|
42
|
-
}
|
|
43
|
-
if (msg.includes("gas") && (msg.includes("estimate") || msg.includes("estimation"))) {
|
|
44
|
-
return "GAS_ESTIMATION_FAILED";
|
|
45
|
-
}
|
|
46
|
-
if (msg.includes("paymaster") || msg.includes("sponsor")) {
|
|
47
|
-
return "SPONSORSHIP_DENIED";
|
|
48
|
-
}
|
|
49
|
-
if (msg.includes("useroperation") && (msg.includes("reverted") || msg.includes("rejected") || msg.includes("failed"))) {
|
|
50
|
-
return "BUNDLER_REJECTED";
|
|
51
|
-
}
|
|
52
|
-
if (msg.includes("nonce") && msg.includes("authorization")) {
|
|
53
|
-
return "AUTHORIZATION_NONCE_MISMATCH";
|
|
54
|
-
}
|
|
55
|
-
if (msg.includes("nonce") || msg.includes("aa25") || msg.includes("aa10")) {
|
|
56
|
-
return "BUNDLER_REJECTED";
|
|
57
|
-
}
|
|
58
|
-
if (msg.includes("authorization") || msg.includes("delegation")) {
|
|
59
|
-
return "AUTHORIZATION_FAILED";
|
|
60
|
-
}
|
|
61
|
-
if (msg.includes("econnrefused") || msg.includes("fetch failed") || msg.includes("network") || msg.includes("timeout")) {
|
|
62
|
-
return "PROVIDER_UNREACHABLE";
|
|
63
|
-
}
|
|
64
|
-
return "PROVIDER_ERROR";
|
|
65
|
-
}
|
|
66
|
-
function wrapProviderError(error, provider) {
|
|
67
|
-
var _a;
|
|
68
|
-
if (error instanceof SmartAccountError) {
|
|
69
|
-
return error;
|
|
70
|
-
}
|
|
71
|
-
const code = classifyProviderError(error);
|
|
72
|
-
const message = error instanceof Error ? (_a = error.message) != null ? _a : String(error) : String(error);
|
|
73
|
-
return new SmartAccountError({ code, message, provider, cause: error });
|
|
74
|
-
}
|
|
75
|
-
export {
|
|
76
|
-
SMART_ACCOUNT_ERROR_CODES,
|
|
77
|
-
SmartAccountError,
|
|
78
|
-
classifyProviderError,
|
|
79
|
-
wrapProviderError
|
|
80
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { SmartAccountProvider } from './types.js';
|
|
2
|
-
export declare const SMART_ACCOUNT_ERROR_CODES: readonly ["MISSING_CHAIN", "MISSING_ACCOUNT_ADDRESS", "MISSING_API_KEY", "INVALID_CONFIG", "AUTHORIZATION_FAILED", "DELEGATION_CONFLICT", "AUTHORIZATION_NONCE_MISMATCH", "CHAIN_MISMATCH", "BUNDLER_REJECTED", "GAS_ESTIMATION_FAILED", "SPONSORSHIP_DENIED", "RECEIPT_TIMEOUT", "TRANSACTION_REVERTED", "RECEIPT_MISSING", "PROVIDER_UNREACHABLE", "PROVIDER_RATE_LIMITED", "PROVIDER_ERROR"];
|
|
3
|
-
export type SmartAccountErrorCode = (typeof SMART_ACCOUNT_ERROR_CODES)[number];
|
|
4
|
-
export declare class SmartAccountError extends Error {
|
|
5
|
-
readonly code: SmartAccountErrorCode;
|
|
6
|
-
readonly provider: SmartAccountProvider;
|
|
7
|
-
constructor(params: {
|
|
8
|
-
code: SmartAccountErrorCode;
|
|
9
|
-
message: string;
|
|
10
|
-
provider: SmartAccountProvider;
|
|
11
|
-
cause?: unknown;
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Classifies an unknown provider error into a SmartAccountErrorCode.
|
|
16
|
-
* Inspects the error message for common patterns across AA providers.
|
|
17
|
-
*/
|
|
18
|
-
export declare function classifyProviderError(error: unknown): SmartAccountErrorCode;
|
|
19
|
-
/**
|
|
20
|
-
* Wraps an unknown error thrown by a provider SDK into a SmartAccountError.
|
|
21
|
-
*/
|
|
22
|
-
export declare function wrapProviderError(error: unknown, provider: SmartAccountProvider): SmartAccountError;
|