Skip to content

Commit

Permalink
remove initialize in TokenRecoverPortal.sol
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonberg1997 committed Dec 8, 2023
1 parent 698705a commit c52befa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 30 deletions.
10 changes: 2 additions & 8 deletions contracts/BC_fusion/TokenRecoverPortal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ import "./lib/Utils.sol";
* The BC users can recover the token from TokenHub after the merkle tree root is generated.
* For more details, please refer to the BEP-299(https://github.com/bnb-chain/BEPs/pull/299).
*/
contract TokenRecoverPortal is System, Initializable, ReentrancyGuardUpgradeable {
contract TokenRecoverPortal is System, ReentrancyGuardUpgradeable {
using Utils for string;
using Utils for bytes;

/*----------------- constants -----------------*/
string public constant SOURCE_CHAIN_ID = "Binance-Chain-Ganges";
address public constant INIT_APPROVAL_ADDRESS = 0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa;

/*----------------- storage -----------------*/
address public approvalAddress;
Expand All @@ -33,9 +32,8 @@ contract TokenRecoverPortal is System, Initializable, ReentrancyGuardUpgradeable
// recoveredMap is used to record the recovered token.
mapping(bytes32 => bool) private recoveredMap;

/*----------------- permission control -----------------*/
// assetProtector is the address that is allowed to pause the #recover.
address public assetProtector = 0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa;
address public assetProtector;
// paused is used to pause the #recover.
bool private _paused;

Expand Down Expand Up @@ -95,10 +93,6 @@ contract TokenRecoverPortal is System, Initializable, ReentrancyGuardUpgradeable
// This event is triggered whenever a call to #recover succeeds.
event TokenRecoverRequested(bytes32 tokenSymbol, address account, uint256 amount);

function initialize() external initializer onlyCoinbase onlyZeroGasPrice {
approvalAddress = INIT_APPROVAL_ADDRESS;
}

/**
* isRecovered check if the token is recovered.
* @param node the leaf node of merkle tree.
Expand Down
29 changes: 7 additions & 22 deletions scripts/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,13 @@ def generate_token_hub(max_gas_for_transfer_bnb, max_gas_for_calling_bep20, rewa
replace_parameter(contract, "uint256 constant public INIT_MINIMUM_RELAY_FEE", f"{init_minimum_relay_fee}")


def generate_token_recover_portal(source_chain_id, approval_address, merkle_root):
def generate_token_recover_portal(source_chain_id):
contract = "BC_fusion/TokenRecoverPortal.sol"
backup_file(
os.path.join(work_dir, "contracts", contract), os.path.join(work_dir, "contracts", contract[:-4] + ".bak")
)

replace_parameter(contract, "string public constant SOURCE_CHAIN_ID", f"\"{source_chain_id}\"")
replace_parameter(contract, "address public constant INIT_APPROVAL_ADDRESS", f"{approval_address}")

if merkle_root != "":
insert(contract, "approvalAddress = INIT_APPROVAL_ADDRESS;", f"\t\tmerkle_root = {merkle_root};")
insert(contract, "approvalAddress = INIT_APPROVAL_ADDRESS;", f"\t\tmerkleRootAlreadyInit = true;")


def generate_validator_set(init_burn_ratio, init_validatorset_bytes):
Expand Down Expand Up @@ -230,15 +225,13 @@ def mainnet():
whitelist_1 = "0xb005741528b86F5952469d80A8614591E3c5B632"
whitelist_2 = "0x446AA6E0DC65690403dF3F127750da1322941F3e"
source_chain_id = "Binance-Chain-Tigris"
approval_address = "0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa"
merkle_root = ""

generate_system()
generate_cross_chain()
generate_relayer_hub(whitelist_1, whitelist_2)
generate_tendermint_light_client(init_consensus_bytes)
generate_validator_set(init_burn_ratio, init_validatorset_bytes)
generate_token_recover_portal(source_chain_id, approval_address, merkle_root)
generate_token_recover_portal(source_chain_id)

generate_genesis()
print("Generate genesis of mainnet successfully")
Expand All @@ -257,15 +250,13 @@ def testnet():
whitelist_1 = "0x9fB29AAc15b9A4B7F17c3385939b007540f4d791"
whitelist_2 = "0x37B8516a0F88E65D677229b402ec6C1e0E333004"
source_chain_id = "Binance-Chain-Ganges"
approval_address = "0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa"
merkle_root = ""

generate_system()
generate_cross_chain()
generate_relayer_hub(whitelist_1, whitelist_2)
generate_tendermint_light_client(init_consensus_bytes)
generate_validator_set(init_burn_ratio, init_validatorset_bytes)
generate_token_recover_portal(source_chain_id, approval_address, merkle_root)
generate_token_recover_portal(source_chain_id)

generate_genesis()
print("Generate genesis of testnet successfully")
Expand All @@ -278,10 +269,7 @@ def qa(
whitelist_2: Annotated[
str, typer.Option(help="whitelist relayer2's address")] = "0x42D596440775C90db8d9187b47650986E1063493",
source_chain_id: Annotated[
str, typer.Option(help="source chain id of the token recover portal")] = "Binance-Chain-Ganges",
approval_address: Annotated[str, typer.Option(help="approval address of the token recover portal")
] = "0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa",
merkle_root: Annotated[str, typer.Option(help="merkle root of the token recover portal")] = ""
str, typer.Option(help="source chain id of the token recover portal")] = "Binance-Chain-Ganges"
):
global network, chain_id, hex_chain_id
network = "qa"
Expand All @@ -297,7 +285,7 @@ def qa(
generate_relayer_hub(whitelist_1, whitelist_2)
generate_tendermint_light_client(init_consensus_bytes)
generate_validator_set(init_burn_ratio, init_validatorset_bytes)
generate_token_recover_portal(source_chain_id, approval_address, merkle_root)
generate_token_recover_portal(source_chain_id)

generate_genesis()
print("Generate genesis of qa-net successfully")
Expand All @@ -314,10 +302,7 @@ def local(
whitelist_2: Annotated[
str, typer.Option(help="whitelist relayer2's address")] = "0x316b2Fa7C8a2ab7E21110a4B3f58771C01A71344",
source_chain_id: Annotated[
str, typer.Option(help="source chain id of the token recover portal")] = "Binance-Chain-Ganges",
approval_address: Annotated[str, typer.Option(help="approval address of the token recover portal")
] = "0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa",
merkle_root: Annotated[str, typer.Option(help="merkle root of the token recover portal")] = ""
str, typer.Option(help="source chain id of the token recover portal")] = "Binance-Chain-Ganges"
):
global network, chain_id, hex_chain_id
network = "local"
Expand Down Expand Up @@ -345,7 +330,7 @@ def local(
generate_relayer_hub(whitelist_1, whitelist_2)
generate_tendermint_light_client(init_consensus_bytes)
generate_validator_set(init_burn_ratio, init_validatorset_bytes)
generate_token_recover_portal(source_chain_id, approval_address, merkle_root)
generate_token_recover_portal(source_chain_id)

generate_genesis()
print("Generate genesis of local-net successfully")
Expand Down

0 comments on commit c52befa

Please sign in to comment.