-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement migrate method in coordinator v2 plus (#9807)
* implement migrate method in coordinator v2 plus * add extra args field to requestRandomWords() * add missing client file * prettier * prettier * add forge tests for migrations * address comments * add missing file * remove s_requestPayment() * fix failing tests * run prettier
- Loading branch information
1 parent
d1a423e
commit 7eca961
Showing
30 changed files
with
2,610 additions
and
271 deletions.
There are no files selected for viewing
This file contains 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
15 changes: 15 additions & 0 deletions
15
contracts/src/v0.8/dev/interfaces/IVRFCoordinatorV2PlusMigration.sol
This file contains 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,15 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.4; | ||
|
||
// Future versions of VRFCoordinatorV2Plus must implement IVRFCoordinatorV2PlusMigration | ||
// to support migrations from previous versions | ||
interface IVRFCoordinatorV2PlusMigration { | ||
/** | ||
* @notice called by older versions of coordinator for migration. | ||
* @notice only callable by older versions of coordinator | ||
* @notice supports transfer of native currency | ||
* @param encodedData - user data from older version of coordinator | ||
* @return subId | ||
*/ | ||
function onMigration(bytes calldata encodedData) external payable returns (uint64 subId); | ||
} |
This file contains 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
35 changes: 35 additions & 0 deletions
35
contracts/src/v0.8/dev/interfaces/IVRFMigratableCoordinatorV2Plus.sol
This file contains 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,35 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.4; | ||
|
||
import "../vrf/libraries/VRFV2PlusClient.sol"; | ||
|
||
// Interface that enables consumers of VRFCoordinatorV2Plus to be future-proof for upgrades | ||
// This interface is supported by subsequent versions of VRFCoordinatorV2Plus | ||
interface IVRFMigratableCoordinatorV2Plus { | ||
/** | ||
* @notice Request a set of random words. | ||
* @param req - a struct containing following fiels for randomness request: | ||
* keyHash - Corresponds to a particular oracle job which uses | ||
* that key for generating the VRF proof. Different keyHash's have different gas price | ||
* ceilings, so you can select a specific one to bound your maximum per request cost. | ||
* subId - The ID of the VRF subscription. Must be funded | ||
* with the minimum subscription balance required for the selected keyHash. | ||
* minimumRequestConfirmations - How many blocks you'd like the | ||
* oracle to wait before responding to the request. See SECURITY CONSIDERATIONS | ||
* for why you may want to request more. The acceptable range is | ||
* [minimumRequestBlockConfirmations, 200]. | ||
* callbackGasLimit - How much gas you'd like to receive in your | ||
* fulfillRandomWords callback. Note that gasleft() inside fulfillRandomWords | ||
* may be slightly less than this amount because of gas used calling the function | ||
* (argument decoding etc.), so you may need to request slightly more than you expect | ||
* to have inside fulfillRandomWords. The acceptable range is | ||
* [0, maxGasLimit] | ||
* numWords - The number of uint256 random values you'd like to receive | ||
* in your fulfillRandomWords callback. Note these numbers are expanded in a | ||
* secure way by the VRFCoordinator from a single random value supplied by the oracle. | ||
* nativePayment - Whether payment should be made in ETH or LINK. | ||
* @return requestId - A unique identifier of the request. Can be used to match | ||
* a request to a response in fulfillRandomWords. | ||
*/ | ||
function requestRandomWords(VRFV2PlusClient.RandomWordsRequest calldata req) external returns (uint256 requestId); | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.