Skip to content

Commit

Permalink
Deploy child chain mintable predicates (#1516)
Browse files Browse the repository at this point in the history
* Introduce mintable predicates

* Introduce new contracts and deploy rootchain ones

* Simplify and unify all initializers to use initContract function

* Update SC spec

* Initialize child chain mintable predicates

* Rebase fix

* Remove dead code
  • Loading branch information
Stefan-Ethernal committed May 29, 2023
1 parent 44bbefc commit a7d36d1
Show file tree
Hide file tree
Showing 13 changed files with 737 additions and 369 deletions.
32 changes: 29 additions & 3 deletions command/genesis/polybft_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,16 @@ func (p *genesisParams) deployContracts(totalStake *big.Int,

if !params.nativeTokenConfig.IsMintable {
genesisContracts = append(genesisContracts,
&contractInfo{artifact: contractsapi.NativeERC20, address: contracts.NativeERC20TokenContract})
&contractInfo{
artifact: contractsapi.NativeERC20,
address: contracts.NativeERC20TokenContract,
})
} else {
genesisContracts = append(genesisContracts,
&contractInfo{artifact: contractsapi.NativeERC20Mintable, address: contracts.NativeERC20TokenContract})
&contractInfo{
artifact: contractsapi.NativeERC20Mintable,
address: contracts.NativeERC20TokenContract,
})
}

if len(params.bridgeAllowListAdmin) != 0 || len(params.bridgeBlockListAdmin) != 0 {
Expand All @@ -386,6 +392,7 @@ func (p *genesisParams) deployContracts(totalStake *big.Int,
address: contracts.ChildERC1155PredicateContract,
})
} else {
// rootchain originated tokens predicates
genesisContracts = append(genesisContracts,
&contractInfo{
artifact: contractsapi.ChildERC20Predicate,
Expand All @@ -403,6 +410,25 @@ func (p *genesisParams) deployContracts(totalStake *big.Int,
artifact: contractsapi.ChildERC1155Predicate,
address: contracts.ChildERC1155PredicateContract,
})

// childchain originated tokens predicates
genesisContracts = append(genesisContracts,
&contractInfo{
artifact: contractsapi.RootMintableERC20Predicate,
address: contracts.RootMintableERC20PredicateContract,
})

genesisContracts = append(genesisContracts,
&contractInfo{
artifact: contractsapi.RootMintableERC721Predicate,
address: contracts.RootMintableERC721PredicateContract,
})

genesisContracts = append(genesisContracts,
&contractInfo{
artifact: contractsapi.RootMintableERC1155Predicate,
address: contracts.RootMintableERC1155PredicateContract,
})
}

allocations := make(map[types.Address]*chain.GenesisAccount, len(genesisContracts)+1)
Expand All @@ -416,7 +442,7 @@ func (p *genesisParams) deployContracts(totalStake *big.Int,

if rewardTokenByteCode != nil {
// if reward token is provided in genesis then, add it to allocations
// to RewardTokenContract address and update polybftConfig
// to RewardTokenContract address and update Polybft config
allocations[contracts.RewardTokenContract] = &chain.GenesisAccount{
Balance: big.NewInt(0),
Code: rewardTokenByteCode,
Expand Down

0 comments on commit a7d36d1

Please sign in to comment.