de-husk / cosm-tome Goto Github PK
View Code? Open in Web Editor NEW๐ฎ Easy to use Cosmos SDK rust client library ๐ฎ
License: Apache License 2.0
๐ฎ Easy to use Cosmos SDK rust client library ๐ฎ
License: Apache License 2.0
Right now Im exposing a CosmosClient
trait mock, but thats way too much detail for people only needing to mock the top level CosmTome
api.
We should also put this in the mocks
feature.
Key::Mnemonic("blah blah blah")
really only works for localnet.
We need a way to securely sign transactions for testnet / mainnet use cases.
Something that I find I would like to do often is bundle multiple types of messages together inside a vec and send them off. May want to send a wasm store_code, instantiate, then execute for example. It would be even better if this was inside the same tx. This could be achieved with a trait that look like this:
pub trait Request {
fn to_any(&self, sender_addr: Address) -> DeployResult<Any>;
}
impl<S> Request for ExecRequest<S>
where
S: Serialize + Clone + 'static,
{
fn to_any(&self, sender_addr: Address) -> DeployResult<Any> {
let proto = self.clone().to_proto(sender_addr)?;
let any = proto.to_any()?;
Ok(any)
}
}
impl<S> Request for StoreCodeRequest<S> {
...
}
Then one could simply pass a vec of these Request objects to an execute function that takes in a Vec<&dyn Request>
The function signature should probably look like this:
async fn broadcast_tx(&self, tx: &impl IntoIterator<Item = Raw>) -> Result<ChainTxResponse, ChainError>
This would be super useful for quickly sending off many txs. @de-husk if you don't have time for this I'd be happy to take a crack at it! My deployment software is regularly sending off 20-30 txs in a row so this would be super useful for me.
Right now I had to fork cosm-orc to use the current revision for cosm-tome
.
However this did prove Key::Raw
works in a real world setting 100%. CronCats/croncat-rs#111
pretty self explanatory. Generally good practice to derive these for your types. Would love to migrate my project over to this (currently using a hacked together fork) but I can't until I'm able to Serialize! I can submit a PR if you like.
First off, this is a cool project! Really appreciate the work you're doing here. I'm working on a ledger cosmos library written in pure rust. I would love to be able to integrate with the Key system you've built into this, but the current implementation doesn't work because it requires that you have direct access to the SigningKey (impossible with ledgers). For what I'm suggesting, each Key variant would have specific logic for how to sign a specific SignDoc. I have a prototype of how this would work if you'd like to see it, it's fairly straightforwards though. The Ledger library still has one last issue that I haven't solved yet, but it's 90% of the way to being functional.
let client = TendermintRPC::new(&chain_info.rpc_endpoint.clone().unwrap()).unwrap();
let cosm_tome = CosmTome::new(chain_info, client);
let wasm_data = std::fs::read(path)?;
let tx_options = TxOptions { timeout_height: None, fee: None, memo: "wasm_deploy".into() };
let req = StoreCodeRequest { wasm_data, instantiate_perms: None };
let response = cosm_tome.wasm_store(req, &key, &tx_options).await?; // <== error occurs in this line
full error message
serde parse error
Caused by:
missing field `id` at line 8 column 1
Location:
/Users/ewoolsey/.cargo/registry/src/github.com-1ecc6299db9ec823/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9
and the trace logs
[2022-12-23T22:30:49Z TRACE hyper::proto::h1::conn] maybe_notify; read_from_io blocked
[2022-12-23T22:30:49Z TRACE want] signal: Want
[2022-12-23T22:30:49Z TRACE hyper::proto::h1::conn] flushed({role=client}): State { reading: Init, writing: Init, keep_alive: Idle }
[2022-12-23T22:30:49Z TRACE want] signal: Want
[2022-12-23T22:30:49Z TRACE hyper::proto::h1::conn] flushed({role=client}): State { reading: Init, writing: Init, keep_alive: Idle }
[2022-12-23T22:30:49Z TRACE hyper::client::pool] put; add idle connection for ("http", 167.99.177.244:26657)
[2022-12-23T22:30:49Z DEBUG hyper::client::pool] pooling idle connection for ("http", 167.99.177.244:26657)
[2022-12-23T22:30:49Z DEBUG tendermint_rpc::client::transport::http::sealed] Incoming response: {
"jsonrpc": "2.0",
"error": {
"code": -32600,
"message": "Invalid Request",
"data": "error reading request body: http: request body too large"
}
}
serde parse error
Caused by:
missing field `id` at line 8 column 1
Location:
/Users/ewoolsey/.cargo/registry/src/github.com-1ecc6299db9ec823/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9
Everything works fine with small .wasm files < 300kB
Large ones > 530kB cause this error. The exact same message is working on a different build using tendermint_rpc 0.27
The web socket client has tons of advantages. Would be great to add support for it. If you're interested I could work on a PR?
People will be able to manually do this through the upcoming tx
module, but it would be really nice if users could just call bank_send_batch()
, wasm_execute_batch()
, etc and batch multiple msgs under the same transaction.
For now we are going to allow a single signer / payer of fees for all msgs.
Right now we are defaulting to BLOCKING
Currently there is no easy way to build on top of cosm-tome and generically handle different clients. I think the current method of bundling ChainConfig and a generic client T together inside CosmTome is not the best api. If I don't know which client I want to use at compile time there is no easy way to build on top. My suggestion is to completely do away with the CosmTome type and instead simply use extension traits. For every client that is CosmosClient we get all of the nice cosm_tome methods.
Here is an example of the current api
let client = CosmosgRPC::new(chain_info.grpc_endpoint.clone().unwrap());
let cosm_tome = CosmTome::new(chain_info, client);
let response = cosm_tome.wasm_execute(req, &key, &tx_options).await?;
and here is what it could look like with my suggested change
let client = CosmosgRPC::new(chain_info.grpc_endpoint.clone().unwrap());
let response = client.wasm_execute(chain_info, req, &key, &tx_options).await?;
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.