Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
7f57ac87
Unverified
Commit
7f57ac87
authored
Sep 16, 2021
by
elenadimitrova
Committed by
Kelvin Fichter
Nov 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove SafeMatch usage and rely on Solidity 0.8 built in safe math functionality
parent
ae24e852
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
29 deletions
+8
-29
L1StandardBridge.sol
...ges/contracts/contracts/L1/messaging/L1StandardBridge.sol
+2
-4
StateCommitmentChain.sol
...es/contracts/contracts/L1/rollup/StateCommitmentChain.sol
+1
-4
TestERC20.sol
packages/contracts/contracts/test-helpers/TestERC20.sol
+5
-21
No files found.
packages/contracts/contracts/L1/messaging/L1StandardBridge.sol
View file @
7f57ac87
...
...
@@ -10,7 +10,6 @@ import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
/* Library Imports */
import { CrossDomainEnabled } from "../../libraries/bridge/CrossDomainEnabled.sol";
import { Lib_PredeployAddresses } from "../../libraries/constants/Lib_PredeployAddresses.sol";
import { SafeMath } from "@openzeppelin/contracts/utils/math/SafeMath.sol";
import { Address } from "@openzeppelin/contracts/utils/Address.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
...
...
@@ -23,7 +22,6 @@ import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.s
* Runtime target: EVM
*/
contract L1StandardBridge is IL1StandardBridge, CrossDomainEnabled {
using SafeMath for uint;
using SafeERC20 for IERC20;
/********************************
...
...
@@ -263,7 +261,7 @@ contract L1StandardBridge is IL1StandardBridge, CrossDomainEnabled {
message
);
deposits[_l1Token][_l2Token] = deposits[_l1Token][_l2Token]
.add(_amount)
;
deposits[_l1Token][_l2Token] = deposits[_l1Token][_l2Token]
+ _amount
;
emit ERC20DepositInitiated(_l1Token, _l2Token, _from, _to, _amount, _data);
}
...
...
@@ -306,7 +304,7 @@ contract L1StandardBridge is IL1StandardBridge, CrossDomainEnabled {
override
onlyFromCrossDomainAccount(l2TokenBridge)
{
deposits[_l1Token][_l2Token] = deposits[_l1Token][_l2Token]
.sub(_amount)
;
deposits[_l1Token][_l2Token] = deposits[_l1Token][_l2Token]
- _amount
;
// When a withdrawal is finalized on L1, the L1 Bridge transfers the funds to the withdrawer
IERC20(_l1Token).safeTransfer(_to, _amount);
...
...
packages/contracts/contracts/L1/rollup/StateCommitmentChain.sol
View file @
7f57ac87
...
...
@@ -12,9 +12,6 @@ import { ICanonicalTransactionChain } from "./ICanonicalTransactionChain.sol";
import { IBondManager } from "../verification/IBondManager.sol";
import { IChainStorageContainer } from "./IChainStorageContainer.sol";
/* External Imports */
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
/**
* @title StateCommitmentChain
* @dev The State Commitment Chain (SCC) contract contains a list of proposed state roots which
...
...
@@ -243,7 +240,7 @@ contract StateCommitmentChain is IStateCommitmentChain, Lib_AddressResolver {
timestamp != 0,
"Batch header timestamp cannot be zero"
);
return
SafeMath.add(timestamp,
FRAUD_PROOF_WINDOW) > block.timestamp;
return
(timestamp +
FRAUD_PROOF_WINDOW) > block.timestamp;
}
...
...
packages/contracts/contracts/test-helpers/TestERC20.sol
View file @
7f57ac87
...
...
@@ -3,8 +3,6 @@ pragma solidity ^0.8.4;
// a test ERC20 token with an open mint function
contract TestERC20 {
using SafeMath for uint;
string public constant name = "Test";
string public constant symbol = "TST";
uint8 public constant decimals = 18;
...
...
@@ -18,8 +16,8 @@ contract TestERC20 {
constructor() {}
function mint(address to, uint256 value) public {
totalSupply = totalSupply
.add(value)
;
balanceOf[to] = balanceOf[to]
.add(value)
;
totalSupply = totalSupply
+ value
;
balanceOf[to] = balanceOf[to]
+ value
;
emit Transfer(address(0), to, value);
}
...
...
@@ -29,8 +27,8 @@ contract TestERC20 {
}
function _transfer(address from, address to, uint256 value) private {
balanceOf[from] = balanceOf[from]
.sub(value)
;
balanceOf[to] = balanceOf[to]
.add(value)
;
balanceOf[from] = balanceOf[from]
- value
;
balanceOf[to] = balanceOf[to]
+ value
;
emit Transfer(from, to, value);
}
...
...
@@ -46,23 +44,9 @@ contract TestERC20 {
function transferFrom(address from, address to, uint256 value) external returns (bool) {
if (allowance[from][msg.sender] != type(uint).max) {
allowance[from][msg.sender] = allowance[from][msg.sender]
.sub(value)
;
allowance[from][msg.sender] = allowance[from][msg.sender]
- value
;
}
_transfer(from, to, value);
return true;
}
}
library SafeMath {
function add(uint256 x, uint256 y) internal pure returns (uint256 z) {
require((z = x + y) >= x, "ds-math-add-overflow");
}
function sub(uint256 x, uint256 y) internal pure returns (uint256 z) {
require((z = x - y) <= x, "ds-math-sub-underflow");
}
function mul(uint256 x, uint256 y) internal pure returns (uint256 z) {
require(y == 0 || (z = x * y) / y == x, "ds-math-mul-overflow");
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment