1.0.0 • Published 10 months ago

web3modal-connector-oreid v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
10 months ago

Oreid Web3-Modal Connector

OreidWalletConnector is a JavaScript class that helps you connect your application to different blockchain networks using the ORE ID service, which is an universal blockchain account service. This connector makes it easier to manage different chains and accounts in your dApp, by abstracting the underlying complexity involved in connecting to multiple chains.

Dependencies

This package uses the following dependencies:

  • "wagmi": An abstraction layer that provides a common interface and hooks for interacting with ethereum.
  • "oreid-js": The ORE ID library, which simplifies the process of integrating blockchain user authentication into any app.
  • "viem": A typescript interface for ethereum
  • "oreid-provider": Oreid-js's EIP-1193 provider.

Key Components

  • ChainNameIdMappings: An object containing chain names and their corresponding IDs.
  • OreidWalletConnector Class: The main class in this module. It extends the Connector class from the wagmi library, providing integration with ORE ID.
  • Constructor: The constructor method is used to initialize the class. It sets up the chains, checks if they are supported by OreID, and creates an OreID instance.
  • connect method: This method is used to connect the application to a blockchain network. It initializes the OreId SDK, authenticates the user, selects the correct account and then emits a connect event.
  • disconnect method: This method is used to disconnect the wallet from the application. It removes relevant data from local storage and logs out from OreID.
  • getWalletClient method: This method returns a wallet client that can be used to interact with the chain.
  • getAccount method: This method is used to get the current selected account.
  • switchChain method: This method is used to switch to a different blockchain.

High level flow and lifecycle

On installation wagmi will:

  • Consume an instance of the OreidWalletConnector class.
  • Underlying methods like connect are called by wagmi under the hood using OreId's EIP-1193 provider.
  • The same will be true for other EVM methods like sendTransaction and signMessage.

Events

The OreidWalletConnector class emits several events that you can listen to:

  • connect: Fired when the connection is successfully established.
  • disconnect: Fired when the user disconnects their wallet.
  • change: Fired when the selected chain or account is changed.