bit-country/Metaverse-Network

Tokenize Country Ownership

Closed this issue · 1 comments

ed-iv commented

Heya @justinphamnz, the following is intended to open up a discussion about how we could go about implementing the tokenization of country ownership. This feature would allow country owners to tokenize their ownership status by minting an NFT in a group-class pair that has been designated for this purpose. This will allow 'ownership' of a country to be dealt with using any system built for NFTs, e.g. auctions. Here, this feature is proposed as an alternative means of representing ownership that an owner may opt into by calling the tokenize_ownership() extrinsic.

The existing Country struct would be modified, replacing the current owner field with an ownership_id field that introduces an OwnershipId type that represents multiple types of identifiers allowing ownership to be either account-based or token-based.

Calling tokenize_ownership() mints the special-purpose NFT and adjusts the Country to reflect this by updating the OwnershipId field. The check_ownership() implementation will be changed to check OwnershipId type and determine ownership accordingly.

Calling untokenize_ownership() burns the ownership token and switches ownership_id back to OwnershipId::Standard(AccountId).

The NFT pallet will need to be updated to introduce a new TokenType::Ownership type and to prevent unpermissioned minting/burning of NFTs of this TokenType; this should only happen through the extrinsics described above. Additionally, any NFT transfer will have to check if the NFT being transferred is of type TokenType::Ownership and update the record in using the API provided by associate type CountryOwnershipSource accordingly.

To simplify the interactions between the country and nft pallets, we could mandate that actions like freezing/unfreezing countries can only be performed on countries that are using the 'standard' ownership model. Additionally, maybe we ant to impose some fee for transitioning between ownership models via tokenize_ownership() and untokenize_ownership?

Types

New Types

  • enum OwnershipId
    • Standard(AccountId)
    • Token(AssetId)
  • trait OwnershipTokenManager // abstracts access to NFT implementation
    • fn mint_ownership_token()
    • fn burn_ownership_token()

Modifications to Existing Types

  • trait BCCountry // update API to include facilities to adjust ownership of country
    • fn update_ownership(country_id: CountryId, ownership_id: OwnershipId)
  • struct Country
    • ownership_id: OwnershipId // updated
    • metaData: Vec<u8>
    • currency_id: SocialTokenCurrencyId
  • pub enum TokenType
    • Ownership // add new token type

Country Pallet Changes

  • Config
    • type OwnershipTokenManager: OwnershipTokenManager // associate type to mint/burn
  • Storage
    • CountryOwner doubleMap(CountryId, OwnershipId) => ()
  • Calls
    • tokenize_ownership()
    • untokenize_ownership() or maybe standardize_ownership() ?
  • Module
    • check_ownership() // update to check OwnershipId

NFT Pallet Changes

  • Config
    • type CountryOwnershipSource: BCCountrySelf::AccountId
  • Calls
    • Check for additional TokenType::Ownership case to handle additional requirement of updating country ownership using CountryOwnershipSource::update_ownership()
      • transfer()
      • transfer_batch()
  • Module
    • fn mint_ownership_token()
    • fn burn_ownership_token()

Progress

  • Country pallet adjustments

    • Introduce associate type OwnershipTokenManager for mint/burn of ownership token
    • Update CountryOwner storage to use OwnershipId
    • Implement extrinsics
      • tokenize_ownership
      • standardize_ownership
    • Update check_ownership implementation
    • Adjust transfer_country() call to handle ownership types
  • Add / modify types

    • Create OwnershipId enum
    • Create OwnershipTokenManager trait
    • Add update_ownership() function to BCCountry trait
    • Adjust Country struct to use new OwnershipId
    • Add new TokenType variant TokenType::Ownership
  • NFT pallet adjustments

    • Add associate type CountryOwnershipSource
    • Update extrinsics to check ownership
      • transfer()
      • transfer_batch()
    • Provide implementations for OwnershipTokenManager
      • mint_ownership_token()
      • burn_ownership_token()
  • Add test cases to cover new functinoality

@ed-iv Good plan. Let's convert them to todos.
There is also a change of transfer_country call in bitcountry pallet to handle different ownership type.
Thanks @ed-iv.