Skip to content

Commit ce1acfe

Browse files
matias-gonzaonMiniRomancpb80100xSulpiride
authored
OIDC/merge guardians branch again (#94)
* feat: add initial guardian recovery views * feat: add confirm guardian view * feat: improve guardian view with edge cases * fix: remove commented code * feat: improve component imports * feat: add logout icon in desktop breakpoint * fix: naming * fix: pnpm lock * fix: wrong nav component import * fix: add missing package to cspell * feat: add recover account views * feat: add unknown account page * feat: improve account init recovery start * feat: reorganize routes with typed routes * feat: add recovery process warning when logged in * feat: add account not ready page * fix: confirm-guardian page * feat: add base guardian recovery module * chore: update contracts submodule * chore: update contracts submodule * chore: update contracts submodule * feat: add sso account validation * Update packages/auth-server/pages/recovery/guardian/index.vue Co-authored-by: Lukasz Romanowski <5160687+MiniRoman@users.noreply.github.com> * feat: add integration with /recovery/guardian/find-account * feat: integrate contracts in guardians settings page * feat: set proper path to confirm-guardian page * feat: add guardian confirmation integration * feat: add ui improvements * feat: address pr comments * feat: update contracts submodule * chore: update contract submodule * feat: add integration to confirm recovery view * feat: add integration with cancel recovery (#53) * feat: add integration with cancel recovery * feat: update contracts submodule and abi * feat: add verify recovery view on the main page * chore: update contracts * feat: add missing nuxt config * feat: new passkey signature format includes the credential id, which is hopefully available * feat: custom paymaster handler & zyfi integration (#51) * feat: custom paymaster handler & zyfi integration * feat: export paymaster package * fix: bigint serializer * feat: passkey paymaster handler & general paymaster handler & fix types * fix: import path * chore: add new words to cspell * chore: fix zyfi input data * fix: ci (#60) * fix: update to include credential id on creation Also update contracts locally * chore: update to latest contracts * fix: update lockfile from contract dep change * fix: import for utils * fix: update signature format tests It doesn't look correct visually, but it's mocked on both ends so it's not super clear on what it's testing * feat: attempt to use new dynamic contract addresses When deploying the contracts, it should create the file, blocking the build * fix: provide an example file Can have a different test to make sure this gets updated or put the contract build step into the other builds * fix: add create2 to nft deploy Try encoding the local contracts directly instead of via env vars doesn't appear to work locally... * fix: encode passkey id as bytes This was correct on creation, but wrong on signing * chore: update to latest contract * fix: update hardcoded signatures for passkey view This was super tough to find and would have been a compile error had we imported the abi directly from the contracts! This is something I'm going to look into so we don't lose our minds * fix: remove debugging changes You just have to know that the quest address is added via .env.local so the object in the config isn't used * feat: improve confirm guardian flow * chore: update contracts package * feat: execute pending recovery on login (#57) * feat: execute pending recovery on login * feat: move recovery client to sdk * feat: add account-not-ready view * chore: fix pnpm lock --------- Co-authored-by: aon <21188659+aon@users.noreply.github.com> * fix: parse newly created account address from events (#66) * fix: parse newly created account address from events * fix: unit tests * feat: attempt to import abi automatically Having to manually update the ABI kinda defeats the point of type safety, but it's clear the auto-generated one doesn't play nice with the existing file so more work will be necessary to update it so it's compatible * fix: use view function to get key Picks up a fix from the publish function for the correct abi * fix: remove publish from CI It looks like nuxt builds don't like the poorly formatted json, so instead of trying to pretty print the abi automatically we'll rely on the editor tools to do this. At the very least the publish step is documented? * fix: update import names problem was not the file format, but the file name change * fix: pad bytes32 values for proper abi encoding (#61) Co-authored-by: cpb8010 <cpb8010@users.noreply.github.com> * fix: use pnpm run build instead of build CI is behaving strange? * fix: use correct contract branch * fix: pull contract directory in CI This explains why the build was failing * feat: setup local node for deploy This should be fine because we aren't actually using it * feat: improve recovery flow (#71) * feat: add placeholder to account select component * feat: add init recovery method to be used by any client * feat: improve recovery flow * feat: improve confirm recovery flow * feat: improve styles * Feat/update to match contracts (#81) * feat: update to work with new guardian validator * chore: update contracts submodule * chore: remove duplicated hooks * chore: update guardian validator abi * feat: update to match new contracts * chore: update contracts repo * feat: use recovery guardian sso contracts deployment * chore: temporarily hardcode appkit project id * chore: temporarily change app url * feat: unify encoding of credential id * feat: unify encoding of credential id * feat: use provider from appkit * feat: new passkey signature format (#58) * feat: new passkey signature format includes the credential id, which is hopefully available * fix: update to include credential id on creation Also update contracts locally * chore: update to latest contracts * fix: update lockfile from contract dep change * fix: import for utils * fix: update signature format tests It doesn't look correct visually, but it's mocked on both ends so it's not super clear on what it's testing * feat: attempt to use new dynamic contract addresses When deploying the contracts, it should create the file, blocking the build * fix: provide an example file Can have a different test to make sure this gets updated or put the contract build step into the other builds * fix: add create2 to nft deploy Try encoding the local contracts directly instead of via env vars doesn't appear to work locally... * fix: encode passkey id as bytes This was correct on creation, but wrong on signing * chore: update to latest contract * fix: update hardcoded signatures for passkey view This was super tough to find and would have been a compile error had we imported the abi directly from the contracts! This is something I'm going to look into so we don't lose our minds * fix: remove debugging changes You just have to know that the quest address is added via .env.local so the object in the config isn't used * feat: attempt to import abi automatically Having to manually update the ABI kinda defeats the point of type safety, but it's clear the auto-generated one doesn't play nice with the existing file so more work will be necessary to update it so it's compatible * fix: use view function to get key Picks up a fix from the publish function for the correct abi * fix: remove publish from CI It looks like nuxt builds don't like the poorly formatted json, so instead of trying to pretty print the abi automatically we'll rely on the editor tools to do this. At the very least the publish step is documented? * fix: update import names problem was not the file format, but the file name change * fix: use pnpm run build instead of build CI is behaving strange? * fix: use correct contract branch * fix: pull contract directory in CI This explains why the build was failing * feat: setup local node for deploy This should be fine because we aren't actually using it * [wip] Add application metadata (#82) * feat: provide auth-server metadata Can be helpful for custom auth-server implementions that want extra data * fix: use a record instead of an array of records There's not really much extra flexibility here, so just keep it simple * fix: update demo app with new metadata format * Update packages/auth-server/components/session/Metadata.vue --------- Co-authored-by: Nicolas Villanueva <1890113+MexicanAce@users.noreply.github.com> * fix: update to breaking factory change This was already fixed during guardian module work * fix: update ABI breaking name and argument changes were not published Added publish step to readme * fix: update new variable name now automatically checked via types! * fix: update test mock The log parsing format is broken because the return type changed, but regenerating the log format is non-trival so that can be updated later. introducing #84 * fix: update account id length Updating the tests to match --------- Co-authored-by: Nicolas Villanueva <1890113+MexicanAce@users.noreply.github.com> * feat: update to latest contracts version * chore: fix build * feat: upgrate paymaster * chore: bump submodules * chore: bump contract submodule * fix: fixes after merge oidc working lots of testing missing * fix: fix nft app wip * feat: remove aud and iss from pub inputs (#90) * feat: remove aud and iss from pub inputs remove aud and iss from pub inputs * fix: test should deploy all contracts test should deploy all contracts * fix: fixed sdk tests --------- Co-authored-by: calvo.generico <miguelfeliped@gmail.com> * fix: more fixes * fix: more fixes --------- Co-authored-by: aon <21188659+aon@users.noreply.github.com> Co-authored-by: Lukasz Romanowski <5160687+MiniRoman@users.noreply.github.com> Co-authored-by: cbe <cbe@matterlabs.dev> Co-authored-by: Utkir S. <sobirovutkir@gmail.com> Co-authored-by: Nicolas Villanueva <1890113+MexicanAce@users.noreply.github.com> Co-authored-by: cpb8010 <cpb8010@users.noreply.github.com> Co-authored-by: Lyova Potyomkin <lyova.potyomkin@gmail.com> Co-authored-by: calvo.generico <miguelfeliped@gmail.com>
1 parent 8adb811 commit ce1acfe

File tree

85 files changed

+2879
-1245
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+2879
-1245
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ jobs:
4141
run: pnpm install -r --frozen-lockfile
4242
working-directory: packages/contracts
4343

44-
- name: Build SDK
45-
run: pnpm nx build sdk
46-
4744
- name: Build contracts
4845
run: pnpm build
4946
working-directory: packages/contracts
5047

5148
- name: Deploy contracts
52-
run: pnpm run deploy
49+
run: pnpm run deploy --file ../auth-server/stores/local-node.json
5350
working-directory: packages/contracts
5451

52+
- name: Build SDK
53+
run: pnpm nx build sdk
54+
5555
- name: Install zksync-foundry
5656
run: |
5757
wget -qc https://github.com/matter-labs/foundry-zksync/releases/download/nightly/foundry_nightly_linux_amd64.tar.gz -O - | tar -xz
@@ -63,7 +63,7 @@ jobs:
6363
- name: Deploy Demo-App contracts
6464
run: pnpm nx deploy-contracts demo-app
6565

66-
- name: Run tests
66+
- name: Run tests
6767
run: pnpm test
6868
working-directory: packages/sdk
6969

@@ -115,17 +115,17 @@ jobs:
115115
run: pnpm install -r --frozen-lockfile
116116
working-directory: packages/contracts
117117

118-
- name: Build SDK
119-
run: pnpm nx build sdk
120-
121118
- name: Build contracts
122119
run: pnpm build
123120
working-directory: packages/contracts
124121

125122
- name: Deploy contracts
126-
run: pnpm run deploy
123+
run: pnpm run deploy --file ../auth-server/stores/local-node.json
127124
working-directory: packages/contracts
128125

126+
- name: Build SDK
127+
run: pnpm nx build sdk
128+
129129
- name: Deploy NFT contracts
130130
run: pnpm nx deploy:local nft-quest-contracts
131131

.github/workflows/deploy-auth-server.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- uses: actions/checkout@v4 # v4
20+
with:
21+
submodules: recursive
2022

2123
- name: Setup pnpm
2224
uses: pnpm/action-setup@v4
@@ -29,6 +31,23 @@ jobs:
2931
node-version: lts/Iron
3032
cache: 'pnpm'
3133

34+
# SDK depends on contracts
35+
- name: Install contract dependencies
36+
run: pnpm install -r --frozen-lockfile
37+
working-directory: packages/contracts
38+
39+
- name: Build contracts
40+
run: pnpm run build
41+
working-directory: packages/contracts
42+
43+
# Local node to have target for deploy
44+
- name: Era Test Node Action
45+
uses: dutterbutter/anvil-zksync-action@v1.1.0
46+
47+
- name: Deploy contracts
48+
run: pnpm run deploy --file ../auth-server/stores/local-node.json
49+
working-directory: packages/contracts
50+
3251
- name: Install dependencies
3352
run: pnpm install -r --frozen-lockfile
3453

.github/workflows/deploy-nft-quest.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- uses: actions/checkout@v4 # v4
20+
with:
21+
submodules: recursive
2022

2123
- name: Setup pnpm
2224
uses: pnpm/action-setup@v4
@@ -32,6 +34,23 @@ jobs:
3234
- name: Install dependencies
3335
run: pnpm install -r --frozen-lockfile
3436

37+
# SDK depends on contracts
38+
- name: Install contract dependencies
39+
run: pnpm install -r --frozen-lockfile
40+
working-directory: packages/contracts
41+
42+
- name: Build contracts
43+
run: pnpm build
44+
working-directory: packages/contracts
45+
46+
# Local node to have target for deploy
47+
- name: Era Test Node Action
48+
uses: dutterbutter/anvil-zksync-action@v1.1.0
49+
50+
- name: Deploy contracts
51+
run: pnpm run deploy --file ../auth-server/stores/local-node.json
52+
working-directory: packages/contracts
53+
3554
- name: Build apps
3655
run: pnpm nx build nft-quest
3756

.github/workflows/deploy-package.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ jobs:
1414

1515
steps:
1616
- uses: actions/checkout@v4
17+
with:
18+
submodules: recursive
1719

1820
- name: Setup pnpm
1921
uses: pnpm/action-setup@v4
@@ -29,6 +31,23 @@ jobs:
2931
- name: Install dependencies
3032
run: pnpm install -r --frozen-lockfile
3133

34+
# SDK depends on contracts
35+
- name: Install contract dependencies
36+
run: pnpm install -r --frozen-lockfile
37+
working-directory: packages/contracts
38+
39+
- name: Build contracts
40+
run: pnpm build
41+
working-directory: packages/contracts
42+
43+
# Local node to have target for deploy
44+
- name: Era Test Node Action
45+
uses: dutterbutter/anvil-zksync-action@v1.1.0
46+
47+
- name: Deploy contracts
48+
run: pnpm run deploy --file ../auth-server/stores/local-node.json
49+
working-directory: packages/contracts
50+
3251
- name: Build the package
3352
run: pnpm nx build sdk
3453

.github/workflows/deploy-preview.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,23 @@ jobs:
3333
node-version: lts/Iron
3434
cache: 'pnpm'
3535

36+
# SDK depends on contracts
37+
- name: Install contract dependencies
38+
run: pnpm install -r --frozen-lockfile
39+
working-directory: packages/contracts
40+
41+
- name: Build contracts
42+
run: pnpm run build
43+
working-directory: packages/contracts
44+
45+
# Local node to have target for deploy
46+
- name: Era Test Node Action
47+
uses: dutterbutter/anvil-zksync-action@v1.1.0
48+
49+
- name: Deploy contracts
50+
run: pnpm run deploy --file ../auth-server/stores/local-node.json
51+
working-directory: packages/contracts
52+
3653
- name: Install dependencies
3754
run: pnpm install -r --frozen-lockfile
3855

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ This monorepo is comprised of the following packages, products, and examples:
143143
# Compile and deploy contracts
144144
cd packages/contracts
145145
pnpm build
146-
pnpm run deploy
146+
pnpm --dir packages/contracts run publish ../sdk/src/abi
147+
pnpm --dir packages/contracts run deploy --file ../auth-server/stores/local-node.json
147148
```
148149

149150
6. Start the demo application:

cspell-config/cspell-misc.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ vueuse
1212
dockerized
1313
ethereum
1414
sepolia
15+
foundryup
1516

1617
// examples/bank-demo
1718
ctap
@@ -42,3 +43,11 @@ groth
4243
zkey
4344
snark
4445
snarkjs
46+
47+
// examples/demo-app
48+
zkout
49+
cancun
50+
EVMLA
51+
52+
// paymasters
53+
zyfi

examples/nft-quest-contracts/deploy/deploy.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ export default async function (hre: HardhatRuntimeEnvironment) {
1717
console.log("PAYMASTER CONTRACT: ", await paymasterContract.getAddress());
1818

1919
if (hre.network.config.ethNetwork.includes("localhost")) {
20+
const nftQuestAddress = await nftContract.getAddress();
21+
const paymasterContractAddress = await paymasterContract.getAddress();
22+
2023
// Update the .env.local file with the contract addresses for NFT Quest app
2124
const envFilePath = path.join(__dirname, "../../nft-quest/.env.local");
2225

@@ -25,10 +28,8 @@ export default async function (hre: HardhatRuntimeEnvironment) {
2528
fs.writeFileSync(envFilePath, "", { encoding: "utf8" });
2629
console.log(`.env.local file has been created at ${envFilePath}`);
2730
}
28-
const nftContractAddress = await nftContract.getAddress();
29-
const paymasterContractAddress = await paymasterContract.getAddress();
3031

31-
const envContent = `NUXT_PUBLIC_CONTRACTS_NFT=${nftContractAddress}\nNUXT_PUBLIC_CONTRACTS_PAYMASTER=${paymasterContractAddress}\n`;
32+
const envContent = `NUXT_PUBLIC_CONTRACTS_NFT=${nftQuestAddress}\nNUXT_PUBLIC_CONTRACTS_PAYMASTER=${paymasterContractAddress}\n`;
3233

3334
fs.writeFileSync(envFilePath, envContent, { encoding: "utf8" });
3435
console.log(`.env.local file has been updated at ${envFilePath}`);

examples/nft-quest-contracts/deploy/utils.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Deployer } from "@matterlabs/hardhat-zksync";
55
import dotenv from "dotenv";
66
import { ethers } from "ethers";
77
import * as hre from "hardhat";
8-
import { Provider, Wallet } from "zksync-ethers";
8+
import { ContractFactory, Provider, utils, Wallet } from "zksync-ethers";
99

1010
// Load env file
1111
dotenv.config();
@@ -105,23 +105,33 @@ export const deployContract = async (contractArtifactName: string, constructorAr
105105
await verifyEnoughBalance(wallet, deploymentFee);
106106

107107
// Deploy the contract to ZKsync
108-
const contract = await deployer.deploy(artifact, constructorArguments);
108+
const salt = ethers.hexlify("0x" + "0".repeat(64));
109+
const create2Deployer = new ContractFactory(artifact.abi, artifact.bytecode, wallet, "create2");
110+
const encodedArgs = create2Deployer.interface.encodeDeploy(constructorArguments);
111+
const bytecodeHash = utils.hashBytecode(artifact.bytecode);
112+
const standardCreate2Address = utils.create2Address(wallet.address, bytecodeHash, salt, constructorArguments ? encodedArgs : "0x");
113+
const accountCode = await wallet.provider.getCode(standardCreate2Address);
114+
if (accountCode != "0x") {
115+
log(`Contract ${contractArtifactName} already exists!`);
116+
return new ethers.Contract(standardCreate2Address, artifact.abi, wallet);
117+
}
118+
119+
const contract = await (constructorArguments ? create2Deployer.deploy(...constructorArguments, { customData: { salt } }) : create2Deployer.deploy({ customData: { salt } }));
109120
const address = await contract.getAddress();
110-
const constructorArgs = contract.interface.encodeDeploy(constructorArguments);
111121
const fullContractSource = `${artifact.sourceName}:${artifact.contractName}`;
112122

113123
// Display contract deployment info
114124
log(`\n"${artifact.contractName}" was successfully deployed:`);
115125
log(` - Contract address: ${address}`);
116126
log(` - Contract source: ${fullContractSource}`);
117-
log(` - Encoded constructor arguments: ${constructorArgs}\n`);
127+
log(` - Encoded constructor arguments: ${encodedArgs}\n`);
118128

119129
if (!options?.noVerify && hre.network.config.verifyURL) {
120130
log(`Requesting contract verification...`);
121131
await verifyContract({
122132
address,
123133
contract: fullContractSource,
124-
constructorArguments: constructorArgs,
134+
constructorArguments: encodedArgs,
125135
bytecode: artifact.bytecode,
126136
});
127137
}

examples/nft-quest/nuxt.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ export default defineNuxtConfig({
5959
public: {
6060
chain: zksyncInMemoryNode,
6161
contracts: {
62-
nft: "0x111C3E89Ce80e62EE88318C2804920D4c96f92bb",
63-
paymaster: "0x4B5DF730c2e6b28E17013A1485E5d9BC41Efe021",
62+
nft: "0xF4E1ee85f0645b5871B03bc40d151C174F0e86f6",
63+
paymaster: "0x25B89fa6e157937f845ec0Fb41733B29bc20A4d3",
6464
},
6565
baseUrl: "http://localhost:3006",
6666
authServerUrl: "http://localhost:3002/confirm",

0 commit comments

Comments
 (0)