-
Notifications
You must be signed in to change notification settings - Fork 954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Light SDK #2220
Light SDK #2220
Conversation
light_sdk/src/lib.rs
Outdated
pub const TX_REVEAL_PK_HASH: [u8; 32] = [0x8d, 0x4e, 0x20, 0x08, 0x30, 0xa9, 0xf6, 0x03, 0xd6, 0x47, 0x79, 0x9f, 0xaf, 0xdb, 0xf1, 0x94, 0x6e, 0x07, 0xa0, 0x38, 0xa6, 0x7c, 0xfa, 0x09, 0xd4, 0xee, 0xb3, 0x1c, 0x80, 0xc7, 0x74, 0xce]; | ||
|
||
/// Takes any kind of inner tx and gives me back my sign bytes | ||
pub fn get_inner_sign_bytes(mut tx: Tx) -> Hash { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be immutable functions on a specific RevealPk struct. Ie. this signature should be repeated for every type of transaction.
Also this function should be immutable.
light_sdk/src/tx_builders/mod.rs
Outdated
|
||
pub mod pos; | ||
|
||
pub(in crate::tx_builders) fn build_tx( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no generics - everything should be passed in as strings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is not exposed to the SDK user
light_sdk/src/tx_builders/mod.rs
Outdated
} | ||
|
||
pub(in crate::tx_builders) fn attach_raw_signatures( | ||
mut tx: Tx, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no mutability - we should consume the tx object and return a new one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I'm doing here but I need the object to be mutable in the scope of the function
light_sdk/src/tx_builders/pos.rs
Outdated
/// Generate the signature(s) for the given transaction and signers | ||
pub fn generate_signatures( | ||
mut self, | ||
secret_keys: &[common::SecretKey], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the library doesn't take secret keys.
it should expose sign_bytes()
and then the caller figures out how to sign it
light_sdk/src/tx_builders/pos.rs
Outdated
} | ||
|
||
/// Generate the signature(s) for the given transaction and signers | ||
pub fn generate_signatures( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
likewise - this kind of function shouldn't exist in the public api
light_sdk/src/reading/mod.rs
Outdated
/// Lookup the full response accompanying the specified transaction event | ||
pub fn query_tx_response( | ||
tendermint_addr: &str, | ||
tx_query: TxEventQuery<'_>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is essentially a hash, right? Can this type be instantiated by the caller?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I changed this to take a &str
. It means you can only query applied txs and not accepted, but I think that is totally fine.
light_sdk/src/reading/mod.rs
Outdated
} | ||
|
||
/// Query a validator's unbonds for a given epoch | ||
pub fn query_and_print_unbonds( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's not have print options in the api. if a caller wants to print something, they can do it in their own code.
@@ -0,0 +1,679 @@ | |||
use std::str::FromStr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall I like the api.
It's probably better to split the individual submodules into their own files.
@@ -0,0 +1,3 @@ | |||
pub mod blocking {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be just 1 function - submit_tx().
2561ee9
to
4a148f9
Compare
* origin/adrian/light-sdk: Adds a method to serialize transactions Makes internal struct of `RevealPk` private Fixes datetime Splits light sdk queries into multiple files Renames light sdk crate and adds description Adds missing feature for tendermint-rpc in light sdk Changelog #2220 Imports `HttpClient` from `tendermint_rpc` Updates types and imports after rebase Updates docstrings and fixes clippy Some small type simplifications in the reading api [feat]: Added rpc functions to light sdk Renames `get_msg_to_sign` to `get_sign_bytes` [feat]: Small fixes and making stuff public First draft of all transactions in light sdk Refactors pos txs in separate file. Improved shared functions Created light SDK builders. First attempt at overview of light-sdk
* origin/adrian/light-sdk: Adds a method to serialize transactions Makes internal struct of `RevealPk` private Fixes datetime Splits light sdk queries into multiple files Renames light sdk crate and adds description Adds missing feature for tendermint-rpc in light sdk Changelog #2220 Imports `HttpClient` from `tendermint_rpc` Updates types and imports after rebase Updates docstrings and fixes clippy Some small type simplifications in the reading api [feat]: Added rpc functions to light sdk Renames `get_msg_to_sign` to `get_sign_bytes` [feat]: Small fixes and making stuff public First draft of all transactions in light sdk Refactors pos txs in separate file. Improved shared functions Created light SDK builders. First attempt at overview of light-sdk
* origin/adrian/light-sdk: Adds a method to serialize transactions Makes internal struct of `RevealPk` private Fixes datetime Splits light sdk queries into multiple files Renames light sdk crate and adds description Adds missing feature for tendermint-rpc in light sdk Changelog #2220 Imports `HttpClient` from `tendermint_rpc` Updates types and imports after rebase Updates docstrings and fixes clippy Some small type simplifications in the reading api [feat]: Added rpc functions to light sdk Renames `get_msg_to_sign` to `get_sign_bytes` [feat]: Small fixes and making stuff public First draft of all transactions in light sdk Refactors pos txs in separate file. Improved shared functions Created light SDK builders. First attempt at overview of light-sdk
Describe your changes
Implements a first version of a simpler, more user-friendly SDK.
Indicate on which release or other PRs this topic is based on
Commit 74d412e of
base
(v0.28.1)Checklist before merging to
draft