0.2.0 • Published 6 years ago

sniper-js v0.2.0

Weekly downloads
16
License
-
Repository
github
Last release
6 years ago

SniperJS

Build Status npm version codecov NSP Status

Overview

SniperJS is a javascript library that assists in the of development third-party applications for sniper.io. SniperJS ships as an ECMAScript 6 module, and can run in-browser or in NodeJS. This module aims to provide reusable code in support of a range of applications, from frontends to bots.

Module Installation

  • npm i --save sniper-js

Quickstart

import Sniper from 'sniper-js'

// requires web3 Provider
let snpr = new Sniper({
  provider: web3 // can be injected web3 object, or rpc URL string
})

// create an order
snpr.init().then(() => {
  // orderObj contains order data
  snpr.createOrderAsync(orderObj)
  .then((order) => {
    let hash = snpr.getOrderHash(order)

    // verify order signature
    console.log(
      'verification test:',
      snpr.verifySignature(hash, order.maker, order.sig)
    )

    return order
  }).then((order) => {
    // submit order
    snpr.submitOrder(order)
  })
})

Local Installation

  • Requires NodeJS & NPM
  • npm i

Test

  • npm test

Develop

  • npm start

Standalone Build

  • npm run build