@getpara/aa-alchemy 2.16.0 → 2.17.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/action.d.ts +1 -1
- package/dist/action.js +34 -15
- package/dist/types.d.ts +1 -1
- package/package.json +3 -3
package/dist/action.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type SmartAccountClient } from '@aa-sdk/core';
|
|
2
|
-
import type { SmartAccount4337, SmartAccount7702 } from '@getpara/viem-v2-integration';
|
|
2
|
+
import type { SmartAccount4337, SmartAccount7702 } from '@getpara/viem-v2-integration/aa';
|
|
3
3
|
import type { CreateAlchemySmartAccountParams } from './types.js';
|
|
4
4
|
export type { CreateAlchemySmartAccountParams, AlchemyTransactionOptions } from './types.js';
|
|
5
5
|
/**
|
package/dist/action.js
CHANGED
|
@@ -2,7 +2,16 @@ import { createModularAccountAlchemyClient, createModularAccountV2Client } from
|
|
|
2
2
|
import * as alchemyInfra from "@account-kit/infra";
|
|
3
3
|
import { WalletClientSigner } from "@aa-sdk/core";
|
|
4
4
|
import { createParaAccount } from "@getpara/viem-v2-integration";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
SmartAccountError,
|
|
7
|
+
wrapProviderError,
|
|
8
|
+
resolveWalletIdentifier,
|
|
9
|
+
ensureExternalWalletChain,
|
|
10
|
+
rejectExternalWallet7702,
|
|
11
|
+
assertAccountAddress,
|
|
12
|
+
isExternalWallet,
|
|
13
|
+
resolveExternalSigner
|
|
14
|
+
} from "@getpara/viem-v2-integration/aa";
|
|
6
15
|
import { createWalletClient, createPublicClient, http } from "viem";
|
|
7
16
|
const ALCHEMY_7702_DELEGATION_ADDRESS = "0x69007702764179f14F51cdce752f4f775d74E139";
|
|
8
17
|
const alchemyChainById = new Map(
|
|
@@ -19,14 +28,29 @@ function ensureAlchemyChain(chain) {
|
|
|
19
28
|
});
|
|
20
29
|
}
|
|
21
30
|
async function createAlchemySmartAccount(params) {
|
|
22
|
-
const { para, apiKey, chain: rawChain, rpcUrl, gasPolicyId, mode = "4337" } = params;
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
31
|
+
const { para, apiKey, chain: rawChain, rpcUrl, gasPolicyId, mode: rawMode = "4337" } = params;
|
|
32
|
+
const mode = rawMode;
|
|
33
|
+
if (mode === "7702") rejectExternalWallet7702(params.signer, "ALCHEMY");
|
|
25
34
|
const chain = ensureAlchemyChain(rawChain);
|
|
26
|
-
const viemAccount = createParaAccount(para, walletAddress);
|
|
27
|
-
const viemClient = createWalletClient({ account: viemAccount, chain, transport: http(rpcUrl) });
|
|
28
35
|
const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
|
|
29
|
-
|
|
36
|
+
let viemAccount;
|
|
37
|
+
let walletClientSigner;
|
|
38
|
+
if (params.signer) {
|
|
39
|
+
if (isExternalWallet(params.signer)) {
|
|
40
|
+
viemAccount = resolveExternalSigner(params.signer);
|
|
41
|
+
walletClientSigner = new WalletClientSigner(params.signer, "external");
|
|
42
|
+
} else {
|
|
43
|
+
viemAccount = params.signer;
|
|
44
|
+
const viemClient = createWalletClient({ account: viemAccount, chain, transport: http(rpcUrl) });
|
|
45
|
+
walletClientSigner = new WalletClientSigner(viemClient, "external");
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
const walletAddress = resolveWalletIdentifier(para, params);
|
|
49
|
+
if (!walletAddress) return null;
|
|
50
|
+
viemAccount = createParaAccount(para, walletAddress);
|
|
51
|
+
const viemClient = createWalletClient({ account: viemAccount, chain, transport: http(rpcUrl) });
|
|
52
|
+
walletClientSigner = new WalletClientSigner(viemClient, "para");
|
|
53
|
+
}
|
|
30
54
|
let alchemyClient;
|
|
31
55
|
if (mode === "7702") {
|
|
32
56
|
alchemyClient = await createModularAccountV2Client({
|
|
@@ -44,15 +68,10 @@ async function createAlchemySmartAccount(params) {
|
|
|
44
68
|
policyId: gasPolicyId
|
|
45
69
|
});
|
|
46
70
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
throw new SmartAccountError({
|
|
50
|
-
code: "MISSING_ACCOUNT_ADDRESS",
|
|
51
|
-
message: "Unable to determine account address from Alchemy client",
|
|
52
|
-
provider: "ALCHEMY"
|
|
53
|
-
});
|
|
54
|
-
}
|
|
71
|
+
assertAccountAddress(alchemyClient.account?.address, "Alchemy client", "ALCHEMY");
|
|
72
|
+
const accountAddress = alchemyClient.account.address;
|
|
55
73
|
const sendBatchTransaction = async (calls, txOptions) => {
|
|
74
|
+
await ensureExternalWalletChain(params.signer, chain, "ALCHEMY");
|
|
56
75
|
const alchemyOptions = txOptions;
|
|
57
76
|
if (!alchemyClient.sendUserOperation) {
|
|
58
77
|
throw new SmartAccountError({
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { UserOperationOverrides } from '@aa-sdk/core';
|
|
2
|
-
import type { ApiKeySmartAccountConfig, CreateSmartAccountParams, SmartAccountModeParam } from '@getpara/viem-v2-integration';
|
|
2
|
+
import type { ApiKeySmartAccountConfig, CreateSmartAccountParams, SmartAccountModeParam } from '@getpara/viem-v2-integration/aa';
|
|
3
3
|
/**
|
|
4
4
|
* Configuration for Alchemy smart account.
|
|
5
5
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/aa-alchemy",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.0",
|
|
4
4
|
"description": "Alchemy smart account integration for Para",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@aa-sdk/core": "^4.84.1",
|
|
26
26
|
"@account-kit/infra": "^4.84.1",
|
|
27
27
|
"@account-kit/smart-contracts": "^4.84.1",
|
|
28
|
-
"@getpara/viem-v2-integration": "2.
|
|
28
|
+
"@getpara/viem-v2-integration": "2.17.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"viem": ">=2.0.0"
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "3ed1f835b97ae720f1ac747611296e3b86f61138"
|
|
40
40
|
}
|