Skip to content
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

chore: lint contracts package with graph custom config #958

Merged
merged 9 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: CI - packages/contracts

env:
CI: true
Expand All @@ -23,7 +23,9 @@ jobs:
- name: Set up environment
uses: ./.github/actions/setup
- name: Run tests
run: yarn test:coverage
run: |
pushd packages/contracts
yarn test:coverage
- name: Upload coverage report
uses: codecov/codecov-action@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-token-dist.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: CI - packages/token-distribution

env:
CI: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: E2E
name: E2E - packages/contracts

env:
CI: true
Expand Down Expand Up @@ -41,4 +41,5 @@ jobs:
sed -i'' -e 's/^\(.*dev.period.*\)/# \1/' docker-compose.yaml
./test-node.bash --init --batchposters 0 --redundantsequencers 0 --detach
popd
pushd packages/contracts
L1_NETWORK=localnitrol1 L2_NETWORK=localnitrol2 yarn test:e2e
7 changes: 0 additions & 7 deletions packages/contracts/.eslintignore

This file was deleted.

19 changes: 0 additions & 19 deletions packages/contracts/.eslintrc

This file was deleted.

4 changes: 0 additions & 4 deletions packages/contracts/.prettierignore

This file was deleted.

35 changes: 0 additions & 35 deletions packages/contracts/.prettierrc.json

This file was deleted.

7 changes: 1 addition & 6 deletions packages/contracts/contracts/arbitrum/IBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@ interface IBridge {
bytes32 messageDataHash
);

event BridgeCallTriggered(
address indexed outbox,
address indexed destAddr,
uint256 amount,
bytes data
);
event BridgeCallTriggered(address indexed outbox, address indexed destAddr, uint256 amount, bytes data);

event InboxToggle(address indexed inbox, bool enabled);

Expand Down
3 changes: 1 addition & 2 deletions packages/contracts/contracts/arbitrum/IOutbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ interface IOutbox {

function l2ToL1OutputId() external view returns (bytes32);

function processOutgoingMessages(bytes calldata sendsData, uint256[] calldata sendLengths)
external;
function processOutgoingMessages(bytes calldata sendsData, uint256[] calldata sendLengths) external;

function outboxEntryExists(uint256 batchNum) external view returns (bool);
}
54 changes: 12 additions & 42 deletions packages/contracts/contracts/bancor/BancorFormula.sol
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,7 @@ contract BancorFormula {
uint256 _amount
) public view returns (uint256) {
// validate input
require(
_supply > 0 && _reserveBalance > 0 && _totalRatio > 1 && _totalRatio <= MAX_RATIO * 2
);
require(_supply > 0 && _reserveBalance > 0 && _totalRatio > 1 && _totalRatio <= MAX_RATIO * 2);

// special case for 0 amount
if (_amount == 0) return 0;
Expand Down Expand Up @@ -364,11 +362,7 @@ contract BancorFormula {
) public view returns (uint256) {
// validate input
require(
_supply > 0 &&
_reserveBalance > 0 &&
_totalRatio > 1 &&
_totalRatio <= MAX_RATIO * 2 &&
_amount <= _supply
_supply > 0 && _reserveBalance > 0 && _totalRatio > 1 && _totalRatio <= MAX_RATIO * 2 && _amount <= _supply
);

// special case for 0 amount
Expand Down Expand Up @@ -407,12 +401,7 @@ contract BancorFormula {
* This functions assumes that "_expN < 2 ^ 256 / log(MAX_NUM - 1)", otherwise the multiplication should be replaced with a "safeMul".
* Since we rely on unsigned-integer arithmetic and "base < 1" ==> "log(base) < 0", this function does not support "_baseN < _baseD".
*/
function power(
uint256 _baseN,
uint256 _baseD,
uint32 _expN,
uint32 _expD
) internal view returns (uint256, uint8) {
function power(uint256 _baseN, uint256 _baseD, uint32 _expN, uint32 _expD) internal view returns (uint256, uint8) {
require(_baseN < MAX_NUM);

uint256 baseLog;
Expand All @@ -428,10 +417,7 @@ contract BancorFormula {
return (optimalExp(baseLogTimesExp), MAX_PRECISION);
} else {
uint8 precision = findPositionInMaxExpArray(baseLogTimesExp);
return (
generalExp(baseLogTimesExp >> (MAX_PRECISION - precision), precision),
precision
);
return (generalExp(baseLogTimesExp >> (MAX_PRECISION - precision), precision), precision);
}
}

Expand Down Expand Up @@ -642,37 +628,21 @@ contract BancorFormula {

z = y = x - FIXED_1;
w = (y * y) / FIXED_1;
res +=
(z * (0x100000000000000000000000000000000 - y)) /
0x100000000000000000000000000000000;
res += (z * (0x100000000000000000000000000000000 - y)) / 0x100000000000000000000000000000000;
z = (z * w) / FIXED_1; // add y^01 / 01 - y^02 / 02
res +=
(z * (0x0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - y)) /
0x200000000000000000000000000000000;
res += (z * (0x0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - y)) / 0x200000000000000000000000000000000;
z = (z * w) / FIXED_1; // add y^03 / 03 - y^04 / 04
res +=
(z * (0x099999999999999999999999999999999 - y)) /
0x300000000000000000000000000000000;
res += (z * (0x099999999999999999999999999999999 - y)) / 0x300000000000000000000000000000000;
z = (z * w) / FIXED_1; // add y^05 / 05 - y^06 / 06
res +=
(z * (0x092492492492492492492492492492492 - y)) /
0x400000000000000000000000000000000;
res += (z * (0x092492492492492492492492492492492 - y)) / 0x400000000000000000000000000000000;
z = (z * w) / FIXED_1; // add y^07 / 07 - y^08 / 08
res +=
(z * (0x08e38e38e38e38e38e38e38e38e38e38e - y)) /
0x500000000000000000000000000000000;
res += (z * (0x08e38e38e38e38e38e38e38e38e38e38e - y)) / 0x500000000000000000000000000000000;
z = (z * w) / FIXED_1; // add y^09 / 09 - y^10 / 10
res +=
(z * (0x08ba2e8ba2e8ba2e8ba2e8ba2e8ba2e8b - y)) /
0x600000000000000000000000000000000;
res += (z * (0x08ba2e8ba2e8ba2e8ba2e8ba2e8ba2e8b - y)) / 0x600000000000000000000000000000000;
z = (z * w) / FIXED_1; // add y^11 / 11 - y^12 / 12
res +=
(z * (0x089d89d89d89d89d89d89d89d89d89d89 - y)) /
0x700000000000000000000000000000000;
res += (z * (0x089d89d89d89d89d89d89d89d89d89d89 - y)) / 0x700000000000000000000000000000000;
z = (z * w) / FIXED_1; // add y^13 / 13 - y^14 / 14
res +=
(z * (0x088888888888888888888888888888888 - y)) /
0x800000000000000000000000000000000; // add y^15 / 15 - y^16 / 16
res += (z * (0x088888888888888888888888888888888 - y)) / 0x800000000000000000000000000000000; // add y^15 / 15 - y^16 / 16

return res;
}
Expand Down
Loading
Loading