Skip to content

Commit e878ace

Browse files
committed
more documentation
Signed-off-by: Alexander Diemand <[email protected]>
1 parent 68b5ed6 commit e878ace

File tree

3 files changed

+139
-0
lines changed

3 files changed

+139
-0
lines changed

doc/Deployment.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Deployment
2+
3+
Depending on the target chain, we run for deployment of the contracts:
4+
5+
## Deploy to local node
6+
7+
First, run a node in another terminal:
8+
```sh
9+
cd bca-token-solidity
10+
npx hardhat compile
11+
npx hardhat node
12+
```
13+
14+
* if this our first run of the node, then we can import the list of output accounts into MetaMask
15+
* in other cases it might be necessary to "clear activity" in MetaMask for these accounts so it resyncs with the node and starts with the first block
16+
17+
Then, deploy the ERC20 contract along with the service manager contract:
18+
19+
```sh
20+
npx hardhat ignition deploy ignition/modules/BCA_Token.ts --network localhost
21+
npx hardhat ignition deploy ignition/modules/BCA_ServiceManager.ts --network localhost
22+
```
23+
24+
## Deploy to Amoy testnet
25+
26+
- tbd
27+
28+
## Deploy to Polygon mainnet
29+
30+
- tbd

doc/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919

2020
[Services](./Services.md)
2121

22+
## Testing and estimating Gas costs
23+
24+
[Testing](./Testing.md)
25+
26+
## Deployment
27+
28+
[Deployment](./Deployment.md)
2229

2330
## User authentication
2431

doc/Testing.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Testing
2+
3+
Tests are implemented in [bca-token-solidity/test](./bca-token-solidity/test/) and can be run:
4+
5+
```sh
6+
cd bca-token-solidity
7+
npx hardhat test
8+
```
9+
10+
# Test coverage
11+
12+
How much of the contract's code is covered by tests? This can be answered by:
13+
14+
```sh
15+
cd bca-token-solidity
16+
npx hardhat coverage
17+
```
18+
19+
Which outputs as of today (2024-11-23):
20+
21+
```sh
22+
------------------------------|----------|----------|----------|----------|----------------|
23+
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
24+
------------------------------|----------|----------|----------|----------|----------------|
25+
contracts/ | 88.66 | 71.82 | 89.29 | 91.37 | |
26+
BCA_ERC20_nf.sol | 100 | 68.75 | 100 | 100 | |
27+
BCA_Funding24.sol | 84.62 | 81.25 | 100 | 88.89 | 64,66 |
28+
BCA_Service.sol | 25 | 25 | 33.33 | 46.15 |... 45,48,50,54 |
29+
BCA_ServiceController.sol | 85.71 | 50 | 66.67 | 88.89 | 43 |
30+
BCA_ServiceInstance.sol | 95.45 | 81.48 | 100 | 96.97 | 141,171 |
31+
BCA_ServiceManager.sol | 100 | 60 | 100 | 100 | |
32+
Iface_Funding24.sol | 100 | 100 | 100 | 100 | |
33+
Iface_Service.sol | 100 | 100 | 100 | 100 | |
34+
Iface_ServiceController.sol | 100 | 100 | 100 | 100 | |
35+
Iface_ServiceInstance.sol | 100 | 100 | 100 | 100 | |
36+
Iface_ServiceManager.sol | 100 | 100 | 100 | 100 | |
37+
------------------------------|----------|----------|----------|----------|----------------|
38+
All files | 88.66 | 71.82 | 89.29 | 91.37 | |
39+
------------------------------|----------|----------|----------|----------|----------------|
40+
```
41+
42+
Clearly, for some of the contracts we have to write some more tests to increase coverage.
43+
44+
# Estimating Gas costs
45+
46+
If we run the tests with the environment variable `REPORT_GAS=true`, then the output will contain information about the Gas usage of the transactions.
47+
48+
```sh
49+
cd bca-token-solidity
50+
REPORT_GAS=true npx hardhat test
51+
```
52+
53+
Will output:
54+
```sh
55+
·----------------------------------------------|---------------------------|--------------|-----------------------------·
56+
| Solc version: 0.8.24 · Optimizer enabled: true · Runs: 1000 · Block limit: 30000000 gas │
57+
···············································|···························|··············|······························
58+
| Methods │
59+
·························|·····················|·············|·············|··············|···············|··············
60+
| Contract · Method · Min · Max · Avg · # calls · usd (avg) │
61+
·························|·····················|·············|·············|··············|···············|··············
62+
| BCAServiceController · newService · - · - · 1106858 · 4 · - │
63+
·························|·····················|·············|·············|··············|···············|··············
64+
| BCAServiceFunding24 · deposit · 100100 · 156994 · 138029 · 12 · - │
65+
·························|·····················|·············|·············|··············|···············|··············
66+
| BCAServiceInstance · makeDeposit · 51323 · 105528 · 101656 · 28 · - │
67+
·························|·····················|·············|·············|··············|···············|··············
68+
| BCAServiceInstance · stop · - · - · 49123 · 4 · - │
69+
·························|·····················|·············|·············|··············|···············|··············
70+
| BCAServiceInstance · withdrawProvider · 70814 · 105014 · 87939 · 9 · - │
71+
·························|·····················|·············|·············|··············|···············|··············
72+
| BCAServiceInstance · withdrawUser · - · - · 73013 · 2 · - │
73+
·························|·····················|·············|·············|··············|···············|··············
74+
| BCAServiceManager · newController · 1385995 · 1402892 · 1394444 · 4 · - │
75+
·························|·····················|·············|·············|··············|···············|··············
76+
| BCAServiceToken · approve · 46388 · 46448 · 46417 · 25 · - │
77+
·························|·····················|·············|·············|··············|···············|··············
78+
| BCAServiceToken · burn · 33963 · 33975 · 33971 · 6 · - │
79+
·························|·····················|·············|·············|··············|···············|··············
80+
| BCAServiceToken · mint · 36620 · 70856 · 61634 · 26 · - │
81+
·························|·····················|·············|·············|··············|···············|··············
82+
| BCAServiceToken · setBurnerAddress · - · - · 56508 · 1 · - │
83+
·························|·····················|·············|·············|··············|···············|··············
84+
| BCAServiceToken · setMinterAddress · - · - · 56486 · 1 · - │
85+
·························|·····················|·············|·············|··············|···············|··············
86+
| BCAServiceToken · setServiceAddress · - · - · 54551 · 2 · - │
87+
·························|·····················|·············|·············|··············|···············|··············
88+
| BCAServiceToken · transfer · 29706 · 51582 · 45948 · 13 · - │
89+
·························|·····················|·············|·············|··············|···············|··············
90+
| BCAServiceToken · transferFrom · - · - · 57616 · 3 · - │
91+
·························|·····················|·············|·············|··············|···············|··············
92+
| Deployments · · % of limit · │
93+
···············································|·············|·············|··············|···············|··············
94+
| BCAServiceFunding24 · - · - · 854510 · 2.8 % · - │
95+
···············································|·············|·············|··············|···············|··············
96+
| BCAServiceInstance · - · - · 769313 · 2.6 % · - │
97+
···············································|·············|·············|··············|···············|··············
98+
| BCAServiceManager · - · - · 1781152 · 5.9 % · - │
99+
···············································|·············|·············|··············|···············|··············
100+
| BCAServiceToken · - · - · 1175977 · 3.9 % · - │
101+
·----------------------------------------------|-------------|-------------|--------------|---------------|-------------·
102+
```

0 commit comments

Comments
 (0)