Catalog npm
Back to packageRELEASE DETAILS

0.0.3

npm

@0xbigboss/pocketjs-monorepo

![Build](https://github.com/pokt-foundation/pocket-js-slim/actions/workflows/node.js.yml/badge.svg)

Published2 Oct 2022
Direct dependencies3
Transitive dependenciesNot calculated

README

Current package documentation

PocketJS

Build

A complete, fast and slim SDK to interact with the Pocket Network.

Usage

Add the packages for each part to your project:

yarn add @pokt-foundation/pocketjs-provider @pokt-foundation/pocketjs-signer @pokt-foundation/pocketjs-transaction-builder @pokt-foundation/pocketjs-relayer @pokt-foundation/pocketjs-utils

And use each piece as you see fit:

import { JsonRpcProvider } from "@0xbigboss/pocketjs-provider";
import { KeyManager } from "@0xbigboss/pocketjs-signer";
import { TransactionBuilder } from "@0xbigboss/pocketjs-transaction-builder";
import { Relayer } from "@0xbigboss/pocketjs-relayer";
import {
  MAINNET_RPC_URL,
  DISPATCHERS,
  RELAY_DATA,
  POCKET_AAT,
} from "./config.js";

// Instantiate a provider for querying information on the chain!
export const provider = new JsonRpcProvider({
  rpcUrl: MAINNET_RPC_URL,
  // If you'll Instantiate a relayer, you need to add dispatchers as well
  dispatchers: DISPATCHERS,
});

const balance = await provider.getBalance(
  "07a6fca4dea9f01e4c19f301df0d0afac128561b"
);

// Instantiate a signer for importing an account and signing messages!
export const signer = await KeyManager.fromPrivateKey(process.env.PRIVATE_KEY);

const address = signer.getAddress();
const publicKey = signer.getPublicKey();
const signedMessage = signer.sign("deadbeef");

// Instantiate a new TransactionBuilder for creating transaction messages and
// and sending them over the network!
export const transactionBuilder = new TransactionBuilder({
  provider,
  signer,
});

// Create a new `Send` Message which is used to send funds over the network.
const sendMsg = transactionBuilder.send(
  signer.getAddress(),
  "07a6fca4dea9f01e4c19f301df0d0afac128561b",
  // Amount in uPOKT (1 POKT = 1*10^6 uPOKT)
  "1000000"
);
// Send it over the network!
const txresponse = await transactionBuilder.submit({
  memo: "POKT Payment",
  txMsg: sendMsg,
});

// Create a new relayer to send relays over the network!
export const relayer = new Relayer({
  keyManager: signer,
  provider,
  dispatchers: DISPATCHERS,
});

const session = await relayer.getNewSession({
  chain: process.env.APP_CHAIN,
  applicationPubKey: process.env.APP_PUBLIC_KEY,
});

const relay = await relayer.relay({
  data: process.env.RELAY_DATA,
  blockchain: process.env.APP_CHAIN,
  pocketAAT: POCKET_AAT,
  session: session,
});

Contributing

Setting up

Download the repo from Github, and just run pnpm i at the root folder. This will install all of the individual packages in the necessary order. If you'd like to build all packages manually, you'll need follow the order in which they're referenced:

  • Install packages/utils
  • Install packages/types
  • Install packages/abstract-provider
  • Install packages/provider
  • Install packages/signer
  • Install packages/relayer
  • Install packages/transaction-builder

The best way to develop locally is to link the local packages from your clone to the project you're working on; this will let you either run the dev server or build the packages to see the changes in real time.

We use Turborepo to manage build caches and our general build/test pipeline. This means that only the packages that have changed will get built again, saving you time. At the root package.json we've also defined a collection of scripts you can use to run individual packages on their dev server.

Running tests

For running tests, either run pnpm jest on the corresponding repo or run pnpm turbo run test on the root folder to run all tests.

👋 Get started contributing with a good first issue.

Don't be shy to contribute even the smallest tweak. 🐲 There are still some dragons to be aware of, but we'll be here to help you get started!

Issues

If you ever come across an issue with PocketJS, do a search in the issues tab of this repo and make sure it hasn't been reported before. Follow these steps to help us prevent unnecessary notifications to the many people following this repo.

  • If the issue you found has been reported and is still open, and the details match your issue, give a "thumbs up" to the relevant posts in the issue thread to signal that you have the same issue. No further action is required on your part.
  • If the issue you found has been reported and is still open, but the issue is missing some details, you can add a comment to the issue thread describing the additional details.
  • If the issue you found has been reported but has been closed, you can comment on the closed issue thread and ask to have the issue reopened because you are still experiencing the issue. Alternatively, you can open a new issue, reference the closed issue by number or link, and state that you are still experiencing the issue. Provide any additional details in your post so we can better understand the issue and how to fix it.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 3

Native requirements
3 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
turbo
Environment
{
  "local_name": "turbo",
  "alias": false,
  "peer_metadata": null
}
latestdevelopment
prettier
Environment
{
  "local_name": "prettier",
  "alias": false,
  "peer_metadata": null
}
^2.5.1development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^4.5.5development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "b870c3cb84ea746c1c885acbe6c6a77affbf88b2",
  "tarball": "https://registry.npmjs.org/@0xbigboss/pocketjs-monorepo/-/pocketjs-monorepo-0.0.3.tgz",
  "fileCount": 190,
  "integrity": "sha512-tAtIA9cLrRXPzBSbLoc2s1T8Azn5oce+r/kshNnyvgQz6Fdo5kq+Uk+TokJ7XONiBf8JVpaekw9PUQm2OLq8MQ==",
  "signatures": [
    {
      "sig": "MEQCIF0MYdwBhxD2ZDYo6NphetbFBZrGGz+5jsKTXbK5zST/AiBq2mGSS6dkAkOFRqSC6LxdQuSsikru2tQQFdCO9Iykpw==",
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
    }
  ],
  "unpackedSize": 4566970,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjORLLACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqw5g//eyixiDnMw7p2emHWSYm2NVFQmBS1r+vEhEDnFsPJqF4DVvFe\r\np1FfhpMZcS0/5cJ0MSC5EtuwInFr8nkcIjfeyGrODRGNS4u5B9gsXpU+ZkHT\r\nNlo+uKjBFT5D6keGxflfruW6CMJrScIjmlFyTV+zTgcDZ2XbuTfqkGvYpfx1\r\nRB4BnCewYXLs97DkjQAO1rAnso5Lu8I4miukWu8ZtVqwxwAM4iCxGYl2q57e\r\n+uxAcB/k4xa4vJcGx7rvjdem1uavj7iBTLsSYngJRFE9r3ljlLlOqDgTpgCB\r\nFzDIMkpcU1oh7tHu0XnkAWkVkPeqVp/g6NDQnA/41P8D0EddABvNHWhb8Bw2\r\nfsusFs5SKa8UcDtpZGHFQMHh1Ne+vS9zL4gm2JoM6Y9lpCleaX0slRxhhX/H\r\nqE+Wyg0MH2THA/k4tkmjKtR5SbGhxYj/ifHVzZyGdLWwVOikDnN5+YOEkDLT\r\nSQHNERX1lmLAPKnBRoeKyUGI4jnwS1OgMejf2Nd0VehKACmuM8qxDIM5AOtA\r\ngBVFY0tuQ067fQ/YEV28vVfe/4+D3HqLUmzsFjqVDxFn2q226cAO27+lozha\r\nxRy1ip2SqZvLBuqpM4xxRgZOrimMVSdO/HZhxS2QNNN9srkbKcSMZm6IKvHp\r\nnDbqjUffFuSAp3uyLpDtkNBOQ/7yWREkNUA=\r\n=3Grw\r\n-----END PGP SIGNATURE-----\r\n"
}

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:43 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:839b2f877a97761e30ebe85e62bf2b2782fa6401a41d5487372ad3fbeb17de18

Other collected versions

0.0.430 OctView all collected versions →