Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e145cf9
feat: new passkey signature format
cpb8010 Feb 5, 2025
1bbdb8e
Merge branch 'main' into multi-domain-passkey
cpb8010 Feb 7, 2025
b4d4fd4
fix: update to include credential id on creation
cpb8010 Feb 7, 2025
6833313
chore: update to latest contracts
cpb8010 Feb 7, 2025
8aed1b3
fix: update lockfile from contract dep change
cpb8010 Feb 7, 2025
332c89e
fix: import for utils
cpb8010 Feb 7, 2025
019b677
fix: update signature format tests
cpb8010 Feb 7, 2025
447cd93
feat: attempt to use new dynamic contract addresses
cpb8010 Feb 9, 2025
24e9208
fix: provide an example file
cpb8010 Feb 9, 2025
8666649
fix: add create2 to nft deploy
cpb8010 Feb 10, 2025
67851a5
fix: encode passkey id as bytes
cpb8010 Feb 11, 2025
99114da
chore: update to latest contract
cpb8010 Feb 11, 2025
254adf8
fix: update hardcoded signatures for passkey view
cpb8010 Feb 11, 2025
0731e8a
fix: remove debugging changes
cpb8010 Feb 11, 2025
021b806
Merge branch 'main' into multi-domain-passkey
cpb8010 Feb 13, 2025
b7f2d23
feat: attempt to import abi automatically
cpb8010 Feb 20, 2025
2e2ef67
fix: use view function to get key
cpb8010 Feb 20, 2025
17317db
fix: remove publish from CI
cpb8010 Feb 20, 2025
614889d
fix: update import names
cpb8010 Feb 20, 2025
5589c50
fix: use pnpm run build instead of build
cpb8010 Feb 23, 2025
a268c07
Merge remote-tracking branch 'origin/main' into multi-domain-passkey
cpb8010 Feb 24, 2025
7afdd8f
fix: use correct contract branch
cpb8010 Feb 24, 2025
edae999
fix: pull contract directory in CI
cpb8010 Feb 24, 2025
84f39b6
feat: setup local node for deploy
cpb8010 Feb 24, 2025
92e1fe2
[wip] Add application metadata (#82)
cpb8010 Mar 4, 2025
f39cfa5
fix: update to breaking factory change
cpb8010 Mar 6, 2025
cf7bbca
fix: update ABI
cpb8010 Mar 6, 2025
e99323f
fix: update new variable name
cpb8010 Mar 6, 2025
6c5959b
fix: update test mock
cpb8010 Mar 6, 2025
3a048e0
fix: update account id length
cpb8010 Mar 7, 2025
40ffcaa
feat: add message to explain message
cpb8010 Mar 7, 2025
91722da
fix: remove all usage of metadata from demo app and server
cpb8010 Mar 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ jobs:
run: pnpm install -r --frozen-lockfile
working-directory: packages/contracts

- name: Build SDK
run: pnpm nx build sdk

- name: Build contracts
run: pnpm build
working-directory: packages/contracts

- name: Deploy contracts
run: pnpm run deploy
run: pnpm run deploy --file ../auth-server/stores/local-node.json
working-directory: packages/contracts

- name: Build SDK
run: pnpm nx build sdk

- name: Install zksync-foundry
run: |
wget -qc https://github.com/matter-labs/foundry-zksync/releases/download/nightly/foundry_nightly_linux_amd64.tar.gz -O - | tar -xz
Expand Down Expand Up @@ -115,17 +115,17 @@ jobs:
run: pnpm install -r --frozen-lockfile
working-directory: packages/contracts

- name: Build SDK
run: pnpm nx build sdk

- name: Build contracts
run: pnpm build
working-directory: packages/contracts

- name: Deploy contracts
run: pnpm run deploy
run: pnpm run deploy --file ../auth-server/stores/local-node.json
working-directory: packages/contracts

- name: Build SDK
run: pnpm nx build sdk

- name: Deploy NFT contracts
run: pnpm nx deploy:local nft-quest-contracts

Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/deploy-auth-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4 # v4
with:
submodules: recursive

- name: Setup pnpm
uses: pnpm/action-setup@v4
Expand All @@ -29,6 +31,23 @@ jobs:
node-version: lts/Iron
cache: 'pnpm'

# SDK depends on contracts
- name: Install contract dependencies
run: pnpm install -r --frozen-lockfile
working-directory: packages/contracts

- name: Build contracts
run: pnpm run build
working-directory: packages/contracts

# Local node to have target for deploy
- name: Era Test Node Action
uses: dutterbutter/anvil-zksync-action@v1.1.0

- name: Deploy contracts
run: pnpm run deploy --file ../auth-server/stores/local-node.json
working-directory: packages/contracts

- name: Install dependencies
run: pnpm install -r --frozen-lockfile

Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/deploy-nft-quest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4 # v4
with:
submodules: recursive

- name: Setup pnpm
uses: pnpm/action-setup@v4
Expand All @@ -32,6 +34,23 @@ jobs:
- name: Install dependencies
run: pnpm install -r --frozen-lockfile

# SDK depends on contracts
- name: Install contract dependencies
run: pnpm install -r --frozen-lockfile
working-directory: packages/contracts

- name: Build contracts
run: pnpm build
working-directory: packages/contracts

# Local node to have target for deploy
- name: Era Test Node Action
uses: dutterbutter/anvil-zksync-action@v1.1.0

- name: Deploy contracts
run: pnpm run deploy --file ../auth-server/stores/local-node.json
working-directory: packages/contracts

- name: Build apps
run: pnpm nx build nft-quest

Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/deploy-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup pnpm
uses: pnpm/action-setup@v4
Expand All @@ -29,6 +31,23 @@ jobs:
- name: Install dependencies
run: pnpm install -r --frozen-lockfile

# SDK depends on contracts
- name: Install contract dependencies
run: pnpm install -r --frozen-lockfile
working-directory: packages/contracts

- name: Build contracts
run: pnpm build
working-directory: packages/contracts

# Local node to have target for deploy
- name: Era Test Node Action
uses: dutterbutter/anvil-zksync-action@v1.1.0

- name: Deploy contracts
run: pnpm run deploy --file ../auth-server/stores/local-node.json
working-directory: packages/contracts

- name: Build the package
run: pnpm nx build sdk

Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/deploy-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
output_urls: "${{ steps.preview_deploy.outputs.urls }}"
steps:
- uses: actions/checkout@v4 # v4
with:
submodules: recursive

- name: Setup pnpm
uses: pnpm/action-setup@v4
Expand All @@ -30,6 +32,23 @@ jobs:
node-version: lts/Iron
cache: 'pnpm'

# SDK depends on contracts
- name: Install contract dependencies
run: pnpm install -r --frozen-lockfile
working-directory: packages/contracts

- name: Build contracts
run: pnpm run build
working-directory: packages/contracts

# Local node to have target for deploy
- name: Era Test Node Action
uses: dutterbutter/anvil-zksync-action@v1.1.0

- name: Deploy contracts
run: pnpm run deploy --file ../auth-server/stores/local-node.json
working-directory: packages/contracts

- name: Install dependencies
run: pnpm install -r --frozen-lockfile

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ This monorepo is comprised of the following packages, products, and examples:
# Compile and deploy contracts
cd packages/contracts
pnpm build
pnpm run deploy
pnpm --dir packages/contracts run publish ../sdk/src/abi
pnpm --dir packages/contracts run deploy --file ../auth-server/stores/local-node.json
```

6. Start the demo application:
Expand Down
7 changes: 4 additions & 3 deletions examples/nft-quest-contracts/deploy/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export default async function (hre: HardhatRuntimeEnvironment) {
console.log("PAYMASTER CONTRACT: ", await paymasterContract.getAddress());

if (hre.network.config.ethNetwork.includes("localhost")) {
const nftQuestAddress = await nftContract.getAddress();
const paymasterContractAddress = await paymasterContract.getAddress();

// Update the .env.local file with the contract addresses for NFT Quest app
const envFilePath = path.join(__dirname, "../../nft-quest/.env.local");

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

const envContent = `NUXT_PUBLIC_CONTRACTS_NFT=${nftContractAddress}\nNUXT_PUBLIC_CONTRACTS_PAYMASTER=${paymasterContractAddress}\n`;
const envContent = `NUXT_PUBLIC_CONTRACTS_NFT=${nftQuestAddress}\nNUXT_PUBLIC_CONTRACTS_PAYMASTER=${paymasterContractAddress}\n`;

fs.writeFileSync(envFilePath, envContent, { encoding: "utf8" });
console.log(`.env.local file has been updated at ${envFilePath}`);
Expand Down
20 changes: 15 additions & 5 deletions examples/nft-quest-contracts/deploy/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Deployer } from "@matterlabs/hardhat-zksync";
import dotenv from "dotenv";
import { ethers } from "ethers";
import * as hre from "hardhat";
import { Provider, Wallet } from "zksync-ethers";
import { ContractFactory, Provider, utils, Wallet } from "zksync-ethers";

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

// Deploy the contract to ZKsync
const contract = await deployer.deploy(artifact, constructorArguments);
const salt = ethers.hexlify("0x" + "0".repeat(64));
const create2Deployer = new ContractFactory(artifact.abi, artifact.bytecode, wallet, "create2");
const encodedArgs = create2Deployer.interface.encodeDeploy(constructorArguments);
const bytecodeHash = utils.hashBytecode(artifact.bytecode);
const standardCreate2Address = utils.create2Address(wallet.address, bytecodeHash, salt, constructorArguments ? encodedArgs : "0x");
const accountCode = await wallet.provider.getCode(standardCreate2Address);
if (accountCode != "0x") {
log(`Contract ${contractArtifactName} already exists!`);
return new ethers.Contract(standardCreate2Address, artifact.abi, wallet);
}

const contract = await (constructorArguments ? create2Deployer.deploy(...constructorArguments, { customData: { salt } }) : create2Deployer.deploy({ customData: { salt } }));
const address = await contract.getAddress();
const constructorArgs = contract.interface.encodeDeploy(constructorArguments);
const fullContractSource = `${artifact.sourceName}:${artifact.contractName}`;

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

if (!options?.noVerify && hre.network.config.verifyURL) {
log(`Requesting contract verification...`);
await verifyContract({
address,
contract: fullContractSource,
constructorArguments: constructorArgs,
constructorArguments: encodedArgs,
bytecode: artifact.bytecode,
});
}
Expand Down
4 changes: 2 additions & 2 deletions packages/auth-server/components/session/row/Row.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<script setup lang="ts">
import { HandRaisedIcon } from "@heroicons/vue/24/outline";
import type { Hash } from "viem";
import { SessionKeyModuleAbi } from "zksync-sso/abi";
import { SessionKeyValidatorAbi } from "zksync-sso/abi";
import { type SessionConfig, type SessionState, SessionStatus } from "zksync-sso/utils";

const props = defineProps<{
Expand Down Expand Up @@ -100,7 +100,7 @@ const {
const client = getPublicClient({ chainId: defaultChain.id });
const res = await client.readContract({
address: contractsByChain[defaultChain.id].session,
abi: SessionKeyModuleAbi,
abi: SessionKeyValidatorAbi,
functionName: "sessionState",
args: [address.value!, props.session],
});
Expand Down
1 change: 1 addition & 0 deletions packages/auth-server/composables/useAccountCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const useAccountCreate = (_chainId: MaybeRef<SupportedChainId>) => {
const deployerClient = getThrowAwayClient({ chainId: chainId.value });

const deployedAccount = await deployAccount(deployerClient, {
credentialId,
credentialPublicKey,
uniqueAccountId: credentialId,
contracts: contractsByChain[chainId.value],
Expand Down
4 changes: 2 additions & 2 deletions packages/auth-server/pages/dashboard/sessions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
import { InformationCircleIcon } from "@heroicons/vue/20/solid";
import type { Hex } from "viem";
import { zksyncInMemoryNode } from "viem/chains";
import { SessionKeyModuleAbi } from "zksync-sso/abi";
import { SessionKeyValidatorAbi } from "zksync-sso/abi";
import type { SessionConfig } from "zksync-sso/utils";

const { defaultChain, getPublicClient } = useClientStore();
Expand All @@ -99,7 +99,7 @@ const {
const contracts = contractsByChain[defaultChain.id];
const publicClient = getPublicClient({ chainId: defaultChain.id });
const logs = await publicClient.getContractEvents({
abi: SessionKeyModuleAbi,
abi: SessionKeyValidatorAbi,
address: contracts.session,
eventName: "SessionCreated",
args: {
Expand Down
9 changes: 3 additions & 6 deletions packages/auth-server/stores/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { zksyncInMemoryNode, zksyncSepoliaTestnet } from "viem/chains";
import { eip712WalletActions } from "viem/zksync";
import { createZksyncPasskeyClient, type PasskeyRequiredContracts } from "zksync-sso/client/passkey";

import localChainData from "./local-node.json";

export const supportedChains = [zksyncSepoliaTestnet, zksyncInMemoryNode];
export type SupportedChainId = (typeof supportedChains)[number]["id"];
export const blockExplorerUrlByChain: Record<SupportedChainId, string> = {
Expand All @@ -26,12 +28,7 @@ export const contractsByChain: Record<SupportedChainId, ChainContracts> = {
accountFactory: "0x73CFa70318FD25F2166d47Af9d93Cf72eED48724",
accountPaymaster: "0xA46D949858335308859076FA605E773eB679e534",
},
[zksyncInMemoryNode.id]: {
session: "0xD68963C76ab7FFACbF53B1750325254F40eDe765",
passkey: "0x21b8397BeF5128662564b8491676baa6754AFD47",
accountFactory: "0x26711A4A572a5BBdF967b6385636Bd968e6E883C",
accountPaymaster: "0x61C2F9736eC60C9175Cdc02DB81D730cf06eF0Ee",
},
[zksyncInMemoryNode.id]: localChainData,
};

export const useClientStore = defineStore("client", () => {
Expand Down
6 changes: 6 additions & 0 deletions packages/auth-server/stores/local-node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"session": "0x530b3d86dF715ab70817B0b199C70a1D344db642",
"passkey": "0x3dbA0387Ba8643aD6F29eFbAb73389C4E587B02A",
"accountFactory": "0xf7158210d5CCB6978E736EFcA4A4A1cFE60cB230",
"accountPaymaster": "0x2F04b853f90E5d0B2e0c532d8D7b5bb6B18ab0ec"
}
2 changes: 1 addition & 1 deletion packages/contracts
Submodule contracts updated 341 files
Loading
Loading