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

v1.0.0-beta.26 #103

Closed
wants to merge 8 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
317 changes: 109 additions & 208 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,72 +40,19 @@ yarn add @walletconnect/web3-provider @portis/web3 fortmatic squarelink @torusla

- [React Button](#React-Button)
- [Core Module](#Core-Module)
- [Individual Connectors](#Individual-Connectors)

### React Button

Add Web3Connect Button to your React App as follows

```js
import Web3Connect from "web3connect";
import WalletConnectProvider from "@walletconnect/web3-provider";
import Portis from "@portis/web3";
import Fortmatic from "fortmatic";
import Squarelink from "squarelink";
import Torus from "@toruslabs/torus-embed";
import Arkane from "@arkane-network/web3-arkane-provider";
import Authereum from "authereum";

const providerOptions = { /* See Provider Options Section */ }

<Web3Connect.Button
network="mainnet" // optional
providerOptions={{
walletconnect: {
package: WalletConnectProvider, // required
options: {
infuraId: "INFURA_ID" // required
}
},
portis: {
package: Portis, // required
options: {
id: "PORTIS_ID" // required
}
},
fortmatic: {
package: Fortmatic, // required
options: {
key: "FORTMATIC_KEY" // required
}
},
squarelink: {
package: Squarelink, // required
options: {
id: "SQUARELINK_ID" // required
}
},
torus: {
package: Torus, // required
options: {
enableLogging: false, // optional
buttonPosition: "bottom-left", // optional
buildEnv: "production", // optional
showTorusButton: true, // optional
enabledVerifiers: { // optional
google: false // optional
}
}
},
arkane: {
package: Arkane, // required
options: {
clientId: "ARKANE_CLIENT_ID" // required, replace
}
},
authereum: {
package: Authereum, // required
options: {}
}
}}
providerOptions={providerOptions}
onConnect={(provider: any) => {
const web3 = new Web3(provider); // add provider to web3
}}
Expand All @@ -129,56 +76,13 @@ import Torus from "@toruslabs/torus-embed";
import Arkane from "@arkane-network/web3-arkane-provider";
import Authereum from "authereum";

const providerOptions = {
/* See Provider Options Section */
};

const web3Connect = new Web3Connect.Core({
network: "mainnet", // optional
providerOptions: {
walletconnect: {
package: WalletConnectProvider, // required
options: {
infuraId: "INFURA_ID" // required
}
},
portis: {
package: Portis, // required
options: {
id: "PORTIS_ID" // required
}
},
fortmatic: {
package: Fortmatic, // required
options: {
key: "FORTMATIC_KEY" // required
}
},
squarelink: {
package: Squarelink, // required
options: {
id: "SQUARELINK_ID" // required
}
},
torus: {
package: Torus, // required
options: {
enableLogging: false, // optional
buttonPosition: "bottom-left", // optional
buildEnv: "production", // optional
showTorusButton: true, // optional
enabledVerifiers: { // optional
google: false // optional
}
}
},
arkane: {
package: Arkane, // required
options: {
clientId: "ARKANE_CLIENT_ID" // required, replace
}
},
authereum: {
package: Authereum, // required
options: {}
}
}
providerOptions: providerOptions
});

// subscribe to connect
Expand All @@ -194,66 +98,118 @@ web3Connect.on("close", () => {
web3Connect.toggleModal(); // open modal on button click
```

### Individual Connectors
## Provider Options

Add individual connectors for each provider to your own UI (no modal provided)
These are all the providers available with Web3Connect and how to configure their provider options

```js
import Web3Connect from "web3connect";
### WalletConnect

```typescript
import WalletConnectProvider from "@walletconnect/web3-provider";

const providerOptions = {
walletconnect: {
package: WalletConnectProvider, // required
options: {
infuraId: "INFURA_ID" // required
}
}
};
```

### Portis

```typescript
import Portis from "@portis/web3";

const providerOptions = {
portis: {
package: Portis, // required
options: {
id: "PORTIS_ID" // required
}
}
};
```

### Fortmatic

```typescript
import Fortmatic from "fortmatic";

const providerOptions = {
fortmatic: {
package: Fortmatic, // required
options: {
key: "FORTMATIC_KEY" // required
}
}
};
```

### Squarelink

```typescript
import Squarelink from "squarelink";
import Torus from "@toruslabs/torus-embed";
import Authereum from "authereum";

// For inject providers in dapp browsers
const provider = await Web3Connect.ConnectToInjected();
const providerOptions = {
squarelink: {
package: Squarelink, // required
options: {
id: "SQUARELINK_ID" // required
}
}
};
```

### Torus

// For WalletConnect
const provider = await Web3Connect.ConnectToWalletConnect(
WalletConnectProvider,
{
infuraId: "INFURA_ID", // required
bridge: "https://bridge.walletconnect.org" // optional
```typescript
import Torus from "@toruslabs/torus-embed";

const providerOptions = {
torus: {
package: Torus, // required
options: {
enableLogging: false, // optional
buttonPosition: "bottom-left", // optional
buildEnv: "production", // optional
showTorusButton: true, // optional
enabledVerifiers: {
// optional
google: false // optional
}
}
}
);
};
```

// For Portis
const provider = await Web3Connect.ConnectToPortis(Portis, {
id: "PORTIS_ID", // required
network: "mainnet" // optional
});
### Arkane

// For Fortmatic
const provider = await Web3Connect.ConnectToFortmatic(Fortmatic, {
key: "FORTMATIC_KEY", // required
network: "mainnet" // optional
});
```typescript
import Arkane from "@arkane-network/web3-arkane-provider";

// For Squarelink
const provider = await Web3Connect.ConnectToSquarelink(Squarelink, {
id: "SQUARELINK_ID", // required
network: "mainnet" // optional
});
const providerOptions = {
arkane: {
package: Arkane, // required
options: {
clientId: "ARKANE_CLIENT_ID" // required, replace
}
}
};
```

// For Torus
const provider = await Web3Connect.ConnectToTorus(Torus, {
enableLogging: false, // optional
buttonPosition: "bottom-left", // optional
buildEnv: "production", // optional
showTorusButton: true // optional
});
### Authereum

// For Arkane
const provider = await Web3Connect.ConnectToArkane(Arkane, {
key: "ARKANE_CLIENT_ID", // required
environment: "staging" // optional
```typescript
import Authereum from "authereum";

// For Authereum
const provider = await Web3Connect.ConnectToAuthereum(Authereum, {
network: "mainnet" // optional
});
const providerOptions = {
authereum: {
package: Authereum, // required
options: {}
}
};
```

## Utils
Expand Down Expand Up @@ -298,67 +254,12 @@ interface IProviderCallback {
}
```

## Options

- providerOptions (optional): An object mapping arbitrary string that adds the required configuration to multiple web3 providers.

- walletconnect:

- package: dependency injection to enable provider
- options:
- infuraId: the infura app ID registered (required)
- bridge: bridge url (optional)

- portis:

- package: dependency injection to enable provider
- options:
- id: the app id registered (required)
- network: choose initial network name (optional)
- config: additional configuration, like support of Gas Station Network (optional)

- fortmatic:

- package: dependency injection to enable provider
- options:
- key: the secret key (required)
- network: choose initial network name (optional)

- arkane:

- package: dependency injection to enable provider
- options:
- clientId: the client id used by the application (required)
- nodeUrl: choose initial network name (optional)
- environment: the environment to connect to (optional). Production by default, use 'staging' for testing

- squarelink:

- package: dependency injection to enable provider
- options:
- id: the client ID registered (required)
- network: choose initial network name (optional)
- config: additional configuration, like `scope` to use supplemental methods (optional)

- torus:

- package: dependency injection to enable provider
- options:
- enableLogging: enable logging for debugging (optional),
- buttonPosition: set button position (optional),
- buildEnv: set build environment (optional),
- showTorusButton: enable displaying torus button
- enabledVerifiers: disable certain verifiers by passing false against them

- authereum:

- package: dependency injection to enable provider
- options:
- network: choose initial network name (optional)
## Optional Flags

You can disable the injected provider by adding the following flag:
You can enable the following optional flags:

- disableInjectedProvider: true (optional)
- disableInjectedProvider: disable displaying injected provider as an option
- disablePreferredProvider: disable caching preffered provider in localStorage

## Collaboration

Expand Down
4 changes: 2 additions & 2 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@arkane-network/web3-arkane-provider": "0.2.5",
"@arkane-network/web3-arkane-provider": "^0.2.5",
"@portis/web3": "^2.0.0-beta.40",
"@toruslabs/torus-embed": "^0.2.6",
"@walletconnect/web3-provider": "^1.0.0-beta.42",
"authereum": "0.0.4-beta.33",
"authereum": "^0.0.4-beta.68",
"axios": "^0.18.0",
"bignumber.js": "^8.1.1",
"ethereumjs-util": "^6.1.0",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "web3connect",
"version": "1.0.0-beta.25",
"version": "1.0.0-beta.26",
"description": "A single Web3 / Ethereum provider solution for all Wallets",
"keywords": [
"web3",
Expand Down
Loading