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

@zbyte-io/zbyte-wallet-sdk-core

v1.1.2

Published

Core functionality of zbyte wallet, currently is getting consumed by zbyte-wallet-ui-sdk

Downloads

3

Readme

zbyte Wallet core SDK

SDK contains all the core functionality related to zbyte wallet, and can be supported on browser(client side code).

Installation

  • To install the lib use npm below npm command
    npm install @zbyteio/zbyte-wallet-sdk-core

Documentation

  • zbyte core wallet manages the user account creation and worked with DPLAT token.
  • User can see the current DPLAT balance and transfer it to another account.
  • Supported blockchain's are polygon and avalanche c-chain.
  • All the key-pairs are managed by the other third-party libraries which we termed as external key provider(EKP).
  • Currently supported external key provider(EKP) are Web3auth and Metamask.
  • Since DPLAT Token is not a L1 token, zbyte wallet defined some mandatory interfaces which are mentioned below:
    interface IWalletProvider {
        /**
        * @description Use to connect the wallet provider.
        */
        connect(): Promise<any>;
        /**
        * @description Use to checked whether wallet provider connected or not.
        */
        isConnected(): boolean;
        /**
        * @description fetch the wallet provider which internally set the provider
        * @param networkConfig Blockchain Network parameters
        */
        getKeyProvider(networkConfig: NetworkConfig): Promise<IKeyProvider>;
    }
    
    interface IKeyProvider {
        /**
        * @description Name of the key provider
        */
        readonly serviceProviderName: string;
        /**
        * @description Add Network to the given key provider
        * @param networkConfig Network Information of the blockchain
        */
        addChain(networkConfig: NetworkConfig): Promise<void>;
        /**
        * @description Switch default network to the given key provider,
        *              switchChain only supported on the added chain.
        * @param chainId chainId in hex string format e.g 0x89(137)
        */
        switchChain(chainId: string): Promise<void>;
        getProvider(): any;
    }
  • Then below are some important apis to interact with wallet:
    • IsConnected()
      • Check whether wallet is connected to underneath key provider like web3auth or metamask.
    • Connect()
      • Connect to underneath key provider.
    • SignTypedData(txnMessage: string, chainId: number)
      • Sign the EIP-712 transaction.
      • Inputs:
        • txnMessage: Serialized EIP-712 message
        • chainId: blockchain id which need the signature
    • BatchSignTypedData(txnBatch: UnsignedBatchTx): Promise<OperationSign[]>;
      • Its used when we need multiple transaction to be signed.
    • GetAddress()
      • Return the blockchain address for the given user.
    • GetTokenBalance(address: string)
      • Provide the zbyte token present in the given user's address.
      • Input:
        • address: User's blockchain address

Usage

  • Please refer the below code for consuming the wallet sdk:
        const web3Auth = new Web3AuthProvider();
        const metamask = new MetaMaskProvider();
    	const walletProvider: IWalletProvider = web3Auth || metamask;
          
        const wallet = new WalletCore(walletProvider, getBlockchainNetwork(CHAIN_ID_MATIC_TESTNET));
    
        // For using web3auth which is the default and preferred provider
        // requires extra authentication function 
        wallet.injectAuthVerifier({
            clientId: string;
            domain: string;
            typeOfLogin?: LOGIN_TYPE;
            verifier: string;
            accessToken: string;
            tokenExpiry?: number;
            typeOfToken?: string;
        });
    
        if (!wallet.isConnected()) {
            console.log(await wallet.connect()
            .then((result) => {
                console.log("initialized")
                return result;
            })
            .catch(e => console.error(e)));
        }
    
        const userAddress = await wallet.getAddress();
        const dplatBalance = await wallet.getTokenBalance(userAddress);