@web3auth/no-modal 10.0.0-beta.7 → 10.0.0-beta.9
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/dist/lib.cjs/connectors/metamask-connector/metamaskConnector.js +11 -4
- package/dist/lib.cjs/index.js +1 -2
- package/dist/lib.cjs/noModal.js +30 -10
- package/dist/lib.cjs/providers/account-abstraction-provider/index.js +1 -0
- package/dist/lib.cjs/providers/account-abstraction-provider/providers/AccountAbstractionProvider.js +12 -1
- package/dist/lib.cjs/providers/account-abstraction-provider/rpc/ethRpcMiddlewares.js +25 -3
- package/dist/lib.cjs/react/solana/hooks/useSolanaWallet.js +5 -1
- package/dist/lib.cjs/react/wagmi/provider.js +3 -4
- package/dist/lib.cjs/types/noModal.d.ts +4 -1
- package/dist/lib.cjs/types/providers/account-abstraction-provider/providers/AccountAbstractionProvider.d.ts +2 -1
- package/dist/lib.cjs/types/providers/account-abstraction-provider/rpc/ethRpcMiddlewares.d.ts +4 -1
- package/dist/lib.cjs/types/providers/index.d.ts +0 -1
- package/dist/lib.cjs/types/react/wagmi/provider.d.ts +1 -2
- package/dist/lib.cjs/vue/solana/composables/useSolanaWallet.js +7 -4
- package/dist/lib.cjs/vue/wagmi/provider.js +1 -1
- package/dist/lib.esm/connectors/metamask-connector/metamaskConnector.js +11 -4
- package/dist/lib.esm/index.js +1 -2
- package/dist/lib.esm/noModal.js +31 -10
- package/dist/lib.esm/providers/account-abstraction-provider/index.js +1 -1
- package/dist/lib.esm/providers/account-abstraction-provider/providers/AccountAbstractionProvider.js +14 -4
- package/dist/lib.esm/providers/account-abstraction-provider/rpc/ethRpcMiddlewares.js +24 -3
- package/dist/lib.esm/react/solana/hooks/useSolanaWallet.js +5 -0
- package/dist/lib.esm/react/wagmi/provider.js +4 -5
- package/dist/lib.esm/vue/solana/composables/useSolanaWallet.js +7 -3
- package/dist/lib.esm/vue/wagmi/provider.js +2 -2
- package/dist/noModal.umd.min.js +1 -1
- package/package.json +17 -29
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
3
4
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
5
|
var sdk = require('@metamask/sdk');
|
|
5
6
|
var deepmerge = require('deepmerge');
|
|
@@ -41,6 +42,7 @@ class MetaMaskConnector extends baseEvmConnector.BaseEvmConnector {
|
|
|
41
42
|
throw new Error("Not implemented");
|
|
42
43
|
}
|
|
43
44
|
async init(options) {
|
|
45
|
+
var _metamaskOptions$useD;
|
|
44
46
|
await super.init(options);
|
|
45
47
|
const chainConfig = this.coreOptions.chains.find(x => x.chainId === options.chainId);
|
|
46
48
|
super.checkInitializationRequirements({
|
|
@@ -48,16 +50,20 @@ class MetaMaskConnector extends baseEvmConnector.BaseEvmConnector {
|
|
|
48
50
|
});
|
|
49
51
|
// Detect app metadata
|
|
50
52
|
const iconUrl = await utils.getSiteIcon(window);
|
|
53
|
+
// TODO: handle ssr
|
|
51
54
|
const appMetadata = {
|
|
52
|
-
name: utils.getSiteName(window),
|
|
53
|
-
url: window.location.origin,
|
|
55
|
+
name: utils.getSiteName(window) || "web3auth",
|
|
56
|
+
url: window.location.origin || "https://web3auth.io",
|
|
54
57
|
iconUrl
|
|
55
58
|
};
|
|
56
59
|
// initialize the MetaMask SDK
|
|
57
60
|
const metamaskOptions = deepmerge(this.metamaskOptions || {}, {
|
|
58
61
|
dappMetadata: appMetadata
|
|
59
62
|
});
|
|
60
|
-
this.metamaskSDK = new sdk.MetaMaskSDK(metamaskOptions)
|
|
63
|
+
this.metamaskSDK = new sdk.MetaMaskSDK(_objectSpread(_objectSpread({}, metamaskOptions), {}, {
|
|
64
|
+
_source: "web3auth",
|
|
65
|
+
useDeeplink: (_metamaskOptions$useD = metamaskOptions.useDeeplink) !== null && _metamaskOptions$useD !== void 0 ? _metamaskOptions$useD : true
|
|
66
|
+
}));
|
|
61
67
|
// Work around: in case there is an existing SDK instance in memory (window.mmsdk exists), it won't initialize the new SDK instance again
|
|
62
68
|
// and return the existing instance instead of undefined (this is an assumption, not sure if it's a bug or feature of the MetaMask SDK)
|
|
63
69
|
const initResult = await this.metamaskSDK.init();
|
|
@@ -87,11 +93,12 @@ class MetaMaskConnector extends baseEvmConnector.BaseEvmConnector {
|
|
|
87
93
|
if (!chainConfig) throw index$1.WalletLoginError.connectionError("Chain config is not available");
|
|
88
94
|
try {
|
|
89
95
|
if (this.status !== constants.CONNECTOR_STATUS.CONNECTING) {
|
|
96
|
+
var _this$metamaskOptions;
|
|
90
97
|
this.status = constants.CONNECTOR_STATUS.CONNECTING;
|
|
91
98
|
this.emit(constants.CONNECTOR_EVENTS.CONNECTING, {
|
|
92
99
|
connector: index.WALLET_CONNECTORS.METAMASK
|
|
93
100
|
});
|
|
94
|
-
if (!this.metamaskSDK.isExtensionActive() && this.metamaskOptions.headless) {
|
|
101
|
+
if (!this.metamaskSDK.isExtensionActive() && (_this$metamaskOptions = this.metamaskOptions) !== null && _this$metamaskOptions !== void 0 && _this$metamaskOptions.headless) {
|
|
95
102
|
// when metamask is not injected and headless is true, broadcast the uri to the login modal
|
|
96
103
|
this.metamaskSDK.getProvider().on("display_uri", uri => {
|
|
97
104
|
this.updateConnectorData({
|
package/dist/lib.cjs/index.js
CHANGED
|
@@ -34,7 +34,6 @@ var baseProvider = require('./providers/base-provider/baseProvider.js');
|
|
|
34
34
|
var CommonJRPCProvider = require('./providers/base-provider/CommonJRPCProvider.js');
|
|
35
35
|
var commonPrivateKeyProvider = require('./providers/base-provider/commonPrivateKeyProvider.js');
|
|
36
36
|
var utils$2 = require('./providers/base-provider/utils.js');
|
|
37
|
-
var EthereumSigningProvider = require('./providers/ethereum-mpc-provider/providers/signingProviders/EthereumSigningProvider.js');
|
|
38
37
|
var constants$2 = require('./providers/ethereum-provider/providers/privateKeyProviders/TransactionFormatter/constants.js');
|
|
39
38
|
var formatter = require('./providers/ethereum-provider/providers/privateKeyProviders/TransactionFormatter/formatter.js');
|
|
40
39
|
var interfaces = require('./providers/ethereum-provider/providers/privateKeyProviders/TransactionFormatter/interfaces.js');
|
|
@@ -159,6 +158,7 @@ exports.NFTCheckoutEmbed = embed.NFTCheckoutEmbed;
|
|
|
159
158
|
exports.nftCheckoutPlugin = plugin.nftCheckoutPlugin;
|
|
160
159
|
exports.walletServicesPlugin = plugin$1.walletServicesPlugin;
|
|
161
160
|
exports.accountAbstractionProvider = AccountAbstractionProvider.accountAbstractionProvider;
|
|
161
|
+
exports.toEoaProvider = AccountAbstractionProvider.toEoaProvider;
|
|
162
162
|
Object.defineProperty(exports, "BiconomySmartAccount", {
|
|
163
163
|
enumerable: true,
|
|
164
164
|
get: function () { return ethereumControllers.BiconomySmartAccount; }
|
|
@@ -195,7 +195,6 @@ Object.defineProperty(exports, "EIP1193_EVENTS", {
|
|
|
195
195
|
get: function () { return utils$2.EIP1193_EVENTS; }
|
|
196
196
|
});
|
|
197
197
|
exports.createRandomId = utils$2.createRandomId;
|
|
198
|
-
exports.EthereumSigningProvider = EthereumSigningProvider.EthereumSigningProvider;
|
|
199
198
|
exports.EIP1559APIEndpoint = constants$2.EIP1559APIEndpoint;
|
|
200
199
|
exports.GAS_ESTIMATE_TYPES = constants$2.GAS_ESTIMATE_TYPES;
|
|
201
200
|
exports.LegacyGasAPIEndpoint = constants$2.LegacyGasAPIEndpoint;
|
package/dist/lib.cjs/noModal.js
CHANGED
|
@@ -33,6 +33,7 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
|
|
|
33
33
|
_defineProperty(this, "connectedConnectorName", null);
|
|
34
34
|
_defineProperty(this, "status", constants.CONNECTOR_STATUS.NOT_READY);
|
|
35
35
|
_defineProperty(this, "cachedConnector", null);
|
|
36
|
+
_defineProperty(this, "aaProvider", null);
|
|
36
37
|
_defineProperty(this, "currentChainId", void 0);
|
|
37
38
|
_defineProperty(this, "connectors", []);
|
|
38
39
|
_defineProperty(this, "commonJRPCProvider", null);
|
|
@@ -61,6 +62,9 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
|
|
|
61
62
|
var _this$currentChain;
|
|
62
63
|
return this.getConnector(this.connectedConnectorName, (_this$currentChain = this.currentChain) === null || _this$currentChain === void 0 ? void 0 : _this$currentChain.chainNamespace);
|
|
63
64
|
}
|
|
65
|
+
get accountAbstractionProvider() {
|
|
66
|
+
return this.aaProvider;
|
|
67
|
+
}
|
|
64
68
|
set provider(_) {
|
|
65
69
|
throw new Error("Not implemented");
|
|
66
70
|
}
|
|
@@ -274,15 +278,24 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
|
|
|
274
278
|
}
|
|
275
279
|
}
|
|
276
280
|
initAccountAbstractionConfig(projectConfig) {
|
|
281
|
+
var _this$coreOptions$acc2;
|
|
277
282
|
const isAAEnabled = Boolean(this.coreOptions.accountAbstractionConfig || (projectConfig === null || projectConfig === void 0 ? void 0 : projectConfig.smartAccounts));
|
|
278
283
|
if (!isAAEnabled) return;
|
|
279
|
-
// merge project config with core options,
|
|
284
|
+
// merge smart account config from project config with core options, core options will take precedence over project config
|
|
280
285
|
const _ref = (projectConfig === null || projectConfig === void 0 ? void 0 : projectConfig.smartAccounts) || {},
|
|
281
286
|
{
|
|
282
287
|
walletScope
|
|
283
288
|
} = _ref,
|
|
284
289
|
configWithoutWalletScope = _objectWithoutProperties(_ref, _excluded);
|
|
285
|
-
|
|
290
|
+
const aaChainMap = new Map();
|
|
291
|
+
const allAaChains = [...((configWithoutWalletScope === null || configWithoutWalletScope === void 0 ? void 0 : configWithoutWalletScope.chains) || []), ...(((_this$coreOptions$acc2 = this.coreOptions.accountAbstractionConfig) === null || _this$coreOptions$acc2 === void 0 ? void 0 : _this$coreOptions$acc2.chains) || [])];
|
|
292
|
+
for (const chain of allAaChains) {
|
|
293
|
+
const existingChain = aaChainMap.get(chain.chainId);
|
|
294
|
+
if (!existingChain) aaChainMap.set(chain.chainId, chain);else aaChainMap.set(chain.chainId, _objectSpread(_objectSpread({}, existingChain), chain));
|
|
295
|
+
}
|
|
296
|
+
this.coreOptions.accountAbstractionConfig = _objectSpread(_objectSpread({}, deepmerge(configWithoutWalletScope || {}, this.coreOptions.accountAbstractionConfig || {})), {}, {
|
|
297
|
+
chains: Array.from(aaChainMap.values())
|
|
298
|
+
});
|
|
286
299
|
// determine if we should use AA with external wallet
|
|
287
300
|
if (this.coreOptions.useAAWithExternalWallet === undefined) {
|
|
288
301
|
this.coreOptions.useAAWithExternalWallet = walletScope === constants$1.SMART_ACCOUNT_WALLET_SCOPE.ALL;
|
|
@@ -417,28 +430,35 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
|
|
|
417
430
|
provider
|
|
418
431
|
} = data;
|
|
419
432
|
let finalProvider = provider.provider || provider;
|
|
420
|
-
// setup AA provider
|
|
433
|
+
// setup AA provider if AA is enabled
|
|
421
434
|
const {
|
|
422
435
|
accountAbstractionConfig
|
|
423
436
|
} = this.coreOptions;
|
|
424
|
-
const
|
|
437
|
+
const isAaSupportedForCurrentChain = ((_this$currentChain3 = this.currentChain) === null || _this$currentChain3 === void 0 ? void 0 : _this$currentChain3.chainNamespace) === baseControllers.CHAIN_NAMESPACES.EIP155 && (accountAbstractionConfig === null || accountAbstractionConfig === void 0 || (_accountAbstractionCo = accountAbstractionConfig.chains) === null || _accountAbstractionCo === void 0 ? void 0 : _accountAbstractionCo.some(chain => {
|
|
425
438
|
var _this$currentChain4;
|
|
426
439
|
return chain.chainId === ((_this$currentChain4 = this.currentChain) === null || _this$currentChain4 === void 0 ? void 0 : _this$currentChain4.chainId);
|
|
427
440
|
}));
|
|
428
|
-
|
|
429
|
-
if (isExternalWalletAndAAEnabled && doesAASupportCurrentChain) {
|
|
441
|
+
if (isAaSupportedForCurrentChain && (data.connector === index$1.WALLET_CONNECTORS.AUTH || this.coreOptions.useAAWithExternalWallet)) {
|
|
430
442
|
var _accountAbstractionCo2;
|
|
431
|
-
const aaChainIds = new Set((accountAbstractionConfig === null || accountAbstractionConfig === void 0 || (_accountAbstractionCo2 = accountAbstractionConfig.chains) === null || _accountAbstractionCo2 === void 0 ? void 0 : _accountAbstractionCo2.map(chain => chain.chainId)) || []);
|
|
432
443
|
const {
|
|
433
|
-
accountAbstractionProvider
|
|
444
|
+
accountAbstractionProvider,
|
|
445
|
+
toEoaProvider
|
|
434
446
|
} = await Promise.resolve().then(function () { return require('./providers/account-abstraction-provider/index.js'); });
|
|
447
|
+
// for embedded wallets, we use ws-embed provider which is AA provider, need to derive EOA provider
|
|
448
|
+
const eoaProvider = data.connector === index$1.WALLET_CONNECTORS.AUTH ? await toEoaProvider(provider) : provider;
|
|
449
|
+
const aaChainIds = new Set((accountAbstractionConfig === null || accountAbstractionConfig === void 0 || (_accountAbstractionCo2 = accountAbstractionConfig.chains) === null || _accountAbstractionCo2 === void 0 ? void 0 : _accountAbstractionCo2.map(chain => chain.chainId)) || []);
|
|
435
450
|
const aaProvider = await accountAbstractionProvider({
|
|
436
451
|
accountAbstractionConfig,
|
|
437
|
-
provider,
|
|
452
|
+
provider: eoaProvider,
|
|
438
453
|
chain: this.currentChain,
|
|
439
454
|
chains: this.coreOptions.chains.filter(chain => aaChainIds.has(chain.chainId))
|
|
440
455
|
});
|
|
441
|
-
|
|
456
|
+
this.aaProvider = aaProvider;
|
|
457
|
+
// if external wallet is used and AA is enabled for external wallets, use AA provider
|
|
458
|
+
// for embedded wallets, we use ws-embed provider which already supports AA
|
|
459
|
+
if (data.connector !== index$1.WALLET_CONNECTORS.AUTH && this.coreOptions.useAAWithExternalWallet) {
|
|
460
|
+
finalProvider = this.aaProvider;
|
|
461
|
+
}
|
|
442
462
|
}
|
|
443
463
|
this.commonJRPCProvider.updateProviderEngineProxy(finalProvider);
|
|
444
464
|
this.connectedConnectorName = data.connector;
|
|
@@ -6,6 +6,7 @@ var ethereumControllers = require('@toruslabs/ethereum-controllers');
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
exports.accountAbstractionProvider = AccountAbstractionProvider.accountAbstractionProvider;
|
|
9
|
+
exports.toEoaProvider = AccountAbstractionProvider.toEoaProvider;
|
|
9
10
|
Object.defineProperty(exports, "BiconomySmartAccount", {
|
|
10
11
|
enumerable: true,
|
|
11
12
|
get: function () { return ethereumControllers.BiconomySmartAccount; }
|
package/dist/lib.cjs/providers/account-abstraction-provider/providers/AccountAbstractionProvider.js
CHANGED
|
@@ -145,7 +145,7 @@ class AccountAbstractionProvider extends baseProvider.BaseProvider {
|
|
|
145
145
|
handlers: providerHandlers
|
|
146
146
|
});
|
|
147
147
|
engine.push(aaMiddleware);
|
|
148
|
-
const eoaMiddleware = ethRpcMiddlewares.
|
|
148
|
+
const eoaMiddleware = ethRpcMiddlewares.providerAsMiddleware(eoaProvider);
|
|
149
149
|
engine.push(eoaMiddleware);
|
|
150
150
|
const provider = auth.providerFromEngine(engine);
|
|
151
151
|
this.updateProviderEngineProxy(provider);
|
|
@@ -255,9 +255,20 @@ const accountAbstractionProvider = async ({
|
|
|
255
255
|
smartAccountChainsConfig
|
|
256
256
|
});
|
|
257
257
|
};
|
|
258
|
+
const toEoaProvider = async aaProvider => {
|
|
259
|
+
// derive EOA provider from AA provider
|
|
260
|
+
const engine = new auth.JRPCEngine();
|
|
261
|
+
const eoaMiddleware = await ethRpcMiddlewares.createEoaMiddleware({
|
|
262
|
+
aaProvider
|
|
263
|
+
});
|
|
264
|
+
engine.push(eoaMiddleware);
|
|
265
|
+
engine.push(ethRpcMiddlewares.providerAsMiddleware(aaProvider));
|
|
266
|
+
return auth.providerFromEngine(engine);
|
|
267
|
+
};
|
|
258
268
|
|
|
259
269
|
Object.defineProperty(exports, "SMART_ACCOUNT", {
|
|
260
270
|
enumerable: true,
|
|
261
271
|
get: function () { return ethereumControllers.SMART_ACCOUNT; }
|
|
262
272
|
});
|
|
263
273
|
exports.accountAbstractionProvider = accountAbstractionProvider;
|
|
274
|
+
exports.toEoaProvider = toEoaProvider;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
4
|
+
var ethereumControllers = require('@toruslabs/ethereum-controllers');
|
|
4
5
|
var auth = require('@web3auth/auth');
|
|
5
6
|
|
|
6
7
|
async function createAaMiddleware({
|
|
@@ -8,7 +9,7 @@ async function createAaMiddleware({
|
|
|
8
9
|
handlers
|
|
9
10
|
}) {
|
|
10
11
|
const [eoaAddress] = await eoaProvider.request({
|
|
11
|
-
method:
|
|
12
|
+
method: ethereumControllers.METHOD_TYPES.GET_ACCOUNTS
|
|
12
13
|
});
|
|
13
14
|
/**
|
|
14
15
|
* Validates the keyholder address, and returns a normalized (i.e. lowercase)
|
|
@@ -155,7 +156,27 @@ async function createAaMiddleware({
|
|
|
155
156
|
personal_sign: auth.createAsyncMiddleware(personalSign)
|
|
156
157
|
});
|
|
157
158
|
}
|
|
158
|
-
function
|
|
159
|
+
async function createEoaMiddleware({
|
|
160
|
+
aaProvider
|
|
161
|
+
}) {
|
|
162
|
+
async function getAccounts(_req, res) {
|
|
163
|
+
const [, eoaAddress] = await aaProvider.request({
|
|
164
|
+
method: ethereumControllers.METHOD_TYPES.GET_ACCOUNTS
|
|
165
|
+
});
|
|
166
|
+
res.result = [eoaAddress];
|
|
167
|
+
}
|
|
168
|
+
async function requestAccounts(_req, res) {
|
|
169
|
+
const [, eoaAddress] = await aaProvider.request({
|
|
170
|
+
method: ethereumControllers.METHOD_TYPES.ETH_REQUEST_ACCOUNTS
|
|
171
|
+
});
|
|
172
|
+
res.result = [eoaAddress];
|
|
173
|
+
}
|
|
174
|
+
return auth.createScaffoldMiddleware({
|
|
175
|
+
eth_accounts: auth.createAsyncMiddleware(getAccounts),
|
|
176
|
+
eth_requestAccounts: auth.createAsyncMiddleware(requestAccounts)
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
function providerAsMiddleware(provider) {
|
|
159
180
|
return async (req, res, _next, end) => {
|
|
160
181
|
// send request to provider
|
|
161
182
|
try {
|
|
@@ -169,4 +190,5 @@ function eoaProviderAsMiddleware(provider) {
|
|
|
169
190
|
}
|
|
170
191
|
|
|
171
192
|
exports.createAaMiddleware = createAaMiddleware;
|
|
172
|
-
exports.
|
|
193
|
+
exports.createEoaMiddleware = createEoaMiddleware;
|
|
194
|
+
exports.providerAsMiddleware = providerAsMiddleware;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var web3_js = require('@solana/web3.js');
|
|
4
4
|
var react = require('react');
|
|
5
|
+
var baseControllers = require('@toruslabs/base-controllers');
|
|
5
6
|
require('@solana/wallet-standard-features');
|
|
6
7
|
require('@toruslabs/bs58');
|
|
7
|
-
require('@toruslabs/base-controllers');
|
|
8
8
|
require('@babel/runtime/helpers/defineProperty');
|
|
9
9
|
require('@web3auth/auth');
|
|
10
10
|
require('../../../base/errors/index.js');
|
|
@@ -40,7 +40,11 @@ const useSolanaWallet = () => {
|
|
|
40
40
|
}, [web3Auth, provider]);
|
|
41
41
|
react.useEffect(() => {
|
|
42
42
|
const init = async () => {
|
|
43
|
+
var _web3Auth$currentChai;
|
|
43
44
|
if (!solanaWallet$1) return;
|
|
45
|
+
if (!(web3Auth !== null && web3Auth !== void 0 && (_web3Auth$currentChai = web3Auth.currentChain) !== null && _web3Auth$currentChai !== void 0 && _web3Auth$currentChai.chainNamespace) || web3Auth.currentChain.chainNamespace !== baseControllers.CHAIN_NAMESPACES.SOLANA) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
44
48
|
const accounts = await solanaWallet$1.requestAccounts();
|
|
45
49
|
if ((accounts === null || accounts === void 0 ? void 0 : accounts.length) > 0) {
|
|
46
50
|
setAccounts(accounts);
|
|
@@ -163,7 +163,7 @@ function WagmiProvider(_ref) {
|
|
|
163
163
|
} else {
|
|
164
164
|
wagmiChains.push(wagmiChain);
|
|
165
165
|
}
|
|
166
|
-
finalConfig.transports[wagmiChain.id] = viem.http(chain.rpcTarget);
|
|
166
|
+
finalConfig.transports[wagmiChain.id] = chain.wsTarget ? viem.webSocket(chain.wsTarget) : viem.http(chain.rpcTarget);
|
|
167
167
|
});
|
|
168
168
|
finalConfig.chains = [wagmiChains[0], ...wagmiChains.slice(1)];
|
|
169
169
|
}
|
|
@@ -176,9 +176,8 @@ function WagmiProvider(_ref) {
|
|
|
176
176
|
return react.createElement(wagmi.WagmiProvider, // typecast to WagmiProviderPropsBase to avoid type error
|
|
177
177
|
// as we are omitting the config prop from WagmiProviderProps
|
|
178
178
|
// and creating a new config object with the finalConfig
|
|
179
|
-
_objectSpread(_objectSpread({
|
|
180
|
-
config: finalConfig
|
|
181
|
-
}, props), {}, {
|
|
179
|
+
_objectSpread(_objectSpread({}, props), {}, {
|
|
180
|
+
config: finalConfig,
|
|
182
181
|
reconnectOnMount: false
|
|
183
182
|
}), react.createElement(Web3AuthWagmiProvider, null, children));
|
|
184
183
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { SafeEventEmitter } from "@web3auth/auth";
|
|
2
|
-
import { ChainNamespaceType, CONNECTOR_STATUS_TYPE, CustomChainConfig, IConnector, IPlugin, IProvider, IWeb3Auth, IWeb3AuthCoreOptions, LoginParamMap, ProjectConfig, UserAuthInfo, UserInfo, WALLET_CONNECTOR_TYPE, Web3AuthNoModalEvents } from "./base";
|
|
2
|
+
import { type ChainNamespaceType, type CONNECTOR_STATUS_TYPE, type CustomChainConfig, type IConnector, type IPlugin, type IProvider, type IWeb3Auth, type IWeb3AuthCoreOptions, type LoginParamMap, type ProjectConfig, type UserAuthInfo, type UserInfo, type WALLET_CONNECTOR_TYPE, type Web3AuthNoModalEvents } from "./base";
|
|
3
|
+
import { type AccountAbstractionProvider } from "./providers/account-abstraction-provider";
|
|
3
4
|
import { CommonJRPCProvider } from "./providers/base-provider";
|
|
4
5
|
export declare class Web3AuthNoModal extends SafeEventEmitter<Web3AuthNoModalEvents> implements IWeb3Auth {
|
|
5
6
|
readonly coreOptions: IWeb3AuthCoreOptions;
|
|
6
7
|
connectedConnectorName: WALLET_CONNECTOR_TYPE | null;
|
|
7
8
|
status: CONNECTOR_STATUS_TYPE;
|
|
8
9
|
cachedConnector: string | null;
|
|
10
|
+
protected aaProvider: AccountAbstractionProvider | null;
|
|
9
11
|
protected currentChainId: string;
|
|
10
12
|
protected connectors: IConnector<unknown>[];
|
|
11
13
|
protected commonJRPCProvider: CommonJRPCProvider | null;
|
|
@@ -16,6 +18,7 @@ export declare class Web3AuthNoModal extends SafeEventEmitter<Web3AuthNoModalEve
|
|
|
16
18
|
get connected(): boolean;
|
|
17
19
|
get provider(): IProvider | null;
|
|
18
20
|
get connectedConnector(): IConnector<unknown> | null;
|
|
21
|
+
get accountAbstractionProvider(): AccountAbstractionProvider | null;
|
|
19
22
|
set provider(_: IProvider | null);
|
|
20
23
|
init(options?: {
|
|
21
24
|
signal?: AbortSignal;
|
|
@@ -44,4 +44,5 @@ export declare const accountAbstractionProvider: ({ accountAbstractionConfig, ch
|
|
|
44
44
|
chains: CustomChainConfig[];
|
|
45
45
|
provider: IProvider;
|
|
46
46
|
}) => Promise<AccountAbstractionProvider>;
|
|
47
|
-
export
|
|
47
|
+
export declare const toEoaProvider: (aaProvider: IProvider) => Promise<IProvider>;
|
|
48
|
+
export { type AccountAbstractionMultiChainConfig, type AccountAbstractionProvider, type BundlerConfig, type PaymasterConfig, SMART_ACCOUNT };
|
package/dist/lib.cjs/types/providers/account-abstraction-provider/rpc/ethRpcMiddlewares.d.ts
CHANGED
|
@@ -5,4 +5,7 @@ export declare function createAaMiddleware({ eoaProvider, handlers, }: {
|
|
|
5
5
|
eoaProvider: IProvider;
|
|
6
6
|
handlers: IEthProviderHandlers;
|
|
7
7
|
}): Promise<JRPCMiddleware<unknown, unknown>>;
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function createEoaMiddleware({ aaProvider }: {
|
|
9
|
+
aaProvider: IProvider;
|
|
10
|
+
}): Promise<JRPCMiddleware<unknown, unknown>>;
|
|
11
|
+
export declare function providerAsMiddleware(provider: IProvider): JRPCMiddleware<unknown, unknown>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { PropsWithChildren } from "react";
|
|
2
|
-
import { WagmiProviderProps as WagmiProviderPropsBase } from "wagmi";
|
|
3
2
|
import { WagmiProviderProps } from "./interface";
|
|
4
|
-
export declare function WagmiProvider({ children, ...props }: PropsWithChildren<WagmiProviderProps>): import("react").FunctionComponentElement<PropsWithChildren<
|
|
3
|
+
export declare function WagmiProvider({ children, ...props }: PropsWithChildren<WagmiProviderProps>): import("react").FunctionComponentElement<PropsWithChildren<import("wagmi").WagmiProviderProps>>;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var web3_js = require('@solana/web3.js');
|
|
4
4
|
var vue = require('vue');
|
|
5
|
+
var baseControllers = require('@toruslabs/base-controllers');
|
|
5
6
|
var solanaWallet = require('../../../providers/solana-provider/solanaWallet.js');
|
|
6
|
-
require('@toruslabs/base-controllers');
|
|
7
7
|
require('@babel/runtime/helpers/defineProperty');
|
|
8
8
|
require('@web3auth/auth');
|
|
9
9
|
require('../../../base/errors/index.js');
|
|
@@ -26,7 +26,10 @@ const useSolanaWallet = () => {
|
|
|
26
26
|
const solanaWallet$1 = vue.shallowRef(null);
|
|
27
27
|
const connection = vue.shallowRef(null);
|
|
28
28
|
vue.watch(provider, async newVal => {
|
|
29
|
-
var _accounts$value;
|
|
29
|
+
var _web3Auth$value, _accounts$value;
|
|
30
|
+
if (!((_web3Auth$value = web3Auth.value) !== null && _web3Auth$value !== void 0 && (_web3Auth$value = _web3Auth$value.currentChain) !== null && _web3Auth$value !== void 0 && _web3Auth$value.chainNamespace) || web3Auth.value.currentChain.chainNamespace !== baseControllers.CHAIN_NAMESPACES.SOLANA) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
30
33
|
if (!newVal && solanaWallet$1.value) {
|
|
31
34
|
solanaWallet$1.value = null;
|
|
32
35
|
accounts.value = null;
|
|
@@ -42,8 +45,8 @@ const useSolanaWallet = () => {
|
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
if (solanaWallet$1.value && !connection.value) {
|
|
45
|
-
var _web3Auth$
|
|
46
|
-
connection.value = new web3_js.Connection((_web3Auth$
|
|
48
|
+
var _web3Auth$value2;
|
|
49
|
+
connection.value = new web3_js.Connection((_web3Auth$value2 = web3Auth.value) === null || _web3Auth$value2 === void 0 || (_web3Auth$value2 = _web3Auth$value2.currentChain) === null || _web3Auth$value2 === void 0 ? void 0 : _web3Auth$value2.rpcTarget);
|
|
47
50
|
}
|
|
48
51
|
});
|
|
49
52
|
return {
|
|
@@ -188,7 +188,7 @@ const WagmiProvider = vue.defineComponent({
|
|
|
188
188
|
} else {
|
|
189
189
|
wagmiChains.push(wagmiChain);
|
|
190
190
|
}
|
|
191
|
-
configParams.transports[wagmiChain.id] = viem.http(chain.rpcTarget);
|
|
191
|
+
configParams.transports[wagmiChain.id] = chain.wsTarget ? viem.webSocket(chain.wsTarget) : viem.http(chain.rpcTarget);
|
|
192
192
|
});
|
|
193
193
|
configParams.chains = [wagmiChains[0], ...wagmiChains.slice(1)];
|
|
194
194
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
1
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
3
|
import { MetaMaskSDK } from '@metamask/sdk';
|
|
3
4
|
import deepmerge from 'deepmerge';
|
|
@@ -32,6 +33,7 @@ class MetaMaskConnector extends BaseEvmConnector {
|
|
|
32
33
|
throw new Error("Not implemented");
|
|
33
34
|
}
|
|
34
35
|
async init(options) {
|
|
36
|
+
var _metamaskOptions$useD;
|
|
35
37
|
await super.init(options);
|
|
36
38
|
const chainConfig = this.coreOptions.chains.find(x => x.chainId === options.chainId);
|
|
37
39
|
super.checkInitializationRequirements({
|
|
@@ -40,9 +42,10 @@ class MetaMaskConnector extends BaseEvmConnector {
|
|
|
40
42
|
|
|
41
43
|
// Detect app metadata
|
|
42
44
|
const iconUrl = await getSiteIcon(window);
|
|
45
|
+
// TODO: handle ssr
|
|
43
46
|
const appMetadata = {
|
|
44
|
-
name: getSiteName(window),
|
|
45
|
-
url: window.location.origin,
|
|
47
|
+
name: getSiteName(window) || "web3auth",
|
|
48
|
+
url: window.location.origin || "https://web3auth.io",
|
|
46
49
|
iconUrl
|
|
47
50
|
};
|
|
48
51
|
|
|
@@ -50,7 +53,10 @@ class MetaMaskConnector extends BaseEvmConnector {
|
|
|
50
53
|
const metamaskOptions = deepmerge(this.metamaskOptions || {}, {
|
|
51
54
|
dappMetadata: appMetadata
|
|
52
55
|
});
|
|
53
|
-
this.metamaskSDK = new MetaMaskSDK(metamaskOptions)
|
|
56
|
+
this.metamaskSDK = new MetaMaskSDK(_objectSpread(_objectSpread({}, metamaskOptions), {}, {
|
|
57
|
+
_source: "web3auth",
|
|
58
|
+
useDeeplink: (_metamaskOptions$useD = metamaskOptions.useDeeplink) !== null && _metamaskOptions$useD !== void 0 ? _metamaskOptions$useD : true
|
|
59
|
+
}));
|
|
54
60
|
// Work around: in case there is an existing SDK instance in memory (window.mmsdk exists), it won't initialize the new SDK instance again
|
|
55
61
|
// and return the existing instance instead of undefined (this is an assumption, not sure if it's a bug or feature of the MetaMask SDK)
|
|
56
62
|
const initResult = await this.metamaskSDK.init();
|
|
@@ -80,11 +86,12 @@ class MetaMaskConnector extends BaseEvmConnector {
|
|
|
80
86
|
if (!chainConfig) throw WalletLoginError.connectionError("Chain config is not available");
|
|
81
87
|
try {
|
|
82
88
|
if (this.status !== CONNECTOR_STATUS.CONNECTING) {
|
|
89
|
+
var _this$metamaskOptions;
|
|
83
90
|
this.status = CONNECTOR_STATUS.CONNECTING;
|
|
84
91
|
this.emit(CONNECTOR_EVENTS.CONNECTING, {
|
|
85
92
|
connector: WALLET_CONNECTORS.METAMASK
|
|
86
93
|
});
|
|
87
|
-
if (!this.metamaskSDK.isExtensionActive() && this.metamaskOptions.headless) {
|
|
94
|
+
if (!this.metamaskSDK.isExtensionActive() && (_this$metamaskOptions = this.metamaskOptions) !== null && _this$metamaskOptions !== void 0 && _this$metamaskOptions.headless) {
|
|
88
95
|
// when metamask is not injected and headless is true, broadcast the uri to the login modal
|
|
89
96
|
this.metamaskSDK.getProvider().on("display_uri", uri => {
|
|
90
97
|
this.updateConnectorData({
|
package/dist/lib.esm/index.js
CHANGED
|
@@ -30,13 +30,12 @@ export { NFTCheckoutEmbed } from './plugins/nft-checkout-plugin/embed.js';
|
|
|
30
30
|
export { nftCheckoutPlugin } from './plugins/nft-checkout-plugin/plugin.js';
|
|
31
31
|
export { BUTTON_POSITION, CONFIRMATION_STRATEGY } from '@web3auth/ws-embed';
|
|
32
32
|
export { walletServicesPlugin } from './plugins/wallet-services-plugin/plugin.js';
|
|
33
|
-
export { accountAbstractionProvider } from './providers/account-abstraction-provider/providers/AccountAbstractionProvider.js';
|
|
33
|
+
export { accountAbstractionProvider, toEoaProvider } from './providers/account-abstraction-provider/providers/AccountAbstractionProvider.js';
|
|
34
34
|
export { BiconomySmartAccount, KernelSmartAccount, MetamaskSmartAccount, NexusSmartAccount, SMART_ACCOUNT, SafeSmartAccount, TrustSmartAccount } from '@toruslabs/ethereum-controllers';
|
|
35
35
|
export { BaseProvider } from './providers/base-provider/baseProvider.js';
|
|
36
36
|
export { CommonJRPCProvider } from './providers/base-provider/CommonJRPCProvider.js';
|
|
37
37
|
export { CommonPrivateKeyProvider } from './providers/base-provider/commonPrivateKeyProvider.js';
|
|
38
38
|
export { EIP1193_EVENTS, createRandomId } from './providers/base-provider/utils.js';
|
|
39
|
-
export { EthereumSigningProvider } from './providers/ethereum-mpc-provider/providers/signingProviders/EthereumSigningProvider.js';
|
|
40
39
|
export { EIP1559APIEndpoint, GAS_ESTIMATE_TYPES, LegacyGasAPIEndpoint, TRANSACTION_ENVELOPE_TYPES, TRANSACTION_TYPES } from './providers/ethereum-provider/providers/privateKeyProviders/TransactionFormatter/constants.js';
|
|
41
40
|
export { TransactionFormatter } from './providers/ethereum-provider/providers/privateKeyProviders/TransactionFormatter/formatter.js';
|
|
42
41
|
export { SignTypedDataVersion } from './providers/ethereum-provider/providers/privateKeyProviders/TransactionFormatter/interfaces.js';
|
package/dist/lib.esm/noModal.js
CHANGED
|
@@ -28,6 +28,7 @@ class Web3AuthNoModal extends SafeEventEmitter {
|
|
|
28
28
|
_defineProperty(this, "connectedConnectorName", null);
|
|
29
29
|
_defineProperty(this, "status", CONNECTOR_STATUS.NOT_READY);
|
|
30
30
|
_defineProperty(this, "cachedConnector", null);
|
|
31
|
+
_defineProperty(this, "aaProvider", null);
|
|
31
32
|
_defineProperty(this, "currentChainId", void 0);
|
|
32
33
|
_defineProperty(this, "connectors", []);
|
|
33
34
|
_defineProperty(this, "commonJRPCProvider", null);
|
|
@@ -56,6 +57,9 @@ class Web3AuthNoModal extends SafeEventEmitter {
|
|
|
56
57
|
var _this$currentChain;
|
|
57
58
|
return this.getConnector(this.connectedConnectorName, (_this$currentChain = this.currentChain) === null || _this$currentChain === void 0 ? void 0 : _this$currentChain.chainNamespace);
|
|
58
59
|
}
|
|
60
|
+
get accountAbstractionProvider() {
|
|
61
|
+
return this.aaProvider;
|
|
62
|
+
}
|
|
59
63
|
set provider(_) {
|
|
60
64
|
throw new Error("Not implemented");
|
|
61
65
|
}
|
|
@@ -277,16 +281,25 @@ class Web3AuthNoModal extends SafeEventEmitter {
|
|
|
277
281
|
}
|
|
278
282
|
}
|
|
279
283
|
initAccountAbstractionConfig(projectConfig) {
|
|
284
|
+
var _this$coreOptions$acc2;
|
|
280
285
|
const isAAEnabled = Boolean(this.coreOptions.accountAbstractionConfig || (projectConfig === null || projectConfig === void 0 ? void 0 : projectConfig.smartAccounts));
|
|
281
286
|
if (!isAAEnabled) return;
|
|
282
287
|
|
|
283
|
-
// merge project config with core options,
|
|
288
|
+
// merge smart account config from project config with core options, core options will take precedence over project config
|
|
284
289
|
const _ref = (projectConfig === null || projectConfig === void 0 ? void 0 : projectConfig.smartAccounts) || {},
|
|
285
290
|
{
|
|
286
291
|
walletScope
|
|
287
292
|
} = _ref,
|
|
288
293
|
configWithoutWalletScope = _objectWithoutProperties(_ref, _excluded);
|
|
289
|
-
|
|
294
|
+
const aaChainMap = new Map();
|
|
295
|
+
const allAaChains = [...((configWithoutWalletScope === null || configWithoutWalletScope === void 0 ? void 0 : configWithoutWalletScope.chains) || []), ...(((_this$coreOptions$acc2 = this.coreOptions.accountAbstractionConfig) === null || _this$coreOptions$acc2 === void 0 ? void 0 : _this$coreOptions$acc2.chains) || [])];
|
|
296
|
+
for (const chain of allAaChains) {
|
|
297
|
+
const existingChain = aaChainMap.get(chain.chainId);
|
|
298
|
+
if (!existingChain) aaChainMap.set(chain.chainId, chain);else aaChainMap.set(chain.chainId, _objectSpread(_objectSpread({}, existingChain), chain));
|
|
299
|
+
}
|
|
300
|
+
this.coreOptions.accountAbstractionConfig = _objectSpread(_objectSpread({}, deepmerge(configWithoutWalletScope || {}, this.coreOptions.accountAbstractionConfig || {})), {}, {
|
|
301
|
+
chains: Array.from(aaChainMap.values())
|
|
302
|
+
});
|
|
290
303
|
|
|
291
304
|
// determine if we should use AA with external wallet
|
|
292
305
|
if (this.coreOptions.useAAWithExternalWallet === undefined) {
|
|
@@ -427,28 +440,36 @@ class Web3AuthNoModal extends SafeEventEmitter {
|
|
|
427
440
|
} = data;
|
|
428
441
|
let finalProvider = provider.provider || provider;
|
|
429
442
|
|
|
430
|
-
// setup AA provider
|
|
443
|
+
// setup AA provider if AA is enabled
|
|
431
444
|
const {
|
|
432
445
|
accountAbstractionConfig
|
|
433
446
|
} = this.coreOptions;
|
|
434
|
-
const
|
|
447
|
+
const isAaSupportedForCurrentChain = ((_this$currentChain3 = this.currentChain) === null || _this$currentChain3 === void 0 ? void 0 : _this$currentChain3.chainNamespace) === CHAIN_NAMESPACES.EIP155 && (accountAbstractionConfig === null || accountAbstractionConfig === void 0 || (_accountAbstractionCo = accountAbstractionConfig.chains) === null || _accountAbstractionCo === void 0 ? void 0 : _accountAbstractionCo.some(chain => {
|
|
435
448
|
var _this$currentChain4;
|
|
436
449
|
return chain.chainId === ((_this$currentChain4 = this.currentChain) === null || _this$currentChain4 === void 0 ? void 0 : _this$currentChain4.chainId);
|
|
437
450
|
}));
|
|
438
|
-
|
|
439
|
-
if (isExternalWalletAndAAEnabled && doesAASupportCurrentChain) {
|
|
451
|
+
if (isAaSupportedForCurrentChain && (data.connector === WALLET_CONNECTORS.AUTH || this.coreOptions.useAAWithExternalWallet)) {
|
|
440
452
|
var _accountAbstractionCo2;
|
|
441
|
-
const aaChainIds = new Set((accountAbstractionConfig === null || accountAbstractionConfig === void 0 || (_accountAbstractionCo2 = accountAbstractionConfig.chains) === null || _accountAbstractionCo2 === void 0 ? void 0 : _accountAbstractionCo2.map(chain => chain.chainId)) || []);
|
|
442
453
|
const {
|
|
443
|
-
accountAbstractionProvider
|
|
454
|
+
accountAbstractionProvider,
|
|
455
|
+
toEoaProvider
|
|
444
456
|
} = await import('./providers/account-abstraction-provider/index.js');
|
|
457
|
+
// for embedded wallets, we use ws-embed provider which is AA provider, need to derive EOA provider
|
|
458
|
+
const eoaProvider = data.connector === WALLET_CONNECTORS.AUTH ? await toEoaProvider(provider) : provider;
|
|
459
|
+
const aaChainIds = new Set((accountAbstractionConfig === null || accountAbstractionConfig === void 0 || (_accountAbstractionCo2 = accountAbstractionConfig.chains) === null || _accountAbstractionCo2 === void 0 ? void 0 : _accountAbstractionCo2.map(chain => chain.chainId)) || []);
|
|
445
460
|
const aaProvider = await accountAbstractionProvider({
|
|
446
461
|
accountAbstractionConfig,
|
|
447
|
-
provider,
|
|
462
|
+
provider: eoaProvider,
|
|
448
463
|
chain: this.currentChain,
|
|
449
464
|
chains: this.coreOptions.chains.filter(chain => aaChainIds.has(chain.chainId))
|
|
450
465
|
});
|
|
451
|
-
|
|
466
|
+
this.aaProvider = aaProvider;
|
|
467
|
+
|
|
468
|
+
// if external wallet is used and AA is enabled for external wallets, use AA provider
|
|
469
|
+
// for embedded wallets, we use ws-embed provider which already supports AA
|
|
470
|
+
if (data.connector !== WALLET_CONNECTORS.AUTH && this.coreOptions.useAAWithExternalWallet) {
|
|
471
|
+
finalProvider = this.aaProvider;
|
|
472
|
+
}
|
|
452
473
|
}
|
|
453
474
|
this.commonJRPCProvider.updateProviderEngineProxy(finalProvider);
|
|
454
475
|
this.connectedConnectorName = data.connector;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { accountAbstractionProvider } from './providers/AccountAbstractionProvider.js';
|
|
1
|
+
export { accountAbstractionProvider, toEoaProvider } from './providers/AccountAbstractionProvider.js';
|
|
2
2
|
export { BiconomySmartAccount, KernelSmartAccount, MetamaskSmartAccount, NexusSmartAccount, SMART_ACCOUNT, SafeSmartAccount, TrustSmartAccount } from '@toruslabs/ethereum-controllers';
|
package/dist/lib.esm/providers/account-abstraction-provider/providers/AccountAbstractionProvider.js
CHANGED
|
@@ -2,10 +2,10 @@ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
|
2
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
3
|
import { SMART_ACCOUNT, METHOD_TYPES } from '@toruslabs/ethereum-controllers';
|
|
4
4
|
export { SMART_ACCOUNT } from '@toruslabs/ethereum-controllers';
|
|
5
|
-
import {
|
|
5
|
+
import { JRPCEngine, providerFromEngine, providerErrors } from '@web3auth/auth';
|
|
6
6
|
import { defineChain, createPublicClient, http, createWalletClient, custom } from 'viem';
|
|
7
7
|
import { createPaymasterClient, createBundlerClient } from 'viem/account-abstraction';
|
|
8
|
-
import {
|
|
8
|
+
import { createEoaMiddleware, providerAsMiddleware, createAaMiddleware } from '../rpc/ethRpcMiddlewares.js';
|
|
9
9
|
import { getProviderHandlers } from './utils.js';
|
|
10
10
|
import { BaseProvider } from '../../base-provider/baseProvider.js';
|
|
11
11
|
import { CHAIN_NAMESPACES } from '@toruslabs/base-controllers';
|
|
@@ -135,7 +135,7 @@ class AccountAbstractionProvider extends BaseProvider {
|
|
|
135
135
|
handlers: providerHandlers
|
|
136
136
|
});
|
|
137
137
|
engine.push(aaMiddleware);
|
|
138
|
-
const eoaMiddleware =
|
|
138
|
+
const eoaMiddleware = providerAsMiddleware(eoaProvider);
|
|
139
139
|
engine.push(eoaMiddleware);
|
|
140
140
|
const provider = providerFromEngine(engine);
|
|
141
141
|
this.updateProviderEngineProxy(provider);
|
|
@@ -245,5 +245,15 @@ const accountAbstractionProvider = async ({
|
|
|
245
245
|
smartAccountChainsConfig
|
|
246
246
|
});
|
|
247
247
|
};
|
|
248
|
+
const toEoaProvider = async aaProvider => {
|
|
249
|
+
// derive EOA provider from AA provider
|
|
250
|
+
const engine = new JRPCEngine();
|
|
251
|
+
const eoaMiddleware = await createEoaMiddleware({
|
|
252
|
+
aaProvider
|
|
253
|
+
});
|
|
254
|
+
engine.push(eoaMiddleware);
|
|
255
|
+
engine.push(providerAsMiddleware(aaProvider));
|
|
256
|
+
return providerFromEngine(engine);
|
|
257
|
+
};
|
|
248
258
|
|
|
249
|
-
export { accountAbstractionProvider };
|
|
259
|
+
export { accountAbstractionProvider, toEoaProvider };
|