Skip to content

Upgrading Advertisement contracts

Tiago Rosado edited this page Feb 20, 2019 · 5 revisions

As explained in Advertisement contract architecture section, Advertisement contract is composed by three contracts, Advertisement contract, Advertisement Storage contract and Advertisement Finance contract. This separation allows for upgrade of a single contract when any of those contracts need upgrades without the need for redeploying all contracts.

Upgrading Advertisement Contract

Considering Advertisement Storage and Advertisement Finance contracts don't need upgrades the contracts' owner needs to perform the following calls in this exact order:

  1. Deploy Advertisement contract with the correct Advertisement Storage and Advertisement Finance contracts' addresses
  2. (Optional) If the new contract is required to keep track of campaign ids held by the old Advertisement contract, call importBidIds function of the new Advertisement contract with the old Advertisement contract address. Note: The importBidIds function does not check for duplicates.
  3. Call addAddressToWhitelist function of Advertisement Storage contract with the new Advertisement contract address
  4. Call setAllowedAddress function of Advertisement Finance contract with the new Advertisement contract address

This operation will preserve all campaigns stored in Storage and Finance contracts.

Upgrading Advertisement Finance Contract

Contracts' owner needs to perform the following calls in this exact order:

  1. Deploy new Advertisement Finance contract
  2. Call setAdsContractAddress on the new Advertisement Finance contract with the current Advertisement contract address
  3. Call upgradeFinance on the current Advertisement contract

This operation will preserve all campaigns stored in Storage and Finance contracts.

Upgrading Advertisement Storage Contract

This operation will cancel all campaigns stored in the smart contracts.

Contracts' owner needs to perform the following calls in this exact order:

  1. Deploy Advertisement Storage contract
  2. Call setAllowedAddresses function of the new Advertisement Storage contract with the Advertisement contract address
  3. Call upgradeStorage function of Advertisement contract with the new Advertisement Storage contract address