npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@chainbrary/web3-login

v16.0.26

Published

This package provides a simple and customizable Web3 login modal for Angular applications. It supports account and network change events and provides methods to interact with the Ethereum blockchain.

Downloads

132

Readme

@chainbrary/web3-login

This package provides a simple and customizable Web3 login modal for Angular applications. It supports account and network change events and provides methods to interact with the Ethereum blockchain.

Installation

Use the package manager npm to install @chainbrary/web3-login.

npm install @chainbrary/web3-login

Usage

Import the Web3LoginModule into your Angular application and add it to the imports array in the @NgModule decorator of your AppModule:

import { Web3LoginModule } from '@chainbrary/web3-login';

@NgModule({
  imports: [Web3LoginModule]
})
export class AppModule {}

Inject the Web3LoginService into your component or service where you want to use the Web3 login functionality:

import { Web3LoginService } from '@chainbrary/web3-login';

constructor(private web3LoginService: Web3LoginService) {}

Use the service methods as needed:

Opening the login modal

To open the login modal, call the openLoginModal() method. This method returns an EventEmitter that emits a IModalState object containing the current state of the modal (either 'opened' or 'closed').

const stateEvent = this.web3LoginService.openLoginModal();

stateEvent.subscribe((state: IModalState) => {
  // Handle the modal state here
});

Closing the login modal

To close the login modal programmatically, call the closeLoginModal() method.

this.web3LoginService.closeLoginModal();

Listening to account changes

To listen for account changes, use the onAccountChangedEvent$ observable:

this.web3LoginService.onAccountChangedEvent$.subscribe((account: string | undefined) => {
  // Handle account changes here
});

Listening to chain changes

To listen for chain changes, use the onChainChangedEvent$ observable:

this.web3LoginService.onChainChangedEvent$.subscribe(({ chainId, networkName }) => {
  // Handle chain changes here
});

Accessing the Current Network

Subscribe to the currentNetwork$ observable to get the current network details:

this.web3LoginService.currentNetwork$.subscribe((networkDetail: INetworkDetail | null) => {
  // Handle current network details here
});

Obtaining Network Information

Use getNetworkDetailByChainId(chainId: string | null) to get detailed information about a network based on its chain ID:

const networkDetail = this.web3LoginService.getNetworkDetailByChainId(chainId);

Customization

To customize the appearance of the login modal, modify the following CSS classes in your application:

.web3-login-modal: The modal container
.web3-login-header: The modal header
.web3-login-content: The modal content
.web3-login-footer: The modal footer

Feedback and Improvements

We value your feedback and are committed to continuously improving the Chainbrary library. Your suggestions, comments, and ideas will help shape the future of this project. Please don't hesitate to share your thoughts with us through the contact channels listed above. We will strive to incorporate your feedback into future updates to enhance the library for all users.

Contact Us

For any questions, feedback, or concerns, please feel free to contact us through the following channels:

License

The @chainbrary/web3-login package is released under the MIT License.

Let me know if you need any additional information or if you have any questions.