Skip to content

Functions for retrieving AssetId and Amount - #61

Open
aritkulova wants to merge 7 commits into
devfrom
feat/asset-id-amount-getters
Open

aritkulova wants to merge 7 commits into
devfrom
feat/asset-id-amount-getters

Conversation

@aritkulova

@aritkulova aritkulova commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator
  • This PR suggests a bug fix and I've added the necessary tests.
  • This PR introduces a new feature and I've discussed the update in an Issue or with the team.
  • This PR is just a minor change like a typo fix.

Resolves #32.
Since currently enums are not supported in multi-file programs, enum IndexType is replaced with the is_input_index: bool parameter.

@aritkulova
aritkulova requested a review from Hrom131 September 30, 2026 12:00
@aritkulova aritkulova self-assigned this Sep 30, 2026
@aritkulova
aritkulova force-pushed the feat/asset-id-amount-getters branch from 1c55501 to 50b3c84 Compare September 30, 2026 13:16
Comment thread simf/lib/utxo/getters/amount.simf

@LesterEvSe LesterEvSe left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's start with the is_input_index: bool parameter in amount.simf, asset_id.simf and asset_id_with_amount.simf.

We don't need it. Let's implement these getters the same way as in the price-oracle helper file: one function per jet, with jet::input_* / jet::output_* called directly.

The main reason is that we don't want users to pay for the match and extra is_input_index: bool argument. Pruning doesn't help: the unused branch is replaced by a 32-byte hash, which is bigger than the branch itself. In my measurement, a single input getter is 140 bytes with the match and 91 bytes without it, and each call costs about 1,500 mWU more to run.

So, please, remove the is_input_index helpers from all three files (get_explicit_* and get_confidential_*: six functions in total), and write the input and output variants directly.

Comment thread simf/lib/utxo/getters/amount.simf Outdated
renamed get_current to get_explicit and get_confidential for consistency

@Hrom131 Hrom131 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@aritkulova
aritkulova force-pushed the feat/asset-id-amount-getters branch from 8dcf09c to 7762fc9 Compare October 6, 2026 15:09
added negative tests;
added witness for parity bit;
utxo order in a tx is now deterministic;
small cleanups
@aritkulova
aritkulova force-pushed the feat/asset-id-amount-getters branch from 7762fc9 to cb2761a Compare October 6, 2026 15:27
Comment thread tests/stdlib/utxo/getters/amount.rs Outdated
Comment thread tests/stdlib/common/core.rs Outdated
Comment thread tests/stdlib/common/utxo_helper.rs Outdated
Comment thread tests/stdlib/common/core.rs Outdated
Comment thread tests/stdlib/common/core.rs Outdated
Comment thread tests/stdlib/common/core.rs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants