Skip to content

Commit

Permalink
Fixing customer id encoding (#407)
Browse files Browse the repository at this point in the history
## Description
<!-- Describe what change this PR is implementing -->

## Types of Changes
Please select the branch type you are merging and fill in the relevant
template.
<!--- Check the following box with an x if the following applies: -->
- [ ] Hotfix
- [ ] Release
- [ ] Fix or Feature

## Fix or Feature
<!--- Check the following box with an x if the following applies: -->

### Types of Changes
<!--- What types of changes does your code introduce? -->
- [ ] Tech Debt (Code improvements)
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Dependency upgrade (A change in substrate or any 3rd party crate
version)

### Migrations and Hooks
<!--- Check the following box with an x if the following applies: -->
- [ ] This change requires a runtime migration.
- [ ] Modifies `on_initialize`
- [ ] Modifies `on_finalize`

### Checklist for Fix or Feature
<!--- All boxes need to be checked. Follow this checklist before
requiring PR review -->
- [ ] Change has been tested locally.
- [ ] Change adds / updates tests if applicable.
- [ ] Changelog doc updated.
- [ ] `spec_version` has been incremented.
- [ ] `network-relayer`'s
[events](https://github.com/Cerebellum-Network/network-relayer/blob/dev-cere/shared/substrate/events.go)
have been updated according to the blockchain events if applicable.
- [ ] All CI checks have been passed successfully

## Checklist for Hotfix
<!--- All boxes need to be checked. Follow this checklist before
requiring PR review -->
- [ ] Change has been deployed to Testnet.
- [ ] Change has been tested in Testnet.
- [ ] Changelog has been updated.
- [ ] Crate version has been updated.
- [ ] `spec_version` has been incremented.
- [ ] Transaction version has been updated if required.
- [ ] Pull Request to `dev` has been created.
- [ ] Pull Request to `staging` has been created.
- [ ] `network-relayer`'s
[events](https://github.com/Cerebellum-Network/network-relayer/blob/dev-cere/shared/substrate/events.go)
have been updated according to the blockchain events if applicable.
- [ ] All CI checks have been passed successfully

## Checklist for Release
<!--- All boxes need to be checked. Follow this checklist before
requiring PR review -->
- [ ] Change has been deployed to Devnet.
- [ ] Change has been tested in Devnet.
- [ ] Change has been deployed to Qanet.
- [ ] Change has been tested in Qanet.
- [ ] Change has been deployed to Testnet.
- [ ] Change has been tested in Testnet.
- [ ] Changelog has been updated.
- [ ] Crate version has been updated.
- [ ] Spec version has been updated.
- [ ] Transaction version has been updated if required.
- [ ] All CI checks have been passed successfully
  • Loading branch information
ayushmishra2005 authored Aug 1, 2024
1 parent 1f5e092 commit 396e017
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ chrono = { version = "0.4.31", default-features = false }
clap = { version = "4.2.5", features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] }
futures = { version = "0.3.21" }
hex = { version = "0.4.3", default-features = false, features = ["alloc"] }
hex-literal = { version = "^0.3.1", default-features = false }
jsonrpsee = { version = "0.16.2", default-features = false, features = ["server"] }
lazy_static = { version = "1.4.0", default-features = false }
Expand Down
2 changes: 2 additions & 0 deletions pallets/ddc-verification/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ frame-benchmarking = { workspace = true, optional = true }
frame-election-provider-support = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
hex = { workspace = true }
itertools = { workspace = true }
log = { workspace = true }
polkadot-ckb-merkle-mountain-range = { workspace = true }
Expand All @@ -44,6 +45,7 @@ sp-keystore = { workspace = true }
[features]
default = ["std"]
std = [
"hex/std",
"polkadot-ckb-merkle-mountain-range/std",
"codec/std",
"frame-benchmarking?/std",
Expand Down
8 changes: 5 additions & 3 deletions pallets/ddc-verification/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1431,9 +1431,11 @@ pub mod pallet {
payers: customers_activity_batched[i]
.iter()
.map(|activity| {
let customer_id = activity.clone().customer_id.into_bytes();
let account_id =
T::AccountId::decode(&mut &customer_id[..]).unwrap(); // todo! Remove Unwrap
let binding = activity.clone();
let customer_id = binding.customer_id.as_str();
let key = customer_id.trim_start_matches("0x");
let h_key = hex::decode(key).unwrap();
let account_id = T::AccountId::decode(&mut &h_key[..]).unwrap(); // todo! Remove Unwrap
let customer_usage = CustomerUsage {
transferred_bytes: activity.transferred_bytes,
stored_bytes: activity.stored_bytes,
Expand Down
2 changes: 1 addition & 1 deletion runtime/cere-dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// and set impl_version to 0. If only runtime
// implementation changes and behavior does not, then leave spec_version as
// is and increment impl_version.
spec_version: 54108,
spec_version: 54109,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 19,
Expand Down

0 comments on commit 396e017

Please sign in to comment.