|
| 1 | +// Copyright © 2023 Kaleido, Inc. |
| 2 | +// |
| 3 | +// SPDX-License-Identifier: Apache-2.0 |
| 4 | +// |
| 5 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +// you may not use this file except in compliance with the License. |
| 7 | +// You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, software |
| 12 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +// See the License for the specific language governing permissions and |
| 15 | +// limitations under the License. |
| 16 | + |
| 17 | +package cmd |
| 18 | + |
| 19 | +import ( |
| 20 | + "context" |
| 21 | + "fmt" |
| 22 | + "path/filepath" |
| 23 | + |
| 24 | + "github.com/spf13/cobra" |
| 25 | + |
| 26 | + "github.com/hyperledger/firefly-cli/internal/log" |
| 27 | + "github.com/hyperledger/firefly-cli/internal/stacks" |
| 28 | + "github.com/hyperledger/firefly-cli/pkg/types" |
| 29 | +) |
| 30 | + |
| 31 | +var initTezosCmd = &cobra.Command{ |
| 32 | + Use: "tezos [stack_name] [member_count]", |
| 33 | + Short: "Create a new FireFly local dev stack using an Tezos blockchain", |
| 34 | + Long: `Create a new FireFly local dev stack using an Tezos blockchain`, |
| 35 | + Args: cobra.MaximumNArgs(2), |
| 36 | + RunE: func(cmd *cobra.Command, args []string) error { |
| 37 | + ctx := log.WithVerbosity(context.Background(), verbose) |
| 38 | + ctx = log.WithLogger(ctx, logger) |
| 39 | + stackManager := stacks.NewStackManager(ctx) |
| 40 | + initOptions.BlockchainProvider = types.BlockchainProviderTezos.String() |
| 41 | + initOptions.BlockchainConnector = types.BlockchainConnectorTezosconnect.String() |
| 42 | + initOptions.BlockchainNodeProvider = types.BlockchainNodeProviderRemoteRPC.String() |
| 43 | + // By default we turn off multiparty mode while it's not supported yet |
| 44 | + initOptions.MultipartyEnabled = false |
| 45 | + initOptions.TokenProviders = []string{} |
| 46 | + if err := initCommon(args); err != nil { |
| 47 | + return err |
| 48 | + } |
| 49 | + if err := stackManager.InitStack(&initOptions); err != nil { |
| 50 | + stackManager.RemoveStack() |
| 51 | + return err |
| 52 | + } |
| 53 | + fmt.Printf("Stack '%s' created!\nTo start your new stack run:\n\n%s start %s\n", initOptions.StackName, rootCmd.Use, initOptions.StackName) |
| 54 | + fmt.Printf("\nYour docker compose file for this stack can be found at: %s\n\n", filepath.Join(stackManager.Stack.StackDir, "docker-compose.yml")) |
| 55 | + return nil |
| 56 | + }, |
| 57 | +} |
| 58 | + |
| 59 | +func init() { |
| 60 | + initTezosCmd.Flags().IntVar(&initOptions.BlockPeriod, "block-period", -1, "Block period in seconds. Default is variable based on selected blockchain provider.") |
| 61 | + initTezosCmd.Flags().StringVar(&initOptions.ContractAddress, "contract-address", "", "Do not automatically deploy a contract, instead use a pre-configured address") |
| 62 | + initTezosCmd.Flags().StringVar(&initOptions.RemoteNodeURL, "remote-node-url", "", "For cases where the node is pre-existing and running remotely") |
| 63 | + |
| 64 | + initCmd.AddCommand(initTezosCmd) |
| 65 | +} |
0 commit comments