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

@eurega/near

v0.0.2

Published

Eurega lib to interact with mintbase & near

Downloads

4

Readme

Explorins near-mintbase API

This library provides a gateway to connect to your mintbase near wallet to your app to get its data and work with it.

  • Acquire an API key in the Developer tab on Mintbase

working example to connect testnet

First we create an instance to our wallet

import { NearWallet } from '@explorins/near-lib';

    const wallet = new NearWallet(
        {
            MINTBASE_API_KEY,
            'testnet'
        }
    );

Now web can subscribe to wallet logged observable

    $logginObservable = wallet.isLogged$;
    $logginObservable.subscribe((logged:boolean) => {
        ...
    })

Next we must to init our wallet object

    await wallet.init();

After init if we are previously logged, we can recover the loggin state and actuate accordingly in the app

    $logginObservable.subscribe((logged:boolean) => {
        if(logged) console.log('Already logged in');
    })

If you are not connected to your wallet you must link the login button to the following action

    // Connect to your mintbase near wallet
    await wallet.connect();

    (...)
    

This action will redirect you to your wallet login on the near page

  • When we return to our app, we will already be connected to mintbase and we will be able to use its methods

    // Connect to your mintbase near wallet
    await wallet.mintbaseLogin();

    // Retrieve the basic information
    const walletDetails = await wallet.getDetails();
    const token = await wallet.getTokenFromCurrentWallet();

    (...)
    

The mintbaseLogin function establishes the connection with our mintbase wallet once we have done login in near.

  • mintbaseLogin throws us an error in case we are not logged in near , in that case we must capture the error to redirect our users to the login
    try {
      // Si no está logeado lanzara error y no seguirá
      await this.wallet.mintbaseLogin();
    } catch (error) {
      console.log(' *** not logged, press login button')
    }

The wallet object that we have created provides us with an observable that returns information about the login status.

const loggedObservable = wallet.isLogged$;

loggedObservable.subscribe((status: boolean) => {
  console.log('Logged status change: ', status);
})

Library errors are returned to the application using numerical codes that allow us to customize our response to the user in each case.

    CONNECT: {
        USER_NOT_FOUND: '0101',
        MINTBASE_LOGIN: '0102',
        USUPPORTED_NETWORK: '0103',
        MINTBASE_NOT_CONNECTED: '0104',
        MINTBASE_ERROR: '0105'
    },
    DISCONNECT: {
        MINTBASE_ERROR: '0201',
        MINTBASE_NOT_CONNECTED: '0202',
        ALREADY_DISCONNECTED: '0203'
    },
    TRANSFER_TOKEN: {
        ACCOUNT_NOT_FOUND: '0301',
        CONTRACT_NOT_FOUND: '0302',
        TRANSACTION_FAILS: '0303',
        MINTBASE_NOT_CONNECTED: '0304'
    },
    CONTRACT: {
        USER_NOT_FOUND: '0401',
        MINTBASE_NOT_CONNECTED: '0402',
        MINTBASE_ERROR: '0403',
        CONTRACT_NAME_NOT_FOUND: '0404',
        NEAR_ERROR: '0405'
    },
    GET_TOKEN: {
        MINTBASE_NOT_CONNECTED: '0501',
        TIMEOUT_ERROR: '0502'
    },
    MAKE_OFFER: {
        USER_NOT_FOUND: '0601',
        TOKEN_NOT_FOUND: '0602',
        STORE_NOT_FOUND: '0603',
        MINTBASE_NOT_CONNECTED: '0604',
        MINTBASE_ERROR: '0605'
    },
    FETCH_STORE: {
        MINTBASE_NOT_CONNECTED: '0701',
        MINTBASE_ERROR: '0702',
        GRAPHQL_ERROR: '0703'
    },
    FETCH_THINGS: {
        MINTBASE_NOT_CONNECTED: '0801',
        MINTBASE_ERROR: '0802'
    },
    GET_MINTERS: {
        MINTBASE_NOT_CONNECTED: '0901',
        MINTBASE_ERROR: '0902',
        CONTRACT_ERROR: '0903'
    },
    FETCH_MARKETPLACE: {
        MINTBASE_NOT_CONNECTED: '1001',
        MINTBASE_ERROR: '1002'
    }