Code Monkey home page Code Monkey logo

api-sdk-ts's Introduction

TzKt API SDK written in Typescript

lerna

A collection of packages simplifying working with TzKT APIs.

Please note, this is a monorepository. Documentation for packages provided by it may be found in readme files in respective project folders.

Install

Installing any package from this repository for use in you project is as simple as running

npm i @tzkt/<package_name>
Name Description NPM
@tzkt/sdk-api Wrappers for TzKT API endpoints written in TS npm version
@tzkt/sdk-events Subscription manager for TzKT events npm version
@tzkt/ext-taquito TzKT taquito extension npm version

Contributing and publishing

This repository and packages inside of it are managed by Lerna. The preferred package manager is npm. That said - you will need at least node > 14 and npm > 6 to proceed.

Development and update

Documentation on development and updating of packages may be found in the respective folders. Below are some bootstrapping commands that you first need to run in the root of this repository.

Install dependencies (this will install Lerna and any shared dependencies).

npm install

Bootstrap it all together - installs local dependencies and ties it all up. Under the hood it uses lerna bootstrap with strict hoisting flags passed to it.

npm run bootstrap

Build and publish

After you're done with making your changes, you will need to build packages in this repo and then publish.

npm run build
npm run publish

api-sdk-ts's People

Contributors

egovar avatar groxan avatar llomal avatar m-kus avatar mv-go avatar souljorje avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

api-sdk-ts's Issues

ReferenceError: fetch is not defined

I am using the library to interact with Tezos blockchain via Nodejs application.
The source code

import * as api from '@tzkt/sdk-api';
api.defaults.baseUrl = 'https://api.ghostnet.tzkt.io/'

async function getTransaction()
{
  const receipt = await api.operationsGetByHash("oopzR8DwzX9VLrSoeJP4WirFWz22SkA2AZ7TM4K1yHSGKzViDme");
  console.log(receipt);
}
getTransaction();

The error msg is :

/../nodejsexample/node_modules/@tzkt/oazapfts/lib/runtime/index.js:78
        const res = await (customFetch || fetch)(href, {
                                          ^
ReferenceError: fetch is not defined
    at doFetch (/../nodejsexample/node_modules/@tzkt/oazapfts/lib/runtime/index.js:78:43)
    at fetchText (/../nodejsexample/node_modules/@tzkt/oazapfts/lib/runtime/index.js:32:27)
    at Object.fetchJson (/../nodejsexample/node_modules/@tzkt/oazapfts/lib/runtime/index.js:46:62)
    at Module.operationsGetByHash (/../nodejsexample/node_modules/@tzkt/sdk-api/build/main/index.js:684:33)
    at getTransaction (file:///../nodejsexample/index.js:119:29)
    at file:///../nodejsexample/index.js:123:1

Allow not passing jsonPath for JsonParameter type args

  • I'm submitting a ...
    [x] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

Summary
Despite TS types stating that jsonPath field in JsonParameter is optional, the runtime error is thrown every time jsonPath is not passed in.

This essentially prohibits creating requests of any patter that looks like this
/{bigmap}/keys?key.nat={tokenId}&value.gt=0
Value filter for creating this request should have jsonPath: undefined or not passed in at all.

jsonParameter parser works counterintuitive

  • I'm submitting a ...

  • feature request

  • Summary

I wish it works like this:

contractsGetBigMapByNameKeys(
    address,
    'name',
    {
      value: {
        token_id: {
           in: ['0', '1'],
        },
       /*  instead of
       in: {
          jsonPath: 'token_id',
          jsonValue: ['0', '1'],
        },
       */
      },
    },
  )
  • Other information

I suggest to recursively create that.kind.of.path from object with last nested property as value. And also I suggest to use reduce for declarativeness.

sourcemaps don't work

  • I'm submitting a ...

  • bug report

  • Summary

Could not load content for http://localhost:3000/node_modules/@tzkt/api-sdk-ts/src/index.ts (HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE)

  • Other information

try to distribute ./src

Compatibility with recent taquito

Heya, and thank you!

It seems to work quite nicely :)

Small issue: it's not quite compatible with more recent versions of taquito. At best type errors (15.0), at worst runtime errors (15.1).

Failed to invoke 'SubscribeToOperations' due to an error on the server. InvalidDataException

  • I'm submitting a ...
    [ *] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary
    Hello, I am getting the error below while trying to create a subscription for monitoring transactions.

Error: Error: Failed to invoke 'SubscribeToOperations' due to an error on the server. InvalidDataException: Error binding arguments. Make sure that the types of the provided values match the types of the hub method being invoked.
    at /project-path/node_modules/@tzkt/sdk-events/src/client.ts:292:15
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
[ERROR] 02:31:38 Error: Error: Failed to invoke 'SubscribeToOperations' due to an error on the server. InvalidDataException: Error binding arguments. Make sure that the types of the provided values match the types of the hub method being invoked.
  • Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)
    Here is my snippet code
import { EventsService } from '@tzkt/sdk-events';

class Mempool {
  private events: EventsService;

  constructor() {
    this.events = new EventsService({
      url: 'https://api.tzkt.io/v1/events',
      reconnect: true,
    });
  }

  monitor = () => {
    this.events.operations({ types: ['transaction'] }).subscribe({ next: console.log });
  };
}

export const mempool = new Mempool();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.