Skip to content

Commit

Permalink
Merge pull request #223 from CosmWasm/coral-binary
Browse files Browse the repository at this point in the history
Coral binary
  • Loading branch information
ethanfrey authored Jul 27, 2020
2 parents 826ca87 + cd9ae04 commit b269f78
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 16 deletions.
26 changes: 24 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,43 @@ endif
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))

coral_ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=coral \
-X github.com/cosmos/cosmos-sdk/version.ServerName=corald \
-X github.com/cosmos/cosmos-sdk/version.ClientName=coral \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X github.com/CosmWasm/wasmd/app.CLIDir=.coral \
-X github.com/CosmWasm/wasmd/app.NodeDir=.corald \
-X github.com/CosmWasm/wasmd/app.Bech32Prefix=coral \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)"

coral_ldflags += $(LDFLAGS)
coral_ldflags := $(strip $(coral_ldflags))

BUILD_FLAGS := -tags $(build_tags_comma_sep) -ldflags '$(ldflags)' -trimpath
CORAL_BUILD_FLAGS := -tags $(build_tags_comma_sep) -ldflags '$(coral_ldflags)' -trimpath

all: install lint test

build: go.sum
ifeq ($(OS),Windows_NT)
go build -mod=readonly $(BUILD_FLAGS) -o build/wasmd.exe ./cmd/wasmd
go build -mod=readonly $(BUILD_FLAGS) -o build/wasmgovd.exe ./cmd/wasmgovd
# wasmd nodes not supported on windows, maybe the cli?
go build -mod=readonly $(BUILD_FLAGS) -o build/wasmcli.exe ./cmd/wasmcli
else
go build -mod=readonly $(BUILD_FLAGS) -o build/wasmd ./cmd/wasmd
go build -mod=readonly $(BUILD_FLAGS) -o build/wasmgovd ./cmd/wasmgovd
go build -mod=readonly $(BUILD_FLAGS) -o build/wasmcli ./cmd/wasmcli
endif

build-coral: go.sum
ifeq ($(OS),Windows_NT)
# wasmd nodes not supported on windows, maybe the cli?
go build -mod=readonly $(CORAL_BUILD_FLAGS) -o build/coral.exe ./cmd/wasmcli
else
go build -mod=readonly $(CORAL_BUILD_FLAGS) -o build/corald ./cmd/wasmd
go build -mod=readonly $(CORAL_BUILD_FLAGS) -o build/coral ./cmd/wasmcli
endif

build-linux: go.sum
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build

Expand Down
30 changes: 27 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,37 @@ import (

const appName = "WasmApp"

// We pull these out so we can set them with LDFLAGS in the Makefile
var (
// DefaultCLIHome default home directories for wasmcli
DefaultCLIHome = os.ExpandEnv("$HOME/.wasmcli")
CLIDir = ".wasmcli"
NodeDir = ".wasmd"
Bech32Prefix = sdk.Bech32MainPrefix
)

// These constants are derived from the above variables.
// These are the ones we will want to use in the code, based on
// any overrides above
var (
// DefaultCLIHome default home directories for wasmcli
DefaultCLIHome = os.ExpandEnv("$HOME/") + CLIDir
// DefaultNodeHome default home directories for wasmd
DefaultNodeHome = os.ExpandEnv("$HOME/.wasmd")
DefaultNodeHome = os.ExpandEnv("$HOME/") + NodeDir

// Bech32PrefixAccAddr defines the Bech32 prefix of an account's address
Bech32PrefixAccAddr = Bech32Prefix
// Bech32PrefixAccPub defines the Bech32 prefix of an account's public key
Bech32PrefixAccPub = Bech32Prefix + sdk.PrefixPublic
// Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address
Bech32PrefixValAddr = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator
// Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key
Bech32PrefixValPub = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator + sdk.PrefixPublic
// Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address
Bech32PrefixConsAddr = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus
// Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key
Bech32PrefixConsPub = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus + sdk.PrefixPublic
)

var (
// ModuleBasics The module BasicManager is in charge of setting up basic,
// non-dependant module elements, such as codec registration
// and genesis verification.
Expand Down
15 changes: 8 additions & 7 deletions cmd/wasmcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import (
"os"
"path"

"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/keys"
Expand All @@ -17,8 +20,6 @@ import (
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
"github.com/cosmos/cosmos-sdk/x/bank"
bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/tendermint/go-amino"
"github.com/tendermint/tendermint/libs/cli"
Expand All @@ -35,18 +36,18 @@ func main() {

// Read in the configuration file for the sdk
config := sdk.GetConfig()
config.SetBech32PrefixForAccount(sdk.Bech32PrefixAccAddr, sdk.Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(sdk.Bech32PrefixValAddr, sdk.Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(sdk.Bech32PrefixConsAddr, sdk.Bech32PrefixConsPub)
config.SetBech32PrefixForAccount(app.Bech32PrefixAccAddr, app.Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(app.Bech32PrefixValAddr, app.Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(app.Bech32PrefixConsAddr, app.Bech32PrefixConsPub)
config.Seal()

// TODO: setup keybase, viper object, etc. to be passed into
// the below functions and eliminate global vars, like we do
// with the cdc

rootCmd := &cobra.Command{
Use: "wasmcli",
Short: "Command line interface for interacting with wasmd",
Use: version.ClientName,
Short: "Command line interface for interacting with " + version.ServerName,
}

// Add --chain-id to persistent flags and mark it required
Expand Down
9 changes: 5 additions & 4 deletions cmd/wasmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"encoding/json"
"github.com/cosmos/cosmos-sdk/version"
"io"

"github.com/CosmWasm/wasmd/app"
Expand Down Expand Up @@ -32,15 +33,15 @@ func main() {
cdc := app.MakeCodec()

config := sdk.GetConfig()
config.SetBech32PrefixForAccount(sdk.Bech32PrefixAccAddr, sdk.Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(sdk.Bech32PrefixValAddr, sdk.Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(sdk.Bech32PrefixConsAddr, sdk.Bech32PrefixConsPub)
config.SetBech32PrefixForAccount(app.Bech32PrefixAccAddr, app.Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(app.Bech32PrefixValAddr, app.Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(app.Bech32PrefixConsAddr, app.Bech32PrefixConsPub)
config.Seal()

ctx := server.NewDefaultContext()
cobra.EnableCommandSorting = false
rootCmd := &cobra.Command{
Use: "wasmd",
Use: version.ServerName,
Short: "Wasm Daemon (server) with wasm gov proposals disabled\",",
PersistentPreRunE: server.PersistentPreRunEFn(ctx),
}
Expand Down

0 comments on commit b269f78

Please sign in to comment.