Skip to content

Cerebellum-Network/Freeport-Smart-Contracts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Freeport Smart Contracts

Introduction

A set of contracts to hold NFTs, capture royalties, and subscribe to services.

See Freeport.sol.

See the documentation (regenerate with npm run doc).

Deployments

v3.1.2 on Polygon (Production LiveOne)

  • 8_upgrade_freeport
  • 9_upgrade_simple_auction
  • 11_upgrade_fiat_gateway
  • 23_upgrade_auction
  • 24_upgrade_collection_factory
  • 25_upgrade_marketplace
  • 26_upgrade_nftattachment

v3.1.1 on Polygon (Production)

  • Re-run 26_upgrade_nftattachment
  • Re-run 24_upgrade_collection_factory
  • Re-run 25_upgrade_marketplace

v3.1.0 on Polygon (Production)

  • Transfer on factory
  • FREEP-693: added forwarder role to Biconomy forwarder
  • fix-configure_deployment: support fresh artifact files

v3.0.0 on Polygon (Production)

Contracts: Freeport and Fiat Gateway and Simple Auction and NFT Attachment and USDC ERC20 and CollectionFactory and Auction and Marketplace .

Accounts: Fiat-to-NFT Service ( see prod_setup). Biconomy enabled. Admin Gnosis Safe.

v3.0.0 on Polygon Mumbai testnet (Staging)

Contracts: Freeport and Fiat Gateway and Simple Auction and NFT Attachment and Test USDC and CollectionFactory and Auction and Marketplace .

Accounts: Fiat-to-NFT Service ( see stage_setup). Biconomy enabled. Admin.

v3.0.0 on Polygon Mumbai testnet (Dev)

Contracts: Freeport and Fiat Gateway and Simple Auction and NFT Attachment and Test USDC and CollectionFactory and Auction and Marketplace .

Accounts: Fiat-to-NFT Service ( see dev_setup). Biconomy enabled. Admin.

v2.1.0 on Polygon Mumbai (Experiment @AlekseiMisyukevich)

Contracts: Freeport and Fiat Gateway and Simple Auction and NFT Attachment and TestERC20.

Accounts: Fiat-to-NFT Service ( see dev_setup). Biconomy enabled. Admin.

How to upgrade

Review all code changes since the last deployed release. Understand how upgradeable contracts work (see doc). Pay attention to:

  • Events: make sure the event listeners are upgraded to support both new and old versions of events at the same time.
  • Structure changes: make sure existing fields do not change in any way, only new fields are added.
  • Existing data: the existing objects in the contract will have a zero value for new fields; make sure the code handles this correctly.
  • Functions: make sure that no public function was removed or signature changed.
  • Initialization: if a new feature requires some initialization, make sure this happens in a new initialize_vX.X.X function, and that this function is called during the upgrade (example: initialize_v2_0_0).
  • Unit tests: understand what behavior changed.

Bump the version, maintain CHANGELOG.md, and create a release in github.

Then, select which deployment to operate on. One way is to use the configure_deployment script (see configuration inside).

Choose a migration script depending on which contract to upgrade (e.g.: N=8). For the DEV environment, you need to edit the addresses in build/*.json. Then run:

npm run test
export MNEMONIC="  …mnemonic of a wallet that is admin…  "
truffle migrate --compile-all --network=polygon_testnet -f N --to N

Release the JS SDK (see instructions).

How to deploy

npm test
npm run migrate --network=polygon_testnet

Write down the contract address and current version in the Releases section above.

Commit these files in build/contracts/: Freeport.json, FiatGateway.json, SimpleAuction.json , NFTAttachment.json.

For dev on Polygon testnet, setup test accounts:

truffle exec scripts/dev_setup.js --network=polygon_testnet

For staging on Polygon testnet, setup test accounts:

truffle exec scripts/stage_setup.js --network=polygon_testnet

For prod on Polygon mainnet, setup production accounts (edit the scripts to change accounts):

truffle exec scripts/prod_setup.js --network=polygon_mainnet
truffle exec scripts/prod_add_admin.js --network polygon_mainnet

The script will print the address of the different accounts, including the fiat-to-nft service account.

Verify on Polyscan using the information in Freeport.json and the flattened code:

npm run flatten

More instructions can be found in the original README of the template.

How to use test image

1. To copy the latest snapshot of db with deployed contract and built contracts use

sudo . ./copy-artifacts.sh dir_path_to (copy to your directory)
sudo . ./copy-artifacts.sh (copy to default ./artifacts directory)

2. To run ganache cli locally with already deployed contract use

export MNEMONIC='spatial spin account funny glue cancel cushion twelve inmate author night dust'
export NETWORK_ID=5777
docker run -d -p 8545:8545 524725240689.dkr.ecr.us-west-2.amazonaws.com/crb-davinci-nft-test:latest --db /app/db --mnemonic $MNEMONIC --networkId $NETWORK_ID

How to update Freeport SDK

  1. Open SDK project in IDE, switch to master branch
  2. Copy smart-contract artifacts from /build/contracts to SDK's /src/artifacts
  3. Run yarn update-types
  4. Commit changes with message like "artifacts from commit e57691bc"
  5. Check that npm whoami returns "cere-io" (otherwise update your NPM_TOKEN env var for publishing @cere packages)
  6. Run yarn deploy and publish next version ( see Versioning)
  7. Push changes to the remote branch
  8. Install the new version of SDK in projects that use it

How to run e2e test locally

Readme.md for running e2e-test locally is here. For this service you need to create image locally and tag it with tag 524725240689.dkr.ecr.us-west-2.amazonaws.com/crb-davinci-nft-test:YOUR_CUSTOM_TAG and use YOUR_CUSTOM_TAG for running e2e-tests locally.

Where to check the e2e-tests result after merge in dev?

After merge in develop, make sure that tests passed in @e2e-test-results channel on Cere Slack.

Contracts Overview

image