Skip to content

In the repo, trying to implement and test upgradable proxy contract.

Notifications You must be signed in to change notification settings

Rita94105/Proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Proxy contract

In the repo, trying to implement and test upgradable proxy contract.

Practice 1

  • UpgradeableProxy.sol

  • TradingCenter.sol: version 1 contract with exchange function to transfer USDT or USDC

  • TradingCenterV2.sol: version 2 contract with malicious empty function to rub all users' money

  • TradingCenterTest.t.sol

    • user1, user2 approve to proxy contract
    • upgrade version 1 contract to version 2
    • Initialize TradingCenterV2
    • empty users' account

practice 2

  • FiatTokenV3.sol:

    • mimick to upgrade USDC contract
    • with new whitelist function that both mint() and transfer() require msg.sender who is in the whitelist to call
    • require to preserve the same slots as FiatTokenV2_1 at first
  • FiatTokenV3Test.t.sol:

Documentation

Environment: foundry

https://book.getfoundry.sh/

Build

1. download fuundry

curl -L https://foundry.paradigm.xyz | bash

2. install or update foundry

foundryup

3. create new project

forge init [project name]

4. install openzepplin

forge install openzeppelin/openzeppelin-contracts --no-commit

5. install Merkle

forge install dmfxyz/murky --no-commit

6. add dependencies and path

forge remappings > remappings.txt

Test

1. download the git

git clone https://github.com/Rita94105/proxy.git

2. adjust the path

cd proxy

3. test Practice 1

forge test --mc TradingCenter
  • test result

TradingCenter_testResut

4. test Practice 2

forge test --mc FiatTokenV3 
  • test result

FiatTokenV3_testResut

About

In the repo, trying to implement and test upgradable proxy contract.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published