Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rename zksync account to sso #184

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ Add ZKsync SSO connector to your app (using `wagmi`):
```ts
import { zksyncSepoliaTestnet } from "viem/chains";
import { createConfig, connect } from "@wagmi/core";
import { zksyncAccountConnector } from "zksync-sso/connector";
import { zksyncSsoConnector } from "zksync-sso/connector";

const ssoConnector = zksyncAccountConnector({
const ssoConnector = zksyncSsoConnector({
// Optional session configuration, if omitted user will have to sign every transaction via Auth Server
session: {
// Allow up to 0.1 ETH to be spend in gas fees
Expand Down
4 changes: 2 additions & 2 deletions docs/sdk/client-auth-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ your application. It's built on top of [client SDK](../client/README.md) and
```ts
import { zksync } from "viem/chains";
import { createConfig, connect } from "@wagmi/core";
import { zksyncAccountConnector } from "zksync-sso/connector";
import { zksyncSsoConnector } from "zksync-sso/connector";

const ssoConnector = zksyncAccountConnector({
const ssoConnector = zksyncSsoConnector({
// Optional session configuration
session: {
feeLimit: parseEther("0.1"),
Expand Down
4 changes: 2 additions & 2 deletions examples/demo-app/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@

<script lang="ts" setup>
import { disconnect, getBalance, watchAccount, sendTransaction, createConfig, connect, reconnect, type GetBalanceReturnType } from "@wagmi/core";
import { zksyncAccountConnector } from "zksync-sso/connector";
import { zksyncSsoConnector } from "zksync-sso/connector";
import { zksyncInMemoryNode } from "@wagmi/core/chains";
import { createWalletClient, http, parseEther, type Address } from "viem";
import { privateKeyToAccount } from "viem/accounts";

const testTransferTarget = "0x55bE1B079b53962746B2e86d12f158a41DF294A6";
const zksyncConnector = zksyncAccountConnector({
const zksyncConnector = zksyncSsoConnector({
authServerUrl: "http://localhost:3002/confirm",
session: {
feeLimit: parseEther("0.1"),
Expand Down
4 changes: 2 additions & 2 deletions examples/nft-quest/stores/connector.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { connect, createConfig, type CreateConnectorFn, disconnect, getAccount, http, reconnect, watchAccount } from "@wagmi/core";
import { zksyncInMemoryNode, zksyncLocalNode, zksyncSepoliaTestnet } from "@wagmi/core/chains";
import { type Address, type Hash, parseEther } from "viem";
import { zksyncAccountConnector } from "zksync-sso/connector";
import { zksyncSsoConnector } from "zksync-sso/connector";

export const useConnectorStore = defineStore("connector", () => {
const runtimeConfig = useRuntimeConfig();
Expand All @@ -14,7 +14,7 @@ export const useConnectorStore = defineStore("connector", () => {
type SupportedChainId = (typeof supportedChains)[number]["id"];
if (!chain) throw new Error(`Chain with id ${runtimeConfig.public.chain.id} was not found in supported chains list`);

const connector = zksyncAccountConnector({
const connector = zksyncSsoConnector({
metadata: {
name: "ZK NFT Quest",
icon: `${runtimeConfig.public.baseUrl}/favicon.svg`,
Expand Down
92 changes: 0 additions & 92 deletions packages/contracts/test/sdk/PasskeyClient.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/sdk/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# zksync-sso-sdk

ZKsync Account SDK
ZKsync SSO SDK
4 changes: 2 additions & 2 deletions packages/sdk/src/client-auth-server/Signer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type Address, type Chain, type Hash, hexToNumber, http, type RpcSchema as RpcSchemaGeneric, type SendTransactionParameters, type Transport } from "viem";

import { createZksyncSessionClient, type ZksyncAccountSessionClient } from "../client/index.js";
import { createZksyncSessionClient, type ZksyncSsoSessionClient } from "../client/index.js";
import type { Communicator } from "../communicator/index.js";
import { type SessionConfig } from "../utils/session.js";
import { StorageItem } from "../utils/storage.js";
Expand Down Expand Up @@ -51,7 +51,7 @@ export class Signer implements SignerInterface {

private _account: StorageItem<Account | null>;
private _chainsInfo = new StorageItem<ChainsInfo>(StorageItem.scopedStorageKey("chainsInfo"), []);
private walletClient: ZksyncAccountSessionClient | undefined;
private walletClient: ZksyncSsoSessionClient | undefined;

constructor({ metadata, communicator, updateListener, session, chains, transports }: SignerConstructorParams) {
if (!chains.length) throw new Error("At least one chain must be included in the config");
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/client-auth-server/WalletProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export type WalletProviderConstructorOptions = {
};

export class WalletProvider extends EventEmitter implements ProviderInterface {
readonly isZksyncAccount = true;
readonly isZksyncSso = true;
private signer: Signer;

constructor({ metadata, chains, transports, session, authServerUrl }: WalletProviderConstructorOptions) {
Expand Down
22 changes: 11 additions & 11 deletions packages/sdk/src/client/clients/passkey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { eip712WalletActions } from "viem/zksync";

import { passkeyHashSignatureResponseFormat } from "../../utils/passkey.js";
import { requestPasskeyAuthentication } from "../actions/passkey.js";
import { type ZksyncAccountPasskeyActions, zksyncAccountPasskeyActions } from "../decorators/passkey.js";
import { type ZksyncSsoPasskeyActions, zksyncSsoPasskeyActions } from "../decorators/passkey.js";
import { toSmartAccount } from "../smart-account.js";

export function createZksyncPasskeyClient<
transport extends Transport,
chain extends Chain,
rpcSchema extends RpcSchema | undefined = undefined,
>(_parameters: ZksyncAccountPasskeyClientConfig<transport, chain, rpcSchema>): ZksyncAccountPasskeyClient<transport, chain, rpcSchema> {
>(_parameters: ZksyncSsoPasskeyClientConfig<transport, chain, rpcSchema>): ZksyncSsoPasskeyClient<transport, chain, rpcSchema> {
type WalletClientParameters = typeof _parameters;
const parameters: WalletClientParameters & {
key: NonNullable<WalletClientParameters["key"]>;
Expand All @@ -19,7 +19,7 @@ export function createZksyncPasskeyClient<
..._parameters,
address: getAddress(_parameters.address),
key: _parameters.key || "wallet",
name: _parameters.name || "ZKsync Account Passkey Client",
name: _parameters.name || "ZKsync SSO Passkey Client",
};

const account = toSmartAccount({
Expand Down Expand Up @@ -49,7 +49,7 @@ export function createZksyncPasskeyClient<
.extend(publicActions)
.extend(walletActions)
.extend(eip712WalletActions())
.extend(zksyncAccountPasskeyActions);
.extend(zksyncSsoPasskeyActions);
return client;
}

Expand All @@ -58,7 +58,7 @@ export type PasskeyRequiredContracts = {
passkey: Address; // Validator for passkey signature
accountFactory?: Address; // For account creation
};
type ZksyncAccountPasskeyData = {
type ZksyncSsoPasskeyData = {
credentialPublicKey: Uint8Array; // Public key of the passkey
userName: string; // Basically unique user id (which is called `userName` in webauthn)
userDisplayName: string; // Also option required for webauthn
Expand All @@ -67,12 +67,12 @@ type ZksyncAccountPasskeyData = {
paymasterInput?: Hex;
};

export type ClientWithZksyncAccountPasskeyData<
export type ClientWithZksyncSsoPasskeyData<
transport extends Transport = Transport,
chain extends Chain = Chain,
> = Client<transport, chain, Account> & ZksyncAccountPasskeyData;
> = Client<transport, chain, Account> & ZksyncSsoPasskeyData;

export type ZksyncAccountPasskeyClient<
export type ZksyncSsoPasskeyClient<
transport extends Transport = Transport,
chain extends Chain = Chain,
rpcSchema extends RpcSchema | undefined = undefined,
Expand All @@ -85,11 +85,11 @@ export type ZksyncAccountPasskeyClient<
rpcSchema extends RpcSchema
? [...PublicRpcSchema, ...WalletRpcSchema, ...rpcSchema]
: [...PublicRpcSchema, ...WalletRpcSchema],
PublicActions<transport, chain, account> & WalletActions<chain, account> & ZksyncAccountPasskeyActions
> & ZksyncAccountPasskeyData
PublicActions<transport, chain, account> & WalletActions<chain, account> & ZksyncSsoPasskeyActions
> & ZksyncSsoPasskeyData
>;

export interface ZksyncAccountPasskeyClientConfig<
export interface ZksyncSsoPasskeyClientConfig<
transport extends Transport = Transport,
chain extends Chain = Chain,
rpcSchema extends RpcSchema | undefined = undefined,
Expand Down
26 changes: 13 additions & 13 deletions packages/sdk/src/client/clients/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { privateKeyToAccount } from "viem/accounts";

import { encodeSession } from "../../utils/encoding.js";
import type { SessionConfig } from "../../utils/session.js";
import { type ZksyncAccountSessionActions, zksyncAccountSessionActions } from "../decorators/session.js";
import { type ZksyncAccountWalletActions, zksyncAccountWalletActions } from "../decorators/session_wallet.js";
import { type ZksyncSsoSessionActions, zksyncSsoSessionActions } from "../decorators/session.js";
import { type ZksyncSsoWalletActions, zksyncSsoWalletActions } from "../decorators/session_wallet.js";
import { toSmartAccount } from "../smart-account.js";

export function createZksyncSessionClient<
transport extends Transport,
chain extends Chain,
rpcSchema extends RpcSchema | undefined = undefined,
>(_parameters: ZksyncAccountSessionClientConfig<transport, chain, rpcSchema>): ZksyncAccountSessionClient<transport, chain, rpcSchema> {
>(_parameters: ZksyncSsoSessionClientConfig<transport, chain, rpcSchema>): ZksyncSsoSessionClient<transport, chain, rpcSchema> {
type WalletClientParameters = typeof _parameters;
const parameters: WalletClientParameters & {
key: NonNullable<WalletClientParameters["key"]>;
Expand All @@ -20,7 +20,7 @@ export function createZksyncSessionClient<
..._parameters,
address: getAddress(_parameters.address),
key: _parameters.key || "wallet",
name: _parameters.name || "ZKsync Account Session Client",
name: _parameters.name || "ZKsync SSO Session Client",
};

const account = toSmartAccount({
Expand Down Expand Up @@ -53,27 +53,27 @@ export function createZksyncSessionClient<
contracts: parameters.contracts,
}))
.extend(publicActions)
.extend(zksyncAccountWalletActions)
.extend(zksyncAccountSessionActions);
.extend(zksyncSsoWalletActions)
.extend(zksyncSsoSessionActions);
return client;
}

export type SessionRequiredContracts = {
session: Address; // Session, spend limit, etc.
};
type ZksyncAccountSessionData = {
type ZksyncSsoSessionData = {
sessionKey: Hash;
sessionConfig: SessionConfig;
contracts: SessionRequiredContracts;
};

export type ClientWithZksyncAccountSessionData<
export type ClientWithZksyncSsoSessionData<
transport extends Transport = Transport,
chain extends Chain = Chain,
account extends Account = Account,
> = Client<transport, chain, account> & ZksyncAccountSessionData;
> = Client<transport, chain, account> & ZksyncSsoSessionData;

export type ZksyncAccountSessionClient<
export type ZksyncSsoSessionClient<
transport extends Transport = Transport,
chain extends Chain = Chain,
rpcSchema extends RpcSchema | undefined = undefined,
Expand All @@ -86,11 +86,11 @@ export type ZksyncAccountSessionClient<
rpcSchema extends RpcSchema
? [...PublicRpcSchema, ...WalletRpcSchema, ...rpcSchema]
: [...PublicRpcSchema, ...WalletRpcSchema],
ZksyncAccountWalletActions<chain, account> & ZksyncAccountSessionActions
> & ZksyncAccountSessionData
ZksyncSsoWalletActions<chain, account> & ZksyncSsoSessionActions
> & ZksyncSsoSessionData
>;

export interface ZksyncAccountSessionClientConfig<
export interface ZksyncSsoSessionClientConfig<
transport extends Transport = Transport,
chain extends Chain = Chain,
rpcSchema extends RpcSchema | undefined = undefined,
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk/src/client/decorators/passkey.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { type Chain, type Transport } from "viem";

import { createSession, type CreateSessionArgs, type CreateSessionReturnType } from "../actions/session.js";
import type { ClientWithZksyncAccountPasskeyData } from "../clients/passkey.js";
import type { ClientWithZksyncSsoPasskeyData } from "../clients/passkey.js";

export type ZksyncAccountPasskeyActions = {
export type ZksyncSsoPasskeyActions = {
createSession: (args: Omit<CreateSessionArgs, "contracts">) => Promise<CreateSessionReturnType>;
};

export function zksyncAccountPasskeyActions<
export function zksyncSsoPasskeyActions<
transport extends Transport,
chain extends Chain,
>(client: ClientWithZksyncAccountPasskeyData<transport, chain>): ZksyncAccountPasskeyActions {
>(client: ClientWithZksyncSsoPasskeyData<transport, chain>): ZksyncSsoPasskeyActions {
return {
createSession: async (args: Omit<CreateSessionArgs, "contracts">) => {
return await createSession(client, {
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk/src/client/decorators/session.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { type Account, type Chain, type Transport } from "viem";

import type { ClientWithZksyncAccountSessionData } from "../clients/session.js";
import type { ClientWithZksyncSsoSessionData } from "../clients/session.js";

/* eslint-disable @typescript-eslint/no-empty-object-type */
export type ZksyncAccountSessionActions = {
export type ZksyncSsoSessionActions = {
};

export function zksyncAccountSessionActions<
export function zksyncSsoSessionActions<
transport extends Transport,
chain extends Chain,
account extends Account,
/* eslint-disable @typescript-eslint/no-unused-vars */
>(client: ClientWithZksyncAccountSessionData<transport, chain, account>): ZksyncAccountSessionActions {
>(client: ClientWithZksyncSsoSessionData<transport, chain, account>): ZksyncSsoSessionActions {
return {
};
}
Loading