Skip to content
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

Rename 'block_index' to 'transaction_index' #4725

Merged
merged 2 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backend/canisters/registry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Changed

- Use dynamic buffer size when reading from stable memory ([#4683](https://github.com/open-chat-labs/open-chat/pull/4683))
- Rename 'block_index' to 'transaction_index' ([#4683](https://github.com/open-chat-labs/open-chat/pull/4683))

## [[2.0.918](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.918-registry)] - 2023-10-30

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::lifecycle::{init_env, init_state};
use crate::memory::get_upgrades_memory;
use crate::Data;
use crate::{mutate_state, Data};
use canister_logger::LogEntry;
use canister_tracing_macros::trace;
use ic_cdk_macros::post_upgrade;
Expand All @@ -25,4 +25,6 @@ fn post_upgrade(args: Args) {
init_state(env, data, args.wasm_version);

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

mutate_state(|state| state.data.tokens.rename_block_index_to_transaction_index());
}
6 changes: 6 additions & 0 deletions backend/canisters/registry/impl/src/model/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ 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
2 changes: 1 addition & 1 deletion backend/canisters/registry/impl/src/updates/add_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ fn extract_urls(
.as_ref()
.filter(|ns| !ns.is_nns)
.map(|ns| ns.root_canister_id)
.map(|c| format!("https://dashboard.internetcomputer.org/sns/{c}/transaction/{{block_index}}"))
.map(|c| format!("https://dashboard.internetcomputer.org/sns/{c}/transaction/{{transaction_index}}"))
}) {
Some(url) => url,
_ => return Err("'transaction_url_format' must be provided for non-SNS tokens"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@
});

function url(id: bigint): string {
return urlFormat.replace("{block_index}", id.toString()).replace("{transaction_hash}", "");
return urlFormat
.replace("{block_index}", id.toString())
.replace("{transaction_index}", id.toString())
.replace("{transaction_hash}", "");
}

function openDashboard(id: bigint) {
Expand Down
1 change: 1 addition & 0 deletions frontend/openchat-client/src/utils/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1597,6 +1597,7 @@ export function buildTransactionUrl(

return transactionUrlFormat
.replace("{block_index}", transfer.blockIndex.toString())
.replace("{transaction_index}", transfer.blockIndex.toString())
.replace("{transaction_hash}", transfer.transactionHash ?? "");
}

Expand Down
Loading