diff --git a/CHANGELOG.md b/CHANGELOG.md index 9deda88..7757a60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -74,4 +74,8 @@ * Goto dashboard on successful transaction. -* Handle widget closing on transaction complete \ No newline at end of file +* Handle widget closing on transaction complete + +### 2.0.3 (2023-11-13) + +* Connection error fixes and reload page fixes \ No newline at end of file diff --git a/README.md b/README.md index 2813cda..03d38a8 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ let keyless = new Keyless("mumbaitestnet"); > Once the constructor is intialized, call `init()` to initialize login. ```js - await keyless2.init(true); + await keyless.init(true); ``` > Use `onLogin()` to manage the state of the dApp when the user is loggedIn from Keyless. diff --git a/package-lock.json b/package-lock.json index 773e7e6..5e80732 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/safle-keyless-js", - "version": "2.0.2", + "version": "2.0.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-keyless-js", - "version": "2.0.2", + "version": "2.0.3", "license": "ISC", "dependencies": { "ethereumjs-util": "^5.2.0", diff --git a/package.json b/package.json index d0c23ab..66a87c1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-keyless-js", - "version": "2.0.2", + "version": "2.0.3", "description": "", "main": "dist/index.js", "scripts": { diff --git a/src/networks.ts b/src/networks.ts index 060ff49..e788ce5 100644 --- a/src/networks.ts +++ b/src/networks.ts @@ -1,84 +1,138 @@ -import { INetwork } from './interfaces'; +import { INetwork } from "./interfaces"; export function networkAdapter(network: string | INetwork) { - console.log("NETWORK", network); - const networkObj = typeof network === 'string' ? Object.assign({}, networks[network]) : network; - console.log("NetworkObj",networkObj); + console.log("NETWORK", network); + const networkObj = + typeof network === "string" + ? Object.assign({}, networks[network]) + : network; + console.log("NetworkObj", networkObj); return networkObj.nodeUrl; } const networks: { [key: string]: INetwork } = { - mainnet: { - nodeUrl: 'https://mainnet.infura.io/v3/8faaf4fcbdcc4dd0bee8c87eb4b0315b', - chainId: '1', - }, - goerlitestnet: { - nodeUrl: 'https://goerli.infura.io/v3/8faaf4fcbdcc4dd0bee8c87eb4b0315b', - chainId: '420', - }, - polygonmainnet: { - nodeUrl: 'https://polygon-mainnet.infura.io/v3/8faaf4fcbdcc4dd0bee8c87eb4b0315b', - chainId: '137', - }, - mumbaitestnet: { - nodeUrl: 'https://polygon-mumbai.infura.io/v3/814228beb1ff4d5991988329e57c349c', - chainId: '80001', - }, - optimism: { - nodeUrl: 'https://polygon-mainnet.infura.io/v3/8faaf4fcbdcc4dd0bee8c87eb4b0315b', - chainId: '10', - }, - arbitrum: { - nodeUrl: 'https://arbitrum-mainnet.infura.io/v3/8faaf4fcbdcc4dd0bee8c87eb4b0315b', - chainId: '42161', - }, - velas: { - nodeUrl: 'https://evmexplorer.velas.com/rpc', - chainId: '106', - }, - mantle: { - nodeUrl: 'http://rpc.mantle.xyz/', - chainId: '5000', - }, - bsc: { - nodeUrl: 'https://bsc-dataseed.binance.org', - chainId: '56', - }, - '1': { - nodeUrl: 'https://mainnet.infura.io/v3/8faaf4fcbdcc4dd0bee8c87eb4b0315b', - chainId: '1', - }, - '420': { - nodeUrl: 'https://goerli.infura.io/v3/8faaf4fcbdcc4dd0bee8c87eb4b0315b', - chainId: '420', - }, - '137': { - nodeUrl: 'https://polygon-mainnet.infura.io/v3/8faaf4fcbdcc4dd0bee8c87eb4b0315b', - chainId: '137', - }, - '80001': { - nodeUrl: 'https://polygon-mumbai.infura.io/v3/814228beb1ff4d5991988329e57c349c', - chainId: '80001', - }, - '10': { - nodeUrl: 'https://polygon-mainnet.infura.io/v3/8faaf4fcbdcc4dd0bee8c87eb4b0315b', - chainId: '10', - }, - '42161': { - nodeUrl: 'https://arbitrum-mainnet.infura.io/v3/8faaf4fcbdcc4dd0bee8c87eb4b0315b', - chainId: '42161', - }, - '106': { - nodeUrl: 'https://evmexplorer.velas.com/rpc', - chainId: '106', - }, - '5000': { - nodeUrl: 'http://rpc.mantle.xyz/', - chainId: '5000', - }, - '56': { - nodeUrl: 'https://bsc-dataseed.binance.org', - chainId: '56', - } - + mainnet: { + nodeUrl: "https://mainnet.infura.io/v3/8faaf4fcbdcc4dd0bee8c87eb4b0315b", + chainId: "1", + }, + goerlitestnet: { + nodeUrl: "https://goerli.infura.io/v3/8faaf4fcbdcc4dd0bee8c87eb4b0315b", + chainId: "420", + }, + polygonmainnet: { + nodeUrl: + "https://polygon-mainnet.infura.io/v3/8faaf4fcbdcc4dd0bee8c87eb4b0315b", + chainId: "137", + }, + mumbaitestnet: { + nodeUrl: + "https://polygon-mumbai.infura.io/v3/814228beb1ff4d5991988329e57c349c", + chainId: "80001", + }, + optimism: { + nodeUrl: + "https://polygon-mainnet.infura.io/v3/8faaf4fcbdcc4dd0bee8c87eb4b0315b", + chainId: "10", + }, + optimismtestnet: { + nodeUrl: + "https://optimism-goerli.infura.io/v3/8faaf4fcbdcc4dd0bee8c87eb4b0315b", + chainId: "420", + }, + arbitrum: { + nodeUrl: + "https://arbitrum-mainnet.infura.io/v3/8faaf4fcbdcc4dd0bee8c87eb4b0315b", + chainId: "42161", + }, + arbitrumtestnet: { + nodeUrl: + "https://arbitrum-goerli.infura.io/v3/8faaf4fcbdcc4dd0bee8c87eb4b0315b", + chainId: "421613", + }, + velas: { + nodeUrl: "https://evmexplorer.velas.com/rpc", + chainId: "106", + }, + velastestnet: { + nodeUrl: "https://evmexplorer.testnet.velas.com/rpc", + chainId: "111", + }, + mantle: { + nodeUrl: "http://rpc.mantle.xyz/", + chainId: "5000", + }, + mantletestnet: { + nodeUrl: "https://rpc.testnet.mantle.xyz", + chainId: "5001", + }, + bsc: { + nodeUrl: "https://bsc-dataseed.binance.org", + chainId: "56", + }, + bsctestnet: { + nodeUrl: "https://data-seed-prebsc-1-s1.binance.org:8545", + chainId: "97", + }, + "1": { + nodeUrl: "https://mainnet.infura.io/v3/8faaf4fcbdcc4dd0bee8c87eb4b0315b", + chainId: "1", + }, + "5": { + nodeUrl: "https://goerli.infura.io/v3/8faaf4fcbdcc4dd0bee8c87eb4b0315b", + chainId: "5", + }, + "137": { + nodeUrl: + "https://polygon-mainnet.infura.io/v3/8faaf4fcbdcc4dd0bee8c87eb4b0315b", + chainId: "137", + }, + "80001": { + nodeUrl: + "https://polygon-mumbai.infura.io/v3/814228beb1ff4d5991988329e57c349c", + chainId: "80001", + }, + "10": { + nodeUrl: + "https://optimism-mainnet.infura.io/v3/8faaf4fcbdcc4dd0bee8c87eb4b0315b", + chainId: "10", + }, + "420": { + nodeUrl: + "https://optimism-goerli.infura.io/v3/8faaf4fcbdcc4dd0bee8c87eb4b0315b", + chainId: "420", + }, + "42161": { + nodeUrl: + "https://arbitrum-mainnet.infura.io/v3/8faaf4fcbdcc4dd0bee8c87eb4b0315b", + chainId: "42161", + }, + "421613": { + nodeUrl: + "https://arbitrum-goerli.infura.io/v3/8faaf4fcbdcc4dd0bee8c87eb4b0315b", + chainId: "421613", + }, + "106": { + nodeUrl: "https://evmexplorer.velas.com/rpc", + chainId: "106", + }, + "111": { + nodeUrl: "https://evmexplorer.testnet.velas.com/rpc", + chainId: "111", + }, + "5000": { + nodeUrl: "http://rpc.mantle.xyz/", + chainId: "5000", + }, + "5001": { + nodeUrl: "https://rpc.testnet.mantle.xyz", + chainId: "5001", + }, + "56": { + nodeUrl: "https://bsc-dataseed.binance.org", + chainId: "56", + }, + "97": { + nodeUrl: "https://data-seed-prebsc-1-s1.binance.org:8545", + chainId: "97", + }, }; diff --git a/src/widgetManager.ts b/src/widgetManager.ts index d1b6e57..666b966 100644 --- a/src/widgetManager.ts +++ b/src/widgetManager.ts @@ -88,21 +88,25 @@ export default class WidgetManager { parentMethod: (res: any) => { console.log("Parent method called!", res); //parseResult(res); - if(res.disconnetKeyless&& this.iframe){ - console.log("disconnecting keyless") + if (res.disconnetKeyless && this.iframe) { + console.log("disconnecting keyless"); this.iframe.style.display = "none"; document.body.removeChild(this.iframe); } - if(res.closeWidget && this.iframe) { - console.log("closing widget") - if(res.resp.isConnected) { + if (res.closeWidget && this.iframe) { + console.log("closing widget"); + if (res.resp.isConnected) { this.iframe.style.display = "none"; } else { - document.body.removeChild(this.iframe); + document.body.removeChild(this.iframe); } - } if (res.loginSuccess && res.isFirstLogin) { + console.log( + "IN WIDGET MANAGER ", + res.data[0], + `${Number(res.currentChain.chainId)}` + ); this._onLogin(res.data[0], `${Number(res.currentChain.chainId)}`); } if (res.isLogout) {