Skip to content

Commit

Permalink
Merge pull request #97 from getsafle/feat-fix-UI
Browse files Browse the repository at this point in the history
keyless-js fixes
  • Loading branch information
sshubhamagg authored Nov 14, 2023
2 parents 8b2b7fc + dd48d5f commit 29d764f
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 89 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,8 @@

* Goto dashboard on successful transaction.

* Handle widget closing on transaction complete
* Handle widget closing on transaction complete

### 2.0.3 (2023-11-13)

* Connection error fixes and reload page fixes
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@getsafle/safle-keyless-js",
"version": "2.0.2",
"version": "2.0.3",
"description": "",
"main": "dist/index.js",
"scripts": {
Expand Down
208 changes: 131 additions & 77 deletions src/networks.ts
Original file line number Diff line number Diff line change
@@ -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",
},
};
18 changes: 11 additions & 7 deletions src/widgetManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 29d764f

Please sign in to comment.