Skip to content

Commit

Permalink
Merge pull request #1486 from Web3Auth/alpha-v2
Browse files Browse the repository at this point in the history
Alpha v2
  • Loading branch information
chaitanyapotti authored Jun 12, 2023
2 parents cd68f4b + 8c69bd8 commit 4f46054
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 50 deletions.
52 changes: 21 additions & 31 deletions package-lock.json

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

19 changes: 19 additions & 0 deletions packages/adapters/metamask-adapter/src/metamaskAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,25 @@ class MetamaskAdapter extends BaseEvmAdapter<void> {
async connect(): Promise<SafeEventEmitterProvider | null> {
super.checkConnectionRequirements();
if (!this.metamaskProvider) throw WalletLoginError.notConnectedError("Not able to connect with metamask");
const { ethereum } = window as any;
const isPhantom = Boolean("isPhantom" in ethereum);
// check which is the active provider
if (ethereum && ethereum.isMetaMask && isPhantom) {
// this means phantom is the active provider.
if (ethereum.providers && ethereum.providers.length > 0) {
const provider = ethereum.providers.find((p: any) => p.isMetaMask && !p.overrideIsMetaMask);

if (provider) {
ethereum.setProvider(provider);
}
}
} else if (ethereum && (ethereum.providers || []).length > 0) {
// this means that there are another providers than metamask (like coinbase).
const provider = ethereum.providers.find((p: any) => p.isMetaMask);
if (provider) {
ethereum.setSelectedProvider(provider);
}
}

this.status = ADAPTER_STATUS.CONNECTING;
this.emit(ADAPTER_EVENTS.CONNECTING, { adapter: WALLET_ADAPTERS.METAMASK });
Expand Down
2 changes: 1 addition & 1 deletion packages/adapters/openlogin-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@types/lodash.merge": "^4.6.7"
},
"dependencies": {
"@toruslabs/openlogin": "^4.5.3",
"@toruslabs/openlogin": "^4.5.4",
"@toruslabs/openlogin-utils": "^4.5.1",
"@web3auth/base": "^6.0.1-alpha.0",
"@web3auth/base-provider": "^6.0.1-alpha.0",
Expand Down
10 changes: 2 additions & 8 deletions packages/adapters/openlogin-adapter/src/openloginAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import OpenLogin, { getHashQueryParams } from "@toruslabs/openlogin";
import OpenLogin from "@toruslabs/openlogin";
import { LoginParams, OPENLOGIN_NETWORK, OpenLoginOptions, SUPPORTED_KEY_CURVES, UX_MODE } from "@toruslabs/openlogin-utils";
import {
ADAPTER_CATEGORY,
Expand Down Expand Up @@ -86,14 +86,8 @@ export class OpenloginAdapter extends BaseAdapter<OpenloginLoginParams> {
super.checkInitializationRequirements();
if (!this.clientId) throw WalletInitializationError.invalidParams("clientId is required before openlogin's initialization");
if (!this.openloginOptions) throw WalletInitializationError.invalidParams("openloginOptions is required before openlogin's initialization");
let isRedirectResult = false;
const isRedirectResult = this.openloginOptions.uxMode === UX_MODE.REDIRECT;

if (this.openloginOptions.uxMode === UX_MODE.REDIRECT) {
const redirectResult = getHashQueryParams();
if (Object.keys(redirectResult).length > 0 && redirectResult.sessionId) {
isRedirectResult = true;
}
}
this.openloginOptions = {
...this.openloginOptions,
replaceUrlOnRedirect: isRedirectResult,
Expand Down
2 changes: 1 addition & 1 deletion packages/adapters/torus-evm-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@babel/runtime": "^7.x"
},
"dependencies": {
"@toruslabs/torus-embed": "^2.1.0",
"@toruslabs/torus-embed": "^2.1.1",
"@web3auth/base": "^6.0.1-alpha.0",
"@web3auth/base-evm-adapter": "^6.0.1-alpha.0"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/adapters/wallet-connect-v2-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
},
"devDependencies": {
"@types/lodash.merge": "^4.6.7",
"@walletconnect/sign-client": "^2.7.8",
"@walletconnect/types": "^2.7.8",
"@walletconnect/utils": "^2.7.8"
"@walletconnect/sign-client": "^2.8.0",
"@walletconnect/types": "^2.8.0",
"@walletconnect/utils": "^2.8.0"
},
"lint-staged": {
"!(*d).ts": [
Expand Down
2 changes: 1 addition & 1 deletion packages/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"dependencies": {
"@toruslabs/http-helpers": "^4.0.0",
"@toruslabs/openlogin": "^4.5.3",
"@toruslabs/openlogin": "^4.5.4",
"@toruslabs/openlogin-jrpc": "^4.5.1",
"@toruslabs/openlogin-utils": "^4.5.1",
"jwt-decode": "^3.1.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/no-modal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@babel/runtime": "^7.x"
},
"dependencies": {
"@toruslabs/openlogin": "^4.5.3",
"@toruslabs/openlogin": "^4.5.4",
"@toruslabs/openlogin-jrpc": "^4.5.1",
"@toruslabs/openlogin-utils": "^4.5.1",
"@web3auth/base": "^6.0.1-alpha.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"eth-rpc-errors": "^4.0.3"
},
"dependencies": {
"@toruslabs/torus-embed": "^2.1.0",
"@toruslabs/torus-embed": "^2.1.1",
"@web3auth/base": "^6.0.1-alpha.0",
"@web3auth/base-plugin": "^6.0.1-alpha.0",
"@web3auth/no-modal": "^6.0.2-alpha.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@toruslabs/isomorphic-style-loader": "^5.3.3",
"@types/lodash.clonedeep": "^4.5.7",
"@types/lodash.merge": "^4.6.7",
"@types/react": "^18.2.9",
"@types/react": "^18.2.11",
"@types/react-dom": "^18.2.4",
"@typescript-eslint/eslint-plugin": "^5.59.9",
"autoprefixer": "^10.4.14",
Expand All @@ -59,7 +59,7 @@
"eslint-plugin-simple-import-sort": "^10.0.0",
"live-server": "^1.2.2",
"postcss": "^8.4.24",
"postcss-loader": "^7.3.2",
"postcss-loader": "^7.3.3",
"postcss-prefix-selector": "^1.16.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand All @@ -70,7 +70,7 @@
},
"dependencies": {
"@toruslabs/http-helpers": "^4.0.0",
"@toruslabs/openlogin": "^4.5.3",
"@toruslabs/openlogin": "^4.5.4",
"@toruslabs/openlogin-jrpc": "^4.5.1",
"@toruslabs/openlogin-utils": "^4.5.1",
"@web3auth/base": "^6.0.1-alpha.0",
Expand Down

0 comments on commit 4f46054

Please sign in to comment.