Skip to content

Commit d821e01

Browse files
author
Dev Kalra
authored
feat(entropy-v2): add provider parameter to entropy callback (#1389)
* add provider parameter to entropy callback * order * abis regen * update version
1 parent 26c3d08 commit d821e01

File tree

6 files changed

+20
-4
lines changed

6 files changed

+20
-4
lines changed

target_chains/ethereum/contracts/contracts/entropy/Entropy.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ abstract contract Entropy is IEntropy, EntropyState {
407407

408408
IEntropyConsumer(callAddress)._entropyCallback(
409409
sequenceNumber,
410+
provider,
410411
randomNumber
411412
);
412413
}

target_chains/ethereum/contracts/contracts/entropy/EntropyUpgradable.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,6 @@ contract EntropyUpgradable is
105105
}
106106

107107
function version() public pure returns (string memory) {
108-
return "0.2.0";
108+
return "0.3.0";
109109
}
110110
}

target_chains/ethereum/contracts/forge-test/Entropy.t.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,7 @@ contract EntropyTest is Test, EntropyTestUtils, EntropyEvents {
834834
);
835835

836836
assertEq(consumer.sequence(), assignedSequenceNumber);
837+
assertEq(consumer.provider(), provider1);
837838
assertEq(
838839
consumer.randomness(),
839840
random.combineRandomValues(
@@ -893,6 +894,7 @@ contract EntropyConsumer is IEntropyConsumer {
893894
uint64 public sequence;
894895
bytes32 public randomness;
895896
address public entropy;
897+
address public provider;
896898

897899
constructor(address _entropy) {
898900
entropy = _entropy;
@@ -913,9 +915,11 @@ contract EntropyConsumer is IEntropyConsumer {
913915

914916
function entropyCallback(
915917
uint64 _sequence,
918+
address _provider,
916919
bytes32 _randomness
917920
) internal override {
918921
sequence = _sequence;
922+
provider = _provider;
919923
randomness = _randomness;
920924
}
921925
}
@@ -935,6 +939,7 @@ contract EntropyConsumerFails is IEntropyConsumer {
935939

936940
function entropyCallback(
937941
uint64 _sequence,
942+
address _provider,
938943
bytes32 _randomness
939944
) internal override {
940945
revert("Callback failed");

target_chains/ethereum/entropy_sdk/solidity/IEntropyConsumer.sol

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ abstract contract IEntropyConsumer {
55
// This method is called by Entropy to provide the random number to the consumer.
66
// It asserts that the msg.sender is the Entropy contract. It is not meant to be
77
// override by the consumer.
8-
function _entropyCallback(uint64 sequence, bytes32 randomNumber) external {
8+
function _entropyCallback(
9+
uint64 sequence,
10+
address provider,
11+
bytes32 randomNumber
12+
) external {
913
address entropy = getEntropy();
1014
require(entropy != address(0), "Entropy address not set");
1115
require(msg.sender == entropy, "Only Entropy can call this function");
1216

13-
entropyCallback(sequence, randomNumber);
17+
entropyCallback(sequence, provider, randomNumber);
1418
}
1519

1620
// getEntropy returns Entropy contract address. The method is being used to check that the
@@ -23,6 +27,7 @@ abstract contract IEntropyConsumer {
2327
// indeed from Entropy contract.
2428
function entropyCallback(
2529
uint64 sequence,
30+
address provider,
2631
bytes32 randomNumber
2732
) internal virtual;
2833
}

target_chains/ethereum/entropy_sdk/solidity/abis/IEntropyConsumer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
"name": "sequence",
77
"type": "uint64"
88
},
9+
{
10+
"internalType": "address",
11+
"name": "provider",
12+
"type": "address"
13+
},
914
{
1015
"internalType": "bytes32",
1116
"name": "randomNumber",

target_chains/ethereum/entropy_sdk/solidity/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pythnetwork/entropy-sdk-solidity",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"description": "Generate secure random numbers with Pyth Entropy",
55
"repository": {
66
"type": "git",

0 commit comments

Comments
 (0)