generated from kurtosis-tech/package-template-repo
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: initial cli setup * feat: implement version command for cli (#32) * feat: Add version constant * chore: update go mod file * feat: Add Timestamp formatter to logrus * feat: Get current cli version * chore: Update go mod file * feat: Implementation for dive clean command * feat: Add Timestamp formatter to logrus * chore: remove clean implementation --------- Co-authored-by: hemz10 <[email protected]> * feat: implement clean command for cli (#33) * feat: Add version constant * chore: update go mod file * feat: Add Timestamp formatter to logrus * feat: Get current cli version * chore: Update go mod file * feat: Implementation for dive clean command * feat: Add Timestamp formatter to logrus * chore: remove clean implementation * feat: get running enclaves * feat: Implement clean functionality --------- Co-authored-by: hemz10 <[email protected]> Co-authored-by: shreyasbhat0 <[email protected]> * feat: implement chain command for dive cli (#36) * feat: init chain command * chore: update chain command * feat: add eth command to chain * feat: add hardhat command to chain * feat: remove cosmos * feat: Ckip 69 implement help command for cli (#34) * feat: Add version constant * chore: update go mod file * feat: Add Timestamp formatter to logrus * feat: Get current cli version * chore: Update go mod file * feat: Implementation for dive clean command * feat: Add Timestamp formatter to logrus * chore: remove clean implementation * feat: get running enclaves * feat: Implement clean functionality * docs: Update help for chain command * docs: update help for bridge command * feat:Display banner only on start not on subcommands --------- Co-authored-by: hemz10 <[email protected]> Co-authored-by: shreyasbhat0 <[email protected]> * feat: Ckip 80 add discord command to dive cli (#35) * feat: implement discord command * feat: import discord to rootcmd --------- Co-authored-by: hemz10 <[email protected]> * feat: Ckip 79 add command for twitter in dive cli (#37) * feat: implement twitter command * feat: add twitter to rootcmd * chore: add reusable function to common --------- Co-authored-by: hemz10 <[email protected]> * feat: implement bridge command for DIVE CLI (#39) * chore: update dive banner * feat: implement bridge command * feat: update service packages * chore: update bridge * chore: update setplimit * feat: Ckip 81 add tutorial command to the dive cli (#38) * feat: check for latest update when starting dive * feat: implement tutorial command * refactor: update help command descriptions --------- Co-authored-by: hemz10 <[email protected]> Co-authored-by: shreyasbhat0 <[email protected]> * refactor: dive cli codebase refactor (#40) * refactor: update code structure * feat: add goreleaser * chore: update dive --------- Co-authored-by: Hemanth Kumar <[email protected]> Co-authored-by: hemz10 <[email protected]>
- Loading branch information
Showing
19 changed files
with
1,291 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
Copyright © 2023 Hugobyte AI Labs <[email protected]> | ||
*/ | ||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
Copyright © 2023 Hugobyte AI Labs<[email protected]> | ||
*/ | ||
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 | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
} |
Oops, something went wrong.