Skip to content

Commit

Permalink
Remove deprecated nervous_system field from TokenDetails (#4584)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Oct 16, 2023
1 parent 3eebddb commit d82f1fe
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 49 deletions.
4 changes: 4 additions & 0 deletions backend/canisters/registry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Include `root_canister_id` in `NervousSystemSummary` ([#4573](https://github.com/open-chat-labs/open-chat/pull/4573))

### Removed

- Remove deprecated `nervous_system` field from `TokenDetails` ([#4584](https://github.com/open-chat-labs/open-chat/pull/4584))

## [[2.0.883](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.883-registry)] - 2023-10-12

### Added
Expand Down
5 changes: 0 additions & 5 deletions backend/canisters/registry/api/can.did
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ type TokenDetails = record {
decimals : nat8;
fee : nat;
logo : text;
nervous_system: opt record {
is_nns: bool;
root: CanisterId;
governance: CanisterId;
};
info_url : text;
how_to_buy_url : text;
transaction_url_format : text;
Expand Down
19 changes: 0 additions & 19 deletions backend/canisters/registry/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pub struct TokenDetails {
pub decimals: u8,
pub fee: u128,
pub logo: String,
pub nervous_system: Option<NervousSystemDeprecated>,
pub info_url: String,
pub how_to_buy_url: String,
pub transaction_url_format: String,
Expand Down Expand Up @@ -74,24 +73,6 @@ impl From<&NervousSystemDetails> for NervousSystemSummary {
}
}

// TODO Remove this after next release
#[derive(CandidType, Serialize, Deserialize, Clone, Debug)]
pub struct NervousSystemDeprecated {
pub is_nns: bool,
pub root: CanisterId,
pub governance: CanisterId,
}

impl From<NervousSystemDetails> for NervousSystemDeprecated {
fn from(value: NervousSystemDetails) -> Self {
NervousSystemDeprecated {
is_nns: value.is_nns,
root: value.root_canister_id,
governance: value.governance_canister_id,
}
}
}

#[derive(CandidType, Serialize, Deserialize, Debug)]
// TODO uncomment the line below once candid is aware of the `rename_all` attribute
// #[serde(rename_all = "lowercase")]
Expand Down
7 changes: 1 addition & 6 deletions backend/canisters/registry/impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::model::nervous_systems::{NervousSystemMetrics, NervousSystems};
use crate::model::tokens::{TokenMetrics, Tokens};
use candid::Principal;
use canister_state_macros::canister_state;
use registry_canister::{NervousSystemDeprecated, NervousSystemDetails};
use registry_canister::NervousSystemDetails;
use serde::{Deserialize, Serialize};
use std::cell::RefCell;
use std::collections::HashSet;
Expand Down Expand Up @@ -133,11 +133,6 @@ impl Data {
8,
10_000,
IC_LOGO.to_string(),
Some(NervousSystemDeprecated {
is_nns: true,
root: root_canister_id,
governance: governance_canister_id,
}),
"https://dashboard.internetcomputer.org/transactions".to_string(),
"https://www.finder.com/uk/how-to-buy-internet-computer".to_string(),
"https://dashboard.internetcomputer.org/transaction/{transaction_hash}".to_string(),
Expand Down
6 changes: 1 addition & 5 deletions backend/canisters/registry/impl/src/model/tokens.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use registry_canister::{NervousSystemDeprecated, TokenDetails};
use registry_canister::TokenDetails;
use serde::{Deserialize, Serialize};
use types::{CanisterId, TimestampMillis};

Expand All @@ -18,7 +18,6 @@ impl Tokens {
decimals: u8,
fee: u128,
logo: String,
nervous_system: Option<NervousSystemDeprecated>,
info_url: String,
how_to_buy_url: String,
transaction_url_format: String,
Expand All @@ -34,7 +33,6 @@ impl Tokens {
decimals,
fee,
logo,
nervous_system,
info_url,
how_to_buy_url,
transaction_url_format,
Expand Down Expand Up @@ -71,7 +69,6 @@ pub struct TokenMetrics {
decimals: u8,
fee: u128,
logo_length: usize,
nervous_system: Option<NervousSystemDeprecated>,
info_url: String,
how_to_buy_url: String,
transaction_url_format: String,
Expand All @@ -88,7 +85,6 @@ impl From<&TokenDetails> for TokenMetrics {
decimals: value.decimals,
fee: value.fee,
logo_length: value.logo.len(),
nervous_system: value.nervous_system.clone(),
info_url: value.info_url.clone(),
how_to_buy_url: value.how_to_buy_url.clone(),
transaction_url_format: value.transaction_url_format.clone(),
Expand Down
3 changes: 1 addition & 2 deletions backend/canisters/registry/impl/src/updates/add_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async fn add_token_impl(
}
Ok((name, symbol, decimals, fee, logo)) => mutate_state(|state| {
let now = state.env.now();
if let Some(ns) = nervous_system.clone() {
if let Some(ns) = nervous_system {
state.data.nervous_systems.add(ns, now);
}
if state.data.tokens.add(
Expand All @@ -80,7 +80,6 @@ async fn add_token_impl(
decimals,
fee.0.try_into().unwrap(),
logo.unwrap(),
nervous_system.map(|ns| ns.into()),
info_url,
how_to_buy_url,
transaction_url_format,
Expand Down
4 changes: 4 additions & 0 deletions frontend/openchat-agent/codegen.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
SCRIPT=$(readlink -f "$0")
SCRIPT_DIR=$(dirname "$SCRIPT")
cd $SCRIPT_DIR

didc bind ../../backend/canisters/user_index/api/can.did -t ts > ./src/services/userIndex/candid/types.d.ts
didc bind ../../backend/canisters/user_index/api/can.did -t js > ./src/services/userIndex/candid/idl.js

Expand Down
7 changes: 0 additions & 7 deletions frontend/openchat-agent/src/services/registry/candid/idl.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ export const idlFactory = ({ IDL }) => {
'logo' : IDL.Text,
'name' : IDL.Text,
'last_updated' : TimestampMillis,
'nervous_system' : IDL.Opt(
IDL.Record({
'root' : CanisterId,
'is_nns' : IDL.Bool,
'governance' : CanisterId,
})
),
'ledger_canister_id' : CanisterId,
'symbol' : IDL.Text,
'transaction_url_format' : IDL.Text,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1192,9 +1192,6 @@ export interface TokenDetails {
'logo' : string,
'name' : string,
'last_updated' : TimestampMillis,
'nervous_system' : [] | [
{ 'root' : CanisterId, 'is_nns' : boolean, 'governance' : CanisterId }
],
'ledger_canister_id' : CanisterId,
'symbol' : string,
'transaction_url_format' : string,
Expand Down
4 changes: 2 additions & 2 deletions upgrade_order.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Website -> GroupIndex
Website -> Registry

Website before GroupIndex because the `chat_id` field has been removed from `GroupMatch`
Website before Registry because `nervous_system` has been removed from `TokenDetails`

0 comments on commit d82f1fe

Please sign in to comment.