Skip to content

Commit 5548bd5

Browse files
committed
Refactor code structure for improved readability and maintainability
1 parent 4d9f53e commit 5548bd5

File tree

17 files changed

+3643
-71
lines changed

17 files changed

+3643
-71
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
### Features
66

7+
- Added metadata extension (`Info`) with name and content URI slots, and MASM procedures `get_token_metadata`, `get_max_supply`, `get_decimals`, and `get_token_symbol` for the token metadata standard. Aligned fungible faucet token metadata with the metadata standard: faucet now uses the canonical slot `miden::standards::metadata::token_metadata` so MASM metadata getters work with faucet storage.([#2439](https://github.com/0xMiden/miden-base/pull/2439))
8+
79
- Enable `CodeBuilder` to add advice map entries to compiled scripts ([#2275](https://github.com/0xMiden/miden-base/pull/2275)).
810
- Added `BlockNumber::MAX` constant to represent the maximum block number ([#2324](https://github.com/0xMiden/miden-base/pull/2324)).
911
- Added single-word `Array` standard ([#2203](https://github.com/0xMiden/miden-base/pull/2203)).
@@ -20,6 +22,7 @@
2022

2123
### Changes
2224

25+
- `TokenMetadata` (faucet) now uses the shared metadata slot from the metadata module for consistency with MASM standards.
2326
- Made kernel procedure offset constants public and replaced accessor procedures with direct constant usage ([#2375](https://github.com/0xMiden/miden-base/pull/2375)).
2427
- [BREAKING] Made `AccountComponentMetadata` a required parameter of `AccountComponent::new()`; removed `with_supported_type`, `with_supports_all_types`, and `with_metadata` methods from `AccountComponent`; simplified `AccountComponentMetadata::new()` to take just `name`; renamed `AccountComponentTemplateError` to `ComponentMetadataError` ([#2373](https://github.com/0xMiden/miden-base/pull/2373), [#2395](https://github.com/0xMiden/miden-base/pull/2395)).
2528
- Fixed MASM inline comment casing to adhere to commenting conventions ([#2398](https://github.com/0xMiden/miden-base/pull/2398)).

crates/miden-standards/asm/account_components/faucets/basic_fungible_faucet.masm

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,19 @@
44

55
pub use ::miden::standards::faucets::basic_fungible::distribute
66
pub use ::miden::standards::faucets::basic_fungible::burn
7+
8+
# Metadata — getters only (no setters for basic faucet)
9+
pub use ::miden::standards::metadata::fungible::get_name
10+
pub use ::miden::standards::metadata::fungible::get_config
11+
pub use ::miden::standards::metadata::fungible::is_max_supply_mutable
12+
pub use ::miden::standards::metadata::fungible::is_description_mutable
13+
pub use ::miden::standards::metadata::fungible::is_logo_uri_mutable
14+
pub use ::miden::standards::metadata::fungible::is_external_link_mutable
15+
pub use ::miden::standards::metadata::fungible::get_description
16+
pub use ::miden::standards::metadata::fungible::get_logo_uri
17+
pub use ::miden::standards::metadata::fungible::get_external_link
18+
pub use ::miden::standards::metadata::fungible::get_token_metadata
19+
pub use ::miden::standards::metadata::fungible::get_max_supply
20+
pub use ::miden::standards::metadata::fungible::get_decimals
21+
pub use ::miden::standards::metadata::fungible::get_token_symbol
22+
pub use ::miden::standards::metadata::fungible::get_token_supply

crates/miden-standards/asm/account_components/faucets/network_fungible_faucet.masm

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,24 @@ pub use ::miden::standards::faucets::network_fungible::distribute
66
pub use ::miden::standards::faucets::network_fungible::burn
77
pub use ::miden::standards::faucets::network_fungible::transfer_ownership
88
pub use ::miden::standards::faucets::network_fungible::renounce_ownership
9+
10+
# Metadata — all from metadata::fungible
11+
pub use ::miden::standards::metadata::fungible::get_owner
12+
pub use ::miden::standards::metadata::fungible::get_name
13+
pub use ::miden::standards::metadata::fungible::get_config
14+
pub use ::miden::standards::metadata::fungible::is_max_supply_mutable
15+
pub use ::miden::standards::metadata::fungible::is_description_mutable
16+
pub use ::miden::standards::metadata::fungible::is_logo_uri_mutable
17+
pub use ::miden::standards::metadata::fungible::is_external_link_mutable
18+
pub use ::miden::standards::metadata::fungible::get_description
19+
pub use ::miden::standards::metadata::fungible::get_logo_uri
20+
pub use ::miden::standards::metadata::fungible::get_external_link
21+
pub use ::miden::standards::metadata::fungible::get_token_metadata
22+
pub use ::miden::standards::metadata::fungible::get_max_supply
23+
pub use ::miden::standards::metadata::fungible::get_decimals
24+
pub use ::miden::standards::metadata::fungible::get_token_symbol
25+
pub use ::miden::standards::metadata::fungible::get_token_supply
26+
pub use ::miden::standards::metadata::fungible::optional_set_description
27+
pub use ::miden::standards::metadata::fungible::optional_set_logo_uri
28+
pub use ::miden::standards::metadata::fungible::optional_set_external_link
29+
pub use ::miden::standards::metadata::fungible::optional_set_max_supply

crates/miden-standards/asm/standards/access/ownable.masm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ end
102102
#! Invocation: call
103103
pub proc get_owner
104104
exec.owner
105-
# => [owner_prefix, owner_suffix, pad(14)]
105+
# => [owner_prefix, owner_suffix, pad(16)] depth 18
106+
exec.::miden::core::sys::truncate_stack
107+
# => [owner_prefix, owner_suffix, pad(14)] depth 16
106108
end
107109

108110
#! Transfers ownership to a new account.

crates/miden-standards/asm/standards/faucets/mod.masm

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ use ::miden::protocol::asset::FUNGIBLE_ASSET_MAX_AMOUNT
1010

1111
const PRIVATE_NOTE=2
1212

13+
# Token metadata slot — duplicated here so distribute can read it via exec without
14+
# going through the call-safe get_max_supply wrapper.
15+
const TOKEN_METADATA_SLOT = word("miden::standards::metadata::token_metadata")
16+
1317
# ERRORS
1418
# =================================================================================================
1519

@@ -29,9 +33,9 @@ const ERR_BASIC_FUNGIBLE_BURN_WRONG_NUMBER_OF_ASSETS="burn requires exactly 1 no
2933
# The local memory address at which the metadata slot content is stored.
3034
const METADATA_SLOT_LOCAL=0
3135

32-
# The standard slot where fungible faucet metadata like token symbol or decimals are stored.
36+
# The standard slot where fungible faucet metadata is stored (canonical with metadata module).
3337
# Layout: [token_supply, max_supply, decimals, token_symbol]
34-
const METADATA_SLOT=word("miden::standards::fungible_faucets::metadata")
38+
const METADATA_SLOT=word("miden::standards::metadata::token_metadata")
3539

3640
#! Distributes freshly minted fungible assets to the provided recipient by creating a note.
3741
#!
@@ -67,19 +71,9 @@ pub proc distribute
6771
# => [max_supply, token_supply, amount, tag, note_type, RECIPIENT]
6872

6973
# Assert that minting does not violate any supply constraints.
70-
#
71-
# To make sure we cannot mint more than intended, we need to check:
72-
# 1) (max_supply - token_supply) <= max_supply, i.e. the subtraction does not wrap around
73-
# 2) amount + token_supply does not exceed max_supply
74-
# 3) amount + token_supply is less than FUNGIBLE_ASSET_MAX_AMOUNT
75-
#
76-
# This is done with the following concrete assertions:
77-
# - assert token_supply <= max_supply which ensures 1)
78-
# - assert max_supply <= FUNGIBLE_ASSET_MAX_AMOUNT to help ensure 3)
79-
# - assert amount <= max_mint_amount to ensure 2) as well as 3)
80-
# - this ensures 3) because token_supply + max_mint_amount at most ends up being equal to
81-
# max_supply and we already asserted that max_supply does not exceed
82-
# FUNGIBLE_ASSET_MAX_AMOUNT
74+
# - assert token_supply <= max_supply
75+
# - assert max_supply <= FUNGIBLE_ASSET_MAX_AMOUNT
76+
# - assert amount <= max_mint_amount
8377
# ---------------------------------------------------------------------------------------------
8478

8579
dup.1 dup.1

0 commit comments

Comments
 (0)