Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to extract issuedSupply #59

Closed
zoedberg opened this issue Jun 5, 2023 · 4 comments
Closed

unable to extract issuedSupply #59

zoedberg opened this issue Jun 5, 2023 · 4 comments
Labels
bug Something isn't working
Milestone

Comments

@zoedberg
Copy link
Contributor

zoedberg commented Jun 5, 2023

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?

@dr-orlovsky
Copy link
Member

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?

@zoedberg
Copy link
Contributor Author

zoedberg commented Jun 7, 2023

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"))).

@dr-orlovsky
Copy link
Member

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

@dr-orlovsky
Copy link
Member

Closing as completed with #64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Development

No branches or pull requests

2 participants