RGB-WG / rgb-schemata

Standard RGB schemata and schema compiler
Apache License 2.0
29 stars 20 forks source link

UDA contract with allocation but no tokens #18

Closed zoedberg closed 8 months ago

zoedberg commented 9 months ago

Currently it's possible to issue an UDA contract with an asset owner but no tokens. But the assetOwner field wants a seal and an allocation, and the latter is defined as struct Allocation(TokenIndex, OwnedFraction). If the asset has no tokens I don't see why the allocation should refer to a token index that doesn't exist.

I would change the interface definition from assetOwner* and tokens* to assetOwner+ and tokens+. But I remember this was once said (https://github.com/LNP-BP/LNPBPs/pull/154#discussion_r1179659623):

Genesis now can just produce an issue right and not tokens (i.e. they may be issued later). Thus also a global type change and Issue parameters. This makes RGB21 compatible with RGB20

Therefore I'm ok keeping assetOwner* and tokens*, but IMO we should add a check that prevents setting an assetOwner without defining also tokens. Any other solution that removes this inconsistency will also be fine.

dr-orlovsky commented 8 months ago

This can be achieved by creating an AluVM script checking genesis. I will try to do this.

dr-orlovsky commented 8 months ago

BTW we can have more strict requirements in the scheme than in the interface. I mean even if the RGB21 interface allows optional tokens, in schema we can require the presence of at least one:

interface RGB21
    global tokens* :: TokenData
    -- ...

schema UDA implements RGB21
    global tokens+ :: TokenData
    -- ...

I made the necessary changes to the UDA schema in https://github.com/RGB-WG/rgb-schemata/pull/19