Skip to content

Commit aa0730f

Browse files
madninjaclaude
andauthored
feat(hotspot): upgrade mobile config streaming to V4 with owner fields (#514)
Replace V3 config service streaming with V4 to get owner wallet and owner_changed_at directly from the config service, eliminating the need for a separate DAS sync. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9910a0c commit aa0730f

3 files changed

Lines changed: 41 additions & 23 deletions

File tree

Cargo.lock

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

helium-lib/src/client.rs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -697,16 +697,16 @@ pub mod config {
697697
use super::*;
698698
use helium_proto::services::mobile_config::{
699699
DeviceType, DeviceTypeV2, GatewayClient, GatewayInfoBatchReqV1, GatewayInfoReqV1,
700-
GatewayInfoResV2, GatewayInfoStreamReqV3, GatewayInfoStreamResV2,
701-
GatewayInfoStreamResV3, GatewayInfoV2, GatewayInfoV3,
700+
GatewayInfoResV2, GatewayInfoStreamReqV4, GatewayInfoStreamResV2,
701+
GatewayInfoStreamResV4, GatewayInfoV2, GatewayInfoV4,
702702
};
703703

704704
impl_message_sign!(GatewayInfoReqV1);
705-
impl_message_sign!(GatewayInfoStreamReqV3);
705+
impl_message_sign!(GatewayInfoStreamReqV4);
706706
impl_message_sign!(GatewayInfoBatchReqV1);
707707
impl_message_verify!(GatewayInfoResV2);
708708
impl_message_verify!(GatewayInfoStreamResV2);
709-
impl_message_verify!(GatewayInfoStreamResV3);
709+
impl_message_verify!(GatewayInfoStreamResV4);
710710

711711
#[derive(Clone)]
712712
pub struct Client {
@@ -810,21 +810,21 @@ pub mod config {
810810
BoxStream<'_, Result<Vec<(helium_crypto::PublicKey, Option<HotspotInfo>)>, Error>>,
811811
Error,
812812
> {
813-
let mut req = GatewayInfoStreamReqV3 {
813+
let mut req = GatewayInfoStreamReqV4 {
814814
signer: self.keypair.public_key().into(),
815815
batch_size,
816816
min_updated_at: updated_since,
817817
..Default::default()
818818
};
819819
req.sign(&self.keypair)?;
820-
let streaming = self.client.info_stream_v3(req).await?.into_inner();
820+
let streaming = self.client.info_stream_v4(req).await?.into_inner();
821821
let streaming = streaming.map_err(Error::from).and_then(|res| {
822822
let address = self.address.clone();
823823
async move {
824824
res.verify(&address)?;
825825
res.gateways
826826
.into_iter()
827-
.map(info_from_info_v3)
827+
.map(info_from_info_v4)
828828
.collect::<Result<Vec<_>, _>>()
829829
}
830830
});
@@ -875,13 +875,16 @@ pub mod config {
875875
created_at: info.created_at,
876876
updated_at: info.updated_at,
877877
location_changed_at: 0, // Not available in V2
878+
owner: None,
879+
owner_changed_at: 0,
878880
}),
879881
))
880882
}
881883

882-
fn info_from_info_v3(
883-
info: GatewayInfoV3,
884+
fn info_from_info_v4(
885+
info: GatewayInfoV4,
884886
) -> Result<(helium_crypto::PublicKey, Option<HotspotInfo>), Error> {
887+
use std::str::FromStr;
885888
let address = info.address.try_into()?;
886889

887890
let (device_type, mode) = match DeviceTypeV2::try_from(info.device_type)
@@ -907,6 +910,12 @@ pub mod config {
907910
})
908911
.unwrap_or((None, 0, None));
909912

913+
let owner = if info.owner.is_empty() {
914+
None
915+
} else {
916+
Some(Pubkey::from_str(&info.owner).map_err(DecodeError::from)?)
917+
};
918+
910919
Ok((
911920
address,
912921
Some(HotspotInfo::Mobile {
@@ -918,6 +927,8 @@ pub mod config {
918927
created_at: info.created_at,
919928
updated_at: info.updated_at,
920929
location_changed_at,
930+
owner,
931+
owner_changed_at: info.owner_changed_at,
921932
}),
922933
))
923934
}

helium-lib/src/hotspot/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{
66
data_credits,
77
error::{DecodeError, EncodeError, Error},
88
helium_entity_manager, is_zero,
9-
keypair::{pubkey, serde_pubkey, Keypair, Pubkey},
9+
keypair::{pubkey, serde_opt_pubkey, serde_pubkey, Keypair, Pubkey},
1010
kta, message, onboarding, priority_fee,
1111
solana_sdk::{
1212
instruction::{AccountMeta, Instruction},
@@ -547,6 +547,11 @@ pub enum HotspotInfo {
547547
updated_at: u64,
548548
#[serde(skip_serializing_if = "is_zero", default)]
549549
location_changed_at: u64,
550+
#[serde(with = "serde_opt_pubkey")]
551+
#[serde(skip_serializing_if = "Option::is_none", default)]
552+
owner: Option<Pubkey>,
553+
#[serde(skip_serializing_if = "is_zero", default)]
554+
owner_changed_at: u64,
550555
},
551556
}
552557

@@ -841,6 +846,8 @@ impl From<helium_entity_manager::accounts::MobileHotspotInfoV0> for HotspotInfo
841846
created_at: 0, // Not available in on-chain account
842847
updated_at: 0, // Not available in on-chain account
843848
location_changed_at: 0, // Not available in on-chain account
849+
owner: None,
850+
owner_changed_at: 0,
844851
}
845852
}
846853
}

0 commit comments

Comments
 (0)