Skip to content

Commit

Permalink
fix promotion rewards by encoding timestamp as seconds (#884)
Browse files Browse the repository at this point in the history
* fix promotion rewards by encoding timestamp as seconds

* Update reward_index to store promotion reward in db
  • Loading branch information
bbalser authored Oct 30, 2024
1 parent 04673f4 commit 47d72cb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
2 changes: 1 addition & 1 deletion mobile_config/src/client/carrier_service_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl CarrierServiceVerifier for CarrierServiceClient {
&self,
) -> Result<Vec<ServiceProviderPromotions>, Self::Error> {
let mut request = mobile_config::CarrierIncentivePromotionListReqV1 {
timestamp: Utc::now().encode_timestamp_millis(),
timestamp: Utc::now().encode_timestamp(),
signer: self.signing_key.public_key().into(),
signature: vec![],
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TYPE reward_type ADD VALUE 'mobile_promotion';
30 changes: 8 additions & 22 deletions reward_index/src/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub enum RewardType {
MobileServiceProvider,
MobileUnallocated,
IotUnallocated,
MobilePromotion,
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
Expand Down Expand Up @@ -185,28 +186,13 @@ impl Indexer {
},
r.amount,
))),
// Some(MobileReward::PromotionReward(PromotionReward {
// entity: Some(Entity::SubscriberId(subscriber_id)),
// service_provider_amount,
// matched_amount,
// })) => Ok(Some((
// RewardKey {
// key: bs58::encode(&subscriber_id).into_string(),
// reward_type: RewardType::MobileSubscriber,
// },
// service_provider_amount + matched_amount,
// ))),
// Some(MobileReward::PromotionReward(PromotionReward {
// entity: Some(Entity::GatewayKey(gateway_key)),
// service_provider_amount,
// matched_amount,
// })) => Ok(Some((
// RewardKey {
// key: PublicKeyBinary::from(gateway_key).to_string(),
// reward_type: RewardType::MobileGateway,
// },
// service_provider_amount + matched_amount,
// ))),
Some(MobileReward::PromotionReward(promotion)) => Ok(Some((
RewardKey {
key: promotion.entity,
reward_type: RewardType::MobilePromotion,
},
promotion.service_provider_amount + promotion.matched_amount,
))),
_ => bail!("got an invalid reward share"),
}
}
Expand Down

0 comments on commit 47d72cb

Please sign in to comment.