Skip to content

Document the exact predicate of the has_nft function family - #135

Open
MavenRain wants to merge 1 commit into
aiken-lang:mainfrom
MavenRain:docs/121-clarify-nft-semantics
Open

Document the exact predicate of the has_nft function family#135
MavenRain wants to merge 1 commit into
aiken-lang:mainfrom
MavenRain:docs/121-clarify-nft-semantics

Conversation

@MavenRain

Copy link
Copy Markdown

See #121.

Problem

The doc comments of has_any_nft, has_any_nft_strict, has_nft and has_nft_strict say the functions check that a Value "carries an NFT". As #121 points out, the name and the docs imply a chain-level property the functions cannot observe. The actual predicate is local to the given Value: a quantity of exactly 1 (and, for the strict variants, no other assets beside Ada). A fungible token present with a quantity of 1 also satisfies it.

The rename proposed in #121 is contested (uniqueness is extrinsic under any name), so this PR takes the documentation route instead: keep the names, state the predicate exactly, and warn about the local scope of the check.

Fix

  • State the exact predicate in all four doc comments: a quantity of exactly 1 of at least one asset (has_any_nft), of a single asset (has_any_nft_strict), or of the given asset (has_nft, has_nft_strict).
  • Add an [!IMPORTANT] admonition (house style, as used elsewhere in assets.ak): the check is local to the given Value, does not prove chain-level uniqueness, and a fungible token present with a quantity of 1 also passes.
  • Fix the has_nft_strict examples that call the function with value1 / value3 while the example binds value.

Docs only; no code change. If a rename is decided in #121 after all, this text carries over to the new names.

Testing

aiken fmt --check clean; aiken check: 986 passed, 0 failed (969 unit, 17 property).

The doc comments said the functions check that a Value "carries an
NFT".  What they check is a quantity of exactly 1 within the given
Value.  That proves nothing about chain-level uniqueness, and a
fungible token present with a quantity of 1 also passes.

State the predicate in all four doc comments and add an IMPORTANT
admonition with the caveat, following the discussion in aiken-lang#121.  Also
fix the has_nft_strict examples that call the function with value1 /
value3 while the example binds value.

See aiken-lang#121

Signed-off-by: Onyeka Obi <softwareengineerasaservant@isurvivable.cv>
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.

1 participant