Skip to content

Commit b3f4709

Browse files
authored
Merge branch 'matter-labs:main' into main
2 parents 9f2498f + 82a75dc commit b3f4709

File tree

15 files changed

+868
-403
lines changed

15 files changed

+868
-403
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ jobs:
5353
working-directory: packages/contracts
5454

5555
- name: Build SDK
56-
run: pnpm nx build sdk
56+
run: |
57+
pnpm nx build sdk
58+
pnpm nx build connector-export
5759
5860
- name: Install zksync-foundry
5961
run: |

.github/workflows/deploy-package.yml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,48 @@ jobs:
5151
- name: Build the package
5252
run: pnpm nx build sdk
5353

54+
- name: Build the connector-export package
55+
run: pnpm nx build connector-export
56+
5457
- name: Prepare package.json
5558
working-directory: packages/sdk
5659
run: node prepare-package.mjs
5760
env:
5861
INPUT_VERSION: ${{ github.event.inputs.version }}
5962

63+
- name: Prepare connector-export package.json
64+
working-directory: packages/connector-export
65+
run: node prepare-package.mjs
66+
env:
67+
INPUT_VERSION: ${{ github.event.inputs.version }}
68+
6069
- name: Create .npmrc for NPM
6170
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPMJS_NPM_MATTERLABS_AUTOMATION_TOKEN }}" > ~/.npmrc
6271

63-
- name: Publish to NPM
72+
- name: Publish SDK to NPM
6473
working-directory: packages/sdk
6574
run: npm publish --access public
75+
76+
- name: Publish connector-export to NPM
77+
working-directory: packages/connector-export
78+
run: npm publish --access public
6679

6780
- name: Create .npmrc for GitHub Packages
68-
run: echo "@OWNER:registry=https://npm.pkg.github.com\n//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc
81+
run: |
82+
echo "@matter-labs:registry=https://npm.pkg.github.com" > ~/.npmrc
83+
echo "@zksync-sso:registry=https://npm.pkg.github.com" >> ~/.npmrc
84+
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> ~/.npmrc
6985
70-
- name: Publish to GitHub Packages
86+
- name: Publish SDK to GitHub Packages
7187
working-directory: packages/sdk
72-
run: npm publish --access public
88+
run: |
89+
# Update package name for GitHub Packages to be scoped to the organization
90+
npm pkg set name="@matter-labs/zksync-sso"
91+
npm publish --registry=https://npm.pkg.github.com
92+
93+
- name: Publish connector-export to GitHub Packages
94+
working-directory: packages/connector-export
95+
run: |
96+
# Update package name for GitHub Packages to be scoped to the organization
97+
npm pkg set name="@matter-labs/zksync-sso-connector-export"
98+
npm publish --registry=https://npm.pkg.github.com

examples/demo-app/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"vue": "^3.4.21",
2121
"wagmi": "^2.12.17",
2222
"zksync-ethers": "^6.15.0",
23-
"zksync-sso": "workspace:*"
23+
"zksync-sso": "workspace:*",
24+
"@zksync-sso/connector-export": "workspace:*"
2425
},
2526
"devDependencies": {
2627
"@nuxt/eslint": "^0.5.7",

examples/demo-app/pages/index.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,13 @@
5656

5757
<script lang="ts" setup>
5858
import { disconnect, getBalance, watchAccount, sendTransaction, createConfig, connect, reconnect, waitForTransactionReceipt, type GetBalanceReturnType } from "@wagmi/core";
59-
import { zksyncSsoConnector } from "zksync-sso/connector";
60-
import { zksyncInMemoryNode } from "@wagmi/core/chains";
59+
import { zksyncSsoConnector, eraTestNode } from "@zksync-sso/connector-export";
6160
import { createWalletClient, http, parseEther, type Address } from "viem";
6261
import { privateKeyToAccount } from "viem/accounts";
6362
import { getGeneralPaymasterInput } from "viem/zksync";
6463
import PaymasterContract from "../forge-output.json";
6564
66-
const chain = zksyncInMemoryNode;
65+
const chain = eraTestNode; // Now using the exported eraTestNode instead of zksyncInMemoryNode
6766
6867
const testTransferTarget = "0x55bE1B079b53962746B2e86d12f158a41DF294A6";
6968
const zksyncConnectorWithSession = zksyncSsoConnector({

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
"typescript": "5.6.2",
4848
"typescript-eslint": "8.7.0",
4949
"viem": "^2.30.0",
50-
"zksync-sso": "workspace:*"
50+
"zksync-sso": "workspace:*",
51+
"@zksync-sso/connector-export": "workspace:*"
5152
},
5253
"nx": {
5354
"includedScripts": []
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
dist
2+
3+
node_modules
4+
tsconfig*.tsbuildinfo
5+
.DS_Store
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# @zksync-sso/connector-export
2+
3+
This package exports the ZKsync SSO connector with embedded Era Test Node
4+
support, eliminating the need to manually import and configure the era-test-node
5+
chain.
6+
7+
## Installation
8+
9+
```bash
10+
npm install @zksync-sso/connector-export
11+
# or
12+
pnpm add @zksync-sso/connector-export
13+
# or
14+
yarn add @zksync-sso/connector-export
15+
```
16+
17+
## Usage
18+
19+
### Simple Usage (with embedded Era Test Node)
20+
21+
The connector now automatically includes the Era Test Node (chain ID 260)
22+
configuration:
23+
24+
```typescript
25+
import { createConfig, http } from "@wagmi/core";
26+
import { zksyncSsoConnector, eraTestNode } from "@zksync-sso/connector-export";
27+
28+
const wagmiConfig = createConfig({
29+
chains: [eraTestNode], // Era test node is now exported directly
30+
connectors: [
31+
zksyncSsoConnector({
32+
authServerUrl: "http://localhost:3002/confirm",
33+
session: {
34+
feeLimit: parseEther("0.1"),
35+
transfers: [
36+
{
37+
to: "0x55bE1B079b53962746B2e86d12f158a41DF294A6",
38+
valueLimit: parseEther("0.1"),
39+
},
40+
],
41+
},
42+
}),
43+
],
44+
transports: {
45+
[eraTestNode.id]: http(),
46+
},
47+
});
48+
```
49+
50+
### Advanced Configuration
51+
52+
You can disable the automatic Era Test Node inclusion if you want to configure
53+
chains manually:
54+
55+
```typescript
56+
import { zksyncSsoConnector } from "@zksync-sso/connector-export";
57+
import { zksyncSepoliaTestnet } from "@wagmi/core/chains";
58+
59+
const connector = zksyncSsoConnector({
60+
includeEraTestNode: false, // Disable automatic era-test-node inclusion
61+
authServerUrl: "https://auth.zksync.dev/confirm",
62+
// ... other options
63+
});
64+
65+
const wagmiConfig = createConfig({
66+
chains: [zksyncSepoliaTestnet], // Use your own chain configuration
67+
connectors: [connector],
68+
transports: {
69+
[zksyncSepoliaTestnet.id]: http(),
70+
},
71+
});
72+
```
73+
74+
## Exported Items
75+
76+
### `zksyncSsoConnector(options)`
77+
78+
Enhanced ZKsync SSO connector that automatically includes the era-test-node
79+
configuration.
80+
81+
#### Options
82+
83+
All options from the original `ZksyncSsoConnectorOptions` plus:
84+
85+
- `includeEraTestNode?: boolean` - Whether to include the era-test-node chain
86+
automatically. Defaults to `true`.
87+
88+
### `eraTestNode`
89+
90+
The Era Test Node chain definition (chain ID 260) that can be used directly in
91+
your wagmi configuration.
92+
93+
```typescript
94+
{
95+
id: 260,
96+
name: "ZKsync Era Test Node",
97+
nativeCurrency: {
98+
name: "Ether",
99+
symbol: "ETH",
100+
decimals: 18,
101+
},
102+
rpcUrls: {
103+
default: {
104+
http: ["http://localhost:8011"],
105+
},
106+
},
107+
testnet: true,
108+
// ... additional ZKsync-specific configuration
109+
}
110+
```
111+
112+
## Migration from Previous Version
113+
114+
If you were previously importing the era-test-node chain manually:
115+
116+
**Before:**
117+
118+
```typescript
119+
import { zksyncSsoConnector } from "zksync-sso/connector";
120+
import { zksyncInMemoryNode } from "@wagmi/core/chains";
121+
122+
const wagmiConfig = createConfig({
123+
chains: [zksyncInMemoryNode],
124+
connectors: [zksyncSsoConnector(options)],
125+
// ...
126+
});
127+
```
128+
129+
**After:**
130+
131+
```typescript
132+
import { zksyncSsoConnector, eraTestNode } from "@zksync-sso/connector-export";
133+
134+
const wagmiConfig = createConfig({
135+
chains: [eraTestNode], // Now exported directly from the connector package
136+
connectors: [zksyncSsoConnector(options)], // Same API, but with era-test-node embedded
137+
// ...
138+
});
139+
```
140+
141+
## Requirements
142+
143+
- Node.js 18+
144+
- ZKsync SSO SDK
145+
- Viem ^2.30.0
146+
- Wagmi ^2.0.0
147+
148+
## License
149+
150+
MIT
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "@zksync-sso/connector-export",
3+
"type": "module",
4+
"version": "0.1.0",
5+
"description": "Exports only the connector from the zksync-sso SDK.",
6+
"main": "dist/index.js",
7+
"module": "dist/index.js",
8+
"types": "dist/index.d.ts",
9+
"exports": {
10+
".": {
11+
"import": "./dist/index.js",
12+
"types": "./dist/index.d.ts"
13+
},
14+
"./package.json": "./package.json"
15+
},
16+
"files": [
17+
"dist"
18+
],
19+
"scripts": {
20+
"build:ts": "tsc --project tsconfig.build.json",
21+
"tsclean": "rm -rf dist *.tsbuildinfo",
22+
"build": "npm run clean && npm run build:esm && npm run build:cjs && npm run build:types && npm run build:ts",
23+
"build:esm": "tsc --project tsconfig.build.json --outDir ./dist/_esm && printf '{\"type\": \"module\",\"sideEffects\":false}' > ./dist/_esm/package.json",
24+
"build:cjs": "tsc --project ./tsconfig.build.json --outDir ./dist/_cjs --removeComments --verbatimModuleSyntax false && printf '{\"type\":\"commonjs\"}' > ./dist/_cjs/package.json",
25+
"build:types": "tsc --project ./tsconfig.build.json --declarationDir ./dist/_types --emitDeclarationOnly --declaration --declarationMap",
26+
"clean": "rm -rf *.tsbuildinfo dist",
27+
"typecheck": "tsc --noEmit",
28+
"publish:local": "pnpm publish --no-git-checks --force",
29+
"test": "vitest run"
30+
},
31+
"peerDependencies": {
32+
"viem": "^2.30.0",
33+
"zksync-sso": "workspace:*"
34+
},
35+
"author": "Matter Labs",
36+
"license": "MIT",
37+
"devDependencies": {
38+
"vitest": "^2.1.8"
39+
}
40+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { promises as fs } from "fs";
2+
import path from "path";
3+
4+
const version = process.env.INPUT_VERSION;
5+
if (!version) {
6+
console.error("Error: INPUT_VERSION is required.");
7+
process.exit(1);
8+
}
9+
10+
const packageJsonPath = path.resolve("./package.json");
11+
12+
async function preparePackageJson() {
13+
try {
14+
const packageJsonData = await fs.readFile(packageJsonPath, "utf8");
15+
const packageJson = JSON.parse(packageJsonData);
16+
17+
// Remove unnecessary properties for publishing
18+
delete packageJson.private;
19+
delete packageJson.publishConfig;
20+
21+
// Set the new version
22+
packageJson.version = version;
23+
24+
// Write the updated package.json back to the file
25+
await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));
26+
27+
console.log(`Updated connector-export package.json for version ${version}`);
28+
} catch (error) {
29+
console.error("Error updating connector-export package.json:", error);
30+
process.exit(1);
31+
}
32+
}
33+
34+
preparePackageJson();

0 commit comments

Comments
 (0)