@getpara/viem-v2-integration 2.14.0 → 2.16.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.
@@ -0,0 +1,101 @@
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
+ // Transaction Submission
36
+ "BUNDLER_REJECTED",
37
+ "GAS_ESTIMATION_FAILED",
38
+ "SPONSORSHIP_DENIED",
39
+ // Transaction Receipt
40
+ "RECEIPT_TIMEOUT",
41
+ "TRANSACTION_REVERTED",
42
+ "RECEIPT_MISSING",
43
+ // Provider
44
+ "PROVIDER_UNREACHABLE",
45
+ "PROVIDER_RATE_LIMITED",
46
+ "PROVIDER_ERROR"
47
+ ];
48
+ class SmartAccountError extends Error {
49
+ constructor(params) {
50
+ super(params.message);
51
+ this.name = "SmartAccountError";
52
+ this.code = params.code;
53
+ this.provider = params.provider;
54
+ if (params.cause !== void 0) {
55
+ this.cause = params.cause;
56
+ }
57
+ }
58
+ }
59
+ function classifyProviderError(error) {
60
+ const msg = error instanceof Error ? error.message.toLowerCase() : String(error).toLowerCase();
61
+ if (msg.includes("rate limit") || msg.includes("429")) {
62
+ return "PROVIDER_RATE_LIMITED";
63
+ }
64
+ if (msg.includes("gas") && (msg.includes("estimate") || msg.includes("estimation"))) {
65
+ return "GAS_ESTIMATION_FAILED";
66
+ }
67
+ if (msg.includes("paymaster") || msg.includes("sponsor")) {
68
+ return "SPONSORSHIP_DENIED";
69
+ }
70
+ if (msg.includes("useroperation") && (msg.includes("reverted") || msg.includes("rejected") || msg.includes("failed"))) {
71
+ return "BUNDLER_REJECTED";
72
+ }
73
+ if (msg.includes("nonce") && msg.includes("authorization")) {
74
+ return "AUTHORIZATION_NONCE_MISMATCH";
75
+ }
76
+ if (msg.includes("nonce") || msg.includes("aa25") || msg.includes("aa10")) {
77
+ return "BUNDLER_REJECTED";
78
+ }
79
+ if (msg.includes("authorization") || msg.includes("delegation")) {
80
+ return "AUTHORIZATION_FAILED";
81
+ }
82
+ if (msg.includes("econnrefused") || msg.includes("fetch failed") || msg.includes("network") || msg.includes("timeout")) {
83
+ return "PROVIDER_UNREACHABLE";
84
+ }
85
+ return "PROVIDER_ERROR";
86
+ }
87
+ function wrapProviderError(error, provider) {
88
+ if (error instanceof SmartAccountError) {
89
+ return error;
90
+ }
91
+ const code = classifyProviderError(error);
92
+ const message = error instanceof Error ? error.message : String(error);
93
+ return new SmartAccountError({ code, message, provider, cause: error });
94
+ }
95
+ // Annotate the CommonJS export names for ESM import in node:
96
+ 0 && (module.exports = {
97
+ SMART_ACCOUNT_ERROR_CODES,
98
+ SmartAccountError,
99
+ classifyProviderError,
100
+ wrapProviderError
101
+ });
@@ -0,0 +1,48 @@
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 types_exports = {};
19
+ __export(types_exports, {
20
+ SMART_ACCOUNT_PROVIDERS: () => SMART_ACCOUNT_PROVIDERS,
21
+ isSmartAccount4337: () => isSmartAccount4337,
22
+ isSmartAccount7702: () => isSmartAccount7702
23
+ });
24
+ module.exports = __toCommonJS(types_exports);
25
+ const SMART_ACCOUNT_PROVIDERS = [
26
+ "ALCHEMY",
27
+ "ZERODEV",
28
+ "BICONOMY",
29
+ "GELATO",
30
+ "PIMLICO",
31
+ "SAFE",
32
+ "THIRDWEB",
33
+ "RHINESTONE",
34
+ "PORTO",
35
+ "CDP"
36
+ ];
37
+ function isSmartAccount7702(account) {
38
+ return account.mode === "7702";
39
+ }
40
+ function isSmartAccount4337(account) {
41
+ return account.mode === "4337";
42
+ }
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ SMART_ACCOUNT_PROVIDERS,
46
+ isSmartAccount4337,
47
+ isSmartAccount7702
48
+ });
@@ -0,0 +1,39 @@
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 utils_exports = {};
19
+ __export(utils_exports, {
20
+ resolveWalletIdentifier: () => resolveWalletIdentifier
21
+ });
22
+ module.exports = __toCommonJS(utils_exports);
23
+ function resolveWalletIdentifier(para, params) {
24
+ var _a;
25
+ try {
26
+ if (params.address) {
27
+ const wallet = para.findWalletByAddress(params.address, { type: ["EVM"] });
28
+ return wallet.address;
29
+ }
30
+ const validId = para.findWalletId(params.walletId, { type: ["EVM"] });
31
+ return (_a = para.wallets[validId]) == null ? void 0 : _a.address;
32
+ } catch (e) {
33
+ return null;
34
+ }
35
+ }
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ resolveWalletIdentifier
39
+ });
package/dist/cjs/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,9 +17,18 @@ 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 src_exports = {};
20
+ __export(src_exports, {
21
+ resolveWalletIdentifier: () => import_utils.resolveWalletIdentifier
22
+ });
16
23
  module.exports = __toCommonJS(src_exports);
17
24
  __reExport(src_exports, require("./viemWalletClient.js"), module.exports);
25
+ __reExport(src_exports, require("./aa/types.js"), module.exports);
26
+ __reExport(src_exports, require("./aa/errors.js"), module.exports);
27
+ var import_utils = require("./aa/utils.js");
18
28
  // Annotate the CommonJS export names for ESM import in node:
19
29
  0 && (module.exports = {
20
- ...require("./viemWalletClient.js")
30
+ resolveWalletIdentifier,
31
+ ...require("./viemWalletClient.js"),
32
+ ...require("./aa/types.js"),
33
+ ...require("./aa/errors.js")
21
34
  });
@@ -0,0 +1,76 @@
1
+ import "../chunk-HJO26HIQ.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
+ // Transaction Submission
12
+ "BUNDLER_REJECTED",
13
+ "GAS_ESTIMATION_FAILED",
14
+ "SPONSORSHIP_DENIED",
15
+ // Transaction Receipt
16
+ "RECEIPT_TIMEOUT",
17
+ "TRANSACTION_REVERTED",
18
+ "RECEIPT_MISSING",
19
+ // Provider
20
+ "PROVIDER_UNREACHABLE",
21
+ "PROVIDER_RATE_LIMITED",
22
+ "PROVIDER_ERROR"
23
+ ];
24
+ class SmartAccountError extends Error {
25
+ constructor(params) {
26
+ super(params.message);
27
+ this.name = "SmartAccountError";
28
+ this.code = params.code;
29
+ this.provider = params.provider;
30
+ if (params.cause !== void 0) {
31
+ this.cause = params.cause;
32
+ }
33
+ }
34
+ }
35
+ function classifyProviderError(error) {
36
+ const msg = error instanceof Error ? error.message.toLowerCase() : String(error).toLowerCase();
37
+ if (msg.includes("rate limit") || msg.includes("429")) {
38
+ return "PROVIDER_RATE_LIMITED";
39
+ }
40
+ if (msg.includes("gas") && (msg.includes("estimate") || msg.includes("estimation"))) {
41
+ return "GAS_ESTIMATION_FAILED";
42
+ }
43
+ if (msg.includes("paymaster") || msg.includes("sponsor")) {
44
+ return "SPONSORSHIP_DENIED";
45
+ }
46
+ if (msg.includes("useroperation") && (msg.includes("reverted") || msg.includes("rejected") || msg.includes("failed"))) {
47
+ return "BUNDLER_REJECTED";
48
+ }
49
+ if (msg.includes("nonce") && msg.includes("authorization")) {
50
+ return "AUTHORIZATION_NONCE_MISMATCH";
51
+ }
52
+ if (msg.includes("nonce") || msg.includes("aa25") || msg.includes("aa10")) {
53
+ return "BUNDLER_REJECTED";
54
+ }
55
+ if (msg.includes("authorization") || msg.includes("delegation")) {
56
+ return "AUTHORIZATION_FAILED";
57
+ }
58
+ if (msg.includes("econnrefused") || msg.includes("fetch failed") || msg.includes("network") || msg.includes("timeout")) {
59
+ return "PROVIDER_UNREACHABLE";
60
+ }
61
+ return "PROVIDER_ERROR";
62
+ }
63
+ function wrapProviderError(error, provider) {
64
+ if (error instanceof SmartAccountError) {
65
+ return error;
66
+ }
67
+ const code = classifyProviderError(error);
68
+ const message = error instanceof Error ? error.message : String(error);
69
+ return new SmartAccountError({ code, message, provider, cause: error });
70
+ }
71
+ export {
72
+ SMART_ACCOUNT_ERROR_CODES,
73
+ SmartAccountError,
74
+ classifyProviderError,
75
+ wrapProviderError
76
+ };
@@ -0,0 +1,24 @@
1
+ import "../chunk-HJO26HIQ.js";
2
+ const SMART_ACCOUNT_PROVIDERS = [
3
+ "ALCHEMY",
4
+ "ZERODEV",
5
+ "BICONOMY",
6
+ "GELATO",
7
+ "PIMLICO",
8
+ "SAFE",
9
+ "THIRDWEB",
10
+ "RHINESTONE",
11
+ "PORTO",
12
+ "CDP"
13
+ ];
14
+ function isSmartAccount7702(account) {
15
+ return account.mode === "7702";
16
+ }
17
+ function isSmartAccount4337(account) {
18
+ return account.mode === "4337";
19
+ }
20
+ export {
21
+ SMART_ACCOUNT_PROVIDERS,
22
+ isSmartAccount4337,
23
+ isSmartAccount7702
24
+ };
@@ -0,0 +1,17 @@
1
+ import "../chunk-HJO26HIQ.js";
2
+ function resolveWalletIdentifier(para, params) {
3
+ var _a;
4
+ try {
5
+ if (params.address) {
6
+ const wallet = para.findWalletByAddress(params.address, { type: ["EVM"] });
7
+ return wallet.address;
8
+ }
9
+ const validId = para.findWalletId(params.walletId, { type: ["EVM"] });
10
+ return (_a = para.wallets[validId]) == null ? void 0 : _a.address;
11
+ } catch (e) {
12
+ return null;
13
+ }
14
+ }
15
+ export {
16
+ resolveWalletIdentifier
17
+ };
@@ -0,0 +1,41 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ var __async = (__this, __arguments, generator) => {
18
+ return new Promise((resolve, reject) => {
19
+ var fulfilled = (value) => {
20
+ try {
21
+ step(generator.next(value));
22
+ } catch (e) {
23
+ reject(e);
24
+ }
25
+ };
26
+ var rejected = (value) => {
27
+ try {
28
+ step(generator.throw(value));
29
+ } catch (e) {
30
+ reject(e);
31
+ }
32
+ };
33
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
34
+ step((generator = generator.apply(__this, __arguments)).next());
35
+ });
36
+ };
37
+
38
+ export {
39
+ __spreadValues,
40
+ __async
41
+ };
package/dist/esm/index.js CHANGED
@@ -1 +1,8 @@
1
+ import "./chunk-HJO26HIQ.js";
1
2
  export * from "./viemWalletClient.js";
3
+ export * from "./aa/types.js";
4
+ export * from "./aa/errors.js";
5
+ import { resolveWalletIdentifier } from "./aa/utils.js";
6
+ export {
7
+ resolveWalletIdentifier
8
+ };
@@ -1,39 +1,7 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
- var __async = (__this, __arguments, generator) => {
18
- return new Promise((resolve, reject) => {
19
- var fulfilled = (value) => {
20
- try {
21
- step(generator.next(value));
22
- } catch (e) {
23
- reject(e);
24
- }
25
- };
26
- var rejected = (value) => {
27
- try {
28
- step(generator.throw(value));
29
- } catch (e) {
30
- reject(e);
31
- }
32
- };
33
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
34
- step((generator = generator.apply(__this, __arguments)).next());
35
- });
36
- };
1
+ import {
2
+ __async,
3
+ __spreadValues
4
+ } from "./chunk-HJO26HIQ.js";
37
5
  import {
38
6
  createWalletClient,
39
7
  hashMessage,
@@ -0,0 +1,22 @@
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", "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;
@@ -0,0 +1,203 @@
1
+ import type ParaCore from '@getpara/core-sdk';
2
+ import type { Chain, Hex, LocalAccount, TransactionReceipt } from 'viem';
3
+ /**
4
+ * Base configuration shared by all smart account implementations.
5
+ */
6
+ export interface BaseSmartAccountConfig {
7
+ /** Optional wallet address to use. If none is provided, the first EVM wallet will be used. */
8
+ address?: Hex;
9
+ /** Optional wallet ID to use. Alternative to `address` for selecting a specific wallet. */
10
+ walletId?: string;
11
+ }
12
+ /**
13
+ * Configuration for smart accounts that require chain configuration.
14
+ */
15
+ export interface ChainBasedSmartAccountConfig extends BaseSmartAccountConfig {
16
+ /** Target blockchain chain */
17
+ chain: Chain;
18
+ /** RPC URL for the chain. If not provided, defaults to the chain's built-in public RPC. */
19
+ rpcUrl?: string;
20
+ }
21
+ /**
22
+ * Configuration for smart accounts with API key authentication.
23
+ */
24
+ export interface ApiKeySmartAccountConfig extends ChainBasedSmartAccountConfig {
25
+ /** API key for the service */
26
+ apiKey: string;
27
+ }
28
+ /**
29
+ * Configuration for smart accounts with paymaster support.
30
+ */
31
+ export interface PaymasterSmartAccountConfig extends ChainBasedSmartAccountConfig {
32
+ /** Optional bundler RPC URL */
33
+ bundlerUrl?: string;
34
+ /** Optional paymaster RPC URL for gas sponsorship */
35
+ paymasterUrl?: string;
36
+ }
37
+ /**
38
+ * Adds `para: ParaCore` to a config type to produce the full action params.
39
+ */
40
+ export type CreateSmartAccountParams<T extends BaseSmartAccountConfig> = T & {
41
+ /** Para SDK instance */
42
+ para: ParaCore;
43
+ };
44
+ /**
45
+ * Smart account mode — the two execution models supported by AA providers.
46
+ * - '4337': EIP-4337 UserOperations via bundler
47
+ * - '7702': EIP-7702 EOA delegation (type 4 transactions)
48
+ */
49
+ export type SmartAccountMode = '4337' | '7702';
50
+ /**
51
+ * Maps a mode literal to the corresponding SmartAccount type.
52
+ * When mode is the full union or undefined, returns the union.
53
+ */
54
+ export type SmartAccountForMode<TMode extends SmartAccountMode | undefined, TClient = any> = TMode extends '7702' ? SmartAccount7702<TClient> : TMode extends '4337' ? SmartAccount4337<TClient> : SmartAccount<TClient>;
55
+ /**
56
+ * Mixin for params that support choosing between 4337 and 7702 execution modes.
57
+ */
58
+ export interface SmartAccountModeParam {
59
+ /**
60
+ * Account mode: EIP-4337 (bundler) or EIP-7702 (EOA delegation)
61
+ * @default '4337'
62
+ */
63
+ mode?: SmartAccountMode;
64
+ }
65
+ /**
66
+ * All supported AA provider names.
67
+ */
68
+ export declare const SMART_ACCOUNT_PROVIDERS: readonly ["ALCHEMY", "ZERODEV", "BICONOMY", "GELATO", "PIMLICO", "SAFE", "THIRDWEB", "RHINESTONE", "PORTO", "CDP"];
69
+ export type SmartAccountProvider = (typeof SMART_ACCOUNT_PROVIDERS)[number];
70
+ /**
71
+ * Transaction parameters
72
+ */
73
+ export interface TransactionParams {
74
+ /** Recipient address */
75
+ to: Hex;
76
+ /** Amount in wei. Use viem's `parseEther('0.1')` to convert from ETH. */
77
+ value?: bigint;
78
+ /** Encoded contract call data. Use viem's `encodeFunctionData()` to encode. */
79
+ data?: Hex;
80
+ }
81
+ /**
82
+ * Re-export viem's TransactionReceipt as the standard return type.
83
+ * All providers return a full on-chain receipt with logs, gasUsed, etc.
84
+ */
85
+ export type { TransactionReceipt } from 'viem';
86
+ /**
87
+ * Base smart account interface with shared functionality
88
+ * This contains methods available on ALL account types
89
+ */
90
+ interface SmartAccountBase<TClient = any> {
91
+ /**
92
+ * The smart account address — where transactions originate from on-chain.
93
+ * - EIP-4337: Counterfactual smart account address (different from signer EOA)
94
+ * - EIP-7702: EOA address (same as signer.address)
95
+ */
96
+ smartAccountAddress: Hex;
97
+ /**
98
+ * The Para viem LocalAccount that signs operations for this smart account.
99
+ * Provides signMessage, signTypedData, signTransaction, and signAuthorization.
100
+ * For 4337, signer.address differs from `smartAccountAddress` (signer EOA vs smart account).
101
+ * For 7702, signer.address equals `smartAccountAddress`.
102
+ */
103
+ signer: LocalAccount;
104
+ /**
105
+ * Chain this account is configured for.
106
+ */
107
+ chain: Chain;
108
+ /**
109
+ * Provider name
110
+ */
111
+ provider: SmartAccountProvider;
112
+ /**
113
+ * Send a single transaction and wait for confirmation.
114
+ *
115
+ * @param params - Transaction parameters
116
+ * @param options - Provider-specific options (paymaster config, gas settings, etc.)
117
+ * @returns viem TransactionReceipt — full on-chain receipt with logs, gasUsed, status, etc.
118
+ */
119
+ sendTransaction(params: TransactionParams, options?: unknown): Promise<TransactionReceipt>;
120
+ /**
121
+ * Send multiple transactions in a batch and wait for confirmation.
122
+ *
123
+ * @param calls - Array of transaction calls
124
+ * @param options - Provider-specific options (paymaster config, gas settings, etc.)
125
+ * @returns viem TransactionReceipt — full on-chain receipt with logs, gasUsed, status, etc.
126
+ */
127
+ sendBatchTransaction(calls: TransactionParams[], options?: unknown): Promise<TransactionReceipt>;
128
+ /**
129
+ * The underlying provider-specific client
130
+ * Use this to access provider-specific features beyond the unified interface
131
+ *
132
+ * @example
133
+ * ```typescript
134
+ * // Access provider-specific features
135
+ * const nativeClient = smartAccount.client;
136
+ * await nativeClient.simulateUserOperation({ ... });
137
+ * ```
138
+ */
139
+ client: TClient;
140
+ }
141
+ /**
142
+ * EIP-4337 smart account (user operations via bundler)
143
+ *
144
+ * Providers: Alchemy, ZeroDev, Biconomy, Pimlico, Safe, Thirdweb, Rhinestone, CDP
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * const account: SmartAccount4337 = createPimlicoSmartAccount(client);
149
+ * await account.sendTransaction({ to, value, data });
150
+ * ```
151
+ */
152
+ export interface SmartAccount4337<TClient = any> extends SmartAccountBase<TClient> {
153
+ /** Discriminant — always `'4337'` for EIP-4337 accounts. */
154
+ mode: '4337';
155
+ }
156
+ /**
157
+ * EIP-7702 smart account (EOA delegation)
158
+ *
159
+ * Providers: Alchemy, ZeroDev, Biconomy, Pimlico, Gelato, Porto, Thirdweb
160
+ *
161
+ * @example
162
+ * ```typescript
163
+ * const account: SmartAccount7702 = createPortoSmartAccount(provider);
164
+ * // smartAccountAddress === signer.address for 7702
165
+ * // delegationAddress is the contract the EOA delegates to
166
+ * ```
167
+ */
168
+ export interface SmartAccount7702<TClient = any> extends SmartAccountBase<TClient> {
169
+ /** Discriminant — always `'7702'` for EIP-7702 accounts. */
170
+ mode: '7702';
171
+ /**
172
+ * The smart contract address the EOA delegates execution to.
173
+ * Each provider uses a different delegation contract.
174
+ * Undefined if the provider handles delegation internally.
175
+ */
176
+ delegationAddress?: Hex;
177
+ }
178
+ /**
179
+ * Unified smart account type - discriminated union
180
+ *
181
+ * Use TypeScript's control flow analysis to narrow types based on the `mode` field:
182
+ *
183
+ * @example
184
+ * ```typescript
185
+ * function handleAccount(account: SmartAccount) {
186
+ * if (account.mode === '7702') {
187
+ * // TypeScript knows this is SmartAccount7702
188
+ * console.log('Delegation:', account.delegationAddress);
189
+ * }
190
+ * // Both modes share sendTransaction, signer, chain
191
+ * await account.sendTransaction({ to, value, data });
192
+ * }
193
+ * ```
194
+ */
195
+ export type SmartAccount<TClient = any> = SmartAccount4337<TClient> | SmartAccount7702<TClient>;
196
+ /**
197
+ * Type guard to check if account supports EIP-7702
198
+ */
199
+ export declare function isSmartAccount7702<TClient = any>(account: SmartAccount<TClient>): account is SmartAccount7702<TClient>;
200
+ /**
201
+ * Type guard to check if account supports EIP-4337
202
+ */
203
+ export declare function isSmartAccount4337<TClient = any>(account: SmartAccount<TClient>): account is SmartAccount4337<TClient>;
@@ -0,0 +1,14 @@
1
+ import type ParaCore from '@getpara/core-sdk';
2
+ import type { Hex } from 'viem';
3
+ /**
4
+ * Resolves an EVM wallet address from params. Returns `null` if no matching wallet exists.
5
+ *
6
+ * Priority:
7
+ * 1. Explicit `address` — validated as an EVM wallet via `findWalletByAddress()`
8
+ * 2. `walletId` — validated via `findWalletId()` and resolved to address
9
+ * 3. Neither — picks the first available EVM wallet via `findWalletId()`
10
+ */
11
+ export declare function resolveWalletIdentifier(para: ParaCore, params: {
12
+ address?: Hex;
13
+ walletId?: string;
14
+ }): Hex | null;
@@ -1 +1,4 @@
1
1
  export * from './viemWalletClient.js';
2
+ export * from './aa/types.js';
3
+ export * from './aa/errors.js';
4
+ export { resolveWalletIdentifier } from './aa/utils.js';
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@getpara/viem-v2-integration",
3
- "version": "2.14.0",
3
+ "version": "2.16.0",
4
4
  "dependencies": {
5
- "@getpara/core-sdk": "2.14.0"
5
+ "@getpara/core-sdk": "2.16.0"
6
6
  },
7
7
  "devDependencies": {
8
8
  "typescript": "^5.8.3",
@@ -19,7 +19,7 @@
19
19
  "dist",
20
20
  "package.json"
21
21
  ],
22
- "gitHead": "8ac7cfbe3b106a42e53f6e5439f484ab11b0e1f3",
22
+ "gitHead": "fbe96a062b308d04105213378c12c38ee973c798",
23
23
  "main": "dist/cjs/index.js",
24
24
  "module": "dist/esm/index.js",
25
25
  "peerDependencies": {