Skip to content

Commit

Permalink
Merge branch 'master' into feature/optimize-address-array
Browse files Browse the repository at this point in the history
# Conflicts:
#	test/contracts/AddressArray.test.ts
  • Loading branch information
zZoMROT committed Nov 17, 2023
2 parents 8b3d6af + 2d8f878 commit 8e89d6b
Show file tree
Hide file tree
Showing 65 changed files with 3,830 additions and 3,068 deletions.
25 changes: 0 additions & 25 deletions .github/actions/setup/action.yml

This file was deleted.

18 changes: 15 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,34 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup
- uses: actions/setup-node@v3
with:
node-version: 20
cache: 'yarn'
- run: yarn
- run: yarn lint

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup
- uses: actions/setup-node@v3
with:
node-version: 20
cache: 'yarn'
- run: yarn
- run: yarn typechain
- run: yarn test:ci

coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup
- uses: actions/setup-node@v3
with:
node-version: 20
cache: 'yarn'
- run: yarn
- run: yarn typechain
- run: yarn coverage
- uses: codecov/codecov-action@v3
6 changes: 3 additions & 3 deletions .github/workflows/cpv.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PR
name: CHECK_PACKAGE_VERSION

on:
pull_request:
Expand All @@ -11,8 +11,8 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm install -g yarn
node-version: 20
cache: 'yarn'
- run: yarn global add semver-compare-cli
- run: export PATH="$PATH:$(yarn global bin)"
- name: Get local package version
Expand Down
27 changes: 23 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,31 @@ on:
workflow_dispatch:

jobs:
publish:
publish-npmjs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup
- run: yarn typechain
- uses: actions/setup-node@v3
with:
node-version: 20
cache: 'yarn'
- run: yarn
- run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- run: yarn publishPackage
- run: yarn publish

publish-github:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
cache: 'yarn'
- run: yarn
- name: Auth in GitHub private registry npm
run: |
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > .npmrc
echo "@1inch:registry=https://npm.pkg.github.com" >> .npmrc
- run: yarn publish
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ cache
node_modules
coverage
coverage.json
build
dist
typechain-types
.coverage_contracts
.coverage_artifacts
.env
.idea
typechain-types
.DS_Store
*.log
mochaOutput.json
27 changes: 23 additions & 4 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
module.exports = {
configureYulOptimizer: true,
solcOptimizerDetails: {
yul: true,
yulDetails: {
optimizerSteps:
'dhfoDgvlfnTUtnIf' + // None of these can make stack problems worse
'[' +
'xa[r]EscLM' + // Turn into SSA and simplify
'cCTUtTOntnfDIl' + // Perform structural simplification
'Lcl' + // Simplify again
'Vcl [j]' + // Reverse SSA

// should have good 'compilability' property here.

'Tpel' + // Run functional expression inliner
'xa[rl]' + // Prune a bit more in SSA
'xa[r]cL' + // Turn into SSA again and simplify
'gvf' + // Run full inliner
'CTUca[r]LSsTFOtfDnca[r]Ilc' + // SSA plus simplify
']' +
'jml[jl] VcTOcl jml : fDnTOcm', // Make source short and pretty
},
},
skipFiles: [
'mocks', 'tests', 'interfaces',
],
mocha: {
grep: "@skip-on-coverage",
invert: true
},
}
1 change: 1 addition & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"error",
"^0.8.0"
],
"no-global-import": "off",
"private-vars-leading-underscore": "error",
"func-visibility": ["error", { "ignoreConstructors": true }]
}
Expand Down
36 changes: 36 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Contributing to 1inch
=======

Thanks for taking the time to contribute! All types of contributions are encouraged and valued. Please make sure to read the sections below before making your contribution. It will make it a lot easier for maintainers and speeds up the merge of your contribution.

## Creating Pull Requests (PRs)

As a contributor, you are expected to fork this repository, work on your own fork and then submit pull requests. The pull requests will be reviewed and eventually merged into the main repo.

## A typical workflow

1) Before contributing any changes it is a good practice to open an issue and provide the reasoning for the changes
1) Make sure your fork is up to date with the main repository
2) Update all dependencies to the latest version
```
yarn
```
3) Branch out from `master` into `fix/some-bug-#123`
(Postfixing #123 will associate your PR with the issue #123)
4) Make your changes, add your files, commit and push to your fork.
Before pushing the branch ensure that:
* JS and Solidity linting tests pass
```
yarn lint
```
* New and/or fixed features are covered with relevant tests and all existing tests pass
```
yarn test
```
5) Go to the GitHub repo in your web browser and issue a new pull request.
6) Maintainers will review your code and possibly ask for changes before your code is pulled into the main repository. We'll check that all tests pass, review the coding style, and check for general code correctness. If everything is OK, we'll merge your pull request.

## All done!

If you have any questions feel free to post them in the issues section.
Thanks for your time and code!
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2019-2021 1inch
Copyright (c) 2019-2023 1inch

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ This repository contains frequently used smart contracts, libraries and interfac
|utils|`fixSignature(signature)`|patchs ganache's signature to geth's version|
|utils|`signMessage(signer, messageHex) `|signs `messageHex` with `signer` and patchs ganache's signature to geth's version|
|utils|`countInstructions(txHash, instruction)`|counts amount of `instruction` in transaction with `txHash` hash|
|utils|`deployAndGetContract(contractName, constructorArgs, deployments, deployer, deploymentName, skipVerify, skipIfAlreadyDeployed, gasPrice, maxPriorityFeePerGas, maxFeePerGas, log, waitConfirmations)`|deploys contract `contractName` as `deploymentName` if not `skipIfAlreadyDeployed` with `constructorArgs` from `deployer` using `hardhat-deploy` `deployments` with additional gas options `gasPrice`, `maxPriorityFeePerGas` and `maxFeePerGas` and outputs results to the console if `log`. Tries to verify it after `waitConfirmations` on Etherscan if not `skipVerify`.|
|profileEVM|`profileEVM(txHash, instruction, optionalTraceFile)`|the same as the `countInstructions()` with option of writing all trace to `optionalTraceFile`|
|profileEVM|`gasspectEVM(txHash, options, optionalTraceFile)`|returns all used operations in `txHash` transaction with `options` and their costs with option of writing all trace to `optionalTraceFile`|

Expand Down
1 change: 0 additions & 1 deletion contracts/EthReceiver.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;
pragma abicoder v1;

abstract contract EthReceiver {
error EthDepositRejected();
Expand Down
5 changes: 3 additions & 2 deletions contracts/GasChecker.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;
pragma abicoder v1;

contract GasChecker {
error GasCostDiffers(uint256 expected, uint256 actual);
Expand All @@ -12,6 +11,8 @@ contract GasChecker {
unchecked {
gas -= gasleft();
}
if (expected > 0 && gas != expected) revert GasCostDiffers(expected, gas);
if (expected > 0 && gas != expected) {
revert GasCostDiffers(expected, gas);
}
}
}
1 change: 0 additions & 1 deletion contracts/OnlyWethReceiver.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;
pragma abicoder v1;

import "./EthReceiver.sol";

Expand Down
8 changes: 8 additions & 0 deletions contracts/interfaces/ICreate3Deployer.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface ICreate3Deployer {
function deploy(bytes32 salt, bytes calldata code) external returns (address);
function addressOf(bytes32 salt) external view returns (address);
}
1 change: 0 additions & 1 deletion contracts/interfaces/IDaiLikePermit.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;
pragma abicoder v1;

interface IDaiLikePermit {
function permit(
Expand Down
1 change: 0 additions & 1 deletion contracts/interfaces/IERC20MetadataUppercase.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;
pragma abicoder v1;

interface IERC20MetadataUppercase {
function NAME() external view returns (string memory); // solhint-disable-line func-name-mixedcase
Expand Down
40 changes: 40 additions & 0 deletions contracts/interfaces/IPermit2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IPermit2 {
struct PermitDetails {
// ERC20 token address
address token;
// the maximum amount allowed to spend
uint160 amount;
// timestamp at which a spender's token allowances become invalid
uint48 expiration;
// an incrementing value indexed per owner,token,and spender for each signature
uint48 nonce;
}
/// @notice The permit message signed for a single token allownce
struct PermitSingle {
// the permit data for a single token alownce
PermitDetails details;
// address permissioned on the allowed tokens
address spender;
// deadline on the permit signature
uint256 sigDeadline;
}
/// @notice Packed allowance
struct PackedAllowance {
// amount allowed
uint160 amount;
// permission expiry
uint48 expiration;
// an incrementing value indexed per owner,token,and spender for each signature
uint48 nonce;
}

function transferFrom(address user, address spender, uint160 amount, address token) external;

function permit(address owner, PermitSingle memory permitSingle, bytes calldata signature) external;

function allowance(address user, address token, address spender) external view returns (PackedAllowance memory);
}
5 changes: 4 additions & 1 deletion contracts/interfaces/IWETH.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;
pragma abicoder v1;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IWETH is IERC20 {
event Deposit(address indexed dst, uint256 wad);

event Withdrawal(address indexed src, uint256 wad);

function deposit() external payable;

function withdraw(uint256 amount) external;
Expand Down
1 change: 0 additions & 1 deletion contracts/libraries/AddressArray.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;
pragma abicoder v1;

/// @title Library that implements address array on mapping, stores array length at 0 index.
library AddressArray {
Expand Down
Loading

0 comments on commit 8e89d6b

Please sign in to comment.