编译器
0.8.20+commit.a1b79de6
文件 1 的 4:ILPNClient.sol
pragma solidity ^0.8.0;
import {ILPNRegistry} from "./ILPNRegistry.sol";
interface ILPNClient {
function lpnCallback(uint256 requestId, uint256[] calldata results)
external;
}
文件 2 的 4:ILPNRegistry.sol
pragma solidity ^0.8.0;
interface ILPNRegistry {
event NewRegistration(
address indexed storageContract,
address indexed client,
uint256 mappingSlot,
uint256 lengthSlot
);
event NewRequest(
uint256 indexed requestId,
address indexed storageContract,
address indexed client,
bytes32 key,
uint256 startBlock,
uint256 endBlock,
uint256 offset,
uint256 gasFee,
uint256 proofBlock
);
event NewResponse(
uint256 indexed requestId, address indexed client, uint256[] results
);
function gasFee() external returns (uint256);
function register(
address storageContract,
uint256 mappingSlot,
uint256 lengthSlot
) external;
function request(
address storageContract,
bytes32 key,
uint256 startBlock,
uint256 endBlock,
uint256 offset
) external payable returns (uint256);
function respond(
uint256 requestId_,
bytes32[] calldata data,
uint256 blockNumber
) external;
}
文件 3 的 4:LPNClientV0.sol
pragma solidity ^0.8.0;
import {ILPNRegistry} from "../interfaces/ILPNRegistry.sol";
import {ILPNClient} from "../interfaces/ILPNClient.sol";
error CallbackNotAuthorized();
abstract contract LPNClientV0 is ILPNClient {
ILPNRegistry public lpnRegistry;
modifier onlyLagrangeRegistry() {
if (msg.sender != address(lpnRegistry)) {
revert CallbackNotAuthorized();
}
_;
}
constructor(ILPNRegistry _lpnRegistry) {
lpnRegistry = _lpnRegistry;
}
function lpnCallback(uint256 requestId, uint256[] calldata results)
external
onlyLagrangeRegistry
{
processCallback(requestId, results);
}
function processCallback(uint256 requestId, uint256[] calldata results)
internal
virtual;
}
文件 4 的 4:LPNQueryV0.sol
pragma solidity ^0.8.13;
import {LPNClientV0} from "./LPNClientV0.sol";
import {ILPNRegistry} from "../interfaces/ILPNRegistry.sol";
contract LPNQueryV0 is LPNClientV0 {
struct RequestMetadata {
address sender;
address holder;
}
mapping(uint256 requestId => RequestMetadata request) public requests;
event Query(address indexed sender, address indexed storageContract);
event Result(
uint256 indexed requestId,
address indexed sender,
address indexed holder,
uint256[] results
);
constructor(ILPNRegistry lpnRegistry) LPNClientV0(lpnRegistry) {}
function query(
address storageContract,
address holder,
uint256 startBlock,
uint256 endBlock,
uint8 offset
) external payable {
uint256 requestId = lpnRegistry.request{value: msg.value}(
storageContract,
bytes32(uint256(uint160(holder))),
startBlock,
endBlock,
offset
);
requests[requestId] =
RequestMetadata({sender: msg.sender, holder: holder});
emit Query(msg.sender, storageContract);
}
function processCallback(uint256 requestId, uint256[] calldata results)
internal
override
{
RequestMetadata memory req = requests[requestId];
emit Result(requestId, req.sender, req.holder, results);
delete requests[requestId];
}
}
{
"compilationTarget": {
"src/client/LPNQueryV0.sol": "LPNQueryV0"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [
":@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
":@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
":ds-test/=lib/forge-std/lib/ds-test/src/",
":erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
":forge-std/=lib/forge-std/src/",
":openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/",
":solady/=lib/solady/src/"
]
}
[{"inputs":[{"internalType":"contract ILPNRegistry","name":"lpnRegistry","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"CallbackNotAuthorized","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"storageContract","type":"address"}],"name":"Query","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"holder","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"results","type":"uint256[]"}],"name":"Result","type":"event"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256[]","name":"results","type":"uint256[]"}],"name":"lpnCallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lpnRegistry","outputs":[{"internalType":"contract ILPNRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"storageContract","type":"address"},{"internalType":"address","name":"holder","type":"address"},{"internalType":"uint256","name":"startBlock","type":"uint256"},{"internalType":"uint256","name":"endBlock","type":"uint256"},{"internalType":"uint8","name":"offset","type":"uint8"}],"name":"query","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"}],"name":"requests","outputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"holder","type":"address"}],"stateMutability":"view","type":"function"}]