A light and easy to use proxy smart contracts for others smart contracts.
- https://blog.openzeppelin.com/the-transparent-proxy-pattern
- https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/contracts/proxy
- Proxy hack
- deploy proxySlow SC
- call(installSmartContract, targetSc) // targetSc is the logic contract
- proxySlow SC -> proxyCall(targetFunction, targetArgs) -> call(targetSc, targetFunction)
- Upgrade the logic contract using
proxySlow.installSmartContract
- only owner can update the logic contract
- Storage is set on logic contract
- Proxy storage cannot be accessed by the logic contract
- Easy to use: deploy the logic contract, deploy the proxy and update it
- owner standard use Context.caller() and thus owner is proxySlow
- Cannot call directly on sc (if function is protected by: onlyOnwer), only using proxy
- assembly/contracts: proxy smart contract code
- src/proxyUtils.ts: massa-web3 helper functions related to proxy
- assembly/__tests__: smart contract unit test
- src/test_XXX.ts: Buildnet tests (see Buildnet tests section below)
npm install
npm run test
- cp -v .env.sample .env
- EDIT .env
- WALLET_SECRET_KEY requires an account with some coins to deploy
- WALLET_SECRET_KEY_2 is only for the tests (non owner)
- npm install
- Test smart contract upgrade (Demonstrate proxy updatability, low coin amount to deploy):
- deploy add0.wasm, add.wasm + proxy, install add0, call add, install add1 then call add again
- npm run test_pslow_add
- deploy add0.wasm, add.wasm + proxy, install add0, call add, install add1 then call add again
- Test storage (Demonstrate proxy + Storage)
- npm run test_pslow_storage1
- Test detect (Demonstrate proxy detection)
- npm run test_pslow_detect
- Test owner (Demonstrate that the proxy is the owner)
- npm run test_pslow_owner