Skip to content

Commit 3ac68b1

Browse files
Syed Asad KazmiSyed Asad Kazmi
Syed Asad Kazmi
authored and
Syed Asad Kazmi
committed
Fixed the value initialization of subId in SubscriptionAPI.sol
1 parent 2c70edc commit 3ac68b1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

contracts/src/v0.8/vrf/dev/SubscriptionAPI.sol

+8-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,14 @@ abstract contract SubscriptionAPI is ConfirmedOwner, IERC677Receiver, IVRFSubscr
346346
// Generate a subscription id that is globally unique.
347347
uint64 currentSubNonce = s_currentSubNonce;
348348
subId = uint256(
349-
keccak256(abi.encodePacked(msg.sender, blockhash(block.number - 1), address(this), currentSubNonce))
349+
keccak256(
350+
abi.encodePacked(
351+
msg.sender,
352+
(block.number == 0 ? bytes32(0) : blockhash(block.number - 1)),
353+
address(this),
354+
currentSubNonce
355+
)
356+
)
350357
);
351358
// Increment the subscription nonce counter.
352359
s_currentSubNonce = currentSubNonce + 1;

0 commit comments

Comments
 (0)