How to use the ripple-lib.UInt160.json_rewrite function in ripple-lib

To help you get started, we’ve selected a few ripple-lib 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 ripple-unmaintained / ripple-watch / bot.js View on Github external
+ (pay_diff ? "\u000f" : "")
                    + " "
                    + UInt160.json_rewrite(m.transaction.Account, opts_gateways) + st
                    + " > "
                    + (created ? "\u0002" : "")
                    + UInt160.json_rewrite(m.transaction.Destination, opts_gateways) + dt
                    + (created ? "\u000f" : "");

    process_offers(m);
  }
  else if (m.transaction.TransactionType === 'AccountSet')
  {
    console.log("transaction: ", JSON.stringify(m, undefined, 2));

    say_type  = 'ACT';
    say_watch = UInt160.json_rewrite(m.transaction.Account, opts_gateways);
  }
  else if (m.transaction.TransactionType === 'TrustSet')
  {
    var limit = 'LimitAmount' in m.transaction
                  ? Amount.from_json(m.transaction.LimitAmount).to_human_full(opts_gateways) + " "
                  : "";

    say_type  = 'TRS';
    say_watch = limit
                  + UInt160.json_rewrite(m.transaction.Account, opts_gateways);
  }
  else if (m.transaction.TransactionType === 'OfferCreate')
  {
    // console.log("OfferCreate: ", JSON.stringify(m, undefined, 2));

    var owner       = UInt160.json_rewrite(m.transaction.Account, opts_gateways);
github ripple-unmaintained / ripple-watch / bot.js View on Github external
}
  else if (m.transaction.TransactionType === 'TrustSet')
  {
    var limit = 'LimitAmount' in m.transaction
                  ? Amount.from_json(m.transaction.LimitAmount).to_human_full(opts_gateways) + " "
                  : "";

    say_type  = 'TRS';
    say_watch = limit
                  + UInt160.json_rewrite(m.transaction.Account, opts_gateways);
  }
  else if (m.transaction.TransactionType === 'OfferCreate')
  {
    // console.log("OfferCreate: ", JSON.stringify(m, undefined, 2));

    var owner       = UInt160.json_rewrite(m.transaction.Account, opts_gateways);
    var taker_gets  = Amount.from_json(m.transaction.TakerGets);
    var taker_pays  = Amount.from_json(m.transaction.TakerPays);
    var b_fok       = !!(m.transaction.Flags & Transaction.flags.OfferCreate.FillOrKill);
    var b_ioc       = !!(m.transaction.Flags & Transaction.flags.OfferCreate.ImmediateOrCancel);

//    say_type  = b_fok ? 'FOK' : b_ioc ? 'IOC' : 'OFR';
//    say_watch = UInt160.json_rewrite(m.transaction.Account, opts_gateways)
//          + " #" + m.transaction.Sequence
//          + " offers " + taker_gets.to_human_full(opts_gateways)
//          + " for " + taker_pays.to_human_full(opts_gateways);

    if (m.meta.TransactionResult === 'tesSUCCESS'
      && (taker_gets.is_native() || taker_pays.is_native()))
    {
      process_offers(m);
github radrbiz / radard / test / testutils.js View on Github external
function verify_balance(remote, src, amount_json, callback) {
  assert.strictEqual(arguments.length, 4);

  var amount_req  = Amount.from_json(amount_json);
  src = UInt160.json_rewrite(src);

  if (amount_req.is_native()) {
    var options = {account: src, ledger: 'current'};
    remote.request_account_balance(options, function(err, amount_act) {
      if (err) {
        return callback(err);
      }
      var valid_balance = amount_act.equals(amount_req, true);
      if (!valid_balance) {
        //console.log('verify_balance: failed: %s / %s',
        //amount_act.to_text_full(),
        //amount_req.to_text_full());
      }
      callback(valid_balance ? null : new Error('Balance invalid: ' + amount_json + ' / ' + amount_act.to_json()));
    });
  } else {
github ripple / rippled / test / testutils.js View on Github external
function verify_balance(remote, src, amount_json, callback) {
  assert.strictEqual(arguments.length, 4);

  var amount_req  = Amount.from_json(amount_json);
  src = UInt160.json_rewrite(src);

  if (amount_req.is_native()) {
    var options = {account: src, ledger: 'current'};
    remote.request_account_balance(options, function(err, amount_act) {
      if (err) {
        return callback(err);
      }
      var valid_balance = amount_act.equals(amount_req, true);
      if (!valid_balance) {
        //console.log('verify_balance: failed: %s / %s',
        //amount_act.to_text_full(),
        //amount_req.to_text_full());
      }
      callback(valid_balance ? null : new Error('Balance invalid: ' + amount_json + ' / ' + amount_act.to_json()));
    });
  } else {
github ripple-unmaintained / ripple-watch / bot.js View on Github external
+ (pay_diff ? "!" : "")
                    + " "
                    + UInt160.json_rewrite(m.transaction.Account, opts_gateways) + st
                    + " > "
                    + (created ? "!" : "")
                    + UInt160.json_rewrite(m.transaction.Destination, opts_gateways) + dt
                    + (created ? "!" : "");

    say_watch_irc = (pay_diff ? "\u0002" : "")
                    + colorize('irc', say_amount, pay_diff)
                    + (pay_diff ? "\u000f" : "")
                    + " "
                    + UInt160.json_rewrite(m.transaction.Account, opts_gateways) + st
                    + " > "
                    + (created ? "\u0002" : "")
                    + UInt160.json_rewrite(m.transaction.Destination, opts_gateways) + dt
                    + (created ? "\u000f" : "");

    process_offers(m);
  }
  else if (m.transaction.TransactionType === 'AccountSet')
  {
    console.log("transaction: ", JSON.stringify(m, undefined, 2));

    say_type  = 'ACT';
    say_watch = UInt160.json_rewrite(m.transaction.Account, opts_gateways);
  }
  else if (m.transaction.TransactionType === 'TrustSet')
  {
    var limit = 'LimitAmount' in m.transaction
                  ? Amount.from_json(m.transaction.LimitAmount).to_human_full(opts_gateways) + " "
                  : "";
github ripple-unmaintained / ripple-watch / bot.js View on Github external
var b_gateway_src = !!gateway_addresses[UInt160.json_rewrite(m.transaction.Account)];
    var b_gateway_dst = !!gateway_addresses[UInt160.json_rewrite(m.transaction.Destination)];
    var pay_diff      = b_gateway_src
                          ? +1
                          : b_gateway_dst
                            ? -1
                            : 0;

    var say_amount    = Amount.from_json(m.transaction.Amount).to_human_full(opts_gateways);

    say_type    = 'PAY';
    say_watch   = (pay_diff ? "!" : "")
                    + colorize('console', say_amount, pay_diff)
                    + (pay_diff ? "!" : "")
                    + " "
                    + UInt160.json_rewrite(m.transaction.Account, opts_gateways) + st
                    + " > "
                    + (created ? "!" : "")
                    + UInt160.json_rewrite(m.transaction.Destination, opts_gateways) + dt
                    + (created ? "!" : "");

    say_watch_irc = (pay_diff ? "\u0002" : "")
                    + colorize('irc', say_amount, pay_diff)
                    + (pay_diff ? "\u000f" : "")
                    + " "
                    + UInt160.json_rewrite(m.transaction.Account, opts_gateways) + st
                    + " > "
                    + (created ? "\u0002" : "")
                    + UInt160.json_rewrite(m.transaction.Destination, opts_gateways) + dt
                    + (created ? "\u000f" : "");

    process_offers(m);
github ripple-unmaintained / ripple-watch / bot.js View on Github external
&& m.meta.AffectedNodes.filter(function (node) {
        return node.CreatedNode
          && node.CreatedNode.LedgerEntryType === 'AccountRoot'
          && node.CreatedNode.NewFields.Account === m.transaction.Destination;
      }).length;

    var st  = 'number' === typeof m.transaction.SourceTag
      ? "?st=" + m.transaction.SourceTag
      : "";

    var dt  = 'number' === typeof m.transaction.DestinationTag
      ? "?dt=" + m.transaction.DestinationTag
      : "";

    var b_gateway_src = !!gateway_addresses[UInt160.json_rewrite(m.transaction.Account)];
    var b_gateway_dst = !!gateway_addresses[UInt160.json_rewrite(m.transaction.Destination)];
    var pay_diff      = b_gateway_src
                          ? +1
                          : b_gateway_dst
                            ? -1
                            : 0;

    var say_amount    = Amount.from_json(m.transaction.Amount).to_human_full(opts_gateways);

    say_type    = 'PAY';
    say_watch   = (pay_diff ? "!" : "")
                    + colorize('console', say_amount, pay_diff)
                    + (pay_diff ? "!" : "")
                    + " "
                    + UInt160.json_rewrite(m.transaction.Account, opts_gateways) + st
                    + " > "
                    + (created ? "!" : "")
github ripple-unmaintained / ripple-watch / bot.js View on Github external
var created = m.meta
      && m.meta.AffectedNodes.filter(function (node) {
        return node.CreatedNode
          && node.CreatedNode.LedgerEntryType === 'AccountRoot'
          && node.CreatedNode.NewFields.Account === m.transaction.Destination;
      }).length;

    var st  = 'number' === typeof m.transaction.SourceTag
      ? "?st=" + m.transaction.SourceTag
      : "";

    var dt  = 'number' === typeof m.transaction.DestinationTag
      ? "?dt=" + m.transaction.DestinationTag
      : "";

    var b_gateway_src = !!gateway_addresses[UInt160.json_rewrite(m.transaction.Account)];
    var b_gateway_dst = !!gateway_addresses[UInt160.json_rewrite(m.transaction.Destination)];
    var pay_diff      = b_gateway_src
                          ? +1
                          : b_gateway_dst
                            ? -1
                            : 0;

    var say_amount    = Amount.from_json(m.transaction.Amount).to_human_full(opts_gateways);

    say_type    = 'PAY';
    say_watch   = (pay_diff ? "!" : "")
                    + colorize('console', say_amount, pay_diff)
                    + (pay_diff ? "!" : "")
                    + " "
                    + UInt160.json_rewrite(m.transaction.Account, opts_gateways) + st
                    + " > "