@getpara/aa-gelato 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.
- package/dist/action.d.ts +13 -0
- package/dist/action.js +91 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -0
- package/dist/package.json +3 -0
- package/dist/types.d.ts +26 -0
- package/dist/types.js +0 -0
- package/package.json +38 -0
package/dist/action.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { GelatoBundlerClient } from '@gelatocloud/gasless';
|
|
2
|
+
import type { SmartAccount7702 } from '@getpara/viem-v2-integration';
|
|
3
|
+
import type { CreateGelatoSmartAccountParams } from './types.js';
|
|
4
|
+
export type { CreateGelatoSmartAccountParams } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Creates a Gelato smart wallet using Para for signing.
|
|
7
|
+
*
|
|
8
|
+
* Uses Gelato's native SDK with EIP-7702. The SDK handles authorization internally.
|
|
9
|
+
*
|
|
10
|
+
* @param params - Configuration parameters
|
|
11
|
+
* @returns Unified SmartAccount interface wrapping Gelato bundler client, or null if no EVM wallet exists
|
|
12
|
+
*/
|
|
13
|
+
export declare function createGelatoSmartAccount(params: CreateGelatoSmartAccountParams): Promise<SmartAccount7702<GelatoBundlerClient> | null>;
|
package/dist/action.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { createGelatoBundlerClient, toGelatoSmartAccount } from "@gelatocloud/gasless";
|
|
2
|
+
import { createParaAccount } from "@getpara/viem-v2-integration";
|
|
3
|
+
import { SmartAccountError, wrapProviderError, resolveWalletIdentifier } from "@getpara/viem-v2-integration";
|
|
4
|
+
import { entryPoint08Address } from "viem/account-abstraction";
|
|
5
|
+
import { createPublicClient, http } from "viem";
|
|
6
|
+
const GELATO_DELEGATION_ADDRESS = "0x5aF42746a8Af42d8a4708dF238C53F1F71abF0E0";
|
|
7
|
+
async function createGelatoSmartAccount(params) {
|
|
8
|
+
const { para, apiKey, chain, rpcUrl } = params;
|
|
9
|
+
const walletAddress = resolveWalletIdentifier(para, params);
|
|
10
|
+
if (!walletAddress) return null;
|
|
11
|
+
const viemAccount = createParaAccount(para, walletAddress);
|
|
12
|
+
const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
|
|
13
|
+
const smartAccount = toGelatoSmartAccount({
|
|
14
|
+
client: publicClient,
|
|
15
|
+
owner: viemAccount
|
|
16
|
+
});
|
|
17
|
+
const isGelatoDelegated = await smartAccount.isDeployed();
|
|
18
|
+
const existingCode = await publicClient.getCode({ address: viemAccount.address });
|
|
19
|
+
const hasNonGelatoDelegation = !isGelatoDelegated && !!existingCode && existingCode !== "0x";
|
|
20
|
+
if (hasNonGelatoDelegation) {
|
|
21
|
+
smartAccount.isDeployed = async () => true;
|
|
22
|
+
smartAccount.getNonce = async (params2) => {
|
|
23
|
+
return await publicClient.readContract({
|
|
24
|
+
abi: [
|
|
25
|
+
{
|
|
26
|
+
name: "getNonce",
|
|
27
|
+
type: "function",
|
|
28
|
+
inputs: [
|
|
29
|
+
{ name: "sender", type: "address" },
|
|
30
|
+
{ name: "key", type: "uint192" }
|
|
31
|
+
],
|
|
32
|
+
outputs: [{ name: "nonce", type: "uint256" }]
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
address: entryPoint08Address,
|
|
36
|
+
args: [viemAccount.address, params2?.key ?? BigInt(0)],
|
|
37
|
+
functionName: "getNonce"
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const bundlerClient = await createGelatoBundlerClient({
|
|
42
|
+
account: smartAccount,
|
|
43
|
+
apiKey,
|
|
44
|
+
client: publicClient,
|
|
45
|
+
sponsored: true
|
|
46
|
+
});
|
|
47
|
+
if (!bundlerClient.account?.address) {
|
|
48
|
+
throw new SmartAccountError({
|
|
49
|
+
code: "MISSING_ACCOUNT_ADDRESS",
|
|
50
|
+
message: "Gelato bundler client must have an account address",
|
|
51
|
+
provider: "GELATO"
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const accountAddress = bundlerClient.account.address;
|
|
55
|
+
async function getAuthorizationIfNeeded() {
|
|
56
|
+
if (isGelatoDelegated) return void 0;
|
|
57
|
+
return await smartAccount.signAuthorization();
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
smartAccountAddress: accountAddress,
|
|
61
|
+
signer: viemAccount,
|
|
62
|
+
chain,
|
|
63
|
+
mode: "7702",
|
|
64
|
+
provider: "GELATO",
|
|
65
|
+
delegationAddress: GELATO_DELEGATION_ADDRESS,
|
|
66
|
+
async sendBatchTransaction(calls) {
|
|
67
|
+
try {
|
|
68
|
+
const authorization = await getAuthorizationIfNeeded();
|
|
69
|
+
const hash = await bundlerClient.sendUserOperation({
|
|
70
|
+
...authorization ? { authorization } : {},
|
|
71
|
+
calls: calls.map((c) => ({
|
|
72
|
+
to: c.to,
|
|
73
|
+
value: c.value || BigInt(0),
|
|
74
|
+
data: c.data || "0x"
|
|
75
|
+
}))
|
|
76
|
+
});
|
|
77
|
+
const { receipt } = await bundlerClient.waitForUserOperationReceipt({ hash });
|
|
78
|
+
return receipt;
|
|
79
|
+
} catch (error) {
|
|
80
|
+
throw wrapProviderError(error, "GELATO");
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
async sendTransaction(tx) {
|
|
84
|
+
return this.sendBatchTransaction([tx]);
|
|
85
|
+
},
|
|
86
|
+
client: bundlerClient
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export {
|
|
90
|
+
createGelatoSmartAccount
|
|
91
|
+
};
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ApiKeySmartAccountConfig, CreateSmartAccountParams } from '@getpara/viem-v2-integration';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for Gelato smart account.
|
|
4
|
+
*
|
|
5
|
+
* EIP-7702 only. Uses Gelato's relay for gas-sponsored transactions.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const config: GelatoSmartAccountConfig = {
|
|
10
|
+
* apiKey: 'YOUR_GELATO_API_KEY',
|
|
11
|
+
* chain: baseSepolia,
|
|
12
|
+
* };
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export interface GelatoSmartAccountConfig extends ApiKeySmartAccountConfig {
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Parameters for `createGelatoSmartAccount`.
|
|
19
|
+
* Includes all config fields plus `para` (the Para SDK instance).
|
|
20
|
+
*/
|
|
21
|
+
export type CreateGelatoSmartAccountParams = CreateSmartAccountParams<GelatoSmartAccountConfig>;
|
|
22
|
+
/**
|
|
23
|
+
* Parameters for the `useGelatoSmartAccount` hook.
|
|
24
|
+
* Same as {@link GelatoSmartAccountConfig} — `para` is provided automatically via context.
|
|
25
|
+
*/
|
|
26
|
+
export type UseGelatoSmartAccountParams = GelatoSmartAccountConfig;
|
package/dist/types.js
ADDED
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@getpara/aa-gelato",
|
|
3
|
+
"version": "2.16.0",
|
|
4
|
+
"description": "Gelato 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
|
+
"@gelatocloud/gasless": "^0.0.12",
|
|
26
|
+
"@getpara/viem-v2-integration": "2.16.0"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"viem": ">=2.0.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"typescript": "^5.8.3"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"gitHead": "fbe96a062b308d04105213378c12c38ee973c798"
|
|
38
|
+
}
|