-
Notifications
You must be signed in to change notification settings - Fork 552
Pack: using Chainlink VRF v2 (Direct Funding Method) #296
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
Conversation
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
* Use other forwarders only if there's a strong reason to bypass this check. | ||
*/ | ||
address[] memory forwarders = new address[](_trustedForwarders.length + 1); | ||
uint256 i; |
Check warning
Code scanning / Slither
Uninitialized local variables
PackVRFDirect.initialize(address,string,string,string,address[],address,uint256).i (contracts/pack/PackVRFDirect.sol#131) is a local variable never initialized
contracts/pack/PackVRFDirect.sol
Outdated
Comment on lines
30
to
495
} | ||
} | ||
|
||
/*/////////////////////////////////////////////////////////////// | ||
Getter functions | ||
//////////////////////////////////////////////////////////////*/ | ||
|
||
/// @dev Returns the underlying contents of a pack. | ||
function getPackContents(uint256 _packId) | ||
public | ||
view | ||
returns (Token[] memory contents, uint256[] memory perUnitAmounts) | ||
{ | ||
PackInfo memory pack = packInfo[_packId]; | ||
uint256 total = getTokenCountOfBundle(_packId); | ||
contents = new Token[](total); | ||
perUnitAmounts = new uint256[](total); | ||
|
||
for (uint256 i = 0; i < total; i += 1) { | ||
contents[i] = getTokenOfBundle(_packId, i); | ||
} | ||
perUnitAmounts = pack.perUnitAmounts; | ||
} | ||
|
||
/*/////////////////////////////////////////////////////////////// | ||
Internal functions | ||
//////////////////////////////////////////////////////////////*/ | ||
|
||
/// @dev Returns whether owner can be set in the given execution context. | ||
function _canSetOwner() internal view override returns (bool) { | ||
return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); | ||
} | ||
|
||
/// @dev Returns whether royalty info can be set in the given execution context. | ||
function _canSetRoyaltyInfo() internal view override returns (bool) { | ||
return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); | ||
} | ||
|
||
/// @dev Returns whether contract metadata can be set in the given execution context. | ||
function _canSetContractURI() internal view override returns (bool) { | ||
return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); | ||
} | ||
|
||
/*/////////////////////////////////////////////////////////////// | ||
Miscellaneous | ||
//////////////////////////////////////////////////////////////*/ | ||
|
||
/** | ||
* @dev See {ERC1155-_beforeTokenTransfer}. | ||
*/ | ||
function _beforeTokenTransfer( | ||
address operator, | ||
address from, | ||
address to, | ||
uint256[] memory ids, | ||
uint256[] memory amounts, | ||
bytes memory data | ||
) internal virtual override { | ||
super._beforeTokenTransfer(operator, from, to, ids, amounts, data); | ||
|
||
// if transfer is restricted on the contract, we still want to allow burning and minting | ||
if (!hasRole(transferRole, address(0)) && from != address(0) && to != address(0)) { | ||
require(hasRole(transferRole, from) || hasRole(transferRole, to), "!TRANSFER_ROLE"); | ||
} | ||
|
||
if (from == address(0)) { | ||
for (uint256 i = 0; i < ids.length; ++i) { | ||
totalSupply[ids[i]] += amounts[i]; | ||
} | ||
} | ||
|
||
if (to == address(0)) { | ||
for (uint256 i = 0; i < ids.length; ++i) { | ||
totalSupply[ids[i]] -= amounts[i]; | ||
} | ||
} | ||
} | ||
|
||
/// @dev See EIP-2771 | ||
function _msgSender() | ||
internal | ||
view | ||
virtual | ||
override(ContextUpgradeable, ERC2771ContextUpgradeable) | ||
returns (address sender) | ||
{ | ||
return ERC2771ContextUpgradeable._msgSender(); | ||
} | ||
|
||
/// @dev See EIP-2771 | ||
function _msgData() | ||
internal | ||
view | ||
virtual | ||
override(ContextUpgradeable, ERC2771ContextUpgradeable) | ||
returns (bytes calldata) | ||
{ | ||
return ERC2771ContextUpgradeable._msgData(); | ||
} | ||
} |
Check warning
Code scanning / Slither
Missing inheritance
PackVRFDirect (contracts/pack/PackVRFDirect.sol#30-495) should inherit from IThirdwebContract (contracts/interfaces/IThirdwebContract.sol#4-19)
*/ | ||
function createPack( | ||
Token[] calldata contents, | ||
uint256[] calldata numOfRewardUnits, |
Check warning
Code scanning / Slither
Variable names too similar
Variable IPackVRFDirect.createPack(ITokenBundle.Token[],uint256[],string,uint128,uint128,address).numOfRewardUnits (contracts/interfaces/IPackVRFDirect.sol#58) is too similar to PackVRFDirect.escrowPackContents(ITokenBundle.Token[],uint256[],string,uint256,uint256,bool).sumOfRewardUnits (contracts/pack/PackVRFDirect.sol#326)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Introduces
PackVRFDirect
: uses Chainlink VRF to get robust random numbers (instead of pseudo-random numbers from block variables) to make the process of selection of rewards fair i.e. the chance of receiving a reward is a true representation of how rare the reward is.