RGB-WG / rgb-std

RGB standard libs for WASM & low-level integrations (no FS/networking)

Home Page:https://rgb.tech

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unable to extract issuedSupply

zoedberg opened this issue · comments

I cannot find a way to retrieve the issuedSupply global field from an RGB20 contract.
By doing contract.global("issuedSupply") I receive Err(FieldNameUnknown(FieldName("issuedSupply"))). I've tried also inspecting genesis data, since from the rgb20 interface definition issuedSupply seems to be required only in the global key of the genesis, but I didn't succeed to extract it.

@dr-orlovsky could you please help me with this?

This looks like a bug. Anyway, I think in https://github.com/RGB-WG/rgb-wallet/blob/8981d7d9818bd54c7e2898dd0b68442254101281/std/src/interface/rgb20.rs#LL125C52-L125C64 we need to change none_or_many into one_or_more. Can you pls try that?

one_or_more doesn't exist, but I guess you intended one_or_many. I've tried but the behavior did not change: issuance works and by doing contract.global("issuedSupply") I receive Err(FieldNameUnknown(FieldName("issuedSupply"))).

Ok, here's why it happens:

Interfaces declare ABI which contract schemata must follow. But interfaces do not enforce or verify whether the contract implementing some interface actually follows that (the same as in Ethereum). Why? Since interfaces are not in the consensus layer! Thus, the contract (schema) writer must ensure that the schema is appropriately written and follows the interface requirements.

In the future, it will be the responsibility of the Contractum compiler to do that checks for the authors and fail compilation if the schema implementation is invalid. However, today we do not have yet Contractum compiler, thus we need to check that manually.

The current NIA schema doesn't define global fields issuedSupply, thus interface fails to provide that information. Fixed in RGB-WG/rgb-schemata#7

Also, I am doing a PR which will add a simple API to the Rgb20 contract wrapper to fetch the total issued supply information. I will add it to the #64 where I already picked your fixes for the interface requirements.

Finally, I did a change in the RGB20 standard matching the fixed issuedSupply global state constraints: LNP-BP/LNPBPs@f06756c

Closing as completed with #64