0.10.14 • Published 2 years ago

@arteq-io/react-common v0.10.14

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

npm-react-common

A repo to hold all reusable common react components

Connecting wallet and authenticating

important

always set these:

window.chain = "ETHEREUM";
window.network = "RINKEBY";
window.SKEPTICS_BASE_URL="https://skeptic-dev.arteq.auction/skeptic/v1";
ReactDOM.render(
    <React.StrictMode>
      <App />
    </React.StrictMode>,
    document.getElementById('root')
);

if you want to disable reCaptcha (local testing) add also this global variable:

window.DISABLE_RECAPTCHA

or add recaptcha lib in your index.html and set sitekey like so:

window.rcSiteKey = "6LfJSDceAAAAAPLNlczwZMQbOXbATkOZiW0u0GA3";
  • To customize sign message, please set SIGN_MESSAGE environment variable before building your repo

to set sign message, set this global variable:

window.MESSAGE_TO_SIGN = "Welcome to skeptics! signing this message means you agree with our terms of use (https://example.org/temrs-of-use), please sign this message in order to log in"
import { useWallet } from "@arteq-io/react-common";

window.chain = "ETHEREUM";
window.network = "RINKEBY";
window.servicesURL = "[https://skeptics-base-url]";


const WalletConnect = () => {

  const {
    logout,
    account,
    initMetamask,
    isWalletConnected,
    initWalletConnect,
  } = useWallet();

  return (
    <main>
      {isWalletConnected 
        ?  (
          <>
            <h1>Login with wallet</h1>
            <ul>
              <li onClick={initMetamask}>with Metamask</li>
              <li onClick={initWalletConnect}>with WalletConnect</li>
            </ul>
          </>
        ) : (
          <>
            <h2>Wallet Address: {account}</h2>
            <button onClick={logout}>Logout</button>
          </>
        )
      }
    </main>
  );
}

const App = () => (
  <WalletProvider>
    <WalletConnect />
  </WaletProvider>
);

possible issues:

  • you're not using React@17 this package is created based on react 17 and haven't been tested on react 18 which was just released if you've installed react with create-react-app, you can downgrade react to 17 like so:
  • edit package.json and change react from 18 (or any other versions) to 17 in dependecies section
  • rm -rf ./node_modules
  • do a yarn or npm install again
  • change index.jsx to use previous react-dom import and syntax
  • you're using react-scripts>4.0 this version has some issues with source map (because of webpack 5)

it should be fine as long as you disable source-map in .env file:

  • add a line to .env file: GENERATE_SOURCEMAP=false

TODO:

add these functions:

  • login DONE
  • logout DONE
  • profile
  • updateProfile
  • sendEmailOTP
  • verifyEmailOTP
  • balances (nft, ethereum, erc20 token)
0.10.14

2 years ago

0.10.13

2 years ago

0.10.12

2 years ago

0.10.11

2 years ago

0.10.10

2 years ago

0.10.9

2 years ago

0.10.8

2 years ago

0.10.7

2 years ago

0.10.6

2 years ago

0.10.5

2 years ago

0.10.4

2 years ago

0.10.3

2 years ago

0.10.2

2 years ago

0.10.1

2 years ago

0.10.0

2 years ago

0.9.10

2 years ago

0.9.9

2 years ago

0.9.8

2 years ago

0.9.7

2 years ago

0.9.6

2 years ago

0.9.4

2 years ago

0.9.3

2 years ago

0.9.2

2 years ago

0.9.1

2 years ago

0.9.0

2 years ago

0.8.1

2 years ago

0.7.6

2 years ago

0.7.5

2 years ago

0.7.4

2 years ago

0.5.8

2 years ago

0.5.7

2 years ago

0.5.6

2 years ago

0.5.5

2 years ago

0.5.4

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago