npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

swtc-utils

v1.3.2

Published

swtc utils

Downloads

41

Readme

The COMMUNITY SWTC JavaScript Library for DEVELOPERS - Transaction

swtc-transaction is seprated package from swtc-lib (jingtum-lib)

keeps the same interface as original without websocket dependancy

zero config webpack and browerify

adds transaction builds and submit

support multiple Remote including swtc-lib(websocket) and swtc-api(api)

Changes

  • add method signPromise() and submitPromise()
  • typescript OrderBook
  • typescript support
  • add methods buildRelationTx()
  • support null Remote, swtc-api Remote and swtc-lib Remote
  • add method submitApi() to submit transactions to https://api.jingtum.com by default
  • add methods buildPaymentTx(), buildOfferCreateTX(), buildOfferCancelTx()
  • seperate package from swtc-lib

Getting and Using swtc-transaction

Via npm for Node.js

  $ npm install swtc-transaction  // node.js and web app
const Transaction = require("swtc-transaction").Transaction // cjs import
// or
import { Transaction } from "swtc-transaction" // esm import

Using swtc-transaction

  • const tx = Transaction.buildPaymentTx(options)
  • const tx = Transaction.buildPaymentTx(options, remote={})
  • const tx = Transaction.buildPaymentTx(options, remote={_axios: axios.create({})})
  • const tx = Transaction.buildOfferCreateTx(options, remote={})
  • const tx = Transaction.buildOfferCancelTx(options, remote={})
  • local sign and submit
tx.addMemo() // optional
tx.setSecret("s......................")
tx.setSequence(100) // optional, automatic during signing
tx.sign(callback) // async function
tx.submitApi() // returns promise

example

> tx = TX.buildPaymentTx({source: DATA.address, to: DATA.address2, amount: {value: 0.1, currency: 'SWT', issuer: ''}})
Transaction {
  domain:
   Domain {
     domain: null,
     _events:
      [Object: null prototype] {
        removeListener: [Function: updateExceptionCapture],
        newListener: [Function: updateExceptionCapture],
        error: [Function: debugDomainError] },
     _eventsCount: 3,
     _maxListeners: undefined,
     members: [] },
  _events: [Object: null prototype] {},
  _eventsCount: 0,
  _maxListeners: undefined,
  _remote: {},
  _token: 'swt',
  tx_json:
   { Flags: 0,
     Fee: 10000,
     TransactionType: 'Payment',
     Account: 'jGxW97eCqxfAWvmqSgNkwc2apCejiM89bG',
     Amount: '100000',
     Destination: 'jLvo6LSKNEYJ4KDwDuM8LU5fuSsQkE4HVW' },
  _filter: [Function],
  _secret: undefined }
> tx.setSecret(DATA.secret)
undefined
> tx.sign(console.log)
undefined
> null '120000220000000024000002326140000000000186A0684000000000002710732102197F1426BCA2F59B6B910F0391E55888B4FE80AF962478493104A33274B1B03A74473045022100F0175B4AFF5B1E348FC46A8C0021FF22B16CF87113C0B6E042174374416B071102203CB8A47A82576B69DB50051DF943C87872BB8F065A2D12B01ACA03890FAC8E548114AF09183A11AA70DA06E115E03B0E5478232740B58314DA976A4DE4827163F062B09050832D8D78025D5A'

> tx.tx_json
{ Flags: 0,
  Fee: 0.01,
  TransactionType: 'Payment',
  Account: 'jGxW97eCqxfAWvmqSgNkwc2apCejiM89bG',
  Amount: 0.1,
  Destination: 'jLvo6LSKNEYJ4KDwDuM8LU5fuSsQkE4HVW',
  Sequence: 562,
  SigningPubKey:
   '02197F1426BCA2F59B6B910F0391E55888B4FE80AF962478493104A33274B1B03A',
  TxnSignature:
   '3045022100F0175B4AFF5B1E348FC46A8C0021FF22B16CF87113C0B6E042174374416B071102203CB8A47A82576B69DB50051DF943C87872BB8F065A2D12B01ACA03890FAC8E54',
  blob:
   '120000220000000024000002326140000000000186A0684000000000002710732102197F1426BCA2F59B6B910F0391E55888B4FE80AF962478493104A33274B1B03A74473045022100F0175B4AFF5B1E348FC46A8C0021FF22B16CF87113C0B6E042174374416B071102203CB8A47A82576B69DB50051DF943C87872BB8F065A2D12B01ACA03890FAC8E548114AF09183A11AA70DA06E115E03B0E5478232740B58314DA976A4DE4827163F062B09050832D8D78025D5A' }
> tx.submitApi().then(console.log).catch(console.log)
Promise {}
> { status: 200,
  statusText: 'OK',
  data:
   { success: true,
     status_code: '0',
     engine_result: 'tesSUCCESS',
     engine_result_code: 0,
     engine_result_message:
      'The transaction was applied. Only final in a validated ledger.',
     tx_blob:
      '120000220000000024000002326140000000000186A0684000000000002710732102197F1426BCA2F59B6B910F0391E55888B4FE80AF962478493104A33274B1B03A74473045022100F0175B4AFF5B1E348FC46A8C0021FF22B16CF87113C0B6E042174374416B071102203CB8A47A82576B69DB50051DF943C87872BB8F065A2D12B01ACA03890FAC8E548114AF09183A11AA70DA06E115E03B0E5478232740B58314DA976A4DE4827163F062B09050832D8D78025D5A',
     tx_json:
      { Account: 'jGxW97eCqxfAWvmqSgNkwc2apCejiM89bG',
        Amount: '100000',
        Destination: 'jLvo6LSKNEYJ4KDwDuM8LU5fuSsQkE4HVW',
        Fee: '10000',
        Flags: 0,
        Sequence: 562,
        SigningPubKey:
         '02197F1426BCA2F59B6B910F0391E55888B4FE80AF962478493104A33274B1B03A',
        TransactionType: 'Payment',
        TxnSignature:
         '3045022100F0175B4AFF5B1E348FC46A8C0021FF22B16CF87113C0B6E042174374416B071102203CB8A47A82576B69DB50051DF943C87872BB8F065A2D12B01ACA03890FAC8E54',
        hash:
         '48D94F52CD0D9FD60634DEB5886D27149551235BD6CDA1C752F817C3290C327B' } } }

>

Involving swtc-transaction

Build from the source and test

  $ git clone https://github.com/swtcca/swtc-lib.git -b transaction swtc-transaction
  $ cd swtc-transaction; npm install
  $ npm run build or npm run build:production (optional for static browser)
  $ npm run test