Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
Introduce ACL mintable predicates
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Ethernal committed May 28, 2023
1 parent feedf32 commit 3dc7ec0
Show file tree
Hide file tree
Showing 8 changed files with 295 additions and 97 deletions.
6 changes: 3 additions & 3 deletions command/genesis/polybft_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,19 +375,19 @@ func (p *genesisParams) deployContracts(totalStake *big.Int,
if len(params.bridgeAllowListAdmin) != 0 || len(params.bridgeBlockListAdmin) != 0 {
genesisContracts = append(genesisContracts,
&contractInfo{
artifact: contractsapi.ChildERC20PredicateAccessList,
artifact: contractsapi.ChildERC20PredicateACL,
address: contracts.ChildERC20PredicateContract,
})

genesisContracts = append(genesisContracts,
&contractInfo{
artifact: contractsapi.ChildERC721PredicateAccessList,
artifact: contractsapi.ChildERC721PredicateACL,
address: contracts.ChildERC721PredicateContract,
})

genesisContracts = append(genesisContracts,
&contractInfo{
artifact: contractsapi.ChildERC1155PredicateAccessList,
artifact: contractsapi.ChildERC1155PredicateACL,
address: contracts.ChildERC1155PredicateContract,
})
} else {
Expand Down
6 changes: 3 additions & 3 deletions consensus/polybft/contracts_initializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func getInitERC20PredicateInput(config *BridgeConfig, childOriginatedTokens bool

// getInitChildERC20PredicateAccessListInput builds input parameters for ChildERC20PredicateAccessList SC initialization
func getInitChildERC20PredicateAccessListInput(config *BridgeConfig, owner types.Address) ([]byte, error) {
params := &contractsapi.InitializeChildERC20PredicateAccessListFn{
params := &contractsapi.InitializeChildERC20PredicateACLFn{
NewL2StateSender: contracts.L2StateSenderContract,
NewStateReceiver: contracts.StateReceiverContract,
NewRootERC20Predicate: config.RootERC20PredicateAddr,
Expand Down Expand Up @@ -108,7 +108,7 @@ func getInitERC721PredicateInput(config *BridgeConfig, childOriginatedTokens boo
// getInitChildERC721PredicateAccessListInput builds input parameters
// for ChildERC721PredicateAccessList SC initialization
func getInitChildERC721PredicateAccessListInput(config *BridgeConfig, owner types.Address) ([]byte, error) {
params := &contractsapi.InitializeChildERC721PredicateAccessListFn{
params := &contractsapi.InitializeChildERC721PredicateACLFn{
NewL2StateSender: contracts.L2StateSenderContract,
NewStateReceiver: contracts.StateReceiverContract,
NewRootERC721Predicate: config.RootERC721PredicateAddr,
Expand Down Expand Up @@ -146,7 +146,7 @@ func getInitERC1155PredicateInput(config *BridgeConfig, childOriginatedTokens bo
// getInitChildERC1155PredicateAccessListInput builds input parameters
// for ChildERC1155PredicateAccessList SC initialization
func getInitChildERC1155PredicateAccessListInput(config *BridgeConfig, owner types.Address) ([]byte, error) {
params := &contractsapi.InitializeChildERC1155PredicateAccessListFn{
params := &contractsapi.InitializeChildERC1155PredicateACLFn{
NewL2StateSender: contracts.L2StateSenderContract,
NewStateReceiver: contracts.StateReceiverContract,
NewRootERC1155Predicate: config.RootERC1155PredicateAddr,
Expand Down
36 changes: 31 additions & 5 deletions consensus/polybft/contractsapi/artifacts-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ import (
"os"
"path"
"runtime"
"strings"

"github.com/0xPolygon/polygon-edge/consensus/polybft/contractsapi/artifact"
"github.com/dave/jennifer/jen"

"github.com/0xPolygon/polygon-edge/consensus/polybft/contractsapi/artifact"
)

const (
extension = ".sol"
)

func main() {
Expand Down Expand Up @@ -49,12 +55,16 @@ func main() {
},
{
"child/ChildERC20PredicateAccessList.sol",
"ChildERC20PredicateAccessList",
"ChildERC20PredicateACL",
},
{
"child/RootMintableERC20Predicate.sol",
"RootMintableERC20Predicate",
},
{
"child/RootMintableERC20PredicateAccessList.sol",
"RootMintableERC20PredicateACL",
},
{
"child/ChildERC721.sol",
"ChildERC721",
Expand All @@ -65,12 +75,16 @@ func main() {
},
{
"child/ChildERC721PredicateAccessList.sol",
"ChildERC721PredicateAccessList",
"ChildERC721PredicateACL",
},
{
"child/RootMintableERC721Predicate.sol",
"RootMintableERC721Predicate",
},
{
"child/RootMintableERC721PredicateAccessList.sol",
"RootMintableERC721PredicateACL",
},
{
"child/ChildERC1155.sol",
"ChildERC1155",
Expand All @@ -81,12 +95,16 @@ func main() {
},
{
"child/ChildERC1155PredicateAccessList.sol",
"ChildERC1155PredicateAccessList",
"ChildERC1155PredicateACL",
},
{
"child/RootMintableERC1155Predicate.sol",
"RootMintableERC1155Predicate",
},
{
"child/RootMintableERC1155PredicateAccessList.sol",
"RootMintableERC1155PredicateACL",
},
{
"child/System.sol",
"System",
Expand Down Expand Up @@ -170,7 +188,7 @@ func main() {
}

for _, v := range readContracts {
artifactBytes, err := artifact.ReadArtifactData(scpath, v.Path, v.Name)
artifactBytes, err := artifact.ReadArtifactData(scpath, v.Path, getContractName(v.Path))
if err != nil {
log.Fatal(err)
}
Expand All @@ -188,3 +206,11 @@ func main() {
log.Fatal(err)
}
}

// getContractName extracts smart contract name from provided path
func getContractName(path string) string {
pathSegments := strings.Split(path, string([]rune{os.PathSeparator}))
nameSegment := pathSegments[len(pathSegments)-1]

return strings.Split(nameSegment, extension)[0]
}
42 changes: 36 additions & 6 deletions consensus/polybft/contractsapi/bindings-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ func main() {
[]string{},
},
{
"ChildERC20PredicateAccessList",
gensc.ChildERC20PredicateAccessList,
"ChildERC20PredicateACL",
gensc.ChildERC20PredicateACL,
false,
[]string{
"initialize",
Expand All @@ -119,6 +119,16 @@ func main() {
},
[]string{},
},
{
"RootMintableERC20PredicateACL",
gensc.RootMintableERC20PredicateACL,
false,
[]string{
"initialize",
"depositTo",
},
[]string{},
},
{
"NativeERC20",
gensc.NativeERC20,
Expand Down Expand Up @@ -210,8 +220,8 @@ func main() {
[]string{},
},
{
"ChildERC1155PredicateAccessList",
gensc.ChildERC1155PredicateAccessList,
"ChildERC1155PredicateACL",
gensc.ChildERC1155PredicateACL,
false,
[]string{
"initialize",
Expand All @@ -229,6 +239,16 @@ func main() {
},
[]string{},
},
{
"RootMintableERC1155PredicateACL",
gensc.RootMintableERC1155PredicateACL,
false,
[]string{
"initialize",
"depositBatch",
},
[]string{},
},
{
"ChildERC1155",
gensc.ChildERC1155,
Expand Down Expand Up @@ -280,8 +300,8 @@ func main() {
[]string{},
},
{
"ChildERC721PredicateAccessList",
gensc.ChildERC721PredicateAccessList,
"ChildERC721PredicateACL",
gensc.ChildERC721PredicateACL,
false,
[]string{
"initialize",
Expand All @@ -299,6 +319,16 @@ func main() {
},
[]string{},
},
{
"RootMintableERC721PredicateACL",
gensc.RootMintableERC721PredicateACL,
false,
[]string{
"initialize",
"depositBatch",
},
[]string{},
},
{
"ChildERC721",
gensc.ChildERC721,
Expand Down
Loading

0 comments on commit 3dc7ec0

Please sign in to comment.