Skip to content

Commit

Permalink
fix: return 6 decimals and INIT symbol for uinit (#125)
Browse files Browse the repository at this point in the history
* fix to return 6 decimals and INIT symbol for uinit

* fix copatibility
  • Loading branch information
beer-1 authored Sep 18, 2024
1 parent c70e66e commit 7513151
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 2 deletions.
Binary file modified precompile/binaries/minlib/coin.mv
Binary file not shown.
Binary file modified precompile/binaries/stdlib/coin.mv
Binary file not shown.
Binary file modified precompile/binaries/stdlib/fungible_asset.mv
Binary file not shown.
3 changes: 3 additions & 0 deletions precompile/modules/initia_stdlib/sources/coin.move
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ module initia_std::coin {
object::address_to_object(addr)
}

// for lz compatibility
struct Coin<phantom CoinType> {}

#[test_only]
fun initialize_coin_for_testing(
account: &signer, symbol: String
Expand Down
14 changes: 12 additions & 2 deletions precompile/modules/initia_stdlib/sources/fa/fungible_asset.move
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,12 @@ module initia_std::fungible_asset {
#[view]
/// Get the symbol of the fungible asset from the `metadata` object.
public fun symbol<T: key>(metadata: Object<T>): String acquires Metadata {
borrow_fungible_metadata(&metadata).symbol
let md = borrow_fungible_metadata(&metadata);
if (object::is_owner(metadata, @initia_std) && md.symbol == string::utf8(b"uinit")) {
return string::utf8(b"INIT")
};

md.symbol
}

#[view]
Expand All @@ -506,7 +511,12 @@ module initia_std::fungible_asset {
#[view]
/// Get the decimals from the `metadata` object.
public fun decimals<T: key>(metadata: Object<T>): u8 acquires Metadata {
borrow_fungible_metadata(&metadata).decimals
let md = borrow_fungible_metadata(&metadata);
if (object::is_owner(metadata, @initia_std) && md.symbol == string::utf8(b"uinit")) {
return 6
};

md.decimals
}

#[view]
Expand Down
3 changes: 3 additions & 0 deletions precompile/modules/minitia_stdlib/sources/coin.move
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,9 @@ module minitia_std::coin {
object::address_to_object(addr)
}

// for lz compatibility
struct Coin<phantom CoinType> {}

#[test_only]
fun initialize_coin_for_testing(
account: &signer, symbol: String
Expand Down

0 comments on commit 7513151

Please sign in to comment.