@dynamic-labs/ethereum-aa 2.0.0-alpha.1 → 2.0.0-alpha.11
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 +160 -0
- package/package.json +12 -10
- package/src/ZeroDevConnector.cjs +78 -60
- package/src/ZeroDevConnector.d.ts +10 -9
- package/src/ZeroDevConnector.js +80 -62
- package/src/utils/fetchChain.cjs +28 -0
- package/src/utils/fetchChain.d.ts +3 -0
- package/src/utils/fetchChain.js +23 -0
- package/src/utils/index.d.ts +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,164 @@
|
|
|
1
1
|
|
|
2
|
+
## [2.0.0-alpha.11](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.10...v2.0.0-alpha.11) (2024-03-12)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### ⚠ BREAKING CHANGES
|
|
6
|
+
|
|
7
|
+
* rename FetchPublicAddressOpts to GetAddressOpts (#4910)
|
|
8
|
+
* remove use effect in useWalletEventListeners (#4843)
|
|
9
|
+
* rename fetchPublicAddress to getAddress (#4851)
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* Add farcaster to iconic ([#4925](https://github.com/dynamic-labs/DynamicAuth/issues/4925)) ([ab282dc](https://github.com/dynamic-labs/DynamicAuth/commit/ab282dc9cdcc0fe11f014d002b056ef4d3b34234))
|
|
14
|
+
* use transaction confirmation ui on signAndSendTransaction for solana embedded wallets ([#4909](https://github.com/dynamic-labs/DynamicAuth/issues/4909)) ([d77e89e](https://github.com/dynamic-labs/DynamicAuth/commit/d77e89ecff9dfc67ed48537f541a9995b2662e1e))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* add back connect button css variables ([#4922](https://github.com/dynamic-labs/DynamicAuth/issues/4922)) ([1119d62](https://github.com/dynamic-labs/DynamicAuth/commit/1119d62c2db6504952393060930524c3823e4a00))
|
|
20
|
+
* keep adaptive wallet list height ([#4916](https://github.com/dynamic-labs/DynamicAuth/issues/4916)) ([62aa54e](https://github.com/dynamic-labs/DynamicAuth/commit/62aa54e81d563082f7aa519f2ff2b5132e7dd83d))
|
|
21
|
+
* pass account and chain to walletClient ([#4865](https://github.com/dynamic-labs/DynamicAuth/issues/4865)) ([17a143f](https://github.com/dynamic-labs/DynamicAuth/commit/17a143f87a77e56227b2517038c20cf67f8e08bf))
|
|
22
|
+
* update walletbook to fix zerion in-app browser detection issue ([#4917](https://github.com/dynamic-labs/DynamicAuth/issues/4917)) ([48b05d7](https://github.com/dynamic-labs/DynamicAuth/commit/48b05d78e4f7add09787b64505723d4eca34d3e0))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
* remove use effect in useWalletEventListeners ([#4843](https://github.com/dynamic-labs/DynamicAuth/issues/4843)) ([2e948bb](https://github.com/dynamic-labs/DynamicAuth/commit/2e948bbca0dbdceab7460a844d0988eacd47f581))
|
|
26
|
+
* rename fetchPublicAddress to getAddress ([#4851](https://github.com/dynamic-labs/DynamicAuth/issues/4851)) ([668e7dd](https://github.com/dynamic-labs/DynamicAuth/commit/668e7dd62e1f323dbe64209b5c59c2cd0ee45d61))
|
|
27
|
+
* rename FetchPublicAddressOpts to GetAddressOpts ([#4910](https://github.com/dynamic-labs/DynamicAuth/issues/4910)) ([e5e4b1b](https://github.com/dynamic-labs/DynamicAuth/commit/e5e4b1b08a4e010afa44f8abb0bf6af7f236a86a))
|
|
28
|
+
|
|
29
|
+
## [2.0.0-alpha.10](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.9...v2.0.0-alpha.10) (2024-03-08)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### ⚠ BREAKING CHANGES
|
|
33
|
+
|
|
34
|
+
* rename hideEmbeddedWalletUIs prop to hideEmbeddedWalletTra… (#4892)
|
|
35
|
+
* refactor send transaction for multi chain (#4831)
|
|
36
|
+
|
|
37
|
+
### Features
|
|
38
|
+
|
|
39
|
+
* add sandbox indicator to sdk ([62fd821](https://github.com/dynamic-labs/DynamicAuth/commit/62fd821a895bb54cec4cae3d153aa0056a7e6638))
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Bug Fixes
|
|
43
|
+
|
|
44
|
+
* coinbase connector and auth fetcher no being set properly ([#4891](https://github.com/dynamic-labs/DynamicAuth/issues/4891)) ([328566f](https://github.com/dynamic-labs/DynamicAuth/commit/328566ff39c38d5b5761ddc655de3a5d08bb567a))
|
|
45
|
+
* fix server side rendering ([#4811](https://github.com/dynamic-labs/DynamicAuth/issues/4811)) ([063dfae](https://github.com/dynamic-labs/DynamicAuth/commit/063dfae8b6750875d2f35dd9709a1f675495f4fb))
|
|
46
|
+
* hide network ([#4885](https://github.com/dynamic-labs/DynamicAuth/issues/4885)) ([ec10c58](https://github.com/dynamic-labs/DynamicAuth/commit/ec10c588218f067e991d5830fc06ec081e4e1d18))
|
|
47
|
+
* network picker on mobile ([#4887](https://github.com/dynamic-labs/DynamicAuth/issues/4887)) ([6e0ab1b](https://github.com/dynamic-labs/DynamicAuth/commit/6e0ab1bc7d138b73373741960a501ff7cf20e3f9))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
* refactor send transaction for multi chain ([#4831](https://github.com/dynamic-labs/DynamicAuth/issues/4831)) ([c98444b](https://github.com/dynamic-labs/DynamicAuth/commit/c98444be7935420dda3d8216d03946f5893eb82f))
|
|
51
|
+
* rename hideEmbeddedWalletUIs prop to hideEmbeddedWalletTra… ([#4892](https://github.com/dynamic-labs/DynamicAuth/issues/4892)) ([7cdf519](https://github.com/dynamic-labs/DynamicAuth/commit/7cdf5196b1cd8516de2d456163fe9071956d40d3))
|
|
52
|
+
|
|
53
|
+
## [2.0.0-alpha.9](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.8...v2.0.0-alpha.9) (2024-03-06)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### Features
|
|
57
|
+
|
|
58
|
+
* solana connector new sendTransaction method ([#4842](https://github.com/dynamic-labs/DynamicAuth/issues/4842)) ([0b198e3](https://github.com/dynamic-labs/DynamicAuth/commit/0b198e30d83fbbc8d506654d87cbfad403fda289))
|
|
59
|
+
* specify solana network when using phantom redirect deeplinking ([#4863](https://github.com/dynamic-labs/DynamicAuth/issues/4863)) ([fb4ee7c](https://github.com/dynamic-labs/DynamicAuth/commit/fb4ee7cfc0493c9c85b6ccb31954842556c58aa4))
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
### Bug Fixes
|
|
63
|
+
|
|
64
|
+
* isLoggedIn should return true even when there is no primary wallet ([#4875](https://github.com/dynamic-labs/DynamicAuth/issues/4875)) ([f396e22](https://github.com/dynamic-labs/DynamicAuth/commit/f396e22b9d809b05ac52194ffa4346f3591d17fe))
|
|
65
|
+
* update btckit network conversion for signPsbt ([a6009e1](https://github.com/dynamic-labs/DynamicAuth/commit/a6009e18c453b4e65545455fea0e52ed7a983b4d))
|
|
66
|
+
* user getting logged out when signing in with email linked to a unavailable wallet ([#4858](https://github.com/dynamic-labs/DynamicAuth/issues/4858)) ([8653e13](https://github.com/dynamic-labs/DynamicAuth/commit/8653e13d2067dd0161e660b4374c08a9fe0bc203))
|
|
67
|
+
|
|
68
|
+
## [2.0.0-alpha.8](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.7...v2.0.0-alpha.8) (2024-03-04)
|
|
69
|
+
|
|
70
|
+
## [2.0.0-alpha.7](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.6...v2.0.0-alpha.7) (2024-02-28)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
### ⚠ BREAKING CHANGES
|
|
74
|
+
|
|
75
|
+
* add networkValidationMode and remove enableForcedNetworkValidation (#4778)
|
|
76
|
+
|
|
77
|
+
### Features
|
|
78
|
+
|
|
79
|
+
* add bitget and okx wallets ([51fab41](https://github.com/dynamic-labs/DynamicAuth/commit/51fab413096fd89ce99c6c617cf4f3f5db9bf44d))
|
|
80
|
+
* add networkValidationMode and remove enableForcedNetworkValidation ([#4778](https://github.com/dynamic-labs/DynamicAuth/issues/4778)) ([ccb9576](https://github.com/dynamic-labs/DynamicAuth/commit/ccb9576c81b2c570185f5126d6d1fcfcbb5ac9e3))
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
### Bug Fixes
|
|
84
|
+
|
|
85
|
+
* **GVTY-1243:** non evm onramp urls ([#4791](https://github.com/dynamic-labs/DynamicAuth/issues/4791)) ([fea602e](https://github.com/dynamic-labs/DynamicAuth/commit/fea602e2835b4bb9bc096b96375fa97297bf35f1))
|
|
86
|
+
* revert use enableForcedNetworkValidation on connect-only ([#4750](https://github.com/dynamic-labs/DynamicAuth/issues/4750)) ([#4772](https://github.com/dynamic-labs/DynamicAuth/issues/4772)) ([b871c22](https://github.com/dynamic-labs/DynamicAuth/commit/b871c2295f39230bc34ae1fca5f8817cd9251a17))
|
|
87
|
+
* use correct chromeId for okx and bitget wallets and remove group from coin98 ([#4795](https://github.com/dynamic-labs/DynamicAuth/issues/4795)) ([e63bad7](https://github.com/dynamic-labs/DynamicAuth/commit/e63bad76ed06636151212c915a102359a03b4218))
|
|
88
|
+
|
|
89
|
+
## [2.0.0-alpha.6](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.5...v2.0.0-alpha.6) (2024-02-26)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
### ⚠ BREAKING CHANGES
|
|
93
|
+
|
|
94
|
+
* setShowAuthFlow opens dynamic profile in non-multi-wallet states
|
|
95
|
+
|
|
96
|
+
### Features
|
|
97
|
+
|
|
98
|
+
* allow passing prop to hide embedded wallet action confirmation UIs ([#4775](https://github.com/dynamic-labs/DynamicAuth/issues/4775)) ([d7c6a46](https://github.com/dynamic-labs/DynamicAuth/commit/d7c6a4699e41f6a62d31880c3bd0346ebfa0e3ba))
|
|
99
|
+
* make sms mobile keyboard numeric ([#4755](https://github.com/dynamic-labs/DynamicAuth/issues/4755)) ([f36844a](https://github.com/dynamic-labs/DynamicAuth/commit/f36844aeaae240c520181b3242492db8ffc64a50))
|
|
100
|
+
* setShowAuthFlow opens dynamic profile in non-multi-wallet states ([42dbbc0](https://github.com/dynamic-labs/DynamicAuth/commit/42dbbc00a5cebe937dca5a80397cdd3c577f6a45))
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
### Bug Fixes
|
|
104
|
+
|
|
105
|
+
* demo one-time codes for solana wallets fix ([#4760](https://github.com/dynamic-labs/DynamicAuth/issues/4760)) ([a5ab2a8](https://github.com/dynamic-labs/DynamicAuth/commit/a5ab2a8bc348a35a898e03db0900bfab88184c17))
|
|
106
|
+
* only store passcode in backend when auto-generated by dynamic ([#4764](https://github.com/dynamic-labs/DynamicAuth/issues/4764)) ([528bedc](https://github.com/dynamic-labs/DynamicAuth/commit/528bedce5cbd3022ddafe4242954a04f5b70ae74))
|
|
107
|
+
* use enableForcedNetworkValidation on connect-only ([#4750](https://github.com/dynamic-labs/DynamicAuth/issues/4750)) ([6299f7c](https://github.com/dynamic-labs/DynamicAuth/commit/6299f7c3ce705ddb19714f6b7a3a488851ed8dde))
|
|
108
|
+
|
|
109
|
+
## [2.0.0-alpha.5](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.4...v2.0.0-alpha.5) (2024-02-22)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
### ⚠ BREAKING CHANGES
|
|
113
|
+
|
|
114
|
+
* wagmi v2 (#4660)
|
|
115
|
+
|
|
116
|
+
### Features
|
|
117
|
+
|
|
118
|
+
* wagmi v2 ([#4660](https://github.com/dynamic-labs/DynamicAuth/issues/4660)) ([d8894e6](https://github.com/dynamic-labs/DynamicAuth/commit/d8894e61393b90ccf44904c33394b54286f0f9e9))
|
|
119
|
+
|
|
120
|
+
## [2.0.0-alpha.4](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.3...v2.0.0-alpha.4) (2024-02-22)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
### ⚠ BREAKING CHANGES
|
|
124
|
+
|
|
125
|
+
* remove wallet connector from callback types (#4730)
|
|
126
|
+
* drop support for walletconnect v1 (#4666)
|
|
127
|
+
|
|
128
|
+
### Features
|
|
129
|
+
|
|
130
|
+
* add coin98 evm ([1d64f5f](https://github.com/dynamic-labs/DynamicAuth/commit/1d64f5f00885ff671358651fd0251b77a2e05739))
|
|
131
|
+
* add support for solana versioned transactions ([#4721](https://github.com/dynamic-labs/DynamicAuth/issues/4721)) ([25b1643](https://github.com/dynamic-labs/DynamicAuth/commit/25b1643f8addbada09fff5d22e988bdf22038170))
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
### Bug Fixes
|
|
135
|
+
|
|
136
|
+
* allow rpc-providers package to use exports based on usage ([#4539](https://github.com/dynamic-labs/DynamicAuth/issues/4539)) ([abdc196](https://github.com/dynamic-labs/DynamicAuth/commit/abdc19641580cbcfe8f9e357c645f8291bc9ed66))
|
|
137
|
+
* coinbasesocial should display coinbase in profile linking section ([#4680](https://github.com/dynamic-labs/DynamicAuth/issues/4680)) ([21cbe2e](https://github.com/dynamic-labs/DynamicAuth/commit/21cbe2e24345a33bc927428c01cc7b5c724e40e5))
|
|
138
|
+
* improve on transaction confirmation step ([#4704](https://github.com/dynamic-labs/DynamicAuth/issues/4704)) ([f2b27cf](https://github.com/dynamic-labs/DynamicAuth/commit/f2b27cfd94452be2eb7e88a298f61ef56985931f))
|
|
139
|
+
* prevent the DynamicMultiWalletPromptsWidget from opening if useris not logged in ([#4701](https://github.com/dynamic-labs/DynamicAuth/issues/4701)) ([2bb35fd](https://github.com/dynamic-labs/DynamicAuth/commit/2bb35fd29b60677e893390f7d47857cd76c73adc))
|
|
140
|
+
* reduce isPreauthorized calls when starknet wallet is connected ([#4710](https://github.com/dynamic-labs/DynamicAuth/issues/4710)) ([ca6a630](https://github.com/dynamic-labs/DynamicAuth/commit/ca6a630dd47a1c116afcd63fe7256ffc745532ab))
|
|
141
|
+
* update sepolia currency symbol ([#4728](https://github.com/dynamic-labs/DynamicAuth/issues/4728)) ([3c228a0](https://github.com/dynamic-labs/DynamicAuth/commit/3c228a03ccc962374ad1dac3ab45af92732ba61a))
|
|
142
|
+
* use overflow clip when available, use hidden by default ([#4696](https://github.com/dynamic-labs/DynamicAuth/issues/4696)) ([29fb2a1](https://github.com/dynamic-labs/DynamicAuth/commit/29fb2a1e48b010c6c1d525403fbdcf7ded068466))
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
* drop support for walletconnect v1 ([#4666](https://github.com/dynamic-labs/DynamicAuth/issues/4666)) ([4af93e4](https://github.com/dynamic-labs/DynamicAuth/commit/4af93e4f9b95fa4c49bbfda0c1144da1a4a43991))
|
|
146
|
+
* remove wallet connector from callback types ([#4730](https://github.com/dynamic-labs/DynamicAuth/issues/4730)) ([08cb200](https://github.com/dynamic-labs/DynamicAuth/commit/08cb200a09c0fd78d2093d1a60b17089b3b2c2b1))
|
|
147
|
+
|
|
148
|
+
## [2.0.0-alpha.3](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.2...v2.0.0-alpha.3) (2024-02-13)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
### Bug Fixes
|
|
152
|
+
|
|
153
|
+
* allow any icon to be used in wallet list tabs ([#4678](https://github.com/dynamic-labs/DynamicAuth/issues/4678)) ([eb03603](https://github.com/dynamic-labs/DynamicAuth/commit/eb036031725a91cb28c144b3bdcb5b20b3314038))
|
|
154
|
+
|
|
155
|
+
## [2.0.0-alpha.2](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.1...v2.0.0-alpha.2) (2024-02-13)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
### Bug Fixes
|
|
159
|
+
|
|
160
|
+
* old iconic dependency version ([#4673](https://github.com/dynamic-labs/DynamicAuth/issues/4673)) ([4a5c448](https://github.com/dynamic-labs/DynamicAuth/commit/4a5c448c251540139f84514328d5f1d31808d75c))
|
|
161
|
+
|
|
2
162
|
## [2.0.0-alpha.1](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.0...v2.0.0-alpha.1) (2024-02-12)
|
|
3
163
|
|
|
4
164
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/ethereum-aa",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.11",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -26,16 +26,18 @@
|
|
|
26
26
|
"./package.json": "./package.json"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"@dynamic-labs/
|
|
31
|
-
"@dynamic-labs/
|
|
32
|
-
"@dynamic-labs/
|
|
33
|
-
"@dynamic-labs/utils": "2.0.0-alpha.
|
|
34
|
-
"@dynamic-labs/
|
|
35
|
-
"@dynamic-labs/wallet-
|
|
36
|
-
"@dynamic-labs/wallet-connector-core": "2.0.0-alpha.1"
|
|
29
|
+
"@dynamic-labs/sdk-api": "0.0.376",
|
|
30
|
+
"@dynamic-labs/logger": "2.0.0-alpha.11",
|
|
31
|
+
"@dynamic-labs/types": "2.0.0-alpha.11",
|
|
32
|
+
"@dynamic-labs/utils": "2.0.0-alpha.11",
|
|
33
|
+
"@dynamic-labs/viem-utils": "2.0.0-alpha.11",
|
|
34
|
+
"@dynamic-labs/wallet-book": "2.0.0-alpha.11",
|
|
35
|
+
"@dynamic-labs/wallet-connector-core": "2.0.0-alpha.11"
|
|
37
36
|
},
|
|
38
37
|
"peerDependencies": {
|
|
39
|
-
"
|
|
38
|
+
"@zerodev/presets": "^5.1.4",
|
|
39
|
+
"@zerodev/sdk": "^5.1.7",
|
|
40
|
+
"permissionless": "^0.0.34",
|
|
41
|
+
"viem": "^2.7.6"
|
|
40
42
|
}
|
|
41
43
|
}
|
package/src/ZeroDevConnector.cjs
CHANGED
|
@@ -3,17 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _tslib = require('../_virtual/_tslib.cjs');
|
|
6
|
-
var
|
|
6
|
+
var presets = require('@zerodev/presets');
|
|
7
7
|
var viem = require('viem');
|
|
8
|
+
var permissionless = require('permissionless');
|
|
8
9
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
9
10
|
var viemUtils = require('@dynamic-labs/viem-utils');
|
|
10
11
|
var utils = require('@dynamic-labs/utils');
|
|
12
|
+
var fetchChain = require('./utils/fetchChain.cjs');
|
|
11
13
|
var logger = require('./utils/logger.cjs');
|
|
12
14
|
|
|
13
15
|
class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
14
|
-
get key() {
|
|
15
|
-
return 'zerodev';
|
|
16
|
-
}
|
|
17
16
|
constructor(opts) {
|
|
18
17
|
var _a;
|
|
19
18
|
super(opts);
|
|
@@ -22,6 +21,7 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
22
21
|
this.isGasSponsorshipDisabled = false;
|
|
23
22
|
this.isEmbeddedWallet = true;
|
|
24
23
|
this.name = 'ZeroDev';
|
|
24
|
+
this.overrideKey = 'zerodev';
|
|
25
25
|
const zeroDevProjectId = (_a = opts.apiProviders.zerodev) === null || _a === void 0 ? void 0 : _a.clientId;
|
|
26
26
|
if (!zeroDevProjectId) {
|
|
27
27
|
throw new Error('Missing ZeroDev project ID provided. Add your ZeroDev project id to your project configuration via the Dynamic Labs dashboard.');
|
|
@@ -34,28 +34,35 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
34
34
|
return this.eoaConnector;
|
|
35
35
|
}
|
|
36
36
|
getAccountAbstractionProvider() {
|
|
37
|
-
return this.
|
|
37
|
+
return this.kernelClient;
|
|
38
|
+
}
|
|
39
|
+
endSession() {
|
|
40
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
localStorage.removeItem(fetchChain.cachedChainIdKey);
|
|
42
|
+
});
|
|
38
43
|
}
|
|
39
44
|
setEoaConnector(connector) {
|
|
40
45
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
this.
|
|
46
|
+
this.kernelClientDeferredPromise = new utils.DeferredPromise();
|
|
42
47
|
this.eoaConnector = connector;
|
|
43
48
|
const signer = yield this.eoaConnector.getSigner();
|
|
44
|
-
if (!signer) {
|
|
49
|
+
if (!(signer === null || signer === void 0 ? void 0 : signer.account)) {
|
|
45
50
|
return;
|
|
46
51
|
}
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
const kernelClient = yield presets.createEcdsaKernelAccountClient({
|
|
53
|
+
chain: yield fetchChain.fetchChain(this.projectId),
|
|
54
|
+
paymaster: 'NONE',
|
|
50
55
|
projectId: this.projectId,
|
|
56
|
+
provider: 'STACKUP',
|
|
57
|
+
signer: permissionless.walletClientToSmartAccountSigner(signer),
|
|
51
58
|
});
|
|
52
|
-
utils.wrapMethodWithCallback(
|
|
59
|
+
utils.wrapMethodWithCallback(kernelClient, 'sendUserOperation', (original, ...args) => {
|
|
53
60
|
this._walletUiUtils.disabledConfirmationOnce();
|
|
54
61
|
return original(...args);
|
|
55
62
|
});
|
|
56
|
-
this.
|
|
63
|
+
this.kernelClient = kernelClient;
|
|
57
64
|
yield this.checkIsProjectChainEnabled();
|
|
58
|
-
this.
|
|
65
|
+
this.kernelClientDeferredPromise.resolve();
|
|
59
66
|
});
|
|
60
67
|
}
|
|
61
68
|
checkIsProjectChainEnabled() {
|
|
@@ -70,69 +77,67 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
70
77
|
}
|
|
71
78
|
});
|
|
72
79
|
}
|
|
73
|
-
|
|
80
|
+
getKernelClientWithSponsorshipValidation() {
|
|
74
81
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
if (this.
|
|
76
|
-
return this.
|
|
82
|
+
if (this.kernelClientWithSponsorship) {
|
|
83
|
+
return this.kernelClientWithSponsorship;
|
|
77
84
|
}
|
|
78
85
|
const { eoaConnector } = this;
|
|
79
86
|
if (!eoaConnector)
|
|
80
87
|
throw new utils.DynamicError('No EOA connector');
|
|
81
88
|
const signer = yield eoaConnector.getSigner();
|
|
82
|
-
this.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
paymasterConfig: {
|
|
86
|
-
onlySendSponsoredTransaction: true,
|
|
87
|
-
policy: 'VERIFYING_PAYMASTER',
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
owner: sdk.convertWalletClientToAccountSigner(signer),
|
|
89
|
+
this.kernelClientWithSponsorship = yield presets.createEcdsaKernelAccountClient({
|
|
90
|
+
chain: yield fetchChain.fetchChain(this.projectId),
|
|
91
|
+
paymaster: 'SPONSOR',
|
|
91
92
|
projectId: this.projectId,
|
|
93
|
+
provider: 'STACKUP',
|
|
94
|
+
signer: permissionless.walletClientToSmartAccountSigner(signer),
|
|
92
95
|
});
|
|
93
|
-
utils.wrapMethodWithCallback(this.
|
|
96
|
+
utils.wrapMethodWithCallback(this.kernelClientWithSponsorship, 'sendUserOperation', (original, ...args) => {
|
|
94
97
|
this._walletUiUtils.disabledConfirmationOnce();
|
|
95
98
|
return original(...args);
|
|
96
99
|
});
|
|
97
|
-
return this.
|
|
100
|
+
return this.kernelClientWithSponsorship;
|
|
98
101
|
});
|
|
99
102
|
}
|
|
100
|
-
|
|
101
|
-
var _a, _b;
|
|
103
|
+
getAddress() {
|
|
104
|
+
var _a, _b, _c;
|
|
102
105
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
yield ((_a = this.
|
|
104
|
-
return (_b = this.
|
|
106
|
+
yield ((_a = this.kernelClientDeferredPromise) === null || _a === void 0 ? void 0 : _a.promise);
|
|
107
|
+
return (_c = (_b = this.kernelClient) === null || _b === void 0 ? void 0 : _b.account) === null || _c === void 0 ? void 0 : _c.address;
|
|
105
108
|
});
|
|
106
109
|
}
|
|
107
110
|
getConnectedAccounts() {
|
|
108
|
-
var _a;
|
|
111
|
+
var _a, _b, _c;
|
|
109
112
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
110
|
-
yield ((_a = this.
|
|
111
|
-
return this.
|
|
112
|
-
? [yield this.
|
|
113
|
+
yield ((_a = this.kernelClientDeferredPromise) === null || _a === void 0 ? void 0 : _a.promise);
|
|
114
|
+
return ((_c = (_b = this.kernelClient) === null || _b === void 0 ? void 0 : _b.account) === null || _c === void 0 ? void 0 : _c.address)
|
|
115
|
+
? [yield this.kernelClient.account.address]
|
|
113
116
|
: [];
|
|
114
117
|
});
|
|
115
118
|
}
|
|
116
119
|
getNetwork() {
|
|
117
|
-
var _a, _b;
|
|
120
|
+
var _a, _b, _c;
|
|
118
121
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
119
|
-
yield ((_a = this.
|
|
120
|
-
return (_b = this.
|
|
122
|
+
yield ((_a = this.kernelClientDeferredPromise) === null || _a === void 0 ? void 0 : _a.promise);
|
|
123
|
+
return (_c = (_b = this.kernelClient) === null || _b === void 0 ? void 0 : _b.chain) === null || _c === void 0 ? void 0 : _c.id;
|
|
121
124
|
});
|
|
122
125
|
}
|
|
123
126
|
getTransport(provider) {
|
|
124
127
|
const transport = viemUtils.confirmationTransport({
|
|
125
|
-
connector: this,
|
|
126
128
|
onPersonalSign: ({ message }) => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
127
129
|
this._walletUiUtils.disabledConfirmationOnce();
|
|
128
|
-
return provider.signMessage(
|
|
130
|
+
return provider.signMessage({
|
|
131
|
+
account: provider.account,
|
|
132
|
+
message,
|
|
133
|
+
});
|
|
129
134
|
}),
|
|
130
135
|
onSendTransaction: ({ transaction }) => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
131
136
|
try {
|
|
132
137
|
this._walletUiUtils.disabledConfirmationOnce();
|
|
133
138
|
const effectiveProvider = this.isGasSponsorshipDisabled
|
|
134
139
|
? provider
|
|
135
|
-
: yield this.
|
|
140
|
+
: yield this.getKernelClientWithSponsorshipValidation();
|
|
136
141
|
const response = yield effectiveProvider.sendTransaction(viemUtils.unFormatTransaction(transaction));
|
|
137
142
|
return response;
|
|
138
143
|
}
|
|
@@ -150,39 +155,48 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
150
155
|
onSignTypedData: ({ message }) => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
151
156
|
this._walletUiUtils.disabledConfirmationOnce();
|
|
152
157
|
const signTypedData = JSON.parse(message);
|
|
153
|
-
return provider.signTypedData(
|
|
158
|
+
return provider.signTypedData({
|
|
159
|
+
account: provider.account,
|
|
160
|
+
message: signTypedData.message,
|
|
161
|
+
primaryType: signTypedData.primaryType,
|
|
162
|
+
types: signTypedData.types,
|
|
163
|
+
});
|
|
154
164
|
}),
|
|
155
|
-
provider
|
|
165
|
+
provider,
|
|
156
166
|
transport: viem.custom(provider),
|
|
167
|
+
walletConnector: this,
|
|
157
168
|
walletUiUtils: this._walletUiUtils,
|
|
158
169
|
});
|
|
159
170
|
return transport;
|
|
160
171
|
}
|
|
161
|
-
getWalletClient() {
|
|
162
|
-
const provider = this.
|
|
172
|
+
getWalletClient(chainId) {
|
|
173
|
+
const provider = this.kernelClient;
|
|
163
174
|
if (!provider)
|
|
164
175
|
throw new utils.DynamicError('No provider');
|
|
165
176
|
const transport = this.getTransport(provider);
|
|
166
177
|
const walletClient = viem.createWalletClient({
|
|
178
|
+
account: provider.account,
|
|
179
|
+
chain: chainId ? viemUtils.chainsMap[chainId] : undefined,
|
|
167
180
|
transport,
|
|
168
181
|
});
|
|
169
182
|
return walletClient;
|
|
170
183
|
}
|
|
171
184
|
getPublicClient() {
|
|
172
185
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
173
|
-
const provider = this.
|
|
186
|
+
const provider = this.kernelClient.extend(viem.publicActions);
|
|
174
187
|
if (!provider)
|
|
175
188
|
throw new utils.DynamicError('No provider');
|
|
176
|
-
return provider
|
|
189
|
+
return provider;
|
|
177
190
|
});
|
|
178
191
|
}
|
|
179
192
|
getSigner() {
|
|
193
|
+
var _a;
|
|
180
194
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
181
|
-
const provider = this.
|
|
195
|
+
const provider = this.kernelClient;
|
|
182
196
|
if (!provider)
|
|
183
197
|
throw new utils.DynamicError('No provider');
|
|
184
198
|
const transport = this.getTransport(provider);
|
|
185
|
-
const address =
|
|
199
|
+
const address = (_a = provider.account) === null || _a === void 0 ? void 0 : _a.address;
|
|
186
200
|
const walletClient = viem.createWalletClient({
|
|
187
201
|
account: address,
|
|
188
202
|
transport,
|
|
@@ -191,17 +205,22 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
191
205
|
});
|
|
192
206
|
}
|
|
193
207
|
canSponsorTransactionGas(transaction) {
|
|
194
|
-
var _a;
|
|
195
208
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
196
209
|
try {
|
|
210
|
+
yield this.getKernelClientWithSponsorshipValidation();
|
|
197
211
|
const userOperation = {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
212
|
+
callData: yield this.kernelClientWithSponsorship.account.encodeCallData({
|
|
213
|
+
data: transaction.data ? transaction.data : '0x',
|
|
214
|
+
to: transaction.to,
|
|
215
|
+
value: viem.isHex(transaction.value)
|
|
216
|
+
? viem.fromHex(transaction.value, 'bigint')
|
|
217
|
+
: transaction.value,
|
|
218
|
+
}),
|
|
203
219
|
};
|
|
204
|
-
const result = yield
|
|
220
|
+
const result = yield this.kernelClientWithSponsorship.prepareUserOperationRequest({
|
|
221
|
+
account: this.kernelClientWithSponsorship.account,
|
|
222
|
+
userOperation,
|
|
223
|
+
});
|
|
205
224
|
if (!result)
|
|
206
225
|
return false;
|
|
207
226
|
return result.paymasterAndData !== '0x';
|
|
@@ -216,12 +235,11 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
216
235
|
this.isGasSponsorshipDisabled = true;
|
|
217
236
|
}
|
|
218
237
|
getBalance() {
|
|
219
|
-
var _a;
|
|
220
238
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
221
|
-
const rpcClient =
|
|
239
|
+
const rpcClient = this.kernelClient.extend(viem.publicActions);
|
|
222
240
|
if (!rpcClient)
|
|
223
241
|
throw new utils.DynamicError('No RPC client');
|
|
224
|
-
const address = yield this.
|
|
242
|
+
const address = yield this.getAddress();
|
|
225
243
|
if (!address)
|
|
226
244
|
return;
|
|
227
245
|
return viem.formatEther(yield rpcClient.getBalance({ address: address }));
|
|
@@ -230,7 +248,7 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
230
248
|
signMessage(messageToSign) {
|
|
231
249
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
232
250
|
const client = yield this.getSigner();
|
|
233
|
-
const account = yield this.
|
|
251
|
+
const account = yield this.getAddress();
|
|
234
252
|
if (!account || !client)
|
|
235
253
|
return;
|
|
236
254
|
return client.signMessage({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { KernelAccountClient } from '@zerodev/sdk';
|
|
2
2
|
import { PublicClient, RpcTransactionRequest, WalletClient } from 'viem';
|
|
3
3
|
import { Provider, ProviderEnum } from '@dynamic-labs/sdk-api';
|
|
4
4
|
import { Chain, IAccountAbstractionWalletConnector, WalletConnector, WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
|
|
@@ -14,9 +14,9 @@ type ZeroDevConnectorProps = {
|
|
|
14
14
|
};
|
|
15
15
|
export declare class ZeroDevConnector extends WalletConnectorBase implements IAccountAbstractionWalletConnector {
|
|
16
16
|
projectId: string;
|
|
17
|
-
|
|
17
|
+
kernelClient: KernelAccountClient | undefined;
|
|
18
18
|
eoaConnector: WalletConnector | undefined;
|
|
19
|
-
private
|
|
19
|
+
private kernelClientWithSponsorship;
|
|
20
20
|
connectedChain: Chain;
|
|
21
21
|
supportedChains: Chain[];
|
|
22
22
|
evmNetworks: EvmNetwork[];
|
|
@@ -27,21 +27,22 @@ export declare class ZeroDevConnector extends WalletConnectorBase implements IAc
|
|
|
27
27
|
* This is used to make sure that the provider is set before any other method is called.
|
|
28
28
|
* This is needed because the provider is set asynchronously.
|
|
29
29
|
*/
|
|
30
|
-
private
|
|
30
|
+
private kernelClientDeferredPromise;
|
|
31
31
|
name: string;
|
|
32
|
-
|
|
32
|
+
overrideKey: string;
|
|
33
33
|
private _walletUiUtils;
|
|
34
34
|
constructor(opts: ZeroDevConnectorProps);
|
|
35
35
|
getEOAConnector(): WalletConnector | undefined;
|
|
36
|
-
getAccountAbstractionProvider():
|
|
36
|
+
getAccountAbstractionProvider(): KernelAccountClient | undefined;
|
|
37
|
+
endSession(): Promise<void>;
|
|
37
38
|
setEoaConnector(connector: WalletConnector): Promise<void>;
|
|
38
39
|
private checkIsProjectChainEnabled;
|
|
39
|
-
private
|
|
40
|
-
|
|
40
|
+
private getKernelClientWithSponsorshipValidation;
|
|
41
|
+
getAddress(): Promise<string | undefined>;
|
|
41
42
|
getConnectedAccounts(): Promise<string[]>;
|
|
42
43
|
getNetwork(): Promise<number | undefined>;
|
|
43
44
|
private getTransport;
|
|
44
|
-
getWalletClient(): WalletClient | undefined;
|
|
45
|
+
getWalletClient(chainId?: string): WalletClient | undefined;
|
|
45
46
|
getPublicClient(): Promise<void | PublicClient | undefined>;
|
|
46
47
|
getSigner(): Promise<WalletClient | undefined>;
|
|
47
48
|
canSponsorTransactionGas(transaction: RpcTransactionRequest): Promise<boolean>;
|
package/src/ZeroDevConnector.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { __awaiter } from '../_virtual/_tslib.js';
|
|
2
|
-
import {
|
|
3
|
-
import { custom, createWalletClient, isHex, fromHex, formatEther } from 'viem';
|
|
2
|
+
import { createEcdsaKernelAccountClient } from '@zerodev/presets';
|
|
3
|
+
import { custom, createWalletClient, publicActions, isHex, fromHex, formatEther } from 'viem';
|
|
4
|
+
import { walletClientToSmartAccountSigner } from 'permissionless';
|
|
4
5
|
import { WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
|
|
5
|
-
import { confirmationTransport, unFormatTransaction } from '@dynamic-labs/viem-utils';
|
|
6
|
+
import { confirmationTransport, chainsMap, unFormatTransaction } from '@dynamic-labs/viem-utils';
|
|
6
7
|
import { parseEvmNetworks, DynamicError, DeferredPromise, wrapMethodWithCallback, TransactionGasCannotBeSponsoredError, InsufficientFundsError } from '@dynamic-labs/utils';
|
|
8
|
+
import { cachedChainIdKey, fetchChain } from './utils/fetchChain.js';
|
|
7
9
|
import { logger } from './utils/logger.js';
|
|
8
10
|
|
|
9
11
|
class ZeroDevConnector extends WalletConnectorBase {
|
|
10
|
-
get key() {
|
|
11
|
-
return 'zerodev';
|
|
12
|
-
}
|
|
13
12
|
constructor(opts) {
|
|
14
13
|
var _a;
|
|
15
14
|
super(opts);
|
|
@@ -18,6 +17,7 @@ class ZeroDevConnector extends WalletConnectorBase {
|
|
|
18
17
|
this.isGasSponsorshipDisabled = false;
|
|
19
18
|
this.isEmbeddedWallet = true;
|
|
20
19
|
this.name = 'ZeroDev';
|
|
20
|
+
this.overrideKey = 'zerodev';
|
|
21
21
|
const zeroDevProjectId = (_a = opts.apiProviders.zerodev) === null || _a === void 0 ? void 0 : _a.clientId;
|
|
22
22
|
if (!zeroDevProjectId) {
|
|
23
23
|
throw new Error('Missing ZeroDev project ID provided. Add your ZeroDev project id to your project configuration via the Dynamic Labs dashboard.');
|
|
@@ -30,28 +30,35 @@ class ZeroDevConnector extends WalletConnectorBase {
|
|
|
30
30
|
return this.eoaConnector;
|
|
31
31
|
}
|
|
32
32
|
getAccountAbstractionProvider() {
|
|
33
|
-
return this.
|
|
33
|
+
return this.kernelClient;
|
|
34
|
+
}
|
|
35
|
+
endSession() {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
localStorage.removeItem(cachedChainIdKey);
|
|
38
|
+
});
|
|
34
39
|
}
|
|
35
40
|
setEoaConnector(connector) {
|
|
36
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
this.
|
|
42
|
+
this.kernelClientDeferredPromise = new DeferredPromise();
|
|
38
43
|
this.eoaConnector = connector;
|
|
39
44
|
const signer = yield this.eoaConnector.getSigner();
|
|
40
|
-
if (!signer) {
|
|
45
|
+
if (!(signer === null || signer === void 0 ? void 0 : signer.account)) {
|
|
41
46
|
return;
|
|
42
47
|
}
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
const kernelClient = yield createEcdsaKernelAccountClient({
|
|
49
|
+
chain: yield fetchChain(this.projectId),
|
|
50
|
+
paymaster: 'NONE',
|
|
46
51
|
projectId: this.projectId,
|
|
52
|
+
provider: 'STACKUP',
|
|
53
|
+
signer: walletClientToSmartAccountSigner(signer),
|
|
47
54
|
});
|
|
48
|
-
wrapMethodWithCallback(
|
|
55
|
+
wrapMethodWithCallback(kernelClient, 'sendUserOperation', (original, ...args) => {
|
|
49
56
|
this._walletUiUtils.disabledConfirmationOnce();
|
|
50
57
|
return original(...args);
|
|
51
58
|
});
|
|
52
|
-
this.
|
|
59
|
+
this.kernelClient = kernelClient;
|
|
53
60
|
yield this.checkIsProjectChainEnabled();
|
|
54
|
-
this.
|
|
61
|
+
this.kernelClientDeferredPromise.resolve();
|
|
55
62
|
});
|
|
56
63
|
}
|
|
57
64
|
checkIsProjectChainEnabled() {
|
|
@@ -66,69 +73,67 @@ class ZeroDevConnector extends WalletConnectorBase {
|
|
|
66
73
|
}
|
|
67
74
|
});
|
|
68
75
|
}
|
|
69
|
-
|
|
76
|
+
getKernelClientWithSponsorshipValidation() {
|
|
70
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
if (this.
|
|
72
|
-
return this.
|
|
78
|
+
if (this.kernelClientWithSponsorship) {
|
|
79
|
+
return this.kernelClientWithSponsorship;
|
|
73
80
|
}
|
|
74
81
|
const { eoaConnector } = this;
|
|
75
82
|
if (!eoaConnector)
|
|
76
83
|
throw new DynamicError('No EOA connector');
|
|
77
84
|
const signer = yield eoaConnector.getSigner();
|
|
78
|
-
this.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
paymasterConfig: {
|
|
82
|
-
onlySendSponsoredTransaction: true,
|
|
83
|
-
policy: 'VERIFYING_PAYMASTER',
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
owner: convertWalletClientToAccountSigner(signer),
|
|
85
|
+
this.kernelClientWithSponsorship = yield createEcdsaKernelAccountClient({
|
|
86
|
+
chain: yield fetchChain(this.projectId),
|
|
87
|
+
paymaster: 'SPONSOR',
|
|
87
88
|
projectId: this.projectId,
|
|
89
|
+
provider: 'STACKUP',
|
|
90
|
+
signer: walletClientToSmartAccountSigner(signer),
|
|
88
91
|
});
|
|
89
|
-
wrapMethodWithCallback(this.
|
|
92
|
+
wrapMethodWithCallback(this.kernelClientWithSponsorship, 'sendUserOperation', (original, ...args) => {
|
|
90
93
|
this._walletUiUtils.disabledConfirmationOnce();
|
|
91
94
|
return original(...args);
|
|
92
95
|
});
|
|
93
|
-
return this.
|
|
96
|
+
return this.kernelClientWithSponsorship;
|
|
94
97
|
});
|
|
95
98
|
}
|
|
96
|
-
|
|
97
|
-
var _a, _b;
|
|
99
|
+
getAddress() {
|
|
100
|
+
var _a, _b, _c;
|
|
98
101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
-
yield ((_a = this.
|
|
100
|
-
return (_b = this.
|
|
102
|
+
yield ((_a = this.kernelClientDeferredPromise) === null || _a === void 0 ? void 0 : _a.promise);
|
|
103
|
+
return (_c = (_b = this.kernelClient) === null || _b === void 0 ? void 0 : _b.account) === null || _c === void 0 ? void 0 : _c.address;
|
|
101
104
|
});
|
|
102
105
|
}
|
|
103
106
|
getConnectedAccounts() {
|
|
104
|
-
var _a;
|
|
107
|
+
var _a, _b, _c;
|
|
105
108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
-
yield ((_a = this.
|
|
107
|
-
return this.
|
|
108
|
-
? [yield this.
|
|
109
|
+
yield ((_a = this.kernelClientDeferredPromise) === null || _a === void 0 ? void 0 : _a.promise);
|
|
110
|
+
return ((_c = (_b = this.kernelClient) === null || _b === void 0 ? void 0 : _b.account) === null || _c === void 0 ? void 0 : _c.address)
|
|
111
|
+
? [yield this.kernelClient.account.address]
|
|
109
112
|
: [];
|
|
110
113
|
});
|
|
111
114
|
}
|
|
112
115
|
getNetwork() {
|
|
113
|
-
var _a, _b;
|
|
116
|
+
var _a, _b, _c;
|
|
114
117
|
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
-
yield ((_a = this.
|
|
116
|
-
return (_b = this.
|
|
118
|
+
yield ((_a = this.kernelClientDeferredPromise) === null || _a === void 0 ? void 0 : _a.promise);
|
|
119
|
+
return (_c = (_b = this.kernelClient) === null || _b === void 0 ? void 0 : _b.chain) === null || _c === void 0 ? void 0 : _c.id;
|
|
117
120
|
});
|
|
118
121
|
}
|
|
119
122
|
getTransport(provider) {
|
|
120
123
|
const transport = confirmationTransport({
|
|
121
|
-
connector: this,
|
|
122
124
|
onPersonalSign: ({ message }) => __awaiter(this, void 0, void 0, function* () {
|
|
123
125
|
this._walletUiUtils.disabledConfirmationOnce();
|
|
124
|
-
return provider.signMessage(
|
|
126
|
+
return provider.signMessage({
|
|
127
|
+
account: provider.account,
|
|
128
|
+
message,
|
|
129
|
+
});
|
|
125
130
|
}),
|
|
126
131
|
onSendTransaction: ({ transaction }) => __awaiter(this, void 0, void 0, function* () {
|
|
127
132
|
try {
|
|
128
133
|
this._walletUiUtils.disabledConfirmationOnce();
|
|
129
134
|
const effectiveProvider = this.isGasSponsorshipDisabled
|
|
130
135
|
? provider
|
|
131
|
-
: yield this.
|
|
136
|
+
: yield this.getKernelClientWithSponsorshipValidation();
|
|
132
137
|
const response = yield effectiveProvider.sendTransaction(unFormatTransaction(transaction));
|
|
133
138
|
return response;
|
|
134
139
|
}
|
|
@@ -146,39 +151,48 @@ class ZeroDevConnector extends WalletConnectorBase {
|
|
|
146
151
|
onSignTypedData: ({ message }) => __awaiter(this, void 0, void 0, function* () {
|
|
147
152
|
this._walletUiUtils.disabledConfirmationOnce();
|
|
148
153
|
const signTypedData = JSON.parse(message);
|
|
149
|
-
return provider.signTypedData(
|
|
154
|
+
return provider.signTypedData({
|
|
155
|
+
account: provider.account,
|
|
156
|
+
message: signTypedData.message,
|
|
157
|
+
primaryType: signTypedData.primaryType,
|
|
158
|
+
types: signTypedData.types,
|
|
159
|
+
});
|
|
150
160
|
}),
|
|
151
|
-
provider
|
|
161
|
+
provider,
|
|
152
162
|
transport: custom(provider),
|
|
163
|
+
walletConnector: this,
|
|
153
164
|
walletUiUtils: this._walletUiUtils,
|
|
154
165
|
});
|
|
155
166
|
return transport;
|
|
156
167
|
}
|
|
157
|
-
getWalletClient() {
|
|
158
|
-
const provider = this.
|
|
168
|
+
getWalletClient(chainId) {
|
|
169
|
+
const provider = this.kernelClient;
|
|
159
170
|
if (!provider)
|
|
160
171
|
throw new DynamicError('No provider');
|
|
161
172
|
const transport = this.getTransport(provider);
|
|
162
173
|
const walletClient = createWalletClient({
|
|
174
|
+
account: provider.account,
|
|
175
|
+
chain: chainId ? chainsMap[chainId] : undefined,
|
|
163
176
|
transport,
|
|
164
177
|
});
|
|
165
178
|
return walletClient;
|
|
166
179
|
}
|
|
167
180
|
getPublicClient() {
|
|
168
181
|
return __awaiter(this, void 0, void 0, function* () {
|
|
169
|
-
const provider = this.
|
|
182
|
+
const provider = this.kernelClient.extend(publicActions);
|
|
170
183
|
if (!provider)
|
|
171
184
|
throw new DynamicError('No provider');
|
|
172
|
-
return provider
|
|
185
|
+
return provider;
|
|
173
186
|
});
|
|
174
187
|
}
|
|
175
188
|
getSigner() {
|
|
189
|
+
var _a;
|
|
176
190
|
return __awaiter(this, void 0, void 0, function* () {
|
|
177
|
-
const provider = this.
|
|
191
|
+
const provider = this.kernelClient;
|
|
178
192
|
if (!provider)
|
|
179
193
|
throw new DynamicError('No provider');
|
|
180
194
|
const transport = this.getTransport(provider);
|
|
181
|
-
const address =
|
|
195
|
+
const address = (_a = provider.account) === null || _a === void 0 ? void 0 : _a.address;
|
|
182
196
|
const walletClient = createWalletClient({
|
|
183
197
|
account: address,
|
|
184
198
|
transport,
|
|
@@ -187,17 +201,22 @@ class ZeroDevConnector extends WalletConnectorBase {
|
|
|
187
201
|
});
|
|
188
202
|
}
|
|
189
203
|
canSponsorTransactionGas(transaction) {
|
|
190
|
-
var _a;
|
|
191
204
|
return __awaiter(this, void 0, void 0, function* () {
|
|
192
205
|
try {
|
|
206
|
+
yield this.getKernelClientWithSponsorshipValidation();
|
|
193
207
|
const userOperation = {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
208
|
+
callData: yield this.kernelClientWithSponsorship.account.encodeCallData({
|
|
209
|
+
data: transaction.data ? transaction.data : '0x',
|
|
210
|
+
to: transaction.to,
|
|
211
|
+
value: isHex(transaction.value)
|
|
212
|
+
? fromHex(transaction.value, 'bigint')
|
|
213
|
+
: transaction.value,
|
|
214
|
+
}),
|
|
199
215
|
};
|
|
200
|
-
const result = yield
|
|
216
|
+
const result = yield this.kernelClientWithSponsorship.prepareUserOperationRequest({
|
|
217
|
+
account: this.kernelClientWithSponsorship.account,
|
|
218
|
+
userOperation,
|
|
219
|
+
});
|
|
201
220
|
if (!result)
|
|
202
221
|
return false;
|
|
203
222
|
return result.paymasterAndData !== '0x';
|
|
@@ -212,12 +231,11 @@ class ZeroDevConnector extends WalletConnectorBase {
|
|
|
212
231
|
this.isGasSponsorshipDisabled = true;
|
|
213
232
|
}
|
|
214
233
|
getBalance() {
|
|
215
|
-
var _a;
|
|
216
234
|
return __awaiter(this, void 0, void 0, function* () {
|
|
217
|
-
const rpcClient =
|
|
235
|
+
const rpcClient = this.kernelClient.extend(publicActions);
|
|
218
236
|
if (!rpcClient)
|
|
219
237
|
throw new DynamicError('No RPC client');
|
|
220
|
-
const address = yield this.
|
|
238
|
+
const address = yield this.getAddress();
|
|
221
239
|
if (!address)
|
|
222
240
|
return;
|
|
223
241
|
return formatEther(yield rpcClient.getBalance({ address: address }));
|
|
@@ -226,7 +244,7 @@ class ZeroDevConnector extends WalletConnectorBase {
|
|
|
226
244
|
signMessage(messageToSign) {
|
|
227
245
|
return __awaiter(this, void 0, void 0, function* () {
|
|
228
246
|
const client = yield this.getSigner();
|
|
229
|
-
const account = yield this.
|
|
247
|
+
const account = yield this.getAddress();
|
|
230
248
|
if (!account || !client)
|
|
231
249
|
return;
|
|
232
250
|
return client.signMessage({
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
6
|
+
var viemUtils = require('@dynamic-labs/viem-utils');
|
|
7
|
+
var logger = require('./logger.cjs');
|
|
8
|
+
|
|
9
|
+
const cachedChainIdKey = 'dynamic_zd_chain_id';
|
|
10
|
+
const fetchChain = (projectId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
11
|
+
try {
|
|
12
|
+
const cachedChainId = localStorage.getItem(cachedChainIdKey);
|
|
13
|
+
if (cachedChainId) {
|
|
14
|
+
return viemUtils.chainsMap[cachedChainId];
|
|
15
|
+
}
|
|
16
|
+
const response = yield (yield fetch(`https://prod-api.zerodev.app/projects/${projectId}`)).json();
|
|
17
|
+
localStorage.setItem(cachedChainIdKey, response.chainId);
|
|
18
|
+
return viemUtils.chainsMap[response.chainId];
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
logger.logger.error('Failed to fetch ZeroDev project settings from ZeroDev API ' +
|
|
22
|
+
'This is needed to fetch the chain id so that we know which chain the smart contract is on');
|
|
23
|
+
throw err;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
exports.cachedChainIdKey = cachedChainIdKey;
|
|
28
|
+
exports.fetchChain = fetchChain;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
2
|
+
import { chainsMap } from '@dynamic-labs/viem-utils';
|
|
3
|
+
import { logger } from './logger.js';
|
|
4
|
+
|
|
5
|
+
const cachedChainIdKey = 'dynamic_zd_chain_id';
|
|
6
|
+
const fetchChain = (projectId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
7
|
+
try {
|
|
8
|
+
const cachedChainId = localStorage.getItem(cachedChainIdKey);
|
|
9
|
+
if (cachedChainId) {
|
|
10
|
+
return chainsMap[cachedChainId];
|
|
11
|
+
}
|
|
12
|
+
const response = yield (yield fetch(`https://prod-api.zerodev.app/projects/${projectId}`)).json();
|
|
13
|
+
localStorage.setItem(cachedChainIdKey, response.chainId);
|
|
14
|
+
return chainsMap[response.chainId];
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
logger.error('Failed to fetch ZeroDev project settings from ZeroDev API ' +
|
|
18
|
+
'This is needed to fetch the chain id so that we know which chain the smart contract is on');
|
|
19
|
+
throw err;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export { cachedChainIdKey, fetchChain };
|