Skip to content

Commit 9070eab

Browse files
WIP modular accounts
1 parent f98365c commit 9070eab

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

packages/thirdweb/src/wallets/smart/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ export async function connectSmartWallet(
119119
entrypointAddress,
120120
};
121121
}
122+
console.log("entrypointAddress", entrypointAddress);
122123
}
123124

124125
if (
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import { beforeAll, describe, expect, it } from "vitest";
2+
import { TEST_CLIENT } from "../../../test/src/test-clients.js";
3+
import { sepolia } from "../../chains/chain-definitions/sepolia.js";
4+
import { type ThirdwebContract, getContract } from "../../contract/contract.js";
5+
import { sendTransaction } from "../../transaction/actions/send-transaction.js";
6+
import { prepareTransaction } from "../../transaction/prepare-transaction.js";
7+
import type { Address } from "../../utils/address.js";
8+
import { isContractDeployed } from "../../utils/bytecode/is-contract-deployed.js";
9+
import type { Account, Wallet } from "../interfaces/wallet.js";
10+
import { generateAccount } from "../utils/generateAccount.js";
11+
import { smartWallet } from "./smart-wallet.js";
12+
13+
let wallet: Wallet;
14+
let smartAccount: Account;
15+
let smartWalletAddress: Address;
16+
let personalAccount: Account;
17+
let accountContract: ThirdwebContract;
18+
19+
const chain = sepolia;
20+
const client = TEST_CLIENT;
21+
const factoryAddress = "0xbE648d62571AcEAaBBEb1Ea35d99fBbdbC262B58";
22+
23+
describe.runIf(process.env.TW_SECRET_KEY).sequential(
24+
"SmartWallet policy tests",
25+
{
26+
retry: 0,
27+
timeout: 240_000,
28+
},
29+
() => {
30+
beforeAll(async () => {
31+
personalAccount = await generateAccount({
32+
client,
33+
});
34+
wallet = smartWallet({
35+
chain,
36+
gasless: true,
37+
factoryAddress,
38+
});
39+
smartAccount = await wallet.connect({
40+
client: TEST_CLIENT,
41+
personalAccount,
42+
});
43+
smartWalletAddress = smartAccount.address as Address;
44+
accountContract = getContract({
45+
address: smartWalletAddress,
46+
chain,
47+
client,
48+
});
49+
});
50+
51+
it("can connect", async () => {
52+
expect(smartWalletAddress).toHaveLength(42);
53+
54+
// const d = decodeErrorResult({
55+
// data: "0x79bd117bb61d27f600000000000000000000000000000000000000000000000000000000",
56+
// abi: await resolveContractAbi({
57+
// address: ENTRYPOINT_ADDRESS_v0_7,
58+
// client,
59+
// chain,
60+
// }),
61+
// });
62+
// console.log(d);
63+
});
64+
65+
it("can sign a msg", async () => {
66+
await smartAccount.signMessage({ message: "hello world" });
67+
const isDeployed = await isContractDeployed(accountContract);
68+
expect(isDeployed).toEqual(true);
69+
});
70+
71+
it("should send a transaction", async () => {
72+
const tx = prepareTransaction({
73+
client,
74+
chain,
75+
to: smartAccount.address,
76+
value: 0n,
77+
});
78+
79+
console.log("Sending transaction...");
80+
const receipt = await sendTransaction({
81+
transaction: tx,
82+
account: smartAccount,
83+
});
84+
console.log("Transaction sent:", receipt.transactionHash);
85+
expect(receipt.transactionHash).toBeDefined();
86+
});
87+
},
88+
);

0 commit comments

Comments
 (0)