@dag-kit/kit 1.0.2 → 1.0.4-alpha.3
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/index.cjs +564 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +209 -0
- package/dist/index.d.ts +209 -0
- package/dist/index.js +544 -0
- package/dist/index.js.map +1 -0
- package/package.json +16 -11
- package/src/clients/actions/contract.ts +1 -1
- package/src/clients/actions/example.ts +252 -252
- package/src/clients/actions/example2.ts +60 -60
- package/src/clients/actions/index.ts +145 -0
- package/src/clients/actions/main.ts +34 -17
- package/src/clients/actions/test.ts +210 -210
- package/src/clients/types.ts +2 -1
- package/src/exports/index.ts +7 -4
- package/src/exports/public-types.ts +6 -0
- package/src/index.ts +17 -0
- package/src/signers/PrivateKeySigner.ts +41 -0
- package/src/signers/PrivySigner.ts +93 -0
- package/src/signers/types.ts +45 -0
- package/src/version.ts +1 -1
- package/dist/esm/clients/actions/contract.js +0 -42
- package/dist/esm/clients/actions/example.js +0 -211
- package/dist/esm/clients/actions/example2.js +0 -50
- package/dist/esm/clients/actions/index.js +0 -1
- package/dist/esm/clients/actions/main.js +0 -415
- package/dist/esm/clients/actions/test.js +0 -1
- package/dist/esm/clients/actions/testPaymasterService.js +0 -88
- package/dist/esm/clients/chains.js +0 -19
- package/dist/esm/clients/types.js +0 -1
- package/dist/esm/exports/index.js +0 -2
- package/dist/esm/version.js +0 -3
- package/dist/types/clients/actions/contract.d.ts +0 -12
- package/dist/types/clients/actions/contract.d.ts.map +0 -1
- package/dist/types/clients/actions/example.d.ts +0 -2
- package/dist/types/clients/actions/example.d.ts.map +0 -1
- package/dist/types/clients/actions/example2.d.ts +0 -2
- package/dist/types/clients/actions/example2.d.ts.map +0 -1
- package/dist/types/clients/actions/index.d.ts +0 -1
- package/dist/types/clients/actions/index.d.ts.map +0 -1
- package/dist/types/clients/actions/main.d.ts +0 -40
- package/dist/types/clients/actions/main.d.ts.map +0 -1
- package/dist/types/clients/actions/test.d.ts +0 -1
- package/dist/types/clients/actions/test.d.ts.map +0 -1
- package/dist/types/clients/actions/testPaymasterService.d.ts +0 -2
- package/dist/types/clients/actions/testPaymasterService.d.ts.map +0 -1
- package/dist/types/clients/chains.d.ts +0 -81
- package/dist/types/clients/chains.d.ts.map +0 -1
- package/dist/types/clients/types.d.ts +0 -31
- package/dist/types/clients/types.d.ts.map +0 -1
- package/dist/types/exports/index.d.ts +0 -4
- package/dist/types/exports/index.d.ts.map +0 -1
- package/dist/types/version.d.ts +0 -2
- package/dist/types/version.d.ts.map +0 -1
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// import {
|
|
2
|
+
// createPublicClient,
|
|
3
|
+
// createWalletClient,
|
|
4
|
+
// encodeFunctionData,
|
|
5
|
+
// formatEther,
|
|
6
|
+
// http,
|
|
7
|
+
// parseEther,
|
|
8
|
+
// parseGwei,
|
|
9
|
+
// } from "viem";
|
|
10
|
+
// import { awakening } from "../chains";
|
|
11
|
+
// import { privateKeyToAccount } from "viem/accounts";
|
|
12
|
+
// import { entryPoint06Address } from "viem/account-abstraction";
|
|
13
|
+
// import { toSimpleSmartAccount } from "permissionless/accounts";
|
|
14
|
+
// import { createSmartAccountClient } from "permissionless";
|
|
15
|
+
// import { createPimlicoClient } from "permissionless/clients/pimlico";
|
|
16
|
+
// import { abi } from "./contract";
|
|
17
|
+
|
|
18
|
+
// const { bundler_rpc, chain_config } = awakening;
|
|
19
|
+
// const FACTORY_ADDRESS = "0x8FaB6DF00085eb05D5F2C1FA46a6E539587ae3f3";
|
|
20
|
+
// const adminKey =
|
|
21
|
+
// "0x6b0f66a03b67d7b9eaa6c31123ffe5bf2ee58eb40ab86c8a14d6f1294838b0c8";
|
|
22
|
+
|
|
23
|
+
// const publicClient = createPublicClient({
|
|
24
|
+
// chain: awakening.chain_config,
|
|
25
|
+
// transport: http(awakening.chain_config.rpcUrls.default.http[0]),
|
|
26
|
+
// });
|
|
27
|
+
|
|
28
|
+
// const walletClient = createWalletClient({
|
|
29
|
+
// account: privateKeyToAccount(adminKey),
|
|
30
|
+
// chain: chain_config,
|
|
31
|
+
// transport: http(chain_config.rpcUrls.default.http[0]),
|
|
32
|
+
// });
|
|
33
|
+
|
|
34
|
+
// const account = await toSimpleSmartAccount({
|
|
35
|
+
// client: publicClient,
|
|
36
|
+
// owner: privateKeyToAccount(adminKey),
|
|
37
|
+
// factoryAddress: FACTORY_ADDRESS,
|
|
38
|
+
// entryPoint: {
|
|
39
|
+
// address: entryPoint06Address,
|
|
40
|
+
// version: "0.6",
|
|
41
|
+
// },
|
|
42
|
+
// index: 100n,
|
|
43
|
+
// });
|
|
44
|
+
|
|
45
|
+
// console.log("Account Address: %s", account.address);
|
|
46
|
+
// // Check if account is deployed
|
|
47
|
+
// let code = await publicClient.getCode({
|
|
48
|
+
// address: account.address,
|
|
49
|
+
// });
|
|
50
|
+
|
|
51
|
+
// let isDeployed = code && code !== "0x";
|
|
52
|
+
// console.log(
|
|
53
|
+
// `Deployment Status: ${isDeployed ? "✅ Deployed" : "⚠️ Not deployed"}`
|
|
54
|
+
// );
|
|
55
|
+
|
|
56
|
+
// if (!isDeployed) {
|
|
57
|
+
// const fundTx = await walletClient.sendTransaction({
|
|
58
|
+
// to: account.address,
|
|
59
|
+
// value: parseEther("10"),
|
|
60
|
+
// chain: undefined,
|
|
61
|
+
// });
|
|
62
|
+
|
|
63
|
+
// await publicClient.waitForTransactionReceipt({
|
|
64
|
+
// hash: fundTx,
|
|
65
|
+
// timeout: 120_000,
|
|
66
|
+
// pollingInterval: 5_000,
|
|
67
|
+
// });
|
|
68
|
+
// console.log("Account funded");
|
|
69
|
+
// }
|
|
70
|
+
|
|
71
|
+
// console.log("\n==== Sending Test UserOperation =====");
|
|
72
|
+
// const cd = encodeFunctionData({
|
|
73
|
+
// abi,
|
|
74
|
+
// functionName: "increment",
|
|
75
|
+
// args: [],
|
|
76
|
+
// });
|
|
77
|
+
|
|
78
|
+
// const smartAccountClient = createSmartAccountClient({
|
|
79
|
+
// bundlerTransport: http(bundler_rpc),
|
|
80
|
+
// chain: awakening,
|
|
81
|
+
// account,
|
|
82
|
+
// });
|
|
83
|
+
|
|
84
|
+
// // Simple test: send 0 ETH to self (just to test the flow)
|
|
85
|
+
// try {
|
|
86
|
+
// // Get current gas prices from the bundler
|
|
87
|
+
// const dagClient = createPimlicoClient({
|
|
88
|
+
// transport: http(bundler_rpc),
|
|
89
|
+
// entryPoint: {
|
|
90
|
+
// address: entryPoint06Address,
|
|
91
|
+
// version: "0.6",
|
|
92
|
+
// },
|
|
93
|
+
// });
|
|
94
|
+
|
|
95
|
+
// const balance = await publicClient.getBalance({
|
|
96
|
+
// address: account.address,
|
|
97
|
+
// });
|
|
98
|
+
// const balanceInETH = Number(balance) / 1e18;
|
|
99
|
+
|
|
100
|
+
// const gasPrices = await dagClient.getUserOperationGasPrice();
|
|
101
|
+
// console.log("Using gas prices:", gasPrices.fast);
|
|
102
|
+
|
|
103
|
+
// const SAFE_GAS_PRICE = parseGwei("50"); // 100 Gwei
|
|
104
|
+
|
|
105
|
+
// console.log("SAFE gas prices:", formatEther(SAFE_GAS_PRICE));
|
|
106
|
+
|
|
107
|
+
// const txHash = await smartAccountClient.sendTransaction({
|
|
108
|
+
// to: "0x8FaB6DF00085eb05D5F2C1FA46a6E539587ae3f3", // Send to self
|
|
109
|
+
// value: 0n,
|
|
110
|
+
// data: cd,
|
|
111
|
+
// maxFeePerGas: SAFE_GAS_PRICE,
|
|
112
|
+
// maxPriorityFeePerGas: SAFE_GAS_PRICE,
|
|
113
|
+
// // Keep your high limits
|
|
114
|
+
// callGasLimit: 150000n,
|
|
115
|
+
// verificationGasLimit: 500000n, // Bumped for safety
|
|
116
|
+
// preVerificationGas: 100000n,
|
|
117
|
+
// });
|
|
118
|
+
|
|
119
|
+
// console.log(`\n✅ Success!`);
|
|
120
|
+
// console.log(`UserOperation Hash: ${txHash}`);
|
|
121
|
+
// console.log(`Transaction: https://awakening.bdagscan.com/tx/${txHash}`);
|
|
122
|
+
|
|
123
|
+
// // Wait a moment for the transaction to be included
|
|
124
|
+
// console.log("\nWaiting for transaction to be mined...");
|
|
125
|
+
// await new Promise((resolve) => setTimeout(resolve, 5000));
|
|
126
|
+
|
|
127
|
+
// const newBalance = await publicClient.getBalance({
|
|
128
|
+
// address: account.address,
|
|
129
|
+
// });
|
|
130
|
+
// const newBalanceInETH = Number(newBalance) / 1e18;
|
|
131
|
+
// console.log(`\nFinal Balance: ${newBalanceInETH} ETH`);
|
|
132
|
+
// console.log(`Gas Cost: ${balanceInETH - newBalanceInETH} ETH`);
|
|
133
|
+
|
|
134
|
+
// console.log("\n🎉 Account Abstraction is working on Awakening!");
|
|
135
|
+
// console.log(
|
|
136
|
+
// "This proves your setup is correct - the issue is specific to Awakening testnet."
|
|
137
|
+
// );
|
|
138
|
+
// } catch (error: any) {
|
|
139
|
+
// console.error("\n❌ Transaction failed:");
|
|
140
|
+
// console.error(error.message);
|
|
141
|
+
|
|
142
|
+
// if (error.details) {
|
|
143
|
+
// console.error("\nDetails:", error.details);
|
|
144
|
+
// }
|
|
145
|
+
// }
|
|
@@ -14,6 +14,8 @@ import {
|
|
|
14
14
|
type Address,
|
|
15
15
|
encodeFunctionData,
|
|
16
16
|
parseEther,
|
|
17
|
+
Client,
|
|
18
|
+
ByteArray,
|
|
17
19
|
} from "viem";
|
|
18
20
|
import { privateKeyToAccount } from "viem/accounts";
|
|
19
21
|
import { toSimpleSmartAccount } from "permissionless/accounts";
|
|
@@ -25,7 +27,8 @@ import {
|
|
|
25
27
|
SmartAccountConfig,
|
|
26
28
|
SendUserOperationParams,
|
|
27
29
|
UserOperationReceipt,
|
|
28
|
-
} from "../types";
|
|
30
|
+
} from "../types.js";
|
|
31
|
+
import { ISigner } from "../../signers/types.js";
|
|
29
32
|
|
|
30
33
|
// ==============================================================================
|
|
31
34
|
// Main SDK Class
|
|
@@ -33,14 +36,12 @@ import {
|
|
|
33
36
|
|
|
34
37
|
export class DagAAClient {
|
|
35
38
|
private config: DagAAConfig;
|
|
36
|
-
private publicClient:
|
|
37
|
-
private walletClient:
|
|
38
|
-
private bundlerClient:
|
|
39
|
+
private publicClient: any | null;
|
|
40
|
+
private walletClient: any | null;
|
|
41
|
+
private bundlerClient: any | null = null;
|
|
39
42
|
private smartAccount: any | null = null;
|
|
40
43
|
private paymasterClient: any | null = null;
|
|
41
|
-
private smartAccountClient:
|
|
42
|
-
typeof createSmartAccountClient
|
|
43
|
-
> | null = null;
|
|
44
|
+
private smartAccountClient: any | null = null;
|
|
44
45
|
|
|
45
46
|
constructor(config: DagAAConfig) {
|
|
46
47
|
this.config = {
|
|
@@ -170,30 +171,33 @@ export class DagAAClient {
|
|
|
170
171
|
async connectSmartAccount(
|
|
171
172
|
accountConfig: SmartAccountConfig
|
|
172
173
|
): Promise<Address> {
|
|
173
|
-
const
|
|
174
|
+
const { signer, accountAddress } = accountConfig;
|
|
174
175
|
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
176
|
+
const isReady = await signer.isReady();
|
|
177
|
+
if (!isReady) {
|
|
178
|
+
throw new Error("Signer is not ready. Ensure wallet is connected.");
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const owner = await signer.getAccount();
|
|
180
182
|
|
|
181
|
-
|
|
183
|
+
const signingClient = await signer.getWalletClient();
|
|
184
|
+
|
|
185
|
+
if (accountAddress) {
|
|
182
186
|
// Use existing account
|
|
183
187
|
this.smartAccount = await toSimpleSmartAccount({
|
|
184
|
-
client: signingClient,
|
|
188
|
+
client: signingClient as unknown as Client,
|
|
185
189
|
owner: owner,
|
|
186
190
|
factoryAddress: this.config.factoryAddress,
|
|
187
191
|
entryPoint: {
|
|
188
192
|
address: this.config.entryPointAddress!,
|
|
189
193
|
version: "0.6",
|
|
190
194
|
},
|
|
191
|
-
address:
|
|
195
|
+
address: accountAddress,
|
|
192
196
|
});
|
|
193
197
|
} else {
|
|
194
198
|
// Create new account
|
|
195
199
|
this.smartAccount = await toSimpleSmartAccount({
|
|
196
|
-
client: signingClient,
|
|
200
|
+
client: signingClient as unknown as Client,
|
|
197
201
|
owner: owner,
|
|
198
202
|
factoryAddress: this.config.factoryAddress,
|
|
199
203
|
entryPoint: {
|
|
@@ -509,8 +513,21 @@ export class DagAAClient {
|
|
|
509
513
|
console.log(`Funding account with ${amount} wei...`);
|
|
510
514
|
|
|
511
515
|
const hash = await client.sendTransaction({
|
|
516
|
+
account: signer, // ✅ Add this line
|
|
512
517
|
to: this.smartAccount.address,
|
|
513
518
|
value: amount,
|
|
519
|
+
kzg: {
|
|
520
|
+
blobToKzgCommitment: function (blob: ByteArray): ByteArray {
|
|
521
|
+
throw new Error("Function not implemented.");
|
|
522
|
+
},
|
|
523
|
+
computeBlobKzgProof: function (
|
|
524
|
+
blob: ByteArray,
|
|
525
|
+
commitment: ByteArray
|
|
526
|
+
): ByteArray {
|
|
527
|
+
throw new Error("Function not implemented.");
|
|
528
|
+
},
|
|
529
|
+
},
|
|
530
|
+
chain: undefined,
|
|
514
531
|
});
|
|
515
532
|
|
|
516
533
|
console.log(`✅ Funded: ${hash}`);
|