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(
|
IEntropyConsumer(callAddress)._entropyCallback(
|
||||||
sequenceNumber,
|
sequenceNumber,
|
||||||
|
provider,
|
||||||
randomNumber
|
randomNumber
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,6 +105,6 @@ contract EntropyUpgradable is
|
||||||
}
|
}
|
||||||
|
|
||||||
function version() public pure returns (string memory) {
|
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.sequence(), assignedSequenceNumber);
|
||||||
|
assertEq(consumer.provider(), provider1);
|
||||||
assertEq(
|
assertEq(
|
||||||
consumer.randomness(),
|
consumer.randomness(),
|
||||||
random.combineRandomValues(
|
random.combineRandomValues(
|
||||||
|
@ -893,6 +894,7 @@ contract EntropyConsumer is IEntropyConsumer {
|
||||||
uint64 public sequence;
|
uint64 public sequence;
|
||||||
bytes32 public randomness;
|
bytes32 public randomness;
|
||||||
address public entropy;
|
address public entropy;
|
||||||
|
address public provider;
|
||||||
|
|
||||||
constructor(address _entropy) {
|
constructor(address _entropy) {
|
||||||
entropy = _entropy;
|
entropy = _entropy;
|
||||||
|
@ -913,9 +915,11 @@ contract EntropyConsumer is IEntropyConsumer {
|
||||||
|
|
||||||
function entropyCallback(
|
function entropyCallback(
|
||||||
uint64 _sequence,
|
uint64 _sequence,
|
||||||
|
address _provider,
|
||||||
bytes32 _randomness
|
bytes32 _randomness
|
||||||
) internal override {
|
) internal override {
|
||||||
sequence = _sequence;
|
sequence = _sequence;
|
||||||
|
provider = _provider;
|
||||||
randomness = _randomness;
|
randomness = _randomness;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -935,6 +939,7 @@ contract EntropyConsumerFails is IEntropyConsumer {
|
||||||
|
|
||||||
function entropyCallback(
|
function entropyCallback(
|
||||||
uint64 _sequence,
|
uint64 _sequence,
|
||||||
|
address _provider,
|
||||||
bytes32 _randomness
|
bytes32 _randomness
|
||||||
) internal override {
|
) internal override {
|
||||||
revert("Callback failed");
|
revert("Callback failed");
|
||||||
|
|
|
@ -5,12 +5,16 @@ abstract contract IEntropyConsumer {
|
||||||
// This method is called by Entropy to provide the random number to the consumer.
|
// 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
|
// It asserts that the msg.sender is the Entropy contract. It is not meant to be
|
||||||
// override by the consumer.
|
// override by the consumer.
|
||||||
function _entropyCallback(uint64 sequence, bytes32 randomNumber) external {
|
function _entropyCallback(
|
||||||
|
uint64 sequence,
|
||||||
|
address provider,
|
||||||
|
bytes32 randomNumber
|
||||||
|
) external {
|
||||||
address entropy = getEntropy();
|
address entropy = getEntropy();
|
||||||
require(entropy != address(0), "Entropy address not set");
|
require(entropy != address(0), "Entropy address not set");
|
||||||
require(msg.sender == entropy, "Only Entropy can call this function");
|
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
|
// 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.
|
// indeed from Entropy contract.
|
||||||
function entropyCallback(
|
function entropyCallback(
|
||||||
uint64 sequence,
|
uint64 sequence,
|
||||||
|
address provider,
|
||||||
bytes32 randomNumber
|
bytes32 randomNumber
|
||||||
) internal virtual;
|
) internal virtual;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
"name": "sequence",
|
"name": "sequence",
|
||||||
"type": "uint64"
|
"type": "uint64"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "provider",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"internalType": "bytes32",
|
"internalType": "bytes32",
|
||||||
"name": "randomNumber",
|
"name": "randomNumber",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@pythnetwork/entropy-sdk-solidity",
|
"name": "@pythnetwork/entropy-sdk-solidity",
|
||||||
"version": "1.2.0",
|
"version": "1.3.0",
|
||||||
"description": "Generate secure random numbers with Pyth Entropy",
|
"description": "Generate secure random numbers with Pyth Entropy",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
Loading…
Reference in New Issue