Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Infinity Wallet Connector #528

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A single Web3 / Ethereum provider solution for all Wallets

Web3Modal is an easy-to-use library to help developers add support for multiple providers in their apps with a simple customizable configuration.

By default Web3Modal Library supports injected providers like ( **Metamask**,**Brave Wallet**, **Dapper**, **Frame**, **Gnosis Safe**, **Tally**, Web3 Browsers, etc) and **WalletConnect**. You can also easily configure the library to support **Coinbase Wallet**, **Torus**, **Portis**, **Fortmatic** and many more.
By default Web3Modal Library supports injected providers like ( **Metamask**,**Brave Wallet**, **Dapper**, **Frame**, **Gnosis Safe**, **Tally**, Web3 Browsers, etc) and **WalletConnect**. You can also easily configure the library to support **Coinbase Wallet**, **Infinity Wallet**, **Torus**, **Portis**, **Fortmatic** and many more.

## Preview

Expand Down Expand Up @@ -198,6 +198,7 @@ These are all the providers available with Web3Modal and how to configure their

- [WalletConnect](./docs/providers/walletconnect.md)
- [Coinbase Wallet](./docs/providers/coinbasewallet.md)
- [Infinity Wallet](./docs/providers/infinitywallet.md)
- [Fortmatic](./docs/providers/fortmatic.md)
- [Torus](./docs/providers/torus.md)
- [Portis](./docs/providers/portis.md)
Expand Down
23 changes: 23 additions & 0 deletions docs/providers/infinitywallet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Infinity Wallet

1. Install Provider Package

```bash
npm install --save @infinitywallet/infinity-connector

# OR

yarn add @infinitywallet/infinity-connector
```

2. Set Provider Options

```typescript
import * as InfinityWalletConnect from '@infinitywallet/infinity-connector';

const providerOptions = {
infinitywallet: {
package: InfinityWalletConnect
}
};
```
1 change: 1 addition & 0 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"dependencies": {
"@babel/core": "7.12.3",
"@coinbase/wallet-sdk": "^3.0.4",
"@infinitywallet/infinity-connector": "^1.0.6",
"@pmmmwh/react-refresh-webpack-plugin": "0.4.2",
"@svgr/webpack": "5.4.0",
"@testing-library/jest-dom": "^5.11.4",
Expand Down
5 changes: 5 additions & 0 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import WalletConnect from "@walletconnect/web3-provider";
import CoinbaseWalletSDK from "@coinbase/wallet-sdk";
// @ts-ignore
import { Web3Auth } from "@web3auth/web3auth";
// @ts-ignore
import * as InfinityWalletConnect from '@infinitywallet/infinity-connector';

import Button from "./components/Button";
import Column from "./components/Column";
Expand Down Expand Up @@ -238,6 +240,9 @@ class App extends React.Component<any, any> {
infuraId
}
},
infinitywallet: {
package: InfinityWalletConnect
},
coinbasewallet: {
package: CoinbaseWalletSDK,
options: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"ethereum",
"web3modal",
"metamask",
"infinitywallet",
"tally",
"walletconnect",
"portis",
Expand Down
1 change: 1 addition & 0 deletions src/components/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ declare global {
opera: any;
bitkeep: any;
starzwallet: any;
infinitywallet: any;
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ export function getProviderDescription(
case "hardware":
description = `Connect to your ${providerInfo.name} Hardware Wallet`;
break;
case "connectWallet":
description = `Connect to your ${providerInfo.name}`;
break;
default:
break;
}
Expand Down
2 changes: 2 additions & 0 deletions src/providers/connectors/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import injected from "./injected";
import infinitywallet from "./infinitywallet";
import boltx from "./boltx";
import walletconnect from "./walletconnect";
import portis from "./portis";
Expand All @@ -23,6 +24,7 @@ import starzwallet from "./starzwallet";
export {
injected,
walletconnect,
infinitywallet,
boltx,
portis,
torus,
Expand Down
36 changes: 36 additions & 0 deletions src/providers/connectors/infinitywallet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { IAbstractConnectorOptions, getChainId } from "../../helpers";

const ConnectInfinityWallet = async (
InfinityWalletConnect: any,
opts: IAbstractConnectorOptions
) => {
let provider = null;
try {
let chainId = 1;

if (opts) {
chainId =
opts.network && getChainId(opts.network) ? getChainId(opts.network) : 1;
}

if (
typeof (window as any).ethereum !== "undefined" &&
window.ethereum?.isInfinityWallet
) {
const infinitywalletConnector = new InfinityWalletConnect.InfinityWalletConnector(
{
supportedChainIds: [chainId]
}
);
provider = await infinitywalletConnector.getProvider();
} else {
InfinityWalletConnect.openInfinityWallet(window.location.href, chainId);
throw new Error("Not open in Infinity Wallet, or cant find provider");
}
} catch (e) {
throw e;
}
return provider;
};

export default ConnectInfinityWallet;
37 changes: 37 additions & 0 deletions src/providers/logos/infinitywallet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion src/providers/providers/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// @ts-ignore
import WalletConnectLogo from "../logos/walletconnect-circle.svg";
// @ts-ignore
import InfinityWalletLogo from "../logos/infinitywallet.svg";
// @ts-ignore
import PortisLogo from "../logos/portis.svg";
// @ts-ignore
import FortmaticLogo from "../logos/fortmatic.svg";
Expand Down Expand Up @@ -53,6 +55,14 @@ export const WALLETCONNECT: IProviderInfo = {
}
};

export const INFINITYWALLET: IProviderInfo = {
id: "infinitywallet",
name: "Infinity Wallet",
logo: InfinityWalletLogo,
type: "connectWallet",
check: "isInfinitywallet"
};

export const PORTIS: IProviderInfo = {
id: "portis",
name: "Portis",
Expand Down Expand Up @@ -223,4 +233,3 @@ export const STARZWALLET: IProviderInfo = {
type: "injected",
check: "isStarzWallet"
};