@web3auth/modal 10.0.0-beta.6 → 10.0.0-beta.7
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 -1
- package/dist/lib.cjs/packages/modal/src/modalManager.js +30 -4
- package/dist/lib.cjs/packages/modal/src/react/hooks/useWalletServicesPlugin.js +2 -1
- package/dist/lib.cjs/packages/modal/src/react/hooks/useWeb3AuthConnect.js +5 -1
- package/dist/lib.cjs/packages/modal/src/react/solana/hooks/useSignAndSendTransaction.js +2 -1
- package/dist/lib.cjs/packages/modal/src/react/solana/hooks/useSignMessage.js +2 -1
- package/dist/lib.cjs/packages/modal/src/react/solana/hooks/useSignTransaction.js +2 -0
- package/dist/lib.cjs/packages/modal/src/react/solana/hooks/useSolanaWallet.js +12 -5
- package/dist/lib.cjs/packages/modal/src/react/wagmi/provider.js +2 -1
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +21 -15
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.js +12 -7
- package/dist/lib.cjs/packages/modal/src/ui/components/Login/Login.js +20 -5
- package/dist/lib.cjs/packages/modal/src/ui/components/Login/LoginOtp/LoginOtp.js +12 -9
- package/dist/lib.cjs/packages/modal/src/ui/components/Root/Root.js +151 -81
- package/dist/lib.cjs/packages/modal/src/ui/components/Widget/Widget.js +11 -1
- package/dist/lib.cjs/packages/modal/src/ui/constants.js +26 -0
- package/dist/lib.cjs/packages/modal/src/ui/context/RootContext.js +12 -3
- package/dist/lib.cjs/packages/modal/src/ui/css/index.css.js +1 -1
- package/dist/lib.cjs/packages/modal/src/ui/loginModal.js +24 -15
- package/dist/lib.cjs/packages/modal/src/ui/utils.js +16 -4
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWalletServicesPlugin.js +2 -1
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWeb3AuthConnect.js +4 -0
- package/dist/lib.cjs/packages/modal/src/vue/solana/composables/useSignAndSendTransaction.js +36 -0
- package/dist/lib.cjs/packages/modal/src/vue/solana/composables/useSignMessage.js +38 -0
- package/dist/lib.cjs/packages/modal/src/vue/solana/composables/useSignTransaction.js +36 -0
- package/dist/lib.cjs/packages/modal/src/vue/solana/composables/useSolanaWallet.js +46 -0
- package/dist/lib.cjs/packages/modal/src/vue/solana/index.js +13 -0
- package/dist/lib.cjs/packages/modal/src/vue/wagmi/index.js +7 -0
- package/dist/lib.cjs/packages/modal/src/vue/wagmi/provider.js +218 -0
- package/dist/lib.cjs/types/interface.d.ts +1 -1
- package/dist/lib.cjs/types/react/solana/hooks/useSignTransaction.d.ts +1 -1
- package/dist/lib.cjs/types/react/solana/hooks/useSolanaWallet.d.ts +2 -0
- package/dist/lib.cjs/types/react/wagmi/index.d.ts +1 -0
- package/dist/lib.cjs/types/react/wagmi/interface.d.ts +1 -1
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWallet.type.d.ts +1 -0
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.type.d.ts +3 -4
- package/dist/lib.cjs/types/ui/components/Login/LoginOtp/LoginOtp.type.d.ts +3 -2
- package/dist/lib.cjs/types/ui/constants.d.ts +2 -0
- package/dist/lib.cjs/types/ui/context/RootContext.d.ts +12 -3
- package/dist/lib.cjs/types/ui/interfaces.d.ts +6 -0
- package/dist/lib.cjs/types/ui/loginModal.d.ts +1 -1
- package/dist/lib.cjs/types/ui/utils.d.ts +2 -2
- package/dist/lib.cjs/types/vue/solana/composables/index.d.ts +4 -0
- package/dist/lib.cjs/types/vue/solana/composables/useSignAndSendTransaction.d.ts +9 -0
- package/dist/lib.cjs/types/vue/solana/composables/useSignMessage.d.ts +9 -0
- package/dist/lib.cjs/types/vue/solana/composables/useSignTransaction.d.ts +9 -0
- package/dist/lib.cjs/types/vue/solana/composables/useSolanaWallet.d.ts +9 -0
- package/dist/lib.cjs/types/vue/solana/index.d.ts +1 -0
- package/dist/lib.cjs/types/vue/wagmi/index.d.ts +2 -0
- package/dist/lib.cjs/types/vue/wagmi/interface.d.ts +4 -0
- package/dist/lib.cjs/types/vue/wagmi/provider.d.ts +16 -0
- package/dist/lib.esm/packages/modal/src/config.js +1 -1
- package/dist/lib.esm/packages/modal/src/modalManager.js +33 -4
- package/dist/lib.esm/packages/modal/src/react/hooks/useWalletServicesPlugin.js +2 -1
- package/dist/lib.esm/packages/modal/src/react/hooks/useWeb3AuthConnect.js +5 -1
- package/dist/lib.esm/packages/modal/src/react/solana/hooks/useSignAndSendTransaction.js +2 -1
- package/dist/lib.esm/packages/modal/src/react/solana/hooks/useSignMessage.js +2 -1
- package/dist/lib.esm/packages/modal/src/react/solana/hooks/useSignTransaction.js +2 -0
- package/dist/lib.esm/packages/modal/src/react/solana/hooks/useSolanaWallet.js +12 -5
- package/dist/lib.esm/packages/modal/src/react/wagmi/provider.js +2 -1
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +21 -15
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.js +13 -8
- package/dist/lib.esm/packages/modal/src/ui/components/Login/Login.js +21 -5
- package/dist/lib.esm/packages/modal/src/ui/components/Login/LoginOtp/LoginOtp.js +12 -9
- package/dist/lib.esm/packages/modal/src/ui/components/Root/Root.js +154 -82
- package/dist/lib.esm/packages/modal/src/ui/components/Widget/Widget.js +12 -1
- package/dist/lib.esm/packages/modal/src/ui/constants.js +26 -1
- package/dist/lib.esm/packages/modal/src/ui/context/RootContext.js +12 -3
- package/dist/lib.esm/packages/modal/src/ui/css/index.css.js +1 -1
- package/dist/lib.esm/packages/modal/src/ui/loginModal.js +24 -15
- package/dist/lib.esm/packages/modal/src/ui/utils.js +16 -4
- package/dist/lib.esm/packages/modal/src/vue/composables/useWalletServicesPlugin.js +2 -1
- package/dist/lib.esm/packages/modal/src/vue/composables/useWeb3AuthConnect.js +4 -0
- package/dist/lib.esm/packages/modal/src/vue/solana/composables/useSignAndSendTransaction.js +34 -0
- package/dist/lib.esm/packages/modal/src/vue/solana/composables/useSignMessage.js +36 -0
- package/dist/lib.esm/packages/modal/src/vue/solana/composables/useSignTransaction.js +34 -0
- package/dist/lib.esm/packages/modal/src/vue/solana/composables/useSolanaWallet.js +44 -0
- package/dist/lib.esm/packages/modal/src/vue/solana/index.js +4 -0
- package/dist/lib.esm/packages/modal/src/vue/wagmi/index.js +1 -0
- package/dist/lib.esm/packages/modal/src/vue/wagmi/provider.js +219 -0
- package/dist/modal.umd.min.js +1 -1
- package/dist/modal.umd.min.js.LICENSE.txt +0 -24
- package/package.json +29 -4
|
@@ -38,6 +38,7 @@ class LoginModal {
|
|
|
38
38
|
_defineProperty(this, "chainNamespaces", void 0);
|
|
39
39
|
_defineProperty(this, "walletRegistry", void 0);
|
|
40
40
|
_defineProperty(this, "callbacks", void 0);
|
|
41
|
+
_defineProperty(this, "externalWalletsConfig", void 0);
|
|
41
42
|
_defineProperty(this, "initModal", async () => {
|
|
42
43
|
const darkState = {
|
|
43
44
|
isDark: this.isDark
|
|
@@ -175,6 +176,7 @@ class LoginModal {
|
|
|
175
176
|
noModal.log.info("addSocialLogins", connector, loginMethods, loginMethodsOrder, uiConfig);
|
|
176
177
|
});
|
|
177
178
|
_defineProperty(this, "addWalletLogins", (externalWalletsConfig, options) => {
|
|
179
|
+
this.externalWalletsConfig = externalWalletsConfig;
|
|
178
180
|
this.setState({
|
|
179
181
|
externalWalletsConfig,
|
|
180
182
|
externalWalletsInitialized: !!options.externalWalletsInitialized,
|
|
@@ -242,29 +244,36 @@ class LoginModal {
|
|
|
242
244
|
_defineProperty(this, "setState", newState => {
|
|
243
245
|
this.stateEmitter.emit("STATE_UPDATED", newState);
|
|
244
246
|
});
|
|
245
|
-
_defineProperty(this, "updateWalletConnect", walletConnectUri => {
|
|
246
|
-
if (!walletConnectUri) return;
|
|
247
|
-
this.setState({
|
|
248
|
-
walletConnectUri
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
247
|
_defineProperty(this, "handleConnectorData", connectorData => {
|
|
252
248
|
if (connectorData.connectorName === noModal.WALLET_CONNECTORS.WALLET_CONNECT_V2) {
|
|
253
249
|
const walletConnectData = connectorData.data;
|
|
254
|
-
|
|
250
|
+
if (walletConnectData.uri) {
|
|
251
|
+
this.setState({
|
|
252
|
+
walletConnectUri: walletConnectData.uri
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if (connectorData.connectorName === noModal.WALLET_CONNECTORS.METAMASK) {
|
|
257
|
+
const metamaskData = connectorData.data;
|
|
258
|
+
if (metamaskData.uri) {
|
|
259
|
+
this.setState({
|
|
260
|
+
metamaskConnectUri: metamaskData.uri
|
|
261
|
+
});
|
|
262
|
+
}
|
|
255
263
|
}
|
|
256
264
|
});
|
|
257
265
|
_defineProperty(this, "subscribeCoreEvents", listener => {
|
|
258
266
|
listener.on(noModal.CONNECTOR_EVENTS.CONNECTING, data => {
|
|
267
|
+
var _this$externalWallets;
|
|
259
268
|
noModal.log.info("connecting with connector", data);
|
|
260
|
-
// don't show loader in case of wallet connect, because currently it listens for incoming
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}
|
|
269
|
+
// don't show loader in case of wallet connect, because currently it listens for incoming connections without any user interaction
|
|
270
|
+
if ((data === null || data === void 0 ? void 0 : data.connector) === noModal.WALLET_CONNECTORS.WALLET_CONNECT_V2) return;
|
|
271
|
+
// don't show loader in case of metamask qr code, because currently it listens for incoming connections without any user interaction
|
|
272
|
+
const isMetamaskInjected = (_this$externalWallets = this.externalWalletsConfig) === null || _this$externalWallets === void 0 || (_this$externalWallets = _this$externalWallets[noModal.WALLET_CONNECTORS.METAMASK]) === null || _this$externalWallets === void 0 ? void 0 : _this$externalWallets.isInjected;
|
|
273
|
+
if ((data === null || data === void 0 ? void 0 : data.connector) === noModal.WALLET_CONNECTORS.METAMASK && !isMetamaskInjected) return;
|
|
274
|
+
this.setState({
|
|
275
|
+
status: interfaces.MODAL_STATUS.CONNECTING
|
|
276
|
+
});
|
|
268
277
|
});
|
|
269
278
|
listener.on(noModal.CONNECTOR_EVENTS.CONNECTED, data => {
|
|
270
279
|
noModal.log.debug("connected with connector", data);
|
|
@@ -82,16 +82,28 @@ const validatePhoneNumber = async phoneNumber => {
|
|
|
82
82
|
const result = await httpHelpers.post(`${passwordlessBackendUrl}/api/v3/phone_number/validate`, {
|
|
83
83
|
phone_number: phoneNumber
|
|
84
84
|
});
|
|
85
|
-
if (result && result.success) return result
|
|
86
|
-
return
|
|
85
|
+
if (result && result.success) return result;
|
|
86
|
+
return {
|
|
87
|
+
success: false,
|
|
88
|
+
parsed_number: "",
|
|
89
|
+
country_flag: ""
|
|
90
|
+
};
|
|
87
91
|
} catch (error) {
|
|
88
92
|
noModal.log.error("error validating phone number", error);
|
|
89
93
|
if (error.status === 400) {
|
|
90
|
-
return
|
|
94
|
+
return {
|
|
95
|
+
success: false,
|
|
96
|
+
parsed_number: "",
|
|
97
|
+
country_flag: ""
|
|
98
|
+
};
|
|
91
99
|
}
|
|
92
100
|
// sending true because we don't want the user to be stuck on a flow
|
|
93
101
|
// if there is an error with the api or something went wrong.
|
|
94
|
-
return
|
|
102
|
+
return {
|
|
103
|
+
success: false,
|
|
104
|
+
parsed_number: "",
|
|
105
|
+
country_flag: ""
|
|
106
|
+
};
|
|
95
107
|
}
|
|
96
108
|
};
|
|
97
109
|
const getUserLanguage = defaultLanguage => {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var noModal = require('@web3auth/no-modal');
|
|
3
4
|
var vue$1 = require('@web3auth/no-modal/vue');
|
|
4
5
|
var vue = require('vue');
|
|
5
6
|
|
|
6
7
|
const useWalletServicesPlugin = () => {
|
|
7
8
|
const context = vue.inject(vue$1.WalletServicesContextKey);
|
|
8
|
-
if (!context) throw
|
|
9
|
+
if (!context) throw noModal.WalletInitializationError.fromCode(1000, "usage of useWalletServicesPlugin not wrapped in `WalletServicesContextProvider`.");
|
|
9
10
|
return context;
|
|
10
11
|
};
|
|
11
12
|
|
|
@@ -16,6 +16,10 @@ const useWeb3AuthConnect = () => {
|
|
|
16
16
|
if (!newVal && connectorName.value) {
|
|
17
17
|
connectorName.value = null;
|
|
18
18
|
}
|
|
19
|
+
if (newVal && !connectorName.value) {
|
|
20
|
+
var _web3Auth$value;
|
|
21
|
+
connectorName.value = (_web3Auth$value = web3Auth.value) === null || _web3Auth$value === void 0 ? void 0 : _web3Auth$value.connectedConnectorName;
|
|
22
|
+
}
|
|
19
23
|
}, {
|
|
20
24
|
immediate: true
|
|
21
25
|
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var noModal = require('@web3auth/no-modal');
|
|
4
|
+
var vue = require('vue');
|
|
5
|
+
var useSolanaWallet = require('./useSolanaWallet.js');
|
|
6
|
+
|
|
7
|
+
const useSignAndSendTransaction = () => {
|
|
8
|
+
const {
|
|
9
|
+
solanaWallet
|
|
10
|
+
} = useSolanaWallet.useSolanaWallet();
|
|
11
|
+
const loading = vue.ref(false);
|
|
12
|
+
const error = vue.ref(null);
|
|
13
|
+
const data = vue.ref(null);
|
|
14
|
+
const signAndSendTransaction = async transaction => {
|
|
15
|
+
loading.value = true;
|
|
16
|
+
error.value = null;
|
|
17
|
+
try {
|
|
18
|
+
if (!solanaWallet.value) throw noModal.WalletInitializationError.notReady();
|
|
19
|
+
const signature = await solanaWallet.value.signAndSendTransaction(transaction);
|
|
20
|
+
data.value = signature;
|
|
21
|
+
return signature;
|
|
22
|
+
} catch (err) {
|
|
23
|
+
error.value = err;
|
|
24
|
+
} finally {
|
|
25
|
+
loading.value = false;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
loading,
|
|
30
|
+
error,
|
|
31
|
+
data,
|
|
32
|
+
signAndSendTransaction
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.useSignAndSendTransaction = useSignAndSendTransaction;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var noModal = require('@web3auth/no-modal');
|
|
4
|
+
var vue = require('vue');
|
|
5
|
+
var useSolanaWallet = require('./useSolanaWallet.js');
|
|
6
|
+
|
|
7
|
+
const useSignMessage = () => {
|
|
8
|
+
const {
|
|
9
|
+
solanaWallet,
|
|
10
|
+
accounts
|
|
11
|
+
} = useSolanaWallet.useSolanaWallet();
|
|
12
|
+
const loading = vue.ref(false);
|
|
13
|
+
const error = vue.ref(null);
|
|
14
|
+
const data = vue.ref(null);
|
|
15
|
+
const signMessage = async (message, from) => {
|
|
16
|
+
loading.value = true;
|
|
17
|
+
error.value = null;
|
|
18
|
+
try {
|
|
19
|
+
var _accounts$value;
|
|
20
|
+
if (!solanaWallet.value) throw noModal.WalletInitializationError.notReady();
|
|
21
|
+
const signature = await solanaWallet.value.signMessage(message, from !== null && from !== void 0 ? from : (_accounts$value = accounts.value) === null || _accounts$value === void 0 ? void 0 : _accounts$value[0]);
|
|
22
|
+
data.value = signature;
|
|
23
|
+
return signature;
|
|
24
|
+
} catch (err) {
|
|
25
|
+
error.value = err;
|
|
26
|
+
} finally {
|
|
27
|
+
loading.value = false;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
loading,
|
|
32
|
+
error,
|
|
33
|
+
data,
|
|
34
|
+
signMessage
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
exports.useSignMessage = useSignMessage;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var noModal = require('@web3auth/no-modal');
|
|
4
|
+
var vue = require('vue');
|
|
5
|
+
var useSolanaWallet = require('./useSolanaWallet.js');
|
|
6
|
+
|
|
7
|
+
const useSignTransaction = () => {
|
|
8
|
+
const {
|
|
9
|
+
solanaWallet
|
|
10
|
+
} = useSolanaWallet.useSolanaWallet();
|
|
11
|
+
const loading = vue.ref(false);
|
|
12
|
+
const error = vue.ref(null);
|
|
13
|
+
const data = vue.ref(null);
|
|
14
|
+
const signTransaction = async transaction => {
|
|
15
|
+
loading.value = true;
|
|
16
|
+
error.value = null;
|
|
17
|
+
try {
|
|
18
|
+
if (!solanaWallet.value) throw noModal.WalletInitializationError.notReady();
|
|
19
|
+
const signedTransaction = await solanaWallet.value.signTransaction(transaction);
|
|
20
|
+
data.value = signedTransaction;
|
|
21
|
+
return signedTransaction;
|
|
22
|
+
} catch (err) {
|
|
23
|
+
error.value = err;
|
|
24
|
+
} finally {
|
|
25
|
+
loading.value = false;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
loading,
|
|
30
|
+
error,
|
|
31
|
+
data,
|
|
32
|
+
signTransaction
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.useSignTransaction = useSignTransaction;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var web3_js = require('@solana/web3.js');
|
|
4
|
+
var noModal = require('@web3auth/no-modal');
|
|
5
|
+
var vue = require('vue');
|
|
6
|
+
require('@web3auth/no-modal/vue');
|
|
7
|
+
var useWeb3Auth = require('../../composables/useWeb3Auth.js');
|
|
8
|
+
|
|
9
|
+
const useSolanaWallet = () => {
|
|
10
|
+
const {
|
|
11
|
+
provider,
|
|
12
|
+
web3Auth
|
|
13
|
+
} = useWeb3Auth.useWeb3Auth();
|
|
14
|
+
const accounts = vue.ref([]);
|
|
15
|
+
const solanaWallet = vue.shallowRef(null);
|
|
16
|
+
const connection = vue.shallowRef(null);
|
|
17
|
+
vue.watch(provider, async newVal => {
|
|
18
|
+
var _accounts$value;
|
|
19
|
+
if (!newVal && solanaWallet.value) {
|
|
20
|
+
solanaWallet.value = null;
|
|
21
|
+
accounts.value = null;
|
|
22
|
+
connection.value = null;
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (!solanaWallet.value) {
|
|
26
|
+
solanaWallet.value = new noModal.SolanaWallet(newVal);
|
|
27
|
+
}
|
|
28
|
+
if (solanaWallet.value && ((_accounts$value = accounts.value) === null || _accounts$value === void 0 ? void 0 : _accounts$value.length) === 0) {
|
|
29
|
+
const result = await solanaWallet.value.requestAccounts();
|
|
30
|
+
if ((result === null || result === void 0 ? void 0 : result.length) > 0) {
|
|
31
|
+
accounts.value = result;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (solanaWallet.value && !connection.value) {
|
|
35
|
+
var _web3Auth$value;
|
|
36
|
+
connection.value = new web3_js.Connection((_web3Auth$value = web3Auth.value) === null || _web3Auth$value === void 0 || (_web3Auth$value = _web3Auth$value.currentChain) === null || _web3Auth$value === void 0 ? void 0 : _web3Auth$value.rpcTarget);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return {
|
|
40
|
+
solanaWallet,
|
|
41
|
+
accounts,
|
|
42
|
+
connection
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
exports.useSolanaWallet = useSolanaWallet;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var useSignAndSendTransaction = require('./composables/useSignAndSendTransaction.js');
|
|
4
|
+
var useSignMessage = require('./composables/useSignMessage.js');
|
|
5
|
+
var useSignTransaction = require('./composables/useSignTransaction.js');
|
|
6
|
+
var useSolanaWallet = require('./composables/useSolanaWallet.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.useSignAndSendTransaction = useSignAndSendTransaction.useSignAndSendTransaction;
|
|
11
|
+
exports.useSignMessage = useSignMessage.useSignMessage;
|
|
12
|
+
exports.useSignTransaction = useSignTransaction.useSignTransaction;
|
|
13
|
+
exports.useSolanaWallet = useSolanaWallet.useSolanaWallet;
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
4
|
+
var core = require('@wagmi/core');
|
|
5
|
+
var vue$1 = require('@wagmi/vue');
|
|
6
|
+
var connectors = require('@wagmi/vue/connectors');
|
|
7
|
+
var noModal = require('@web3auth/no-modal');
|
|
8
|
+
var viem = require('viem');
|
|
9
|
+
var vue = require('vue');
|
|
10
|
+
require('@web3auth/no-modal/vue');
|
|
11
|
+
var useWeb3Auth = require('../composables/useWeb3Auth.js');
|
|
12
|
+
var useWeb3AuthDisconnect = require('../composables/useWeb3AuthDisconnect.js');
|
|
13
|
+
|
|
14
|
+
const WEB3AUTH_CONNECTOR_ID = "web3auth";
|
|
15
|
+
// Helper to initialize connectors for the given wallets
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
async function setupConnector(provider, config) {
|
|
18
|
+
let connector = config.connectors.find(c => c.id === WEB3AUTH_CONNECTOR_ID);
|
|
19
|
+
if (connector) return connector;
|
|
20
|
+
// Create new connector if not already existing
|
|
21
|
+
connector = connectors.injected({
|
|
22
|
+
target: {
|
|
23
|
+
provider: provider,
|
|
24
|
+
id: WEB3AUTH_CONNECTOR_ID,
|
|
25
|
+
name: "Web3Auth"
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const result = config._internal.connectors.setup(connector);
|
|
29
|
+
config._internal.connectors.setState(current => [...current, result]);
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
// Helper to connect a wallet and update wagmi state
|
|
33
|
+
async function connectWeb3AuthWithWagmi(connector, config) {
|
|
34
|
+
var _config$storage, _config$storage2;
|
|
35
|
+
await Promise.all([(_config$storage = config.storage) === null || _config$storage === void 0 ? void 0 : _config$storage.removeItem(`${connector.id}.disconnected`), (_config$storage2 = config.storage) === null || _config$storage2 === void 0 ? void 0 : _config$storage2.setItem("recentConnectorId", connector.id)]);
|
|
36
|
+
let chainId = await connector.getChainId();
|
|
37
|
+
if (!config.chains.find(c => c.id === chainId)) {
|
|
38
|
+
chainId = config.chains[0].id;
|
|
39
|
+
}
|
|
40
|
+
const accounts = await connector.getAccounts();
|
|
41
|
+
const connections = new Map([[connector.uid, {
|
|
42
|
+
accounts: [accounts[0]],
|
|
43
|
+
chainId,
|
|
44
|
+
connector
|
|
45
|
+
}]]);
|
|
46
|
+
config.setState(state => _objectSpread(_objectSpread({}, state), {}, {
|
|
47
|
+
chainId,
|
|
48
|
+
connections,
|
|
49
|
+
current: connector.uid,
|
|
50
|
+
status: "connected"
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
async function disconnectWeb3AuthFromWagmi(config) {
|
|
54
|
+
config._internal.connectors.setState(prev => prev.filter(c => c.id !== WEB3AUTH_CONNECTOR_ID));
|
|
55
|
+
config.setState(state => _objectSpread(_objectSpread({}, state), {}, {
|
|
56
|
+
chainId: state.chainId,
|
|
57
|
+
connections: new Map(),
|
|
58
|
+
current: undefined,
|
|
59
|
+
status: "disconnected"
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
const Web3AuthWagmiProvider = vue.defineComponent({
|
|
63
|
+
name: "Web3AuthWagmiProvider",
|
|
64
|
+
setup() {
|
|
65
|
+
const {
|
|
66
|
+
isConnected,
|
|
67
|
+
provider
|
|
68
|
+
} = useWeb3Auth.useWeb3Auth();
|
|
69
|
+
const {
|
|
70
|
+
disconnect
|
|
71
|
+
} = useWeb3AuthDisconnect.useWeb3AuthDisconnect();
|
|
72
|
+
const wagmiConfig = vue$1.useConfig();
|
|
73
|
+
vue$1.useAccountEffect({
|
|
74
|
+
onDisconnect: async () => {
|
|
75
|
+
noModal.log.info("Disconnected from wagmi");
|
|
76
|
+
if (isConnected.value) await disconnect();
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
vue.watch(isConnected, async newIsConnected => {
|
|
80
|
+
if (newIsConnected && provider.value) {
|
|
81
|
+
const connector = await setupConnector(provider.value, wagmiConfig);
|
|
82
|
+
if (!connector) {
|
|
83
|
+
noModal.log.error("Failed to setup vue wagmi connector");
|
|
84
|
+
throw new Error("Failed to setup connector");
|
|
85
|
+
}
|
|
86
|
+
await connectWeb3AuthWithWagmi(connector, wagmiConfig);
|
|
87
|
+
} else if (!newIsConnected) {
|
|
88
|
+
if (wagmiConfig.state.status === "connected") {
|
|
89
|
+
await disconnectWeb3AuthFromWagmi(wagmiConfig);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}, {
|
|
93
|
+
immediate: true
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
render() {
|
|
97
|
+
var _this$$slots$default;
|
|
98
|
+
return vue.h((_this$$slots$default = this.$slots.default) !== null && _this$$slots$default !== void 0 ? _this$$slots$default : "");
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
const Web3AuthWagmiInnerProvider = vue.defineComponent({
|
|
102
|
+
name: "Web3AuthWagmiInnerProvider",
|
|
103
|
+
props: {
|
|
104
|
+
config: {
|
|
105
|
+
type: Object,
|
|
106
|
+
required: false
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
setup(props) {
|
|
110
|
+
const {
|
|
111
|
+
config
|
|
112
|
+
} = props;
|
|
113
|
+
vue.provide(vue$1.configKey, config);
|
|
114
|
+
},
|
|
115
|
+
render() {
|
|
116
|
+
var _this$$slots$default2;
|
|
117
|
+
return vue.h(Web3AuthWagmiProvider, {}, (_this$$slots$default2 = this.$slots.default) !== null && _this$$slots$default2 !== void 0 ? _this$$slots$default2 : "");
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
const WagmiProvider = vue.defineComponent({
|
|
121
|
+
name: "WagmiProvider",
|
|
122
|
+
props: {
|
|
123
|
+
config: {
|
|
124
|
+
type: Object,
|
|
125
|
+
required: false
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
setup(props) {
|
|
129
|
+
const {
|
|
130
|
+
config
|
|
131
|
+
} = props;
|
|
132
|
+
const {
|
|
133
|
+
web3Auth,
|
|
134
|
+
isInitialized
|
|
135
|
+
} = useWeb3Auth.useWeb3Auth();
|
|
136
|
+
const finalConfig = vue.shallowRef(null);
|
|
137
|
+
const defineWagmiConfig = () => {
|
|
138
|
+
var _web3Auth$value;
|
|
139
|
+
const configParams = _objectSpread(_objectSpread({
|
|
140
|
+
ssr: true
|
|
141
|
+
}, config), {}, {
|
|
142
|
+
chains: undefined,
|
|
143
|
+
connectors: [],
|
|
144
|
+
transports: {},
|
|
145
|
+
multiInjectedProviderDiscovery: false,
|
|
146
|
+
client: undefined
|
|
147
|
+
});
|
|
148
|
+
const wagmiChains = [];
|
|
149
|
+
if (isInitialized.value && web3Auth !== null && web3Auth !== void 0 && (_web3Auth$value = web3Auth.value) !== null && _web3Auth$value !== void 0 && (_web3Auth$value = _web3Auth$value.coreOptions) !== null && _web3Auth$value !== void 0 && _web3Auth$value.chains) {
|
|
150
|
+
var _web3Auth$value$curre;
|
|
151
|
+
const defaultChainId = (_web3Auth$value$curre = web3Auth.value.currentChain) === null || _web3Auth$value$curre === void 0 ? void 0 : _web3Auth$value$curre.chainId;
|
|
152
|
+
const chains = web3Auth.value.coreOptions.chains;
|
|
153
|
+
chains.forEach(chain => {
|
|
154
|
+
const wagmiChain = viem.defineChain({
|
|
155
|
+
id: Number.parseInt(chain.chainId, 16),
|
|
156
|
+
// id in number form
|
|
157
|
+
name: chain.displayName,
|
|
158
|
+
rpcUrls: {
|
|
159
|
+
default: {
|
|
160
|
+
http: [chain.rpcTarget],
|
|
161
|
+
webSocket: [chain.wsTarget]
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
blockExplorers: chain.blockExplorerUrl ? {
|
|
165
|
+
default: {
|
|
166
|
+
name: "explorer",
|
|
167
|
+
// TODO: correct name if chain config has it
|
|
168
|
+
url: chain.blockExplorerUrl
|
|
169
|
+
}
|
|
170
|
+
} : undefined,
|
|
171
|
+
nativeCurrency: {
|
|
172
|
+
name: chain.tickerName,
|
|
173
|
+
symbol: chain.ticker,
|
|
174
|
+
decimals: chain.decimals || 18
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
if (defaultChainId === chain.chainId) {
|
|
178
|
+
wagmiChains.unshift(wagmiChain);
|
|
179
|
+
} else {
|
|
180
|
+
wagmiChains.push(wagmiChain);
|
|
181
|
+
}
|
|
182
|
+
configParams.transports[wagmiChain.id] = viem.http(chain.rpcTarget);
|
|
183
|
+
});
|
|
184
|
+
configParams.chains = [wagmiChains[0], ...wagmiChains.slice(1)];
|
|
185
|
+
}
|
|
186
|
+
if (!configParams.chains) return;
|
|
187
|
+
return vue$1.createConfig(configParams);
|
|
188
|
+
};
|
|
189
|
+
vue.watch(isInitialized, newIsInitialized => {
|
|
190
|
+
if (newIsInitialized && !finalConfig.value) {
|
|
191
|
+
finalConfig.value = defineWagmiConfig();
|
|
192
|
+
if (finalConfig.value) {
|
|
193
|
+
core.hydrate(finalConfig.value, _objectSpread({
|
|
194
|
+
reconnectOnMount: false
|
|
195
|
+
}, props.config));
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}, {
|
|
199
|
+
immediate: true
|
|
200
|
+
});
|
|
201
|
+
return {
|
|
202
|
+
finalConfig
|
|
203
|
+
};
|
|
204
|
+
},
|
|
205
|
+
render() {
|
|
206
|
+
if (!this.finalConfig) return null;
|
|
207
|
+
return vue.h(Web3AuthWagmiInnerProvider, {
|
|
208
|
+
config: this.finalConfig
|
|
209
|
+
}, {
|
|
210
|
+
default: () => {
|
|
211
|
+
var _this$$slots$default3, _this$$slots;
|
|
212
|
+
return (_this$$slots$default3 = (_this$$slots = this.$slots).default) === null || _this$$slots$default3 === void 0 ? void 0 : _this$$slots$default3.call(_this$$slots);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
exports.WagmiProvider = WagmiProvider;
|
|
@@ -3,7 +3,7 @@ export interface ModalConfig extends Omit<BaseConnectorConfig, "isInjected" | "c
|
|
|
3
3
|
loginMethods?: LoginMethodConfig;
|
|
4
4
|
}
|
|
5
5
|
export interface ConnectorsModalConfig {
|
|
6
|
-
connectors?: Record<WALLET_CONNECTOR_TYPE, ModalConfig
|
|
6
|
+
connectors?: Partial<Record<WALLET_CONNECTOR_TYPE, ModalConfig>>;
|
|
7
7
|
hideWalletDiscovery?: boolean;
|
|
8
8
|
}
|
|
9
9
|
export interface IWeb3AuthModal extends IWeb3Auth {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { Connection } from "@solana/web3.js";
|
|
1
2
|
import { SolanaWallet } from "@web3auth/no-modal";
|
|
2
3
|
export type IUseSolanaWallet = {
|
|
3
4
|
accounts: string[] | null;
|
|
4
5
|
solanaWallet: SolanaWallet | null;
|
|
6
|
+
connection: Connection | null;
|
|
5
7
|
};
|
|
6
8
|
export declare const useSolanaWallet: () => IUseSolanaWallet;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { CreateConfigParameters, WagmiProviderProps as WagmiProviderPropsBase } from "wagmi";
|
|
2
2
|
export type WagmiProviderProps = Omit<WagmiProviderPropsBase, "config"> & {
|
|
3
|
-
config?: CreateConfigParameters
|
|
3
|
+
config?: Omit<CreateConfigParameters, "chains" | "connectors" | "transports" | "multiInjectedProviderDiscovery" | "client">;
|
|
4
4
|
};
|
|
@@ -4,6 +4,7 @@ export interface ConnectWalletProps {
|
|
|
4
4
|
isDark: boolean;
|
|
5
5
|
config: Record<string, BaseConnectorConfig>;
|
|
6
6
|
walletConnectUri: string | undefined;
|
|
7
|
+
metamaskConnectUri: string | undefined;
|
|
7
8
|
walletRegistry?: WalletRegistry;
|
|
8
9
|
allExternalButtons: ExternalButton[];
|
|
9
10
|
customConnectorButtons: ExternalButton[];
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
walletConnectUri: string;
|
|
1
|
+
import { type ExternalButton } from "../../../interfaces";
|
|
2
|
+
export interface ConnectWalletQrCodeProps {
|
|
3
|
+
qrCodeValue: string;
|
|
5
4
|
isDark: boolean;
|
|
6
5
|
selectedButton: ExternalButton;
|
|
7
6
|
logoImage?: string;
|
|
@@ -2,9 +2,10 @@ import { type AUTH_CONNECTION_TYPE } from "@web3auth/auth";
|
|
|
2
2
|
export interface LoginOtpProps {
|
|
3
3
|
otpLoading: boolean;
|
|
4
4
|
authConnection: AUTH_CONNECTION_TYPE;
|
|
5
|
-
|
|
5
|
+
countryFlag: string;
|
|
6
6
|
errorMessage: string;
|
|
7
|
+
loginHint?: string;
|
|
7
8
|
setShowOtpFlow: (showOtpFlow: boolean) => void;
|
|
8
9
|
handleOtpComplete: (otp: string) => void;
|
|
9
10
|
}
|
|
10
|
-
export type OtpInputProps = Pick<LoginOtpProps, "otpLoading" | "loginHint" | "setShowOtpFlow" | "handleOtpComplete" | "authConnection" | "errorMessage">;
|
|
11
|
+
export type OtpInputProps = Pick<LoginOtpProps, "otpLoading" | "loginHint" | "setShowOtpFlow" | "handleOtpComplete" | "authConnection" | "errorMessage" | "countryFlag">;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WalletRegistryItem } from "@web3auth/no-modal";
|
|
1
2
|
export declare const PAGES: {
|
|
2
3
|
LOGIN: string;
|
|
3
4
|
SHOW_SOCIAL_LOGINS: string;
|
|
@@ -13,3 +14,4 @@ export declare const DEFAULT_LOGO_DARK = "https://images.web3auth.io/web3auth-lo
|
|
|
13
14
|
export declare const WALLET_CONNECT_LOGO = "https://images.web3auth.io/login-wallet-connect.svg";
|
|
14
15
|
export declare const DEFAULT_PRIMARY_COLOR = "#0364FF";
|
|
15
16
|
export declare const DEFAULT_ON_PRIMARY_COLOR = "#FFFFFF";
|
|
17
|
+
export declare const DEFAULT_METAMASK_WALLET_REGISTRY_ITEM: WalletRegistryItem;
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import { Dispatch, SetStateAction } from "react";
|
|
2
2
|
import { ExternalButton, ToastType } from "../interfaces";
|
|
3
3
|
export type BodyState = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
installLinks?: {
|
|
5
|
+
show: boolean;
|
|
6
|
+
wallet: ExternalButton;
|
|
7
|
+
};
|
|
8
|
+
multiChainSelector: {
|
|
9
|
+
show: boolean;
|
|
10
|
+
wallet: ExternalButton;
|
|
11
|
+
};
|
|
12
|
+
metamaskQrCode: {
|
|
13
|
+
show: boolean;
|
|
14
|
+
wallet: ExternalButton;
|
|
15
|
+
};
|
|
7
16
|
};
|
|
8
17
|
export type ToastState = {
|
|
9
18
|
message: string;
|
|
@@ -89,6 +89,7 @@ export interface ModalState {
|
|
|
89
89
|
modalVisibilityDelayed: boolean;
|
|
90
90
|
postLoadingMessage: string;
|
|
91
91
|
walletConnectUri: string;
|
|
92
|
+
metamaskConnectUri: string;
|
|
92
93
|
socialLoginsConfig: SocialLoginsConfig;
|
|
93
94
|
externalWalletsConfig: Record<string, BaseConnectorConfig>;
|
|
94
95
|
detailedLoaderConnector: string;
|
|
@@ -205,3 +206,8 @@ export declare enum TOAST_TYPE {
|
|
|
205
206
|
INFO = "info"
|
|
206
207
|
}
|
|
207
208
|
export type ToastType = (typeof TOAST_TYPE)[keyof typeof TOAST_TYPE];
|
|
209
|
+
export interface ValidatePhoneNumberApiResponse {
|
|
210
|
+
success: boolean;
|
|
211
|
+
parsed_number: string;
|
|
212
|
+
country_flag: string;
|
|
213
|
+
}
|
|
@@ -7,6 +7,7 @@ export declare class LoginModal {
|
|
|
7
7
|
private chainNamespaces;
|
|
8
8
|
private walletRegistry;
|
|
9
9
|
private callbacks;
|
|
10
|
+
private externalWalletsConfig;
|
|
10
11
|
constructor(uiConfig: LoginModalProps, callbacks: LoginModalCallbacks);
|
|
11
12
|
get isDark(): boolean;
|
|
12
13
|
initModal: () => Promise<void>;
|
|
@@ -23,7 +24,6 @@ export declare class LoginModal {
|
|
|
23
24
|
private handleExternalWalletClick;
|
|
24
25
|
private handleSocialLoginClick;
|
|
25
26
|
private setState;
|
|
26
|
-
private updateWalletConnect;
|
|
27
27
|
private handleConnectorData;
|
|
28
28
|
private subscribeCoreEvents;
|
|
29
29
|
}
|