-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
374 additions
and
117 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
.forge-snapshots/Base-V3DutchOrder-BaseExecuteSingleWithFee.snap
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 |
---|---|---|
@@ -1 +1 @@ | ||
198780 | ||
198870 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
231116 | ||
231296 |
2 changes: 1 addition & 1 deletion
2
.forge-snapshots/Base-V3DutchOrder-ExecuteBatchMultipleOutputs.snap
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 |
---|---|---|
@@ -1 +1 @@ | ||
244626 | ||
244817 |
2 changes: 1 addition & 1 deletion
2
.forge-snapshots/Base-V3DutchOrder-ExecuteBatchMultipleOutputsDifferentTokens.snap
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 |
---|---|---|
@@ -1 +1 @@ | ||
302041 | ||
302243 |
2 changes: 1 addition & 1 deletion
2
.forge-snapshots/Base-V3DutchOrder-ExecuteBatchNativeOutput.snap
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 |
---|---|---|
@@ -1 +1 @@ | ||
224642 | ||
224822 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
165165 | ||
165255 |
2 changes: 1 addition & 1 deletion
2
.forge-snapshots/Base-V3DutchOrder-ExecuteSingleNativeOutput.snap
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 |
---|---|---|
@@ -1 +1 @@ | ||
150727 | ||
150817 |
2 changes: 1 addition & 1 deletion
2
.forge-snapshots/Base-V3DutchOrder-ExecuteSingleValidation.snap
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 |
---|---|---|
@@ -1 +1 @@ | ||
174481 | ||
174571 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
43785 | ||
43875 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
169089 | ||
169179 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
169170 | ||
169260 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
169113 | ||
169203 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
13179 | ||
13351 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
1199 | ||
1247 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
6677 | ||
6755 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
6365 | ||
6443 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
1271 | ||
1309 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
5899 | ||
5975 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
4703 | ||
4779 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
4703 | ||
4779 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
1271 | ||
1309 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
88354 | ||
89192 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
26242 | ||
26608 |
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,31 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import {IArbSys} from "../interfaces/IArbSys.sol"; | ||
|
||
/// @title BlockNumberish | ||
/// A helper contract to get the current block number on different chains | ||
contract BlockNumberish { | ||
// Declare an immutable function type variable for the _getTstorish function | ||
// based on chain support for tstore at time of deployment. | ||
function() view returns (uint256) internal immutable _getBlockNumberish; | ||
|
||
constructor() { | ||
// Set the function to use based on chainid | ||
if (block.chainid == 42161) { | ||
_getBlockNumberish = _getBlockNumberSyscall; | ||
} else { | ||
_getBlockNumberish = _getBlockNumber; | ||
} | ||
} | ||
|
||
/// @dev Private function to get the block number on arbitrum | ||
function _getBlockNumberSyscall() private view returns (uint256) { | ||
return IArbSys(0x0000000000000000000000000000000000000064).arbBlockNumber(); | ||
} | ||
|
||
/// @dev Private function to get the block number using the opcode | ||
function _getBlockNumber() private view returns (uint256) { | ||
return block.number; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity ^0.8.0; | ||
|
||
import {Test} from "forge-std/Test.sol"; | ||
import {BlockNumberish} from "../../src/base/BlockNumberish.sol"; | ||
|
||
/// Mock Arbitrum syscall contract | ||
contract MockArbSys { | ||
uint256 _blockNumber; | ||
|
||
/// @dev helper function to set the block number | ||
function setBlockNumber(uint256 blockNumber) external { | ||
_blockNumber = blockNumber; | ||
} | ||
|
||
/// @notice returns the block number | ||
function arbBlockNumber() external view returns (uint256) { | ||
return _blockNumber; | ||
} | ||
} | ||
|
||
contract MockBlockNumberish is BlockNumberish { | ||
function getBlockNumberish() external view returns (uint256) { | ||
return _getBlockNumberish(); | ||
} | ||
} | ||
|
||
contract BlockNumberishTest is Test { | ||
MockArbSys arbSys; | ||
MockBlockNumberish blockNumberish; | ||
|
||
function setUp() public { | ||
// etch MockArbSys to address(100) | ||
vm.etch(address(100), address(new MockArbSys()).code); | ||
arbSys = MockArbSys(address(100)); | ||
} | ||
|
||
function test_getBlockNumber() public { | ||
blockNumberish = new MockBlockNumberish(); | ||
|
||
vm.roll(100); | ||
assertEq(blockNumberish.getBlockNumberish(), 100); | ||
} | ||
|
||
function test_getBlockNumberSyscall() public { | ||
vm.chainId(42161); | ||
blockNumberish = new MockBlockNumberish(); | ||
|
||
arbSys.setBlockNumber(1); | ||
assertEq(blockNumberish.getBlockNumberish(), 1); | ||
} | ||
} |
Oops, something went wrong.