-
Notifications
You must be signed in to change notification settings - Fork 3
Feat/675 on chain ouis devaddrs #67
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
Open
bryzettler
wants to merge
26
commits into
main
Choose a base branch
from
feat/675-on-chain-ouis-devaddrs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 20 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
f14939b
opt for ::bigint casting on oui and id fields. Only use Decimal parsi…
bryzettler 141203b
wip
bryzettler b83d5e7
remove solana logic and add netid lora_field
bryzettler 26ebcdd
cmds for org managment done
bryzettler 7f46c3e
client => clients
bryzettler ac3beee
include only bare bones lora_field
bryzettler ad1a804
returning oui on creation
bryzettler 8de2d53
prune legacy code
bryzettler eacd7d0
Move solana operations to own struct
bryzettler abec39e
CliSolanaConfig => SolanaArgs
bryzettler a595b27
fix output for net_id and roaming org
bryzettler e171aaf
remove tests
bryzettler 7c3f653
testing
bryzettler 10e0f2e
remove cargo patches
bryzettler 9c40574
self review
bryzettler 2e05c75
fixes after helium-lib pr feedback
bryzettler 3d84ead
tweaks to work with pr feedback of wallet-rs
bryzettler d55042a
flow works
bryzettler 285b921
update readme
bryzettler 7a40d77
unpatch crates
bryzettler ae20460
commands all working with keypair.bin
bryzettler ef73a4b
update readme and env init
bryzettler 9b7d85c
comment out patches
bryzettler 3d13c49
tweak
bryzettler efc3102
address pr comments
bryzettler 9f1f6dd
tweaks
bryzettler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| use crate::{ | ||
| clients::utils::{MsgSign, MsgVerify}, | ||
| impl_sign, impl_verify, | ||
| region::Region, | ||
| region_params::RegionParams, | ||
| KeyType, Result, | ||
| }; | ||
| use helium_crypto::{Keypair, PublicKey}; | ||
| use helium_proto::{ | ||
| services::iot_config::{ | ||
| admin_client, AdminAddKeyReqV1, AdminKeyResV1, AdminLoadRegionReqV1, AdminLoadRegionResV1, | ||
| AdminRemoveKeyReqV1, | ||
| }, | ||
| Message, | ||
| }; | ||
| use std::str::FromStr; | ||
|
|
||
| pub struct AdminClient { | ||
| client: admin_client::AdminClient<helium_proto::services::Channel>, | ||
| server_pubkey: PublicKey, | ||
| } | ||
|
|
||
| impl AdminClient { | ||
| pub async fn new(host: &str, server_pubkey: &str) -> Result<Self> { | ||
| Ok(Self { | ||
| client: admin_client::AdminClient::connect(host.to_owned()).await?, | ||
| server_pubkey: helium_crypto::PublicKey::from_str(server_pubkey)?, | ||
| }) | ||
| } | ||
|
|
||
| pub async fn add_key( | ||
| &mut self, | ||
| pubkey: &PublicKey, | ||
| key_type: KeyType, | ||
| keypair: &Keypair, | ||
| ) -> Result { | ||
| let mut request = AdminAddKeyReqV1 { | ||
| pubkey: pubkey.into(), | ||
| key_type: key_type.into(), | ||
| signer: keypair.public_key().into(), | ||
| signature: vec![], | ||
| }; | ||
| request.signature = request.sign(keypair)?; | ||
| self.client | ||
| .add_key(request) | ||
| .await? | ||
| .into_inner() | ||
| .verify(&self.server_pubkey) | ||
| } | ||
|
|
||
| pub async fn remove_key(&mut self, pubkey: &PublicKey, keypair: &Keypair) -> Result { | ||
| let mut request = AdminRemoveKeyReqV1 { | ||
| pubkey: pubkey.into(), | ||
| signer: keypair.public_key().into(), | ||
| signature: vec![], | ||
| }; | ||
| request.signature = request.sign(keypair)?; | ||
| self.client | ||
| .remove_key(request) | ||
| .await? | ||
| .into_inner() | ||
| .verify(&self.server_pubkey) | ||
| } | ||
|
|
||
| pub async fn load_region( | ||
| &mut self, | ||
| region: Region, | ||
| params: RegionParams, | ||
| indexes: Vec<u8>, | ||
| keypair: &Keypair, | ||
| ) -> Result { | ||
| let mut request = AdminLoadRegionReqV1 { | ||
| region: region.into(), | ||
| params: Some(params.into()), | ||
| hex_indexes: indexes, | ||
| signer: keypair.public_key().into(), | ||
| signature: vec![], | ||
| }; | ||
| request.signature = request.sign(keypair)?; | ||
| self.client | ||
| .load_region(request) | ||
| .await? | ||
| .into_inner() | ||
| .verify(&self.server_pubkey) | ||
| } | ||
| } | ||
|
|
||
| impl_sign!(AdminAddKeyReqV1, signature); | ||
| impl_sign!(AdminRemoveKeyReqV1, signature); | ||
| impl_sign!(AdminLoadRegionReqV1, signature); | ||
|
|
||
| impl_verify!(AdminKeyResV1, signature); | ||
| impl_verify!(AdminLoadRegionResV1, signature); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| use crate::{ | ||
| clients::utils::{MsgSign, MsgVerify}, | ||
| cmds::gateway::GatewayInfo, | ||
| impl_sign, impl_verify, Result, | ||
| }; | ||
| use anyhow::anyhow; | ||
| use helium_crypto::{Keypair, PublicKey}; | ||
| use helium_proto::{ | ||
| services::iot_config::{ | ||
| gateway_client, GatewayInfoReqV1, GatewayInfoResV1, GatewayLocationReqV1, | ||
| GatewayLocationResV1, | ||
| }, | ||
| Message, | ||
| }; | ||
| use std::str::FromStr; | ||
|
|
||
| pub struct GatewayClient { | ||
| client: gateway_client::GatewayClient<helium_proto::services::Channel>, | ||
| server_pubkey: PublicKey, | ||
| } | ||
|
|
||
| impl GatewayClient { | ||
| pub async fn new(host: &str, server_pubkey: &str) -> Result<Self> { | ||
| Ok(Self { | ||
| client: gateway_client::GatewayClient::connect(host.to_owned()).await?, | ||
| server_pubkey: helium_crypto::PublicKey::from_str(server_pubkey)?, | ||
| }) | ||
| } | ||
|
|
||
| pub async fn location( | ||
| &mut self, | ||
| hotspot: &PublicKey, | ||
| keypair: &Keypair, | ||
| ) -> Result<GatewayLocationResV1> { | ||
| let mut request = GatewayLocationReqV1 { | ||
| gateway: hotspot.into(), | ||
| signer: keypair.public_key().into(), | ||
| signature: vec![], | ||
| }; | ||
| request.signature = request.sign(keypair)?; | ||
| let response = self.client.location(request).await?.into_inner(); | ||
| response.verify(&self.server_pubkey)?; | ||
| Ok(response) | ||
| } | ||
|
|
||
| pub async fn info(&mut self, hotspot: &PublicKey, keypair: &Keypair) -> Result<GatewayInfo> { | ||
| let mut request = GatewayInfoReqV1 { | ||
| address: hotspot.into(), | ||
| signer: keypair.public_key().into(), | ||
| signature: vec![], | ||
| }; | ||
| request.signature = request.sign(keypair)?; | ||
| let response = self.client.info(request).await?.into_inner(); | ||
| response.verify(&self.server_pubkey)?; | ||
| let info = response.info.ok_or_else(|| anyhow!("No hotspot found"))?; | ||
| info.try_into() | ||
| } | ||
| } | ||
|
|
||
| impl_sign!(GatewayLocationReqV1, signature); | ||
| impl_sign!(GatewayInfoReqV1, signature); | ||
|
|
||
| impl_verify!(GatewayLocationResV1, signature); | ||
| impl_verify!(GatewayInfoResV1, signature); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| mod admin; | ||
| mod gateway; | ||
| mod org; | ||
| mod route; | ||
| mod utils; | ||
|
|
||
| pub use admin::AdminClient; | ||
| pub use gateway::GatewayClient; | ||
| pub use helium_lib::client::SolanaClient; | ||
| pub use org::*; | ||
| pub use route::*; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
leftover dep