Skip to content

Commit

Permalink
Update Windoge98 transaction fee (#5176)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Jan 15, 2024
1 parent bd6fb7c commit 88db807
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
4 changes: 4 additions & 0 deletions backend/canisters/registry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

### Fixed

- Update Windoge98 transaction fee ([#5176](https://github.com/open-chat-labs/open-chat/pull/5176))

## [[2.0.1003](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1003-registry)] - 2024-01-10

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use ic_cdk_macros::post_upgrade;
use registry_canister::post_upgrade::Args;
use stable_memory::get_reader;
use tracing::info;
use types::CanisterId;
use utils::cycles::init_cycles_dispenser_client;

#[post_upgrade]
Expand All @@ -25,5 +26,11 @@ fn post_upgrade(args: Args) {

info!(version = %args.wasm_version, "Post-upgrade complete");

mutate_state(|state| state.data.tokens.rename_block_index_to_transaction_index());
mutate_state(|state| {
state.data.tokens.set_fee(
CanisterId::from_text("rh2pm-ryaaa-aaaan-qeniq-cai").unwrap(),
100_000,
state.env.now(),
)
});
}
15 changes: 9 additions & 6 deletions backend/canisters/registry/impl/src/model/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ pub struct Tokens {
}

impl Tokens {
pub fn rename_block_index_to_transaction_index(&mut self) {
for token in self.tokens.iter_mut() {
token.transaction_url_format = token.transaction_url_format.replace("block_index", "transaction_index");
}
}

#[allow(clippy::too_many_arguments)]
pub fn add(
&mut self,
Expand Down Expand Up @@ -93,6 +87,15 @@ impl Tokens {
}
}

pub fn set_fee(&mut self, ledger_canister_id: CanisterId, fee: u128, now: TimestampMillis) {
if let Some(token) = self.tokens.iter_mut().find(|t| t.ledger_canister_id == ledger_canister_id) {
if token.fee != fee {
token.fee = fee;
token.last_updated = now;
}
}
}

pub fn last_updated(&self) -> TimestampMillis {
self.last_updated
}
Expand Down

0 comments on commit 88db807

Please sign in to comment.