@web3auth/no-modal 10.14.1 → 10.15.0

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.
Files changed (24) hide show
  1. package/dist/lib.cjs/base/utils.js +1 -1
  2. package/dist/lib.cjs/connectors/wallet-connect-v2-connector/WalletConnectV2Provider.js +1 -0
  3. package/dist/lib.cjs/connectors/wallet-connect-v2-connector/walletConnectV2Utils.js +20 -0
  4. package/dist/lib.cjs/index.js +63 -63
  5. package/dist/lib.cjs/providers/ethereum-mpc-provider/providers/signingProviders/EthereumSigningProvider.js +1 -0
  6. package/dist/lib.cjs/providers/ethereum-provider/rpc/ethRpcMiddlewares.js +10 -2
  7. package/dist/lib.cjs/providers/ethereum-provider/rpc/walletMidddleware.js +82 -2
  8. package/dist/lib.cjs/types/providers/ethereum-provider/rpc/interfaces.d.ts +6 -0
  9. package/dist/lib.cjs/types/providers/ethereum-provider/rpc/walletMidddleware.d.ts +1 -1
  10. package/dist/lib.esm/base/utils.js +1 -1
  11. package/dist/lib.esm/connectors/injected-evm-connector/index.js +6 -1
  12. package/dist/lib.esm/connectors/injected-solana-connector/index.js +3 -2
  13. package/dist/lib.esm/connectors/wallet-connect-v2-connector/index.js +5 -1
  14. package/dist/lib.esm/connectors/wallet-connect-v2-connector/walletConnectV2Utils.js +20 -0
  15. package/dist/lib.esm/index.js +36 -36
  16. package/dist/lib.esm/providers/account-abstraction-provider/index.js +5 -1
  17. package/dist/lib.esm/providers/base-provider/index.js +5 -1
  18. package/dist/lib.esm/providers/ethereum-provider/rpc/ethRpcMiddlewares.js +11 -3
  19. package/dist/lib.esm/providers/ethereum-provider/rpc/walletMidddleware.js +83 -2
  20. package/dist/lib.esm/react/context/WalletServicesInnerContext.js +1 -1
  21. package/dist/lib.esm/vue/index.js +1 -1
  22. package/dist/noModal.umd.min.js +1 -1
  23. package/dist/noModal.umd.min.js.LICENSE.txt +0 -2
  24. package/package.json +4 -4
@@ -1,4 +1,4 @@
1
- import { mergeMiddleware, createScaffoldMiddleware, createAsyncMiddleware, rpcErrors } from '@web3auth/auth';
1
+ import { createScaffoldMiddleware, createAsyncMiddleware, mergeMiddleware, rpcErrors } from '@web3auth/auth';
2
2
  import { createWalletMiddleware } from './walletMidddleware.js';
3
3
 
4
4
  function createEthMiddleware(providerHandlers) {
@@ -10,7 +10,11 @@ function createEthMiddleware(providerHandlers) {
10
10
  processSignTransaction,
11
11
  processEthSignMessage,
12
12
  processTypedMessageV4,
13
- processPersonalMessage
13
+ processPersonalMessage,
14
+ processGetCapabilities,
15
+ processSendCalls,
16
+ processGetCallsStatus,
17
+ processShowCallsStatus
14
18
  } = providerHandlers;
15
19
  const ethMiddleware = mergeMiddleware([createScaffoldMiddleware({
16
20
  eth_syncing: false
@@ -22,7 +26,11 @@ function createEthMiddleware(providerHandlers) {
22
26
  processEthSignMessage,
23
27
  processSignTransaction,
24
28
  processTypedMessageV4,
25
- processPersonalMessage
29
+ processPersonalMessage,
30
+ processGetCapabilities,
31
+ processSendCalls,
32
+ processGetCallsStatus,
33
+ processShowCallsStatus
26
34
  })]);
27
35
  return ethMiddleware;
28
36
  }
@@ -1,5 +1,6 @@
1
1
  import _objectSpread from '@babel/runtime/helpers/objectSpread2';
2
2
  import { createScaffoldMiddleware, createAsyncMiddleware, rpcErrors } from '@web3auth/auth';
3
+ import { isHex, toHex } from 'viem';
3
4
 
4
5
  function createWalletMiddleware({
5
6
  getAccounts,
@@ -9,7 +10,11 @@ function createWalletMiddleware({
9
10
  processPersonalMessage,
10
11
  processTransaction,
11
12
  processSignTransaction,
12
- processTypedMessageV4
13
+ processTypedMessageV4,
14
+ processGetCapabilities,
15
+ processSendCalls,
16
+ processGetCallsStatus,
17
+ processShowCallsStatus
13
18
  }) {
14
19
  if (!getAccounts) {
15
20
  throw new Error("opts.getAccounts is required");
@@ -156,6 +161,77 @@ function createWalletMiddleware({
156
161
  }
157
162
  res.result = await getPublicKey(req);
158
163
  }
164
+ async function getWalletCapabilitiesMiddleware(req, res) {
165
+ if (!processGetCapabilities) {
166
+ throw rpcErrors.methodNotSupported();
167
+ }
168
+ if (!Array.isArray(req.params) || req.params.length === 0) {
169
+ throw rpcErrors.invalidParams("Invalid parameters");
170
+ }
171
+ const account = req.params[0];
172
+ if (!isHex(account)) {
173
+ throw rpcErrors.invalidParams("Invalid account address");
174
+ }
175
+ let chainIds = req.params[1] || []; // if empty array is provided, the wallet will return capabilities for all supported chains
176
+ if (!Array.isArray(chainIds)) {
177
+ throw rpcErrors.invalidParams(`Invalid params, received: ${chainIds}. expected: Array`);
178
+ }
179
+
180
+ // format chain ids
181
+ chainIds = chainIds.map(chainId => isHex(chainId) ? chainId : toHex(chainId));
182
+ const getCapabilitiesParams = [account,
183
+ // account address
184
+ chainIds // [`0xstring`, `0xstring`, ...]
185
+ ];
186
+ res.result = await processGetCapabilities(getCapabilitiesParams);
187
+ }
188
+ async function walletSendCallsMiddleware(req, res) {
189
+ if (!processSendCalls) {
190
+ throw rpcErrors.methodNotSupported();
191
+ }
192
+ const params = Array.isArray(req.params) ? req.params[0] : req.params;
193
+ if (!params || typeof params !== "object") {
194
+ throw rpcErrors.invalidParams("Missing or invalid params for wallet_sendCalls");
195
+ }
196
+ if (!params.version || typeof params.version !== "string") {
197
+ throw rpcErrors.invalidParams(`Invalid version: expected string, got "${params.version || "undefined"}"`);
198
+ }
199
+ if (!params.chainId) {
200
+ throw rpcErrors.invalidParams("Missing required field: chainId");
201
+ }
202
+ if (!Array.isArray(params.calls) || params.calls.length === 0) {
203
+ throw rpcErrors.invalidParams("calls must be a non-empty array");
204
+ }
205
+ const from = params.from;
206
+ if (from) {
207
+ await validateAndNormalizeKeyholder(from, req);
208
+ }
209
+ const walletSendCallsParams = _objectSpread(_objectSpread({}, params), {}, {
210
+ chainId: isHex(params.chainId) ? params.chainId : toHex(params.chainId)
211
+ });
212
+ res.result = await processSendCalls(walletSendCallsParams);
213
+ }
214
+ async function walletBatchCallStatusMiddleware(req, res) {
215
+ if (!processGetCallsStatus) {
216
+ throw rpcErrors.methodNotSupported();
217
+ }
218
+ const batchId = Array.isArray(req.params) ? req.params[0] : req.params;
219
+ if (!batchId || typeof batchId !== "string") {
220
+ throw rpcErrors.invalidParams("Missing or invalid batchId");
221
+ }
222
+ res.result = await processGetCallsStatus(batchId);
223
+ }
224
+ async function walletShowCallsStatusMiddleware(req, res) {
225
+ if (!processShowCallsStatus) {
226
+ throw rpcErrors.methodNotSupported();
227
+ }
228
+ const batchId = Array.isArray(req.params) ? req.params[0] : req.params;
229
+ if (!batchId || typeof batchId !== "string") {
230
+ throw rpcErrors.invalidParams("Missing or invalid batchId");
231
+ }
232
+ await processShowCallsStatus(batchId);
233
+ res.result = true;
234
+ }
159
235
  return createScaffoldMiddleware({
160
236
  // account lookups
161
237
  eth_accounts: createAsyncMiddleware(lookupAccounts),
@@ -170,7 +246,12 @@ function createWalletMiddleware({
170
246
  // message signatures
171
247
  eth_sign: createAsyncMiddleware(ethSign),
172
248
  eth_signTypedData_v4: createAsyncMiddleware(signTypedDataV4),
173
- personal_sign: createAsyncMiddleware(personalSign)
249
+ personal_sign: createAsyncMiddleware(personalSign),
250
+ // EIP-5792
251
+ wallet_getCapabilities: createAsyncMiddleware(getWalletCapabilitiesMiddleware),
252
+ wallet_sendCalls: createAsyncMiddleware(walletSendCallsMiddleware),
253
+ wallet_getCallsStatus: createAsyncMiddleware(walletBatchCallStatusMiddleware),
254
+ wallet_showCallsStatus: createAsyncMiddleware(walletShowCallsStatusMiddleware)
174
255
  });
175
256
  }
176
257
 
@@ -1,4 +1,4 @@
1
- import { createContext, useContext, useState, useEffect, useMemo, createElement } from 'react';
1
+ import { useContext, useState, useEffect, useMemo, createElement, createContext } from 'react';
2
2
  import { EVM_PLUGINS, PLUGIN_EVENTS } from '../../base/plugin/IPlugin.js';
3
3
  import { CONNECTOR_STATUS } from '../../base/connector/constants.js';
4
4
 
@@ -1,4 +1,5 @@
1
1
  export { Web3AuthProvider } from './Web3AuthProvider.js';
2
+ export { WalletServicesContextKey } from './context/WalletServicesContext.js';
2
3
  export { useChain } from './composables/useChain.js';
3
4
  export { useCheckout } from './composables/useCheckout.js';
4
5
  export { useEnableMFA } from './composables/useEnableMFA.js';
@@ -15,4 +16,3 @@ export { useWeb3Auth } from './composables/useWeb3Auth.js';
15
16
  export { useWeb3AuthConnect } from './composables/useWeb3AuthConnect.js';
16
17
  export { useWeb3AuthDisconnect } from './composables/useWeb3AuthDisconnect.js';
17
18
  export { useWeb3AuthUser } from './composables/useWeb3AuthUser.js';
18
- export { WalletServicesContextKey } from './context/WalletServicesContext.js';