Skip to content

Commit b47558d

Browse files
cpb8010Copilot
andauthored
Unify DeployAccount (#138)
* feat: get new sdk changes The goal is to keep the e2e tests passing as we merge a branch where they fail. * Update packages/sdk/src/client/index.ts thanks AI! Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: attempt to undo more changes still fails locally? Trying to undo any breaking changes * Update packages/sdk/src/client/passkey/actions/account.test.ts thanks AI Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * feat: use new modular account interface still isn't using the new factory entry point, but it would be easier to use it if needed! Also add support for recovery, if provided by client * feat: create throwaway owner on deployment Can be saved or used later, mostly as a demo to show all 3 signer types together. * fix: undo test renaming We want this to be new tests with a new name, not losing the old name tests! * fix: fully revert passkey deploy test changes Other updates were made that broke things --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 162326b commit b47558d

File tree

8 files changed

+527
-19
lines changed

8 files changed

+527
-19
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
applyTo: '**'
3+
---
4+
5+
// This file is automatically generated by Nx Console
6+
7+
You are in an nx workspace using Nx 19.8.6 and pnpm as the package manager.
8+
9+
You have access to the Nx MCP server and the tools it provides. Use them. Follow these guidelines in order to best help the user:
10+
11+
# General Guidelines
12+
- When answering questions, use the nx_workspace tool first to gain an understanding of the workspace architecture
13+
- For questions around nx configuration, best practices or if you're unsure, use the nx_docs tool to get relevant, up-to-date docs!! Always use this instead of assuming things about nx configuration
14+
- If the user needs help with an Nx configuration or project graph error, use the 'nx_workspace' tool to get any errors
15+
- To help answer questions about the workspace structure or simply help with demonstrating how tasks depend on each other, use the 'nx_visualize_graph' tool
16+
17+
# Generation Guidelines
18+
If the user wants to generate something, use the following flow:
19+
20+
- learn about the nx workspace and any specifics the user needs by using the 'nx_workspace' tool and the 'nx_project_details' tool if applicable
21+
- get the available generators using the 'nx_generators' tool
22+
- decide which generator to use. If no generators seem relevant, check the 'nx_available_plugins' tool to see if the user could install a plugin to help them
23+
- get generator details using the 'nx_generator_schema' tool
24+
- you may use the 'nx_docs' tool to learn more about a specific generator or technology if you're unsure
25+
- decide which options to provide in order to best complete the user's request. Don't make any assumptions and keep the options minimalistic
26+
- open the generator UI using the 'nx_open_generate_ui' tool
27+
- wait for the user to finish the generator
28+
- read the generator log file using the 'nx_read_generator_log' tool
29+
- use the information provided in the log file to answer the user's question or continue with what they were doing
30+
31+

.vscode/settings.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,12 @@
3636
"[solidity]": {
3737
"editor.defaultFormatter": "esbenp.prettier-vscode"
3838
},
39-
"css.customData": [".vscode/tailwind.json"]
39+
"css.customData": [".vscode/tailwind.json"],
40+
"nxConsole.generateAiAgentRules": true,
41+
"[json]": {
42+
"editor.defaultFormatter": "esbenp.prettier-vscode"
43+
},
44+
"[jsonc]": {
45+
"editor.defaultFormatter": "esbenp.prettier-vscode"
46+
}
4047
}

examples/bank-demo/components/app/AddCryptoButton.vue

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<script setup lang="ts">
1818
import NoPasskeyDialog from "~/components/app/NoPasskeyDialog.vue";
1919
import type { Hex } from "viem";
20-
import { deployAccount } from "zksync-sso/client";
20+
import { deployModularAccount } from "zksync-sso/client";
2121
import { registerNewPasskey } from "zksync-sso/client/passkey";
2222
import { getDeployerClient } from "../common/CryptoDeployer";
2323
@@ -73,10 +73,16 @@ const createAccountWithPasskey = async () => {
7373
const deployerClient = await getDeployerClient(deployerKey as Hex);
7474
7575
try {
76-
const { address, transactionReceipt } = await deployAccount(deployerClient, {
77-
credentialPublicKey: publicPassKey.credentialPublicKey,
78-
credentialId: publicPassKey.credentialId,
79-
contracts,
76+
const { address, transactionReceipt } = await deployModularAccount(deployerClient, {
77+
passkeyModule: {
78+
location: contracts.passkey,
79+
credentialPublicKey: publicPassKey.credentialPublicKey,
80+
credentialId: publicPassKey.credentialId,
81+
},
82+
accountFactory: contracts.accountFactory,
83+
installNoDataModules: [],
84+
// installing creator as an account owner!
85+
owners: [deployerClient.account.address],
8086
});
8187
8288
appMeta.value = {

examples/bank-demo/components/app/NoPasskeyDialog.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,9 @@ type="button"
125125
<script setup lang="ts">
126126
import { toHex, type HDAccount, type Hex } from "viem";
127127
import { english, generateMnemonic, mnemonicToAccount } from "viem/accounts";
128-
import { deployAccount, fetchAccount } from "zksync-sso/client/ecdsa";
128+
import { fetchAccount } from "zksync-sso/client/ecdsa";
129129
import { getDeployerClient } from "../common/CryptoDeployer";
130+
import { deployModularAccount } from "zksync-sso/client";
130131
131132
const { appMeta, contracts, deployerKey } = useAppMeta();
132133
@@ -245,10 +246,10 @@ async function deployAddress(accountAddress: HDAccount) {
245246
return fetchedAccount.address;
246247
} catch (err) {
247248
console.info("account does not exist, deploy!", err);
248-
const deployedAccount = await deployAccount(deployerClient, {
249+
const deployedAccount = await deployModularAccount(deployerClient, {
249250
contracts,
250-
prefix: "bank-demo",
251-
owner: accountAddress.address,
251+
uniqueAccountId: "bank-demo",
252+
owners: [accountAddress.address],
252253
});
253254
return deployedAccount.address;
254255
}

packages/auth-server/composables/useAccountCreate.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { toHex } from "viem";
22
import { generatePrivateKey, privateKeyToAddress } from "viem/accounts";
3-
import { deployAccount } from "zksync-sso/client";
3+
import { deployModularAccount } from "zksync-sso/client";
44
import type { SessionConfig } from "zksync-sso/utils";
55

66
export const useAccountCreate = (_chainId: MaybeRef<SupportedChainId>) => {
@@ -26,15 +26,30 @@ export const useAccountCreate = (_chainId: MaybeRef<SupportedChainId>) => {
2626
};
2727
}
2828

29+
// Don't yet want this to be imported as part of the setup process
30+
const ownerKey = generatePrivateKey();
31+
const ownerAddress = privateKeyToAddress(ownerKey);
32+
2933
const deployerClient = getThrowAwayClient({ chainId: chainId.value });
3034

31-
const deployedAccount = await deployAccount(deployerClient, {
32-
credentialId,
33-
credentialPublicKey,
35+
const chainContracts = contractsByChain[chainId.value];
36+
const deployedAccount = await deployModularAccount(deployerClient, {
37+
accountFactory: chainContracts.accountFactory,
38+
passkeyModule: {
39+
location: chainContracts.passkey,
40+
credentialId,
41+
credentialPublicKey,
42+
},
43+
paymaster: {
44+
location: chainContracts.accountPaymaster,
45+
},
3446
uniqueAccountId: credentialId,
35-
contracts: contractsByChain[chainId.value],
36-
paymasterAddress: contractsByChain[chainId.value].accountPaymaster,
37-
initialSession: sessionData || undefined,
47+
sessionModule: {
48+
location: chainContracts.session,
49+
initialSession: sessionData,
50+
},
51+
owners: [ownerAddress],
52+
installNoDataModules: [chainContracts.recovery],
3853
});
3954

4055
login({

0 commit comments

Comments
 (0)