@web3auth/modal 10.4.0 → 10.5.1
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/packages/modal/src/config.js +1 -3
- package/dist/lib.cjs/packages/modal/src/index.js +0 -1
- package/dist/lib.cjs/packages/modal/src/modalManager.js +1 -1
- package/dist/lib.cjs/packages/modal/src/react/hooks/useFunding.js +34 -0
- package/dist/lib.cjs/packages/modal/src/react/hooks/useReceive.js +34 -0
- package/dist/lib.cjs/packages/modal/src/react/index.js +4 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +4 -3
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.js +13 -3
- package/dist/lib.cjs/packages/modal/src/ui/components/Login/Login.js +1 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Toast/Toast.js +3 -6
- package/dist/lib.cjs/packages/modal/src/vue/composables/useFunding.js +34 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useReceive.js +34 -0
- package/dist/lib.cjs/packages/modal/src/vue/index.js +4 -0
- package/dist/lib.cjs/types/config.d.ts +0 -1
- package/dist/lib.cjs/types/react/hooks/index.d.ts +2 -0
- package/dist/lib.cjs/types/react/hooks/useFunding.d.ts +8 -0
- package/dist/lib.cjs/types/react/hooks/useReceive.d.ts +8 -0
- package/dist/lib.cjs/types/vue/composables/index.d.ts +2 -0
- package/dist/lib.cjs/types/vue/composables/useFunding.d.ts +9 -0
- package/dist/lib.cjs/types/vue/composables/useReceive.d.ts +9 -0
- package/dist/lib.esm/packages/modal/src/config.js +2 -3
- package/dist/lib.esm/packages/modal/src/index.js +1 -1
- package/dist/lib.esm/packages/modal/src/modalManager.js +3 -3
- package/dist/lib.esm/packages/modal/src/react/hooks/useFunding.js +32 -0
- package/dist/lib.esm/packages/modal/src/react/hooks/useReceive.js +32 -0
- package/dist/lib.esm/packages/modal/src/react/index.js +2 -0
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +5 -4
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.js +13 -3
- package/dist/lib.esm/packages/modal/src/ui/components/Login/Login.js +1 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Toast/Toast.js +3 -6
- package/dist/lib.esm/packages/modal/src/vue/composables/useFunding.js +32 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useReceive.js +32 -0
- package/dist/lib.esm/packages/modal/src/vue/index.js +2 -0
- package/dist/modal.umd.min.js +1 -1
- package/package.json +3 -3
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var noModal = require('@web3auth/no-modal');
|
|
4
4
|
|
|
5
|
-
const version = "10.
|
|
5
|
+
const version = "10.5.1";
|
|
6
6
|
const defaultConnectorsModalConfig = {
|
|
7
7
|
hideWalletDiscovery: false,
|
|
8
8
|
connectors: {
|
|
@@ -12,8 +12,6 @@ const defaultConnectorsModalConfig = {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
|
-
const walletRegistryUrl = "https://assets.web3auth.io/v1/wallet-registry.json";
|
|
16
15
|
|
|
17
16
|
exports.defaultConnectorsModalConfig = defaultConnectorsModalConfig;
|
|
18
17
|
exports.version = version;
|
|
19
|
-
exports.walletRegistryUrl = walletRegistryUrl;
|
|
@@ -8,7 +8,6 @@ var noModal = require('@web3auth/no-modal');
|
|
|
8
8
|
|
|
9
9
|
exports.defaultConnectorsModalConfig = config.defaultConnectorsModalConfig;
|
|
10
10
|
exports.version = config.version;
|
|
11
|
-
exports.walletRegistryUrl = config.walletRegistryUrl;
|
|
12
11
|
exports.Web3Auth = modalManager.Web3Auth;
|
|
13
12
|
Object.keys(noModal).forEach(function (k) {
|
|
14
13
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
@@ -296,7 +296,7 @@ class Web3Auth extends noModal.Web3AuthNoModal {
|
|
|
296
296
|
web3AuthNetwork: this.options.web3AuthNetwork,
|
|
297
297
|
aaProvider: (_this$options$account = this.options.accountAbstractionConfig) === null || _this$options$account === void 0 ? void 0 : _this$options$account.smartAccountType,
|
|
298
298
|
authBuildEnv: this.options.authBuildEnv
|
|
299
|
-
}), noModal.fetchWalletRegistry(
|
|
299
|
+
}), noModal.fetchWalletRegistry(noModal.WALLET_REGISTRY_URL)]);
|
|
300
300
|
// handle project config result
|
|
301
301
|
if (projectConfigResult.status === "rejected") {
|
|
302
302
|
const error = await auth.serializeError(projectConfigResult.reason);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var noModal = require('@web3auth/no-modal');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var useWalletServicesPlugin = require('./useWalletServicesPlugin.js');
|
|
6
|
+
|
|
7
|
+
const useFunding = () => {
|
|
8
|
+
const {
|
|
9
|
+
plugin,
|
|
10
|
+
ready
|
|
11
|
+
} = useWalletServicesPlugin.useWalletServicesPlugin();
|
|
12
|
+
const [loading, setLoading] = react.useState(false);
|
|
13
|
+
const [error, setError] = react.useState(null);
|
|
14
|
+
const showFunding = react.useCallback(async showFundingParams => {
|
|
15
|
+
setLoading(true);
|
|
16
|
+
setError(null);
|
|
17
|
+
try {
|
|
18
|
+
if (!plugin) throw noModal.WalletServicesPluginError.notInitialized();
|
|
19
|
+
if (!ready) throw noModal.WalletServicesPluginError.walletPluginNotConnected();
|
|
20
|
+
await plugin.showFunding(showFundingParams);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
setError(error);
|
|
23
|
+
} finally {
|
|
24
|
+
setLoading(false);
|
|
25
|
+
}
|
|
26
|
+
}, [plugin, ready]);
|
|
27
|
+
return {
|
|
28
|
+
loading,
|
|
29
|
+
error,
|
|
30
|
+
showFunding
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.useFunding = useFunding;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var noModal = require('@web3auth/no-modal');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var useWalletServicesPlugin = require('./useWalletServicesPlugin.js');
|
|
6
|
+
|
|
7
|
+
const useReceive = () => {
|
|
8
|
+
const {
|
|
9
|
+
plugin,
|
|
10
|
+
ready
|
|
11
|
+
} = useWalletServicesPlugin.useWalletServicesPlugin();
|
|
12
|
+
const [loading, setLoading] = react.useState(false);
|
|
13
|
+
const [error, setError] = react.useState(null);
|
|
14
|
+
const showReceive = react.useCallback(async showReceiveParams => {
|
|
15
|
+
setLoading(true);
|
|
16
|
+
setError(null);
|
|
17
|
+
try {
|
|
18
|
+
if (!plugin) throw noModal.WalletServicesPluginError.notInitialized();
|
|
19
|
+
if (!ready) throw noModal.WalletServicesPluginError.walletPluginNotConnected();
|
|
20
|
+
await plugin.showReceive(showReceiveParams);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
setError(error);
|
|
23
|
+
} finally {
|
|
24
|
+
setLoading(false);
|
|
25
|
+
}
|
|
26
|
+
}, [plugin, ready]);
|
|
27
|
+
return {
|
|
28
|
+
loading,
|
|
29
|
+
error,
|
|
30
|
+
showReceive
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.useReceive = useReceive;
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
var useCheckout = require('./hooks/useCheckout.js');
|
|
4
4
|
var useEnableMFA = require('./hooks/useEnableMFA.js');
|
|
5
|
+
var useFunding = require('./hooks/useFunding.js');
|
|
5
6
|
var useIdentityToken = require('./hooks/useIdentityToken.js');
|
|
6
7
|
var useManageMFA = require('./hooks/useManageMFA.js');
|
|
8
|
+
var useReceive = require('./hooks/useReceive.js');
|
|
7
9
|
var useSwap = require('./hooks/useSwap.js');
|
|
8
10
|
var useSwitchChain = require('./hooks/useSwitchChain.js');
|
|
9
11
|
var useWalletConnectScanner = require('./hooks/useWalletConnectScanner.js');
|
|
@@ -19,8 +21,10 @@ var Web3AuthProvider = require('./Web3AuthProvider.js');
|
|
|
19
21
|
|
|
20
22
|
exports.useCheckout = useCheckout.useCheckout;
|
|
21
23
|
exports.useEnableMFA = useEnableMFA.useEnableMFA;
|
|
24
|
+
exports.useFunding = useFunding.useFunding;
|
|
22
25
|
exports.useIdentityToken = useIdentityToken.useIdentityToken;
|
|
23
26
|
exports.useManageMFA = useManageMFA.useManageMFA;
|
|
27
|
+
exports.useReceive = useReceive.useReceive;
|
|
24
28
|
exports.useSwap = useSwap.useSwap;
|
|
25
29
|
exports.useSwitchChain = useSwitchChain.useSwitchChain;
|
|
26
30
|
exports.useWalletConnectScanner = useWalletConnectScanner.useWalletConnectScanner;
|
|
@@ -75,12 +75,12 @@ function ConnectWallet(props) {
|
|
|
75
75
|
const buttons = [...allExternalButtons.filter(button => button.hasInjectedWallet && defaultButtonKeys.has(button.name)), ...customConnectorButtons, ...allExternalButtons.filter(button => !button.hasInjectedWallet && defaultButtonKeys.has(button.name))].sort((a, b) => {
|
|
76
76
|
// favor MetaMask over other wallets
|
|
77
77
|
if (a.name === noModal.WALLET_CONNECTORS.METAMASK && b.name === noModal.WALLET_CONNECTORS.METAMASK) {
|
|
78
|
-
// favor injected MetaMask over non-injected MetaMask
|
|
79
|
-
if (a.hasInjectedWallet) return -1;
|
|
80
|
-
if (b.hasInjectedWallet) return 1;
|
|
81
78
|
// favor installed MetaMask over non-installed MetaMask
|
|
82
79
|
if (a.isInstalled) return -1;
|
|
83
80
|
if (b.isInstalled) return 1;
|
|
81
|
+
// favor injected MetaMask over non-injected MetaMask
|
|
82
|
+
if (a.hasInjectedWallet) return -1;
|
|
83
|
+
if (b.hasInjectedWallet) return 1;
|
|
84
84
|
return 0;
|
|
85
85
|
}
|
|
86
86
|
if (a.name === noModal.WALLET_CONNECTORS.METAMASK) return -1;
|
|
@@ -159,6 +159,7 @@ function ConnectWallet(props) {
|
|
|
159
159
|
has_wallet_registry_item: !!button.walletRegistryItem,
|
|
160
160
|
total_external_wallets: allUniqueButtons.length
|
|
161
161
|
});
|
|
162
|
+
noModal.log.info("handleWalletClick", button);
|
|
162
163
|
// for installed wallets
|
|
163
164
|
if (button.isInstalled) {
|
|
164
165
|
var _button$chainNamespac2;
|
|
@@ -8,6 +8,7 @@ var reactI18next = require('react-i18next');
|
|
|
8
8
|
var reactQrcodeLogo = require('react-qrcode-logo');
|
|
9
9
|
var constants = require('../../../constants.js');
|
|
10
10
|
var RootContext = require('../../../context/RootContext.js');
|
|
11
|
+
var interfaces = require('../../../interfaces.js');
|
|
11
12
|
var localeImport = require('../../../localeImport.js');
|
|
12
13
|
var Image = require('../../Image/Image.js');
|
|
13
14
|
|
|
@@ -18,7 +19,8 @@ function ConnectWalletQrCode(props) {
|
|
|
18
19
|
});
|
|
19
20
|
const {
|
|
20
21
|
bodyState,
|
|
21
|
-
setBodyState
|
|
22
|
+
setBodyState,
|
|
23
|
+
setToast
|
|
22
24
|
} = react.useContext(RootContext.RootContext);
|
|
23
25
|
const {
|
|
24
26
|
qrCodeValue,
|
|
@@ -41,8 +43,16 @@ function ConnectWalletQrCode(props) {
|
|
|
41
43
|
className: "w3a--contents",
|
|
42
44
|
children: [qrCodeValue ? jsxRuntime.jsxs("div", {
|
|
43
45
|
className: "w3a--flex w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-4 w3a--rounded-2xl w3a--border w3a--border-app-gray-200 w3a--p-4 dark:w3a--border-app-gray-700",
|
|
44
|
-
children: [jsxRuntime.jsx("
|
|
45
|
-
|
|
46
|
+
children: [jsxRuntime.jsx("button", {
|
|
47
|
+
type: "button",
|
|
48
|
+
className: "w3a--relative w3a--flex w3a--size-[300px] w3a--appearance-none w3a--items-center w3a--justify-center w3a--rounded-2xl",
|
|
49
|
+
onClick: () => {
|
|
50
|
+
navigator.clipboard.writeText(qrCodeValue);
|
|
51
|
+
setToast({
|
|
52
|
+
message: t("modal.external.qr-code-copied-to-clipboard"),
|
|
53
|
+
type: interfaces.TOAST_TYPE.SUCCESS
|
|
54
|
+
});
|
|
55
|
+
},
|
|
46
56
|
children: jsxRuntime.jsx(reactQrcodeLogo.QRCode, {
|
|
47
57
|
size: isDesktop ? 300 : 260,
|
|
48
58
|
eyeRadius: 5,
|
|
@@ -325,6 +325,7 @@ function Login(props) {
|
|
|
325
325
|
has_wallet_registry_item: !!wallet.walletRegistryItem,
|
|
326
326
|
total_external_wallets: totalExternalWallets
|
|
327
327
|
});
|
|
328
|
+
noModal.log.info("handleInstalledWalletClick", wallet);
|
|
328
329
|
// for non-injected Metamask on desktop, show QR code to connect
|
|
329
330
|
if (wallet.name === noModal.WALLET_CONNECTORS.METAMASK && !wallet.hasInjectedWallet && deviceDetails.platform === "desktop") {
|
|
330
331
|
handleExternalWalletClick({
|
|
@@ -55,14 +55,11 @@ const Toast = () => {
|
|
|
55
55
|
fill: "currentColor"
|
|
56
56
|
})
|
|
57
57
|
})
|
|
58
|
-
}), jsxRuntime.
|
|
58
|
+
}), jsxRuntime.jsx("div", {
|
|
59
59
|
className: "w3a--flex w3a--items-center w3a--gap-2",
|
|
60
|
-
children:
|
|
61
|
-
className: toastIconClass[toast.type],
|
|
62
|
-
children: "x"
|
|
63
|
-
}), jsxRuntime.jsx("p", {
|
|
60
|
+
children: jsxRuntime.jsx("p", {
|
|
64
61
|
children: toast.message
|
|
65
|
-
})
|
|
62
|
+
})
|
|
66
63
|
})]
|
|
67
64
|
});
|
|
68
65
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var noModal = require('@web3auth/no-modal');
|
|
4
|
+
var vue = require('vue');
|
|
5
|
+
var useWalletServicesPlugin = require('./useWalletServicesPlugin.js');
|
|
6
|
+
|
|
7
|
+
const useFunding = () => {
|
|
8
|
+
const {
|
|
9
|
+
plugin,
|
|
10
|
+
ready
|
|
11
|
+
} = useWalletServicesPlugin.useWalletServicesPlugin();
|
|
12
|
+
const loading = vue.ref(false);
|
|
13
|
+
const error = vue.ref(null);
|
|
14
|
+
const showFunding = async showFundingParams => {
|
|
15
|
+
loading.value = true;
|
|
16
|
+
error.value = null;
|
|
17
|
+
try {
|
|
18
|
+
if (!plugin) throw noModal.WalletServicesPluginError.notInitialized();
|
|
19
|
+
if (!ready) throw noModal.WalletServicesPluginError.walletPluginNotConnected();
|
|
20
|
+
await plugin.value.showFunding(showFundingParams);
|
|
21
|
+
} catch (err) {
|
|
22
|
+
error.value = err;
|
|
23
|
+
} finally {
|
|
24
|
+
loading.value = false;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
return {
|
|
28
|
+
loading,
|
|
29
|
+
error,
|
|
30
|
+
showFunding
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.useFunding = useFunding;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var noModal = require('@web3auth/no-modal');
|
|
4
|
+
var vue = require('vue');
|
|
5
|
+
var useWalletServicesPlugin = require('./useWalletServicesPlugin.js');
|
|
6
|
+
|
|
7
|
+
const useReceive = () => {
|
|
8
|
+
const {
|
|
9
|
+
plugin,
|
|
10
|
+
ready
|
|
11
|
+
} = useWalletServicesPlugin.useWalletServicesPlugin();
|
|
12
|
+
const loading = vue.ref(false);
|
|
13
|
+
const error = vue.ref(null);
|
|
14
|
+
const showReceive = async showReceiveParams => {
|
|
15
|
+
loading.value = true;
|
|
16
|
+
error.value = null;
|
|
17
|
+
try {
|
|
18
|
+
if (!plugin) throw noModal.WalletServicesPluginError.notInitialized();
|
|
19
|
+
if (!ready) throw noModal.WalletServicesPluginError.walletPluginNotConnected();
|
|
20
|
+
await plugin.value.showReceive(showReceiveParams);
|
|
21
|
+
} catch (err) {
|
|
22
|
+
error.value = err;
|
|
23
|
+
} finally {
|
|
24
|
+
loading.value = false;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
return {
|
|
28
|
+
loading,
|
|
29
|
+
error,
|
|
30
|
+
showReceive
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.useReceive = useReceive;
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
var useCheckout = require('./composables/useCheckout.js');
|
|
4
4
|
var useEnableMFA = require('./composables/useEnableMFA.js');
|
|
5
|
+
var useFunding = require('./composables/useFunding.js');
|
|
5
6
|
var useIdentityToken = require('./composables/useIdentityToken.js');
|
|
6
7
|
var useManageMFA = require('./composables/useManageMFA.js');
|
|
8
|
+
var useReceive = require('./composables/useReceive.js');
|
|
7
9
|
var useSwap = require('./composables/useSwap.js');
|
|
8
10
|
var useSwitchChain = require('./composables/useSwitchChain.js');
|
|
9
11
|
var useWalletConnectScanner = require('./composables/useWalletConnectScanner.js');
|
|
@@ -19,8 +21,10 @@ var Web3AuthProvider = require('./Web3AuthProvider.js');
|
|
|
19
21
|
|
|
20
22
|
exports.useCheckout = useCheckout.useCheckout;
|
|
21
23
|
exports.useEnableMFA = useEnableMFA.useEnableMFA;
|
|
24
|
+
exports.useFunding = useFunding.useFunding;
|
|
22
25
|
exports.useIdentityToken = useIdentityToken.useIdentityToken;
|
|
23
26
|
exports.useManageMFA = useManageMFA.useManageMFA;
|
|
27
|
+
exports.useReceive = useReceive.useReceive;
|
|
24
28
|
exports.useSwap = useSwap.useSwap;
|
|
25
29
|
exports.useSwitchChain = useSwitchChain.useSwitchChain;
|
|
26
30
|
exports.useWalletConnectScanner = useWalletConnectScanner.useWalletConnectScanner;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from "./useCheckout";
|
|
2
2
|
export * from "./useEnableMFA";
|
|
3
|
+
export * from "./useFunding";
|
|
3
4
|
export * from "./useIdentityToken";
|
|
4
5
|
export * from "./useManageMFA";
|
|
6
|
+
export * from "./useReceive";
|
|
5
7
|
export * from "./useSwap";
|
|
6
8
|
export * from "./useSwitchChain";
|
|
7
9
|
export * from "./useWalletConnectScanner";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseEmbedControllerState } from "@toruslabs/base-controllers";
|
|
2
|
+
import { Web3AuthError } from "@web3auth/no-modal";
|
|
3
|
+
export interface IUseFunding {
|
|
4
|
+
loading: boolean;
|
|
5
|
+
error: Web3AuthError | null;
|
|
6
|
+
showFunding: (showFundingParams?: BaseEmbedControllerState["showFunding"]) => Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare const useFunding: () => IUseFunding;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseEmbedControllerState } from "@toruslabs/base-controllers";
|
|
2
|
+
import { Web3AuthError } from "@web3auth/no-modal";
|
|
3
|
+
export interface IUseReceive {
|
|
4
|
+
loading: boolean;
|
|
5
|
+
error: Web3AuthError | null;
|
|
6
|
+
showReceive: (showReceiveParams?: BaseEmbedControllerState["showReceive"]) => Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare const useReceive: () => IUseReceive;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from "./useCheckout";
|
|
2
2
|
export * from "./useEnableMFA";
|
|
3
|
+
export * from "./useFunding";
|
|
3
4
|
export * from "./useIdentityToken";
|
|
4
5
|
export * from "./useManageMFA";
|
|
6
|
+
export * from "./useReceive";
|
|
5
7
|
export * from "./useSwap";
|
|
6
8
|
export * from "./useSwitchChain";
|
|
7
9
|
export * from "./useWalletConnectScanner";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseEmbedControllerState } from "@toruslabs/base-controllers";
|
|
2
|
+
import { Web3AuthError } from "@web3auth/no-modal";
|
|
3
|
+
import { Ref } from "vue";
|
|
4
|
+
export interface IUseFunding {
|
|
5
|
+
loading: Ref<boolean>;
|
|
6
|
+
error: Ref<Web3AuthError | null>;
|
|
7
|
+
showFunding: (showFundingParams?: BaseEmbedControllerState["showFunding"]) => Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export declare const useFunding: () => IUseFunding;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseEmbedControllerState } from "@toruslabs/base-controllers";
|
|
2
|
+
import { Web3AuthError } from "@web3auth/no-modal";
|
|
3
|
+
import { Ref } from "vue";
|
|
4
|
+
export interface IUseReceive {
|
|
5
|
+
loading: Ref<boolean>;
|
|
6
|
+
error: Ref<Web3AuthError | null>;
|
|
7
|
+
showReceive: (showReceiveParams?: BaseEmbedControllerState["showReceive"]) => Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export declare const useReceive: () => IUseReceive;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EVM_CONNECTORS } from '@web3auth/no-modal';
|
|
2
2
|
|
|
3
|
-
const version = "10.
|
|
3
|
+
const version = "10.5.1";
|
|
4
4
|
const defaultConnectorsModalConfig = {
|
|
5
5
|
hideWalletDiscovery: false,
|
|
6
6
|
connectors: {
|
|
@@ -10,6 +10,5 @@ const defaultConnectorsModalConfig = {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
|
-
const walletRegistryUrl = "https://assets.web3auth.io/v1/wallet-registry.json";
|
|
14
13
|
|
|
15
|
-
export { defaultConnectorsModalConfig, version
|
|
14
|
+
export { defaultConnectorsModalConfig, version };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
3
|
import { serializeError } from '@web3auth/auth';
|
|
4
|
-
import { Web3AuthNoModal, cloneDeep, WALLET_CONNECTORS, LOGIN_MODE, log, CONNECTOR_STATUS, sdkVersion, ANALYTICS_SDK_TYPE, withAbort, CONNECTOR_EVENTS, ANALYTICS_EVENTS, getErrorAnalyticsProperties, WalletInitializationError, fetchProjectConfig, fetchWalletRegistry, CONNECTOR_CATEGORY, CONNECTOR_NAMES, CONNECTOR_NAMESPACES } from '@web3auth/no-modal';
|
|
4
|
+
import { Web3AuthNoModal, cloneDeep, WALLET_CONNECTORS, LOGIN_MODE, log, CONNECTOR_STATUS, sdkVersion, ANALYTICS_SDK_TYPE, withAbort, CONNECTOR_EVENTS, ANALYTICS_EVENTS, getErrorAnalyticsProperties, WalletInitializationError, fetchProjectConfig, fetchWalletRegistry, WALLET_REGISTRY_URL, CONNECTOR_CATEGORY, CONNECTOR_NAMES, CONNECTOR_NAMESPACES } from '@web3auth/no-modal';
|
|
5
5
|
import deepmerge from 'deepmerge';
|
|
6
|
-
import { defaultConnectorsModalConfig
|
|
6
|
+
import { defaultConnectorsModalConfig } from './config.js';
|
|
7
7
|
import { AUTH_PROVIDERS_NAMES, AUTH_PROVIDERS, capitalizeFirstLetter } from './ui/config.js';
|
|
8
8
|
import { LOGIN_MODAL_EVENTS } from './ui/interfaces.js';
|
|
9
9
|
import { LoginModal } from './ui/loginModal.js';
|
|
@@ -306,7 +306,7 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
306
306
|
web3AuthNetwork: this.options.web3AuthNetwork,
|
|
307
307
|
aaProvider: (_this$options$account = this.options.accountAbstractionConfig) === null || _this$options$account === void 0 ? void 0 : _this$options$account.smartAccountType,
|
|
308
308
|
authBuildEnv: this.options.authBuildEnv
|
|
309
|
-
}), fetchWalletRegistry(
|
|
309
|
+
}), fetchWalletRegistry(WALLET_REGISTRY_URL)]);
|
|
310
310
|
|
|
311
311
|
// handle project config result
|
|
312
312
|
if (projectConfigResult.status === "rejected") {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { WalletServicesPluginError } from '@web3auth/no-modal';
|
|
2
|
+
import { useState, useCallback } from 'react';
|
|
3
|
+
import { useWalletServicesPlugin } from './useWalletServicesPlugin.js';
|
|
4
|
+
|
|
5
|
+
const useFunding = () => {
|
|
6
|
+
const {
|
|
7
|
+
plugin,
|
|
8
|
+
ready
|
|
9
|
+
} = useWalletServicesPlugin();
|
|
10
|
+
const [loading, setLoading] = useState(false);
|
|
11
|
+
const [error, setError] = useState(null);
|
|
12
|
+
const showFunding = useCallback(async showFundingParams => {
|
|
13
|
+
setLoading(true);
|
|
14
|
+
setError(null);
|
|
15
|
+
try {
|
|
16
|
+
if (!plugin) throw WalletServicesPluginError.notInitialized();
|
|
17
|
+
if (!ready) throw WalletServicesPluginError.walletPluginNotConnected();
|
|
18
|
+
await plugin.showFunding(showFundingParams);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
setError(error);
|
|
21
|
+
} finally {
|
|
22
|
+
setLoading(false);
|
|
23
|
+
}
|
|
24
|
+
}, [plugin, ready]);
|
|
25
|
+
return {
|
|
26
|
+
loading,
|
|
27
|
+
error,
|
|
28
|
+
showFunding
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { useFunding };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { WalletServicesPluginError } from '@web3auth/no-modal';
|
|
2
|
+
import { useState, useCallback } from 'react';
|
|
3
|
+
import { useWalletServicesPlugin } from './useWalletServicesPlugin.js';
|
|
4
|
+
|
|
5
|
+
const useReceive = () => {
|
|
6
|
+
const {
|
|
7
|
+
plugin,
|
|
8
|
+
ready
|
|
9
|
+
} = useWalletServicesPlugin();
|
|
10
|
+
const [loading, setLoading] = useState(false);
|
|
11
|
+
const [error, setError] = useState(null);
|
|
12
|
+
const showReceive = useCallback(async showReceiveParams => {
|
|
13
|
+
setLoading(true);
|
|
14
|
+
setError(null);
|
|
15
|
+
try {
|
|
16
|
+
if (!plugin) throw WalletServicesPluginError.notInitialized();
|
|
17
|
+
if (!ready) throw WalletServicesPluginError.walletPluginNotConnected();
|
|
18
|
+
await plugin.showReceive(showReceiveParams);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
setError(error);
|
|
21
|
+
} finally {
|
|
22
|
+
setLoading(false);
|
|
23
|
+
}
|
|
24
|
+
}, [plugin, ready]);
|
|
25
|
+
return {
|
|
26
|
+
loading,
|
|
27
|
+
error,
|
|
28
|
+
showReceive
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { useReceive };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { useCheckout } from './hooks/useCheckout.js';
|
|
2
2
|
export { useEnableMFA } from './hooks/useEnableMFA.js';
|
|
3
|
+
export { useFunding } from './hooks/useFunding.js';
|
|
3
4
|
export { useIdentityToken } from './hooks/useIdentityToken.js';
|
|
4
5
|
export { useManageMFA } from './hooks/useManageMFA.js';
|
|
6
|
+
export { useReceive } from './hooks/useReceive.js';
|
|
5
7
|
export { useSwap } from './hooks/useSwap.js';
|
|
6
8
|
export { useSwitchChain } from './hooks/useSwitchChain.js';
|
|
7
9
|
export { useWalletConnectScanner } from './hooks/useWalletConnectScanner.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
|
-
import { WALLET_CONNECTORS, ANALYTICS_EVENTS } from '@web3auth/no-modal';
|
|
2
|
+
import { WALLET_CONNECTORS, ANALYTICS_EVENTS, log } from '@web3auth/no-modal';
|
|
3
3
|
import { useContext, useState, useMemo } from 'react';
|
|
4
4
|
import { CONNECT_WALLET_PAGES } from '../../constants.js';
|
|
5
5
|
import { AnalyticsContext } from '../../context/AnalyticsContext.js';
|
|
@@ -73,12 +73,12 @@ function ConnectWallet(props) {
|
|
|
73
73
|
const buttons = [...allExternalButtons.filter(button => button.hasInjectedWallet && defaultButtonKeys.has(button.name)), ...customConnectorButtons, ...allExternalButtons.filter(button => !button.hasInjectedWallet && defaultButtonKeys.has(button.name))].sort((a, b) => {
|
|
74
74
|
// favor MetaMask over other wallets
|
|
75
75
|
if (a.name === WALLET_CONNECTORS.METAMASK && b.name === WALLET_CONNECTORS.METAMASK) {
|
|
76
|
-
// favor injected MetaMask over non-injected MetaMask
|
|
77
|
-
if (a.hasInjectedWallet) return -1;
|
|
78
|
-
if (b.hasInjectedWallet) return 1;
|
|
79
76
|
// favor installed MetaMask over non-installed MetaMask
|
|
80
77
|
if (a.isInstalled) return -1;
|
|
81
78
|
if (b.isInstalled) return 1;
|
|
79
|
+
// favor injected MetaMask over non-injected MetaMask
|
|
80
|
+
if (a.hasInjectedWallet) return -1;
|
|
81
|
+
if (b.hasInjectedWallet) return 1;
|
|
82
82
|
return 0;
|
|
83
83
|
}
|
|
84
84
|
if (a.name === WALLET_CONNECTORS.METAMASK) return -1;
|
|
@@ -158,6 +158,7 @@ function ConnectWallet(props) {
|
|
|
158
158
|
has_wallet_registry_item: !!button.walletRegistryItem,
|
|
159
159
|
total_external_wallets: allUniqueButtons.length
|
|
160
160
|
});
|
|
161
|
+
log.info("handleWalletClick", button);
|
|
161
162
|
|
|
162
163
|
// for installed wallets
|
|
163
164
|
if (button.isInstalled) {
|
|
@@ -5,6 +5,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
5
5
|
import { QRCode } from 'react-qrcode-logo';
|
|
6
6
|
import { WALLET_CONNECT_LOGO } from '../../../constants.js';
|
|
7
7
|
import { RootContext } from '../../../context/RootContext.js';
|
|
8
|
+
import { TOAST_TYPE } from '../../../interfaces.js';
|
|
8
9
|
import i18nInstance from '../../../localeImport.js';
|
|
9
10
|
import Image from '../../Image/Image.js';
|
|
10
11
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
@@ -16,7 +17,8 @@ function ConnectWalletQrCode(props) {
|
|
|
16
17
|
});
|
|
17
18
|
const {
|
|
18
19
|
bodyState,
|
|
19
|
-
setBodyState
|
|
20
|
+
setBodyState,
|
|
21
|
+
setToast
|
|
20
22
|
} = useContext(RootContext);
|
|
21
23
|
const {
|
|
22
24
|
qrCodeValue,
|
|
@@ -39,8 +41,16 @@ function ConnectWalletQrCode(props) {
|
|
|
39
41
|
className: "w3a--contents",
|
|
40
42
|
children: [qrCodeValue ? /*#__PURE__*/jsxs("div", {
|
|
41
43
|
className: "w3a--flex w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-4 w3a--rounded-2xl w3a--border w3a--border-app-gray-200 w3a--p-4 dark:w3a--border-app-gray-700",
|
|
42
|
-
children: [/*#__PURE__*/jsx("
|
|
43
|
-
|
|
44
|
+
children: [/*#__PURE__*/jsx("button", {
|
|
45
|
+
type: "button",
|
|
46
|
+
className: "w3a--relative w3a--flex w3a--size-[300px] w3a--appearance-none w3a--items-center w3a--justify-center w3a--rounded-2xl",
|
|
47
|
+
onClick: () => {
|
|
48
|
+
navigator.clipboard.writeText(qrCodeValue);
|
|
49
|
+
setToast({
|
|
50
|
+
message: t("modal.external.qr-code-copied-to-clipboard"),
|
|
51
|
+
type: TOAST_TYPE.SUCCESS
|
|
52
|
+
});
|
|
53
|
+
},
|
|
44
54
|
children: /*#__PURE__*/jsx(QRCode, {
|
|
45
55
|
size: isDesktop ? 300 : 260,
|
|
46
56
|
eyeRadius: 5,
|
|
@@ -327,6 +327,7 @@ function Login(props) {
|
|
|
327
327
|
has_wallet_registry_item: !!wallet.walletRegistryItem,
|
|
328
328
|
total_external_wallets: totalExternalWallets
|
|
329
329
|
});
|
|
330
|
+
log.info("handleInstalledWalletClick", wallet);
|
|
330
331
|
// for non-injected Metamask on desktop, show QR code to connect
|
|
331
332
|
if (wallet.name === WALLET_CONNECTORS.METAMASK && !wallet.hasInjectedWallet && deviceDetails.platform === "desktop") {
|
|
332
333
|
handleExternalWalletClick({
|
|
@@ -53,14 +53,11 @@ const Toast = () => {
|
|
|
53
53
|
fill: "currentColor"
|
|
54
54
|
})
|
|
55
55
|
})
|
|
56
|
-
}), /*#__PURE__*/
|
|
56
|
+
}), /*#__PURE__*/jsx("div", {
|
|
57
57
|
className: "w3a--flex w3a--items-center w3a--gap-2",
|
|
58
|
-
children:
|
|
59
|
-
className: toastIconClass[toast.type],
|
|
60
|
-
children: "x"
|
|
61
|
-
}), /*#__PURE__*/jsx("p", {
|
|
58
|
+
children: /*#__PURE__*/jsx("p", {
|
|
62
59
|
children: toast.message
|
|
63
|
-
})
|
|
60
|
+
})
|
|
64
61
|
})]
|
|
65
62
|
});
|
|
66
63
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { WalletServicesPluginError } from '@web3auth/no-modal';
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
import { useWalletServicesPlugin } from './useWalletServicesPlugin.js';
|
|
4
|
+
|
|
5
|
+
const useFunding = () => {
|
|
6
|
+
const {
|
|
7
|
+
plugin,
|
|
8
|
+
ready
|
|
9
|
+
} = useWalletServicesPlugin();
|
|
10
|
+
const loading = ref(false);
|
|
11
|
+
const error = ref(null);
|
|
12
|
+
const showFunding = async showFundingParams => {
|
|
13
|
+
loading.value = true;
|
|
14
|
+
error.value = null;
|
|
15
|
+
try {
|
|
16
|
+
if (!plugin) throw WalletServicesPluginError.notInitialized();
|
|
17
|
+
if (!ready) throw WalletServicesPluginError.walletPluginNotConnected();
|
|
18
|
+
await plugin.value.showFunding(showFundingParams);
|
|
19
|
+
} catch (err) {
|
|
20
|
+
error.value = err;
|
|
21
|
+
} finally {
|
|
22
|
+
loading.value = false;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
loading,
|
|
27
|
+
error,
|
|
28
|
+
showFunding
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { useFunding };
|