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

@windingtree/sdk-node-api

v1.7.4

Published

The WindingTree market protocol node API server and client

Downloads

22

Readme

@windingtree/sdk-node-api

The WindingTree market protocol node API server and client. This SDK provides a client and server implementation for communication with the WindingTree Market Protocol Node. This API allows to implement the protocol node management. For the implementation detail please see the node manager app example.

Installation

pnpm i @windingtree/sdk-node-api

Key concepts

This SDK is designed to work with the WindingTree Market Protocol and includes several core components:

  • Routers: These modules define the procedures for user management, admin management, and deal management. Procedures include registration, login, logout, delete, update, checkIn, and checkOut actions, among others.
  • Server: The server module sets up an API server that uses the defined routers to handle requests.
  • Client: The client module provides utilities for creating EIP-712 signatures for certain operations and middleware functions for tRPC link operations.
  • Constants: This module exports various constants used across the SDK, such as the access token name and the typed domain for admin signature.
  • Utils: This module exports a schema used for pagination in query inputs.

Usage

The package exports a NodeApiServer class that can be used to set up an API server that interacts with the WindingTree Market Protocol. The server uses tRPC, an end-to-end typesafe RPC framework, allowing for easy interaction with clients.

import { NodeApiServer } from '@windingtree/sdk-node-api/server';
import { appRouter } from '@windingtree/sdk-node-api/router';
import { ProtocolContracts } from '@windingtree/sdk-contracts-manager';
import { memoryStorage } from '@windingtree/sdk-storage';

// Initialize your ProtocolContracts, Node, and other components here...
const contractsManager = new ProtocolContracts({...});

const usersStorage = await memoryStorage.createInitializer({
  scope: 'users',
})();
const dealsStorage = await memoryStorage.createInitializer({
  scope: 'deals',
})();

const apiServer = new NodeApiServer({
  usersStorage,
  dealsStorage,
  prefix: 'my-prefix',
  port: 3000,
  secret: 'my-secret',
  ownerAccount: entityOwnerAddress,
  protocolContracts: contractsManager,
});

apiServer.start(appRouter);

// Handle incoming requests and perform necessary actions here...

Here's a simple example (React) of using the @windingtree/sdk-node-api/client:

import { createAdminSignature } from '@windingtree/sdk-node-api/client';
import { useNode, useWallet } from '@windingtree/sdk-react/providers';

// Your code to setup the WindingTree Wallet goes here. Assuming you have a `walletClient` object in the app component.
const { walletClient } = useWallet();
const { node } = useNode();

const handleAdminRegister = async (name: string) => {
  try {
    const signature = await createAdminSignature(walletClient);

    await node.admin.register.mutate({
      login: name,
      password: signature,
    });
  } catch (error) {
    console.error('Error admin register:', error);
  }
};

handleAdminRegister();

Documentation

For full documentation and examples, visit windingtree.github.io/sdk

Testing

pnpm test

Contributing

Contribution guidelines