dodoMysteryBox finish

This commit is contained in:
owen05
2021-04-13 11:12:13 +08:00
parent 97b3f4604d
commit 5127e850e3
6 changed files with 166 additions and 37 deletions

View File

@@ -8,7 +8,7 @@
pragma solidity 0.6.9;
interface IRandomGenerator {
function random() external view returns (uint256);
function random(uint256 seed) external view returns (uint256);
}
interface IDODOMidPrice {
@@ -16,7 +16,7 @@ interface IDODOMidPrice {
}
contract RandomGenerator {
address[] internal pools;
address[] public pools;
constructor(address[] memory _pools) public {
for (uint256 i = 0; i < pools.length; i++) {
@@ -24,11 +24,11 @@ contract RandomGenerator {
}
}
function random() external view returns (uint256) {
function random(uint256 seed) external view returns (uint256) {
uint256 priceSum;
for (uint256 i = 0; i < pools.length; i++) {
priceSum += IDODOMidPrice(pools[i]).getMidPrice();
}
return uint256(keccak256(abi.encodePacked(blockhash(block.number-1), priceSum)));
return uint256(keccak256(abi.encodePacked(blockhash(block.number-1), priceSum, seed)));
}
}