This commit is contained in:
CounterFire2023 2024-11-26 10:55:42 +08:00
parent c1e8c549e2
commit 67a25b6850
10 changed files with 435 additions and 1172 deletions

View File

@ -0,0 +1,39 @@
// SPDX-License-Identifier: Apache 2.0
pragma solidity 0.8.19;
contract TestSlot {
// 0
uint public count = 123;
// 1.1
address public owner = msg.sender;
// 1.2
bool public isTrue = true;
// 1.3
uint16 public u16 = 31;
// 2
bytes32 private password;
uint public constant someConst = 123;
// 3, 4, 5
bytes32[3] public data;
struct User {
uint id;
bytes32 password;
}
// 6: length of users
User[] private users;
// 7: empty,
mapping(uint => User) private idToUser;
constructor(bytes32 _password) {
password = _password;
}
function addUser(bytes32 _password) public {
User memory user = User({id: users.length, password: _password});
users.push(user);
idToUser[user.id] = user;
}
function getArrayLocation(uint slot, uint index, uint elementSize) public pure returns (uint) {
return uint(keccak256(abi.encodePacked(slot))) + (index * elementSize);
}
function getMapLocation(uint slot, uint key) public pure returns (uint) {
return uint(keccak256(abi.encodePacked(key, slot)));
}
}

20
deploy/0_deploy_test.ts Normal file
View File

@ -0,0 +1,20 @@
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import { updateArray } from "../scripts/utils"
const deployNFTForGame: DeployFunction =
async function (hre: HardhatRuntimeEnvironment) {
const provider = hre.ethers.provider;
const from = await (await provider.getSigner()).getAddress();
const ret = await hre.deployments.deploy("TestSlot", {
from,
args: ['0xd948549711a1f1198851e8eb8b4857a6159c6388bbab253fbc5b0160b0f9cd5d'],
log: true,
});
console.log("==TestSlot addr=", ret.address);
};
deployNFTForGame.tags = ["TestSlot"];
export default deployNFTForGame;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,337 @@
{
"address": "0xEc2D43E9E7F54E279B08d2d76BDfAE61400651C7",
"abi": [
{
"inputs": [
{
"internalType": "bytes32",
"name": "_password",
"type": "bytes32"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "_password",
"type": "bytes32"
}
],
"name": "addUser",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "count",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "data",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "slot",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "index",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "elementSize",
"type": "uint256"
}
],
"name": "getArrayLocation",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "slot",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "key",
"type": "uint256"
}
],
"name": "getMapLocation",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [],
"name": "isTrue",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "someConst",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "u16",
"outputs": [
{
"internalType": "uint16",
"name": "",
"type": "uint16"
}
],
"stateMutability": "view",
"type": "function"
}
],
"transactionHash": "0x9d1defa3d5e3228bb2c062420e24b2a288409bf28ec6dd625c4ae576113c9f09",
"receipt": {
"to": null,
"from": "0x50A8e60041A206AcaA5F844a1104896224be6F39",
"contractAddress": "0xEc2D43E9E7F54E279B08d2d76BDfAE61400651C7",
"transactionIndex": 0,
"gasUsed": "321301",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"blockHash": "0x507c7a3a4444697cd5b094c3e7f7aa7bd1f2da5ae235cde3ec6eeef900268497",
"transactionHash": "0x9d1defa3d5e3228bb2c062420e24b2a288409bf28ec6dd625c4ae576113c9f09",
"logs": [],
"blockNumber": 44580826,
"cumulativeGasUsed": "321301",
"status": 1,
"byzantium": true
},
"args": [
"0xd948549711a1f1198851e8eb8b4857a6159c6388bbab253fbc5b0160b0f9cd5d"
],
"numDeployments": 1,
"solcInputHash": "0f8deec237bf5f05ad838036ecf818f6",
"metadata": "{\"compiler\":{\"version\":\"0.8.19+commit.7dd6d404\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"_password\",\"type\":\"bytes32\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"_password\",\"type\":\"bytes32\"}],\"name\":\"addUser\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"count\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"data\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"slot\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"elementSize\",\"type\":\"uint256\"}],\"name\":\"getArrayLocation\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"slot\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"key\",\"type\":\"uint256\"}],\"name\":\"getMapLocation\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isTrue\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"someConst\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"u16\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/test/TestSlot.sol\":\"TestSlot\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[],\"viaIR\":true},\"sources\":{\"contracts/test/TestSlot.sol\":{\"content\":\"// SPDX-License-Identifier: Apache 2.0\\npragma solidity 0.8.19;\\ncontract TestSlot {\\n uint public count = 123;\\n address public owner = msg.sender;\\n bool public isTrue = true;\\n uint16 public u16 = 31;\\n bytes32 private password;\\n uint public constant someConst = 123;\\n bytes32[3] public data;\\n struct User {\\n uint id;\\n bytes32 password;\\n }\\n User[] private users;\\n mapping(uint => User) private idToUser;\\n constructor(bytes32 _password) {\\n password = _password;\\n }\\n function addUser(bytes32 _password) public {\\n User memory user = User({id: users.length, password: _password});\\n users.push(user);\\n idToUser[user.id] = user;\\n }\\n function getArrayLocation(uint slot, uint index, uint elementSize) public pure returns (uint) {\\n return uint(keccak256(abi.encodePacked(slot))) + (index * elementSize);\\n }\\n function getMapLocation(uint slot, uint key) public pure returns (uint) {\\n return uint(keccak256(abi.encodePacked(key, slot)));\\n }\\n}\\n\",\"keccak256\":\"0x7125359c59989b80246568b655b9577da8dae4704882855a6874010ba9829073\",\"license\":\"Apache 2.0\"}},\"version\":1}",
"bytecode": "0x60803461008357601f61043738819003918201601f19168301916001600160401b03831184841017610088578084926020946040528339810103126100835751607b600055600180546001600160a81b0319163360ff60a01b191617600160a01b1761ffff60a81b1916601f60a81b179055600255604051610398908161009f8239f35b600080fd5b634e487b7160e01b600052604160045260246000fdfe6080604081815260048036101561001557600080fd5b600092833560e01c90816274530a1461033e5750806306661abd146103215780630a6b4e06146102fb57806359d168b6146102df578063881374d71461027d5780638da5cb5b146102545780638faf850d14610157578063992ddc6f146100b35763f0ba84401461008557600080fd5b346100af5760203660031901126100af573560038110156100af5760209250600301549051908152f35b8280fd5b50913461015457606036600319011261015457602435906044358351602081019086358252602081528581019581871067ffffffffffffffff881117610141578690525190209281810291818304149015171561012e57820180921161011b57602083838152f35b634e487b7160e01b815260118452602490fd5b634e487b7160e01b825260118552602482fd5b634e487b7160e01b855260418852602485fd5b80fd5b50919034610250576020366003190112610250576006549080519181830183811067ffffffffffffffff82111761023d578252808352843560208401526801000000000000000081101561022a57600181018060065581101561021757906101f88361021494936006875260011b7ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f01906020600191805184550151910155565b8151845260076020528320906020600191805184550151910155565b80f35b634e487b7160e01b845260328552602484fd5b634e487b7160e01b845260418552602484fd5b634e487b7160e01b855260418652602485fd5b5080fd5b50503461025057816003193601126102505760015490516001600160a01b039091168152602090f35b50919034610250578060031936011261025057805160208101916024358352843581830152808252606082019382851067ffffffffffffffff8611176102cc5750602094508390525190208152f35b634e487b7160e01b815260418652602490fd5b50503461025057816003193601126102505760209051607b8152f35b50503461025057816003193601126102505760209061ffff60015460a81c169051908152f35b505034610250578160031936011261025057602091549051908152f35b84903461025057816003193601126102505760209060ff60015460a01c1615158152f3fea2646970667358221220e73d55bd9adeeb30fe2d7ef10777b0cb3d9c6b85ee29dd94bbcfd58ad70abd4864736f6c63430008130033",
"deployedBytecode": "0x6080604081815260048036101561001557600080fd5b600092833560e01c90816274530a1461033e5750806306661abd146103215780630a6b4e06146102fb57806359d168b6146102df578063881374d71461027d5780638da5cb5b146102545780638faf850d14610157578063992ddc6f146100b35763f0ba84401461008557600080fd5b346100af5760203660031901126100af573560038110156100af5760209250600301549051908152f35b8280fd5b50913461015457606036600319011261015457602435906044358351602081019086358252602081528581019581871067ffffffffffffffff881117610141578690525190209281810291818304149015171561012e57820180921161011b57602083838152f35b634e487b7160e01b815260118452602490fd5b634e487b7160e01b825260118552602482fd5b634e487b7160e01b855260418852602485fd5b80fd5b50919034610250576020366003190112610250576006549080519181830183811067ffffffffffffffff82111761023d578252808352843560208401526801000000000000000081101561022a57600181018060065581101561021757906101f88361021494936006875260011b7ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f01906020600191805184550151910155565b8151845260076020528320906020600191805184550151910155565b80f35b634e487b7160e01b845260328552602484fd5b634e487b7160e01b845260418552602484fd5b634e487b7160e01b855260418652602485fd5b5080fd5b50503461025057816003193601126102505760015490516001600160a01b039091168152602090f35b50919034610250578060031936011261025057805160208101916024358352843581830152808252606082019382851067ffffffffffffffff8611176102cc5750602094508390525190208152f35b634e487b7160e01b815260418652602490fd5b50503461025057816003193601126102505760209051607b8152f35b50503461025057816003193601126102505760209061ffff60015460a81c169051908152f35b505034610250578160031936011261025057602091549051908152f35b84903461025057816003193601126102505760209060ff60015460a01c1615158152f3fea2646970667358221220e73d55bd9adeeb30fe2d7ef10777b0cb3d9c6b85ee29dd94bbcfd58ad70abd4864736f6c63430008130033",
"devdoc": {
"kind": "dev",
"methods": {},
"version": 1
},
"userdoc": {
"kind": "user",
"methods": {},
"version": 1
},
"storageLayout": {
"storage": [
{
"astId": 4,
"contract": "contracts/test/TestSlot.sol:TestSlot",
"label": "count",
"offset": 0,
"slot": "0",
"type": "t_uint256"
},
{
"astId": 8,
"contract": "contracts/test/TestSlot.sol:TestSlot",
"label": "owner",
"offset": 0,
"slot": "1",
"type": "t_address"
},
{
"astId": 11,
"contract": "contracts/test/TestSlot.sol:TestSlot",
"label": "isTrue",
"offset": 20,
"slot": "1",
"type": "t_bool"
},
{
"astId": 14,
"contract": "contracts/test/TestSlot.sol:TestSlot",
"label": "u16",
"offset": 21,
"slot": "1",
"type": "t_uint16"
},
{
"astId": 16,
"contract": "contracts/test/TestSlot.sol:TestSlot",
"label": "password",
"offset": 0,
"slot": "2",
"type": "t_bytes32"
},
{
"astId": 23,
"contract": "contracts/test/TestSlot.sol:TestSlot",
"label": "data",
"offset": 0,
"slot": "3",
"type": "t_array(t_bytes32)3_storage"
},
{
"astId": 32,
"contract": "contracts/test/TestSlot.sol:TestSlot",
"label": "users",
"offset": 0,
"slot": "6",
"type": "t_array(t_struct(User)28_storage)dyn_storage"
},
{
"astId": 37,
"contract": "contracts/test/TestSlot.sol:TestSlot",
"label": "idToUser",
"offset": 0,
"slot": "7",
"type": "t_mapping(t_uint256,t_struct(User)28_storage)"
}
],
"types": {
"t_address": {
"encoding": "inplace",
"label": "address",
"numberOfBytes": "20"
},
"t_array(t_bytes32)3_storage": {
"base": "t_bytes32",
"encoding": "inplace",
"label": "bytes32[3]",
"numberOfBytes": "96"
},
"t_array(t_struct(User)28_storage)dyn_storage": {
"base": "t_struct(User)28_storage",
"encoding": "dynamic_array",
"label": "struct TestSlot.User[]",
"numberOfBytes": "32"
},
"t_bool": {
"encoding": "inplace",
"label": "bool",
"numberOfBytes": "1"
},
"t_bytes32": {
"encoding": "inplace",
"label": "bytes32",
"numberOfBytes": "32"
},
"t_mapping(t_uint256,t_struct(User)28_storage)": {
"encoding": "mapping",
"key": "t_uint256",
"label": "mapping(uint256 => struct TestSlot.User)",
"numberOfBytes": "32",
"value": "t_struct(User)28_storage"
},
"t_struct(User)28_storage": {
"encoding": "inplace",
"label": "struct TestSlot.User",
"members": [
{
"astId": 25,
"contract": "contracts/test/TestSlot.sol:TestSlot",
"label": "id",
"offset": 0,
"slot": "0",
"type": "t_uint256"
},
{
"astId": 27,
"contract": "contracts/test/TestSlot.sol:TestSlot",
"label": "password",
"offset": 0,
"slot": "1",
"type": "t_bytes32"
}
],
"numberOfBytes": "64"
},
"t_uint16": {
"encoding": "inplace",
"label": "uint16",
"numberOfBytes": "2"
},
"t_uint256": {
"encoding": "inplace",
"label": "uint256",
"numberOfBytes": "32"
}
}
}
}

View File

@ -0,0 +1,36 @@
{
"language": "Solidity",
"sources": {
"contracts/test/TestSlot.sol": {
"content": "// SPDX-License-Identifier: Apache 2.0\npragma solidity 0.8.19;\ncontract TestSlot {\n uint public count = 123;\n address public owner = msg.sender;\n bool public isTrue = true;\n uint16 public u16 = 31;\n bytes32 private password;\n uint public constant someConst = 123;\n bytes32[3] public data;\n struct User {\n uint id;\n bytes32 password;\n }\n User[] private users;\n mapping(uint => User) private idToUser;\n constructor(bytes32 _password) {\n password = _password;\n }\n function addUser(bytes32 _password) public {\n User memory user = User({id: users.length, password: _password});\n users.push(user);\n idToUser[user.id] = user;\n }\n function getArrayLocation(uint slot, uint index, uint elementSize) public pure returns (uint) {\n return uint(keccak256(abi.encodePacked(slot))) + (index * elementSize);\n }\n function getMapLocation(uint slot, uint key) public pure returns (uint) {\n return uint(keccak256(abi.encodePacked(key, slot)));\n }\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"viaIR": true,
"outputSelection": {
"*": {
"*": [
"abi",
"evm.bytecode",
"evm.deployedBytecode",
"evm.methodIdentifiers",
"metadata",
"devdoc",
"userdoc",
"storageLayout",
"evm.gasEstimates"
],
"": [
"ast"
]
}
},
"metadata": {
"useLiteralContent": true
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -26,7 +26,8 @@
"solhint": "solhint --config ./.solhint.json",
"show_verify_list": "npx hardhat verify --list-networks",
"convert-abi": "npx hardhat run scripts/convert-abi.js",
"verify_sample": "npx hardhat verify --network bsc_test --constructor-args ./verify/tokenclaim.js 0xee0044BF2ACEf7C3D7f6781d8f5DC4d2Dd1CE64c"
"verify_sample": "npx hardhat verify --network bsc_test --constructor-args ./verify/tokenclaim.js 0xee0044BF2ACEf7C3D7f6781d8f5DC4d2Dd1CE64c",
"callgraph": "slither contracts/staking/Vester.sol --print call-graph --solc-remaps @=node_modules/@"
},
"author": "",
"license": "ISC",

View File

@ -0,0 +1 @@
["constructor(address,address,address,uint256)","event DurationUpdated(uint256 indexed)","event EventERC20Wallet(address,address)","event EventTokenClaimed(address indexed,address indexed,address,uint256,uint256)","event EventVerifierUpdated(address indexed)","event OwnershipTransferred(address indexed,address indexed)","event Paused(address)","event Unpaused(address)","function _CACHED_CHAIN_ID() view returns (uint256)","function _CACHED_THIS() view returns (address)","function checkSigner(address,bytes32,bytes) pure","function claim(address,address,uint256[4],bytes)","function claimedBitMap(address,address) view returns (uint256)","function duration() view returns (uint256)","function erc20Wallets(address) view returns (address)","function getMessageHash(address,address,address,address,uint256,uint256[4]) pure returns (bytes32)","function minDuration() view returns (uint256)","function owner() view returns (address)","function pause()","function paused() view returns (bool)","function renounceOwnership()","function transferOwnership(address)","function unpause()","function updateDuation(uint256)","function updateERC20Wallet(address,address)","function updateVerifier(address)","function verifier() view returns (address)","function withdrawToken(address,address,uint256)"]