feat(entropy-v2): add provider parameter to entropy callback (#1389)
* add provider parameter to entropy callback * order * abis regen * update version
This commit is contained in:
parent
26c3d08f33
commit
d821e01109
|
@ -407,6 +407,7 @@ abstract contract Entropy is IEntropy, EntropyState {
|
|||
|
||||
IEntropyConsumer(callAddress)._entropyCallback(
|
||||
sequenceNumber,
|
||||
provider,
|
||||
randomNumber
|
||||
);
|
||||
}
|
||||
|
|
|
@ -105,6 +105,6 @@ contract EntropyUpgradable is
|
|||
}
|
||||
|
||||
function version() public pure returns (string memory) {
|
||||
return "0.2.0";
|
||||
return "0.3.0";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -834,6 +834,7 @@ contract EntropyTest is Test, EntropyTestUtils, EntropyEvents {
|
|||
);
|
||||
|
||||
assertEq(consumer.sequence(), assignedSequenceNumber);
|
||||
assertEq(consumer.provider(), provider1);
|
||||
assertEq(
|
||||
consumer.randomness(),
|
||||
random.combineRandomValues(
|
||||
|
@ -893,6 +894,7 @@ contract EntropyConsumer is IEntropyConsumer {
|
|||
uint64 public sequence;
|
||||
bytes32 public randomness;
|
||||
address public entropy;
|
||||
address public provider;
|
||||
|
||||
constructor(address _entropy) {
|
||||
entropy = _entropy;
|
||||
|
@ -913,9 +915,11 @@ contract EntropyConsumer is IEntropyConsumer {
|
|||
|
||||
function entropyCallback(
|
||||
uint64 _sequence,
|
||||
address _provider,
|
||||
bytes32 _randomness
|
||||
) internal override {
|
||||
sequence = _sequence;
|
||||
provider = _provider;
|
||||
randomness = _randomness;
|
||||
}
|
||||
}
|
||||
|
@ -935,6 +939,7 @@ contract EntropyConsumerFails is IEntropyConsumer {
|
|||
|
||||
function entropyCallback(
|
||||
uint64 _sequence,
|
||||
address _provider,
|
||||
bytes32 _randomness
|
||||
) internal override {
|
||||
revert("Callback failed");
|
||||
|
|
|
@ -5,12 +5,16 @@ abstract contract IEntropyConsumer {
|
|||
// This method is called by Entropy to provide the random number to the consumer.
|
||||
// It asserts that the msg.sender is the Entropy contract. It is not meant to be
|
||||
// override by the consumer.
|
||||
function _entropyCallback(uint64 sequence, bytes32 randomNumber) external {
|
||||
function _entropyCallback(
|
||||
uint64 sequence,
|
||||
address provider,
|
||||
bytes32 randomNumber
|
||||
) external {
|
||||
address entropy = getEntropy();
|
||||
require(entropy != address(0), "Entropy address not set");
|
||||
require(msg.sender == entropy, "Only Entropy can call this function");
|
||||
|
||||
entropyCallback(sequence, randomNumber);
|
||||
entropyCallback(sequence, provider, randomNumber);
|
||||
}
|
||||
|
||||
// getEntropy returns Entropy contract address. The method is being used to check that the
|
||||
|
@ -23,6 +27,7 @@ abstract contract IEntropyConsumer {
|
|||
// indeed from Entropy contract.
|
||||
function entropyCallback(
|
||||
uint64 sequence,
|
||||
address provider,
|
||||
bytes32 randomNumber
|
||||
) internal virtual;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
"name": "sequence",
|
||||
"type": "uint64"
|
||||
},
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "provider",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "bytes32",
|
||||
"name": "randomNumber",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@pythnetwork/entropy-sdk-solidity",
|
||||
"version": "1.2.0",
|
||||
"version": "1.3.0",
|
||||
"description": "Generate secure random numbers with Pyth Entropy",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
Loading…
Reference in New Issue