@getpara/aa-cdp 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 +14 -0
- package/dist/action.js +64 -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 +28 -0
- package/dist/types.js +0 -0
- package/package.json +38 -0
package/dist/action.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BundlerClient } from 'viem/account-abstraction';
|
|
2
|
+
import type { SmartAccount4337 } from '@getpara/viem-v2-integration';
|
|
3
|
+
import type { CreateCDPSmartAccountParams } from './types.js';
|
|
4
|
+
export type { CreateCDPSmartAccountParams } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Creates a Coinbase Developer Platform smart account using Para for signing.
|
|
7
|
+
*
|
|
8
|
+
* Uses viem's toCoinbaseSmartAccount with EntryPoint v0.6 and CDP's paymaster
|
|
9
|
+
* for gas sponsorship. EIP-4337 only. Only supports Base and Base Sepolia.
|
|
10
|
+
*
|
|
11
|
+
* @param params - Configuration parameters
|
|
12
|
+
* @returns Unified SmartAccount4337 interface or null if no EVM wallet exists
|
|
13
|
+
*/
|
|
14
|
+
export declare function createCDPSmartAccount(params: CreateCDPSmartAccountParams): Promise<SmartAccount4337<BundlerClient> | null>;
|
package/dist/action.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { createParaAccount } from "@getpara/viem-v2-integration";
|
|
2
|
+
import { SmartAccountError, wrapProviderError, resolveWalletIdentifier } from "@getpara/viem-v2-integration";
|
|
3
|
+
import { createPublicClient, http } from "viem";
|
|
4
|
+
import { toCoinbaseSmartAccount, createBundlerClient } from "viem/account-abstraction";
|
|
5
|
+
const CDP_CHAIN_SLUGS = {
|
|
6
|
+
8453: "base",
|
|
7
|
+
84532: "base-sepolia"
|
|
8
|
+
};
|
|
9
|
+
async function createCDPSmartAccount(params) {
|
|
10
|
+
const { para, rpcToken, chain, rpcUrl } = params;
|
|
11
|
+
const chainSlug = CDP_CHAIN_SLUGS[chain.id];
|
|
12
|
+
if (!chainSlug) {
|
|
13
|
+
throw new Error(`CDP smart accounts only support Base (8453) and Base Sepolia (84532). Got chain ID ${chain.id}.`);
|
|
14
|
+
}
|
|
15
|
+
const walletAddress = resolveWalletIdentifier(para, params);
|
|
16
|
+
if (!walletAddress) return null;
|
|
17
|
+
const viemAccount = createParaAccount(para, walletAddress);
|
|
18
|
+
const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
|
|
19
|
+
const coinbaseAccount = await toCoinbaseSmartAccount({
|
|
20
|
+
client: publicClient,
|
|
21
|
+
owners: [viemAccount],
|
|
22
|
+
version: "1"
|
|
23
|
+
});
|
|
24
|
+
const paymasterUrl = `https://api.developer.coinbase.com/rpc/v1/${chainSlug}/${rpcToken}`;
|
|
25
|
+
const bundlerClient = createBundlerClient({
|
|
26
|
+
account: coinbaseAccount,
|
|
27
|
+
chain,
|
|
28
|
+
transport: http(paymasterUrl),
|
|
29
|
+
paymaster: true
|
|
30
|
+
});
|
|
31
|
+
const accountAddress = bundlerClient.account?.address;
|
|
32
|
+
if (!accountAddress) {
|
|
33
|
+
throw new SmartAccountError({
|
|
34
|
+
code: "MISSING_ACCOUNT_ADDRESS",
|
|
35
|
+
message: "CDP bundler client must have an account address",
|
|
36
|
+
provider: "CDP"
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
const sendBatchTransaction = async (calls) => {
|
|
40
|
+
try {
|
|
41
|
+
const hash = await bundlerClient.sendUserOperation({
|
|
42
|
+
calls: calls.map((c) => ({ to: c.to, value: c.value || BigInt(0), data: c.data || "0x" }))
|
|
43
|
+
});
|
|
44
|
+
const { receipt } = await bundlerClient.waitForUserOperationReceipt({ hash });
|
|
45
|
+
return receipt;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
throw wrapProviderError(error, "CDP");
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const sendTransaction = async (tx) => sendBatchTransaction([tx]);
|
|
51
|
+
return {
|
|
52
|
+
smartAccountAddress: accountAddress,
|
|
53
|
+
signer: viemAccount,
|
|
54
|
+
chain,
|
|
55
|
+
mode: "4337",
|
|
56
|
+
provider: "CDP",
|
|
57
|
+
sendBatchTransaction,
|
|
58
|
+
sendTransaction,
|
|
59
|
+
client: bundlerClient
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
createCDPSmartAccount
|
|
64
|
+
};
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ChainBasedSmartAccountConfig, CreateSmartAccountParams } from '@getpara/viem-v2-integration';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for Coinbase Developer Platform (CDP) smart account.
|
|
4
|
+
*
|
|
5
|
+
* EIP-4337 only. Only supports Base and Base Sepolia.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const config: CDPSmartAccountConfig = {
|
|
10
|
+
* chain: baseSepolia,
|
|
11
|
+
* rpcToken: 'YOUR_CDP_RPC_TOKEN',
|
|
12
|
+
* };
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export interface CDPSmartAccountConfig extends ChainBasedSmartAccountConfig {
|
|
16
|
+
/** CDP RPC token (the token segment from the paymaster URL) */
|
|
17
|
+
rpcToken: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Parameters for `createCDPSmartAccount`.
|
|
21
|
+
* Includes all config fields plus `para` (the Para SDK instance).
|
|
22
|
+
*/
|
|
23
|
+
export type CreateCDPSmartAccountParams = CreateSmartAccountParams<CDPSmartAccountConfig>;
|
|
24
|
+
/**
|
|
25
|
+
* Parameters for the `useCDPSmartAccount` hook.
|
|
26
|
+
* Same as {@link CDPSmartAccountConfig} — `para` is provided automatically via context.
|
|
27
|
+
*/
|
|
28
|
+
export type UseCDPSmartAccountParams = CDPSmartAccountConfig;
|
package/dist/types.js
ADDED
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@getpara/aa-cdp",
|
|
3
|
+
"version": "2.16.0",
|
|
4
|
+
"description": "Coinbase Developer Platform 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/viem-v2-integration": "2.16.0",
|
|
26
|
+
"permissionless": "^0.2.12"
|
|
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
|
+
}
|