2.0.123 • Published 8 months ago

@cryptogate/react-ui v2.0.123

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

Cryptogate/react-ui

Installation

Using yarn:

yarn add @Cryptogate/react-ui

Using npm:

npm install @Cryptogate/react-ui

Required Dependecies

  • "@cryptogate/react-providers": "^0.0.34"
  • "@cryptogate/core": "^0.0.10"
  • "@metamask/detect-provider": "^1.2.0"
  • "ethers": "^5.6.4"
  • "react-device-detect": "^2.2.2"
  • "react-jazzicon": "^1.0.3"
  • "react-slick": "^0.29.0"
  • "slick-carousel": "^1.8.1"

ConnectWalletComponent

This all in one component is built to assist developers in integrating web3 authentication in 3 minutes.

Usage

Step 1: Import the component:

import {ConnectWalletComponent} from "@cryptogate/react-ui"

Step 2: Simply render this component:

import {ConnectWalletComponent} from "@cryptogate/react-ui"

<div>
    <ConnectWalletComponent/>
</div>

Step 3: Add the list of accepted wallets. How about we add METAMASK?

import {ConnectWalletComponent, EthWallets} from "@cryptogate/react-ui"

<div>
    <ConnectWalletComponent
        EthWalletList={[EthWallets.METAMASK]}
    />
</div>

For more details on customizing your own wallet list, check How To Customize My Wallet List

Additional Step: To request a signature, add an onSign callback prop:

import {ConnectWalletComponent, EthWallets} from "@cryptogate/react-ui"

<div>
    <ConnectWalletComponent
        EthWalletList={[EthWallets.METAMASK]}
        onSign={(key) => {console.log(key)}}
    />
</div>

After signing, a key object is created and saved in the localStorage. check onSign Method for the object format.

And that's it.. Congratulations on integrating a Customized Web3 Authentication. For more customization, check the Props List

Props

PropTypeDescriptionDefault
ActiveComponentReact NodeThe first componenet renderedcheck default
Disabled ComponentReact NodeRendered while the message is being signedcheck default
ConnectedComponentReact NodeThis componenet is rendered after signing successfullyIdenticon
EthWalletListnumbers[]Array of accepted ethereum wallets, check Customize Wallet List[]
SolWalletListnumbers[]Array of accepted solana wallets, check Customize Wallet List[]
onSignfunctionCalled after signing a message, check onSign Method
SignatureMessagestringThe message used on signing"This is the default signaure message provided by Cryptogate."
NetworkChainIdsnumbers[]Array of supported networks1 (Ethereum Mainnnet)
NetworkAlertMessagestringAlert message when user connects with an unsupported network"Selected network is not supported."
ConnectedMenuChosenConnectedMenuOptionsThe menu to show when clicking on the Connected Component, check Connected Menu OptionsWALLETINFORMATION
WalletListStyleJSONObject that takes two entries: top and background to change the style of wallets lists popup{top: '0', background: 'white'}

Default Active Component

Default Disabled Component

On Sign Method

The onSign Method takes a key parameter, this key is the value saved in the local storage after signing. The object is in the form of:

{
  address: "<address used to sign>",
  message: "This is the default signaure message provided by Cryptogate." // or the message passed in the SignatureMessage prop,
  signature: "<The signed message>"
}

The onSign Method format:

  (key) => {console.log(key)}

Connected Menu

Cryptogate provides a variety of options when it comes to choosing menu. You can either choose the simple Wallet Information menu, or go with the fully customized Cryptogate Store

In all cases, the ChosenConnectedMenu isOpen and onClose props should always be included

PropTypeDescription
isOpenbooleanA flag if the menu if open or not
onClosefunctionA function called when closing the menu
ChosenConnectedMenuConnnectedMenuOptionsThe menu type you need, check Connected Menu Options for more info
onDisconnectfunctionCallback function after disconnecting
StoreobjectObject constructed from the list of Token & NFT Collection addresses. Check the Store object format

Wallet Information

A simple menu that shows the users wallet information. Balance, wallet address, ENS (if available) and a disconnect button.

Usage

Step 1: Import the component and it's options

import {ConnectedMenu, ConnectedMenuOptions} from "@cryptogate/react-ui"

Step 2: Then render this component with the WalletInformation Option:

import {ConnectedMenu, ConnectedMenuOptions} from "@cryptogate/react-ui"

<div>
    <ConnectedMenu
        isOpen = {isMenuOpen} // isMenuOpen is a state variable
        onClose = {() => seIsMenuOpen(false)}
        ChosenConnectedMenu = {ConnectedMenuOptions.WALLETINFORMATION}
        onDisconnect = {() => router.push("/")}
    />
</div>

Cryptogate Store

A fully customized store. Pass the ConnectedMenuOptions.STORE option and a Store prop. Check the Store object format

Usage

Step 1: Import the component and it's options

import {ConnectedMenu, ConnectedMenuOptions} from "@cryptogate/react-ui"

Step 2: Then render this component with the Store Option:

import {ConnectedMenu, ConnectedMenuOptions} from "@cryptogate/react-ui"

<div>
    <ConnectedMenu
        isOpen = {isMenuOpen} // isMenuOpen is a state variable
        onClose = {() => seIsMenuOpen(false)}
        ChosenConnectedMenu = {ConnectedMenuOptions.STORE}
        onDisconnect = {() => router.push("/")}
        Store = {
            {
                Tokens: [
                    "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
                ],
                NFTs: [
                    "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D",
                    "0x4feec948eb3d6a2eb37560d4b2c16f1c9fe72ef6"
                ]
            }
        }
    />
</div>

Store

This object contain a list of Token and NFT Collection Addresses. Just construct the object as follows:

    {
        Tokens: [
          "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
        ],
        NFTs: [
          "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D",
          "0x4feec948eb3d6a2eb37560d4b2c16f1c9fe72ef6",
        ],
    }

Identicon

Simply display a customized jazzicon.

Usage

Step 1: Import the component

import {Identicon} from "@cryptogate/react-ui"

Step 2: Render the component

import {Identicon} from "@cryptogate/react-ui"

<Identicon/>

And That's It.. Here's your customized jazzicon:

Customized Wallet List

With cryptogate, you have complete controll over adding/removing wallets from the list. No configuration needed, simply update the props.

Usage:

Let's customize our list of Ethereum wallets

Step 1: Importing the list of supported ethereum wallets

import {EthWallets} from "@cryptogate/react-ui"

Step 2: If we observe the imported object EthWallets, it's an enum of supported wallets. All we have to do is pass the wallets we want in the EthWalletList prop:

import {ConnectWalletComponent, EthWallets} from "@cryptogate/react-ui"

<div>
    <ConnectWalletComponent
        EthWalletList={[EthWallets.METAMASK, EthWallets.COINBASE]}
    />
</div>

The current list of supported ethereum wallets: - Metamask: EthWallets.METAMASK - Coinbase: EthWallets.COINBASE - Wallet Connect: EthWallets.WALLETCONNECT

If you want to add all supported wallets, simply pass the EthWallets.ALL value:

<ConnectWalletComponent
        EthWalletList={[EthWallets.ALL]}
    />

For solana wallets, use the SolWallets,

import {ConnectWalletComponent, EthWallets} from "@cryptogate/react-ui"

<div>
    <ConnectWalletComponent
        EthWalletList={[EthWallets.PHANTOM, EthWallets.SOLFLARE]}
    />
</div>

The current list of supported ethereum wallets: - Phantom: EthWallets.PHANTOM - Slope: EthWallets.SLOPE - Solflare Connect: EthWallets.SOLFLARE

Connected Menu Options

Through these options, you can easily select the menu you need

Usage:

Step 1: Importing the list of available menus

import {ConnectedMenuOptions} from "@cryptogate/react-ui"

Step 2: If we observe the imported object ConnectedMenuOptions, it's an enum of available menus. All we have to do is pass the menu we want in the ConnectedMenuChosen prop:

import {ConnectWalletComponent, ConnectedMenuOptions} from "@cryptogate/react-ui"

<div>
    <ConnectWalletComponent
        ConnectedMenuChosen={ConnectedMenuOptions.STORE}
    />
</div>

The current list of available menus: - No Menu: EthWallets.NOMENU - Wallet Information : EthWallets.WALLETINFORMATION - Cryptogate Store: EthWallets.STORE

2.0.109

10 months ago

2.0.119

9 months ago

2.0.118

9 months ago

2.0.117

9 months ago

2.0.116

10 months ago

2.0.115

10 months ago

2.0.114

10 months ago

2.0.113

10 months ago

2.0.112

10 months ago

2.0.111

10 months ago

2.0.110

10 months ago

2.0.123

8 months ago

2.0.122

8 months ago

2.0.121

8 months ago

2.0.120

9 months ago

2.0.108

10 months ago

2.0.107

10 months ago

2.0.106

10 months ago

2.0.105

10 months ago

2.0.104

10 months ago

2.0.88

10 months ago

2.0.103

10 months ago

2.0.89

10 months ago

2.0.102

10 months ago

2.0.86

10 months ago

2.0.101

10 months ago

2.0.87

10 months ago

2.0.100

10 months ago

2.0.84

10 months ago

2.0.85

10 months ago

2.0.99

10 months ago

2.0.97

10 months ago

2.0.98

10 months ago

2.0.95

10 months ago

2.0.96

10 months ago

2.0.93

10 months ago

2.0.94

10 months ago

2.0.91

10 months ago

2.0.92

10 months ago

2.0.90

10 months ago

2.0.79

11 months ago

2.0.78

11 months ago

2.0.82

11 months ago

2.0.83

11 months ago

2.0.80

11 months ago

2.0.81

11 months ago

2.0.77

11 months ago

2.0.75

11 months ago

2.0.76

11 months ago

2.0.73

11 months ago

2.0.74

11 months ago

2.0.71

11 months ago

2.0.72

11 months ago

2.0.70

11 months ago

2.0.59

12 months ago

2.0.57

12 months ago

2.0.58

12 months ago

2.0.55

12 months ago

2.0.56

12 months ago

2.0.53

12 months ago

2.0.54

12 months ago

2.0.51

12 months ago

2.0.52

12 months ago

2.0.50

1 year ago

2.0.68

11 months ago

2.0.69

11 months ago

2.0.66

11 months ago

2.0.67

11 months ago

2.0.64

11 months ago

2.0.65

11 months ago

2.0.62

12 months ago

2.0.63

12 months ago

2.0.60

12 months ago

2.0.61

12 months ago

2.0.48

1 year ago

2.0.49

1 year ago

2.0.46

1 year ago

2.0.47

1 year ago

2.0.45

1 year ago

2.0.44

1 year ago

2.0.42

1 year ago

2.0.43

1 year ago

2.0.28

1 year ago

2.0.29

1 year ago

2.0.37

1 year ago

2.0.38

1 year ago

2.0.35

1 year ago

2.0.36

1 year ago

2.0.33

1 year ago

2.0.31

1 year ago

2.0.32

1 year ago

2.0.30

1 year ago

2.0.39

1 year ago

2.0.40

1 year ago

2.0.41

1 year ago

2.0.27

1 year ago

2.0.4-alpha.0

1 year ago

2.0.0-alpha.0

1 year ago

2.0.7-alpha.0

1 year ago

2.0.3-alpha.0

1 year ago

2.0.12-alpha.0

1 year ago

2.0.6-alpha.0

1 year ago

2.0.2-alpha.0

1 year ago

2.0.9-alpha.0

1 year ago

2.0.11-alpha.0

1 year ago

2.0.5-alpha.0

1 year ago

2.0.10-alpha.0

1 year ago

2.0.15

1 year ago

2.0.16

1 year ago

2.0.13

1 year ago

2.0.1-alpha.0

1 year ago

2.0.14

1 year ago

2.0.12

1 year ago

2.0.8-alpha.0

1 year ago

2.0.19

1 year ago

2.0.17

1 year ago

2.0.18

1 year ago

2.0.26

1 year ago

2.0.24

1 year ago

2.0.25

1 year ago

2.0.22

1 year ago

2.0.23

1 year ago

2.0.20

1 year ago

2.0.21

1 year ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.26

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.27

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

0.0.106

2 years ago

0.0.105

2 years ago

0.0.104

2 years ago

0.0.103

2 years ago

0.0.108

2 years ago

0.0.107

2 years ago

0.0.102

2 years ago

0.0.101

2 years ago

0.0.100

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

0.0.95

2 years ago

0.0.96

2 years ago

0.0.97

2 years ago

0.0.98

2 years ago

0.0.99

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

0.0.94

2 years ago

0.0.84

2 years ago

0.0.85

2 years ago

0.0.86

2 years ago

0.0.87

2 years ago

0.0.88

2 years ago

0.0.89

2 years ago

0.0.80

2 years ago

0.0.81

2 years ago

0.0.82

2 years ago

0.0.83

2 years ago

0.0.73

2 years ago

0.0.74

2 years ago

0.0.75

2 years ago

0.0.76

2 years ago

0.0.77

2 years ago

0.0.78

2 years ago

0.0.79

2 years ago

0.0.90

2 years ago

0.0.91

2 years ago

0.0.92

2 years ago

0.0.93

2 years ago

0.0.72

2 years ago

0.0.71

2 years ago

0.0.70

2 years ago

0.0.69

2 years ago

0.0.68

2 years ago

0.0.67

2 years ago

0.0.66

2 years ago

0.0.65

2 years ago

0.0.64

2 years ago

0.0.63

2 years ago

0.0.62

2 years ago

0.0.61

2 years ago

0.0.60

2 years ago

0.0.59

2 years ago

0.0.58

2 years ago

0.0.57

2 years ago

0.0.56

2 years ago

0.0.55

2 years ago

0.0.54

2 years ago

0.0.53

2 years ago

0.0.52

2 years ago

0.0.51

2 years ago

0.0.50

2 years ago

0.0.50-alpha.0

2 years ago

0.0.49

2 years ago

0.0.49-alpha.0

2 years ago

0.0.46

2 years ago

0.0.44

2 years ago

0.0.43

2 years ago

0.0.42

2 years ago

0.0.41

2 years ago

0.0.40

2 years ago

0.0.39

2 years ago

0.0.38

2 years ago

0.0.37

2 years ago

0.0.36

2 years ago

0.0.35

2 years ago

0.0.34

2 years ago

0.0.33

2 years ago

0.0.32

2 years ago

0.0.31

2 years ago

0.0.30

2 years ago

0.0.29

2 years ago

0.0.28

2 years ago

0.0.27

2 years ago

0.0.26

2 years ago

0.0.25

2 years ago

0.0.24

2 years ago

0.0.23

2 years ago

0.0.22

2 years ago

0.0.21

2 years ago

0.0.20

2 years ago

0.0.19

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago