This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8.0; | |
| // A contract that implements Diamond Storage. | |
| library LibA { | |
| // This struct contains state variables we care about. | |
| struct DiamondStorage { | |
| address owner; | |
| bytes32 dataA; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8.0; | |
| // Find facet for function that is called and execute the | |
| // function if a facet is found and return any value. | |
| fallback() external payable { | |
| // get facet from function selector | |
| address facet = selectorTofacet[msg.sig]; | |
| require(facet != address(0)); | |
| // Execute external function from facet using delegatecall and return any value. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //LibAppStorage.sol | |
| struct AppStorage { | |
| uint256 secondVar; | |
| uint256 firstVar; | |
| uint256 lastVar; | |
| ... | |
| } | |
| library LibAppStorage { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //LibAppStorage.sol | |
| struct AppStorage { | |
| uint256 secondVar; | |
| uint256 firstVar; | |
| uint256 lastVar; | |
| ... | |
| } | |
| library LibAppStorage { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //LibAppStorage.sol | |
| struct AppStorage { | |
| uint256 secondVar; | |
| uint256 firstVar; | |
| uint256 lastVar; | |
| ... | |
| } | |
| library LibAppStorage { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // AppStorage.sol | |
| struct AppStorage { | |
| uint256 secondVar; | |
| uint256 firstVar; | |
| uint256 lastVar; | |
| ... | |
| } | |
| // StakingFacet.sol | |
| import "./AppStorage.sol" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // AppStorage.sol | |
| struct AppStorage { | |
| uint256 secondVar; | |
| uint256 firstVar; | |
| uint256 lastVar; | |
| ... | |
| } | |
| // StakingFacet.sol | |
| import "./AppStorage.sol" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: MIT | |
| pragma solidity 0.8.6; | |
| contract ContractA { | |
| string internal tokenName = "FunToken"; | |
| function initialize() external { | |
| address contractBAddress = 0x6B175474E89094C44Da98b954EedeAC495271d0F; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| { | |
| "anonymous": false, | |
| "inputs": [ | |
| { | |
| "indexed": true, | |
| "internalType": "address", | |
| "name": "depositor", | |
| "type": "address" | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Author: Nick Mudge (https://twitter.com/mudgen) | |
| // This is part of my tweet thread, "Six things you need to know to use DELEGATECALL safely": https://twitter.com/mudgen | |
| // Shows how to use DELEGATECALL | |
| // Using OpenZeppelin's Address library check to see if | |
| // myContract has code. | |
| require(Address.isContract(myContractAddress), "Address has no code"); | |
| // Set function argument we are going to use. | |
| uint myArg = 10; |