github.com/ChainSafe/chainbridge-core@v1.4.2/chains/evm/cli/centrifuge/deploy.go (about) 1 package centrifuge 2 3 import ( 4 "fmt" 5 6 "github.com/ChainSafe/chainbridge-core/chains/evm/calls/contracts/centrifuge" 7 "github.com/ChainSafe/chainbridge-core/chains/evm/calls/evmtransaction" 8 "github.com/ChainSafe/chainbridge-core/chains/evm/cli/initialize" 9 "github.com/ChainSafe/chainbridge-core/chains/evm/cli/logger" 10 "github.com/ChainSafe/chainbridge-core/util" 11 "github.com/ethereum/go-ethereum/common" 12 "github.com/rs/zerolog/log" 13 "github.com/spf13/cobra" 14 ) 15 16 var deployCmd = &cobra.Command{ 17 Use: "deploy", 18 Short: "Deploy a centrifuge asset store contract", 19 Long: "The deploy subcommand deploys a Centrifuge asset store contract that represents bridged Centrifuge assets", 20 PreRun: func(cmd *cobra.Command, args []string) { 21 logger.LoggerMetadata(cmd.Name(), cmd.Flags()) 22 }, 23 PersistentPreRunE: func(cmd *cobra.Command, args []string) error { 24 return util.CallPersistentPreRun(cmd, args) 25 }, 26 RunE: func(cmd *cobra.Command, args []string) error { 27 c, err := initialize.InitializeClient(url, senderKeyPair) 28 if err != nil { 29 return err 30 } 31 t, err := initialize.InitializeTransactor(gasPrice, evmtransaction.NewTransaction, c, prepare) 32 if err != nil { 33 return err 34 } 35 return DeployCentrifugeAssetStoreCmd(cmd, args, centrifuge.NewAssetStoreContract(c, common.Address{}, t)) 36 }, 37 } 38 39 func BindDeployCmdFlags(cmd *cobra.Command) {} 40 41 func init() { 42 BindDeployCmdFlags(deployCmd) 43 } 44 45 func DeployCentrifugeAssetStoreCmd(cmd *cobra.Command, args []string, contract *centrifuge.AssetStoreContract) error { 46 assetStoreAddress, err := contract.DeployContract() 47 if err != nil { 48 log.Error().Err(fmt.Errorf("centrifuge asset store deploy failed: %w", err)) 49 return err 50 } 51 52 log.Info().Msgf("Deployed Centrifuge asset store to address: %s", assetStoreAddress.String()) 53 return nil 54 }