hello guys. how to use AppStorage pattern in solidity
here my. source code:
// Storage.sol
pragma solidity ^0.8.0;
library LibAppStorage {
function diamondStorage() internal pure returns (AppStorage storage ds) {
assembly {
ds.slot := 0
}
}
}
struct AppStorage {
mapping(uint256 => uint256) aavegotchis;
}
Mar 15, 2023, 7:34 PM
pragma solidity ^0.8.0;
import "./AppStorage.sol";
contract A {
function getAavegotchi(uint256 id) public view returns (uint256 ) {
return LibAppStorage.diamondStorage().aavegotchis[id];
}
function setAavegotchi(uint256 id, uint256 nft) public {
LibAppStorage.diamondStorage().aavegotchis[id] = nft;
}
}
import "./AppStorage.sol";
contract A {
function getAavegotchi(uint256 id) public view returns (uint256 ) {
return LibAppStorage.diamondStorage().aavegotchis[id];
}
function setAavegotchi(uint256 id, uint256 nft) public {
LibAppStorage.diamondStorage().aavegotchis[id] = nft;
}
}
Contract B same A
A call set key 1 =. 1
-> when A and B call getAavegotchi whith key =1 -> not same value =1. why?
-> when A and B call getAavegotchi whith key =1 -> not same value =1. why?
Mar 15, 2023, 7:37 PM