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: update zksync account to sso, sdk package deployment workflow, remove verdaccio #186

Merged
merged 13 commits into from
Nov 19, 2024
Merged
46 changes: 46 additions & 0 deletions .github/workflows/deploy-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Deploy NPM Package

on:
workflow_dispatch:
inputs:
version:
description: "Version to publish (e.g., 1.0.0)"
default: "1.0.0"
required: true

jobs:
publish:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9.11.0

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: lts/Iron
cache: 'pnpm'

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

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

- name: Prepare package.json
working-directory: packages/sdk
run: node prepare-package.mjs
env:
INPUT_VERSION: ${{ github.event.inputs.version }}

- name: Create .npmrc
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPMJS_NPM_MATTERLABS_AUTOMATION_TOKEN }}" > ~/.npmrc

- name: Publish to NPM
working-directory: packages/sdk
run: npm publish --access public
28 changes: 0 additions & 28 deletions .verdaccio/config.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
JackHamer09 marked this conversation as resolved.
Show resolved Hide resolved
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
1 change: 0 additions & 1 deletion cspell-config/cspell-misc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ nuxt
Nuxt
nuxtjs
testid
verdaccio
vueuse

// examples/bank-demo
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
51 changes: 0 additions & 51 deletions docs/verdaccio.md

This file was deleted.

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
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
],
"scripts": {
"prepare": "husky",
"registry": "pnpm nx local-registry",
"graph": "pnpm nx graph",
"dev:demo": "pnpm nx run-many -t serve -p auth-server demo-app",
"fmt": "pnpm prettier --write .",
Expand Down Expand Up @@ -49,7 +48,6 @@
"prettier": "3.3.3",
"typescript": "5.6.2",
"typescript-eslint": "8.7.0",
"verdaccio": "6.0.0",
"viem": "^2.21.14",
"zksync-sso": "workspace:*"
},
Expand Down
92 changes: 0 additions & 92 deletions packages/contracts/test/sdk/PasskeyClient.ts

This file was deleted.

10 changes: 10 additions & 0 deletions packages/sdk/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Ignore everything by default
*

# Include specific files and folders
!dist/
!src/
!README.md

# Ignore unnecessary files
*.tsbuildinfo
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
3 changes: 2 additions & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"private": true,
"type": "module",
"name": "zksync-sso",
"description": "ZKsync Smart Sign On SDK",
Expand All @@ -10,7 +11,7 @@
"author": "Matter Labs",
"repository": {
"type": "git",
"url": "https://github.com/matter-labs/zksync-account-sdk.git"
"url": "git+https://github.com/matter-labs/zksync-account-sdk.git"
JackHamer09 marked this conversation as resolved.
Show resolved Hide resolved
},
"scripts": {
"build": "npm run clean && npm run build:esm && npm run build:cjs && npm run build:types",
Expand Down
39 changes: 39 additions & 0 deletions packages/sdk/prepare-package.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { promises as fs } from "fs";
import path from "path";

// Define the path to the package.json
const packageJsonPath = path.resolve("./package.json");
console.log(packageJsonPath);

// Get the version from environment variables
const version = process.env.INPUT_VERSION;
if (!version) {
console.error("Error: INPUT_VERSION is required.");
process.exit(1);
}

async function preparePackageJson() {
try {
// Read the existing package.json
const packageJsonData = await fs.readFile(packageJsonPath, "utf8");
const packageJson = JSON.parse(packageJsonData);

// Remove unnecessary properties
delete packageJson.private;
delete packageJson.type;
delete packageJson.publishConfig;

// Set the new version
packageJson.version = version;

// Write the updated package.json back to the file
await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));

console.log(`Updated package.json for version ${version}`);
} catch (error) {
console.error("Error updating package.json:", error);
process.exit(1);
}
}

preparePackageJson();
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
Loading
Loading