RGB-WG / rgb-schemata

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

add deterministic_contract_id test #41

Closed zoedberg closed 3 months ago

zoedberg commented 4 months ago

This PR adds a test to assert the deterministic contract ID feature works.

It requires https://github.com/RGB-WG/rgb-std/pull/190 to be merged first, after that I'll update the URL of the patched crate.

zoedberg commented 4 months ago

@dr-orlovsky test passes, but if you prefer we can wait for https://github.com/RGB-WG/rgb-std/pull/191 to be merged first, so I can switch from using add_owned_state_det to add_fungible_state_det

dr-orlovsky commented 4 months ago

So do you confirm that PR works and can I merge it?

zoedberg commented 4 months ago

So do you confirm that PR works and can I merge it?

No, I confirm we are able to issue a contract with deterministic contract ID using rgb-std v0.11 branch (I've tried both with commit 58fbbc4, which is the one in the Cargo.lock, and with 76b6da4, which we get after doing a cargo update). By switching to rgb-std branch det (the branch of PR https://github.com/RGB-WG/rgb-std/pull/191) rgb-schemata stops building, it fails compiling rgb-std, here the error logs:

   Compiling rgb-std v0.11.0-beta.5 (https://github.com/RGB-WG/rgb-std?branch=det#6341d2a2)
error[E0609]: no field `value` on type `&DataState`
   --> /home/zoe/.cargo/git/checkouts/rgb-std-adbac1111552c725/6341d2a/src/interface/contract.rs:263:75
    |
263 |                     .strict_deserialize_type(type_schema.sem_id, revealed.value.as_ref())
    |                                                                           ^^^^^ unknown field

error[E0308]: mismatched types
   --> /home/zoe/.cargo/git/checkouts/rgb-std-adbac1111552c725/6341d2a/src/interface/builder.rs:918:33
    |
918 |             .add_state(type_id, RevealedData::new_random_salt(serialized))?;
    |              ---------          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `DataState`, found `RevealedData`
    |              |
    |              arguments to this method are incorrect
    |
note: method defined here
   --> /home/zoe/.cargo/git/checkouts/rgb-core-545e07908459752c/e83f07b/src/contract/global.rs:72:12
    |
72  |     pub fn add_state(
    |            ^^^^^^^^^
help: call `Into::into` on this expression to convert `RevealedData` into `DataState`
    |
918 |             .add_state(type_id, RevealedData::new_random_salt(serialized).into())?;
    |                                                                          +++++++

Some errors have detailed explanations: E0308, E0609.
For more information about an error, try `rustc --explain E0308`.
error: could not compile `rgb-std` (lib) due to 2 previous errors
dr-orlovsky commented 4 months ago

Try with the new dep tip: I fixed dependencies which has changed since the branch was created. It's a temporary fix since it was already fixed in develop branch which integrates dep and has many other fixes and improvements from the last three days (I just didn't want to touch v0.11 not to affect your tests, so I did this develop branch).

zoedberg commented 4 months ago

Now it compiles and I can confirm the PR works (thus approved)

zoedberg commented 4 months ago

PR rebased and updated