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

@neongd/neo-provider

v1.2.2

Published

Neo Provider types and toolings

Downloads

233

Readme

Neo Provider

Neo Provider is a JavaScript API for consistency between dApps and wallets.

In the Neo web application ("dApp") ecosystem, the key management softwares ("wallets") expose their API via a JavaScript object in the web page. This object is called the "Provider".

Historically, Provider implementations have exhibited conflicting interfaces and behaviors between wallets. This project defines some interfaces that the wallet should comply with to improve the interoperability between dapps and wallets. It is designed to be minimal, event-driven, and agnostic of transport and RPC protocols. Its functionality is easily extended by defining new RPC methods and message event types.

API Reference

Methods

request

The request method is intended as a transport- and protocol-agnostic wrapper function for Remote Procedure Calls (RPCs).

interface RequestArguments<T = any> {
  method: string;
  params?: T;
}

Provider.request<R = any, P = any>(args: RequestArguments<P>): Promise<R>;

The Provider should identify the requested RPC method by the value of RequestArguments.method.

If the requested RPC method takes any parameters, the Provider should accept them as the value of RequestArguments.params.

RPC requests should be handled such that the returned Promise either resolves with a value per the requested RPC method's specification, or rejects with an error.

If resolved, the Promise should resolve with a result per the RPC method's specification.

If the returned Promise rejects, it should reject with a ProviderRpcError as specified in the RPC Errors section below.

on

Should be implemented per the Node.js EventEmitter API.

removeListener

Should be implemented per the Node.js EventEmitter API.

Events

connect

See the section Connectivity for the definition of "connected".

If the Provider becomes connected, the Provider should emit the event named connect.

disconnect

See the section Connectivity for the definition of "disconnected".

If the Provider becomes disconnected, the Provider should emit the event named disconnect with value error: ProviderRpcError, per the interfaced defined in the RPC Errors section. The value of the error's code property should follow the status codes for CloseEvent.

message

The message event is intended for arbitrary notifications not covered by other events.

When emitted, the message event be emitted with an object argument of the following form:

export interface ProviderMessage {
  type: string;
  data?: any;
}

networkChanged

If the default network of the Provider changes, the Provider should emit the event named networkChanged with value network: string.

accountChanged

If the default account of the Provider changes, the Provider should emit the event named accountChanged with value account: string.

RPC Errors

export interface ProviderRpcError extends Error {
  code: number;
  data?: any;
}
  • message
    • should be a human-readable string
    • should adhere to the specifications in the Error Standards section below
  • code
    • should be an integer number
    • should adhere to the specifications in the Error Standards section below
  • data
    • should contain any other useful information about the error

Error Standards

ProviderRpcError codes and messages should follow these conventions, in order of priority:

  1. Any errors mandated by the erroring RPC method's specification

  2. The CloseEvent status codes

Connectivity

The Provider is said to be "connected" when it can service RPC requests to at least one network.

The Provider is said to be "disconnected" when it cannot service RPC requests to any network at all.

License

This project is licensed under the MIT License - see the LICENSE file for details.