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

@cybercongress/js-amino

v1.0.0

Published

JS Implementation of Amino

Downloads

12

Readme

Coverage Status

For more information spec, please refer: https://github.com/tendermint/go-amino

Features:

  1. Encode and Decode simple types: ints 8/16/32/64, booleans, strings, bytes
  2. Encode and Decode recursive Structs and Interfaces, Arrays
  3. Encode simple Time data

Install From NPM:

Run npm i js-amino

Install From Source

  1. Run npm install

Running The Examples

  1. cd src/examples
  2. go get
  3. Run examples, e. g. in Go: go run string.go and in JS node string.js

Running The Unit Test

  1. Run npm test

To Do:

  1. Full support for Time encoding and decoding
  2. More Unit test
  3. Benchmarking

Gitcoin program

Our cosmos ecosystem initiative

Usage (MsgMultiSend example)

const {
    Codec,
    FieldOtions,
    TypeFactory,
    Utils,
    Types,
    WireTypes,
} = require('../index');

let StdTx = TypeFactory.create('StdTx', [{
        name: 'msg',
        type: Types.ArrayInterface,
    },
    {
        name: 'fee',
        type: Types.Struct,
    },
    {
        name: 'signatures',
        type: Types.ArrayStruct,
    },
    {
        name: 'memo',
        type: Types.String,
    },
]);

let MsgMultiSend = TypeFactory.create('MsgMultiSend', [{
        name: "inputs",
        type: Types.ArrayStruct
    },
    {
        name: "outputs",
        type: Types.ArrayStruct 
    }
]);

let Coin = TypeFactory.create('coin', [{
        name: 'denom',
        type: Types.String,
    },
    {
        name: 'amount',
        type: Types.String,
    }
]);

let Input = TypeFactory.create('input', [{
        name: 'address',
        type: Types.String,
    },
    {
        name: 'coins',
        type: Types.ArrayStruct,
    }
]);

let Output = TypeFactory.create('output', [{
        name: 'address',
        type: Types.String,
    },
    {
        name: 'coins',
        type: Types.ArrayStruct,
    }
]);

let Fee = TypeFactory.create('fee', [{
        name: 'amount',
        type: Types.ArrayStruct,
    },
    {
        name: 'gas',
        type: Types.Int64,
    }
]);

let PubKeySecp256k1 = TypeFactory.create('PubKeySecp256k1', [{
    name: 's',
    type: Types.ByteSlice,
}], Types.ByteSlice)

let Signature = TypeFactory.create('signature', [{
        name: 'pub_key',
        type: Types.Interface,
    },
    {
        name: 'signature',
        type: Types.ByteSlice,
    }
])

let codec = new Codec();

codec.registerConcrete(new StdTx(), 'auth/StdTx', {});
codec.registerConcrete(new MsgMultiSend(), 'cosmos-sdk/MsgMultiSend', {});
codec.registerConcrete(new PubKeySecp256k1(), 'tendermint/PubKeySecp256k1', {});

let coin = new Coin('cyb', "10000");

let addressFrom = [ 59,58,243,13,132,163,164,202,233,7,236,93,136,166,181,175,236,69,48,186 ]
let addressTo = [ 94,222,114,42,196,107,51,203,139,142,219,243,137,60,54,250,139,153,46,168 ]
  
let input = new Input(addressFrom, [coin]);
let output = new Output(addressTo, [coin]);
let sendMultiMsg = new MsgMultiSend([input], [output]);
let fee = new Fee([new Coin('cyb', '0')], 200000);

let pubKey = new PubKeySecp256k1([2,27,24,0,255,96,147,21,64,29,132,192,108,219,59,134,206,201,126,224,63,160,24,236,170,124,164,95,43,180,6,246,250]);
let signature = [165,76,109,61,53,129,190,147,52,224,34,106,235,208,224,36,190,25,204,36,226,129,97,109,35,130,217,228,144,106,10,134,14,183,95,252,219,235,22,92,37,53,3,89,111,173,12,158,146,71,82,113,236,241,170,121,217,20,236,23,131,35,80,29];

let sig = new Signature(pubKey, signature);
let stdTx = new StdTx([sendMultiMsg], fee, [sig], 'elonmusk');

let jsonTx = codec.marshalJson(stdTx);
let decodedDataTx = new StdTx();

console.log("Binary stdTx:\n", (codec.marshalBinary(stdTx)).toString());
console.log("Json:\n", jsonTx);
codec.unMarshalBinary(codec.marshalBinary(stdTx), decodedDataTx);
console.log("Decoded data:\n", decodedDataTx.JsObject());
Binary stdTx:
  220,1,240,98,93,238,10,80,194,104,154,209,10,36,10,20,59,58,243,13,132,163,164,202,233,7,236,93,136,166,181,175,236,69,48,186,18,12,10,3,99,121,98,18,5,49,48,48,48,48,18,36,10,20,94,222,114,42,196,107,51,203,139,142,219,243,137,60,54,250,139,153,46,168,18,12,10,3,99,121,98,18,5,49,48,48,48,48,18,14,10,8,10,3,99,121,98,18,1,48,16,192,154,12,26,106,10,38,235,90,233,135,33,2,27,24,0,255,96,147,21,64,29,132,192,108,219,59,134,206,201,126,224,63,160,24,236,170,124,164,95,43,180,6,246,250,18,64,165,76,109,61,53,129,190,147,52,224,34,106,235,208,224,36,190,25,204,36,226,129,97,109,35,130,217,228,144,106,10,134,14,183,95,252,219,235,22,92,37,53,3,89,111,173,12,158,146,71,82,113,236,241,170,121,217,20,236,23,131,35,80,29,34,8,101,108,111,110,109,117,115,107

Json:
 {"type":"auth/StdTx","value":{"msg":[{"type":"cosmos-sdk/MsgMultiSend","value":{"inputs":[{"address":[59,58,243,13,132,163,164,202,233,7,236,93,136,166,181,175,236,69,48,186],"coins":[{"denom":"cyb","amount":"10000"}]}],"outputs":[{"address":[94,222,114,42,196,107,51,203,139,142,219,243,137,60,54,250,139,153,46,168],"coins":[{"denom":"cyb","amount":"10000"}]}]}}],"fee":{"amount":[{"denom":"cyb","amount":"0"}],"gas":"200000"},"signatures":[{"pub_key":{"type":"tendermint/PubKeySecp256k1","value":"AhsYAP9gkxVAHYTAbNs7hs7JfuA/oBjsqnykXyu0Bvb6"},"signature":"pUxtPTWBvpM04CJq69DgJL4ZzCTigWFtI4LZ5JBqCoYOt1/82+sWXCU1A1lvrQyekkdScezxqnnZFOwXgyNQHQ=="}],"memo":"elonmusk"}}

Decoded data:
 { msg: [ { inputs: [Array], outputs: [Array] } ],
  fee: { amount: [ [Object] ], gas: 200000 },
  signatures: [ { pub_key: [Array], signature: [Array] } ],
  memo: 'elonmusk' }

Contributing Guide

Contributors

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

License

Code are licensed under MIT license by contributors