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

CW-1155 (and royalties extension) #162

Open
wants to merge 59 commits into
base: main
Choose a base branch
from

Conversation

dirtyshab
Copy link

@dirtyshab dirtyshab commented May 6, 2024

This PR adds a basic implementation of ERC-1155 Multi Token Standard, along with the following extensions:

References:

Some context on the history and current state of development:
This PR continues where PR #78 left off. That implementation had most of the key parts of the standard implemented but was missing some things and required minor fixes to logic.

This PR includes the following additions to the previous implementation by ALPAC-4:

  • On-Chain Royalties extension (based off cw2981).
  • Send functions will pass along native funds sent along with the message to the recipient.
  • Execute MintBatch: mint a batch of tokens.
  • Execute Approve/Revoke: grant/revoke approval on specific tokens and token balances (from cw721).
  • Query ContractInfo: query name/symbol of collection (from cw721).
  • Query Ownership: query contract admin (from cw721).
  • Query AllTokenInfo: query for paginated list of token infos (from cw721).
  • Query Supply: query total number of tokens minted (from cw721).
  • Refactors events to be in format {action}_single and {action}_batch. Batch events will also emit 1 event instead of multiple Single events.

Updates to cw721:

  • generic parameter TQueryExtensionMsg added to Cw721Contract and relevant traits to handle query extension message

ALPAC-4 and others added 25 commits April 30, 2024 15:36
fix: batch events that involve multiple tokens will emit 1 event instead of multiple, with a comma delimited list of '{token_id}:{amount}'.
fix: remove query IsApprovedForAll - too gas intensive, use query 'ApprovalsFor' instead.
fix: verify_approval/s functions.
chore: rename 'ApprovedForAll' to 'ApprovalsFor'.
chore: TokenAmount struct instead of (token_id, amount) tuple vec.
chore: use workspace deps in cargo.
* feat: token_approvals map for approvals on specific tokens on a set amount.
feat: removes previously set token approvals when transferring/burning

* fix: decrement token approvals instead of removing if not expired and amount transferred is less than approved amount

* feat: execute Approve/Revoke single methods

* feat: Approvals query for approvals on a token owner
…r resemble standard, adds missing messages (todo - implement)
feat: uses cw_ownable for minter storage and auth.
dirtyshab and others added 2 commits July 8, 2024 18:33
* rename states: tokens -> nft_info, contract_info -> collection_info

* renamed structs and deprecate: TokenInfo -> NftInfo, ContractInfo -> CollectionInfo, ContractInfoResponse -> CollectionInfoResponse

* cargo schema

* change storage keys for collection info and nft info, consider in migration and keep legacy data for backward migration

* use PA repo for `cw-ownable`

* rename generics and make more readable

* CollectionInfoResponse -> CollectionInfo

* add CollectionInfoExtension with RoyaltyInfo

* cargo schema

* typo

* cleanup

* rename

* cargo schema

* cleanup

* creator and owner changes:
- new query GetMinterOwnership and GetCreatorOwnership, deprecated Ownership
- new execute UpdateMinterOwnership and UpdateCreatorOwnership, deprecate UpdateOwnership
- dedicated stores for minter and creator, where creator usess by default cw_ownable singleton!
- new migrate msg allowing to reset creator and minter
- cleanup migration and split legacy part to dedicated functions
- also make sure using decicated CREATOR and MINTER stores and NOT use cw_ownable::...

* refactor and move key logic to cw721 package:
- move logic from cw721-base to cw721
- merge cw721-base and cw721-metadata-onchain into one, distinction is: `extension: T` where T for base contract is `type DefaultMetadataExtension = Option<Metadata>`
- all logic now in default implementation for traits Cw721Execute and Cw721Query

* fix ci

* cargo fmt

* cargo fmt + clippy

* cargo fmt

* cargo schema

* cargo clippy

* undo: do not rename token keys

* fix unit test

* remove useless generic `TMetadataResponse`

* remove response structs to msg.rs

* cargo schema

* move to dedicated fn

* docs

* rename

* cargo clippy

* add build script

* undo collection info extension and royalty info additions, will be added in next pr

* cleanup

* generate schemas for entry points, cleanup

* update rustc 1.65 -> 1.71

* update cosmwasm version 1.2 -> 1.5, due to rustc compiler issues
see also: CosmWasm/cosmwasm#1727

* update optimizer

* update rustc 1.71 -> 1.78

* use optimizer

* formatting

* install rustup first

* set $HOME/.cargo/env

* install libgcc

* install build-base

* cleanup

* cleanup

* Sync cw1155 with upstream (#5)

* wip: sync up cw1155 with upstream improvements from cw-awesome

* fix build errors/tests

---------

Co-authored-by: mr-t <[email protected]>
packages/cw721/src/msg.rs Outdated Show resolved Hide resolved
@dirtyshab dirtyshab changed the title cw1155-base, cw1155-metadata-onchain, cw1155-royalties CW-1155 (and royalties extension) Aug 22, 2024
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.

3 participants