@zerodev/wallet-react 0.0.1-alpha.1 → 0.0.1-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/_cjs/connector.js +32 -36
- package/dist/_esm/connector.js +38 -42
- package/dist/_types/connector.d.ts.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/connector.ts +45 -50
- package/tsconfig.build.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zerodev/wallet-react",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.3",
|
|
4
4
|
"description": "React hooks for ZeroDev Wallet SDK",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/_cjs/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"wagmi": "^3.0.0",
|
|
31
31
|
"zustand": "^5.0.3",
|
|
32
32
|
"ox": "^0.3.0",
|
|
33
|
-
"@zerodev/wallet-core": "0.0.1-alpha.
|
|
33
|
+
"@zerodev/wallet-core": "0.0.1-alpha.5"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/react": "^19",
|
package/src/connector.ts
CHANGED
|
@@ -50,62 +50,57 @@ export function zeroDevWallet(
|
|
|
50
50
|
return createConnector<Provider, Properties>((wagmiConfig) => {
|
|
51
51
|
let store: ReturnType<typeof createZeroDevWalletStore>
|
|
52
52
|
let provider: ReturnType<typeof createProvider>
|
|
53
|
-
let initPromise: Promise<void> | undefined
|
|
54
53
|
|
|
55
54
|
// Get transports from Wagmi config (uses user's RPC URLs)
|
|
56
55
|
const transports = wagmiConfig.transports
|
|
57
56
|
|
|
58
57
|
// Lazy initialization - only runs on client side
|
|
59
58
|
const initialize = async () => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
console.log('ZeroDevWallet connector initialized')
|
|
106
|
-
})()
|
|
107
|
-
|
|
108
|
-
return initPromise
|
|
59
|
+
console.log('Initializing ZeroDevWallet connector...')
|
|
60
|
+
|
|
61
|
+
// Initialize wallet SDK
|
|
62
|
+
const wallet = await createZeroDevWallet({
|
|
63
|
+
projectId: params.projectId,
|
|
64
|
+
...(params.organizationId && {
|
|
65
|
+
organizationId: params.organizationId,
|
|
66
|
+
}),
|
|
67
|
+
...(params.proxyBaseUrl && { proxyBaseUrl: params.proxyBaseUrl }),
|
|
68
|
+
...(params.sessionStorage && {
|
|
69
|
+
sessionStorage: params.sessionStorage,
|
|
70
|
+
}),
|
|
71
|
+
...(params.rpId && { rpId: params.rpId }),
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
// Create store
|
|
75
|
+
store = createZeroDevWalletStore()
|
|
76
|
+
store.getState().setWallet(wallet)
|
|
77
|
+
|
|
78
|
+
// Initialize chainIds
|
|
79
|
+
const chainIds = params.chains.map((c) => c.id)
|
|
80
|
+
store.setState({ chainIds })
|
|
81
|
+
|
|
82
|
+
// Store OAuth config if provided
|
|
83
|
+
if (params.oauthConfig) {
|
|
84
|
+
store.getState().setOAuthConfig(params.oauthConfig)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Create EIP-1193 provider
|
|
88
|
+
provider = createProvider({
|
|
89
|
+
store,
|
|
90
|
+
config: params,
|
|
91
|
+
chains: Array.from(params.chains),
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
// Check for existing session (page reload)
|
|
95
|
+
const session = await wallet.getSession()
|
|
96
|
+
if (session) {
|
|
97
|
+
console.log('Found existing session, restoring...')
|
|
98
|
+
const eoaAccount = await wallet.toAccount()
|
|
99
|
+
store.getState().setEoaAccount(eoaAccount)
|
|
100
|
+
store.getState().setSession(session)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
console.log('ZeroDevWallet connector initialized')
|
|
109
104
|
}
|
|
110
105
|
|
|
111
106
|
return {
|