Skip to content
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
- Renamed the `Authority` config value slot, expressed the authority kind as a MASM `enum Authority : u8`, and enforced the canonical config-word encoding on read ([#3209](https://github.com/0xMiden/protocol/pull/3209)).
- Unified procedure ordering and document sender-based access control's authentication assumption in the `ownable2step` and `rbac` access control modules ([#3205](https://github.com/0xMiden/protocol/pull/3205)).
- Refactor `asset_vault::add_asset` and `faucet::mint` to use a unified path for all asset types, in preparation of custom asset ([#3217](https://github.com/0xMiden/protocol/pull/3217)).
- Refactor `asset_vault::remove_asset` and `faucet::burn` to use a unified path for all asset types, in preparation of custom assets ([#3078](https://github.com/0xMiden/protocol/issues/3078)).
- [BREAKING] Updated `BlockHeader` to support multiple validator keys and added `ValidatorKeys` and `BlockSignatures` types ([#3174](https://github.com/0xMiden/protocol/pull/3174)).

### Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -889,8 +889,11 @@ proc compute_asset_delta
cswapw
# => [LESSER_ASSET_VALUE, GREATER_ASSET_VALUE, ASSET_ID, delta_op]

dupw.2 exec.asset::id_into_composition
# => [asset_composition, LESSER_ASSET_VALUE, GREATER_ASSET_VALUE, ASSET_ID, delta_op]

# compute the delta as greater - lesser
dupw.2 exec.asset::split
exec.asset::split
# => [DELTA_ASSET_VALUE, ASSET_ID, delta_op]

swapw movup.8
Expand Down
21 changes: 8 additions & 13 deletions crates/miden-protocol/asm/kernels/transaction-core/src/asset.masm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub use {
id_to_asset_class,
id_into_asset_class,
id_to_composition,
id_into_composition,
load,
store,
validate_metadata,
Expand Down Expand Up @@ -251,16 +252,16 @@ pub proc merge
# => [MERGED_ASSET_VALUE]
end

#! Computes OTHER_ASSET_VALUE - CURRENT_ASSET_VALUE for the asset identified by ASSET_ID.
#! Computes OTHER_ASSET_VALUE - CURRENT_ASSET_VALUE for the asset with the given composition.
#!
#! WARNING: This procedure assumes both asset values belong to the asset identified by ASSET_ID
#! and have already been validated.
#! WARNING: This procedure assumes both asset values belong to the same asset and have already been
#! validated. The `asset_composition` must be taken from the asset ID.
#!
#! Inputs: [ASSET_ID, CURRENT_ASSET_VALUE, OTHER_ASSET_VALUE]
#! Inputs: [asset_composition, CURRENT_ASSET_VALUE, OTHER_ASSET_VALUE]
#! Outputs: [SPLIT_ASSET_VALUE]
#!
#! Where:
#! - ASSET_ID is the asset ID of the asset whose values are being split.
#! - asset_composition is the asset composition of the asset whose values are being split.
#! - CURRENT_ASSET_VALUE is the value subtracted from OTHER_ASSET_VALUE.
#! - OTHER_ASSET_VALUE is the value being subtracted from.
#! - SPLIT_ASSET_VALUE is OTHER_ASSET_VALUE - CURRENT_ASSET_VALUE.
Expand All @@ -270,19 +271,13 @@ end
#! - the asset's composition is Custom (not yet supported).
#! - the underlying split operation panics (see fungible_asset::split).
pub proc split
exec.id_to_composition
# => [asset_composition, ASSET_ID, CURRENT_ASSET_VALUE, OTHER_ASSET_VALUE]

dup neq.COMPOSITION_NONE assert.err=ERR_VAULT_SPLIT_COMPOSITION_NONE
# => [asset_composition, ASSET_ID, CURRENT_ASSET_VALUE, OTHER_ASSET_VALUE]
# => [asset_composition, CURRENT_ASSET_VALUE, OTHER_ASSET_VALUE]

eq.COMPOSITION_FUNGIBLE
# => [is_fungible_asset, ASSET_ID, CURRENT_ASSET_VALUE, OTHER_ASSET_VALUE]
# => [is_fungible_asset, CURRENT_ASSET_VALUE, OTHER_ASSET_VALUE]

if.true
dropw
# => [CURRENT_ASSET_VALUE, OTHER_ASSET_VALUE]

exec.fungible_asset::split
# => [SPLIT_ASSET_VALUE]
else
Expand Down
Loading
Loading