Skip to content

Commit

Permalink
use legacy tokencode
Browse files Browse the repository at this point in the history
  • Loading branch information
nkysg committed Feb 9, 2025
1 parent 59920db commit 0aa5055
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/starcoin/src/account/show_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ use starcoin_crypto::ValidCryptoMaterialStringExt;
use starcoin_rpc_client::StateRootOption;
use starcoin_state_api::{ChainStateReader, StateReaderExt};
use starcoin_vm_types::account_address::AccountAddress;
use starcoin_vm_types::account_config::BalanceResource;
use starcoin_vm_types::account_config::{
BalanceResource, G_LEGACY_STC_TOKEN_CODE, G_STC_TOKEN_CODE,
};
use starcoin_vm_types::token::token_code::TokenCode;
use std::collections::HashMap;

Expand Down Expand Up @@ -79,7 +81,11 @@ impl CommandAction for ShowCommand {
.decode::<BalanceResource>()
.ok()
.map(|balance| balance.token());
Some((token_code, balance.unwrap_or(0)))
if token_code == *G_STC_TOKEN_CODE {
Some((G_LEGACY_STC_TOKEN_CODE.clone(), balance.unwrap_or(0)))
} else {
Some((token_code, balance.unwrap_or(0)))
}
} else {
None
}
Expand Down
6 changes: 6 additions & 0 deletions vm/types/src/token/stc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ pub static G_STC_TOKEN_CODE: Lazy<TokenCode> = Lazy::new(|| {
TokenCode::from_str(STC_TOKEN_CODE_STR).expect("Parse STC token code should success.")
});

pub const LEGACY_STC_TOKEN_STR: &str = "0x1::STC::STC";
pub static G_LEGACY_STC_TOKEN_CODE: Lazy<TokenCode> = Lazy::new(|| {
TokenCode::from_str(LEGACY_STC_TOKEN_STR).expect("Parse LEGACY STC token code should success.")
});


static G_STC_IDENTIFIER: Lazy<Identifier> = Lazy::new(|| Identifier::new(STC_NAME).unwrap());

pub fn stc_type_tag() -> TypeTag {
Expand Down

0 comments on commit 0aa5055

Please sign in to comment.