Catalog npm
Back to packageRELEASE DETAILS

2.1.0

npm

@0xbigboss/pocketjs-relayer

Slim relayer client for the Pocket Network v0 Protocol

Published2 Oct 2022
Direct dependencies17
Transitive dependenciesNot calculated

README

Current package documentation

Relayer

This package houses both the abstract relayer interface we expose to people so that they build their own Relayer, and an actual Relayer ready to use for sending relays and dispatching new sessions.

You'll need a staked aplication in the Pocket Network blockchain to use this package.

To learn more about the relay lifecycle, reach for the docs.

Installation

Install through your package manager of choice:

pnpm install @pokt-foundation/pocketjs-relayer

Usage

import { AbstractRelayer, Relayer } from '@pokt-foundation/pocketjs-relayer'

// For the AbstractRelayer, just implement it!
class MyRelayer extends AbstractRelayer {
 // Now override the required methods...
}

// Initializing the relayer is simple:
// 1. Instanciate a provider
export const provider = new JsonRpcProvider({
  rpcUrl: MAINNET_RPC_URL,
  // For a relayer, dispatchers are needed
  dispatchers: DISPATCHERS,
})

// 2. Instanciate a signer for signing the relays
export const signer = await KeyManager.fromPrivateKey(process.env.PRIVATE_KEY)

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

// Get a new session
const session = await relayer.getNewSession({
  chain: process.env.APP_CHAIN,
  applicationPubKey: process.env.APP_PUBLIC_KEY,
})

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

Relayer API

Constructor

keyManager

  • type: KeyManager The KeyManager instance that holds the staked app in the blockchain.

provider

  • type: JsonRpcProvider | IsomorphicProvider The provider instance with available dispatchers to talk to the network.

dispatchers

  • type: String[] Backup set of dispatchers.

Methods

getNewSession({ applicationPubKey, chain, sessionBlockHeight, options }): Promise

Performs a dispatch request to obtain a new session. Fails if no dispatcher is provided through the provider.

Returns Promise<Session>: The dispatch response as a session.

ParamTypeDescription
applicationPubKeystringThe application's public key.
chainstringThe chain for the ssions.
sessionBlockHeightnumberThe session block height.
optionsobjectThe options available to tweak the request itself.
options.retryAttemptsnumberThe number of retries to perform if the first call fails.
options.rejectSelfSignedCertificatesbooleanOption to reject self signed certificates or not.
options.timeoutnumberTimeout before the call fails. In milliseconds.

relay({ blockchain, data, headers, method, node, path, pocketAAT, session, options })

Sends a relay to the network.

ParamTypeDescription
blockchainstringThe chain for the session.
datastringThe data to send, stringified.
headersobjectThe headers to include in the call, if any.
nodeNodeThe node to send the relay to. The node must belong to the current session.
pathstringThe path to query in the relay. Useful for chains like AVAX.
pocketAATAATThe pocketAAT used to authenticate the relay.
sessionSessionThe current session the app is assigned to.
optionsobjectThe options available to tweak the request itself.
options.retryAttemptsnumberThe number of retries to perform if the first call fails.
options.rejectSelfSignedCertificatesbooleanOption to reject self signed certificates or not.
options.timeoutnumberTimeout before the call fails. In milliseconds.

Downloads & popularity

Awaiting observations

No metric observations yet

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

Declared dependencies 17

Native requirements
17 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
debug
Environment
{
  "local_name": "debug",
  "alias": false,
  "peer_metadata": null
}
^4.3.3runtime
js-sha3
Environment
{
  "local_name": "js-sha3",
  "alias": false,
  "peer_metadata": null
}
^0.8.0runtime
js-sha256
Environment
{
  "local_name": "js-sha256",
  "alias": false,
  "peer_metadata": null
}
^0.9.0runtime
isomorphic-webcrypto
Environment
{
  "local_name": "isomorphic-webcrypto",
  "alias": false,
  "peer_metadata": null
}
^2.3.8runtime
@0xbigboss/pocketjs-signer
Environment
{
  "local_name": "@0xbigboss/pocketjs-signer",
  "alias": false,
  "peer_metadata": null
}
2.1.0runtime
@0xbigboss/pocketjs-provider
Environment
{
  "local_name": "@0xbigboss/pocketjs-provider",
  "alias": false,
  "peer_metadata": null
}
2.1.0runtime
@0xbigboss/pocketjs-abstract-provider
Environment
{
  "local_name": "@0xbigboss/pocketjs-abstract-provider",
  "alias": false,
  "peer_metadata": null
}
2.1.0runtime
jest
Environment
{
  "local_name": "jest",
  "alias": false,
  "peer_metadata": null
}
^27.4.7development
eslint
Environment
{
  "local_name": "eslint",
  "alias": false,
  "peer_metadata": null
}
7.32.0development
ts-jest
Environment
{
  "local_name": "ts-jest",
  "alias": false,
  "peer_metadata": null
}
^27.1.3development
prettier
Environment
{
  "local_name": "prettier",
  "alias": false,
  "peer_metadata": null
}
^2.5.1development
@types/jest
Environment
{
  "local_name": "@types/jest",
  "alias": false,
  "peer_metadata": null
}
^27.4.0development
microbundle
Environment
{
  "local_name": "microbundle",
  "alias": false,
  "peer_metadata": null
}
^0.14.2development
prettier-eslint
Environment
{
  "local_name": "prettier-eslint",
  "alias": false,
  "peer_metadata": null
}
^13.0.0development
@0xbigboss/pocketjs-types
Environment
{
  "local_name": "@0xbigboss/pocketjs-types",
  "alias": false,
  "peer_metadata": null
}
2.1.0development
@typescript-eslint/parser
Environment
{
  "local_name": "@typescript-eslint/parser",
  "alias": false,
  "peer_metadata": null
}
^5.10.2development
@typescript-eslint/eslint-plugin
Environment
{
  "local_name": "@typescript-eslint/eslint-plugin",
  "alias": false,
  "peer_metadata": null
}
^5.10.2development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "dc9eb48053a1cd6494287979a001226473322643",
  "tarball": "https://registry.npmjs.org/@0xbigboss/pocketjs-relayer/-/pocketjs-relayer-2.1.0.tgz",
  "fileCount": 27,
  "integrity": "sha512-KToPRJbY9Yx1cNOqk3W0o7NPfsj6db99oa1ij/RIwygjuN+k1UUvE9GPE7BzjRPx8jsUW7BQcLR70jBQ7ItDxQ==",
  "signatures": [
    {
      "sig": "MEQCIC/1Wd4jIx85t3zMPkbKtZSqsfughvLPG/LDREWfXj1pAiAy0osFcrsmqUN6DlseVW6gmX6KK5dAJicYxm1fO2/3fQ==",
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
    }
  ],
  "unpackedSize": 155293,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjORLvACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmooxw//RnwrlmY7wfv9cObEbKHONyqn1wgp3aUvrYDg77/H7RIS0YMV\r\nxg6oey2l/4ItODs5WJJyKKCbm9QnpV0FRiWptm6EsVxItWek8U6g9T5R+AS4\r\nax7Cz2XVqliMw+tMlas/weBe1wiFMFDkScgLbPJxdTgkdY6ZO74Gmb8v+bOo\r\n5JrhF6h9cmOPM9bx/bXnuKPvg3nXHNk+rDuFm2k/pNwIcQxB0LC8/clm6kKC\r\nVDWBUsjXWOxYTBBZYsXR7FNIr4s5y0FcDyumGhh0sWkLHqVII5kagqIePTqt\r\nhCG6zNxGEadK28OMYVScz8fb6W8/yCrGN7pic30nKHKOB7UTVu4nJqmgo74L\r\nmf+8E8EvUAEU2ryA5MoiBRWWEPE3m61TDfDQqv55k4BNaYhJGggA0hafACwt\r\nWqtOhSoP7zSHc3i7JnAi9MqNGJ8AkBcEyCeNZ1eCky/XgWGymo1yP15vmimp\r\nTBL1HSiS/iSDBedvb5WPPX4rVXYkF9MARtmmBHVhZ8izaf2t9KEjqihIOpIj\r\nyaCkSRgKIC6g5owG31dhUXlprsVheWP8x+BCSWKK7N6n4OZAIz71mH7X4po+\r\nmaWlxjTaPCu0VNJxO3UtVmbr9f3r9WM6UK/m0b8fR3lvt9GPKUo9RWZ/qFcP\r\nH3CCPSBOqWaE1OLdEj0aYNHsxEvzdwxgS3I=\r\n=smA1\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:d9bad1f61ba7a82eb4cd8769e1aef3f982ed1f62a167346fb9ebf15ae74a52d3

Other collected versions

2.1.130 OctView all collected versions →