Skip to content

Commit

Permalink
chore: fix bug and add signature for error msgs
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonberg1997 committed Dec 7, 2023
1 parent 7b0e0be commit c146c42
Show file tree
Hide file tree
Showing 14 changed files with 2,071 additions and 15 deletions.
21 changes: 7 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ foundryup
forge install --no-git --no-commit foundry-rs/forge-std@v1.7.3
```

Please make sure your dependency version is as follows:

Node: v12.18.3
Install poetry:
```shell script
curl -sSL https://install.python-poetry.org | python3 -
poetry install
```

Tips: You can manage multi version of Node:
```Shell
Expand Down Expand Up @@ -59,20 +61,11 @@ All system contracts will be flattened and output into `${workspace}/contracts/f

## How to generate mainnet/testnet/QA/local genesis file

You may need install some python dependencies firstly.
Save the following content to `requirements.txt` file, and run `pip install -r requirements.txt` to install them.
```txt
Jinja2==3.1.2
typer==0.9.0
```


Then:
```shell
python scripts/generate.py ${network}
poetry run python -m scripts.generate ${network}
```
Check the `genesis.json` file, and you can get the exact compiled bytecode for different network.
(`python scripts/generate.py --help` for more details)
(`poetry run python -m scripts.generate --help ` for more details)

## How to update contract interface for test

Expand Down
62 changes: 62 additions & 0 deletions abi/bscgovernor.abi
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,19 @@
],
"stateMutability": "view"
},
{
"type": "function",
"name": "governorProtector",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "address"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "hasVoted",
Expand Down Expand Up @@ -711,6 +724,26 @@
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "pause",
"inputs": [],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "paused",
"inputs": [],
"outputs": [
{
"name": "",
"type": "bool",
"internalType": "bool"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "proposalDeadline",
Expand Down Expand Up @@ -1097,6 +1130,13 @@
"outputs": [],
"stateMutability": "payable"
},
{
"type": "function",
"name": "resume",
"inputs": [],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "setLateQuorumVoteExtension",
Expand Down Expand Up @@ -1372,6 +1412,12 @@
],
"anonymous": false
},
{
"type": "event",
"name": "Paused",
"inputs": [],
"anonymous": false
},
{
"type": "event",
"name": "ProposalCanceled",
Expand Down Expand Up @@ -1535,6 +1581,12 @@
],
"anonymous": false
},
{
"type": "event",
"name": "Resumed",
"inputs": [],
"anonymous": false
},
{
"type": "event",
"name": "TimelockChange",
Expand Down Expand Up @@ -1677,6 +1729,11 @@
"name": "Empty",
"inputs": []
},
{
"type": "error",
"name": "GovernorPaused",
"inputs": []
},
{
"type": "error",
"name": "InvalidValue",
Expand All @@ -1703,6 +1760,11 @@
"name": "OnlyCoinbase",
"inputs": []
},
{
"type": "error",
"name": "OnlyGovernorProtector",
"inputs": []
},
{
"type": "error",
"name": "OnlySystemContract",
Expand Down
48 changes: 48 additions & 0 deletions abi/stakehub.abi
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,54 @@
],
"stateMutability": "view"
},
{
"type": "function",
"name": "getValidatorRewardRecord",
"inputs": [
{
"name": "operatorAddress",
"type": "address",
"internalType": "address"
},
{
"name": "dayIndex",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "getValidatorTotalPooledBNBRecord",
"inputs": [
{
"name": "operatorAddress",
"type": "address",
"internalType": "address"
},
{
"name": "dayIndex",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "initialize",
Expand Down
37 changes: 37 additions & 0 deletions abi/systemreward.abi
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,19 @@
],
"stateMutability": "view"
},
{
"type": "function",
"name": "MAX_REWARDS_FOR_FINALITY",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "RELAYERHUB_CONTRACT_ADDR",
Expand Down Expand Up @@ -365,6 +378,30 @@
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "claimRewardsforFinality",
"inputs": [
{
"name": "to",
"type": "address",
"internalType": "address payable"
},
{
"name": "amount",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "isOperator",
Expand Down
24 changes: 24 additions & 0 deletions abi/tokenhub.abi
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,30 @@
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "claimRewardsforFinality",
"inputs": [
{
"name": "",
"type": "address",
"internalType": "address payable"
},
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "getBep2SymbolByContractAddr",
Expand Down
4 changes: 4 additions & 0 deletions contracts/BC_fusion/BSCGovernor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ contract BSCGovernor is
uint64 private constant INIT_MIN_PERIOD_AFTER_QUORUM = uint64(1 days);

/*----------------- errors -----------------*/
// @dev error signature: 0x584a7938
error NotWhitelisted();
// @dev error signature: 0x11b6707f
error TotalSupplyNotEnough();
// @dev error signature: 0xe96776bf
error GovernorPaused();
// @dev error signature: 0x286300de
error OnlyGovernorProtector();

/*----------------- events -----------------*/
Expand Down
2 changes: 2 additions & 0 deletions contracts/BC_fusion/GovToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ contract GovToken is
string private constant SYMBOL = "govBNB";

/*----------------- errors -----------------*/
// @dev error signature: 0x8cd22d19
error TransferNotAllowed();
// @dev error signature: 0x20287471
error ApproveNotAllowed();

/*----------------- storage -----------------*/
Expand Down
10 changes: 10 additions & 0 deletions contracts/BC_fusion/StakeCredit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,25 @@ contract StakeCredit is System, Initializable, ReentrancyGuardUpgradeable, ERC20
uint256 private constant COMMISSION_RATE_BASE = 10_000; // 100%

/*----------------- errors -----------------*/
// @dev error signature: 0x2fe8dae9
error ZeroTotalShares();
// @dev error signature: 0xf6ed9ce0
error ZeroTotalPooledBNB();
// @dev error signature: 0x8cd22d19
error TransferNotAllowed();
// @dev error signature: 0x20287471
error ApproveNotAllowed();
// @dev error signature: 0x858f9ae4
error WrongInitContext();
// @dev error signature: 0x90b8ec18
error TransferFailed();
// @dev error signature: 0x1f2a2005
error ZeroAmount();
// @dev error signature: 0xf4d678b8
error InsufficientBalance();
// @dev error signature: 0xad418937
error NoUnbondRequest();
// @dev error signature: 0x0f363824
error NoClaimableUnbondRequest();

/*----------------- storage -----------------*/
Expand Down
Loading

0 comments on commit c146c42

Please sign in to comment.