@web3auth/no-modal 10.0.0-beta.3 → 10.0.0-beta.4
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/base/connector/constants.js +2 -1
- package/dist/lib.cjs/base/wallet/index.js +1 -3
- package/dist/lib.cjs/connectors/auth-connector/authConnector.js +3 -1
- package/dist/lib.cjs/index.js +2 -0
- package/dist/lib.cjs/noModal.js +20 -3
- package/dist/lib.cjs/plugins/nft-checkout-plugin/plugin.js +2 -2
- package/dist/lib.cjs/plugins/wallet-services-plugin/plugin.js +1 -1
- package/dist/lib.cjs/react/Web3AuthProvider.js +19 -0
- package/dist/lib.cjs/react/{wallet-services-plugin/WalletServicesContext.js → context/WalletServicesInnerContext.js} +18 -33
- package/dist/lib.cjs/react/{no-modal → context}/Web3AuthInnerContext.js +13 -78
- package/dist/lib.cjs/react/hooks/useCheckout.js +45 -0
- package/dist/lib.cjs/react/hooks/useEnableMFA.js +30 -0
- package/dist/lib.cjs/react/hooks/useIdentityToken.js +42 -0
- package/dist/lib.cjs/react/hooks/useManageMFA.js +30 -0
- package/dist/lib.cjs/react/hooks/useSwap.js +45 -0
- package/dist/lib.cjs/react/hooks/useSwitchChain.js +32 -0
- package/dist/lib.cjs/react/hooks/useWalletConnectScanner.js +45 -0
- package/dist/lib.cjs/react/hooks/useWalletServicesPlugin.js +19 -0
- package/dist/lib.cjs/react/hooks/useWalletUI.js +45 -0
- package/dist/lib.cjs/react/hooks/useWeb3Auth.js +28 -0
- package/dist/lib.cjs/react/hooks/useWeb3AuthConnect.js +44 -0
- package/dist/lib.cjs/react/hooks/useWeb3AuthDisconnect.js +30 -0
- package/dist/lib.cjs/react/{no-modal/hooks/useWeb3Auth.js → hooks/useWeb3AuthInner.js} +9 -9
- package/dist/lib.cjs/react/hooks/useWeb3AuthUser.js +50 -0
- package/dist/lib.cjs/react/index.js +26 -9
- package/dist/lib.cjs/react/wagmi/index.js +7 -0
- package/dist/lib.cjs/react/wagmi/provider.js +186 -0
- package/dist/lib.cjs/types/base/connector/baseConnector.d.ts +4 -5
- package/dist/lib.cjs/types/base/connector/constants.d.ts +1 -0
- package/dist/lib.cjs/types/base/connector/interfaces.d.ts +7 -2
- package/dist/lib.cjs/types/base/core/IWeb3Auth.d.ts +17 -4
- package/dist/lib.cjs/types/base/hooks/index.d.ts +3 -23
- package/dist/lib.cjs/types/base/wallet/index.d.ts +16 -21
- package/dist/lib.cjs/types/connectors/auth-connector/authConnector.d.ts +2 -2
- package/dist/lib.cjs/types/connectors/index.d.ts +1 -0
- package/dist/lib.cjs/types/connectors/metamask-connector/index.d.ts +1 -1
- package/dist/lib.cjs/types/noModal.d.ts +2 -2
- package/dist/lib.cjs/types/plugins/nft-checkout-plugin/plugin.d.ts +2 -2
- package/dist/lib.cjs/types/plugins/wallet-services-plugin/plugin.d.ts +2 -2
- package/dist/lib.cjs/types/react/context/WalletServicesInnerContext.d.ts +6 -0
- package/dist/lib.cjs/types/react/{no-modal → context}/Web3AuthInnerContext.d.ts +1 -1
- package/dist/lib.cjs/types/react/hooks/index.d.ts +13 -0
- package/dist/lib.cjs/types/react/hooks/useCheckout.d.ts +8 -0
- package/dist/lib.cjs/types/react/hooks/useEnableMFA.d.ts +7 -0
- package/dist/lib.cjs/types/react/hooks/useIdentityToken.d.ts +13 -0
- package/dist/lib.cjs/types/react/hooks/useManageMFA.d.ts +7 -0
- package/dist/lib.cjs/types/react/hooks/useSwap.d.ts +8 -0
- package/dist/lib.cjs/types/react/hooks/useSwitchChain.d.ts +7 -0
- package/dist/lib.cjs/types/react/hooks/useWalletConnectScanner.d.ts +8 -0
- package/dist/lib.cjs/types/react/hooks/useWalletUI.d.ts +8 -0
- package/dist/lib.cjs/types/react/hooks/useWeb3Auth.d.ts +3 -0
- package/dist/lib.cjs/types/react/hooks/useWeb3AuthConnect.d.ts +9 -0
- package/dist/lib.cjs/types/react/hooks/useWeb3AuthDisconnect.d.ts +9 -0
- package/dist/lib.cjs/types/react/hooks/useWeb3AuthInner.d.ts +2 -0
- package/dist/lib.cjs/types/react/hooks/useWeb3AuthUser.d.ts +9 -0
- package/dist/lib.cjs/types/react/index.d.ts +3 -2
- package/dist/lib.cjs/types/react/{no-modal/interfaces.d.ts → interfaces.d.ts} +8 -3
- package/dist/lib.cjs/types/react/wagmi/index.d.ts +1 -0
- package/dist/lib.cjs/types/react/wagmi/interface.d.ts +4 -0
- package/dist/lib.cjs/types/react/wagmi/provider.d.ts +4 -0
- package/dist/lib.cjs/types/vue/no-modal/interfaces.d.ts +2 -2
- package/dist/lib.esm/base/connector/constants.js +2 -1
- package/dist/lib.esm/base/wallet/index.js +1 -3
- package/dist/lib.esm/connectors/auth-connector/authConnector.js +3 -1
- package/dist/lib.esm/index.js +1 -0
- package/dist/lib.esm/noModal.js +20 -3
- package/dist/lib.esm/plugins/nft-checkout-plugin/plugin.js +2 -2
- package/dist/lib.esm/plugins/wallet-services-plugin/plugin.js +1 -1
- package/dist/lib.esm/react/Web3AuthProvider.js +17 -0
- package/dist/lib.esm/react/context/WalletServicesInnerContext.js +80 -0
- package/dist/lib.esm/react/{no-modal → context}/Web3AuthInnerContext.js +14 -79
- package/dist/lib.esm/react/hooks/useCheckout.js +43 -0
- package/dist/lib.esm/react/hooks/useEnableMFA.js +28 -0
- package/dist/lib.esm/react/hooks/useIdentityToken.js +40 -0
- package/dist/lib.esm/react/hooks/useManageMFA.js +28 -0
- package/dist/lib.esm/react/hooks/useSwap.js +43 -0
- package/dist/lib.esm/react/hooks/useSwitchChain.js +30 -0
- package/dist/lib.esm/react/hooks/useWalletConnectScanner.js +43 -0
- package/dist/lib.esm/react/hooks/useWalletServicesPlugin.js +17 -0
- package/dist/lib.esm/react/hooks/useWalletUI.js +43 -0
- package/dist/lib.esm/react/hooks/useWeb3Auth.js +26 -0
- package/dist/lib.esm/react/hooks/useWeb3AuthConnect.js +42 -0
- package/dist/lib.esm/react/hooks/useWeb3AuthDisconnect.js +28 -0
- package/dist/lib.esm/react/{no-modal/hooks/useWeb3Auth.js → hooks/useWeb3AuthInner.js} +9 -9
- package/dist/lib.esm/react/hooks/useWeb3AuthUser.js +48 -0
- package/dist/lib.esm/react/index.js +14 -5
- package/dist/lib.esm/react/wagmi/index.js +1 -0
- package/dist/lib.esm/react/wagmi/provider.js +184 -0
- package/dist/noModal.umd.min.js +1 -1
- package/package.json +22 -6
- package/dist/lib.cjs/react/no-modal/Web3AuthProvider.js +0 -15
- package/dist/lib.cjs/react/wallet-services-plugin/WalletServicesProvider.js +0 -16
- package/dist/lib.cjs/react/wallet-services-plugin/hooks/useWalletServicesPlugin.js +0 -26
- package/dist/lib.cjs/types/react/no-modal/hooks/index.d.ts +0 -1
- package/dist/lib.cjs/types/react/no-modal/hooks/useWeb3Auth.d.ts +0 -2
- package/dist/lib.cjs/types/react/no-modal/index.d.ts +0 -3
- package/dist/lib.cjs/types/react/wallet-services-plugin/WalletServicesContext.d.ts +0 -7
- package/dist/lib.cjs/types/react/wallet-services-plugin/WalletServicesProvider.d.ts +0 -7
- package/dist/lib.cjs/types/react/wallet-services-plugin/hooks/index.d.ts +0 -1
- package/dist/lib.cjs/types/react/wallet-services-plugin/index.d.ts +0 -4
- package/dist/lib.cjs/types/react/wallet-services-plugin/interfaces.d.ts +0 -5
- package/dist/lib.esm/react/no-modal/Web3AuthProvider.js +0 -13
- package/dist/lib.esm/react/wallet-services-plugin/WalletServicesContext.js +0 -95
- package/dist/lib.esm/react/wallet-services-plugin/WalletServicesProvider.js +0 -14
- package/dist/lib.esm/react/wallet-services-plugin/hooks/useWalletServicesPlugin.js +0 -24
- /package/dist/lib.cjs/types/react/{no-modal/Web3AuthProvider.d.ts → Web3AuthProvider.d.ts} +0 -0
- /package/dist/lib.cjs/types/react/{wallet-services-plugin/hooks → hooks}/useWalletServicesPlugin.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@web3auth/no-modal",
|
|
3
|
-
"version": "10.0.0-beta.
|
|
3
|
+
"version": "10.0.0-beta.4",
|
|
4
4
|
"description": "Multi chain wallet aggregator for web3Auth",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web3Auth/no-modal",
|
|
@@ -34,18 +34,26 @@
|
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@babel/runtime": "^7.x",
|
|
36
36
|
"@coinbase/wallet-sdk": "^4.3.x",
|
|
37
|
-
"react": "
|
|
38
|
-
"
|
|
37
|
+
"react": ">=18",
|
|
38
|
+
"viem": "^2.23.x",
|
|
39
|
+
"vue": "^3.x",
|
|
40
|
+
"wagmi": "^2.x"
|
|
39
41
|
},
|
|
40
42
|
"peerDependenciesMeta": {
|
|
41
43
|
"@coinbase/wallet-sdk": {
|
|
42
44
|
"optional": true
|
|
43
45
|
},
|
|
46
|
+
"@tanstack/react-query": {
|
|
47
|
+
"optional": true
|
|
48
|
+
},
|
|
44
49
|
"react": {
|
|
45
50
|
"optional": true
|
|
46
51
|
},
|
|
47
52
|
"vue": {
|
|
48
53
|
"optional": true
|
|
54
|
+
},
|
|
55
|
+
"wagmi": {
|
|
56
|
+
"optional": true
|
|
49
57
|
}
|
|
50
58
|
},
|
|
51
59
|
"dependencies": {
|
|
@@ -91,8 +99,8 @@
|
|
|
91
99
|
"@coinbase/wallet-sdk": "^4.3.x",
|
|
92
100
|
"@types/elliptic": "6.4.18",
|
|
93
101
|
"@types/json-rpc-random-id": "^1.0.3",
|
|
94
|
-
"@types/react": "^
|
|
95
|
-
"react": "^
|
|
102
|
+
"@types/react": "^19.1.2",
|
|
103
|
+
"react": "^19.1.0",
|
|
96
104
|
"vue": "^3.x"
|
|
97
105
|
},
|
|
98
106
|
"exports": {
|
|
@@ -106,6 +114,11 @@
|
|
|
106
114
|
"require": "./dist/lib.cjs/react/index.js",
|
|
107
115
|
"types": "./dist/lib.cjs/types/react/index.d.ts"
|
|
108
116
|
},
|
|
117
|
+
"./react/wagmi": {
|
|
118
|
+
"import": "./dist/lib.esm/react/wagmi/index.js",
|
|
119
|
+
"require": "./dist/lib.cjs/react/wagmi/index.js",
|
|
120
|
+
"types": "./dist/lib.cjs/types/react/wagmi/index.d.ts"
|
|
121
|
+
},
|
|
109
122
|
"./vue": {
|
|
110
123
|
"import": "./dist/lib.esm/vue/index.js",
|
|
111
124
|
"require": "./dist/lib.cjs/vue/index.js",
|
|
@@ -117,6 +130,9 @@
|
|
|
117
130
|
"react": [
|
|
118
131
|
"./dist/lib.cjs/types/react/index.d.ts"
|
|
119
132
|
],
|
|
133
|
+
"react/wagmi": [
|
|
134
|
+
"./dist/lib.cjs/types/react/wagmi/index.d.ts"
|
|
135
|
+
],
|
|
120
136
|
"vue": [
|
|
121
137
|
"./dist/lib.cjs/types/vue/index.d.ts"
|
|
122
138
|
]
|
|
@@ -142,5 +158,5 @@
|
|
|
142
158
|
"node": ">=20.x",
|
|
143
159
|
"npm": ">=9.x"
|
|
144
160
|
},
|
|
145
|
-
"gitHead": "
|
|
161
|
+
"gitHead": "bc526b2ca7baa9bc6369e22b15efdcf9386988f0"
|
|
146
162
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var react = require('react');
|
|
4
|
-
var Web3AuthInnerContext = require('./Web3AuthInnerContext.js');
|
|
5
|
-
|
|
6
|
-
function Web3AuthProvider({
|
|
7
|
-
config,
|
|
8
|
-
children
|
|
9
|
-
}) {
|
|
10
|
-
return react.createElement(Web3AuthInnerContext.Web3AuthInnerProvider, {
|
|
11
|
-
config
|
|
12
|
-
}, children);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
exports.Web3AuthProvider = Web3AuthProvider;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var react = require('react');
|
|
4
|
-
var WalletServicesContext = require('./WalletServicesContext.js');
|
|
5
|
-
|
|
6
|
-
function WalletServicesProvider({
|
|
7
|
-
children,
|
|
8
|
-
context
|
|
9
|
-
}) {
|
|
10
|
-
const wsElement = react.createElement(WalletServicesContext.WalletServicesContextProvider, {
|
|
11
|
-
context
|
|
12
|
-
}, children);
|
|
13
|
-
return wsElement;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
exports.WalletServicesProvider = WalletServicesProvider;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var react = require('react');
|
|
4
|
-
require('@toruslabs/base-controllers');
|
|
5
|
-
require('@babel/runtime/helpers/defineProperty');
|
|
6
|
-
require('@web3auth/auth');
|
|
7
|
-
var index = require('../../../base/errors/index.js');
|
|
8
|
-
require('../../../base/wallet/index.js');
|
|
9
|
-
require('../../../base/connector/constants.js');
|
|
10
|
-
require('jwt-decode');
|
|
11
|
-
require('../../../base/loglevel.js');
|
|
12
|
-
require('../../../base/plugin/errors.js');
|
|
13
|
-
require('../../../base/plugin/IPlugin.js');
|
|
14
|
-
require('@toruslabs/constants');
|
|
15
|
-
require('@toruslabs/http-helpers');
|
|
16
|
-
var WalletServicesContext = require('../WalletServicesContext.js');
|
|
17
|
-
|
|
18
|
-
const useWalletServicesPlugin = () => {
|
|
19
|
-
const context = react.useContext(WalletServicesContext.WalletServicesContext);
|
|
20
|
-
if (!context) {
|
|
21
|
-
throw index.WalletInitializationError.fromCode(1000, "usage of useWalletServicesPlugin not wrapped in `WalletServicesContextProvider`.");
|
|
22
|
-
}
|
|
23
|
-
return context;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
exports.useWalletServicesPlugin = useWalletServicesPlugin;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useWeb3Auth";
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Context, PropsWithChildren } from "react";
|
|
2
|
-
import { IBaseWeb3AuthHookContext } from "../../base";
|
|
3
|
-
import { IWalletServicesContext } from "./interfaces";
|
|
4
|
-
export declare const WalletServicesContext: Context<IWalletServicesContext>;
|
|
5
|
-
export declare function WalletServicesContextProvider<T extends IBaseWeb3AuthHookContext>({ children, context }: PropsWithChildren<{
|
|
6
|
-
context: Context<T>;
|
|
7
|
-
}>): import("react").FunctionComponentElement<import("react").ProviderProps<IWalletServicesContext>>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type Context, type PropsWithChildren } from "react";
|
|
2
|
-
import { type IBaseWeb3AuthHookContext } from "../../base";
|
|
3
|
-
export declare function WalletServicesProvider<T extends IBaseWeb3AuthHookContext>({ children, context }: PropsWithChildren<{
|
|
4
|
-
context: Context<T>;
|
|
5
|
-
}>): import("react").FunctionComponentElement<PropsWithChildren<{
|
|
6
|
-
context: Context<T>;
|
|
7
|
-
}>>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useWalletServicesPlugin";
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { IBaseWalletServicesHookContext } from "../../base";
|
|
2
|
-
import type { WalletServicesPluginType } from "../../plugins/wallet-services-plugin";
|
|
3
|
-
export interface IWalletServicesContext extends IBaseWalletServicesHookContext {
|
|
4
|
-
plugin: WalletServicesPluginType | null;
|
|
5
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { createElement } from 'react';
|
|
2
|
-
import { Web3AuthInnerProvider } from './Web3AuthInnerContext.js';
|
|
3
|
-
|
|
4
|
-
function Web3AuthProvider({
|
|
5
|
-
config,
|
|
6
|
-
children
|
|
7
|
-
}) {
|
|
8
|
-
return createElement(Web3AuthInnerProvider, {
|
|
9
|
-
config
|
|
10
|
-
}, children);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { Web3AuthProvider };
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { createContext, useState, useContext, useEffect, useCallback, useMemo, createElement } from 'react';
|
|
2
|
-
import '@toruslabs/base-controllers';
|
|
3
|
-
import '@babel/runtime/helpers/defineProperty';
|
|
4
|
-
import '@web3auth/auth';
|
|
5
|
-
import '../../base/errors/index.js';
|
|
6
|
-
import '../../base/wallet/index.js';
|
|
7
|
-
import { CONNECTOR_STATUS } from '../../base/connector/constants.js';
|
|
8
|
-
import 'jwt-decode';
|
|
9
|
-
import '../../base/loglevel.js';
|
|
10
|
-
import { WalletServicesPluginError } from '../../base/plugin/errors.js';
|
|
11
|
-
import { EVM_PLUGINS, PLUGIN_EVENTS } from '../../base/plugin/IPlugin.js';
|
|
12
|
-
import '@toruslabs/constants';
|
|
13
|
-
import '@toruslabs/http-helpers';
|
|
14
|
-
|
|
15
|
-
const WalletServicesContext = createContext(null);
|
|
16
|
-
function WalletServicesContextProvider({
|
|
17
|
-
children,
|
|
18
|
-
context
|
|
19
|
-
}) {
|
|
20
|
-
const [isPluginConnected, setIsPluginConnected] = useState(false);
|
|
21
|
-
const [walletServicesPlugin, setWalletServicesPlugin] = useState(null);
|
|
22
|
-
const web3AuthContext = useContext(context);
|
|
23
|
-
const {
|
|
24
|
-
getPlugin,
|
|
25
|
-
isInitialized,
|
|
26
|
-
isConnected
|
|
27
|
-
} = web3AuthContext;
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
if (isInitialized) {
|
|
30
|
-
const plugin = getPlugin(EVM_PLUGINS.WALLET_SERVICES);
|
|
31
|
-
setWalletServicesPlugin(plugin);
|
|
32
|
-
}
|
|
33
|
-
}, [isInitialized, getPlugin]);
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
if (isConnected) {
|
|
36
|
-
const plugin = getPlugin(EVM_PLUGINS.WALLET_SERVICES);
|
|
37
|
-
if (!walletServicesPlugin) setWalletServicesPlugin(plugin);
|
|
38
|
-
// when rehydrating, the connectedListener may be registered after the connected event is emitted, we need to check the status here
|
|
39
|
-
if ((walletServicesPlugin === null || walletServicesPlugin === void 0 ? void 0 : walletServicesPlugin.status) === CONNECTOR_STATUS.CONNECTED) setIsPluginConnected(true);
|
|
40
|
-
}
|
|
41
|
-
}, [isConnected, getPlugin, walletServicesPlugin]);
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
const connectedListener = () => {
|
|
44
|
-
setIsPluginConnected(true);
|
|
45
|
-
};
|
|
46
|
-
const disconnectedListener = () => {
|
|
47
|
-
setIsPluginConnected(false);
|
|
48
|
-
};
|
|
49
|
-
if (walletServicesPlugin) {
|
|
50
|
-
walletServicesPlugin.on(PLUGIN_EVENTS.CONNECTED, connectedListener);
|
|
51
|
-
walletServicesPlugin.on(PLUGIN_EVENTS.DISCONNECTED, disconnectedListener);
|
|
52
|
-
}
|
|
53
|
-
return () => {
|
|
54
|
-
if (walletServicesPlugin) {
|
|
55
|
-
walletServicesPlugin.off(PLUGIN_EVENTS.CONNECTED, connectedListener);
|
|
56
|
-
walletServicesPlugin.off(PLUGIN_EVENTS.DISCONNECTED, disconnectedListener);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
}, [walletServicesPlugin]);
|
|
60
|
-
const showWalletConnectScanner = useCallback(async showWalletConnectParams => {
|
|
61
|
-
if (!walletServicesPlugin) throw WalletServicesPluginError.notInitialized();
|
|
62
|
-
if (!isPluginConnected) throw WalletServicesPluginError.walletPluginNotConnected();
|
|
63
|
-
return walletServicesPlugin.showWalletConnectScanner(showWalletConnectParams);
|
|
64
|
-
}, [walletServicesPlugin, isPluginConnected]);
|
|
65
|
-
const showWalletUI = useCallback(async showWalletUiParams => {
|
|
66
|
-
if (!walletServicesPlugin) throw WalletServicesPluginError.notInitialized();
|
|
67
|
-
if (!isPluginConnected) throw WalletServicesPluginError.walletPluginNotConnected();
|
|
68
|
-
return walletServicesPlugin.showWalletUi(showWalletUiParams);
|
|
69
|
-
}, [walletServicesPlugin, isPluginConnected]);
|
|
70
|
-
const showCheckout = useCallback(async showCheckoutParams => {
|
|
71
|
-
if (!walletServicesPlugin) throw WalletServicesPluginError.notInitialized();
|
|
72
|
-
if (!isPluginConnected) throw WalletServicesPluginError.walletPluginNotConnected();
|
|
73
|
-
return walletServicesPlugin.showCheckout(showCheckoutParams);
|
|
74
|
-
}, [walletServicesPlugin, isPluginConnected]);
|
|
75
|
-
const showSwap = useCallback(async showSwapParams => {
|
|
76
|
-
if (!walletServicesPlugin) throw WalletServicesPluginError.notInitialized();
|
|
77
|
-
if (!isPluginConnected) throw WalletServicesPluginError.walletPluginNotConnected();
|
|
78
|
-
return walletServicesPlugin.showSwap(showSwapParams);
|
|
79
|
-
}, [walletServicesPlugin, isPluginConnected]);
|
|
80
|
-
const value = useMemo(() => {
|
|
81
|
-
return {
|
|
82
|
-
plugin: walletServicesPlugin,
|
|
83
|
-
isPluginConnected,
|
|
84
|
-
showWalletConnectScanner,
|
|
85
|
-
showCheckout,
|
|
86
|
-
showWalletUI,
|
|
87
|
-
showSwap
|
|
88
|
-
};
|
|
89
|
-
}, [walletServicesPlugin, isPluginConnected, showWalletConnectScanner, showCheckout, showWalletUI, showSwap]);
|
|
90
|
-
return createElement(WalletServicesContext.Provider, {
|
|
91
|
-
value
|
|
92
|
-
}, children);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export { WalletServicesContext, WalletServicesContextProvider };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { createElement } from 'react';
|
|
2
|
-
import { WalletServicesContextProvider } from './WalletServicesContext.js';
|
|
3
|
-
|
|
4
|
-
function WalletServicesProvider({
|
|
5
|
-
children,
|
|
6
|
-
context
|
|
7
|
-
}) {
|
|
8
|
-
const wsElement = createElement(WalletServicesContextProvider, {
|
|
9
|
-
context
|
|
10
|
-
}, children);
|
|
11
|
-
return wsElement;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { WalletServicesProvider };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { useContext } from 'react';
|
|
2
|
-
import '@toruslabs/base-controllers';
|
|
3
|
-
import '@babel/runtime/helpers/defineProperty';
|
|
4
|
-
import '@web3auth/auth';
|
|
5
|
-
import { WalletInitializationError } from '../../../base/errors/index.js';
|
|
6
|
-
import '../../../base/wallet/index.js';
|
|
7
|
-
import '../../../base/connector/constants.js';
|
|
8
|
-
import 'jwt-decode';
|
|
9
|
-
import '../../../base/loglevel.js';
|
|
10
|
-
import '../../../base/plugin/errors.js';
|
|
11
|
-
import '../../../base/plugin/IPlugin.js';
|
|
12
|
-
import '@toruslabs/constants';
|
|
13
|
-
import '@toruslabs/http-helpers';
|
|
14
|
-
import { WalletServicesContext } from '../WalletServicesContext.js';
|
|
15
|
-
|
|
16
|
-
const useWalletServicesPlugin = () => {
|
|
17
|
-
const context = useContext(WalletServicesContext);
|
|
18
|
-
if (!context) {
|
|
19
|
-
throw WalletInitializationError.fromCode(1000, "usage of useWalletServicesPlugin not wrapped in `WalletServicesContextProvider`.");
|
|
20
|
-
}
|
|
21
|
-
return context;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export { useWalletServicesPlugin };
|
|
File without changes
|
|
File without changes
|