Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0neerpat committed Feb 18, 2021
1 parent f9331c7 commit f2990be
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
30 changes: 19 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,38 @@
</a>
</p>

> Auth provider for RedwoodJS using Ethererum.
> Ethereum auth provider for RedwoodJS
This package was inspired from a [lengthy tutorial](https://patrickgallagher.dev/blog/2020/12/27/tutorial-redwood-web3-login/tutorial-add-web3-login-to-redwoodjs) I wrote on adding Ethereum auth to Redwood. If you're planning to implement your own custom auth to RedwoodJS (aside from Ethereum), you may find that tutorial useful.
Looking to implement your own custom Redwood Auth? You may this [tutorial](https://patrickgallagher.dev/blog/2020/12/27/tutorial-redwood-web3-login/tutorial-add-web3-login-to-redwoodjs) helpful.

### [Demo](https://redwood-ethereum-login-demo.vercel.app/)

Demo [source code](https://github.com/oneclickdapp/redwood-ethereum-login-demo)

## Overview
<div align="center" >
<img margin="0 0 10px" width="500" src="./ocd-ethereum-auth.gif"/>
</div>

This package enables the full suite of tooling that `@redwoodjs/auth` provides. Read more about auth in the official RedwoodJS docs https://redwoodjs.com/docs/authentication
## Quick Start

```js
import { useAuth } from "@redwoodjs/auth";
const ethereum = new EthereumAuthClient({
makeRequest,
debug: process.NODE_ENV !== "development",
infuraId: process.env.INFURA_ID
});

const LoginPage = () => {
const { logIn } = useAuth();
const { logIn, logOut, getCurrentUser, client } = useAuth();

const onClick = async () => {
// Trigger wallet unlock & message signature
await logIn();
};
// Trigger authentication
await logIn("walletConnect");

// Access the ethers provider directly
await client.provider.getSigner();
```

If this is your first time using Redwood Auth, you should check out the official Redwood [auth docs](https://redwoodjs.com/docs/authentication)

## Setup

If you haven't created a redwood app yet, you can do so now. See my [introductory blog post](https://patrickgallagher.dev/blog/2020/11/18/web3-redwood-intro/using-redwoodjs-to-create-an-ethereum-app) for more help getting started.
Expand Down
Binary file added ocd-ethereum-auth.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@oneclickdapp/ethereum-auth",
"version": "0.2.0",
"description": "Auth provider for RedwoodJS using Ethererum",
"version": "0.2.1",
"description": "Ethereum auth provider for RedwoodJS",
"author": "Patrick Gallagher <[email protected]>",
"main": "dist/index.js",
"module": "src/index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class EthereumAuthClient {

async login(type = WALLET_TYPES.browser) {
try {
const isWalletConnect = WALLET_TYPES.walletConnect;
const isWalletConnect = type === WALLET_TYPES.walletConnect;
let unlock = unlockBrowser;
if (isWalletConnect) {
if (!this.rpc && !this.infuraId)
Expand Down

0 comments on commit f2990be

Please sign in to comment.