GithubHelp home page GithubHelp logo

cosmos / amino-js Goto Github PK

View Code? Open in Web Editor NEW
31.0 31.0 49.0 4.62 MB

go-amino + GopherJS + TypeScript

Home Page: https://cosmos.github.io/amino-js/

License: Apache License 2.0

JavaScript 0.58% Go 57.91% TypeScript 41.51%

amino-js's Introduction

ToC

Disambiguation

This Cosmos is not related to the React-Cosmos project (yet). Many thanks to Evan Coury and Ovidiu (@skidding) for this Github organization name. As per our initial agreement, this disambiguation notice will stay here.

amino-js's People

Contributors

jordaaash avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

amino-js's Issues

marshalPubKeyMultisigThreshold sample request

Hi,

Can you give me a simple example of marshalizing multisig account object using marshalPubKeyMultisigThreshold() function? In the first place, I'm struggling to create json object of PubKeyMultisigThreshold that is one of the parametes of marshalPubKeyMultisigThreshold().

Todo: update Cosmos SDK and Tendermint types

While resolving #7, I noted that some file names and types in go/lib are out of sync with the versions of the SDK and Tendermint in use.

It's possible that this library's copies were based on the master repositories of the SDK and Tendermint at the time rather than the fixed version releases. I'll be going over the SDK @ 0.35.0 and Tendermint @ 0.31.7 in the fix-types branch to update.

This is also relevant to the work that needs to be done on #3. Figuring out a solution to automate this process might be in scope.

Yarn setup scripts throw errors after first use

The yarn:setup script as presented in the README worked during the initial project setup, but the ordering generates errors if the cmd is run again. I'm able to get around the errors by cherry-picking the functionality. Although these issues will likely be avoided if users only run yarn:setup once, the scripts may need to be updated to avoid confusion.

Scripts from package.json:

"clean":     "rm -rf ./dist/*",
"dirs":      "mkdir ./dist",
"dist:dev":  "yarn clean && yarn go && NODE_ENV=development yarn build",
"setup":     "yarn dirs && yarn dist:dev",

Cmd: yarn setup
Issue: yarn dirs makes ./dist dir before it's cleaned by yarn dist:dev
Result: mkdir: ./dist: File exists -> error Command failed with exit code 1.

Cmd: yarn clean
Issue: yarn clean doesn't remove ./dist dir
Result: Attempting to clean first before cherry-picking yarn dist:dev resulted in the same error as above. Was able to resolve by running rm -rf ./dist prior to yarn setup

amino-js fails to unmarshal a transaction

amino-js v0.4.4 fails to unmarshal (calling unmarshalTx()) this transaction https://www.mintscan.io/txs/7E523023AB564A2AC165503CE66EFA23AAE99D39E89A859BC905093864A8D4A1

The error message is Error: unmarshal to types.Tx failed after 17 bytes (error reading array contents: unrecognized prefix bytes 436F736D)

Here's the transaction in its amino/base64 encoded form (according to a GET /blocks/2567202 call to the Cosmos REST API):

uxfwYl3uCrAWtC1hTgofQ29zbW9zIEh1YiAzIFVwZ3JhZGUgUHJvcG9zYWwgRRLdFUZpZ21lbnQgTmV0d29ya3MgKGh0dHBzOi8vZmlnbWVudC5uZXR3b3JrKQoKLT0tPS0KCkZ1bGwgcHJvcG9zYWw6Cmh0dHBzOi8vaXBmcy5pby9pcGZzL1FtZkp5ZDY0c3JKU1g4MjRXb05uRjZCYnZGNHd2UEdxVkJ5blplTjk4Qzd5Z3EKCi09LT0tCgpfRGVjaXNpb25fCgpXZSBhcmUgc2lnbmFsbGluZyB0aGF0OgoKMS4gVGhlIEdhaWEgMi4wLjMgaW1wbGVtZW50YXRpb24gaXMgYWxpZ25lZCB3aXRoIHRoZSBsaXN0IG9mIGhpZ2gtbGV2ZWwgY2hhbmdlcyBhcHByb3ZlZCBpbiBDb3Ntb3MgSHViIDMgVXBncmFkZSBQcm9wb3NhbCBBLgoKMi4gV2UgYXJlIHByZXBhcmVkIHRvIHVwZ3JhZGUgdGhlIENvc21vcyBIdWIgdG8gY29zbW9zaHViLTMgYmFzZWQgdXBvbgoJYS4gQ29tbWl0IGhhc2g6IDJmNjc4M2UyOThmMjVmZjRlMTJjYjg0NTQ5Nzc3MDUzYWI4ODc0OWE7CgliLiBUaGUgc3RhdGUgZX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XRvbRIIMTIwMDAwMDASFgoQCgV1YXRvbRIHMTQwMDAwMBDAmgwaagom61rphyECbBkcVpHNEJPxF+jExArw3TClQZuDf9VHGAb4d5HDAgoSQPptMTINbW5vADVyreOmURHGI69xIR2LHULPmoqQGxXJTmlSQ+kzkP51iMBxC1RK6N5+LTfQmrmXScUDFJVTvps=

How to make extension of the new type

Hi there,
Its really a fantastic project here for cosmos-sdk as js output! Let me introduce myself, I'm from QOS Group, a partner in cosmos ecosystem. Its quite new and suitable for us when there is blockchain QOS based on tendermint rather than cosmos itself.
I want to extend the specific type of qos tx as the same way of other cosmos types deployed.
Is there more detailed instruction than extend.md?
Thanks~

PS: you can also refer to our issue if you are interested: QOSGroup/qweb#22

Published TS declarations should not depend directly on source files

Currently index.d.ts exports everything from src/, which means other TS projects which use this library have to compile those source files. If the consumer's TS settings are different this leads to problems, e.g. this error which we've encountered:

../../node_modules/@tendermint/amino-js/src/util.ts:21:49 - error TS2304: Cannot find name 'window'.

21     ({ atob, btoa, TextDecoder, TextEncoder } = window);

Separate declaration files would ideally be generated from the source files, so that the library can be used by other TS projects regardless of differences in TS config.

Fail to unmarshal tx data from a block

Using:
[email protected]
@tendermint/[email protected]
@tendermint/[email protected]

Trying to decode tx from block with:


import { decodeString, unmarshalTx } from '@tendermint/amino-js';
import { base64ToBytes } from '@tendermint/belt'; 

  decodeTx(txHash) {
    try {
      const decoded = base64ToBytes(txHash); 
      const unmarshaled = unmarshalTx(decoded);
      return decoded
    }
    catch (error) {
      console.log(error)
      return null
    }
  }

Throws this error on every tx data string from blocks:
For example:

3wEoKBapCluclZNGChRm0QXKCIrFakuLzpL0oqW3MHzH/RIUyTRRx8hJmGRpUL1G+yw8xXQRSHsaFE3H7L64W8UP7sICyw32yIwMNrM6IhMKBXVhdG9tEgoyMDQ5ODQ5MTQwEhAKCgoFdWF0b20SATEQgNMOGmoKJuta6YchAzpqNiIl4AIZl3rIYeUHLU10NyCNiEapGx3SKZ338sTwEkDgs/cND/XjaiNySQxrLQRGbgaLqhyyjozvYozBqvmAiEVxiG5W63DzhGm8UeMxXDh3zemjyMfkZB0XAGqcjs8V

at block 1416024

Error: unmarshal to types.Tx failed after 4 bytes (unrecognized prefix bytes 282816A9): 282816A90A5B9C9593460A1466D105C.....6A9C8ECF15

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.