Skip to content

Commit

Permalink
Merge pull request #1867 from Web3Auth/feat/mipd-v8
Browse files Browse the repository at this point in the history
MIPD: use EIP-6963 to discover injected EVM providers
  • Loading branch information
chaitanyapotti authored Jul 25, 2024
2 parents 8680d8f + 335abd2 commit dce48f0
Show file tree
Hide file tree
Showing 24 changed files with 3,197 additions and 4,330 deletions.
122 changes: 60 additions & 62 deletions demo/vue-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions demo/vue-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"@web3auth/base": "file:../../packages/base",
"@web3auth/base-evm-adapter": "file:../../packages/adapters/base-evm-adapter",
"@web3auth/base-solana-adapter": "file:../../packages/adapters/base-solana-adapter",
"@web3auth/default-evm-adapter": "^8.10.2",
"@web3auth/default-solana-adapter": "^8.8.0",
"@web3auth/default-evm-adapter": "file:../../packages/adapters/default-evm-adapter",
"@web3auth/default-solana-adapter": "file:../../packages/adapters/default-solana-adapter",
"@web3auth/ethereum-provider": "file:../../packages/providers/ethereum-provider",
"@web3auth/metamask-adapter": "file:../../packages/adapters/metamask-adapter",
"@web3auth/modal": "file:../../packages/modal",
Expand All @@ -31,10 +31,7 @@
"@web3auth/solflare-adapter": "file:../../packages/adapters/solflare-adapter",
"@web3auth/torus-evm-adapter": "file:../../packages/adapters/torus-evm-adapter",
"@web3auth/torus-solana-adapter": "file:../../packages/adapters/torus-solana-adapter",
"@web3auth/torus-wallet-connector-plugin": "file:../../packages/plugins/torus-wallet-connector-plugin",
"@web3auth/wallet-connect-v1-adapter": "file:../../packages/adapters/wallet-connect-v1-adapter",
"@web3auth/wallet-connect-v2-adapter": "file:../../packages/adapters/wallet-connect-v2-adapter",
"@web3auth/wallet-services-connector-plugin": "file:../../packages/plugins/wallet-services-connector-plugin",
"@web3auth/wallet-services-plugin": "^8.10.2",
"lodash": "^4.17.21",
"lodash.merge": "^4.6.2",
Expand Down
40 changes: 6 additions & 34 deletions demo/vue-app/src/chains/ethereum.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

<script lang="ts">
import { OPENLOGIN_NETWORK_TYPE } from "@toruslabs/openlogin-utils";
import { ADAPTER_STATUS, CHAIN_NAMESPACES, CONNECTED_EVENT_DATA, log, LoginMethodConfig, WALLET_ADAPTERS } from "@web3auth/base";
import { ADAPTER_STATUS, CHAIN_NAMESPACES, CONNECTED_EVENT_DATA, CustomChainConfig, log, LoginMethodConfig } from "@web3auth/base";
import { getDefaultExternalAdapters } from "@web3auth/default-evm-adapter";
import { EthereumPrivateKeyProvider } from "@web3auth/ethereum-provider";
import { Web3Auth, Web3AuthOptions } from "@web3auth/modal";
Expand All @@ -42,8 +42,7 @@ import Loader from "../components/loader.vue";
import config from "../config";
import EthRpc from "../rpc/ethRpc.vue";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const ethereumChainConfig: any = {
const ethereumChainConfig: CustomChainConfig = {
chainNamespace: CHAIN_NAMESPACES.EIP155,
rpcTarget: "https://rpc.ankr.com/eth",
blockExplorerUrl: "https://etherscan.io",
Expand All @@ -56,7 +55,7 @@ const ethereumChainConfig: any = {
const ethWeb3AuthOptions: Web3AuthOptions = {
chainConfig: ethereumChainConfig,
enableLogging: true,
clientId: config.clientId.mainnet,
clientId: config.clientId.sapphire_mainnet,
privateKeyProvider: new EthereumPrivateKeyProvider({ config: { chainConfig: ethereumChainConfig } }),
};
Expand All @@ -77,7 +76,7 @@ export default defineComponent({
},
openloginNetwork: {
type: String,
default: "testnet",
default: "sapphire_mainnet",
},
},
data() {
Expand Down Expand Up @@ -157,34 +156,7 @@ export default defineComponent({
this.subscribeAuthEvents(this.web3auth);
await this.web3auth.initModal({
modalConfig: {
[WALLET_ADAPTERS.METAMASK]: {
showOnDesktop: true,
showOnModal: true,
showOnMobile: true,
label: "Metamask",
},
[WALLET_ADAPTERS.WALLET_CONNECT_V2]: {
showOnDesktop: true,
showOnModal: true,
showOnMobile: true,
label: "Wallet Connect",
},
[WALLET_ADAPTERS.TORUS_EVM]: {
showOnDesktop: true,
showOnModal: true,
showOnMobile: true,
label: "Torus",
},
[WALLET_ADAPTERS.OPENLOGIN]: {
showOnDesktop: true,
showOnModal: true,
showOnMobile: true,
label: "OpenLogin",
},
},
});
await this.web3auth.initModal();
} catch (error) {
log.info("error", error);
this.uiConsole("error", error);
Expand All @@ -194,7 +166,7 @@ export default defineComponent({
},
subscribeAuthEvents(web3auth: Web3Auth) {
web3auth.on(ADAPTER_STATUS.CONNECTED, async (data: CONNECTED_EVENT_DATA) => {
this.uiConsole("connected to wallet", data);
this.uiConsole("connected to wallet", data.adapter);
this.provider = web3auth.provider;
this.loginButtonStatus = "Logged in";
});
Expand Down
1 change: 1 addition & 0 deletions demo/vue-app/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export default {
clientId: {
sapphire_mainnet: "BNI_pZZpoH4tqzbDDMKwfLOWujTif_kek4h9QEN271Gu0JheYDPEUHNKMl5Nnw5PGOjK-SOxp1RpUdG9TJufMZk",
mainnet: "BCtbnOamqh0cJFEUYA0NB5YkvBECZ3HLZsKfvSRBvew2EiiKW3UxpyQASSR0artjQkiUOCHeZ_ZeygXpYpxZjOs",
testnet: "BJ6l3_kIQiy6YVL7zDlCcEAvGpGukwFgp-C_0WvNI_fAEeIaoVRLDrV5OjtbZr_zJxbyXFsXMT-yhQiUNYvZWpo",
cyan: "BJ6l3_kIQiy6YVL7zDlCcEAvGpGukwFgp-C_0WvNI_fAEeIaoVRLDrV5OjtbZr_zJxbyXFsXMT-yhQiUNYvZWpo",
Expand Down
10 changes: 9 additions & 1 deletion demo/vue-app/src/home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
<div class="flex-vertical-center ui-mode">
<span class="form-label">Openlogin Network</span>
<span class="form-control radio-group">
<label for="sapphire_mainnet" class="radio-button">
<input type="radio" id="sapphire_mainnet" value="sapphire_mainnet" v-model="form.openloginNetwork" />

Check warning on line 50 in demo/vue-app/src/home.vue

View workflow job for this annotation

GitHub Actions / build (18.x, ubuntu-latest)

Attribute "id" should go before "type"

Check warning on line 50 in demo/vue-app/src/home.vue

View workflow job for this annotation

GitHub Actions / build (18.x, ubuntu-latest)

Attribute "v-model" should go before "value"
Sapphire Mainnet
</label>
<label for="sapphire_devnet" class="radio-button">
<input type="radio" id="sapphire_devnet" value="sapphire_devnet" v-model="form.openloginNetwork" />

Check warning on line 54 in demo/vue-app/src/home.vue

View workflow job for this annotation

GitHub Actions / build (18.x, ubuntu-latest)

Attribute "id" should go before "type"

Check warning on line 54 in demo/vue-app/src/home.vue

View workflow job for this annotation

GitHub Actions / build (18.x, ubuntu-latest)

Attribute "v-model" should go before "value"
Sapphire Devnet
</label>
<label for="mainnet" class="radio-button">
<input id="mainnet" v-model="form.openloginNetwork" type="radio" value="mainnet" />
Mainnet
Expand Down Expand Up @@ -276,7 +284,7 @@ const defaultFormConfig = {
chain: "ethereum",
authMode: "hosted",
selectedUiMode: "default",
openloginNetwork: "testnet",
openloginNetwork: "sapphire_mainnet",
plugins: {
torusWallet: false,
walletServices: true,
Expand Down
Loading

0 comments on commit dce48f0

Please sign in to comment.