Skip to content

Commit c4b7d33

Browse files
committed
Upgrade solidity and tests infrastructure
1 parent c950937 commit c4b7d33

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+8724
-23802
lines changed

.babelrc

-5
This file was deleted.

.eslintignore

-6
This file was deleted.

.eslintrc

-21
This file was deleted.

.github/workflows/push_checking.yml

+6-9
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ jobs:
66
runs-on: ubuntu-latest
77
strategy:
88
matrix:
9-
node-version: [12.x]
9+
node-version: [20.x]
1010

1111
steps:
1212
- name: Checkout
13-
uses: 'actions/checkout@master'
13+
uses: actions/checkout@v4
1414

1515
- name: Set Node.js
16-
uses: actions/setup-node@v1
16+
uses: actions/setup-node@v4
1717
with:
1818
node-version: ${{ matrix.node-version }}
1919

@@ -28,22 +28,19 @@ jobs:
2828
runs-on: ubuntu-latest
2929
strategy:
3030
matrix:
31-
node-version: [12.x]
31+
node-version: [20.x]
3232

3333
steps:
3434
- name: Checkout
35-
uses: 'actions/checkout@master'
35+
uses: actions/checkout@v4
3636

3737
- name: Set Node.js
38-
uses: actions/setup-node@v1
38+
uses: actions/setup-node@v4
3939
with:
4040
node-version: ${{ matrix.node-version }}
4141

4242
- name: Install dependencies
4343
run: npm install
4444

45-
- name: Install Truffle
46-
run: npm install -g truffle
47-
4845
- name: Run tests
4946
run: npm run test

.gitignore

+21-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1-
.idea/
2-
node_modules
1+
.idea
2+
.deps
33
build
4-
coverage
5-
coverage.json
6-
/.coverage_artifacts/
7-
/.coverage_contracts/
8-
/coverageEnv/
9-
/coverageEnv/
10-
artifacts/
11-
cache/
12-
.env
4+
contracts/artifacts
5+
internal/rpc/contracts
6+
.deploys
7+
.states
8+
9+
node_modules
10+
.env
11+
12+
# solidity-coverage files
13+
/coverage
14+
/coverage.json
15+
16+
# Hardhat files
17+
/cache
18+
/artifacts
19+
20+
# TypeChain files
21+
/typechain
22+
/typechain-types

.prettierrc

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"printWidth": 120,
3+
"singleQuote": true,
4+
"trailingComma": "all",
5+
"arrowParens": "avoid",
6+
"overrides": [
7+
{
8+
"files": "*.sol",
9+
"options": {
10+
"singleQuote": false,
11+
"quoteProps": "consistent"
12+
}
13+
}
14+
],
15+
"plugins": ["prettier-plugin-solidity"]
16+
}

.solcover.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
skipFiles: ['common/ReentrancyGuard.sol', 'sfc/Migrations.sol']
2+
skipFiles: ['common/ReentrancyGuard.sol', 'sfc/Migrations.sol'],
33
};

Makefile

+8-4
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@ all: build
33

44
.PHONY: build
55
build:
6-
docker run --rm --user $$(id -u):$$(id -g) -v $(PWD):/src -w /src node:16.19.1 bash -c \
7-
'export NPM_CONFIG_PREFIX=~; npm install --no-save; npm install --no-save [email protected]; npm run build'
6+
docker run --rm --user $$(id -u):$$(id -g) -v $(PWD):/src -w /src node:20.17.0 bash -c \
7+
'export NPM_CONFIG_PREFIX=~; npm install --no-save; npx hardhat compile'
88

99
.PHONY: checksum
1010
checksum:
1111
for f in ./build/contracts/*.json; do echo -n "$$f "; jq -j .deployedBytecode $$f | shasum; done
1212

1313
.PHONY: test
1414
test:
15-
docker run --rm --user $$(id -u):$$(id -g) -v $(PWD):/src -w /src node:16.19.1 bash -c \
16-
'export NPM_CONFIG_PREFIX=~; npm install --no-save; npm install --no-save [email protected]; npm run test'
15+
docker run --rm --user $$(id -u):$$(id -g) -v $(PWD):/src -w /src node:20.17.0 bash -c \
16+
'export NPM_CONFIG_PREFIX=~; npm install --no-save; npx hardhat test'
1717

18+
.PHONY: workspace
19+
workspace:
20+
docker run -t -i --rm --user $$(id -u):$$(id -g) -v $(PWD):/src -w /src node:20.17.0 bash -c \
21+
'export NPM_CONFIG_PREFIX=~; npm install --no-save; bash'

contracts/common/Decimal.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
pragma solidity ^0.5.0;
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.9;
23

34
library Decimal {
45
// unit is used for decimals, e.g. 0.123456

contracts/common/Initializable.sol

+31-45
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
pragma solidity >=0.4.24 <0.7.0;
2-
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.9;
33

44
/**
55
* @title Initializable
@@ -14,49 +14,35 @@ pragma solidity >=0.4.24 <0.7.0;
1414
* because this is not dealt with automatically as with constructors.
1515
*/
1616
contract Initializable {
17-
18-
/**
19-
* @dev Indicates that the contract has been initialized.
20-
*/
21-
bool private initialized;
22-
23-
/**
24-
* @dev Indicates that the contract is in the process of being initialized.
25-
*/
26-
bool private initializing;
27-
28-
/**
29-
* @dev Modifier to use in the initializer function of a contract.
30-
*/
31-
modifier initializer() {
32-
require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized");
33-
34-
bool isTopLevelCall = !initializing;
35-
if (isTopLevelCall) {
36-
initializing = true;
37-
initialized = true;
17+
/**
18+
* @dev Indicates that the contract has been initialized.
19+
*/
20+
bool private initialized;
21+
22+
/**
23+
* @dev Indicates that the contract is in the process of being initialized.
24+
*/
25+
bool private initializing;
26+
27+
/**
28+
* @dev Modifier to use in the initializer function of a contract.
29+
*/
30+
modifier initializer() {
31+
require(initializing || !initialized, "Contract instance has already been initialized");
32+
33+
bool isTopLevelCall = !initializing;
34+
if (isTopLevelCall) {
35+
initializing = true;
36+
initialized = true;
37+
}
38+
39+
_;
40+
41+
if (isTopLevelCall) {
42+
initializing = false;
43+
}
3844
}
3945

40-
_;
41-
42-
if (isTopLevelCall) {
43-
initializing = false;
44-
}
45-
}
46-
47-
/// @dev Returns true if and only if the function is running in the constructor
48-
function isConstructor() private view returns (bool) {
49-
// extcodesize checks the size of the code stored in an address, and
50-
// address returns the current address. Since the code is still not
51-
// deployed when running a constructor, any checks on its code size will
52-
// yield zero, making it an effective way to detect if a contract is
53-
// under construction or not.
54-
address self = address(this);
55-
uint256 cs;
56-
assembly { cs := extcodesize(self) }
57-
return cs == 0;
58-
}
59-
60-
// Reserved storage space to allow for layout changes in the future.
61-
uint256[50] private ______gap;
46+
// Reserved storage space to allow for layout changes in the future.
47+
uint256[50] private ______gap;
6248
}

contracts/common/ReentrancyGuard.sol

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
pragma solidity ^0.5.0;
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.9;
3+
24
import "./Initializable.sol";
35

46
/**

0 commit comments

Comments
 (0)