Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added example to showcase OZ ERC1967Upgrade (#613) #615

Merged
merged 5 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "VoteProxy",
"sourceName": "contracts/solidity/oz/ERC1967Upgrade/VoteProxy.sol",
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "implementationContract",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [
{
"internalType": "address",
"name": "target",
"type": "address"
}
],
"name": "AddressEmptyCode",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "admin",
"type": "address"
}
],
"name": "ERC1967InvalidAdmin",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "implementation",
"type": "address"
}
],
"name": "ERC1967InvalidImplementation",
"type": "error"
},
{
"inputs": [],
"name": "ERC1967NonPayable",
"type": "error"
},
{
"inputs": [],
"name": "FailedInnerCall",
"type": "error"
},
{
"inputs": [],
"name": "Unauthorized_Caller",
"type": "error"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "previousAdmin",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "newAdmin",
"type": "address"
}
],
"name": "AdminChanged",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "implementation",
"type": "address"
}
],
"name": "Upgraded",
"type": "event"
},
{
"stateMutability": "payable",
"type": "fallback"
},
{
"inputs": [
{
"internalType": "address",
"name": "newAdmin",
"type": "address"
}
],
"name": "changeAdmin",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "getAdminSlot",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [],
"name": "getCurrentAdmin",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getImplementationSlot",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [],
"name": "implementation",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newImplementation",
"type": "address"
},
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
}
],
"name": "upgradeToAndCall",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"stateMutability": "payable",
"type": "receive"
}
],
"bytecode": "0x60806040523480156200001157600080fd5b5060405162000a8238038062000a82833981016040819052620000349162000330565b604080516020810190915260008152819062000051828262000066565b506200005f905033620000cc565b506200038c565b62000071826200013e565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a2805115620000be57620000b98282620001be565b505050565b620000c86200023b565b5050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200010e60008051602062000a62833981519152546001600160a01b031690565b604080516001600160a01b03928316815291841660208301520160405180910390a16200013b816200025d565b50565b806001600160a01b03163b6000036200017a57604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b80546001600160a01b0319166001600160a01b039290921691909117905550565b6060600080846001600160a01b031684604051620001dd91906200035b565b600060405180830381855af49150503d80600081146200021a576040519150601f19603f3d011682016040523d82523d6000602084013e6200021f565b606091505b50909250905062000232858383620002a0565b95945050505050565b34156200025b5760405163b398979f60e01b815260040160405180910390fd5b565b6001600160a01b0381166200028957604051633173bdd160e11b81526000600482015260240162000171565b8060008051602062000a628339815191526200019d565b606082620002b957620002b38262000306565b620002ff565b8151158015620002d157506001600160a01b0384163b155b15620002fc57604051639996b31560e01b81526001600160a01b038516600482015260240162000171565b50805b9392505050565b805115620003175780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6000602082840312156200034357600080fd5b81516001600160a01b0381168114620002ff57600080fd5b6000825160005b818110156200037e576020818601810151858301520162000362565b506000920191825250919050565b6106c6806200039c6000396000f3fe6080604052600436106100695760003560e01c80637a34c821116100435780637a34c821146100e15780638f2839701461011e5780639ad5c59a1461013e57610070565b80634f1ef2861461007a5780635c60da1b1461009a578063643d430c146100cc57610070565b3661007057005b610078610171565b005b34801561008657600080fd5b50610078610095366004610584565b610183565b3480156100a657600080fd5b506100af6101cc565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156100d857600080fd5b506100af6101db565b3480156100ed57600080fd5b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b6040519081526020016100c3565b34801561012a57600080fd5b50610078610139366004610646565b6101e5565b34801561014a57600080fd5b507fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103610110565b61018161017c6101cc565b61022c565b565b3361018c610250565b6001600160a01b0316816001600160a01b0316146101bd5760405163235c17e160e11b815260040160405180910390fd5b6101c78383610283565b505050565b60006101d66102d9565b905090565b60006101d6610250565b336101ee610250565b6001600160a01b0316816001600160a01b03161461021f5760405163235c17e160e11b815260040160405180910390fd5b61022882610301565b5050565b3660008037600080366000845af43d6000803e80801561024b573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b61028c82610358565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a28051156102d1576101c782826103e4565b61022861045a565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610274565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61032a610250565b604080516001600160a01b03928316815291841660208301520160405180910390a161035581610479565b50565b806001600160a01b03163b60000361039357604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b039290921691909117905550565b6060600080846001600160a01b0316846040516104019190610661565b600060405180830381855af49150503d806000811461043c576040519150601f19603f3d011682016040523d82523d6000602084013e610441565b606091505b50915091506104518583836104ca565b95945050505050565b34156101815760405163b398979f60e01b815260040160405180910390fd5b6001600160a01b0381166104a357604051633173bdd160e11b81526000600482015260240161038a565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61036103b6565b6060826104df576104da82610529565b610522565b81511580156104f657506001600160a01b0384163b155b1561051f57604051639996b31560e01b81526001600160a01b038516600482015260240161038a565b50805b9392505050565b8051156105395780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b80356001600160a01b038116811461056957600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561059757600080fd5b6105a083610552565b9150602083013567ffffffffffffffff808211156105bd57600080fd5b818501915085601f8301126105d157600080fd5b8135818111156105e3576105e361056e565b604051601f8201601f19908116603f0116810190838211818310171561060b5761060b61056e565b8160405282815288602084870101111561062457600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60006020828403121561065857600080fd5b61052282610552565b6000825160005b818110156106825760208186018101518583015201610668565b50600092019182525091905056fea26469706673582212202aaf3a762083dd7fa6a6a17a283e93b780d61d425d8a7733156d3caf1dd311ea64736f6c63430008140033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103",
"deployedBytecode": "0x6080604052600436106100695760003560e01c80637a34c821116100435780637a34c821146100e15780638f2839701461011e5780639ad5c59a1461013e57610070565b80634f1ef2861461007a5780635c60da1b1461009a578063643d430c146100cc57610070565b3661007057005b610078610171565b005b34801561008657600080fd5b50610078610095366004610584565b610183565b3480156100a657600080fd5b506100af6101cc565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156100d857600080fd5b506100af6101db565b3480156100ed57600080fd5b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b6040519081526020016100c3565b34801561012a57600080fd5b50610078610139366004610646565b6101e5565b34801561014a57600080fd5b507fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103610110565b61018161017c6101cc565b61022c565b565b3361018c610250565b6001600160a01b0316816001600160a01b0316146101bd5760405163235c17e160e11b815260040160405180910390fd5b6101c78383610283565b505050565b60006101d66102d9565b905090565b60006101d6610250565b336101ee610250565b6001600160a01b0316816001600160a01b03161461021f5760405163235c17e160e11b815260040160405180910390fd5b61022882610301565b5050565b3660008037600080366000845af43d6000803e80801561024b573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b61028c82610358565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a28051156102d1576101c782826103e4565b61022861045a565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610274565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61032a610250565b604080516001600160a01b03928316815291841660208301520160405180910390a161035581610479565b50565b806001600160a01b03163b60000361039357604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b039290921691909117905550565b6060600080846001600160a01b0316846040516104019190610661565b600060405180830381855af49150503d806000811461043c576040519150601f19603f3d011682016040523d82523d6000602084013e610441565b606091505b50915091506104518583836104ca565b95945050505050565b34156101815760405163b398979f60e01b815260040160405180910390fd5b6001600160a01b0381166104a357604051633173bdd160e11b81526000600482015260240161038a565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61036103b6565b6060826104df576104da82610529565b610522565b81511580156104f657506001600160a01b0384163b155b1561051f57604051639996b31560e01b81526001600160a01b038516600482015260240161038a565b50805b9392505050565b8051156105395780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b80356001600160a01b038116811461056957600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561059757600080fd5b6105a083610552565b9150602083013567ffffffffffffffff808211156105bd57600080fd5b818501915085601f8301126105d157600080fd5b8135818111156105e3576105e361056e565b604051601f8201601f19908116603f0116810190838211818310171561060b5761060b61056e565b8160405282815288602084870101111561062457600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60006020828403121561065857600080fd5b61052282610552565b6000825160005b818110156106825760208186018101518583015201610668565b50600092019182525091905056fea26469706673582212202aaf3a762083dd7fa6a6a17a283e93b780d61d425d8a7733156d3caf1dd311ea64736f6c63430008140033",
"linkReferences": {},
"deployedLinkReferences": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "VoteV1",
"sourceName": "contracts/solidity/oz/ERC1967Upgrade/VoteV1.sol",
"abi": [
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "InvalidInitialization",
"type": "error"
},
{
"inputs": [],
"name": "NotInitializing",
"type": "error"
},
{
"inputs": [],
"name": "Voter_Has_Already_Voted",
"type": "error"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint64",
"name": "version",
"type": "uint64"
}
],
"name": "Initialized",
"type": "event"
},
{
"inputs": [],
"name": "initialize",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "version",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "vote",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "voter",
"type": "address"
}
],
"name": "voted",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "voters",
"outputs": [
{
"internalType": "address[]",
"name": "",
"type": "address[]"
}
],
"stateMutability": "view",
"type": "function"
}
],
"bytecode": "0x608060405234801561001057600080fd5b5060016000556103a5806100256000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c8063350580ea1461005c57806354fd4d501461007a578063632a9a521461008b5780638129fc1c14610095578063aec2ccae1461009d575b600080fd5b6100646100d9565b60405161007191906102f2565b60405180910390f35b600054604051908152602001610071565b61009361013b565b005b6100936101d3565b6100c96100ab36600461033f565b6001600160a01b031660009081526002602052604090205460ff1690565b6040519015158152602001610071565b6060600180548060200260200160405190810160405280929190818152602001828054801561013157602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610113575b5050505050905090565b3360008181526002602052604090205460ff161561016c57604051633b1dbd5760e11b815260040160405180910390fd5b506001805480820182557fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf601805473ffffffffffffffffffffffffffffffffffffffff1916339081179091556000908152600260205260409020805460ff19169091179055565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff1660008115801561021e5750825b905060008267ffffffffffffffff16600114801561023b5750303b155b905081158015610249575080155b156102675760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561029b57845468ff00000000000000001916680100000000000000001785555b600160005583156102eb57845468ff000000000000000019168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050565b6020808252825182820181905260009190848201906040850190845b818110156103335783516001600160a01b03168352928401929184019160010161030e565b50909695505050505050565b60006020828403121561035157600080fd5b81356001600160a01b038116811461036857600080fd5b939250505056fea26469706673582212205146ed303b9ede0c0d8554ecaa9f3f408bf1f0ec621c8c59edc7f2847f9bbc6364736f6c63430008140033",
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100575760003560e01c8063350580ea1461005c57806354fd4d501461007a578063632a9a521461008b5780638129fc1c14610095578063aec2ccae1461009d575b600080fd5b6100646100d9565b60405161007191906102f2565b60405180910390f35b600054604051908152602001610071565b61009361013b565b005b6100936101d3565b6100c96100ab36600461033f565b6001600160a01b031660009081526002602052604090205460ff1690565b6040519015158152602001610071565b6060600180548060200260200160405190810160405280929190818152602001828054801561013157602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610113575b5050505050905090565b3360008181526002602052604090205460ff161561016c57604051633b1dbd5760e11b815260040160405180910390fd5b506001805480820182557fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf601805473ffffffffffffffffffffffffffffffffffffffff1916339081179091556000908152600260205260409020805460ff19169091179055565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff1660008115801561021e5750825b905060008267ffffffffffffffff16600114801561023b5750303b155b905081158015610249575080155b156102675760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561029b57845468ff00000000000000001916680100000000000000001785555b600160005583156102eb57845468ff000000000000000019168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050565b6020808252825182820181905260009190848201906040850190845b818110156103335783516001600160a01b03168352928401929184019160010161030e565b50909695505050505050565b60006020828403121561035157600080fd5b81356001600160a01b038116811461036857600080fd5b939250505056fea26469706673582212205146ed303b9ede0c0d8554ecaa9f3f408bf1f0ec621c8c59edc7f2847f9bbc6364736f6c63430008140033",
"linkReferences": {},
"deployedLinkReferences": {}
}
Loading