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

[#131] TZIP 12 Updates implementing storage views and storage field changes. #151

Merged
merged 8 commits into from
Jan 7, 2021

Conversation

sras
Copy link
Contributor

@sras sras commented Dec 24, 2020

Description

Removes token-metadata-registry entrypoint and storage fields from contract. Add storage views as requried by tzip-12 and move token metadata to TZIP-16 storage view. Update tests and update stablecoin-client to read token-metadata from the TIP-16 metadata.

Related issue(s)

Resolves #131

✅ Checklist for your Pull Request

Related changes (conditional)

  • Tests

    • If I added new functionality, I added tests covering it.
    • If I fixed a bug, I added a regression test to prevent the bug from
      silently reappearing again.
  • Documentation

    • I checked whether I should update the docs and did so if necessary:
    • I updated changelog unless I am sure my changes are
      not essential.

Stylistic guide (mandatory)

@sras sras force-pushed the sras/#131-tzip-12-oc-views branch 6 times, most recently from 6424024 to 93a41df Compare December 25, 2020 14:37
-- possible to originate the contract.
--
-- TODO: once we move the metadata to its own contract, we can
-- add this info back to the metadata.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, can we add it back already?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added it back.

@sras sras force-pushed the sras/#131-tzip-12-oc-views branch 3 times, most recently from f8043ed to 093e8f4 Compare December 25, 2020 18:04
@sras sras marked this pull request as ready for review December 25, 2020 18:05
Copy link
Contributor

@pasqu4le pasqu4le left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As Ivan predicted this has quite a bit of conflict with #115 and an MR to morley-ledgers to move some of these changes there seems to be in order.

haskell/stack.yaml Outdated Show resolved Hide resolved
haskell/test-common/Lorentz/Contracts/Test/Common.hs Outdated Show resolved Hide resolved
haskell/test-common/Lorentz/Contracts/Test/Common.hs Outdated Show resolved Hide resolved
haskell/src/Lorentz/Contracts/Stablecoin.hs Outdated Show resolved Hide resolved
haskell/nettest/StablecoinClientTest.hs Outdated Show resolved Hide resolved
haskell/test/Lorentz/Contracts/Test/Management.hs Outdated Show resolved Hide resolved
@sras sras force-pushed the sras/#131-tzip-12-oc-views branch 5 times, most recently from 8171f26 to 54ac0f4 Compare January 4, 2021 11:48
haskell/src/Stablecoin/Client/Main.hs Outdated Show resolved Hide resolved
haskell/src/Stablecoin/Client/Impl.hs Outdated Show resolved Hide resolved
haskell/src/Lorentz/Contracts/Stablecoin.hs Outdated Show resolved Hide resolved
haskell/stack.yaml Outdated Show resolved Hide resolved
haskell/src/Stablecoin/Client/Impl.hs Outdated Show resolved Hide resolved
haskell/src/Stablecoin/Client/Impl.hs Outdated Show resolved Hide resolved
@sras sras force-pushed the sras/#131-tzip-12-oc-views branch from fe4d8b6 to 3cb14ac Compare January 6, 2021 14:52
Copy link
Contributor

@pasqu4le pasqu4le left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, only a couple nitpick comments and additionally a couple of things in commit messages:

  1. registery typo in 948b84d

  2. in 3cb14ac it says:

    This includes. Some of the major changes are.

    seems a bit redundant, it should probably be:

    Some of the major changes include:

I'll approve already, feel free to merge with these few little changes

haskell/src/Lorentz/Contracts/Stablecoin.hs Outdated Show resolved Hide resolved
haskell/src/Lorentz/Contracts/Stablecoin.hs Outdated Show resolved Hide resolved
haskell/src/Lorentz/Contracts/StablecoinFA1_2.hs Outdated Show resolved Hide resolved
@sras sras force-pushed the sras/#131-tzip-12-oc-views branch from 275e74e to 5c2b1a2 Compare January 7, 2021 03:06
sras added 8 commits January 7, 2021 08:42
Problem: The token metadata registry entrypoint has been removed from
TZIP-12. We have the option to keep the token metadata as annotated
bigmap in storage, but we have decided to implement it as an offchain
storage view. So we have to remove the metadata registry entrypoint as
well as the corresponding field from the storage.

Solution: Token metadata registry storage field is removed. The
entrypoint is removed as well. The tests that check for token metadata
registry field in storage is removed as well.
Problem: We have to add storage views as required by TZIP-12.

Solution: Implement the storage views and include them in TZIP-16
metadata. Origination procedures during tests have been changed to
remove the token metadata registry contract origination. In addition to
this, the procedure to implement the stablecoin-client commands like
`getBalance` and `getTokenMetadata` has been changed to follow the
metadata URI (currently only tezos-storage scheme is supported), and
fetch and execute the views on the storage. This is not currently
working because of inability to fetch whole storage. The
`morley-metadata` dependency has also been bumped to use the new DSL for
buidling metadata. Both the main contract metadata and FA1.2 variant has
been updated to use it.

Apart from this, some testing infra (`checkView` function) has been
moved to `Test.Common` module from the tests for permits that checks the
behavior of views. And it has been used in tests for the new storage
views.
problem: Earlier we called the contract metadata as TZIP16-metadata to
contrast with the token metadata. But now the token metadata has been
moved to tzip-16 metadata. So we only have one metadata, and we can call
it just "metadata".

solution: Remove the old metadata contract, and rename the
tzip16-metadata.ligo file as simply 'metadata.ligo'. Make the
corresponding change in code, and build configurations.
problem: The morley-metadata repo has got some changes to the metadata
record, and is incompatible with the current code.

solution: Update the morly-metadata dependency and use the new infra to
construct the metadata.
The get-token-metadata stablecoin client call was broken due to the view
being run on a `StorageView` instead of `Storage`. But it has been fixed
by using a modified version of `StorageView` with empty bigmaps so that
it is changed to a `Storage` with with the `GetTokenMetadata` view is
interpreted.
Adds back some FA1.2 metadata that was previously disable due to storage
constraints. We can add it back since we are storing metadata in
external contract.
Problem: We have made some changes in this PR to the contract's
interface, so we should update it in changelog.

Solution: Update the changelog.
Problem: As part of this PR, we have made some new changes to the
morley-metadata dependencies. So we should update their versions and
also should use the new infra from them.

Solution: Bump the dependencies, and use the infra from them.
Some of the major changes include:

  * Add custom instances for FA2 param.

  We have change morley-ledgers FA2 parameter not to be bundled with
  it's generic instance. This is so that we can customize the instance
  to match with FA2 parameter of this contract.

  * Port 'checkView' to morley-metadata and use it here

  This function, since it appeared to be a useful one generally, was
  moved to morley-metadata repo.

  * Move tezosStorageSchema to morley-metadata

  This was just being duplicated here. So we now use this symbol
  imported from morley-metadata.
@sras sras force-pushed the sras/#131-tzip-12-oc-views branch from 5c2b1a2 to 2500dce Compare January 7, 2021 03:15
@pasqu4le pasqu4le merged commit fa7e5dd into master Jan 7, 2021
@pasqu4le pasqu4le deleted the sras/#131-tzip-12-oc-views branch January 7, 2021 09:29
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.

Implement TZIP-16 according to TZIP-12
3 participants