Skip to content

Commit

Permalink
update annotations and script
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonberg1997 committed Dec 8, 2023
1 parent d33175f commit 812d2e1
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 55 deletions.
8 changes: 4 additions & 4 deletions contracts/BC_fusion/BSCGovernor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ contract BSCGovernor is
uint64 private constant INIT_MIN_PERIOD_AFTER_QUORUM = uint64(1 days);

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

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

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

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

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

/*----------------- storage -----------------*/
Expand Down
44 changes: 22 additions & 22 deletions contracts/BC_fusion/StakeHub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,49 +31,49 @@ contract StakeHub is System, Initializable {
hex"00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000";

/*----------------- errors -----------------*/
// @dev error signature: 0xd7485e8f
// @notice signature: 0xd7485e8f
error StakeHubPaused();
// @dev error signature: 0xb1d02c3d
// @notice signature: 0xb1d02c3d
error InBlackList();
// @dev error signature: 0xf2771a99
// @notice signature: 0xf2771a99
error OnlyAssetProtector();
// @dev error signature: 0x5f28f62b
// @notice signature: 0x5f28f62b
error ValidatorExisted();
// @dev error signature: 0xfdf4600b
// @notice signature: 0xfdf4600b
error ValidatorNotExist();
// @dev error signature: 0x4b6b857d
// @notice signature: 0x4b6b857d
error ValidatorNotJailed();
// @dev error signature: 0x3cdeb0ea
// @notice signature: 0x3cdeb0ea
error DuplicateConsensusAddress();
// @dev error signature: 0x11fdb947
// @notice signature: 0x11fdb947
error DuplicateVoteAddress();
// @dev error signature: 0x2f64097e
// @notice signature: 0x2f64097e
error SelfDelegationNotEnough();
// @dev error signature: 0xdc81db85
// @notice signature: 0xdc81db85
error InvalidCommission();
// @dev error signature: 0x5dba5ad7
// @notice signature: 0x5dba5ad7
error InvalidMoniker();
// @dev error signature: 0x2c8fc796
// @notice signature: 0x2c8fc796
error InvalidVoteAddress();
// @dev error signature: 0xca40c236
// @notice signature: 0xca40c236
error InvalidConsensusAddress();
// @dev error signature: 0x3f259b7a
// @notice signature: 0x3f259b7a
error UpdateTooFrequently();
// @dev error signature: 0x5c32dd9c
// @notice signature: 0x5c32dd9c
error JailTimeNotExpired();
// @dev error signature: 0xdc6f0bdd
// @notice signature: 0xdc6f0bdd
error DelegationAmountTooSmall();
// @dev error signature: 0x64689203
// @notice signature: 0x64689203
error OnlySelfDelegation();
// @dev error signature: 0x9811e0c7
// @notice signature: 0x9811e0c7
error ZeroShares();
// @dev error signature: 0xf0e3e629
// @notice signature: 0xf0e3e629
error SameValidator();
// @dev error signature: 0x413361db
// @notice signature: 0x413361db
error NoMoreFelonyToday();
// @dev error signature: 0x37233762
// @notice signature: 0x37233762
error AlreadySlashed();
// @dev error signature: 0x90b8ec18
// @notice signature: 0x90b8ec18
error TransferFailed();

/*----------------- storage -----------------*/
Expand Down
10 changes: 5 additions & 5 deletions contracts/BC_fusion/System.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ contract System {
address internal constant TOKEN_RECOVER_PORTAL_ADDR = 0x0000000000000000000000000000000000003000;

/*----------------- errors -----------------*/
// @dev error signature: 0x97b88354
// @notice signature: 0x97b88354
error UnknownParam(string key, bytes value);
// @dev error signature: 0x0a5a6041
// @notice signature: 0x0a5a6041
error InvalidValue(string key, bytes value);
// @dev error signature: 0x116c64a8
// @notice signature: 0x116c64a8
error OnlyCoinbase();
// @dev error signature: 0x83f1b1d3
// @notice signature: 0x83f1b1d3
error OnlyZeroGasPrice();
// @dev error signature: 0xf22c4390
// @notice signature: 0xf22c4390
error OnlySystemContract(address systemContract);

/*----------------- events -----------------*/
Expand Down
20 changes: 10 additions & 10 deletions contracts/BC_fusion/TokenRecoverPortal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,25 @@ contract TokenRecoverPortal is System, Initializable, ReentrancyGuardUpgradeable
}

/*----------------- errors -----------------*/
// @dev error signature: 0x3e493100
// @notice signature: 0x3e493100
error AlreadyRecovered();
// @dev error signature: 0x09bde339
// @notice signature: 0x09bde339
error InvalidProof();
// @dev error signature: 0xad60149e
// @notice signature: 0xad60149e
error InvalidApprovalSignature();
// @dev error signature: 0x8152ea1b
// @notice signature: 0x8152ea1b
error InvalidOwnerPubKeyLength();
// @dev error signature: 0xbc97af2e
// @notice signature: 0xbc97af2e
error InvalidOwnerSignatureLength();
// @dev error signature: 0xf36660de
// @notice signature: 0xf36660de
error MerkleRootAlreadyInitiated();
// @dev error signature: 0x57407297
// @notice signature: 0x57407297
error MerkleRootNotInitialize();
// @dev error signature: 0xc629ac81
// @notice signature: 0xc629ac81
error TokenRecoverPortalPaused();
// @dev error signature: 0xb1d02c3d
// @notice signature: 0xb1d02c3d
error InBlackList();
// @dev error signature: 0xf2771a99
// @notice signature: 0xf2771a99
error OnlyAssetProtector();

/*----------------- events -----------------*/
Expand Down
4 changes: 2 additions & 2 deletions scripts/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def generate_validators(
def generate_error_sig(dir_path: str = "./contracts/BC_fusion"):
dir_path = os.path.join(work_dir, dir_path)

annotation_prefix = " // @dev error signature: "
annotation_prefix = " // @notice signature: "
pattern = re.compile(r"\s{4}error\s[a-zA-Z]*\(.*\);\s$")
for file in os.listdir(dir_path):
if file.endswith(".sol"):
Expand All @@ -430,7 +430,7 @@ def generate_error_sig(dir_path: str = "./contracts/BC_fusion"):
# remove variable names
match = re.search(r"\((.*?)\)", error_msg)
if match and match.group(1) != "":
variables = [v.split()[0] for v in match.group(1).split(",")]
variables = [v.split()[0].strip() for v in match.group(1).split(",")]
error_msg = re.sub(r"\((.*?)\)", f"({','.join(variables)})", error_msg)
sig = Web3.keccak(text=error_msg)[:4].hex()
line = annotation_prefix + sig + "\n" + line
Expand Down

0 comments on commit 812d2e1

Please sign in to comment.