Skip to content

migrate eth flower

Moritz Fuller edited this page Aug 26, 2023 · 1 revision

steps mainnet

in main

  1. create initArgs.did, make sure restoreEnabled is set to true and don't forget to set the correct principal
  2. add canister_ids.json (make mainnet canister production)

in feature/ethflower-backup

  1. add ethflower.json to backup/data
  2. npm run eth-backup
  3. dfx canister --network ic stop production
  4. check backup file manually

in main

  1. DFX_MOC_PATH="$(vessel bin)/moc" dfx deploy --network ic --argument "$(cat initArgs.did)" production --mode reinstall
  2. dfx canister --network ic start production
  3. npm run restore -- --canister-id "$(dfx canister id --network ic production)" --file <latest_backup>.json --pem "$(dfx identity export fpd)" --network ic
  4. remove restoreEnabled from initArgs.did
  5. npm run upgrade-production
  6. dfx canister --network ic call production initCap

steps locally

in feature/ethflower-backup

  1. npm run replica && npm run deploy-local && npm run eth-backup
  2. npm run restore -- --canister-id "$(dfx canister id staging)" --file <latest_backup>.json --pem "$(dfx identity export fpd)"
  3. npm run backup -- --canister-id "$(dfx canister id staging)"
  4. compare the two backup files with one another (use git diff or something similar)
  5. npm run compare
  6. remove restoreEnabled
  7. npm run upgrade:staging

stable state

_registryState : [(TokenIndex, AccountIdentifier)] -> registry : [(TokenIndex, AccountIdentifier)]

  • mapping from token index to owner

_tokenMetadataState : [(TokenIndex, Metadata)] -> tokenMetadata : [(TokenIndex, Metadata)]

  • mapping from token index to metadata, always #nonfungible : { metadata : ?Blob; };
  • metadata encodes the corresponding asset as the index of the asset in _assets ( 0 index belongs to placeholder, so it's tokenIndex + 1)

_ownersState : [(AccountIdentifier, [TokenIndex])] -> owners : [(AccountIdentifier, [TokenIndex])]

  • mapping from account identifier to owned tokens

🚨 _tokenListingState : [(TokenIndex, Listing)] -> tokenListing : [(TokenIndex, Listing)]

  • all listings
  type Listing = {
    seller : Principal;
    price : Nat64;
    locked : ?Time;
  };

  public type Listing = {
    seller : Principal;
    price : Nat64;
    locked : ?Time;
    sellerFrontend : ?Text;
    buyerFrontend : ?Text;
  };

🚨 _tokenSettlementState : [(TokenIndex, Settlement)] -> tokenSettlement : [(TokenIndex, Settlement)]

  • when a user locks a token, a settlement is created and the account the ICP has to be sent to returned
  • on settlement, the entry is removed
type Settlement = {
    seller : Principal;
    price : Nat64;
    subaccount : SubAccount;
    buyer : AccountIdentifier;
  };

  public type Settlement = {
    seller : Principal;
    price : Nat64;
    subaccount : SubAccount;
    buyer : AccountIdentifier;
    sellerFrontend : ?Text;
    buyerFrontend : ?Text;
  };

_paymentsState : [(Principal, [SubAccount])]

  • related to escrow payments, not needed for power equalizer

_refundsState : [(Principal, [SubAccount])]

  • not used

_usedPaymentAddressess : [(AccountIdentifier, Principal, SubAccount)]

  • related to escrow payments, not needed for power equalizer

🚨 _transactions : [Transaction] -> transactionChunk : [Transaction]

  • record of all transactions
  • when loading the chunks, we have to provide a transactionCount
  type Transaction = {
    token : TokenIdentifier;
    seller : Principal;
    price : Nat64;
    buyer : AccountIdentifier;
    time : Time;
  };

_supply : Balance -> supply : Balance

  • total collection size

_minter : Principal

  • canister deployer

_nextTokenId : TokenIndex -> nextTokenId : TokenIndex

  • used for minting

🚨 _assets : [Asset] -> assets : [Asset]

  • all the assets in this collection
  • each token maps to an asset
  • btcflower has a highres key, we either have to manually add that (bad) or ignore it (also bad)
  • we could just point people to the asset caniste to retrieve the high res
  • instead of including the assets in the backup file, we will upload them after a successfull backup
  type Asset = {
    name : Text;
    thumbnail : ?File;
    highres: ?File;
    metadata: ?File;
    payload : File;
  };

  public type Asset = {
    name : Text;
    thumbnail : ?File;
    metadata : ?File;
    payload : File;
  };

isShuffled : Bool -> isShuffled : Bool

  • has the collection been revealed yet

🚨 _saleTransactions : [SaleTransaction] -> saleTransactionChunk : [SaleTransaction]

  • only transactions that occurred during sale
  • because of batch sale tokens is an array (only difference to transactions)
  • when loading the chunks, we have to provide a saleTransactionCount
  type SaleTransaction = {
    tokens : [TokenIndex];
    seller : Principal;
    price : Nat64;
    buyer : AccountIdentifier;
    time : Time;
  };

_salesSettlementsState : [(AccountIdentifier, Sale)] -> salesSettlements : [(AccountIdentifier, Sale)]

  • irrelevant because sale is over

_failedSales : [(AccountIdentifier, SubAccount)] -> failedSales : [(AccountIdentifier, SubAccount)]

  • irrelevant because sale is over

_tokensForSale : [TokenIndex] -> tokensForSale : [TokenIndex]

  • has to be [] if sale is over

_soldIcp : Nat64 -> soldIcp : Nat64

  • not used in BTC Flower, but used in power equalizer
  • has to be calculated from saleTransactions

_whitelist : [AccountIdentifier] -> [(Nat64, AccountIdentifier, WhitelistSlot)]

  • irrelevant because sale is over
Clone this wiki locally