@dynamic-labs/ethereum-aa 2.0.0-alpha.0 → 2.0.0-alpha.10

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 CHANGED
@@ -1,4 +1,144 @@
1
1
 
2
+ ## [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)
3
+
4
+
5
+ ### ⚠ BREAKING CHANGES
6
+
7
+ * rename hideEmbeddedWalletUIs prop to hideEmbeddedWalletTra… (#4892)
8
+ * refactor send transaction for multi chain (#4831)
9
+
10
+ ### Features
11
+
12
+ * add sandbox indicator to sdk ([62fd821](https://github.com/dynamic-labs/DynamicAuth/commit/62fd821a895bb54cec4cae3d153aa0056a7e6638))
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * 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))
18
+ * fix server side rendering ([#4811](https://github.com/dynamic-labs/DynamicAuth/issues/4811)) ([063dfae](https://github.com/dynamic-labs/DynamicAuth/commit/063dfae8b6750875d2f35dd9709a1f675495f4fb))
19
+ * hide network ([#4885](https://github.com/dynamic-labs/DynamicAuth/issues/4885)) ([ec10c58](https://github.com/dynamic-labs/DynamicAuth/commit/ec10c588218f067e991d5830fc06ec081e4e1d18))
20
+ * network picker on mobile ([#4887](https://github.com/dynamic-labs/DynamicAuth/issues/4887)) ([6e0ab1b](https://github.com/dynamic-labs/DynamicAuth/commit/6e0ab1bc7d138b73373741960a501ff7cf20e3f9))
21
+
22
+
23
+ * refactor send transaction for multi chain ([#4831](https://github.com/dynamic-labs/DynamicAuth/issues/4831)) ([c98444b](https://github.com/dynamic-labs/DynamicAuth/commit/c98444be7935420dda3d8216d03946f5893eb82f))
24
+ * rename hideEmbeddedWalletUIs prop to hideEmbeddedWalletTra… ([#4892](https://github.com/dynamic-labs/DynamicAuth/issues/4892)) ([7cdf519](https://github.com/dynamic-labs/DynamicAuth/commit/7cdf5196b1cd8516de2d456163fe9071956d40d3))
25
+
26
+ ## [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)
27
+
28
+
29
+ ### Features
30
+
31
+ * solana connector new sendTransaction method ([#4842](https://github.com/dynamic-labs/DynamicAuth/issues/4842)) ([0b198e3](https://github.com/dynamic-labs/DynamicAuth/commit/0b198e30d83fbbc8d506654d87cbfad403fda289))
32
+ * 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))
33
+
34
+
35
+ ### Bug Fixes
36
+
37
+ * 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))
38
+ * update btckit network conversion for signPsbt ([a6009e1](https://github.com/dynamic-labs/DynamicAuth/commit/a6009e18c453b4e65545455fea0e52ed7a983b4d))
39
+ * 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))
40
+
41
+ ## [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)
42
+
43
+ ## [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)
44
+
45
+
46
+ ### ⚠ BREAKING CHANGES
47
+
48
+ * add networkValidationMode and remove enableForcedNetworkValidation (#4778)
49
+
50
+ ### Features
51
+
52
+ * add bitget and okx wallets ([51fab41](https://github.com/dynamic-labs/DynamicAuth/commit/51fab413096fd89ce99c6c617cf4f3f5db9bf44d))
53
+ * add networkValidationMode and remove enableForcedNetworkValidation ([#4778](https://github.com/dynamic-labs/DynamicAuth/issues/4778)) ([ccb9576](https://github.com/dynamic-labs/DynamicAuth/commit/ccb9576c81b2c570185f5126d6d1fcfcbb5ac9e3))
54
+
55
+
56
+ ### Bug Fixes
57
+
58
+ * **GVTY-1243:** non evm onramp urls ([#4791](https://github.com/dynamic-labs/DynamicAuth/issues/4791)) ([fea602e](https://github.com/dynamic-labs/DynamicAuth/commit/fea602e2835b4bb9bc096b96375fa97297bf35f1))
59
+ * 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))
60
+ * 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))
61
+
62
+ ## [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)
63
+
64
+
65
+ ### ⚠ BREAKING CHANGES
66
+
67
+ * setShowAuthFlow opens dynamic profile in non-multi-wallet states
68
+
69
+ ### Features
70
+
71
+ * 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))
72
+ * make sms mobile keyboard numeric ([#4755](https://github.com/dynamic-labs/DynamicAuth/issues/4755)) ([f36844a](https://github.com/dynamic-labs/DynamicAuth/commit/f36844aeaae240c520181b3242492db8ffc64a50))
73
+ * setShowAuthFlow opens dynamic profile in non-multi-wallet states ([42dbbc0](https://github.com/dynamic-labs/DynamicAuth/commit/42dbbc00a5cebe937dca5a80397cdd3c577f6a45))
74
+
75
+
76
+ ### Bug Fixes
77
+
78
+ * 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))
79
+ * 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))
80
+ * use enableForcedNetworkValidation on connect-only ([#4750](https://github.com/dynamic-labs/DynamicAuth/issues/4750)) ([6299f7c](https://github.com/dynamic-labs/DynamicAuth/commit/6299f7c3ce705ddb19714f6b7a3a488851ed8dde))
81
+
82
+ ## [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)
83
+
84
+
85
+ ### ⚠ BREAKING CHANGES
86
+
87
+ * wagmi v2 (#4660)
88
+
89
+ ### Features
90
+
91
+ * wagmi v2 ([#4660](https://github.com/dynamic-labs/DynamicAuth/issues/4660)) ([d8894e6](https://github.com/dynamic-labs/DynamicAuth/commit/d8894e61393b90ccf44904c33394b54286f0f9e9))
92
+
93
+ ## [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)
94
+
95
+
96
+ ### ⚠ BREAKING CHANGES
97
+
98
+ * remove wallet connector from callback types (#4730)
99
+ * drop support for walletconnect v1 (#4666)
100
+
101
+ ### Features
102
+
103
+ * add coin98 evm ([1d64f5f](https://github.com/dynamic-labs/DynamicAuth/commit/1d64f5f00885ff671358651fd0251b77a2e05739))
104
+ * add support for solana versioned transactions ([#4721](https://github.com/dynamic-labs/DynamicAuth/issues/4721)) ([25b1643](https://github.com/dynamic-labs/DynamicAuth/commit/25b1643f8addbada09fff5d22e988bdf22038170))
105
+
106
+
107
+ ### Bug Fixes
108
+
109
+ * 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))
110
+ * 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))
111
+ * improve on transaction confirmation step ([#4704](https://github.com/dynamic-labs/DynamicAuth/issues/4704)) ([f2b27cf](https://github.com/dynamic-labs/DynamicAuth/commit/f2b27cfd94452be2eb7e88a298f61ef56985931f))
112
+ * 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))
113
+ * 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))
114
+ * update sepolia currency symbol ([#4728](https://github.com/dynamic-labs/DynamicAuth/issues/4728)) ([3c228a0](https://github.com/dynamic-labs/DynamicAuth/commit/3c228a03ccc962374ad1dac3ab45af92732ba61a))
115
+ * 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))
116
+
117
+
118
+ * drop support for walletconnect v1 ([#4666](https://github.com/dynamic-labs/DynamicAuth/issues/4666)) ([4af93e4](https://github.com/dynamic-labs/DynamicAuth/commit/4af93e4f9b95fa4c49bbfda0c1144da1a4a43991))
119
+ * remove wallet connector from callback types ([#4730](https://github.com/dynamic-labs/DynamicAuth/issues/4730)) ([08cb200](https://github.com/dynamic-labs/DynamicAuth/commit/08cb200a09c0fd78d2093d1a60b17089b3b2c2b1))
120
+
121
+ ## [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)
122
+
123
+
124
+ ### Bug Fixes
125
+
126
+ * 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))
127
+
128
+ ## [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)
129
+
130
+
131
+ ### Bug Fixes
132
+
133
+ * old iconic dependency version ([#4673](https://github.com/dynamic-labs/DynamicAuth/issues/4673)) ([4a5c448](https://github.com/dynamic-labs/DynamicAuth/commit/4a5c448c251540139f84514328d5f1d31808d75c))
134
+
135
+ ## [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)
136
+
137
+
138
+ ### Bug Fixes
139
+
140
+ * fix make tabs style attribute optional ([#4667](https://github.com/dynamic-labs/DynamicAuth/issues/4667))
141
+
2
142
  ## [2.0.0-alpha.0](https://github.com/dynamic-labs/DynamicAuth/compare/v1.2.0-alpha.1...v2.0.0-alpha.0) (2024-02-12)
3
143
 
4
144
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/ethereum-aa",
3
- "version": "2.0.0-alpha.0",
3
+ "version": "2.0.0-alpha.10",
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
- "@zerodev/sdk": "^4.1.5",
30
- "@dynamic-labs/sdk-api": "0.0.363",
31
- "@dynamic-labs/logger": "2.0.0-alpha.0",
32
- "@dynamic-labs/types": "2.0.0-alpha.0",
33
- "@dynamic-labs/utils": "2.0.0-alpha.0",
34
- "@dynamic-labs/viem-utils": "2.0.0-alpha.0",
35
- "@dynamic-labs/wallet-book": "2.0.0-alpha.0",
36
- "@dynamic-labs/wallet-connector-core": "2.0.0-alpha.0"
29
+ "@dynamic-labs/sdk-api": "0.0.376",
30
+ "@dynamic-labs/logger": "2.0.0-alpha.10",
31
+ "@dynamic-labs/types": "2.0.0-alpha.10",
32
+ "@dynamic-labs/utils": "2.0.0-alpha.10",
33
+ "@dynamic-labs/viem-utils": "2.0.0-alpha.10",
34
+ "@dynamic-labs/wallet-book": "2.0.0-alpha.10",
35
+ "@dynamic-labs/wallet-connector-core": "2.0.0-alpha.10"
37
36
  },
38
37
  "peerDependencies": {
39
- "viem": "^1.19.13 || ^2.2.0"
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
  }
@@ -3,17 +3,16 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _tslib = require('../_virtual/_tslib.cjs');
6
- var sdk = require('@zerodev/sdk');
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.zeroDevProvider;
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.zeroDevProviderDeferredPromise = new utils.DeferredPromise();
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 zeroDevProvider = yield sdk.ECDSAProvider.init({
48
- bundlerProvider: 'STACKUP',
49
- owner: sdk.convertWalletClientToAccountSigner(signer),
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(zeroDevProvider, 'sendUserOperation', (original, ...args) => {
59
+ utils.wrapMethodWithCallback(kernelClient, 'sendUserOperation', (original, ...args) => {
53
60
  this._walletUiUtils.disabledConfirmationOnce();
54
61
  return original(...args);
55
62
  });
56
- this.zeroDevProvider = zeroDevProvider;
63
+ this.kernelClient = kernelClient;
57
64
  yield this.checkIsProjectChainEnabled();
58
- this.zeroDevProviderDeferredPromise.resolve();
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
- getProviderWithSponsorshipValidation() {
80
+ getKernelClientWithSponsorshipValidation() {
74
81
  return _tslib.__awaiter(this, void 0, void 0, function* () {
75
- if (this.providerWithSponsorship) {
76
- return this.providerWithSponsorship;
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.providerWithSponsorship = yield sdk.ECDSAProvider.init({
83
- bundlerProvider: 'STACKUP',
84
- opts: {
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.providerWithSponsorship, 'sendUserOperation', (original, ...args) => {
96
+ utils.wrapMethodWithCallback(this.kernelClientWithSponsorship, 'sendUserOperation', (original, ...args) => {
94
97
  this._walletUiUtils.disabledConfirmationOnce();
95
98
  return original(...args);
96
99
  });
97
- return this.providerWithSponsorship;
100
+ return this.kernelClientWithSponsorship;
98
101
  });
99
102
  }
100
103
  fetchPublicAddress() {
101
- var _a, _b;
104
+ var _a, _b, _c;
102
105
  return _tslib.__awaiter(this, void 0, void 0, function* () {
103
- yield ((_a = this.zeroDevProviderDeferredPromise) === null || _a === void 0 ? void 0 : _a.promise);
104
- return (_b = this.zeroDevProvider) === null || _b === void 0 ? void 0 : _b.getAddress();
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.zeroDevProviderDeferredPromise) === null || _a === void 0 ? void 0 : _a.promise);
111
- return this.zeroDevProvider
112
- ? [yield this.zeroDevProvider.getAddress()]
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.zeroDevProviderDeferredPromise) === null || _a === void 0 ? void 0 : _a.promise);
120
- return (_b = this.zeroDevProvider) === null || _b === void 0 ? void 0 : _b.rpcClient.chain.id;
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(message);
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.getProviderWithSponsorshipValidation();
140
+ : yield this.getKernelClientWithSponsorshipValidation();
136
141
  const response = yield effectiveProvider.sendTransaction(viemUtils.unFormatTransaction(transaction));
137
142
  return response;
138
143
  }
@@ -150,16 +155,22 @@ 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(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: provider.rpcClient,
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
172
  getWalletClient() {
162
- const provider = this.zeroDevProvider;
173
+ const provider = this.kernelClient;
163
174
  if (!provider)
164
175
  throw new utils.DynamicError('No provider');
165
176
  const transport = this.getTransport(provider);
@@ -170,19 +181,20 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
170
181
  }
171
182
  getPublicClient() {
172
183
  return _tslib.__awaiter(this, void 0, void 0, function* () {
173
- const provider = this.zeroDevProvider;
184
+ const provider = this.kernelClient.extend(viem.publicActions);
174
185
  if (!provider)
175
186
  throw new utils.DynamicError('No provider');
176
- return provider.rpcClient;
187
+ return provider;
177
188
  });
178
189
  }
179
190
  getSigner() {
191
+ var _a;
180
192
  return _tslib.__awaiter(this, void 0, void 0, function* () {
181
- const provider = this.zeroDevProvider;
193
+ const provider = this.kernelClient;
182
194
  if (!provider)
183
195
  throw new utils.DynamicError('No provider');
184
196
  const transport = this.getTransport(provider);
185
- const address = yield provider.getAddress();
197
+ const address = (_a = provider.account) === null || _a === void 0 ? void 0 : _a.address;
186
198
  const walletClient = viem.createWalletClient({
187
199
  account: address,
188
200
  transport,
@@ -191,17 +203,22 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
191
203
  });
192
204
  }
193
205
  canSponsorTransactionGas(transaction) {
194
- var _a;
195
206
  return _tslib.__awaiter(this, void 0, void 0, function* () {
196
207
  try {
208
+ yield this.getKernelClientWithSponsorshipValidation();
197
209
  const userOperation = {
198
- data: transaction.data ? transaction.data : '0x',
199
- target: transaction.to,
200
- value: viem.isHex(transaction.value)
201
- ? viem.fromHex(transaction.value, 'bigint')
202
- : transaction.value,
210
+ callData: yield this.kernelClientWithSponsorship.account.encodeCallData({
211
+ data: transaction.data ? transaction.data : '0x',
212
+ to: transaction.to,
213
+ value: viem.isHex(transaction.value)
214
+ ? viem.fromHex(transaction.value, 'bigint')
215
+ : transaction.value,
216
+ }),
203
217
  };
204
- const result = yield ((_a = this.zeroDevProvider) === null || _a === void 0 ? void 0 : _a.buildUserOperation(userOperation));
218
+ const result = yield this.kernelClientWithSponsorship.prepareUserOperationRequest({
219
+ account: this.kernelClientWithSponsorship.account,
220
+ userOperation,
221
+ });
205
222
  if (!result)
206
223
  return false;
207
224
  return result.paymasterAndData !== '0x';
@@ -216,9 +233,8 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
216
233
  this.isGasSponsorshipDisabled = true;
217
234
  }
218
235
  getBalance() {
219
- var _a;
220
236
  return _tslib.__awaiter(this, void 0, void 0, function* () {
221
- const rpcClient = yield ((_a = this.zeroDevProvider) === null || _a === void 0 ? void 0 : _a.rpcClient);
237
+ const rpcClient = this.kernelClient.extend(viem.publicActions);
222
238
  if (!rpcClient)
223
239
  throw new utils.DynamicError('No RPC client');
224
240
  const address = yield this.fetchPublicAddress();
@@ -1,4 +1,4 @@
1
- import { ECDSAProvider } from '@zerodev/sdk';
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
- zeroDevProvider: ECDSAProvider | undefined;
17
+ kernelClient: KernelAccountClient | undefined;
18
18
  eoaConnector: WalletConnector | undefined;
19
- private providerWithSponsorship;
19
+ private kernelClientWithSponsorship;
20
20
  connectedChain: Chain;
21
21
  supportedChains: Chain[];
22
22
  evmNetworks: EvmNetwork[];
@@ -27,16 +27,17 @@ 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 zeroDevProviderDeferredPromise;
30
+ private kernelClientDeferredPromise;
31
31
  name: string;
32
- get key(): string;
32
+ overrideKey: string;
33
33
  private _walletUiUtils;
34
34
  constructor(opts: ZeroDevConnectorProps);
35
35
  getEOAConnector(): WalletConnector | undefined;
36
- getAccountAbstractionProvider(): ECDSAProvider | undefined;
36
+ getAccountAbstractionProvider(): KernelAccountClient | undefined;
37
+ endSession(): Promise<void>;
37
38
  setEoaConnector(connector: WalletConnector): Promise<void>;
38
39
  private checkIsProjectChainEnabled;
39
- private getProviderWithSponsorshipValidation;
40
+ private getKernelClientWithSponsorshipValidation;
40
41
  fetchPublicAddress(): Promise<string | undefined>;
41
42
  getConnectedAccounts(): Promise<string[]>;
42
43
  getNetwork(): Promise<number | undefined>;
@@ -1,15 +1,14 @@
1
1
  import { __awaiter } from '../_virtual/_tslib.js';
2
- import { ECDSAProvider, convertWalletClientToAccountSigner } from '@zerodev/sdk';
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
6
  import { confirmationTransport, 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.zeroDevProvider;
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.zeroDevProviderDeferredPromise = new DeferredPromise();
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 zeroDevProvider = yield ECDSAProvider.init({
44
- bundlerProvider: 'STACKUP',
45
- owner: convertWalletClientToAccountSigner(signer),
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(zeroDevProvider, 'sendUserOperation', (original, ...args) => {
55
+ wrapMethodWithCallback(kernelClient, 'sendUserOperation', (original, ...args) => {
49
56
  this._walletUiUtils.disabledConfirmationOnce();
50
57
  return original(...args);
51
58
  });
52
- this.zeroDevProvider = zeroDevProvider;
59
+ this.kernelClient = kernelClient;
53
60
  yield this.checkIsProjectChainEnabled();
54
- this.zeroDevProviderDeferredPromise.resolve();
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
- getProviderWithSponsorshipValidation() {
76
+ getKernelClientWithSponsorshipValidation() {
70
77
  return __awaiter(this, void 0, void 0, function* () {
71
- if (this.providerWithSponsorship) {
72
- return this.providerWithSponsorship;
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.providerWithSponsorship = yield ECDSAProvider.init({
79
- bundlerProvider: 'STACKUP',
80
- opts: {
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.providerWithSponsorship, 'sendUserOperation', (original, ...args) => {
92
+ wrapMethodWithCallback(this.kernelClientWithSponsorship, 'sendUserOperation', (original, ...args) => {
90
93
  this._walletUiUtils.disabledConfirmationOnce();
91
94
  return original(...args);
92
95
  });
93
- return this.providerWithSponsorship;
96
+ return this.kernelClientWithSponsorship;
94
97
  });
95
98
  }
96
99
  fetchPublicAddress() {
97
- var _a, _b;
100
+ var _a, _b, _c;
98
101
  return __awaiter(this, void 0, void 0, function* () {
99
- yield ((_a = this.zeroDevProviderDeferredPromise) === null || _a === void 0 ? void 0 : _a.promise);
100
- return (_b = this.zeroDevProvider) === null || _b === void 0 ? void 0 : _b.getAddress();
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.zeroDevProviderDeferredPromise) === null || _a === void 0 ? void 0 : _a.promise);
107
- return this.zeroDevProvider
108
- ? [yield this.zeroDevProvider.getAddress()]
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.zeroDevProviderDeferredPromise) === null || _a === void 0 ? void 0 : _a.promise);
116
- return (_b = this.zeroDevProvider) === null || _b === void 0 ? void 0 : _b.rpcClient.chain.id;
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(message);
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.getProviderWithSponsorshipValidation();
136
+ : yield this.getKernelClientWithSponsorshipValidation();
132
137
  const response = yield effectiveProvider.sendTransaction(unFormatTransaction(transaction));
133
138
  return response;
134
139
  }
@@ -146,16 +151,22 @@ 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(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: provider.rpcClient,
161
+ provider,
152
162
  transport: custom(provider),
163
+ walletConnector: this,
153
164
  walletUiUtils: this._walletUiUtils,
154
165
  });
155
166
  return transport;
156
167
  }
157
168
  getWalletClient() {
158
- const provider = this.zeroDevProvider;
169
+ const provider = this.kernelClient;
159
170
  if (!provider)
160
171
  throw new DynamicError('No provider');
161
172
  const transport = this.getTransport(provider);
@@ -166,19 +177,20 @@ class ZeroDevConnector extends WalletConnectorBase {
166
177
  }
167
178
  getPublicClient() {
168
179
  return __awaiter(this, void 0, void 0, function* () {
169
- const provider = this.zeroDevProvider;
180
+ const provider = this.kernelClient.extend(publicActions);
170
181
  if (!provider)
171
182
  throw new DynamicError('No provider');
172
- return provider.rpcClient;
183
+ return provider;
173
184
  });
174
185
  }
175
186
  getSigner() {
187
+ var _a;
176
188
  return __awaiter(this, void 0, void 0, function* () {
177
- const provider = this.zeroDevProvider;
189
+ const provider = this.kernelClient;
178
190
  if (!provider)
179
191
  throw new DynamicError('No provider');
180
192
  const transport = this.getTransport(provider);
181
- const address = yield provider.getAddress();
193
+ const address = (_a = provider.account) === null || _a === void 0 ? void 0 : _a.address;
182
194
  const walletClient = createWalletClient({
183
195
  account: address,
184
196
  transport,
@@ -187,17 +199,22 @@ class ZeroDevConnector extends WalletConnectorBase {
187
199
  });
188
200
  }
189
201
  canSponsorTransactionGas(transaction) {
190
- var _a;
191
202
  return __awaiter(this, void 0, void 0, function* () {
192
203
  try {
204
+ yield this.getKernelClientWithSponsorshipValidation();
193
205
  const userOperation = {
194
- data: transaction.data ? transaction.data : '0x',
195
- target: transaction.to,
196
- value: isHex(transaction.value)
197
- ? fromHex(transaction.value, 'bigint')
198
- : transaction.value,
206
+ callData: yield this.kernelClientWithSponsorship.account.encodeCallData({
207
+ data: transaction.data ? transaction.data : '0x',
208
+ to: transaction.to,
209
+ value: isHex(transaction.value)
210
+ ? fromHex(transaction.value, 'bigint')
211
+ : transaction.value,
212
+ }),
199
213
  };
200
- const result = yield ((_a = this.zeroDevProvider) === null || _a === void 0 ? void 0 : _a.buildUserOperation(userOperation));
214
+ const result = yield this.kernelClientWithSponsorship.prepareUserOperationRequest({
215
+ account: this.kernelClientWithSponsorship.account,
216
+ userOperation,
217
+ });
201
218
  if (!result)
202
219
  return false;
203
220
  return result.paymasterAndData !== '0x';
@@ -212,9 +229,8 @@ class ZeroDevConnector extends WalletConnectorBase {
212
229
  this.isGasSponsorshipDisabled = true;
213
230
  }
214
231
  getBalance() {
215
- var _a;
216
232
  return __awaiter(this, void 0, void 0, function* () {
217
- const rpcClient = yield ((_a = this.zeroDevProvider) === null || _a === void 0 ? void 0 : _a.rpcClient);
233
+ const rpcClient = this.kernelClient.extend(publicActions);
218
234
  if (!rpcClient)
219
235
  throw new DynamicError('No RPC client');
220
236
  const address = yield this.fetchPublicAddress();
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _tslib = require('../../_virtual/_tslib.cjs');
6
+ var chains = require('viem/chains');
7
+ var logger = require('./logger.cjs');
8
+
9
+ function _interopNamespace(e) {
10
+ if (e && e.__esModule) return e;
11
+ var n = Object.create(null);
12
+ if (e) {
13
+ Object.keys(e).forEach(function (k) {
14
+ if (k !== 'default') {
15
+ var d = Object.getOwnPropertyDescriptor(e, k);
16
+ Object.defineProperty(n, k, d.get ? d : {
17
+ enumerable: true,
18
+ get: function () { return e[k]; }
19
+ });
20
+ }
21
+ });
22
+ }
23
+ n["default"] = e;
24
+ return Object.freeze(n);
25
+ }
26
+
27
+ var chains__namespace = /*#__PURE__*/_interopNamespace(chains);
28
+
29
+ const chainsMap = Object.values(chains__namespace).reduce((acc, chain) => (Object.assign(Object.assign({}, acc), { [chain.id]: chain })), {});
30
+ const cachedChainIdKey = 'dynamic_zd_chain_id';
31
+ const fetchChain = (projectId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
32
+ try {
33
+ const cachedChainId = localStorage.getItem(cachedChainIdKey);
34
+ if (cachedChainId) {
35
+ return chainsMap[cachedChainId];
36
+ }
37
+ const response = yield (yield fetch(`https://prod-api.zerodev.app/projects/${projectId}`)).json();
38
+ localStorage.setItem(cachedChainIdKey, response.chainId);
39
+ return chainsMap[response.chainId];
40
+ }
41
+ catch (err) {
42
+ logger.logger.error('Failed to fetch ZeroDev project settings from ZeroDev API ' +
43
+ 'This is needed to fetch the chain id so that we know which chain the smart contract is on');
44
+ throw err;
45
+ }
46
+ });
47
+
48
+ exports.cachedChainIdKey = cachedChainIdKey;
49
+ exports.fetchChain = fetchChain;
@@ -0,0 +1,3 @@
1
+ import { type Chain } from 'viem/chains';
2
+ export declare const cachedChainIdKey = "dynamic_zd_chain_id";
3
+ export declare const fetchChain: (projectId: string) => Promise<Chain>;
@@ -0,0 +1,24 @@
1
+ import { __awaiter } from '../../_virtual/_tslib.js';
2
+ import * as chains from 'viem/chains';
3
+ import { logger } from './logger.js';
4
+
5
+ const chainsMap = Object.values(chains).reduce((acc, chain) => (Object.assign(Object.assign({}, acc), { [chain.id]: chain })), {});
6
+ const cachedChainIdKey = 'dynamic_zd_chain_id';
7
+ const fetchChain = (projectId) => __awaiter(void 0, void 0, void 0, function* () {
8
+ try {
9
+ const cachedChainId = localStorage.getItem(cachedChainIdKey);
10
+ if (cachedChainId) {
11
+ return chainsMap[cachedChainId];
12
+ }
13
+ const response = yield (yield fetch(`https://prod-api.zerodev.app/projects/${projectId}`)).json();
14
+ localStorage.setItem(cachedChainIdKey, response.chainId);
15
+ return chainsMap[response.chainId];
16
+ }
17
+ catch (err) {
18
+ logger.error('Failed to fetch ZeroDev project settings from ZeroDev API ' +
19
+ 'This is needed to fetch the chain id so that we know which chain the smart contract is on');
20
+ throw err;
21
+ }
22
+ });
23
+
24
+ export { cachedChainIdKey, fetchChain };
@@ -0,0 +1,3 @@
1
+ export * from './fetchChain';
2
+ export * from './logger';
3
+ export * from './isZeroDevConnector';