Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,5 @@ tsconfig.tsbuildinfo
# Generated files
.docusaurus
.cache-loader

dist/
45 changes: 45 additions & 0 deletions cli/.goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of uname.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

# The lines beneath this are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
89 changes: 89 additions & 0 deletions cli/commands/bridge/bridge.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
Copyright © 2023 Hugobyte AI Labs <hello@hugobyte.com>
*/
package bridge

import (
"fmt"
"strconv"
"strings"

"github.com/hugobyte/dive/common"
"github.com/kurtosis-tech/kurtosis/api/golang/core/kurtosis_core_rpc_api_bindings"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

const bridgeMainFunction = "run_btp_setup"

var (
chainA string
chainB string
)

func NewBridgeCmd(diveContext *common.DiveContext) *cobra.Command {

var bridgeCmd = &cobra.Command{
Use: "bridge",
Short: "Command for cross chain communication between two different chains",
Long: `To connect two different chains using any of the supported cross chain communication protocols. This will create an relay to connect two different chains and pass any messages between them.`,
Run: func(cmd *cobra.Command, args []string) {
cmd.Help()
},
}

bridgeCmd.AddCommand(btpBridgeCmd(diveContext))

return bridgeCmd
}

func btpBridgeCmd(diveContext *common.DiveContext) *cobra.Command {

var btpbridgeCmd = &cobra.Command{
Use: "btp",
Short: "Starts Bridge BTP between ChainA and Chain B",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {

enclaveCtx, err := diveContext.GetEnclaveContext()

if err != nil {
logrus.Errorln(err)
}

bridge, _ := cmd.Flags().GetBool("bridge")

params := fmt.Sprintf(`{"args":{"links": {"src": "%s", "dst": "%s"},"bridge":"%s"}}`, chainA, chainB, strconv.FormatBool(bridge))

if strings.ToLower(chainA) == "icon" && strings.ToLower(chainB) == "icon" {

data, _, err := enclaveCtx.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, common.DiveBridgeScript, bridgeMainFunction, params, common.DiveDryRun, common.DiveDefaultParallelism, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{})

if err != nil {
fmt.Println(err)
}
response := common.GetSerializedData(data)

common.WriteToFile(response)
} else {
data, _, err := enclaveCtx.RunStarlarkPackage(diveContext.Ctx, common.DiveRemotePackagePath, common.DiveBridgeScript, bridgeMainFunction, params, common.DiveDryRun, common.DiveDefaultParallelism, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{})

if err != nil {
fmt.Println(err)
}
response := common.GetSerializedData(data)

common.WriteToFile(response)
}
},
}

btpbridgeCmd.Flags().StringVar(&chainA, "chainA", "", "Metion Name of Supported Chain")
btpbridgeCmd.Flags().StringVar(&chainB, "chainB", "", "Metion Name of Supported Chain")
btpbridgeCmd.Flags().Bool("bridge", false, "Mention Bridge ENV")

btpbridgeCmd.MarkFlagRequired("chainA")
btpbridgeCmd.MarkFlagRequired("chainB")

return btpbridgeCmd
}
33 changes: 33 additions & 0 deletions cli/commands/chain/chains.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright © 2023 Hugobyte AI Labs<hello@hugobyte.com>
*/
package chain

import (
"github.com/hugobyte/dive/commands/chain/types"
"github.com/hugobyte/dive/common"
"github.com/spf13/cobra"
)

// chainCmd represents the chain command
func NewChainCmd(diveContext *common.DiveContext) *cobra.Command {
var chainCmd = &cobra.Command{

Use: "chain",
Short: "Build, initialize and start a given blockchain node.",
Long: `The command builds, initializes, and starts a specified blockchain node, providing a seamless setup process. It encompasses compiling and configuring the
necessary dependencies and components required for the blockchain network. By executing this command, the node is launched, enabling network participation, transaction
processing, and ledger maintenance within the specified blockchain ecosystem.`,
Run: func(cmd *cobra.Command, args []string) {
cmd.Help()

},
}

chainCmd.AddCommand(types.NewIconCmd(diveContext))
chainCmd.AddCommand(types.NewEthCmd(diveContext))
chainCmd.AddCommand(types.NewHardhatCmd(diveContext))

return chainCmd

}
57 changes: 57 additions & 0 deletions cli/commands/chain/types/eth.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package types

import (
"github.com/hugobyte/dive/common"
"github.com/kurtosis-tech/kurtosis/api/golang/core/kurtosis_core_rpc_api_bindings"
"github.com/spf13/cobra"
)

func NewEthCmd(diveContext *common.DiveContext) *cobra.Command {

var ethCmd = &cobra.Command{
Use: "eth",
Short: "Build, initialize and start a eth node.",
Long: `The command starts an Ethereum node, initiating the process of setting up and launching a local Ethereum network. It establishes a connection to the Ethereum
network and allows the node in executing smart contracts and maintaining the decentralized ledger.`,
Run: func(cmd *cobra.Command, args []string) {

data, err := RunEthNode(diveContext)

if err != nil {
diveContext.FatalError("Fail to Start ETH Node", err.Error())
}
data.WriteDiveResponse(diveContext)
},
}

return ethCmd

}

func RunEthNode(diveContext *common.DiveContext) (*common.DiveserviceResponse, error) {

kurtosisEnclaveContext, err := diveContext.GetEnclaveContext()

if err != nil {
return nil, err
}

data, _, err := kurtosisEnclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, common.DiveEthHardhatNodeScript, "start_eth_node", `{"args":{}}`, common.DiveDryRun, common.DiveDefaultParallelism, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{})

if err != nil {
return nil, err
}

responseData := common.GetSerializedData(data)

ethResponseData := &common.DiveserviceResponse{}

result, err := ethResponseData.Decode([]byte(responseData))

if err != nil {
return nil, err
}

return result, nil

}
58 changes: 58 additions & 0 deletions cli/commands/chain/types/hardhat.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package types

import (
"github.com/hugobyte/dive/common"
"github.com/kurtosis-tech/kurtosis/api/golang/core/kurtosis_core_rpc_api_bindings"
"github.com/spf13/cobra"
)

func NewHardhatCmd(diveContext *common.DiveContext) *cobra.Command {

var ethCmd = &cobra.Command{
Use: "hardhat",
Short: "Build, initialize and start a hardhat node.",
Long: `The command starts an hardhat node, initiating the process of setting up and launching a local hardhat network. It establishes a connection to the hardhat
network and allows the node in executing smart contracts and maintaining the decentralized ledger.`,
Run: func(cmd *cobra.Command, args []string) {

data, err := RunHardhatNode(diveContext)

if err != nil {
diveContext.FatalError("Fail to Start Hardhat Node", err.Error())
}

data.WriteDiveResponse(diveContext)
},
}

return ethCmd

}

func RunHardhatNode(diveContext *common.DiveContext) (*common.DiveserviceResponse, error) {

kurtosisEnclaveContext, err := diveContext.GetEnclaveContext()

if err != nil {
return nil, err
}

data, _, err := kurtosisEnclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, common.DiveEthHardhatNodeScript, "start_hardhat_node", "{}", common.DiveDryRun, common.DiveDefaultParallelism, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{})

if err != nil {
return nil, err
}

responseData := common.GetSerializedData(data)

hardhatResponseData := &common.DiveserviceResponse{}

result, err := hardhatResponseData.Decode([]byte(responseData))

if err != nil {
return nil, err
}

return result, nil

}
Loading