luniehq / cosmos-api Goto Github PK
View Code? Open in Web Editor NEWLibrary for interacting with applications built on the Cosmos SDK ๐
Home Page: https://lunie.io
License: Apache License 2.0
Library for interacting with applications built on the Cosmos SDK ๐
Home Page: https://lunie.io
License: Apache License 2.0
The examples seem outdated. Would appreciate if someone could update them. Thanks!
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.
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!
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:
Describe alternatives you've considered
Additional context
Hi, I was wondering if there were plans to support RPC subscriptions, so that we can obtain real-time block header and TX data. Currently I'm using https://github.com/nomic-io/js-tendermint + https://github.com/cosmos/amino-js to do this (and am using this library as an RPC query/tx wrapper), but it would be nice to have a single library solution. Please let me know if this feature is feasible, thanks!
Currently there is no way to easily perform the following workflow:
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!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.