16.0.26 • Published 2 months ago

@chainbrary/web3-login v16.0.26

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

@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.

16.0.26

2 months ago

16.0.25

2 months ago

16.0.23

5 months ago

16.0.24

5 months ago

16.0.21

6 months ago

16.0.22

6 months ago

16.0.20

7 months ago

0.0.16

10 months ago

0.0.17

10 months ago

16.0.14

7 months ago

16.0.15

7 months ago

16.0.9

7 months ago

16.0.12

7 months ago

16.0.8

8 months ago

16.0.13

7 months ago

16.0.7

8 months ago

16.0.18

7 months ago

16.0.19

7 months ago

16.0.16

7 months ago

16.0.17

7 months ago

16.0.10

7 months ago

16.0.11

7 months ago

16.0.2

9 months ago

16.0.1

9 months ago

16.0.0

9 months ago

16.0.6

8 months ago

16.0.5

8 months ago

16.0.3

8 months ago

0.0.11

11 months ago

0.0.12

11 months ago

0.0.13

11 months ago

0.0.14

11 months ago

0.0.15

11 months ago

0.0.10

11 months ago

0.0.9

12 months ago

0.0.8

12 months ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago