Git Product home page Git Product logo

cosmos-api's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar faboweb avatar jbibla avatar jnaviask avatar okwme avatar williamchong avatar yakovl 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

Watchers

 avatar  avatar  avatar  avatar  avatar

cosmos-api's Issues

`private key should be a Buffer` when using `signWithPrivateKey` with node.js

Following the examples I receive an error message saying private key should be a Buffer when calling signWithPrivateKey.

import { signWithPrivateKey } from "@lunie/cosmos-keys";
import { createSignedTransaction } from "@lunie/cosmos-api";

const privateKey = Buffer.from(privateKey, "hex");

const signMessage = await createSignedTransaction(
    { gas: 1000, gasPrices: [{ amount: "10", denom: "uatom" }], memo: `Hi from Lunie` },
    [
        {
            type: `cosmos-sdk/Send`,
            value: {
                inputs: [
                    {
                        address: `cosmos1qperwt9wrnkg5k9e5gzfgjppzpqhyav5j24d66`,
                        coins: [{ denom: `STAKE`, amount: `1` }],
                    },
                ],
                outputs: [
                    {
                        address: `cosmos1yeckxz7tapz34kjwnjxvmxzurerquhtrmxmuxt`,
                        coins: [{ denom: `STAKE`, amount: `1` }],
                    },
                ],
            },
        },
    ],
    (signMessage) => signWithPrivateKey(signMessage, privateKey),
    "test-chain",
    0,
    12,
);

console.log(signMessage);

I tried the above code on node.js 10, 12 and 14. The issue seems to be that a different Buffer than the default node.js Buffer is used which then results in the above code blowing up because the private key is a Buffer but not of the expected type because the base classes differ.

      at Object.t.isBuffer (node_modules/@lunie/cosmos-keys/lib/webpack:/cosmos-keys/cosmos-keys.js:8:1)
      at Object.sign (node_modules/@lunie/cosmos-keys/lib/webpack:/cosmos-keys/cosmos-keys.js:8:1)
      at Module.b (node_modules/@lunie/cosmos-keys/lib/webpack:/cosmos-keys/cosmos-keys.js:8:1)

This file indicates that feross/buffer is used.

/*!
 * The buffer module from node.js, for the browser.
 *
 * @author   Feross Aboukhadijeh <http://feross.org>
 * @license  MIT
 */

What would be the proposed solution? It looks like feross/buffer thinks that I am either in a Browser or it is simply incapable to recognize that the node.js Buffer in fact is a valid buffer.

"Uncaught ReferenceError: regeneratorRuntime is not defined"

I'm trying to use the API in a project built on webpack, and I get this error at runtime (build is performed successfully). I've tried a lot of the proposed solutions through Googling and none were able to resolve this issue. Any ideas? Is there a specific babel module I need to include at the right place? Thanks!

Remove Yarn

Is your feature request related to a problem? Please describe.

We have been using Yarn because of the lock file for quiet some time. This is not necessary anymore as npm already since a while has this feature as well. Yarn has some syntax advantages, but it doesn't value the weight of another tool.

Describe the solution you'd like

Remove Yarn from this repository:

  • lock file
  • package.json
  • continuous integration

Describe alternatives you've considered

Additional context

Support send with offline signature.

Currently there is no way to easily perform the following workflow:

  1. Generate a transaction without a signature.
  2. Create a signature from the transaction via command line (offline).
  3. Construct the signed transaction.
  4. Broadcast the signed transaction.

Steps 1-3 are more or less doable, but there's no function to send a transaction signed offline.

The most obvious solution would be to refactor this piece into a separate "broadcastSignedTx()" function: https://github.com/luniehq/cosmos-api/blob/develop/src/send.js#L11 I can submit a PR if that would help. Thanks!

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.