Skip to content

Commit b269f78

Browse files
authored
Merge pull request #223 from CosmWasm/coral-binary
Coral binary
2 parents 826ca87 + cd9ae04 commit b269f78

File tree

4 files changed

+64
-16
lines changed

4 files changed

+64
-16
lines changed

Makefile

+24-2
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,43 @@ endif
6060
ldflags += $(LDFLAGS)
6161
ldflags := $(strip $(ldflags))
6262

63+
coral_ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=coral \
64+
-X github.com/cosmos/cosmos-sdk/version.ServerName=corald \
65+
-X github.com/cosmos/cosmos-sdk/version.ClientName=coral \
66+
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
67+
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
68+
-X github.com/CosmWasm/wasmd/app.CLIDir=.coral \
69+
-X github.com/CosmWasm/wasmd/app.NodeDir=.corald \
70+
-X github.com/CosmWasm/wasmd/app.Bech32Prefix=coral \
71+
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)"
72+
73+
coral_ldflags += $(LDFLAGS)
74+
coral_ldflags := $(strip $(coral_ldflags))
75+
6376
BUILD_FLAGS := -tags $(build_tags_comma_sep) -ldflags '$(ldflags)' -trimpath
77+
CORAL_BUILD_FLAGS := -tags $(build_tags_comma_sep) -ldflags '$(coral_ldflags)' -trimpath
6478

6579
all: install lint test
6680

6781
build: go.sum
6882
ifeq ($(OS),Windows_NT)
69-
go build -mod=readonly $(BUILD_FLAGS) -o build/wasmd.exe ./cmd/wasmd
70-
go build -mod=readonly $(BUILD_FLAGS) -o build/wasmgovd.exe ./cmd/wasmgovd
83+
# wasmd nodes not supported on windows, maybe the cli?
7184
go build -mod=readonly $(BUILD_FLAGS) -o build/wasmcli.exe ./cmd/wasmcli
7285
else
7386
go build -mod=readonly $(BUILD_FLAGS) -o build/wasmd ./cmd/wasmd
7487
go build -mod=readonly $(BUILD_FLAGS) -o build/wasmgovd ./cmd/wasmgovd
7588
go build -mod=readonly $(BUILD_FLAGS) -o build/wasmcli ./cmd/wasmcli
7689
endif
7790

91+
build-coral: go.sum
92+
ifeq ($(OS),Windows_NT)
93+
# wasmd nodes not supported on windows, maybe the cli?
94+
go build -mod=readonly $(CORAL_BUILD_FLAGS) -o build/coral.exe ./cmd/wasmcli
95+
else
96+
go build -mod=readonly $(CORAL_BUILD_FLAGS) -o build/corald ./cmd/wasmd
97+
go build -mod=readonly $(CORAL_BUILD_FLAGS) -o build/coral ./cmd/wasmcli
98+
endif
99+
78100
build-linux: go.sum
79101
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build
80102

app/app.go

+27-3
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,37 @@ import (
3939

4040
const appName = "WasmApp"
4141

42+
// We pull these out so we can set them with LDFLAGS in the Makefile
4243
var (
43-
// DefaultCLIHome default home directories for wasmcli
44-
DefaultCLIHome = os.ExpandEnv("$HOME/.wasmcli")
44+
CLIDir = ".wasmcli"
45+
NodeDir = ".wasmd"
46+
Bech32Prefix = sdk.Bech32MainPrefix
47+
)
4548

49+
// These constants are derived from the above variables.
50+
// These are the ones we will want to use in the code, based on
51+
// any overrides above
52+
var (
53+
// DefaultCLIHome default home directories for wasmcli
54+
DefaultCLIHome = os.ExpandEnv("$HOME/") + CLIDir
4655
// DefaultNodeHome default home directories for wasmd
47-
DefaultNodeHome = os.ExpandEnv("$HOME/.wasmd")
56+
DefaultNodeHome = os.ExpandEnv("$HOME/") + NodeDir
57+
58+
// Bech32PrefixAccAddr defines the Bech32 prefix of an account's address
59+
Bech32PrefixAccAddr = Bech32Prefix
60+
// Bech32PrefixAccPub defines the Bech32 prefix of an account's public key
61+
Bech32PrefixAccPub = Bech32Prefix + sdk.PrefixPublic
62+
// Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address
63+
Bech32PrefixValAddr = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator
64+
// Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key
65+
Bech32PrefixValPub = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator + sdk.PrefixPublic
66+
// Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address
67+
Bech32PrefixConsAddr = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus
68+
// Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key
69+
Bech32PrefixConsPub = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus + sdk.PrefixPublic
70+
)
4871

72+
var (
4973
// ModuleBasics The module BasicManager is in charge of setting up basic,
5074
// non-dependant module elements, such as codec registration
5175
// and genesis verification.

cmd/wasmcli/main.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import (
55
"os"
66
"path"
77

8+
"github.com/spf13/cobra"
9+
"github.com/spf13/viper"
10+
811
"github.com/cosmos/cosmos-sdk/client"
912
"github.com/cosmos/cosmos-sdk/client/flags"
1013
"github.com/cosmos/cosmos-sdk/client/keys"
@@ -17,8 +20,6 @@ import (
1720
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
1821
"github.com/cosmos/cosmos-sdk/x/bank"
1922
bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
20-
"github.com/spf13/cobra"
21-
"github.com/spf13/viper"
2223

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

3637
// Read in the configuration file for the sdk
3738
config := sdk.GetConfig()
38-
config.SetBech32PrefixForAccount(sdk.Bech32PrefixAccAddr, sdk.Bech32PrefixAccPub)
39-
config.SetBech32PrefixForValidator(sdk.Bech32PrefixValAddr, sdk.Bech32PrefixValPub)
40-
config.SetBech32PrefixForConsensusNode(sdk.Bech32PrefixConsAddr, sdk.Bech32PrefixConsPub)
39+
config.SetBech32PrefixForAccount(app.Bech32PrefixAccAddr, app.Bech32PrefixAccPub)
40+
config.SetBech32PrefixForValidator(app.Bech32PrefixValAddr, app.Bech32PrefixValPub)
41+
config.SetBech32PrefixForConsensusNode(app.Bech32PrefixConsAddr, app.Bech32PrefixConsPub)
4142
config.Seal()
4243

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

4748
rootCmd := &cobra.Command{
48-
Use: "wasmcli",
49-
Short: "Command line interface for interacting with wasmd",
49+
Use: version.ClientName,
50+
Short: "Command line interface for interacting with " + version.ServerName,
5051
}
5152

5253
// Add --chain-id to persistent flags and mark it required

cmd/wasmd/main.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"encoding/json"
5+
"github.com/cosmos/cosmos-sdk/version"
56
"io"
67

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

3435
config := sdk.GetConfig()
35-
config.SetBech32PrefixForAccount(sdk.Bech32PrefixAccAddr, sdk.Bech32PrefixAccPub)
36-
config.SetBech32PrefixForValidator(sdk.Bech32PrefixValAddr, sdk.Bech32PrefixValPub)
37-
config.SetBech32PrefixForConsensusNode(sdk.Bech32PrefixConsAddr, sdk.Bech32PrefixConsPub)
36+
config.SetBech32PrefixForAccount(app.Bech32PrefixAccAddr, app.Bech32PrefixAccPub)
37+
config.SetBech32PrefixForValidator(app.Bech32PrefixValAddr, app.Bech32PrefixValPub)
38+
config.SetBech32PrefixForConsensusNode(app.Bech32PrefixConsAddr, app.Bech32PrefixConsPub)
3839
config.Seal()
3940

4041
ctx := server.NewDefaultContext()
4142
cobra.EnableCommandSorting = false
4243
rootCmd := &cobra.Command{
43-
Use: "wasmd",
44+
Use: version.ServerName,
4445
Short: "Wasm Daemon (server) with wasm gov proposals disabled\",",
4546
PersistentPreRunE: server.PersistentPreRunEFn(ctx),
4647
}

0 commit comments

Comments
 (0)