Skip to content

Flowtyio/dapper-offer-royalties

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Dapper Royalties Metadata

Dapper offers require you to supply royalties for a collection when an offer is created made. However, we can't use the royalties metadata standard to provide this information because these values must all be merchant addresses. We do not know whether an address is a merchant account or not, all we can do is check that the address we're given by royalties has a TokenForwarding.Forwarder object or not.

This royalties metadata view is a supplement to the actual MetadataViews.Royalties view which is meant to return only dapper merchant accounts for royalties. It can exist on an nft, but given that not all offers belong to a specific item (edition based offers), we have instead made our example implement this metadata view on the contract level.

Setup is a single transaction, and a contract update.

import DapperRoyaltiesMetadata from "../contracts/DapperRoyaltiesMetadata.cdc"

transaction(dict: {Address: UFix64}) {
    prepare(acct: AuthAccount) {
        let royalties = DapperRoyaltiesMetadata.fromDict(dict: dict)
        acct.save(royalties, to: DapperRoyaltiesMetadata.DapperRoyaltiesPath)
    }
}
    pub fun resolveView(_ view: Type): AnyStruct? {
        switch view {
            case Type<DapperRoyaltiesMetadata.Royalties>():
                if let royalties = self.account.borrow<&DapperRoyaltiesMetadata.Royalties>(from: DapperRoyaltiesMetadata.DapperRoyaltiesPath) {
                    return DapperRoyaltiesMetadata.Royalties(royalties: royalties.getRoyalties())
                } else {
                    return DapperRoyaltiesMetadata.Royalties(royalties: [])
                }
        }
        return nil
    }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published