@baliola/smart-account-sdk 0.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.
@@ -0,0 +1,184 @@
1
+ import { i as IUserOperation, n as ISmartAccount, t as Call } from "./types-CD0TvpY4.js";
2
+ import { t as UserOperationReceipt } from "./receipt-Ceeclfnv.js";
3
+ import { Abi, Address, Chain, ContractFunctionArgs, ContractFunctionName, Hex, Log, PublicClient, Transport } from "viem";
4
+
5
+ //#region src/clients/createBundlerClient.d.ts
6
+ interface CreateBundlerClientParams {
7
+ transport: Transport;
8
+ /** Optional chain tag forwarded to the transport (viem requires it for some transports). */
9
+ chain?: Chain;
10
+ }
11
+ interface BundlerClient {
12
+ request<TResult = unknown>(method: string, params: readonly unknown[]): Promise<TResult>;
13
+ }
14
+ /**
15
+ * Thin JSON-RPC wrapper over a viem `Transport`. Speaks the ERC-4337 v0.7
16
+ * bundler methods without pulling in the rest of viem's client surface,
17
+ * because the bundler endpoint is a different service than the chain RPC.
18
+ *
19
+ * Every error thrown out of `request` is first classified into a typed
20
+ * SDK error (`InvalidUserOperationError`, `UserOperationRejectedError`,
21
+ * `BundlerUnreachableError`, or one of the `UserOperationRevertError`
22
+ * subclasses for AA-code reverts). Callers never see a raw viem error.
23
+ */
24
+ declare function createBundlerClient({
25
+ transport,
26
+ chain
27
+ }: CreateBundlerClientParams): BundlerClient;
28
+ //#endregion
29
+ //#region src/paymaster/types.d.ts
30
+ interface PaymasterContext {
31
+ userOp: IUserOperation;
32
+ entryPoint: Address;
33
+ chainId: number;
34
+ }
35
+ interface PaymasterFields {
36
+ paymaster: Address;
37
+ paymasterData: Hex;
38
+ paymasterVerificationGasLimit?: bigint;
39
+ paymasterPostOpGasLimit?: bigint;
40
+ }
41
+ /**
42
+ * Called exactly once per UserOp just before signing. Returns the fields
43
+ * to merge into the op. Internal-only — public callers configure paymaster
44
+ * via the top-level `paymasterAddress` option on `createSmartAccountClient`.
45
+ */
46
+ type PaymasterResolver = (ctx: PaymasterContext) => Promise<PaymasterFields>;
47
+ //#endregion
48
+ //#region src/actions/types.d.ts
49
+ /**
50
+ * Execution context every action receives. `createSmartAccountClient`
51
+ * builds this once and binds each action to it via `.extend()`.
52
+ */
53
+ interface SmartAccountActionContext {
54
+ account: ISmartAccount;
55
+ publicClient: PublicClient;
56
+ bundler: BundlerClient;
57
+ entryPoint: Address;
58
+ paymaster: PaymasterResolver;
59
+ }
60
+ /** The five UserOp gas fields the bundler returns from `eth_estimateUserOperationGas`. */
61
+ interface UserOperationGasEstimate {
62
+ callGasLimit: bigint;
63
+ verificationGasLimit: bigint;
64
+ preVerificationGas: bigint;
65
+ paymasterVerificationGasLimit?: bigint;
66
+ paymasterPostOpGasLimit?: bigint;
67
+ }
68
+ //#endregion
69
+ //#region src/actions/estimateUserOperationGas.d.ts
70
+ interface EstimateUserOperationGasParams {
71
+ calls: Call[];
72
+ overrides?: Partial<IUserOperation>;
73
+ paymasterFields?: PaymasterFields | null;
74
+ }
75
+ /**
76
+ * Low-level estimate that skips paymaster resolution — callers that want
77
+ * the full `{ calls, overrides }` surface should use the higher-level
78
+ * `estimateUserOperationGas` action below.
79
+ */
80
+ declare function estimateUserOpGasRaw(ctx: SmartAccountActionContext, op: IUserOperation): Promise<UserOperationGasEstimate>;
81
+ declare function estimateUserOperationGas(ctx: SmartAccountActionContext, params: EstimateUserOperationGasParams): Promise<UserOperationGasEstimate>;
82
+ //#endregion
83
+ //#region ../shared/src/chains/events.d.ts
84
+ /**
85
+ * Slice receipt logs for one userop's execution frame: all logs between the
86
+ * BeforeExecution marker (or the prior UserOperationEvent) and this op's
87
+ * UserOperationEvent.
88
+ */
89
+ declare function sliceUserOpLogs(receiptLogs: readonly Log[], userOpHash: Hex): Log[];
90
+ //#endregion
91
+ //#region src/actions/getUserOperationReceipt.d.ts
92
+ interface GetUserOperationReceiptParams {
93
+ userOpHash: Hex;
94
+ }
95
+ declare function getUserOperationReceipt(ctx: SmartAccountActionContext, {
96
+ userOpHash
97
+ }: GetUserOperationReceiptParams): Promise<UserOperationReceipt | null>;
98
+ //#endregion
99
+ //#region src/actions/waitForUserOperationReceipt.d.ts
100
+ interface WaitForUserOperationReceiptParams {
101
+ userOpHash: Hex;
102
+ /** Maximum time to wait, in milliseconds. Defaults to 60s. */
103
+ timeout?: number;
104
+ /** Polling interval in milliseconds. Defaults to 1000ms. */
105
+ pollingInterval?: number;
106
+ /** Optional abort signal to cancel the wait early. */
107
+ signal?: AbortSignal;
108
+ }
109
+ declare function waitForUserOperationReceipt(ctx: SmartAccountActionContext, params: WaitForUserOperationReceiptParams): Promise<UserOperationReceipt>;
110
+ //#endregion
111
+ //#region src/actions/watchUserOperations.d.ts
112
+ interface UserOperationEventMatch {
113
+ userOpHash: Hex;
114
+ sender: Address;
115
+ paymaster: Address;
116
+ nonce: bigint;
117
+ success: boolean;
118
+ actualGasCost: bigint;
119
+ actualGasUsed: bigint;
120
+ log: Log;
121
+ }
122
+ interface WatchUserOperationsParams {
123
+ /** Defaults to `ctx.account.address` when neither sender nor userOpHash is given. */
124
+ sender?: Address;
125
+ /** Narrows the filter to a single op. */
126
+ userOpHash?: Hex;
127
+ onUserOp: (event: UserOperationEventMatch) => void;
128
+ onError?: (err: unknown) => void;
129
+ }
130
+ /** Returned from `watchUserOperations` to stop the subscription. */
131
+ type UnwatchFn = () => void;
132
+ declare function watchUserOperations(ctx: SmartAccountActionContext, params: WatchUserOperationsParams): UnwatchFn;
133
+ //#endregion
134
+ //#region src/actions/writeContract.d.ts
135
+ /** Typed contract call — `args` are ABI-encoded by the SDK. */
136
+ interface TypedCall<TAbi extends Abi = Abi, TFn extends ContractFunctionName<TAbi, "nonpayable" | "payable"> = ContractFunctionName<TAbi, "nonpayable" | "payable">> {
137
+ address: Address;
138
+ abi: TAbi;
139
+ functionName: TFn;
140
+ args?: ContractFunctionArgs<TAbi, "nonpayable" | "payable", TFn>;
141
+ value?: bigint;
142
+ }
143
+ /** Raw call — ETH transfers, pre-encoded calldata, or calls to non-typed targets. */
144
+ interface RawCall {
145
+ to: Address;
146
+ value?: bigint;
147
+ data?: Hex;
148
+ }
149
+ /** Single entry, or a batch of mixed typed/raw entries (one UserOperation, `executeBatch`). */
150
+ type WriteContractInput = TypedCall | RawCall | ReadonlyArray<TypedCall | RawCall>;
151
+ /** UserOperation-level overrides for power users. */
152
+ interface WriteContractOverrides {
153
+ callGasLimit?: bigint;
154
+ verificationGasLimit?: bigint;
155
+ preVerificationGas?: bigint;
156
+ maxFeePerGas?: bigint;
157
+ maxPriorityFeePerGas?: bigint;
158
+ paymasterFields?: PaymasterFields;
159
+ nonce?: bigint;
160
+ }
161
+ /**
162
+ * Bound write-verb shape exposed on `SmartAccountClient`. Same overload set
163
+ * as the underlying `writeContract` but without the leading `ctx` argument.
164
+ */
165
+ interface BoundWriteContract {
166
+ <TAbi extends Abi, TFn extends ContractFunctionName<TAbi, "nonpayable" | "payable">>(input: TypedCall<TAbi, TFn>, overrides?: WriteContractOverrides): Promise<Hex>;
167
+ (input: RawCall, overrides?: WriteContractOverrides): Promise<Hex>;
168
+ (input: ReadonlyArray<TypedCall | RawCall>, overrides?: WriteContractOverrides): Promise<Hex>;
169
+ }
170
+ /**
171
+ * The single public write verb. Accepts:
172
+ * - a typed call: `{ address, abi, functionName, args?, value? }`
173
+ * - a raw call: `{ to, value?, data? }`
174
+ * - an array of either (batched into one UserOperation via `executeBatch`)
175
+ *
176
+ * Returns the `userOpHash`. Use `waitForUserOperationReceipt` to await inclusion.
177
+ */
178
+ declare function writeContract<TAbi extends Abi, TFn extends ContractFunctionName<TAbi, "nonpayable" | "payable">>(ctx: SmartAccountActionContext, input: TypedCall<TAbi, TFn>, overrides?: WriteContractOverrides): Promise<Hex>;
179
+ declare function writeContract(ctx: SmartAccountActionContext, input: RawCall, overrides?: WriteContractOverrides): Promise<Hex>;
180
+ declare function writeContract(ctx: SmartAccountActionContext, input: ReadonlyArray<TypedCall | RawCall>, overrides?: WriteContractOverrides): Promise<Hex>;
181
+ /** Build a context-bound `writeContract` for use on `SmartAccountClient`. */
182
+ declare function bindWriteContract(ctx: SmartAccountActionContext): BoundWriteContract;
183
+ //#endregion
184
+ export { CreateBundlerClientParams as C, BundlerClient as S, EstimateUserOperationGasParams as _, WriteContractOverrides as a, SmartAccountActionContext as b, UnwatchFn as c, watchUserOperations as d, WaitForUserOperationReceiptParams as f, sliceUserOpLogs as g, getUserOperationReceipt as h, WriteContractInput as i, UserOperationEventMatch as l, GetUserOperationReceiptParams as m, RawCall as n, bindWriteContract as o, waitForUserOperationReceipt as p, TypedCall as r, writeContract as s, BoundWriteContract as t, WatchUserOperationsParams as u, estimateUserOpGasRaw as v, createBundlerClient as w, UserOperationGasEstimate as x, estimateUserOperationGas as y };
package/package.json ADDED
@@ -0,0 +1,85 @@
1
+ {
2
+ "name": "@baliola/smart-account-sdk",
3
+ "version": "0.3.1",
4
+ "description": "Client-side SDK for Baliola's Smart Account (ERC-4337) stack on MAC",
5
+ "keywords": [
6
+ "erc-4337",
7
+ "account-abstraction",
8
+ "smart-account",
9
+ "viem",
10
+ "mac",
11
+ "baliola"
12
+ ],
13
+ "license": "SEE LICENSE IN LICENSE",
14
+ "author": "Baliola Development Team",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/baliola/smart-account.git",
18
+ "directory": "sdk"
19
+ },
20
+ "publishConfig": {
21
+ "registry": "https://registry.npmjs.org",
22
+ "access": "public"
23
+ },
24
+ "type": "module",
25
+ "sideEffects": false,
26
+ "main": "./dist/index.js",
27
+ "module": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.js"
33
+ },
34
+ "./accounts": {
35
+ "types": "./dist/accounts/index.d.ts",
36
+ "import": "./dist/accounts/index.js"
37
+ },
38
+ "./actions": {
39
+ "types": "./dist/actions/index.d.ts",
40
+ "import": "./dist/actions/index.js"
41
+ },
42
+ "./auth": {
43
+ "types": "./dist/auth/index.d.ts",
44
+ "import": "./dist/auth/index.js"
45
+ },
46
+ "./chains": {
47
+ "types": "./dist/chains/index.d.ts",
48
+ "import": "./dist/chains/index.js"
49
+ },
50
+ "./clients": {
51
+ "types": "./dist/clients/index.d.ts",
52
+ "import": "./dist/clients/index.js"
53
+ },
54
+ "./errors": {
55
+ "types": "./dist/errors/index.d.ts",
56
+ "import": "./dist/errors/index.js"
57
+ },
58
+ "./types": {
59
+ "types": "./dist/types/index.d.ts",
60
+ "import": "./dist/types/index.js"
61
+ }
62
+ },
63
+ "files": [
64
+ "dist",
65
+ "LICENSE",
66
+ "README.md"
67
+ ],
68
+ "scripts": {
69
+ "build": "tsdown",
70
+ "typecheck": "tsc --noEmit",
71
+ "test": "bun test test/unit test/integration",
72
+ "test:e2e": "LIVE=1 bun test --env-file=../bundler/.env test/e2e",
73
+ "prepublishOnly": "bun run build"
74
+ },
75
+ "peerDependencies": {
76
+ "viem": "^2.46"
77
+ },
78
+ "devDependencies": {
79
+ "@baliola/smart-account-shared": "workspace:*",
80
+ "@types/bun": "latest",
81
+ "tsdown": "^0.21.10",
82
+ "typescript": "^5.7.3",
83
+ "viem": "^2.46.3"
84
+ }
85
+ }