Skip to content

Commit

Permalink
Merge branch 'main' into fix-estimation
Browse files Browse the repository at this point in the history
  • Loading branch information
JackHamer09 committed Nov 20, 2024
2 parents 9311342 + 0bf91c6 commit d22aaf0
Show file tree
Hide file tree
Showing 50 changed files with 267 additions and 1,571 deletions.
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.

35 changes: 5 additions & 30 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 Expand Up @@ -117,34 +117,9 @@ This monorepo is comprised of the following packages, products, and examples:
pnpm install
```

You have two options for using the SDK in the monorepo workspaces, via PNPM
workspace protocol or using Verdaccio. The project is currently configured to
use the SDK package via PNPM. If you want to use the SDK outside of the monorepo
in another local project, setup the Verdaccio option to easily use the SDK
package.

### Using the SDK package via PNPM

PNPM provides a way to "link" workspaces together via `package.json`
dependencies using the
[Workspace protocol](https://pnpm.io/workspaces#workspace-protocol-workspace).

### Using the SDK package locally via Verdaccio

2. Start up the Verdaccio proxy registry.

```bash
pnpm run registry
```

3. Publish the SDK package to your proxy registry.

```bash
pnpm nx publish:local sdk
```

4. Edit the respective `package.json` dependency for the SDK to use the version
that is published to Verdaccio.
2. If creating new packages: use pnpm and
[workspace protocol](https://pnpm.io/workspaces#workspace-protocol-workspace)
to link SDK in the new folder.

## Running commands

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
ethereum

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.

11 changes: 4 additions & 7 deletions examples/demo-app/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
</template>

<script lang="ts" setup>
import { disconnect, getBalance, watchAccount, sendTransaction, createConfig, connect, reconnect, type GetBalanceReturnType, waitForTransactionReceipt } from "@wagmi/core";
import { zksyncAccountConnector } from "zksync-sso/connector";
import { disconnect, getBalance, watchAccount, sendTransaction, createConfig, connect, reconnect, waitForTransactionReceipt, type GetBalanceReturnType } from "@wagmi/core";
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 Expand Up @@ -149,10 +149,7 @@ const sendTokens = async () => {
});
const receipt = await waitForTransactionReceipt(wagmiConfig, { hash: transactionHash });
if (receipt.status !== "success") {
console.log("Transaction failed", receipt);
errorMessage.value = "Transaction reverted";
}
if (receipt.status === "reverted") throw new Error("Transaction reverted");
} catch (error) {
// eslint-disable-next-line no-console
console.error("Transaction failed:", error);
Expand Down
3 changes: 2 additions & 1 deletion examples/nft-quest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ A demo of using the ZKsync SDK for smart accounts.

## Getting Started

Run the following (be sure a local node is running, e.g. `era_test_node`):
Run the following (be sure a local node is running, e.g.
`era_test_node`[https://docs.zksync.io/build/zksync-cli/running-a-node]):

```sh
# Deploy the ZKsync SSO contracts
Expand Down
6 changes: 4 additions & 2 deletions examples/nft-quest/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ export default defineNuxtConfig({
app: {
head: {
link: [
{ rel: "icon", type: "image/x-icon", href: "/favicon.ico" },
{ rel: "icon", type: "image/png", href: "/favicon_48x48.png", sizes: "48x48" },
{ rel: "icon", type: "image/x-icon", href: "/favicon.ico", sizes: "32x32" },
{ rel: "icon", type: "image/png", href: "/icon-96x96.png", sizes: "96x96" },
{ rel: "icon", type: "image/svg+xml", href: "/favicon.svg" },
{ rel: "apple-touch-icon", href: "/apple-touch-icon.png" },
],
bodyAttrs: {
class: "dark-mode",
Expand Down
Binary file added examples/nft-quest/public/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed examples/nft-quest/public/favicon-48x48.png
Binary file not shown.
Binary file modified examples/nft-quest/public/favicon.ico
Binary file not shown.
Binary file removed examples/nft-quest/public/favicon.png
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/nft-quest/public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/nft-quest/public/icon-192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/nft-quest/public/icon-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/nft-quest/public/icon-96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/nft-quest/public/icon-mask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions examples/nft-quest/public/manifest.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "NFT Quest",
"icons": [
{ "src": "/icon-192.png", "type": "image/png", "sizes": "192x192" },
{ "src": "/icon-mask.png", "type": "image/png", "sizes": "512x512", "purpose": "maskable" },
{ "src": "/icon-512.png", "type": "image/png", "sizes": "512x512" }
]
}
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
5 changes: 3 additions & 2 deletions packages/auth-server/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ export default defineNuxtConfig({
head: {
title: "ZKsync SSO",
link: [
{ rel: "icon", type: "image/x-icon", href: "/favicon.ico" },
{ rel: "icon", type: "image/png", href: "/favicon-96x96.png", sizes: "96x96" },
{ rel: "icon", type: "image/x-icon", href: "/favicon.ico", sizes: "32x32" },
{ rel: "icon", type: "image/png", href: "/icon-96x96.png", sizes: "96x96" },
{ rel: "icon", type: "image/svg+xml", href: "/favicon.svg" },
{ rel: "apple-touch-icon", href: "/apple-touch-icon.png" },
],
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-server/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"cwd": "packages/auth-server",
"command": "PORT=3002 nuxt dev"
},
"dependsOn": []
"dependsOn": ["^build"]
},
"build": {
"executor": "nx:run-commands",
Expand Down
Binary file added packages/auth-server/public/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed packages/auth-server/public/favicon-96x96.png
Binary file not shown.
Binary file modified packages/auth-server/public/favicon.ico
Binary file not shown.
5 changes: 1 addition & 4 deletions packages/auth-server/public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/auth-server/public/icon-192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/auth-server/public/icon-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/auth-server/public/icon-96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/auth-server/public/icon-mask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions packages/auth-server/public/manifest.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "ZKsync SSO Auth Server",
"icons": [
{ "src": "/icon-192.png", "type": "image/png", "sizes": "192x192" },
{ "src": "/icon-mask.png", "type": "image/png", "sizes": "512x512", "purpose": "maskable" },
{ "src": "/icon-512.png", "type": "image/png", "sizes": "512x512" }
]
}
Loading

0 comments on commit d22aaf0

Please sign in to comment.