|
| 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 |
0 commit comments