@getpara/aa-biconomy 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,21 @@
1
+ import type { MeeClient } from '@biconomy/abstractjs';
2
+ import type { SmartAccount4337, SmartAccount7702 } from '@getpara/viem-v2-integration';
3
+ import type { CreateBiconomySmartAccountParams } from './types.js';
4
+ export type { CreateBiconomySmartAccountParams } from './types.js';
5
+ /**
6
+ * Creates a Biconomy MEE smart account using Para for signing.
7
+ *
8
+ * Uses the @biconomy/abstractjs SDK with toMultichainNexusAccount and createMeeClient.
9
+ * Transactions are executed via MEE's getQuote + executeQuote flow which handles
10
+ * gas sponsorship and cross-chain orchestration.
11
+ *
12
+ * @param params - Configuration parameters
13
+ * @returns Unified SmartAccount interface wrapping Biconomy MEE client, or null if no EVM wallet exists
14
+ */
15
+ export declare function createBiconomySmartAccount(params: CreateBiconomySmartAccountParams & {
16
+ mode: '7702';
17
+ }): Promise<SmartAccount7702<MeeClient> | null>;
18
+ export declare function createBiconomySmartAccount(params: CreateBiconomySmartAccountParams & {
19
+ mode?: '4337';
20
+ }): Promise<SmartAccount4337<MeeClient> | null>;
21
+ export declare function createBiconomySmartAccount(params: CreateBiconomySmartAccountParams): Promise<SmartAccount4337<MeeClient> | SmartAccount7702<MeeClient> | null>;
package/dist/action.js ADDED
@@ -0,0 +1,116 @@
1
+ import {
2
+ createMeeClient,
3
+ toMultichainNexusAccount,
4
+ getMEEVersion,
5
+ MEEVersion,
6
+ getDefaultMEENetworkUrl,
7
+ getDefaultMeeGasTank
8
+ } from "@biconomy/abstractjs";
9
+ import { createParaAccount } from "@getpara/viem-v2-integration";
10
+ import { SmartAccountError, wrapProviderError, resolveWalletIdentifier } from "@getpara/viem-v2-integration";
11
+ import { http } from "viem";
12
+ const TESTNET_MEE_NETWORK_API_KEY = "mee_3Zmc7H6Pbd5wUfUGu27aGzdf";
13
+ async function createBiconomySmartAccount(params) {
14
+ const { para, chain, rpcUrl, meeUrl, apiKey, mode = "4337" } = params;
15
+ const walletAddress = resolveWalletIdentifier(para, params);
16
+ if (!walletAddress) return null;
17
+ const viemAccount = createParaAccount(para, walletAddress);
18
+ const isTestnet = chain.testnet;
19
+ const resolvedUrl = meeUrl || (isTestnet ? getDefaultMEENetworkUrl(true) : void 0);
20
+ const resolvedApiKey = isTestnet ? TESTNET_MEE_NETWORK_API_KEY : apiKey;
21
+ const chainConfig = {
22
+ chain,
23
+ transport: http(rpcUrl),
24
+ version: getMEEVersion(MEEVersion.V2_1_0),
25
+ ...mode === "7702" && { accountAddress: viemAccount.address }
26
+ };
27
+ const mcNexus = await toMultichainNexusAccount({
28
+ signer: viemAccount,
29
+ chainConfigurations: [chainConfig]
30
+ });
31
+ const chainId = chain.id;
32
+ const needsDelegation = mode === "7702" && !await mcNexus.isDelegated();
33
+ if (needsDelegation) {
34
+ for (const dep of mcNexus.deployments) {
35
+ dep.isDeployed = async () => false;
36
+ }
37
+ }
38
+ const meeClient = await createMeeClient({
39
+ account: mcNexus,
40
+ url: resolvedUrl,
41
+ apiKey: resolvedApiKey
42
+ });
43
+ const deployment = meeClient.account.deployments.find(
44
+ (d) => (d.chainId ?? d.chain?.id) === chainId
45
+ );
46
+ const accountAddress = deployment?.address ?? meeClient.account.deployments[0]?.address;
47
+ if (!accountAddress) {
48
+ throw new SmartAccountError({
49
+ code: "MISSING_ACCOUNT_ADDRESS",
50
+ message: "Unable to determine account address from Biconomy MEE client",
51
+ provider: "BICONOMY"
52
+ });
53
+ }
54
+ const sponsorshipConfig = {
55
+ sponsorship: true,
56
+ sponsorshipOptions: {
57
+ gasTank: isTestnet ? getDefaultMeeGasTank(isTestnet) : void 0,
58
+ url: meeUrl || (isTestnet ? getDefaultMEENetworkUrl(isTestnet) : void 0),
59
+ ...apiKey ? { apiKey } : {}
60
+ }
61
+ };
62
+ const sendBatchTransaction = async (calls) => {
63
+ const quoteParams = {
64
+ instructions: [
65
+ {
66
+ calls: calls.map((c) => ({
67
+ to: c.to,
68
+ value: c.value || BigInt(0),
69
+ data: c.data || "0x"
70
+ })),
71
+ chainId
72
+ }
73
+ ],
74
+ ...sponsorshipConfig,
75
+ ...needsDelegation ? { delegate: true, multichain7702Auth: true } : {}
76
+ };
77
+ try {
78
+ const quote = await meeClient.getQuote(quoteParams);
79
+ const { hash } = await meeClient.executeQuote({ quote });
80
+ const superReceipt = await Promise.race([
81
+ meeClient.waitForSupertransactionReceipt({
82
+ hash
83
+ }),
84
+ new Promise(
85
+ (_, reject) => setTimeout(() => reject(new Error("Biconomy supertransaction timed out after 120s")), 12e4)
86
+ )
87
+ ]);
88
+ const receipt = superReceipt.receipts?.[0];
89
+ if (!receipt) {
90
+ throw new SmartAccountError({
91
+ code: "RECEIPT_MISSING",
92
+ message: "Biconomy supertransaction completed but no on-chain receipt was returned",
93
+ provider: "BICONOMY"
94
+ });
95
+ }
96
+ return receipt;
97
+ } catch (error) {
98
+ throw wrapProviderError(error, "BICONOMY");
99
+ }
100
+ };
101
+ const sendTransaction = async (tx) => sendBatchTransaction([tx]);
102
+ const resolvedChain = deployment?.chain;
103
+ return {
104
+ smartAccountAddress: accountAddress,
105
+ signer: viemAccount,
106
+ chain: resolvedChain,
107
+ mode,
108
+ provider: "BICONOMY",
109
+ sendTransaction,
110
+ sendBatchTransaction,
111
+ client: meeClient
112
+ };
113
+ }
114
+ export {
115
+ createBiconomySmartAccount
116
+ };
@@ -0,0 +1,2 @@
1
+ export { createBiconomySmartAccount } from './action.js';
2
+ export type { BiconomySmartAccountConfig, CreateBiconomySmartAccountParams, UseBiconomySmartAccountParams, } from './types.js';
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import { createBiconomySmartAccount } from "./action.js";
2
+ export {
3
+ createBiconomySmartAccount
4
+ };
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,32 @@
1
+ import type { Url } from '@biconomy/abstractjs';
2
+ import type { ChainBasedSmartAccountConfig, CreateSmartAccountParams, SmartAccountModeParam } from '@getpara/viem-v2-integration';
3
+ /**
4
+ * Configuration for Biconomy smart account.
5
+ *
6
+ * Supports both EIP-4337 and EIP-7702 modes. Transactions are executed via
7
+ * Biconomy's MEE (Multi-chain Execution Environment).
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const config: BiconomySmartAccountConfig = {
12
+ * chain: baseSepolia,
13
+ * apiKey: 'YOUR_BICONOMY_API_KEY',
14
+ * };
15
+ * ```
16
+ */
17
+ export interface BiconomySmartAccountConfig extends ChainBasedSmartAccountConfig, SmartAccountModeParam {
18
+ /** Optional MEE node URL */
19
+ meeUrl?: Url;
20
+ /** MEE API key (required for gas sponsorship) */
21
+ apiKey: string;
22
+ }
23
+ /**
24
+ * Parameters for `createBiconomySmartAccount`.
25
+ * Includes all config fields plus `para` (the Para SDK instance).
26
+ */
27
+ export type CreateBiconomySmartAccountParams = CreateSmartAccountParams<BiconomySmartAccountConfig>;
28
+ /**
29
+ * Parameters for the `useBiconomySmartAccount` hook.
30
+ * Same as {@link BiconomySmartAccountConfig} — `para` is provided automatically via context.
31
+ */
32
+ export type UseBiconomySmartAccountParams = BiconomySmartAccountConfig;
package/dist/types.js ADDED
File without changes
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@getpara/aa-biconomy",
3
+ "version": "2.16.0",
4
+ "description": "Biconomy 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
+ "@biconomy/abstractjs": "1.1.21",
26
+ "@getpara/viem-v2-integration": "2.16.0",
27
+ "@safe-global/types-kit": "^3.0.0"
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
+ }