Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 23 additions & 3 deletions packages/auth-server-api/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import dotenv from "dotenv";
import { readFileSync } from "fs";
import { dirname, join } from "path";
import { fileURLToPath } from "url";
import type { Chain } from "viem";
import { localhost, sepolia } from "viem/chains";
import { type Chain, defineChain } from "viem";
import { localhost } from "viem/chains";
import { z } from "zod";

// Load environment variables
Expand Down Expand Up @@ -69,7 +69,27 @@ if (!FACTORY_ADDRESS || !EOA_VALIDATOR_ADDRESS || !WEBAUTHN_VALIDATOR_ADDRESS ||
}

// Supported chains configuration
const SUPPORTED_CHAINS: Chain[] = [localhost, sepolia];
const zksyncOsTestnet = defineChain({
id: 8022833,
name: "ZKsyncOS Testnet",
nativeCurrency: {
name: "Ether",
symbol: "ETH",
decimals: 18,
},
rpcUrls: {
default: {
http: ["https://zksync-os-testnet-alpha.zksync.dev"],
},
},
blockExplorers: {
default: {
name: "ZKsyncOS Testnet Explorer",
url: "https://zksync-os-testnet-alpha.staging-scan-v2.zksync.dev",
},
},
});
const SUPPORTED_CHAINS: Chain[] = [localhost, zksyncOsTestnet];

function getChain(chainId: number): Chain {
const chain = SUPPORTED_CHAINS.find((c) => c.id === chainId);
Expand Down
47 changes: 34 additions & 13 deletions packages/auth-server/stores/client.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,45 @@
import { useAppKitProvider } from "@reown/appkit/vue";
import { type Address, createPublicClient, createWalletClient, custom, type Hex, http, publicActions, walletActions } from "viem";
import { type Address, createPublicClient, createWalletClient, custom, defineChain, type Hex, http, publicActions, walletActions } from "viem";
import { createBundlerClient } from "viem/account-abstraction";
import { /* generatePrivateKey, */ privateKeyToAccount } from "viem/accounts";
import { localhost, sepolia } from "viem/chains";
import { localhost } from "viem/chains";
import { createPasskeyClient } from "zksync-sso-4337/client";

// TODO: OIDC and guardian recovery are not yet available in sdk-4337
// import { createZkSyncOidcClient, type ZkSyncSsoClient } from "zksync-sso/client/oidc";
// import { createZksyncRecoveryGuardianClient } from "zksync-sso/client/recovery";
import localChainData from "./local-node.json";

export const supportedChains = [localhost, sepolia];
const zksyncOsTestnet = defineChain({
id: 8022833,
name: "ZKsyncOS Testnet",
nativeCurrency: {
name: "Ether",
symbol: "ETH",
decimals: 18,
},
rpcUrls: {
default: {
http: ["https://zksync-os-testnet-alpha.zksync.dev"],
},
},
blockExplorers: {
default: {
name: "ZKsyncOS Testnet Explorer",
url: "https://zksync-os-testnet-alpha.staging-scan-v2.zksync.dev",
},
},
});

export const supportedChains = [localhost, zksyncOsTestnet];
export type SupportedChainId = (typeof supportedChains)[number]["id"];
export const blockExplorerUrlByChain: Record<SupportedChainId, string> = {
[localhost.id]: "http://localhost:3010",
[sepolia.id]: "https://sepolia.etherscan.io",
[zksyncOsTestnet.id]: "https://zksync-os-testnet-alpha.staging-scan-v2.zksync.dev",
};
export const blockExplorerApiByChain: Record<SupportedChainId, string> = {
[localhost.id]: "http://localhost:3020",
[sepolia.id]: "https://api-sepolia.etherscan.io/api",
[zksyncOsTestnet.id]: "https://block-explorer-api.zksync-os-testnet-alpha.zksync.dev/api",
};

type ChainContracts = {
Expand All @@ -32,22 +53,22 @@ type ChainContracts = {

export const contractsByChain: Record<SupportedChainId, ChainContracts> = {
[localhost.id]: localChainData as ChainContracts,
[sepolia.id]: {
eoaValidator: "0x027ce1d8244318e38c3B65E3EABC2537BD712077",
webauthnValidator: "0xAbcB5AB6eBb69F4F5F8cf1a493F56Ad3d28562bd",
sessionValidator: "0x09fbd5b956AF5c64C7eB4fb473E7E64DAF0f79D7",
factory: "0xF33128d7Cd2ab37Af12B3a22D9dA79f928c2B450",
[zksyncOsTestnet.id]: {
eoaValidator: "0x3497392f9662Da3de1EC2AfE8724CdBF6b884088",
webauthnValidator: "0xa5C2c5C723239C0cD11a5691954CdAC4369C874b",
sessionValidator: "0x2bF3B894aA2C13A1545C6982bBbee435B5168b52",
factory: "0x757b5c9854d327A6B76840c996dfAac0F6b3Dc1f",
bundlerUrl: "https://bundler-api.stage-sso.zksync.dev",
beacon: "0xd1Ab9B640995124D3FD311d70BA4F216AD5b1aD5",
beacon: "0x1D779D791B55a093dE60da664C3F301a87f96C62",
},
};

export const chainParameters: Record<SupportedChainId, { blockTime: number }> = {
[localhost.id]: {
blockTime: 1,
},
[sepolia.id]: {
blockTime: 12,
[zksyncOsTestnet.id]: {
blockTime: 1,
},
};

Expand Down
Loading