Skip to content

Instantly share code, notes, and snippets.

@Dustin4444
Created December 1, 2025 12:23
Show Gist options
  • Select an option

  • Save Dustin4444/ca187fda569845ef3b63f0355d5a18a3 to your computer and use it in GitHub Desktop.

Select an option

Save Dustin4444/ca187fda569845ef3b63f0355d5a18a3 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.30+commit.73712a01.js&optimize=undefined&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.9.0;
library TestsAccounts {
function getAccount(uint index) pure public returns (address) {
return address(0);
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.9.0;
library Assert {
event AssertionEvent(
bool passed,
string message,
string methodName
);
event AssertionEventUint(
bool passed,
string message,
string methodName,
uint256 returned,
uint256 expected
);
event AssertionEventInt(
bool passed,
string message,
string methodName,
int256 returned,
int256 expected
);
event AssertionEventBool(
bool passed,
string message,
string methodName,
bool returned,
bool expected
);
event AssertionEventAddress(
bool passed,
string message,
string methodName,
address returned,
address expected
);
event AssertionEventBytes32(
bool passed,
string message,
string methodName,
bytes32 returned,
bytes32 expected
);
event AssertionEventString(
bool passed,
string message,
string methodName,
string returned,
string expected
);
event AssertionEventUintInt(
bool passed,
string message,
string methodName,
uint256 returned,
int256 expected
);
event AssertionEventIntUint(
bool passed,
string message,
string methodName,
int256 returned,
uint256 expected
);
function ok(bool a, string memory message) public returns (bool result) {
result = a;
emit AssertionEvent(result, message, "ok");
}
function equal(uint256 a, uint256 b, string memory message) public returns (bool result) {
result = (a == b);
emit AssertionEventUint(result, message, "equal", a, b);
}
function equal(int256 a, int256 b, string memory message) public returns (bool result) {
result = (a == b);
emit AssertionEventInt(result, message, "equal", a, b);
}
function equal(bool a, bool b, string memory message) public returns (bool result) {
result = (a == b);
emit AssertionEventBool(result, message, "equal", a, b);
}
// TODO: only for certain versions of solc
//function equal(fixed a, fixed b, string message) public returns (bool result) {
// result = (a == b);
// emit AssertionEvent(result, message);
//}
// TODO: only for certain versions of solc
//function equal(ufixed a, ufixed b, string message) public returns (bool result) {
// result = (a == b);
// emit AssertionEvent(result, message);
//}
function equal(address a, address b, string memory message) public returns (bool result) {
result = (a == b);
emit AssertionEventAddress(result, message, "equal", a, b);
}
function equal(bytes32 a, bytes32 b, string memory message) public returns (bool result) {
result = (a == b);
emit AssertionEventBytes32(result, message, "equal", a, b);
}
function equal(string memory a, string memory b, string memory message) public returns (bool result) {
result = (keccak256(abi.encodePacked(a)) == keccak256(abi.encodePacked(b)));
emit AssertionEventString(result, message, "equal", a, b);
}
function notEqual(uint256 a, uint256 b, string memory message) public returns (bool result) {
result = (a != b);
emit AssertionEventUint(result, message, "notEqual", a, b);
}
function notEqual(int256 a, int256 b, string memory message) public returns (bool result) {
result = (a != b);
emit AssertionEventInt(result, message, "notEqual", a, b);
}
function notEqual(bool a, bool b, string memory message) public returns (bool result) {
result = (a != b);
emit AssertionEventBool(result, message, "notEqual", a, b);
}
// TODO: only for certain versions of solc
//function notEqual(fixed a, fixed b, string message) public returns (bool result) {
// result = (a != b);
// emit AssertionEvent(result, message);
//}
// TODO: only for certain versions of solc
//function notEqual(ufixed a, ufixed b, string message) public returns (bool result) {
// result = (a != b);
// emit AssertionEvent(result, message);
//}
function notEqual(address a, address b, string memory message) public returns (bool result) {
result = (a != b);
emit AssertionEventAddress(result, message, "notEqual", a, b);
}
function notEqual(bytes32 a, bytes32 b, string memory message) public returns (bool result) {
result = (a != b);
emit AssertionEventBytes32(result, message, "notEqual", a, b);
}
function notEqual(string memory a, string memory b, string memory message) public returns (bool result) {
result = (keccak256(abi.encodePacked(a)) != keccak256(abi.encodePacked(b)));
emit AssertionEventString(result, message, "notEqual", a, b);
}
/*----------------- Greater than --------------------*/
function greaterThan(uint256 a, uint256 b, string memory message) public returns (bool result) {
result = (a > b);
emit AssertionEventUint(result, message, "greaterThan", a, b);
}
function greaterThan(int256 a, int256 b, string memory message) public returns (bool result) {
result = (a > b);
emit AssertionEventInt(result, message, "greaterThan", a, b);
}
// TODO: safely compare between uint and int
function greaterThan(uint256 a, int256 b, string memory message) public returns (bool result) {
if(b < int(0)) {
// int is negative uint "a" always greater
result = true;
} else {
result = (a > uint(b));
}
emit AssertionEventUintInt(result, message, "greaterThan", a, b);
}
function greaterThan(int256 a, uint256 b, string memory message) public returns (bool result) {
if(a < int(0)) {
// int is negative uint "b" always greater
result = false;
} else {
result = (uint(a) > b);
}
emit AssertionEventIntUint(result, message, "greaterThan", a, b);
}
/*----------------- Lesser than --------------------*/
function lesserThan(uint256 a, uint256 b, string memory message) public returns (bool result) {
result = (a < b);
emit AssertionEventUint(result, message, "lesserThan", a, b);
}
function lesserThan(int256 a, int256 b, string memory message) public returns (bool result) {
result = (a < b);
emit AssertionEventInt(result, message, "lesserThan", a, b);
}
// TODO: safely compare between uint and int
function lesserThan(uint256 a, int256 b, string memory message) public returns (bool result) {
if(b < int(0)) {
// int is negative int "b" always lesser
result = false;
} else {
result = (a < uint(b));
}
emit AssertionEventUintInt(result, message, "lesserThan", a, b);
}
function lesserThan(int256 a, uint256 b, string memory message) public returns (bool result) {
if(a < int(0)) {
// int is negative int "a" always lesser
result = true;
} else {
result = (uint(a) < b);
}
emit AssertionEventIntUint(result, message, "lesserThan", a, b);
}
}
{
"id": "b29bf539a5de0be95e60af045ad2d880",
"_format": "hh-sol-build-info-1",
"solcVersion": "0.8.30",
"solcLongVersion": "0.8.30+commit.73712a01",
"input": {
"language": "Solidity",
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"": [
"ast"
],
"*": [
"abi",
"metadata",
"devdoc",
"userdoc",
"storageLayout",
"evm.legacyAssembly",
"evm.bytecode",
"evm.deployedBytecode",
"evm.methodIdentifiers",
"evm.gasEstimates",
"evm.assembly"
]
}
},
"remappings": []
},
"sources": {
"lib/openzeppelin-contracts/contracts/utils/StorageSlot.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n}\n"
}
}
},
"output": {
"contracts": {
"lib/openzeppelin-contracts/contracts/utils/StorageSlot.sol": {
"StorageSlot": {
"abi": [],
"devdoc": {
"details": "Library for reading and writing primitive types to specific storage slots. Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. This library helps with reading and writing to such slots without the need for inline assembly. The functions in this library return Slot structs that contain a `value` member that can be used to read or write. Example usage to set ERC1967 implementation slot: ``` contract ERC1967 { bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; function _getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } function _setImplementation(address newImplementation) internal { require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\"); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } } ``` _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._",
"kind": "dev",
"methods": {},
"version": 1
},
"evm": {
"assembly": " /* \"lib/openzeppelin-contracts/contracts/utils/StorageSlot.sol\":1279:2670 library StorageSlot {... */\n dataSize(sub_0)\n dataOffset(sub_0)\n 0x0b\n dup3\n dup3\n dup3\n codecopy\n dup1\n mload\n 0x00\n byte\n 0x73\n eq\n tag_1\n jumpi\n mstore(0x00, shl(0xe0, 0x4e487b71))\n mstore(0x04, 0x00)\n revert(0x00, 0x24)\ntag_1:\n mstore(0x00, address)\n 0x73\n dup2\n mstore8\n dup3\n dup2\n return\nstop\n\nsub_0: assembly {\n /* \"lib/openzeppelin-contracts/contracts/utils/StorageSlot.sol\":1279:2670 library StorageSlot {... */\n eq(address, deployTimeAddress())\n mstore(0x40, 0x80)\n revert(0x00, 0x00)\n\n auxdata: 0xa2646970667358221220725b1cedcf19b2fbf7c3c45c08f71df0ebb7daf681f3c5d65a3a5632d50eec8a64736f6c634300081e0033\n}\n",
"bytecode": {
"functionDebugData": {},
"generatedSources": [],
"linkReferences": {},
"object": "60556032600b8282823980515f1a607314602657634e487b7160e01b5f525f60045260245ffd5b305f52607381538281f3fe730000000000000000000000000000000000000000301460806040525f5ffdfea2646970667358221220725b1cedcf19b2fbf7c3c45c08f71df0ebb7daf681f3c5d65a3a5632d50eec8a64736f6c634300081e0033",
"opcodes": "PUSH1 0x55 PUSH1 0x32 PUSH1 0xB DUP3 DUP3 DUP3 CODECOPY DUP1 MLOAD PUSH0 BYTE PUSH1 0x73 EQ PUSH1 0x26 JUMPI PUSH4 0x4E487B71 PUSH1 0xE0 SHL PUSH0 MSTORE PUSH0 PUSH1 0x4 MSTORE PUSH1 0x24 PUSH0 REVERT JUMPDEST ADDRESS PUSH0 MSTORE PUSH1 0x73 DUP2 MSTORE8 DUP3 DUP2 RETURN INVALID PUSH20 0x0 ADDRESS EQ PUSH1 0x80 PUSH1 0x40 MSTORE PUSH0 PUSH0 REVERT INVALID LOG2 PUSH5 0x6970667358 0x22 SLT KECCAK256 PUSH19 0x5B1CEDCF19B2FBF7C3C45C08F71DF0EBB7DAF6 DUP2 RETURN 0xC5 0xD6 GAS GASPRICE JUMP ORIGIN 0xD5 0xE EOFCREATE 0x8A PUSH5 0x736F6C6343 STOP ADDMOD 0x1E STOP CALLER ",
"sourceMap": "1279:1391:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;1279:1391:0;;;;;;;;;;;;;;;;;"
},
"deployedBytecode": {
"functionDebugData": {},
"generatedSources": [],
"immutableReferences": {},
"linkReferences": {},
"object": "730000000000000000000000000000000000000000301460806040525f5ffdfea2646970667358221220725b1cedcf19b2fbf7c3c45c08f71df0ebb7daf681f3c5d65a3a5632d50eec8a64736f6c634300081e0033",
"opcodes": "PUSH20 0x0 ADDRESS EQ PUSH1 0x80 PUSH1 0x40 MSTORE PUSH0 PUSH0 REVERT INVALID LOG2 PUSH5 0x6970667358 0x22 SLT KECCAK256 PUSH19 0x5B1CEDCF19B2FBF7C3C45C08F71DF0EBB7DAF6 DUP2 RETURN 0xC5 0xD6 GAS GASPRICE JUMP ORIGIN 0xD5 0xE EOFCREATE 0x8A PUSH5 0x736F6C6343 STOP ADDMOD 0x1E STOP CALLER ",
"sourceMap": "1279:1391:0:-:0;;;;;;;;"
},
"gasEstimates": {
"creation": {
"codeDepositCost": "17000",
"executionCost": "96",
"totalCost": "17096"
},
"internal": {
"getAddressSlot(bytes32)": "infinite",
"getBooleanSlot(bytes32)": "infinite",
"getBytes32Slot(bytes32)": "infinite",
"getUint256Slot(bytes32)": "infinite"
}
},
"legacyAssembly": {
".code": [
{
"begin": 1279,
"end": 2670,
"name": "PUSH #[$]",
"source": 0,
"value": "0000000000000000000000000000000000000000000000000000000000000000"
},
{
"begin": 1279,
"end": 2670,
"name": "PUSH [$]",
"source": 0,
"value": "0000000000000000000000000000000000000000000000000000000000000000"
},
{
"begin": 1279,
"end": 2670,
"name": "PUSH",
"source": 0,
"value": "B"
},
{
"begin": 1279,
"end": 2670,
"name": "DUP3",
"source": 0
},
{
"begin": 1279,
"end": 2670,
"name": "DUP3",
"source": 0
},
{
"begin": 1279,
"end": 2670,
"name": "DUP3",
"source": 0
},
{
"begin": 1279,
"end": 2670,
"name": "CODECOPY",
"source": 0
},
{
"begin": 1279,
"end": 2670,
"name": "DUP1",
"source": 0
},
{
"begin": 1279,
"end": 2670,
"name": "MLOAD",
"source": 0
},
{
"begin": 1279,
"end": 2670,
"name": "PUSH",
"source": 0,
"value": "0"
},
{
"begin": 1279,
"end": 2670,
"name": "BYTE",
"source": 0
},
{
"begin": 1279,
"end": 2670,
"name": "PUSH",
"source": 0,
"value": "73"
},
{
"begin": 1279,
"end": 2670,
"name": "EQ",
"source": 0
},
{
"begin": 1279,
"end": 2670,
"name": "PUSH [tag]",
"source": 0,
"value": "1"
},
{
"begin": 1279,
"end": 2670,
"name": "JUMPI",
"source": 0
},
{
"begin": -1,
"end": -1,
"name": "PUSH",
"source": -1,
"value": "4E487B71"
},
{
"begin": -1,
"end": -1,
"name": "PUSH",
"source": -1,
"value": "E0"
},
{
"begin": -1,
"end": -1,
"name": "SHL",
"source": -1
},
{
"begin": 1279,
"end": 2670,
"name": "PUSH",
"source": 0,
"value": "0"
},
{
"begin": 1279,
"end": 2670,
"name": "MSTORE",
"source": 0
},
{
"begin": 1279,
"end": 2670,
"name": "PUSH",
"source": 0,
"value": "0"
},
{
"begin": 1279,
"end": 2670,
"name": "PUSH",
"source": 0,
"value": "4"
},
{
"begin": 1279,
"end": 2670,
"name": "MSTORE",
"source": 0
},
{
"begin": 1279,
"end": 2670,
"name": "PUSH",
"source": 0,
"value": "24"
},
{
"begin": 1279,
"end": 2670,
"name": "PUSH",
"source": 0,
"value": "0"
},
{
"begin": 1279,
"end": 2670,
"name": "REVERT",
"source": 0
},
{
"begin": 1279,
"end": 2670,
"name": "tag",
"source": 0,
"value": "1"
},
{
"begin": 1279,
"end": 2670,
"name": "JUMPDEST",
"source": 0
},
{
"begin": 1279,
"end": 2670,
"name": "ADDRESS",
"source": 0
},
{
"begin": 1279,
"end": 2670,
"name": "PUSH",
"source": 0,
"value": "0"
},
{
"begin": 1279,
"end": 2670,
"name": "MSTORE",
"source": 0
},
{
"begin": 1279,
"end": 2670,
"name": "PUSH",
"source": 0,
"value": "73"
},
{
"begin": 1279,
"end": 2670,
"name": "DUP2",
"source": 0
},
{
"begin": 1279,
"end": 2670,
"name": "MSTORE8",
"source": 0
},
{
"begin": 1279,
"end": 2670,
"name": "DUP3",
"source": 0
},
{
"begin": 1279,
"end": 2670,
"name": "DUP2",
"source": 0
},
{
"begin": 1279,
"end": 2670,
"name": "RETURN",
"source": 0
}
],
".data": {
"0": {
".auxdata": "a2646970667358221220725b1cedcf19b2fbf7c3c45c08f71df0ebb7daf681f3c5d65a3a5632d50eec8a64736f6c634300081e0033",
".code": [
{
"begin": 1279,
"end": 2670,
"name": "PUSHDEPLOYADDRESS",
"source": 0
},
{
"begin": 1279,
"end": 2670,
"name": "ADDRESS",
"source": 0
},
{
"begin": 1279,
"end": 2670,
"name": "EQ",
"source": 0
},
{
"begin": 1279,
"end": 2670,
"name": "PUSH",
"source": 0,
"value": "80"
},
{
"begin": 1279,
"end": 2670,
"name": "PUSH",
"source": 0,
"value": "40"
},
{
"begin": 1279,
"end": 2670,
"name": "MSTORE",
"source": 0
},
{
"begin": 1279,
"end": 2670,
"name": "PUSH",
"source": 0,
"value": "0"
},
{
"begin": 1279,
"end": 2670,
"name": "PUSH",
"source": 0,
"value": "0"
},
{
"begin": 1279,
"end": 2670,
"name": "REVERT",
"source": 0
}
]
}
},
"sourceList": [
"lib/openzeppelin-contracts/contracts/utils/StorageSlot.sol",
"#utility.yul"
]
},
"methodIdentifiers": {}
},
"metadata": "{\"compiler\":{\"version\":\"0.8.30+commit.73712a01\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"details\":\"Library for reading and writing primitive types to specific storage slots. Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. This library helps with reading and writing to such slots without the need for inline assembly. The functions in this library return Slot structs that contain a `value` member that can be used to read or write. Example usage to set ERC1967 implementation slot: ``` contract ERC1967 { bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; function _getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } function _setImplementation(address newImplementation) internal { require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\"); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } } ``` _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\",\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"lib/openzeppelin-contracts/contracts/utils/StorageSlot.sol\":\"StorageSlot\"},\"evmVersion\":\"prague\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"lib/openzeppelin-contracts/contracts/utils/StorageSlot.sol\":{\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://39e096c60a6eb1c6a257122d515496bd92d0c6a693a8f07acb6aa4b1263e95d4\",\"dweb:/ipfs/QmPs5trJBacCiSkezP6tpevapuRYWNY6mqSFzsMCJj7e6B\"]}},\"version\":1}",
"storageLayout": {
"storage": [],
"types": null
},
"userdoc": {
"kind": "user",
"methods": {},
"version": 1
}
}
}
},
"sources": {
"lib/openzeppelin-contracts/contracts/utils/StorageSlot.sol": {
"ast": {
"absolutePath": "lib/openzeppelin-contracts/contracts/utils/StorageSlot.sol",
"exportedSymbols": {
"StorageSlot": [
59
]
},
"id": 60,
"license": "MIT",
"nodeType": "SourceUnit",
"nodes": [
{
"id": 1,
"literals": [
"solidity",
"^",
"0.8",
".0"
],
"nodeType": "PragmaDirective",
"src": "105:23:0"
},
{
"abstract": false,
"baseContracts": [],
"canonicalName": "StorageSlot",
"contractDependencies": [],
"contractKind": "library",
"documentation": {
"id": 2,
"nodeType": "StructuredDocumentation",
"src": "130:1148:0",
"text": " @dev Library for reading and writing primitive types to specific storage slots.\n Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n This library helps with reading and writing to such slots without the need for inline assembly.\n The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n Example usage to set ERC1967 implementation slot:\n ```\n contract ERC1967 {\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n function _getImplementation() internal view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n }\n function _setImplementation(address newImplementation) internal {\n require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n }\n }\n ```\n _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._"
},
"fullyImplemented": true,
"id": 59,
"linearizedBaseContracts": [
59
],
"name": "StorageSlot",
"nameLocation": "1287:11:0",
"nodeType": "ContractDefinition",
"nodes": [
{
"canonicalName": "StorageSlot.AddressSlot",
"id": 5,
"members": [
{
"constant": false,
"id": 4,
"mutability": "mutable",
"name": "value",
"nameLocation": "1342:5:0",
"nodeType": "VariableDeclaration",
"scope": 5,
"src": "1334:13:0",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 3,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "1334:7:0",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"visibility": "internal"
}
],
"name": "AddressSlot",
"nameLocation": "1312:11:0",
"nodeType": "StructDefinition",
"scope": 59,
"src": "1305:49:0",
"visibility": "public"
},
{
"canonicalName": "StorageSlot.BooleanSlot",
"id": 8,
"members": [
{
"constant": false,
"id": 7,
"mutability": "mutable",
"name": "value",
"nameLocation": "1394:5:0",
"nodeType": "VariableDeclaration",
"scope": 8,
"src": "1389:10:0",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"typeName": {
"id": 6,
"name": "bool",
"nodeType": "ElementaryTypeName",
"src": "1389:4:0",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"visibility": "internal"
}
],
"name": "BooleanSlot",
"nameLocation": "1367:11:0",
"nodeType": "StructDefinition",
"scope": 59,
"src": "1360:46:0",
"visibility": "public"
},
{
"canonicalName": "StorageSlot.Bytes32Slot",
"id": 11,
"members": [
{
"constant": false,
"id": 10,
"mutability": "mutable",
"name": "value",
"nameLocation": "1449:5:0",
"nodeType": "VariableDeclaration",
"scope": 11,
"src": "1441:13:0",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
"typeName": {
"id": 9,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "1441:7:0",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"visibility": "internal"
}
],
"name": "Bytes32Slot",
"nameLocation": "1419:11:0",
"nodeType": "StructDefinition",
"scope": 59,
"src": "1412:49:0",
"visibility": "public"
},
{
"canonicalName": "StorageSlot.Uint256Slot",
"id": 14,
"members": [
{
"constant": false,
"id": 13,
"mutability": "mutable",
"name": "value",
"nameLocation": "1504:5:0",
"nodeType": "VariableDeclaration",
"scope": 14,
"src": "1496:13:0",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 12,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1496:7:0",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"visibility": "internal"
}
],
"name": "Uint256Slot",
"nameLocation": "1474:11:0",
"nodeType": "StructDefinition",
"scope": 59,
"src": "1467:49:0",
"visibility": "public"
},
{
"body": {
"id": 24,
"nodeType": "Block",
"src": "1698:106:0",
"statements": [
{
"AST": {
"nativeSrc": "1760:38:0",
"nodeType": "YulBlock",
"src": "1760:38:0",
"statements": [
{
"nativeSrc": "1774:14:0",
"nodeType": "YulAssignment",
"src": "1774:14:0",
"value": {
"name": "slot",
"nativeSrc": "1784:4:0",
"nodeType": "YulIdentifier",
"src": "1784:4:0"
},
"variableNames": [
{
"name": "r.slot",
"nativeSrc": "1774:6:0",
"nodeType": "YulIdentifier",
"src": "1774:6:0"
}
]
}
]
},
"documentation": "@solidity memory-safe-assembly",
"evmVersion": "prague",
"externalReferences": [
{
"declaration": 21,
"isOffset": false,
"isSlot": true,
"src": "1774:6:0",
"suffix": "slot",
"valueSize": 1
},
{
"declaration": 17,
"isOffset": false,
"isSlot": false,
"src": "1784:4:0",
"valueSize": 1
}
],
"id": 23,
"nodeType": "InlineAssembly",
"src": "1751:47:0"
}
]
},
"documentation": {
"id": 15,
"nodeType": "StructuredDocumentation",
"src": "1522:87:0",
"text": " @dev Returns an `AddressSlot` with member `value` located at `slot`."
},
"id": 25,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "getAddressSlot",
"nameLocation": "1623:14:0",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 18,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 17,
"mutability": "mutable",
"name": "slot",
"nameLocation": "1646:4:0",
"nodeType": "VariableDeclaration",
"scope": 25,
"src": "1638:12:0",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
"typeName": {
"id": 16,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "1638:7:0",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"visibility": "internal"
}
],
"src": "1637:14:0"
},
"returnParameters": {
"id": 22,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 21,
"mutability": "mutable",
"name": "r",
"nameLocation": "1695:1:0",
"nodeType": "VariableDeclaration",
"scope": 25,
"src": "1675:21:0",
"stateVariable": false,
"storageLocation": "storage",
"typeDescriptions": {
"typeIdentifier": "t_struct$_AddressSlot_$5_storage_ptr",
"typeString": "struct StorageSlot.AddressSlot"
},
"typeName": {
"id": 20,
"nodeType": "UserDefinedTypeName",
"pathNode": {
"id": 19,
"name": "AddressSlot",
"nameLocations": [
"1675:11:0"
],
"nodeType": "IdentifierPath",
"referencedDeclaration": 5,
"src": "1675:11:0"
},
"referencedDeclaration": 5,
"src": "1675:11:0",
"typeDescriptions": {
"typeIdentifier": "t_struct$_AddressSlot_$5_storage_ptr",
"typeString": "struct StorageSlot.AddressSlot"
}
},
"visibility": "internal"
}
],
"src": "1674:23:0"
},
"scope": 59,
"src": "1614:190:0",
"stateMutability": "pure",
"virtual": false,
"visibility": "internal"
},
{
"body": {
"id": 35,
"nodeType": "Block",
"src": "1986:106:0",
"statements": [
{
"AST": {
"nativeSrc": "2048:38:0",
"nodeType": "YulBlock",
"src": "2048:38:0",
"statements": [
{
"nativeSrc": "2062:14:0",
"nodeType": "YulAssignment",
"src": "2062:14:0",
"value": {
"name": "slot",
"nativeSrc": "2072:4:0",
"nodeType": "YulIdentifier",
"src": "2072:4:0"
},
"variableNames": [
{
"name": "r.slot",
"nativeSrc": "2062:6:0",
"nodeType": "YulIdentifier",
"src": "2062:6:0"
}
]
}
]
},
"documentation": "@solidity memory-safe-assembly",
"evmVersion": "prague",
"externalReferences": [
{
"declaration": 32,
"isOffset": false,
"isSlot": true,
"src": "2062:6:0",
"suffix": "slot",
"valueSize": 1
},
{
"declaration": 28,
"isOffset": false,
"isSlot": false,
"src": "2072:4:0",
"valueSize": 1
}
],
"id": 34,
"nodeType": "InlineAssembly",
"src": "2039:47:0"
}
]
},
"documentation": {
"id": 26,
"nodeType": "StructuredDocumentation",
"src": "1810:87:0",
"text": " @dev Returns an `BooleanSlot` with member `value` located at `slot`."
},
"id": 36,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "getBooleanSlot",
"nameLocation": "1911:14:0",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 29,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 28,
"mutability": "mutable",
"name": "slot",
"nameLocation": "1934:4:0",
"nodeType": "VariableDeclaration",
"scope": 36,
"src": "1926:12:0",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
"typeName": {
"id": 27,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "1926:7:0",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"visibility": "internal"
}
],
"src": "1925:14:0"
},
"returnParameters": {
"id": 33,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 32,
"mutability": "mutable",
"name": "r",
"nameLocation": "1983:1:0",
"nodeType": "VariableDeclaration",
"scope": 36,
"src": "1963:21:0",
"stateVariable": false,
"storageLocation": "storage",
"typeDescriptions": {
"typeIdentifier": "t_struct$_BooleanSlot_$8_storage_ptr",
"typeString": "struct StorageSlot.BooleanSlot"
},
"typeName": {
"id": 31,
"nodeType": "UserDefinedTypeName",
"pathNode": {
"id": 30,
"name": "BooleanSlot",
"nameLocations": [
"1963:11:0"
],
"nodeType": "IdentifierPath",
"referencedDeclaration": 8,
"src": "1963:11:0"
},
"referencedDeclaration": 8,
"src": "1963:11:0",
"typeDescriptions": {
"typeIdentifier": "t_struct$_BooleanSlot_$8_storage_ptr",
"typeString": "struct StorageSlot.BooleanSlot"
}
},
"visibility": "internal"
}
],
"src": "1962:23:0"
},
"scope": 59,
"src": "1902:190:0",
"stateMutability": "pure",
"virtual": false,
"visibility": "internal"
},
{
"body": {
"id": 46,
"nodeType": "Block",
"src": "2274:106:0",
"statements": [
{
"AST": {
"nativeSrc": "2336:38:0",
"nodeType": "YulBlock",
"src": "2336:38:0",
"statements": [
{
"nativeSrc": "2350:14:0",
"nodeType": "YulAssignment",
"src": "2350:14:0",
"value": {
"name": "slot",
"nativeSrc": "2360:4:0",
"nodeType": "YulIdentifier",
"src": "2360:4:0"
},
"variableNames": [
{
"name": "r.slot",
"nativeSrc": "2350:6:0",
"nodeType": "YulIdentifier",
"src": "2350:6:0"
}
]
}
]
},
"documentation": "@solidity memory-safe-assembly",
"evmVersion": "prague",
"externalReferences": [
{
"declaration": 43,
"isOffset": false,
"isSlot": true,
"src": "2350:6:0",
"suffix": "slot",
"valueSize": 1
},
{
"declaration": 39,
"isOffset": false,
"isSlot": false,
"src": "2360:4:0",
"valueSize": 1
}
],
"id": 45,
"nodeType": "InlineAssembly",
"src": "2327:47:0"
}
]
},
"documentation": {
"id": 37,
"nodeType": "StructuredDocumentation",
"src": "2098:87:0",
"text": " @dev Returns an `Bytes32Slot` with member `value` located at `slot`."
},
"id": 47,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "getBytes32Slot",
"nameLocation": "2199:14:0",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 40,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 39,
"mutability": "mutable",
"name": "slot",
"nameLocation": "2222:4:0",
"nodeType": "VariableDeclaration",
"scope": 47,
"src": "2214:12:0",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
"typeName": {
"id": 38,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "2214:7:0",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"visibility": "internal"
}
],
"src": "2213:14:0"
},
"returnParameters": {
"id": 44,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 43,
"mutability": "mutable",
"name": "r",
"nameLocation": "2271:1:0",
"nodeType": "VariableDeclaration",
"scope": 47,
"src": "2251:21:0",
"stateVariable": false,
"storageLocation": "storage",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Bytes32Slot_$11_storage_ptr",
"typeString": "struct StorageSlot.Bytes32Slot"
},
"typeName": {
"id": 42,
"nodeType": "UserDefinedTypeName",
"pathNode": {
"id": 41,
"name": "Bytes32Slot",
"nameLocations": [
"2251:11:0"
],
"nodeType": "IdentifierPath",
"referencedDeclaration": 11,
"src": "2251:11:0"
},
"referencedDeclaration": 11,
"src": "2251:11:0",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Bytes32Slot_$11_storage_ptr",
"typeString": "struct StorageSlot.Bytes32Slot"
}
},
"visibility": "internal"
}
],
"src": "2250:23:0"
},
"scope": 59,
"src": "2190:190:0",
"stateMutability": "pure",
"virtual": false,
"visibility": "internal"
},
{
"body": {
"id": 57,
"nodeType": "Block",
"src": "2562:106:0",
"statements": [
{
"AST": {
"nativeSrc": "2624:38:0",
"nodeType": "YulBlock",
"src": "2624:38:0",
"statements": [
{
"nativeSrc": "2638:14:0",
"nodeType": "YulAssignment",
"src": "2638:14:0",
"value": {
"name": "slot",
"nativeSrc": "2648:4:0",
"nodeType": "YulIdentifier",
"src": "2648:4:0"
},
"variableNames": [
{
"name": "r.slot",
"nativeSrc": "2638:6:0",
"nodeType": "YulIdentifier",
"src": "2638:6:0"
}
]
}
]
},
"documentation": "@solidity memory-safe-assembly",
"evmVersion": "prague",
"externalReferences": [
{
"declaration": 54,
"isOffset": false,
"isSlot": true,
"src": "2638:6:0",
"suffix": "slot",
"valueSize": 1
},
{
"declaration": 50,
"isOffset": false,
"isSlot": false,
"src": "2648:4:0",
"valueSize": 1
}
],
"id": 56,
"nodeType": "InlineAssembly",
"src": "2615:47:0"
}
]
},
"documentation": {
"id": 48,
"nodeType": "StructuredDocumentation",
"src": "2386:87:0",
"text": " @dev Returns an `Uint256Slot` with member `value` located at `slot`."
},
"id": 58,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "getUint256Slot",
"nameLocation": "2487:14:0",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 51,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 50,
"mutability": "mutable",
"name": "slot",
"nameLocation": "2510:4:0",
"nodeType": "VariableDeclaration",
"scope": 58,
"src": "2502:12:0",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
"typeName": {
"id": 49,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "2502:7:0",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"visibility": "internal"
}
],
"src": "2501:14:0"
},
"returnParameters": {
"id": 55,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 54,
"mutability": "mutable",
"name": "r",
"nameLocation": "2559:1:0",
"nodeType": "VariableDeclaration",
"scope": 58,
"src": "2539:21:0",
"stateVariable": false,
"storageLocation": "storage",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Uint256Slot_$14_storage_ptr",
"typeString": "struct StorageSlot.Uint256Slot"
},
"typeName": {
"id": 53,
"nodeType": "UserDefinedTypeName",
"pathNode": {
"id": 52,
"name": "Uint256Slot",
"nameLocations": [
"2539:11:0"
],
"nodeType": "IdentifierPath",
"referencedDeclaration": 14,
"src": "2539:11:0"
},
"referencedDeclaration": 14,
"src": "2539:11:0",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Uint256Slot_$14_storage_ptr",
"typeString": "struct StorageSlot.Uint256Slot"
}
},
"visibility": "internal"
}
],
"src": "2538:23:0"
},
"scope": 59,
"src": "2478:190:0",
"stateMutability": "pure",
"virtual": false,
"visibility": "internal"
}
],
"scope": 60,
"src": "1279:1391:0",
"usedErrors": [],
"usedEvents": []
}
],
"src": "105:2566:0"
},
"id": 0
}
}
}
}
{
"deploy": {
"VM:-": {
"linkReferences": {},
"autoDeployLib": true
},
"main:1": {
"linkReferences": {},
"autoDeployLib": true
},
"sepolia:11155111": {
"linkReferences": {},
"autoDeployLib": true
},
"Custom": {
"linkReferences": {},
"autoDeployLib": true
}
},
"data": {
"bytecode": {
"functionDebugData": {},
"generatedSources": [],
"linkReferences": {},
"object": "60556032600b8282823980515f1a607314602657634e487b7160e01b5f525f60045260245ffd5b305f52607381538281f3fe730000000000000000000000000000000000000000301460806040525f5ffdfea2646970667358221220725b1cedcf19b2fbf7c3c45c08f71df0ebb7daf681f3c5d65a3a5632d50eec8a64736f6c634300081e0033",
"opcodes": "PUSH1 0x55 PUSH1 0x32 PUSH1 0xB DUP3 DUP3 DUP3 CODECOPY DUP1 MLOAD PUSH0 BYTE PUSH1 0x73 EQ PUSH1 0x26 JUMPI PUSH4 0x4E487B71 PUSH1 0xE0 SHL PUSH0 MSTORE PUSH0 PUSH1 0x4 MSTORE PUSH1 0x24 PUSH0 REVERT JUMPDEST ADDRESS PUSH0 MSTORE PUSH1 0x73 DUP2 MSTORE8 DUP3 DUP2 RETURN INVALID PUSH20 0x0 ADDRESS EQ PUSH1 0x80 PUSH1 0x40 MSTORE PUSH0 PUSH0 REVERT INVALID LOG2 PUSH5 0x6970667358 0x22 SLT KECCAK256 PUSH19 0x5B1CEDCF19B2FBF7C3C45C08F71DF0EBB7DAF6 DUP2 RETURN 0xC5 0xD6 GAS GASPRICE JUMP ORIGIN 0xD5 0xE EOFCREATE 0x8A PUSH5 0x736F6C6343 STOP ADDMOD 0x1E STOP CALLER ",
"sourceMap": "1279:1391:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;1279:1391:0;;;;;;;;;;;;;;;;;"
},
"deployedBytecode": {
"functionDebugData": {},
"generatedSources": [],
"immutableReferences": {},
"linkReferences": {},
"object": "730000000000000000000000000000000000000000301460806040525f5ffdfea2646970667358221220725b1cedcf19b2fbf7c3c45c08f71df0ebb7daf681f3c5d65a3a5632d50eec8a64736f6c634300081e0033",
"opcodes": "PUSH20 0x0 ADDRESS EQ PUSH1 0x80 PUSH1 0x40 MSTORE PUSH0 PUSH0 REVERT INVALID LOG2 PUSH5 0x6970667358 0x22 SLT KECCAK256 PUSH19 0x5B1CEDCF19B2FBF7C3C45C08F71DF0EBB7DAF6 DUP2 RETURN 0xC5 0xD6 GAS GASPRICE JUMP ORIGIN 0xD5 0xE EOFCREATE 0x8A PUSH5 0x736F6C6343 STOP ADDMOD 0x1E STOP CALLER ",
"sourceMap": "1279:1391:0:-:0;;;;;;;;"
},
"gasEstimates": {
"creation": {
"codeDepositCost": "17000",
"executionCost": "96",
"totalCost": "17096"
},
"internal": {
"getAddressSlot(bytes32)": "infinite",
"getBooleanSlot(bytes32)": "infinite",
"getBytes32Slot(bytes32)": "infinite",
"getUint256Slot(bytes32)": "infinite"
}
},
"methodIdentifiers": {}
},
"abi": []
}
{
"compiler": {
"version": "0.8.30+commit.73712a01"
},
"language": "Solidity",
"output": {
"abi": [],
"devdoc": {
"details": "Library for reading and writing primitive types to specific storage slots. Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. This library helps with reading and writing to such slots without the need for inline assembly. The functions in this library return Slot structs that contain a `value` member that can be used to read or write. Example usage to set ERC1967 implementation slot: ``` contract ERC1967 { bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; function _getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } function _setImplementation(address newImplementation) internal { require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\"); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } } ``` _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._",
"kind": "dev",
"methods": {},
"version": 1
},
"userdoc": {
"kind": "user",
"methods": {},
"version": 1
}
},
"settings": {
"compilationTarget": {
"lib/openzeppelin-contracts/contracts/utils/StorageSlot.sol": "StorageSlot"
},
"evmVersion": "prague",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
},
"sources": {
"lib/openzeppelin-contracts/contracts/utils/StorageSlot.sol": {
"keccak256": "0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d",
"license": "MIT",
"urls": [
"bzz-raw://39e096c60a6eb1c6a257122d515496bd92d0c6a693a8f07acb6aa4b1263e95d4",
"dweb:/ipfs/QmPs5trJBacCiSkezP6tpevapuRYWNY6mqSFzsMCJj7e6B"
]
}
},
"version": 1
}
{
"language": "Solidity",
"settings": {
"remappings": [
"ds-test/=lib/forge-std/lib/ds-test/src/",
"forge-std/=lib/forge-std/src/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"openzeppelin-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"openzeppelin/=lib/openzeppelin-contracts/contracts/",
"solmate/=lib/solmate/src/"
],
"optimizer": {
"enabled": true,
"runs": 100000
},
"metadata": {
"bytecodeHash": "ipfs"
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "london",
"libraries": {}
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822Proxiable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.0;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeacon {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {BeaconProxy} will check that this address is a contract.
*/
function implementation() external view returns (address);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)
pragma solidity ^0.8.0;
import "../Proxy.sol";
import "./ERC1967Upgrade.sol";
/**
* @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
* implementation address that can be changed. This address is stored in storage in the location specified by
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
* implementation behind the proxy.
*/
contract ERC1967Proxy is Proxy, ERC1967Upgrade {
/**
* @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.
*
* If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded
* function call, and allows initializing the storage of the proxy like a Solidity constructor.
*/
constructor(address _logic, bytes memory _data) payable {
_upgradeToAndCall(_logic, _data, false);
}
/**
* @dev Returns the current implementation address.
*/
function _implementation() internal view virtual override returns (address impl) {
return ERC1967Upgrade._getImplementation();
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)
pragma solidity ^0.8.2;
import "../beacon/IBeacon.sol";
import "../../interfaces/draft-IERC1822.sol";
import "../../utils/Address.sol";
import "../../utils/StorageSlot.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
*
* _Available since v4.1._
*
* @custom:oz-upgrades-unsafe-allow delegatecall
*/
abstract contract ERC1967Upgrade {
// This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Returns the current implementation address.
*/
function _getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Perform implementation upgrade
*
* Emits an {Upgraded} event.
*/
function _upgradeTo(address newImplementation) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
}
/**
* @dev Perform implementation upgrade with additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCall(
address newImplementation,
bytes memory data,
bool forceCall
) internal {
_upgradeTo(newImplementation);
if (data.length > 0 || forceCall) {
Address.functionDelegateCall(newImplementation, data);
}
}
/**
* @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCallUUPS(
address newImplementation,
bytes memory data,
bool forceCall
) internal {
// Upgrades from old implementations will perform a rollback test. This test requires the new
// implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
// this special case will break upgrade paths from old UUPS implementation to new ones.
if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {
_setImplementation(newImplementation);
} else {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
} catch {
revert("ERC1967Upgrade: new implementation is not UUPS");
}
_upgradeToAndCall(newImplementation, data, forceCall);
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Returns the current admin.
*/
function _getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
require(newAdmin != address(0), "ERC1967: new admin is the zero address");
StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {AdminChanged} event.
*/
function _changeAdmin(address newAdmin) internal {
emit AdminChanged(_getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
*/
bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Emitted when the beacon is upgraded.
*/
event BeaconUpgraded(address indexed beacon);
/**
* @dev Returns the current beacon.
*/
function _getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the EIP1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract");
require(
Address.isContract(IBeacon(newBeacon).implementation()),
"ERC1967: beacon implementation is not a contract"
);
StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
}
/**
* @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
* not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
*
* Emits a {BeaconUpgraded} event.
*/
function _upgradeBeaconToAndCall(
address newBeacon,
bytes memory data,
bool forceCall
) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0 || forceCall) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
}
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)
pragma solidity ^0.8.0;
/**
* @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
* instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
* be specified by overriding the virtual {_implementation} function.
*
* Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
* different contract through the {_delegate} function.
*
* The success and return data of the delegated call will be returned back to the caller of the proxy.
*/
abstract contract Proxy {
/**
* @dev Delegates the current call to `implementation`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _delegate(address implementation) internal virtual {
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0, 0, calldatasize())
// Call the implementation.
// out and outsize are 0 because we don't know the size yet.
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
// Copy the returned data.
returndatacopy(0, 0, returndatasize())
switch result
// delegatecall returns 0 on error.
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
/**
* @dev This is a virtual function that should be overridden so it returns the address to which the fallback function
* and {_fallback} should delegate.
*/
function _implementation() internal view virtual returns (address);
/**
* @dev Delegates the current call to the address returned by `_implementation()`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _fallback() internal virtual {
_beforeFallback();
_delegate(_implementation());
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
* function in the contract matches the call data.
*/
fallback() external payable virtual {
_fallback();
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
* is empty.
*/
receive() external payable virtual {
_fallback();
}
/**
* @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
* call, or as part of the Solidity `fallback` or `receive` functions.
*
* If overridden should call `super._beforeFallback()`.
*/
function _beforeFallback() internal virtual {}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)
pragma solidity ^0.8.0;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
}
{
"solidity-compiler": {
"language": "Solidity",
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"": [
"ast"
],
"*": [
"abi",
"metadata",
"devdoc",
"userdoc",
"storageLayout",
"evm.legacyAssembly",
"evm.bytecode",
"evm.deployedBytecode",
"evm.methodIdentifiers",
"evm.gasEstimates",
"evm.assembly"
]
}
}
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {ERC1967Proxy} from "openzeppelin/proxy/ERC1967/ERC1967Proxy.sol";
/**
* @notice ShortDurationYieldCoin is ERC1967Proxy
* @dev explicitly declare a contract here to increase readability
*/
contract ShortDurationYieldCoinProxy is ERC1967Proxy {
constructor(address _logic, bytes memory _data) payable ERC1967Proxy(_logic, _data) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment