Skip to content

Commit

Permalink
update: added bytes argument to overriden upgradeToAndCall
Browse files Browse the repository at this point in the history
Signed-off-by: Logan Nguyen <[email protected]>
  • Loading branch information
quiet-node committed Dec 11, 2023
1 parent 8c63a38 commit 06e7970
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@
"internalType": "address",
"name": "newImplementation",
"type": "address"
},
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
}
],
"name": "upgradeToAndCall",
Expand All @@ -181,8 +186,8 @@
"type": "receive"
}
],
"bytecode": "0x608060405234801561001057600080fd5b5060405162000982380380620009828339810160408190526100319161030b565b604080516020810190915260008152819061004c828261005e565b506100589050336100bd565b50610363565b6100678261012c565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a28051156100b1576100ac82826101ab565b505050565b6100b9610222565b5050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6100fe60008051602062000962833981519152546001600160a01b031690565b604080516001600160a01b03928316815291841660208301520160405180910390a161012981610243565b50565b806001600160a01b03163b60000361016757604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b80546001600160a01b0319166001600160a01b039290921691909117905550565b6060600080846001600160a01b0316846040516101c89190610334565b600060405180830381855af49150503d8060008114610203576040519150601f19603f3d011682016040523d82523d6000602084013e610208565b606091505b509092509050610219858383610283565b95945050505050565b34156102415760405163b398979f60e01b815260040160405180910390fd5b565b6001600160a01b03811661026d57604051633173bdd160e11b81526000600482015260240161015e565b806000805160206200096283398151915261018a565b60608261029857610293826102e2565b6102db565b81511580156102af57506001600160a01b0384163b155b156102d857604051639996b31560e01b81526001600160a01b038516600482015260240161015e565b50805b9392505050565b8051156102f25780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b60006020828403121561031d57600080fd5b81516001600160a01b03811681146102db57600080fd5b6000825160005b81811015610355576020818601810151858301520161033b565b506000920191825250919050565b6105ef80620003736000396000f3fe6080604052600436106100695760003560e01c80637a34c821116100435780637a34c821146100e15780638f2839701461011e5780639ad5c59a1461013e57610070565b8063388e9e0a1461007a5780635c60da1b1461009a578063643d430c146100cc57610070565b3661007057005b610078610171565b005b34801561008657600080fd5b50610078610095366004610561565b610183565b3480156100a657600080fd5b506100af6101da565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156100d857600080fd5b506100af6101e9565b3480156100ed57600080fd5b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b6040519081526020016100c3565b34801561012a57600080fd5b50610078610139366004610561565b6101f3565b34801561014a57600080fd5b507fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103610110565b61018161017c6101da565b610236565b565b3361018c61025a565b6001600160a01b0316816001600160a01b0316146101bd5760405163235c17e160e11b815260040160405180910390fd5b6101d6826040518060200160405280600081525061028d565b5050565b60006101e46102e8565b905090565b60006101e461025a565b336101fc61025a565b6001600160a01b0316816001600160a01b03161461022d5760405163235c17e160e11b815260040160405180910390fd5b6101d682610310565b3660008037600080366000845af43d6000803e808015610255573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b61029682610367565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a28051156102e0576102db82826103f3565b505050565b6101d6610469565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc61027e565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61033961025a565b604080516001600160a01b03928316815291841660208301520160405180910390a161036481610488565b50565b806001600160a01b03163b6000036103a257604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b039290921691909117905550565b6060600080846001600160a01b031684604051610410919061058a565b600060405180830381855af49150503d806000811461044b576040519150601f19603f3d011682016040523d82523d6000602084013e610450565b606091505b50915091506104608583836104d9565b95945050505050565b34156101815760405163b398979f60e01b815260040160405180910390fd5b6001600160a01b0381166104b257604051633173bdd160e11b815260006004820152602401610399565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61036103c5565b6060826104ee576104e982610538565b610531565b815115801561050557506001600160a01b0384163b155b1561052e57604051639996b31560e01b81526001600160a01b0385166004820152602401610399565b50805b9392505050565b8051156105485780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b60006020828403121561057357600080fd5b81356001600160a01b038116811461053157600080fd5b6000825160005b818110156105ab5760208186018101518583015201610591565b50600092019182525091905056fea2646970667358221220e075711bc61d4d836d313f5b68b058a00c95d9aa1af3f2455e2516b3d753c68d64736f6c63430008140033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103",
"deployedBytecode": "0x6080604052600436106100695760003560e01c80637a34c821116100435780637a34c821146100e15780638f2839701461011e5780639ad5c59a1461013e57610070565b8063388e9e0a1461007a5780635c60da1b1461009a578063643d430c146100cc57610070565b3661007057005b610078610171565b005b34801561008657600080fd5b50610078610095366004610561565b610183565b3480156100a657600080fd5b506100af6101da565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156100d857600080fd5b506100af6101e9565b3480156100ed57600080fd5b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b6040519081526020016100c3565b34801561012a57600080fd5b50610078610139366004610561565b6101f3565b34801561014a57600080fd5b507fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103610110565b61018161017c6101da565b610236565b565b3361018c61025a565b6001600160a01b0316816001600160a01b0316146101bd5760405163235c17e160e11b815260040160405180910390fd5b6101d6826040518060200160405280600081525061028d565b5050565b60006101e46102e8565b905090565b60006101e461025a565b336101fc61025a565b6001600160a01b0316816001600160a01b03161461022d5760405163235c17e160e11b815260040160405180910390fd5b6101d682610310565b3660008037600080366000845af43d6000803e808015610255573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b61029682610367565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a28051156102e0576102db82826103f3565b505050565b6101d6610469565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc61027e565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61033961025a565b604080516001600160a01b03928316815291841660208301520160405180910390a161036481610488565b50565b806001600160a01b03163b6000036103a257604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b039290921691909117905550565b6060600080846001600160a01b031684604051610410919061058a565b600060405180830381855af49150503d806000811461044b576040519150601f19603f3d011682016040523d82523d6000602084013e610450565b606091505b50915091506104608583836104d9565b95945050505050565b34156101815760405163b398979f60e01b815260040160405180910390fd5b6001600160a01b0381166104b257604051633173bdd160e11b815260006004820152602401610399565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61036103c5565b6060826104ee576104e982610538565b610531565b815115801561050557506001600160a01b0384163b155b1561052e57604051639996b31560e01b81526001600160a01b0385166004820152602401610399565b50805b9392505050565b8051156105485780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b60006020828403121561057357600080fd5b81356001600160a01b038116811461053157600080fd5b6000825160005b818110156105ab5760208186018101518583015201610591565b50600092019182525091905056fea2646970667358221220e075711bc61d4d836d313f5b68b058a00c95d9aa1af3f2455e2516b3d753c68d64736f6c63430008140033",
"bytecode": "0x60806040523480156200001157600080fd5b5060405162000a8238038062000a82833981016040819052620000349162000330565b604080516020810190915260008152819062000051828262000066565b506200005f905033620000cc565b506200038c565b62000071826200013e565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a2805115620000be57620000b98282620001be565b505050565b620000c86200023b565b5050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200010e60008051602062000a62833981519152546001600160a01b031690565b604080516001600160a01b03928316815291841660208301520160405180910390a16200013b816200025d565b50565b806001600160a01b03163b6000036200017a57604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b80546001600160a01b0319166001600160a01b039290921691909117905550565b6060600080846001600160a01b031684604051620001dd91906200035b565b600060405180830381855af49150503d80600081146200021a576040519150601f19603f3d011682016040523d82523d6000602084013e6200021f565b606091505b50909250905062000232858383620002a0565b95945050505050565b34156200025b5760405163b398979f60e01b815260040160405180910390fd5b565b6001600160a01b0381166200028957604051633173bdd160e11b81526000600482015260240162000171565b8060008051602062000a628339815191526200019d565b606082620002b957620002b38262000306565b620002ff565b8151158015620002d157506001600160a01b0384163b155b15620002fc57604051639996b31560e01b81526001600160a01b038516600482015260240162000171565b50805b9392505050565b805115620003175780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6000602082840312156200034357600080fd5b81516001600160a01b0381168114620002ff57600080fd5b6000825160005b818110156200037e576020818601810151858301520162000362565b506000920191825250919050565b6106c6806200039c6000396000f3fe6080604052600436106100695760003560e01c80637a34c821116100435780637a34c821146100e15780638f2839701461011e5780639ad5c59a1461013e57610070565b80634f1ef2861461007a5780635c60da1b1461009a578063643d430c146100cc57610070565b3661007057005b610078610171565b005b34801561008657600080fd5b50610078610095366004610584565b610183565b3480156100a657600080fd5b506100af6101cc565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156100d857600080fd5b506100af6101db565b3480156100ed57600080fd5b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b6040519081526020016100c3565b34801561012a57600080fd5b50610078610139366004610646565b6101e5565b34801561014a57600080fd5b507fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103610110565b61018161017c6101cc565b61022c565b565b3361018c610250565b6001600160a01b0316816001600160a01b0316146101bd5760405163235c17e160e11b815260040160405180910390fd5b6101c78383610283565b505050565b60006101d66102d9565b905090565b60006101d6610250565b336101ee610250565b6001600160a01b0316816001600160a01b03161461021f5760405163235c17e160e11b815260040160405180910390fd5b61022882610301565b5050565b3660008037600080366000845af43d6000803e80801561024b573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b61028c82610358565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a28051156102d1576101c782826103e4565b61022861045a565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610274565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61032a610250565b604080516001600160a01b03928316815291841660208301520160405180910390a161035581610479565b50565b806001600160a01b03163b60000361039357604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b039290921691909117905550565b6060600080846001600160a01b0316846040516104019190610661565b600060405180830381855af49150503d806000811461043c576040519150601f19603f3d011682016040523d82523d6000602084013e610441565b606091505b50915091506104518583836104ca565b95945050505050565b34156101815760405163b398979f60e01b815260040160405180910390fd5b6001600160a01b0381166104a357604051633173bdd160e11b81526000600482015260240161038a565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61036103b6565b6060826104df576104da82610529565b610522565b81511580156104f657506001600160a01b0384163b155b1561051f57604051639996b31560e01b81526001600160a01b038516600482015260240161038a565b50805b9392505050565b8051156105395780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b80356001600160a01b038116811461056957600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561059757600080fd5b6105a083610552565b9150602083013567ffffffffffffffff808211156105bd57600080fd5b818501915085601f8301126105d157600080fd5b8135818111156105e3576105e361056e565b604051601f8201601f19908116603f0116810190838211818310171561060b5761060b61056e565b8160405282815288602084870101111561062457600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60006020828403121561065857600080fd5b61052282610552565b6000825160005b818110156106825760208186018101518583015201610668565b50600092019182525091905056fea26469706673582212202aaf3a762083dd7fa6a6a17a283e93b780d61d425d8a7733156d3caf1dd311ea64736f6c63430008140033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103",
"deployedBytecode": "0x6080604052600436106100695760003560e01c80637a34c821116100435780637a34c821146100e15780638f2839701461011e5780639ad5c59a1461013e57610070565b80634f1ef2861461007a5780635c60da1b1461009a578063643d430c146100cc57610070565b3661007057005b610078610171565b005b34801561008657600080fd5b50610078610095366004610584565b610183565b3480156100a657600080fd5b506100af6101cc565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156100d857600080fd5b506100af6101db565b3480156100ed57600080fd5b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b6040519081526020016100c3565b34801561012a57600080fd5b50610078610139366004610646565b6101e5565b34801561014a57600080fd5b507fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103610110565b61018161017c6101cc565b61022c565b565b3361018c610250565b6001600160a01b0316816001600160a01b0316146101bd5760405163235c17e160e11b815260040160405180910390fd5b6101c78383610283565b505050565b60006101d66102d9565b905090565b60006101d6610250565b336101ee610250565b6001600160a01b0316816001600160a01b03161461021f5760405163235c17e160e11b815260040160405180910390fd5b61022882610301565b5050565b3660008037600080366000845af43d6000803e80801561024b573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b61028c82610358565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a28051156102d1576101c782826103e4565b61022861045a565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610274565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61032a610250565b604080516001600160a01b03928316815291841660208301520160405180910390a161035581610479565b50565b806001600160a01b03163b60000361039357604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b039290921691909117905550565b6060600080846001600160a01b0316846040516104019190610661565b600060405180830381855af49150503d806000811461043c576040519150601f19603f3d011682016040523d82523d6000602084013e610441565b606091505b50915091506104518583836104ca565b95945050505050565b34156101815760405163b398979f60e01b815260040160405180910390fd5b6001600160a01b0381166104a357604051633173bdd160e11b81526000600482015260240161038a565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61036103b6565b6060826104df576104da82610529565b610522565b81511580156104f657506001600160a01b0384163b155b1561051f57604051639996b31560e01b81526001600160a01b038516600482015260240161038a565b50805b9392505050565b8051156105395780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b80356001600160a01b038116811461056957600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561059757600080fd5b6105a083610552565b9150602083013567ffffffffffffffff808211156105bd57600080fd5b818501915085601f8301126105d157600080fd5b8135818111156105e3576105e361056e565b604051601f8201601f19908116603f0116810190838211818310171561060b5761060b61056e565b8160405282815288602084870101111561062457600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60006020828403121561065857600080fd5b61052282610552565b6000825160005b818110156106825760208186018101518583015201610668565b50600092019182525091905056fea26469706673582212202aaf3a762083dd7fa6a6a17a283e93b780d61d425d8a7733156d3caf1dd311ea64736f6c63430008140033",
"linkReferences": {},
"deployedLinkReferences": {}
}
4 changes: 2 additions & 2 deletions contracts/solidity/oz/ERC1967Upgrade/VoteProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ contract VoteProxy is ERC1967Proxy, Context {
*
* Emits an {IERC1967-Upgraded} event.
*/
function upgradeToAndCall(address newImplementation) external onlyProxyAdmin(_msgSender()){
ERC1967Utils.upgradeToAndCall(newImplementation, "");
function upgradeToAndCall(address newImplementation, bytes memory data) external onlyProxyAdmin(_msgSender()){
ERC1967Utils.upgradeToAndCall(newImplementation, data);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions test/solidity/oz/ERC1967Upgrade/Vote.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe('@ERC1967Upgrade Upgradable Vote Tests', () => {
let voteV1, voteV2, proxiedVoteV1, proxiedVoteV2, voteProxy
let admin, voter
const CALL_EXCEPTION = 'CALL_EXCEPTION'
const EMPTY_DATA = '0x'

beforeEach(async () => {
;[admin, voter] = await ethers.getSigners()
Expand All @@ -66,7 +67,7 @@ describe('@ERC1967Upgrade Upgradable Vote Tests', () => {
})

it('Should upgrade proxy vote to point to voteV2', async () => {
await voteProxy.upgradeToAndCall(voteV2.address)
await voteProxy.upgradeToAndCall(voteV2.address, EMPTY_DATA)

expect(await voteProxy.implementation()).to.eq(voteV2.address)
})
Expand Down Expand Up @@ -154,7 +155,7 @@ describe('@ERC1967Upgrade Upgradable Vote Tests', () => {
admin
)

await voteProxy.upgradeToAndCall(voteV2.address)
await voteProxy.upgradeToAndCall(voteV2.address, EMPTY_DATA)

proxiedVoteV2 = new ethers.Contract(
voteProxy.address,
Expand Down

0 comments on commit 06e7970

Please sign in to comment.