-
Notifications
You must be signed in to change notification settings - Fork 249
feat(entropy): Split out V2 interface into separate file. #2645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
150 changes: 150 additions & 0 deletions
150
target_chains/ethereum/entropy_sdk/solidity/IEntropyV2.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
// SPDX-License-Identifier: Apache 2 | ||
pragma solidity ^0.8.0; | ||
|
||
import "./EntropyEvents.sol"; | ||
import "./EntropyEventsV2.sol"; | ||
import "./EntropyStructsV2.sol"; | ||
|
||
interface IEntropyV2 is EntropyEventsV2 { | ||
/// @notice Request a random number using the default provider with default gas limit | ||
/// @return assignedSequenceNumber A unique identifier for this request | ||
/// @dev The address calling this function should be a contract that inherits from the IEntropyConsumer interface. | ||
/// The `entropyCallback` method on that interface will receive a callback with the returned sequence number and | ||
/// the generated random number. | ||
/// | ||
/// `entropyCallback` will be run with the `gasLimit` provided to this function. | ||
/// The `gasLimit` will be rounded up to a multiple of 10k (e.g., 19000 -> 20000), and furthermore is lower bounded | ||
/// by the provider's configured default limit. | ||
/// | ||
/// This method will revert unless the caller provides a sufficient fee (at least `getFeeV2()`) as msg.value. | ||
/// Note that the fee can change over time. Callers of this method should explicitly compute `getFeeV2()` | ||
/// prior to each invocation (as opposed to hardcoding a value). Further note that excess value is *not* refunded to the caller. | ||
/// | ||
/// Note that this method uses an in-contract PRNG to generate the user's portion of the random number. | ||
/// Users must trust this PRNG in order to prove the result is random. If you wish to avoid this trust assumption, | ||
/// call a variant of `requestV2` that accepts a `userRandomNumber` parameter. | ||
function requestV2() | ||
external | ||
payable | ||
returns (uint64 assignedSequenceNumber); | ||
|
||
/// @notice Request a random number using the default provider with specified gas limit | ||
/// @param gasLimit The gas limit for the callback function. | ||
/// @return assignedSequenceNumber A unique identifier for this request | ||
/// @dev The address calling this function should be a contract that inherits from the IEntropyConsumer interface. | ||
/// The `entropyCallback` method on that interface will receive a callback with the returned sequence number and | ||
/// the generated random number. | ||
/// | ||
/// `entropyCallback` will be run with the `gasLimit` provided to this function. | ||
/// The `gasLimit` will be rounded up to a multiple of 10k (e.g., 19000 -> 20000), and furthermore is lower bounded | ||
/// by the provider's configured default limit. | ||
/// | ||
/// This method will revert unless the caller provides a sufficient fee (at least `getFeeV2(gasLimit)`) as msg.value. | ||
/// Note that the fee can change over time. Callers of this method should explicitly compute `getFeeV2(gasLimit)` | ||
/// prior to each invocation (as opposed to hardcoding a value). Further note that excess value is *not* refunded to the caller. | ||
/// | ||
/// Note that this method uses an in-contract PRNG to generate the user's portion of the random number. | ||
/// Users must trust this PRNG in order to prove the result is random. If you wish to avoid this trust assumption, | ||
/// call a variant of `requestV2` that accepts a `userRandomNumber` parameter. | ||
function requestV2( | ||
uint32 gasLimit | ||
) external payable returns (uint64 assignedSequenceNumber); | ||
|
||
/// @notice Request a random number from a specific provider with specified gas limit | ||
/// @param provider The address of the provider to request from | ||
/// @param gasLimit The gas limit for the callback function | ||
/// @return assignedSequenceNumber A unique identifier for this request | ||
/// @dev The address calling this function should be a contract that inherits from the IEntropyConsumer interface. | ||
/// The `entropyCallback` method on that interface will receive a callback with the returned sequence number and | ||
/// the generated random number. | ||
/// | ||
/// `entropyCallback` will be run with the `gasLimit` provided to this function. | ||
/// The `gasLimit` will be rounded up to a multiple of 10k (e.g., 19000 -> 20000), and furthermore is lower bounded | ||
/// by the provider's configured default limit. | ||
/// | ||
/// This method will revert unless the caller provides a sufficient fee (at least `getFeeV2(provider, gasLimit)`) as msg.value. | ||
/// Note that provider fees can change over time. Callers of this method should explicitly compute `getFeeV2(provider, gasLimit)` | ||
/// prior to each invocation (as opposed to hardcoding a value). Further note that excess value is *not* refunded to the caller. | ||
/// | ||
/// Note that this method uses an in-contract PRNG to generate the user's portion of the random number. | ||
/// Users must trust this PRNG in order to prove the result is random. If you wish to avoid this trust assumption, | ||
/// call a variant of `requestV2` that accepts a `userRandomNumber` parameter. | ||
function requestV2( | ||
address provider, | ||
uint32 gasLimit | ||
) external payable returns (uint64 assignedSequenceNumber); | ||
|
||
/// @notice Request a random number from a specific provider with a user-provided random number and gas limit | ||
/// @param provider The address of the provider to request from | ||
/// @param userRandomNumber A random number provided by the user for additional entropy | ||
/// @param gasLimit The gas limit for the callback function. Pass 0 to get a sane default value -- see note below. | ||
/// @return assignedSequenceNumber A unique identifier for this request | ||
/// @dev The address calling this function should be a contract that inherits from the IEntropyConsumer interface. | ||
/// The `entropyCallback` method on that interface will receive a callback with the returned sequence number and | ||
/// the generated random number. | ||
/// | ||
/// `entropyCallback` will be run with the `gasLimit` provided to this function. | ||
/// The `gasLimit` will be rounded up to a multiple of 10k (e.g., 19000 -> 20000), and furthermore is lower bounded | ||
/// by the provider's configured default limit. | ||
/// | ||
/// This method will revert unless the caller provides a sufficient fee (at least `getFeeV2(provider, gasLimit)`) as msg.value. | ||
/// Note that provider fees can change over time. Callers of this method should explicitly compute `getFeeV2(provider, gasLimit)` | ||
/// prior to each invocation (as opposed to hardcoding a value). Further note that excess value is *not* refunded to the caller. | ||
function requestV2( | ||
address provider, | ||
bytes32 userRandomNumber, | ||
uint32 gasLimit | ||
) external payable returns (uint64 assignedSequenceNumber); | ||
|
||
function getProviderInfoV2( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. method docs on this function and below are new |
||
address provider | ||
) external view returns (EntropyStructsV2.ProviderInfo memory info); | ||
|
||
/// @notice Get the address of the default entropy provider | ||
/// @return provider The address of the default provider | ||
/// @dev This method returns the address of the provider that will be used when no specific provider is specified | ||
/// in the requestV2 calls. The default provider can be used to get the base fee and gas limit information. | ||
function getDefaultProvider() external view returns (address provider); | ||
|
||
/// @notice Get information about a specific request | ||
/// @param provider The address of the provider that handled the request | ||
/// @param sequenceNumber The unique identifier of the request | ||
/// @return req The request information including status, random number, and other metadata | ||
/// @dev This method allows querying the state of a previously made request. The returned Request struct | ||
/// contains information about whether the request was fulfilled, the generated random number (if available), | ||
/// and other metadata about the request. | ||
function getRequestV2( | ||
address provider, | ||
uint64 sequenceNumber | ||
) external view returns (EntropyStructsV2.Request memory req); | ||
|
||
/// @notice Get the fee charged by the default provider for the default gas limit | ||
/// @return feeAmount The fee amount in wei | ||
/// @dev This method returns the base fee required to make a request using the default provider with | ||
/// the default gas limit. This fee should be passed as msg.value when calling requestV2(). | ||
/// The fee can change over time, so this method should be called before each request. | ||
function getFeeV2() external view returns (uint128 feeAmount); | ||
|
||
/// @notice Get the fee charged by the default provider for a specific gas limit | ||
/// @param gasLimit The gas limit for the callback function | ||
/// @return feeAmount The fee amount in wei | ||
/// @dev This method returns the fee required to make a request using the default provider with | ||
/// the specified gas limit. This fee should be passed as msg.value when calling requestV2(gasLimit). | ||
/// The fee can change over time, so this method should be called before each request. | ||
function getFeeV2( | ||
uint32 gasLimit | ||
) external view returns (uint128 feeAmount); | ||
|
||
/// @notice Get the fee charged by a specific provider for a request with a given gas limit | ||
/// @param provider The address of the provider to query | ||
/// @param gasLimit The gas limit for the callback function | ||
/// @return feeAmount The fee amount in wei | ||
/// @dev This method returns the fee required to make a request using the specified provider with | ||
/// the given gas limit. This fee should be passed as msg.value when calling requestV2(provider, gasLimit) | ||
/// or requestV2(provider, userRandomNumber, gasLimit). The fee can change over time, so this method | ||
/// should be called before each request. | ||
function getFeeV2( | ||
address provider, | ||
uint32 gasLimit | ||
) external view returns (uint128 feeAmount); | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note that I moved this function over to IEntropyV2 as well since end users may want to call it