@getpara/aa-safe 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,13 @@
1
+ import { type SmartAccountClient } from 'permissionless';
2
+ import type { SmartAccount4337 } from '@getpara/viem-v2-integration';
3
+ import type { CreateSafeSmartAccountParams } from './types.js';
4
+ export type { CreateSafeSmartAccountParams, SafeTransactionOptions } from './types.js';
5
+ /**
6
+ * Creates a Safe smart account using Para for signing.
7
+ *
8
+ * Supports gas sponsorship via Pimlico's paymaster with EntryPoint v0.7.
9
+ *
10
+ * @param params - Configuration parameters
11
+ * @returns Unified SmartAccount interface wrapping Safe client, or null if no EVM wallet exists
12
+ */
13
+ export declare function createSafeSmartAccount(params: CreateSafeSmartAccountParams): Promise<SmartAccount4337<SmartAccountClient> | null>;
package/dist/action.js ADDED
@@ -0,0 +1,83 @@
1
+ import { createSmartAccountClient } from "permissionless";
2
+ import { toSafeSmartAccount } from "permissionless/accounts";
3
+ import { createPimlicoClient } from "permissionless/clients/pimlico";
4
+ import { createParaAccount } from "@getpara/viem-v2-integration";
5
+ import { SmartAccountError, wrapProviderError, resolveWalletIdentifier } from "@getpara/viem-v2-integration";
6
+ import { buildPimlicoRpcUrl } from "@getpara/aa-pimlico";
7
+ import { createPublicClient, http } from "viem";
8
+ import { entryPoint07Address } from "viem/account-abstraction";
9
+ async function createSafeSmartAccount(params) {
10
+ const { para, pimlicoApiKey, chain, rpcUrl, safeVersion = "1.4.1", saltNonce } = params;
11
+ const walletAddress = resolveWalletIdentifier(para, params);
12
+ if (!walletAddress) return null;
13
+ const pimlicoRpcUrl = buildPimlicoRpcUrl(chain, pimlicoApiKey);
14
+ const viemAccount = createParaAccount(para, walletAddress);
15
+ const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
16
+ const paymasterClient = createPimlicoClient({
17
+ entryPoint: {
18
+ address: entryPoint07Address,
19
+ version: "0.7"
20
+ },
21
+ transport: http(pimlicoRpcUrl)
22
+ });
23
+ const safeAccount = await toSafeSmartAccount({
24
+ client: publicClient,
25
+ owners: [viemAccount],
26
+ entryPoint: {
27
+ address: entryPoint07Address,
28
+ version: "0.7"
29
+ },
30
+ version: safeVersion,
31
+ ...saltNonce !== void 0 && { saltNonce }
32
+ });
33
+ const smartAccountClient = createSmartAccountClient({
34
+ account: safeAccount,
35
+ chain,
36
+ paymaster: paymasterClient,
37
+ bundlerTransport: http(pimlicoRpcUrl),
38
+ userOperation: {
39
+ estimateFeesPerGas: async () => {
40
+ const gasPrice = await paymasterClient.getUserOperationGasPrice();
41
+ return gasPrice.fast;
42
+ }
43
+ }
44
+ });
45
+ if (!smartAccountClient.account?.address) {
46
+ throw new SmartAccountError({
47
+ code: "MISSING_ACCOUNT_ADDRESS",
48
+ message: "Safe client must have an account address",
49
+ provider: "SAFE"
50
+ });
51
+ }
52
+ const sendBatchTransaction = async (calls, options) => {
53
+ const safeOptions = options;
54
+ try {
55
+ const hash = await smartAccountClient.sendTransaction({
56
+ account: safeOptions?.account || smartAccountClient.account,
57
+ chain: safeOptions?.chain || smartAccountClient.chain,
58
+ calls,
59
+ ...safeOptions?.middleware
60
+ });
61
+ if ("waitForTransactionReceipt" in smartAccountClient && typeof smartAccountClient.waitForTransactionReceipt === "function") {
62
+ return smartAccountClient.waitForTransactionReceipt({ hash });
63
+ }
64
+ return publicClient.getTransactionReceipt({ hash });
65
+ } catch (error) {
66
+ throw wrapProviderError(error, "SAFE");
67
+ }
68
+ };
69
+ const sendTransaction = async (tx, options) => sendBatchTransaction([tx], options);
70
+ return {
71
+ smartAccountAddress: smartAccountClient.account.address,
72
+ signer: viemAccount,
73
+ chain,
74
+ mode: "4337",
75
+ provider: "SAFE",
76
+ sendBatchTransaction,
77
+ sendTransaction,
78
+ client: smartAccountClient
79
+ };
80
+ }
81
+ export {
82
+ createSafeSmartAccount
83
+ };
@@ -0,0 +1,2 @@
1
+ export { createSafeSmartAccount } from './action.js';
2
+ export type { SafeSmartAccountConfig, CreateSafeSmartAccountParams, UseSafeSmartAccountParams, SafeTransactionOptions, } from './types.js';
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import { createSafeSmartAccount } from "./action.js";
2
+ export {
3
+ createSafeSmartAccount
4
+ };
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,57 @@
1
+ import type { Chain } from 'viem';
2
+ import type { ChainBasedSmartAccountConfig, CreateSmartAccountParams } from '@getpara/viem-v2-integration';
3
+ /**
4
+ * Configuration for Safe smart account.
5
+ *
6
+ * EIP-4337 only. Uses permissionless's Safe implementation with Pimlico's
7
+ * bundler and paymaster infrastructure.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const config: SafeSmartAccountConfig = {
12
+ * chain: baseSepolia,
13
+ * pimlicoApiKey: 'YOUR_PIMLICO_API_KEY',
14
+ * };
15
+ * ```
16
+ */
17
+ export interface SafeSmartAccountConfig extends ChainBasedSmartAccountConfig {
18
+ /** Pimlico API key for bundler and paymaster services */
19
+ pimlicoApiKey: string;
20
+ /**
21
+ * Safe version to use
22
+ * @default '1.4.1'
23
+ */
24
+ safeVersion?: '1.4.1';
25
+ /** Optional salt nonce for deterministic address generation */
26
+ saltNonce?: bigint;
27
+ }
28
+ /**
29
+ * Parameters for `createSafeSmartAccount`.
30
+ * Includes all config fields plus `para` (the Para SDK instance).
31
+ */
32
+ export type CreateSafeSmartAccountParams = CreateSmartAccountParams<SafeSmartAccountConfig>;
33
+ /**
34
+ * Parameters for the `useSafeSmartAccount` hook.
35
+ * Same as {@link SafeSmartAccountConfig} — `para` is provided automatically via context.
36
+ */
37
+ export type UseSafeSmartAccountParams = SafeSmartAccountConfig;
38
+ /**
39
+ * Safe-specific transaction options.
40
+ * Pass as the second argument to `sendTransaction` or `sendBatchTransaction`.
41
+ */
42
+ export interface SafeTransactionOptions {
43
+ /** Custom gas and sponsorship middleware */
44
+ middleware?: {
45
+ gasPrice?: () => Promise<{
46
+ maxFeePerGas: bigint;
47
+ maxPriorityFeePerGas: bigint;
48
+ }>;
49
+ sponsorUserOperation?: (args: {
50
+ userOperation: Record<string, unknown>;
51
+ }) => Promise<Record<string, unknown>>;
52
+ };
53
+ /** Override the account address */
54
+ account?: `0x${string}`;
55
+ /** Override the chain */
56
+ chain?: Chain;
57
+ }
package/dist/types.js ADDED
File without changes
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@getpara/aa-safe",
3
+ "version": "2.16.0",
4
+ "description": "Safe smart account integration for Para",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "sideEffects": false,
9
+ "files": [
10
+ "dist",
11
+ "package.json"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ }
18
+ },
19
+ "scripts": {
20
+ "build": "rm -rf dist && yarn typegen && node ./scripts/build.mjs",
21
+ "typegen": "tsc --emitDeclarationOnly --outDir dist",
22
+ "test": "vitest run --coverage"
23
+ },
24
+ "dependencies": {
25
+ "@getpara/aa-pimlico": "2.16.0",
26
+ "@getpara/viem-v2-integration": "2.16.0",
27
+ "permissionless": "^0.2.12"
28
+ },
29
+ "peerDependencies": {
30
+ "viem": ">=2.0.0"
31
+ },
32
+ "devDependencies": {
33
+ "typescript": "^5.8.3"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "gitHead": "fbe96a062b308d04105213378c12c38ee973c798"
39
+ }