Skip to content

Commit a38c7fd

Browse files
authored
Merge branch 'hyperledger:main' into tobytobias#271
2 parents 6529c63 + 5f7fbf7 commit a38c7fd

32 files changed

+658
-72
lines changed

cmd/init_tezos.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
}

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,20 @@ module github.com/hyperledger/firefly-cli
1919
go 1.16
2020

2121
require (
22+
blockwatch.cc/tzgo v1.17.1
2223
github.com/briandowns/spinner v1.12.0
2324
github.com/btcsuite/btcd v0.22.1
2425
github.com/google/go-containerregistry v0.8.0
2526
github.com/hyperledger/firefly-common v1.1.2
2627
github.com/hyperledger/firefly-signer v0.9.6
27-
github.com/mattn/go-isatty v0.0.14
28+
github.com/mattn/go-isatty v0.0.19
2829
github.com/miracl/conflate v1.2.1
2930
github.com/mitchellh/go-homedir v1.1.0
3031
github.com/otiai10/copy v1.7.0
3132
github.com/spf13/cobra v1.5.0
3233
github.com/spf13/viper v1.12.1-0.20220712161005-5247643f0235
3334
github.com/stretchr/testify v1.8.0
34-
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e
35+
golang.org/x/crypto v0.10.0
3536
gopkg.in/yaml.v2 v2.4.0
3637
gopkg.in/yaml.v3 v3.0.1
3738
)

go.sum

Lines changed: 51 additions & 10 deletions
Large diffs are not rendered by default.

internal/blockchain/ethereum/accounts.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package ethereum
1919
import (
2020
"context"
2121
"fmt"
22-
"io/ioutil"
2322
"os"
2423
"path/filepath"
2524

@@ -45,7 +44,7 @@ func CreateWalletFile(outputDirectory, prefix, password string) (*secp256k1.KeyP
4544
} else {
4645
filename = filepath.Join(outputDirectory, keyPair.Address.String()[2:])
4746
}
48-
err = ioutil.WriteFile(filename, wallet.JSON(), 0755)
47+
err = os.WriteFile(filename, wallet.JSON(), 0755)
4948
if err != nil {
5049
return nil, "", err
5150
}

internal/blockchain/ethereum/besu/besu_provider.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package besu
1919
import (
2020
"context"
2121
"fmt"
22-
"io/ioutil"
2322
"os"
2423
"path"
2524
"path/filepath"
@@ -80,7 +79,7 @@ func (p *BesuProvider) WriteConfig(options *types.InitOptions) error {
8079
// Generate node key
8180
nodeAddress, nodeKey := ethereum.GenerateAddressAndPrivateKey()
8281
// Write the node key to disk
83-
if err := ioutil.WriteFile(filepath.Join(initDir, "blockchain", "nodeKey"), []byte(nodeKey), 0755); err != nil {
82+
if err := os.WriteFile(filepath.Join(initDir, "blockchain", "nodeKey"), []byte(nodeKey), 0755); err != nil {
8483
return err
8584
}
8685
// Drop the 0x on the front of the address here because that's what is expected in the genesis.json

internal/blockchain/ethereum/besu/genesis.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package besu
1919
import (
2020
"encoding/json"
2121
"fmt"
22-
"io/ioutil"
22+
"os"
2323
"path/filepath"
2424
"strings"
2525
)
@@ -64,7 +64,7 @@ type Alloc struct {
6464

6565
func (g *Genesis) WriteGenesisJson(filename string) error {
6666
genesisJsonBytes, _ := json.MarshalIndent(g, "", " ")
67-
if err := ioutil.WriteFile(filepath.Join(filename), genesisJsonBytes, 0755); err != nil {
67+
if err := os.WriteFile(filepath.Join(filename), genesisJsonBytes, 0755); err != nil {
6868
return err
6969
}
7070
return nil

internal/blockchain/ethereum/connector/ethconnect/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package ethconnect
1818

1919
import (
2020
"fmt"
21-
"io/ioutil"
21+
"os"
2222
"path/filepath"
2323

2424
"github.com/hyperledger/firefly-cli/internal/blockchain/ethereum/connector"
@@ -59,7 +59,7 @@ type HTTP struct {
5959

6060
func (e *Config) WriteConfig(filename string, extraConnectorConfigPath string) error {
6161
configYamlBytes, _ := yaml.Marshal(e)
62-
if err := ioutil.WriteFile(filepath.Join(filename), configYamlBytes, 0755); err != nil {
62+
if err := os.WriteFile(filepath.Join(filename), configYamlBytes, 0755); err != nil {
6363
return err
6464
}
6565
if extraConnectorConfigPath != "" {
@@ -71,7 +71,7 @@ func (e *Config) WriteConfig(filename string, extraConnectorConfigPath string) e
7171
if err != nil {
7272
return err
7373
}
74-
if err := ioutil.WriteFile(filename, bytes, 0755); err != nil {
74+
if err := os.WriteFile(filename, bytes, 0755); err != nil {
7575
return err
7676
}
7777
}

internal/blockchain/ethereum/connector/evmconnect/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package evmconnect
1818

1919
import (
2020
"fmt"
21-
"io/ioutil"
21+
"os"
2222
"path/filepath"
2323

2424
"github.com/hyperledger/firefly-cli/internal/blockchain/ethereum/connector"
@@ -76,7 +76,7 @@ type GasOracleConfig struct {
7676

7777
func (e *Config) WriteConfig(filename string, extraEvmconnectConfigPath string) error {
7878
configYamlBytes, _ := yaml.Marshal(e)
79-
if err := ioutil.WriteFile(filepath.Join(filename), configYamlBytes, 0755); err != nil {
79+
if err := os.WriteFile(filepath.Join(filename), configYamlBytes, 0755); err != nil {
8080
return err
8181
}
8282
if extraEvmconnectConfigPath != "" {
@@ -88,7 +88,7 @@ func (e *Config) WriteConfig(filename string, extraEvmconnectConfigPath string)
8888
if err != nil {
8989
return err
9090
}
91-
if err := ioutil.WriteFile(filename, bytes, 0755); err != nil {
91+
if err := os.WriteFile(filename, bytes, 0755); err != nil {
9292
return err
9393
}
9494
}

internal/blockchain/ethereum/contracts.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package ethereum
1919
import (
2020
"context"
2121
"encoding/json"
22-
"io/ioutil"
22+
"os"
2323

2424
"github.com/hyperledger/firefly-cli/internal/blockchain/ethereum/ethtypes"
2525
"github.com/hyperledger/firefly-cli/internal/docker"
@@ -32,7 +32,7 @@ type truffleCompiledContract struct {
3232
}
3333

3434
func ReadTruffleCompiledContract(filePath string) (*ethtypes.CompiledContracts, error) {
35-
d, _ := ioutil.ReadFile(filePath)
35+
d, _ := os.ReadFile(filePath)
3636
var truffleCompiledContract *truffleCompiledContract
3737
err := json.Unmarshal(d, &truffleCompiledContract)
3838
if err != nil {
@@ -51,7 +51,7 @@ func ReadTruffleCompiledContract(filePath string) (*ethtypes.CompiledContracts,
5151
}
5252

5353
func ReadSolcCompiledContract(filePath string) (*ethtypes.CompiledContracts, error) {
54-
d, _ := ioutil.ReadFile(filePath)
54+
d, _ := os.ReadFile(filePath)
5555
var contracts *ethtypes.CompiledContracts
5656
err := json.Unmarshal(d, &contracts)
5757
if err != nil {

internal/blockchain/ethereum/ethsigner/accounts.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package ethsigner
1919
import (
2020
"context"
2121
"fmt"
22-
"io/ioutil"
22+
"os"
2323
"path/filepath"
2424

2525
"github.com/hyperledger/firefly-cli/internal/docker"
@@ -38,7 +38,7 @@ key-file = "/data/keystore/%s"
3838
password-file = "/data/password"
3939
`, keyFile)
4040
filename := filepath.Join(outputDirectory, fmt.Sprintf("%s.toml", keyFile))
41-
return filename, ioutil.WriteFile(filename, []byte(toml), 0755)
41+
return filename, os.WriteFile(filename, []byte(toml), 0755)
4242
}
4343

4444
func (p *EthSignerProvider) copyTomlFileToVolume(ctx context.Context, tomlFilePath, volumeName string) error {

0 commit comments

Comments
 (0)