How to use speedomatic - 10 common examples

To help you get started, we’ve selected a few speedomatic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AugurProject / augur.js / test / unit / parsers / order-book.js View on Github external
maxPrice: "1",
      order: [],
    },
    assertions: function (output) {
      assert.isNull(output);
    },
  });
  test({
    description: "single order",
    params: {
      type: 1,
      minPrice: "0",
      maxPrice: "1",
      orderBookArray: [
        "0x1",                       // orderId
        speedomatic.fix("1.1111111", "hex"), // amount
        speedomatic.fix("0.7777777", "hex"), // price
        "0xb0b",                     // owner
        speedomatic.fix("0.8641974", "hex"), // tokensEscrowed
        speedomatic.fix("0", "hex"),         // sharesEscrowed
        "0xa",                       // betterOrderId
        "0xb",                       // worseOrderId
        "0x4a817c800",                // gasPrice
      ],
    },
    assertions: function (output) {
      assert.deepEqual(output, {
        "0x1": {
          amount: "1.1111",
          fullPrecisionAmount: "1.1111111",
          price: "0.7777",
          fullPrecisionPrice: "0.7777777",
github AugurProject / augur.js / test / unit / trading / order-book / get-order.js View on Github external
getOrder: function (p, callback) {
            assert.deepEqual(p, {
              _type: 1,
              _market: "MARKET_ID",
              _outcome: "OUTCOME_ID",
              _orderId: "0xa"
            });
            callback(null, [
              speedomatic.fix("1.1111111", "hex"), // amount
              speedomatic.fix("0.7777777", "hex"), // price
              "0xb0b",                     // owner
              speedomatic.fix("0.8641974", "hex"), // tokensEscrowed
              speedomatic.fix("0", "hex"),         // sharesEscrowed
              "0xa",                       // betterOrderId
              "0xb",                       // worseOrderId
              "0x4a817c800"                // gasPrice
            ]);
          }
        }
github AugurProject / augur.js / test / unit / create-market / get-market-creation-cost-breakdown.js View on Github external
getOrCacheDesignatedReportNoShowBond: function (p, callback) {
              assert.deepEqual(p, { tx: { to: "UNIVERSE_ADDRESS", send: false } });
              callback(null, speedomatic.fix("1", "string"));
            },
            getOrCacheValidityBond: function (p, callback) {
github AugurProject / augur.js / test / unit / create-market / get-market-creation-cost.js View on Github external
getOrCacheDesignatedReportNoShowBond: function (p, callback) {
              assert.deepEqual(p, { tx: { to: "UNIVERSE_ADDRESS", send: false } });
              callback(null, speedomatic.fix("1", "string"));
            },
            getOrCacheMarketCreationCost: function (p, callback) {
github AugurProject / augur.js / test / unit / create-market / get-market-creation-cost-breakdown.js View on Github external
getOrCacheValidityBond: function (p, callback) {
              assert.deepEqual(p, { tx: { to: "UNIVERSE_ADDRESS", send: false } });
              callback(null, speedomatic.fix("3", "string"));
            },
            getOrCacheReportingFeeDivisor: function (p, callback) {
github AugurProject / augur.js / test / unit / create-market / get-market-creation-cost.js View on Github external
getOrCacheMarketCreationCost: function (p, callback) {
              assert.deepEqual(p, { tx: { to: "UNIVERSE_ADDRESS", send: false } });
              callback(null, speedomatic.fix("4.2", "string"));
            },
          },
github AugurProject / augur.js / test / unit / trading / trade-until-amount-is-zero.js View on Github external
assert.oneOf(p._fxpAmount, ["0x38d7ea4c68000", "0x110d9316ec000"]);
              assert.strictEqual(p._price, "0x1388");
              assert.strictEqual(p._tradeGroupId, "0x1");
              assert.isFunction(p.onSent);
              assert.isFunction(p.onSuccess);
              assert.isFunction(p.onFailed);
              if (p._fxpAmount === "0x38d7ea4c68000") {
                assert.strictEqual(counter, 0);
                counter++;
                p.onSent({ hash: "TRANSACTION_HASH_1" });
                p.onSuccess({ hash: "TRANSACTION_HASH_1", value: speedomatic.fix("4", "string") });
              } else {
                assert.strictEqual(counter, 1);
                counter++;
                p.onSent({ hash: "TRANSACTION_HASH_2" });
                p.onSuccess({ hash: "TRANSACTION_HASH_2", value: speedomatic.fix("1", "string") });
              }
            },
          },
github AugurProject / augur.js / test / unit / create-market / mock-market-created-data.js View on Github external
"use strict";

var abi = require("../../../src/contracts/abi");
var speedomatic = require("speedomatic");
var encodeTransactionInputs = require("../../../src/api/encode-transaction-inputs");
var hashEventAbi = require("../../../src/events/hash-event-abi");

var marketCreatedEventAbi = abi.Augur.find(function (abi) {
  return abi.type === "event" && abi.name === "MarketCreated";
});
var marketCreatedEventNonIndexedInputs = marketCreatedEventAbi.inputs.filter(function (abi) { return !abi.indexed; });
var marketCreatedParamTypes = marketCreatedEventNonIndexedInputs.map(function (abi) { return abi.type; });
var marketCreatedParamObject = {
  market: "0xbb785f16f6aab68007e897ac3560378d8d6ffd16",
  marketCreationFee: speedomatic.fix("0.010000000006", "hex"),
  minPrice: "0x0",
  maxPrice: speedomatic.fix("10000", "hex"),
  marketType: "0x0",
  description: "Will SpaceX successfully complete a manned flight to the International Space Station by the end of 2018?",
  outcomes: [0, 0],
  extraInfo: JSON.stringify({
    resolutionSource: "http://www.spacex.com",
    tags: ["SpaceX", "spaceflight"],
    longDescription: "SpaceX hit a big milestone on Friday with NASA confirming on Friday that the Elon Musk-led space cargo business will launch astronauts to the International Space Station by 2017.\n\nLast year, the space agency tentatively awarded a $2.6 billion contract to SpaceX to carry crew to space. NASA’s announcement on Friday formalizes the deal, which involves SpaceX loading its Crew Dragon spacecraft with astronauts and sending them beyond the stratosphere.",
  }),
};

module.exports = {
  abi: marketCreatedEventAbi,
  eventSignature: hashEventAbi(marketCreatedEventAbi),
  params: marketCreatedParamObject,
github AugurProject / augur.js / scripts / helpers / check-mailbox.js View on Github external
augur.rpc.eth.getBalance([marketMailboxAddress, "latest"], function (attoEthBalance) {
        var ethBalance = speedomatic.bignum(attoEthBalance);
        var combined = speedomatic.unfix(ethBalance.add(cashBalance), "string");
        console.log(chalk.green.dim("Total balance:"), chalk.green(combined));
        process.exit();
      });
    });
github AugurProject / augur.js / scripts / helpers / get-account-balance.js View on Github external
augur.rpc.eth.getBalance([account, "latest"], function (err, etherBalance) {
        if (err) return console.error(err);
        if (etherBalance == null) return console.error("rpc.eth.getBalance failed:", etherBalance);
        var balances = {
          reputation: speedomatic.unfix(reputationBalance, "string"),
          ether: speedomatic.unfix(etherBalance, "string"),
        };
        console.log(chalk.cyan("Balances:"));
        console.log("Ether:      " + chalk.green(balances.ether));
        console.log("Reputation: " + chalk.green(balances.reputation));
        process.exit(0);
      });
    });

speedomatic

Grab bag of formatting and ABI encoding/decoding functions

MIT
Latest version published 7 years ago

Package Health Score

46 / 100
Full package analysis

Popular speedomatic functions

Similar packages