Skip to content

Commit 01f6fbf

Browse files
authored
[BBND-820] Contract Dependency Mess (#413)
Signed-off-by: Miguel_LZPF <miguel.carpena@io.builders>
1 parent b0a8211 commit 01f6fbf

File tree

7 files changed

+18764
-5559
lines changed

7 files changed

+18764
-5559
lines changed

.github/workflows/all.test.yml

Lines changed: 84 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,102 @@
11
name: Tests
22
on:
3-
pull_request:
4-
push:
5-
branches: [main]
3+
pull_request:
4+
push:
5+
branches: [main]
66

77
jobs:
8-
test-node:
9-
name: testing
10-
runs-on: token-studio-linux-large
11-
env:
12-
NODE_OPTIONS: "--max-old-space-size=32768"
13-
CLIENT_PRIVATE_KEY_ECDSA_1: ${{ secrets.CLIENT_PRIVATE_KEY_ECDSA_1 }}
14-
CLIENT_PUBLIC_KEY_ECDSA_1: ${{ secrets.CLIENT_PUBLIC_KEY_ECDSA_1 }}
15-
CLIENT_ACCOUNT_ID_ECDSA_1: "0.0.1328"
16-
CLIENT_EVM_ADDRESS_ECDSA_1_CORRECT: "0x97C50bb12E1C6284cF2855cdba95c5D60AEE44CF"
17-
CLIENT_EVM_ADDRESS_ECDSA_1: "0x0000000000000000000000000000000000000530"
18-
CLIENT_PRIVATE_KEY_ECDSA_2: ${{ secrets.CLIENT_PRIVATE_KEY_ECDSA_2 }}
19-
CLIENT_PUBLIC_KEY_ECDSA_2: ${{ secrets.CLIENT_PUBLIC_KEY_ECDSA_2 }}
20-
CLIENT_ACCOUNT_ID_ECDSA_2: "0.0.2168740"
21-
CLIENT_EVM_ADDRESS_ECDSA_2: "0x00000000000000000000000000000000002117A4"
22-
FACTORY_ADDRESS: "0.0.5480051"
23-
RESOLVER_ADDRESS: "0.0.5479997"
24-
FIREBLOCKS_HEDERA_ACCOUNT_ID: "0.0.2168740"
25-
FIREBLOCKS_HEDERA_PUBLIC_KEY: ${{ secrets.CLIENT_PUBLIC_KEY_ECDSA_2 }}
26-
DFNS_HEDERA_ACCOUNT_ID: "0.0.2168740"
27-
DFNS_WALLET_PUBLIC_KEY: ${{ secrets.CLIENT_PUBLIC_KEY_ECDSA_2 }}
28-
AWS_KMS_HEDERA_ACCOUNT_ID: "0.0.4394946"
29-
AWS_KMS_HEDERA_PUBLIC_KEY: "302d300706052b8104000a03220003ee815bb9b5e53f5dbe7264a77e586127dfcb75da8c1246f5aa6ededdb13e6c21"
30-
REACT_APP_MIRROR_NODE: "https://testnet.mirrornode.hedera.com/api/v1/"
31-
REACT_APP_RPC_NODE: "https://testnet.hashio.io/api"
32-
REACT_APP_RPC_RESOLVER: "0.0.5479997"
33-
REACT_APP_RPC_FACTORY: "0.0.5480051"
34-
REACT_APP_SHOW_DISCLAIMER: "true"
35-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
36-
permissions:
37-
contents: read
8+
test-node:
9+
name: testing
10+
runs-on: token-studio-linux-large
11+
env:
12+
NODE_OPTIONS: '--max-old-space-size=32768'
13+
CONTRACT_SIZER_RUN_ON_COMPILE: 'false'
14+
REPORT_GAS: 'false'
15+
CLIENT_PRIVATE_KEY_ECDSA_1: ${{ secrets.CLIENT_PRIVATE_KEY_ECDSA_1 }}
16+
CLIENT_PUBLIC_KEY_ECDSA_1: ${{ secrets.CLIENT_PUBLIC_KEY_ECDSA_1 }}
17+
CLIENT_ACCOUNT_ID_ECDSA_1: '0.0.1328'
18+
CLIENT_EVM_ADDRESS_ECDSA_1_CORRECT: '0x97C50bb12E1C6284cF2855cdba95c5D60AEE44CF'
19+
CLIENT_EVM_ADDRESS_ECDSA_1: '0x0000000000000000000000000000000000000530'
20+
CLIENT_PRIVATE_KEY_ECDSA_2: ${{ secrets.CLIENT_PRIVATE_KEY_ECDSA_2 }}
21+
CLIENT_PUBLIC_KEY_ECDSA_2: ${{ secrets.CLIENT_PUBLIC_KEY_ECDSA_2 }}
22+
CLIENT_ACCOUNT_ID_ECDSA_2: '0.0.2168740'
23+
CLIENT_EVM_ADDRESS_ECDSA_2: '0x00000000000000000000000000000000002117A4'
24+
FACTORY_ADDRESS: '0.0.5480051'
25+
RESOLVER_ADDRESS: '0.0.5479997'
26+
FIREBLOCKS_HEDERA_ACCOUNT_ID: '0.0.2168740'
27+
FIREBLOCKS_HEDERA_PUBLIC_KEY: ${{ secrets.CLIENT_PUBLIC_KEY_ECDSA_2 }}
28+
DFNS_HEDERA_ACCOUNT_ID: '0.0.2168740'
29+
DFNS_WALLET_PUBLIC_KEY: ${{ secrets.CLIENT_PUBLIC_KEY_ECDSA_2 }}
30+
AWS_KMS_HEDERA_ACCOUNT_ID: '0.0.4394946'
31+
AWS_KMS_HEDERA_PUBLIC_KEY: '302d300706052b8104000a03220003ee815bb9b5e53f5dbe7264a77e586127dfcb75da8c1246f5aa6ededdb13e6c21'
32+
REACT_APP_MIRROR_NODE: 'https://testnet.mirrornode.hedera.com/api/v1/'
33+
REACT_APP_RPC_NODE: 'https://testnet.hashio.io/api'
34+
REACT_APP_RPC_RESOLVER: '0.0.5479997'
35+
REACT_APP_RPC_FACTORY: '0.0.5480051'
36+
REACT_APP_SHOW_DISCLAIMER: 'true'
37+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
38+
permissions:
39+
contents: read
3840

39-
steps:
40-
- name: Harden Runner
41-
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
42-
with:
43-
egress-policy: audit
41+
steps:
42+
- name: Harden Runner
43+
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
44+
with:
45+
egress-policy: audit
4446

45-
- name: Checkout repository
46-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
47+
- name: Checkout repository
48+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4749

48-
- name: Setup NodeJS Environment
49-
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
50-
with:
51-
node-version: 20.x
50+
- name: Setup NodeJS Environment
51+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
52+
with:
53+
node-version: 20.x
5254

53-
- name: Install dependencies Contracts
54-
working-directory: contracts
55-
run: |
56-
npm ci
57-
npm run compile:force
55+
- name: Install dependencies Contracts
56+
working-directory: contracts
57+
run: |
58+
npm ci
59+
npm run compile:force
5860
59-
- name: Test Contracts
60-
working-directory: contracts
61-
run: npm run test
61+
- name: Test Contracts
62+
working-directory: contracts
63+
run: npm run test
6264

63-
- name: Install dependencies SDK
64-
working-directory: sdk
65-
run: |
66-
npm ci
67-
npm run build
65+
- name: Install dependencies SDK
66+
working-directory: sdk
67+
run: |
68+
npm ci
69+
npm run build
6870
69-
- name: Install Yarn
70-
run: npm install -g yarn@1.22.22
71+
- name: Install Yarn
72+
run: npm install -g yarn@1.22.22
7173

72-
# # No tests for UI components yet
73-
# - name: Install dependencies UI Components
74-
# working-directory: uiComponents
75-
# run: yarn install
74+
# # No tests for UI components yet
75+
# - name: Install dependencies UI Components
76+
# working-directory: uiComponents
77+
# run: yarn install
7678

77-
- name: Install dependencies web
78-
working-directory: web
79-
run: yarn install
79+
- name: Install dependencies web
80+
working-directory: web
81+
run: yarn install
8082

81-
- name: Build web
82-
working-directory: web
83-
run: yarn build
83+
- name: Build web
84+
working-directory: web
85+
run: yarn build
8486

85-
- name: Test web
86-
working-directory: web
87-
run: npm run test
87+
- name: Test web
88+
working-directory: web
89+
run: npm run test
8890

89-
- name: Test sdk
90-
working-directory: sdk
91-
run: npm run test
91+
- name: Test sdk
92+
working-directory: sdk
93+
run: npm run test
9294

93-
# # No tests for UI components yet
94-
# - name: Test UI Components
95-
# working-directory: uiComponents
96-
# run: ${{ steps.cgroup.outputs.exec }} npm run test
95+
# # No tests for UI components yet
96+
# - name: Test UI Components
97+
# working-directory: uiComponents
98+
# run: ${{ steps.cgroup.outputs.exec }} npm run test
9799

98-
- name: Upload coverage report
99-
if: ${{ !cancelled() && always() }}
100-
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673
100+
- name: Upload coverage report
101+
if: ${{ !cancelled() && always() }}
102+
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673

contracts/.env.sample

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,9 @@ TESTNET_SCHEDULEDBALANCEADJUSTMENTS='0x0000000000000000000000000000000000000000'
5555
TESTNET_ADJUSTBALANCES='0x0000000000000000000000000000000000000000'
5656
TESTNET_SCHEDULEDTASKS='0x0000000000000000000000000000000000000000'
5757
TESTNET_PROTECTEDPARTITIONS='0x0000000000000000000000000000000000000000'
58+
59+
# * Hardhat Config
60+
# Contract Sizer
61+
CONTRACT_SIZER_RUN_ON_COMPILE=true
62+
# Gas Reporter
63+
REPORT_GAS=true

contracts/.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ node_modules
2727
.env
2828
coverage
2929
coverage.json
30-
typechain
31-
typechain-types
30+
gas-report.txt
3231

3332
#Hardhat files
3433
cache
@@ -37,6 +36,8 @@ artifacts
3736
./docs/*
3837
./cache/*
3938
./typechain-types/*
39+
typechain
40+
typechain-types
4041

4142
#Slither
4243
Slither/*

contracts/Configuration.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,33 @@ export default class Configuration {
287287
// private _privateKeys: Record<Network, string[]>;
288288
// private _endpoints: Record<Network, Endpoints>;
289289
// private _contracts: Record<ContractName, ContractConfig>;
290+
/**
291+
* Determines whether the contract sizer should run on compile.
292+
*
293+
* @returns {boolean} True if the contract sizer should run on compile, false otherwise.
294+
*/
295+
public static get contractSizerRunOnCompile(): boolean {
296+
return (
297+
Configuration._getEnvironmentVariable({
298+
name: 'CONTRACT_SIZER_RUN_ON_COMPILE',
299+
defaultValue: 'true',
300+
}).toLowerCase() === 'true'
301+
)
302+
}
303+
304+
/**
305+
* Determines whether gas reporting is enabled.
306+
*
307+
* @returns {boolean} True if gas reporting is enabled, false otherwise.
308+
*/
309+
public static get reportGas(): boolean {
310+
return (
311+
Configuration._getEnvironmentVariable({
312+
name: 'REPORT_GAS',
313+
defaultValue: 'true',
314+
}).toLowerCase() === 'true'
315+
)
316+
}
290317

291318
public static get privateKeys(): Record<Network, string[]> {
292319
return NETWORKS.reduce(

contracts/hardhat.config.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,10 @@
206206
import { HardhatUserConfig } from 'hardhat/config'
207207
import 'tsconfig-paths/register'
208208
import '@nomicfoundation/hardhat-toolbox'
209+
import '@nomicfoundation/hardhat-chai-matchers'
210+
import '@typechain/hardhat'
209211
import 'hardhat-contract-sizer'
210-
import 'solidity-coverage'
211-
import '@hashgraph/sdk'
212+
import 'hardhat-gas-reporter'
212213
import Configuration from '@configuration'
213214
import '@tasks'
214215

@@ -223,6 +224,12 @@ const config: HardhatUserConfig = {
223224
evmVersion: 'london',
224225
},
225226
},
227+
paths: {
228+
sources: './contracts',
229+
tests: './test/unitTests',
230+
cache: './cache',
231+
artifacts: './artifacts',
232+
},
226233
defaultNetwork: 'hardhat',
227234
networks: {
228235
hardhat: {
@@ -254,9 +261,15 @@ const config: HardhatUserConfig = {
254261
contractSizer: {
255262
alphaSort: true,
256263
disambiguatePaths: false,
257-
runOnCompile: true,
264+
runOnCompile: Configuration.contractSizerRunOnCompile,
258265
strict: true,
259266
},
267+
gasReporter: {
268+
enabled: Configuration.reportGas,
269+
showTimeSpent: true,
270+
outputFile: 'gas-report.txt', // Force output to a file
271+
noColors: true, // Recommended for file output
272+
},
260273
typechain: {
261274
outDir: './typechain-types',
262275
target: 'ethers-v5',

0 commit comments

Comments
 (0)