mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-26 16:25:21 +00:00
commit
7dd47f074a
85
Gopkg.lock
generated
85
Gopkg.lock
generated
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
|
||||||
digest = "1:09a7f74eb6bb3c0f14d8926610c87f569c5cff68e978d30e9a3540aeb626fdf0"
|
digest = "1:09a7f74eb6bb3c0f14d8926610c87f569c5cff68e978d30e9a3540aeb626fdf0"
|
||||||
name = "github.com/bartekn/go-bip39"
|
name = "github.com/bartekn/go-bip39"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
@ -49,7 +48,7 @@
|
|||||||
revision = "d4cc87b860166d00d6b5b9e0d3b3d71d6088d4d4"
|
revision = "d4cc87b860166d00d6b5b9e0d3b3d71d6088d4d4"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
digest = "1:bb617355120eed649354b41a20d1745b2feb994e4da1a97591259143ad65375a"
|
digest = "1:7f6e80c9a48014e57211353a9a82d12088f9dc85f564b6a70674bbc1d5abc34e"
|
||||||
name = "github.com/cosmos/cosmos-sdk"
|
name = "github.com/cosmos/cosmos-sdk"
|
||||||
packages = [
|
packages = [
|
||||||
"baseapp",
|
"baseapp",
|
||||||
@ -58,6 +57,7 @@
|
|||||||
"client/keys",
|
"client/keys",
|
||||||
"client/rpc",
|
"client/rpc",
|
||||||
"client/tx",
|
"client/tx",
|
||||||
|
"client/utils",
|
||||||
"crypto",
|
"crypto",
|
||||||
"crypto/keys",
|
"crypto/keys",
|
||||||
"crypto/keys/bcrypt",
|
"crypto/keys/bcrypt",
|
||||||
@ -71,12 +71,12 @@
|
|||||||
"wire",
|
"wire",
|
||||||
"x/auth",
|
"x/auth",
|
||||||
"x/auth/client/cli",
|
"x/auth/client/cli",
|
||||||
|
"x/auth/client/context",
|
||||||
"x/bank",
|
"x/bank",
|
||||||
"x/bank/client",
|
"x/bank/client",
|
||||||
"x/bank/client/cli",
|
"x/bank/client/cli",
|
||||||
"x/gov",
|
|
||||||
"x/ibc",
|
|
||||||
"x/mock",
|
"x/mock",
|
||||||
|
"x/params",
|
||||||
"x/slashing",
|
"x/slashing",
|
||||||
"x/slashing/client/cli",
|
"x/slashing/client/cli",
|
||||||
"x/stake",
|
"x/stake",
|
||||||
@ -86,8 +86,8 @@
|
|||||||
"x/stake/types",
|
"x/stake/types",
|
||||||
]
|
]
|
||||||
pruneopts = "UT"
|
pruneopts = "UT"
|
||||||
revision = "23e3d5ac12145c02fcb4b4767d7dfccad782aee5"
|
revision = "1c38c70468ec721e3a555ba2f3bf5f9da31f0cc9"
|
||||||
version = "v0.23.1"
|
version = "v0.24.2"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
digest = "1:a2c1d0e43bd3baaa071d1b9ed72c27d78169b2b269f71c105ac4ba34b1be4a39"
|
digest = "1:a2c1d0e43bd3baaa071d1b9ed72c27d78169b2b269f71c105ac4ba34b1be4a39"
|
||||||
@ -437,14 +437,6 @@
|
|||||||
pruneopts = "UT"
|
pruneopts = "UT"
|
||||||
revision = "c4c61651e9e37fa117f53c5a906d3b63090d8445"
|
revision = "c4c61651e9e37fa117f53c5a906d3b63090d8445"
|
||||||
|
|
||||||
[[projects]]
|
|
||||||
digest = "1:8b7ca9e3745cb049a65364d3adbbab63e98d3c43c83cb101cb450c8dac3c3492"
|
|
||||||
name = "github.com/tendermint/abci"
|
|
||||||
packages = ["types"]
|
|
||||||
pruneopts = "UT"
|
|
||||||
revision = "68592f4d8ee34e97db94b7a7976b1309efdb7eb9"
|
|
||||||
version = "v0.10.0"
|
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
digest = "1:087aaa7920e5d0bf79586feb57ce01c35c830396ab4392798112e8aae8c47722"
|
digest = "1:087aaa7920e5d0bf79586feb57ce01c35c830396ab4392798112e8aae8c47722"
|
||||||
@ -458,23 +450,12 @@
|
|||||||
revision = "d8387025d2b9d158cf4efb07e7ebf814bcce2057"
|
revision = "d8387025d2b9d158cf4efb07e7ebf814bcce2057"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
digest = "1:e9113641c839c21d8eaeb2c907c7276af1eddeed988df8322168c56b7e06e0e1"
|
digest = "1:e0a2a4be1e20c305badc2b0a7a9ab7fef6da500763bec23ab81df3b5f9eec9ee"
|
||||||
name = "github.com/tendermint/go-amino"
|
name = "github.com/tendermint/go-amino"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
pruneopts = "UT"
|
pruneopts = "UT"
|
||||||
revision = "2106ca61d91029c931fd54968c2bb02dc96b1412"
|
revision = "a8328986c1608950fa5d3d1c0472cccc4f8fc02c"
|
||||||
version = "0.10.1"
|
version = "v0.12.0-rc0"
|
||||||
|
|
||||||
[[projects]]
|
|
||||||
digest = "1:82f70bfe58f1a55601d469b928aec5b10b1d85710e6adde40dfea8d9adba939d"
|
|
||||||
name = "github.com/tendermint/go-crypto"
|
|
||||||
packages = [
|
|
||||||
".",
|
|
||||||
"tmhash",
|
|
||||||
]
|
|
||||||
pruneopts = "UT"
|
|
||||||
revision = "6a6b591a3d7592a04b46af95451cb5be3b114f76"
|
|
||||||
version = "v0.9.0"
|
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
digest = "1:d4a15d404afbf591e8be16fcda7f5ac87948d5c7531f9d909fd84cc730ab16e2"
|
digest = "1:d4a15d404afbf591e8be16fcda7f5ac87948d5c7531f9d909fd84cc730ab16e2"
|
||||||
@ -485,7 +466,7 @@
|
|||||||
version = "v0.9.2"
|
version = "v0.9.2"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
digest = "1:eb0f8bee357e6c28c9ad5fa074545b5085d0dcf580ba0e7024ab8c3285a5c815"
|
digest = "1:4f15e95fe3888cc75dd34f407d6394cbc7fd3ff24920851b92b295f6a8b556e6"
|
||||||
name = "github.com/tendermint/tendermint"
|
name = "github.com/tendermint/tendermint"
|
||||||
packages = [
|
packages = [
|
||||||
"abci/client",
|
"abci/client",
|
||||||
@ -548,35 +529,26 @@
|
|||||||
"version",
|
"version",
|
||||||
]
|
]
|
||||||
pruneopts = "UT"
|
pruneopts = "UT"
|
||||||
revision = "d542d2c3945116697f60451e6a407082c41c3cc9"
|
revision = "81df19e68ab1519399fccf0cab81cb75bf9d782e"
|
||||||
version = "v0.22.8"
|
version = "v0.23.1-rc0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
digest = "1:68921ddf468c0db04496dc49cc67948f1727a74520b1f1f06100bce5c65fa08b"
|
digest = "1:4dcb0dd65feecb068ce23a234d1a07c7868a1e39f52a6defcae0bb371d03abf6"
|
||||||
name = "github.com/tendermint/tmlibs"
|
|
||||||
packages = [
|
|
||||||
"common",
|
|
||||||
"db",
|
|
||||||
"log",
|
|
||||||
]
|
|
||||||
pruneopts = "UT"
|
|
||||||
revision = "692f1d86a6e2c0efa698fd1e4541b68c74ffaf38"
|
|
||||||
version = "v0.8.4"
|
|
||||||
|
|
||||||
[[projects]]
|
|
||||||
digest = "1:5bd938386bd1f61a581bf8cd6ff2b7b2f79c542929176db4ceb44965440dae07"
|
|
||||||
name = "github.com/zondax/ledger-goclient"
|
name = "github.com/zondax/ledger-goclient"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
pruneopts = "UT"
|
pruneopts = "UT"
|
||||||
revision = "39ba4728c137c75718a21f9b4b3280fa31b9139b"
|
revision = "4296ee5701e945f9b3a7dbe51f402e0b9be57259"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
digest = "1:65a21a9e051d54eb6a3f70c659a765f706a998d9287c302269f4ed8054b2a852"
|
digest = "1:7a71fffde456d746c52f9cd09c50b034533a3180fb1f6320abb149f2ccc579e5"
|
||||||
name = "golang.org/x/crypto"
|
name = "golang.org/x/crypto"
|
||||||
packages = [
|
packages = [
|
||||||
"blowfish",
|
"blowfish",
|
||||||
|
"chacha20poly1305",
|
||||||
"curve25519",
|
"curve25519",
|
||||||
|
"hkdf",
|
||||||
|
"internal/chacha20",
|
||||||
"internal/subtle",
|
"internal/subtle",
|
||||||
"nacl/box",
|
"nacl/box",
|
||||||
"nacl/secretbox",
|
"nacl/secretbox",
|
||||||
@ -608,9 +580,12 @@
|
|||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
digest = "1:0316a8ad208917f1d141b077e278980fd5e4594f3a85f835dacbf24d85798252"
|
digest = "1:4bd75b1a219bc590b05c976bbebf47f4e993314ebb5c7cbf2efe05a09a184d54"
|
||||||
name = "golang.org/x/sys"
|
name = "golang.org/x/sys"
|
||||||
packages = ["unix"]
|
packages = [
|
||||||
|
"cpu",
|
||||||
|
"unix",
|
||||||
|
]
|
||||||
pruneopts = "UT"
|
pruneopts = "UT"
|
||||||
revision = "4e1fef5609515ec7a2cee7b5de30ba6d9b438cbf"
|
revision = "4e1fef5609515ec7a2cee7b5de30ba6d9b438cbf"
|
||||||
|
|
||||||
@ -693,9 +668,11 @@
|
|||||||
input-imports = [
|
input-imports = [
|
||||||
"github.com/cosmos/cosmos-sdk/baseapp",
|
"github.com/cosmos/cosmos-sdk/baseapp",
|
||||||
"github.com/cosmos/cosmos-sdk/client",
|
"github.com/cosmos/cosmos-sdk/client",
|
||||||
|
"github.com/cosmos/cosmos-sdk/client/context",
|
||||||
"github.com/cosmos/cosmos-sdk/client/keys",
|
"github.com/cosmos/cosmos-sdk/client/keys",
|
||||||
"github.com/cosmos/cosmos-sdk/client/rpc",
|
"github.com/cosmos/cosmos-sdk/client/rpc",
|
||||||
"github.com/cosmos/cosmos-sdk/client/tx",
|
"github.com/cosmos/cosmos-sdk/client/tx",
|
||||||
|
"github.com/cosmos/cosmos-sdk/client/utils",
|
||||||
"github.com/cosmos/cosmos-sdk/server",
|
"github.com/cosmos/cosmos-sdk/server",
|
||||||
"github.com/cosmos/cosmos-sdk/server/config",
|
"github.com/cosmos/cosmos-sdk/server/config",
|
||||||
"github.com/cosmos/cosmos-sdk/types",
|
"github.com/cosmos/cosmos-sdk/types",
|
||||||
@ -703,30 +680,28 @@
|
|||||||
"github.com/cosmos/cosmos-sdk/wire",
|
"github.com/cosmos/cosmos-sdk/wire",
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth",
|
"github.com/cosmos/cosmos-sdk/x/auth",
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth/client/cli",
|
"github.com/cosmos/cosmos-sdk/x/auth/client/cli",
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/auth/client/context",
|
||||||
"github.com/cosmos/cosmos-sdk/x/bank",
|
"github.com/cosmos/cosmos-sdk/x/bank",
|
||||||
"github.com/cosmos/cosmos-sdk/x/bank/client/cli",
|
"github.com/cosmos/cosmos-sdk/x/bank/client/cli",
|
||||||
"github.com/cosmos/cosmos-sdk/x/gov",
|
"github.com/cosmos/cosmos-sdk/x/mock",
|
||||||
"github.com/cosmos/cosmos-sdk/x/ibc",
|
"github.com/cosmos/cosmos-sdk/x/params",
|
||||||
"github.com/cosmos/cosmos-sdk/x/slashing",
|
"github.com/cosmos/cosmos-sdk/x/slashing",
|
||||||
"github.com/cosmos/cosmos-sdk/x/slashing/client/cli",
|
"github.com/cosmos/cosmos-sdk/x/slashing/client/cli",
|
||||||
"github.com/cosmos/cosmos-sdk/x/stake",
|
"github.com/cosmos/cosmos-sdk/x/stake",
|
||||||
"github.com/cosmos/cosmos-sdk/x/stake/client/cli",
|
"github.com/cosmos/cosmos-sdk/x/stake/client/cli",
|
||||||
|
"github.com/pkg/errors",
|
||||||
"github.com/spf13/cobra",
|
"github.com/spf13/cobra",
|
||||||
"github.com/spf13/pflag",
|
"github.com/spf13/pflag",
|
||||||
"github.com/spf13/viper",
|
"github.com/spf13/viper",
|
||||||
"github.com/stretchr/testify/assert",
|
"github.com/stretchr/testify/assert",
|
||||||
"github.com/stretchr/testify/require",
|
|
||||||
"github.com/tendermint/abci/types",
|
|
||||||
"github.com/tendermint/go-crypto",
|
|
||||||
"github.com/tendermint/tendermint/abci/types",
|
"github.com/tendermint/tendermint/abci/types",
|
||||||
"github.com/tendermint/tendermint/crypto",
|
"github.com/tendermint/tendermint/crypto",
|
||||||
|
"github.com/tendermint/tendermint/crypto/ed25519",
|
||||||
"github.com/tendermint/tendermint/libs/cli",
|
"github.com/tendermint/tendermint/libs/cli",
|
||||||
"github.com/tendermint/tendermint/libs/common",
|
"github.com/tendermint/tendermint/libs/common",
|
||||||
"github.com/tendermint/tendermint/libs/db",
|
"github.com/tendermint/tendermint/libs/db",
|
||||||
"github.com/tendermint/tendermint/libs/log",
|
"github.com/tendermint/tendermint/libs/log",
|
||||||
"github.com/tendermint/tendermint/types",
|
"github.com/tendermint/tendermint/types",
|
||||||
"github.com/tendermint/tmlibs/db",
|
|
||||||
"github.com/tendermint/tmlibs/log",
|
|
||||||
]
|
]
|
||||||
solver-name = "gps-cdcl"
|
solver-name = "gps-cdcl"
|
||||||
solver-version = 1
|
solver-version = 1
|
||||||
|
11
Gopkg.toml
11
Gopkg.toml
@ -1,6 +1,6 @@
|
|||||||
[[constraint]]
|
[[constraint]]
|
||||||
name = "github.com/cosmos/cosmos-sdk"
|
name = "github.com/cosmos/cosmos-sdk"
|
||||||
version="=0.23.1"
|
version="=0.24.2"
|
||||||
|
|
||||||
|
|
||||||
# Copied from cosmos-sdk, constraints switched to overrides
|
# Copied from cosmos-sdk, constraints switched to overrides
|
||||||
@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
[[override]]
|
[[override]]
|
||||||
name = "github.com/tendermint/go-amino"
|
name = "github.com/tendermint/go-amino"
|
||||||
version = "=0.10.1"
|
version = "=v0.12.0-rc0"
|
||||||
|
|
||||||
[[override]]
|
[[override]]
|
||||||
name = "github.com/tendermint/iavl"
|
name = "github.com/tendermint/iavl"
|
||||||
@ -43,16 +43,17 @@
|
|||||||
|
|
||||||
[[override]]
|
[[override]]
|
||||||
name = "github.com/tendermint/tendermint"
|
name = "github.com/tendermint/tendermint"
|
||||||
version = "=v0.22.8"
|
version = "=v0.23.1-rc0"
|
||||||
|
|
||||||
[[override]]
|
[[override]]
|
||||||
name = "github.com/bartekn/go-bip39"
|
name = "github.com/bartekn/go-bip39"
|
||||||
branch = "master"
|
revision = "a05967ea095d81c8fe4833776774cfaff8e5036c"
|
||||||
|
|
||||||
[[override]]
|
[[override]]
|
||||||
name = "github.com/zondax/ledger-goclient"
|
name = "github.com/zondax/ledger-goclient"
|
||||||
revision = "39ba4728c137c75718a21f9b4b3280fa31b9139b"
|
revision = "4296ee5701e945f9b3a7dbe51f402e0b9be57259"
|
||||||
|
|
||||||
[prune]
|
[prune]
|
||||||
go-tests = true
|
go-tests = true
|
||||||
unused-packages = true
|
unused-packages = true
|
||||||
|
|
@ -16,11 +16,10 @@ import (
|
|||||||
"github.com/cosmos/cosmos-sdk/version"
|
"github.com/cosmos/cosmos-sdk/version"
|
||||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||||
bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
|
bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
|
||||||
//govcmd "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
|
|
||||||
//ibccmd "github.com/cosmos/cosmos-sdk/x/ibc/client/cli"
|
|
||||||
slashingcmd "github.com/cosmos/cosmos-sdk/x/slashing/client/cli"
|
slashingcmd "github.com/cosmos/cosmos-sdk/x/slashing/client/cli"
|
||||||
stakecmd "github.com/cosmos/cosmos-sdk/x/stake/client/cli"
|
stakecmd "github.com/cosmos/cosmos-sdk/x/stake/client/cli"
|
||||||
paychancmd "github.com/kava-labs/kava/internal/x/paychan/client/cmd"
|
paychancmd "github.com/kava-labs/kava/internal/x/paychan/client/cli"
|
||||||
|
|
||||||
"github.com/kava-labs/kava/internal/app"
|
"github.com/kava-labs/kava/internal/app"
|
||||||
//"github.com/kava-labs/kava/internal/lcd"
|
//"github.com/kava-labs/kava/internal/lcd"
|
||||||
@ -53,17 +52,6 @@ func main() {
|
|||||||
)
|
)
|
||||||
tx.AddCommands(tendermintCmd, cdc)
|
tx.AddCommands(tendermintCmd, cdc)
|
||||||
|
|
||||||
// Add IBC commands
|
|
||||||
// ibcCmd := &cobra.Command{
|
|
||||||
// Use: "ibc",
|
|
||||||
// Short: "Inter-Blockchain Communication subcommands",
|
|
||||||
// }
|
|
||||||
// ibcCmd.AddCommand(
|
|
||||||
// client.PostCommands(
|
|
||||||
// ibccmd.IBCTransferCmd(cdc),
|
|
||||||
// ibccmd.IBCRelayCmd(cdc),
|
|
||||||
// )...)
|
|
||||||
|
|
||||||
advancedCmd := &cobra.Command{
|
advancedCmd := &cobra.Command{
|
||||||
Use: "advanced",
|
Use: "advanced",
|
||||||
Short: "Advanced subcommands",
|
Short: "Advanced subcommands",
|
||||||
@ -90,6 +78,10 @@ func main() {
|
|||||||
stakecmd.GetCmdQueryValidators("stake", cdc),
|
stakecmd.GetCmdQueryValidators("stake", cdc),
|
||||||
stakecmd.GetCmdQueryDelegation("stake", cdc),
|
stakecmd.GetCmdQueryDelegation("stake", cdc),
|
||||||
stakecmd.GetCmdQueryDelegations("stake", cdc),
|
stakecmd.GetCmdQueryDelegations("stake", cdc),
|
||||||
|
stakecmd.GetCmdQueryUnbondingDelegation("stake", cdc),
|
||||||
|
stakecmd.GetCmdQueryUnbondingDelegations("stake", cdc),
|
||||||
|
stakecmd.GetCmdQueryRedelegation("stake", cdc),
|
||||||
|
stakecmd.GetCmdQueryRedelegations("stake", cdc),
|
||||||
slashingcmd.GetCmdQuerySigningInfo("slashing", cdc),
|
slashingcmd.GetCmdQuerySigningInfo("slashing", cdc),
|
||||||
)...)
|
)...)
|
||||||
stakeCmd.AddCommand(
|
stakeCmd.AddCommand(
|
||||||
@ -105,27 +97,6 @@ func main() {
|
|||||||
stakeCmd,
|
stakeCmd,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Add gov commands
|
|
||||||
// govCmd := &cobra.Command{
|
|
||||||
// Use: "gov",
|
|
||||||
// Short: "Governance and voting subcommands",
|
|
||||||
// }
|
|
||||||
// govCmd.AddCommand(
|
|
||||||
// client.GetCommands(
|
|
||||||
// govcmd.GetCmdQueryProposal("gov", cdc),
|
|
||||||
// govcmd.GetCmdQueryVote("gov", cdc),
|
|
||||||
// govcmd.GetCmdQueryVotes("gov", cdc),
|
|
||||||
// )...)
|
|
||||||
// govCmd.AddCommand(
|
|
||||||
// client.PostCommands(
|
|
||||||
// govcmd.GetCmdSubmitProposal(cdc),
|
|
||||||
// govcmd.GetCmdDeposit(cdc),
|
|
||||||
// govcmd.GetCmdVote(cdc),
|
|
||||||
// )...)
|
|
||||||
// rootCmd.AddCommand(
|
|
||||||
// govCmd,
|
|
||||||
// )
|
|
||||||
|
|
||||||
// Add auth and bank commands
|
// Add auth and bank commands
|
||||||
rootCmd.AddCommand(
|
rootCmd.AddCommand(
|
||||||
client.GetCommands(
|
client.GetCommands(
|
||||||
|
@ -19,8 +19,7 @@ import (
|
|||||||
"github.com/cosmos/cosmos-sdk/wire"
|
"github.com/cosmos/cosmos-sdk/wire"
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||||
//"github.com/cosmos/cosmos-sdk/x/gov"
|
"github.com/cosmos/cosmos-sdk/x/params"
|
||||||
//"github.com/cosmos/cosmos-sdk/x/ibc"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/slashing"
|
"github.com/cosmos/cosmos-sdk/x/slashing"
|
||||||
"github.com/cosmos/cosmos-sdk/x/stake"
|
"github.com/cosmos/cosmos-sdk/x/stake"
|
||||||
"github.com/kava-labs/kava/internal/x/paychan"
|
"github.com/kava-labs/kava/internal/x/paychan"
|
||||||
@ -41,25 +40,23 @@ type KavaApp struct {
|
|||||||
cdc *wire.Codec
|
cdc *wire.Codec
|
||||||
|
|
||||||
// keys to access the substores
|
// keys to access the substores
|
||||||
keyMain *sdk.KVStoreKey
|
keyMain *sdk.KVStoreKey
|
||||||
keyAccount *sdk.KVStoreKey
|
keyAccount *sdk.KVStoreKey
|
||||||
|
keyStake *sdk.KVStoreKey
|
||||||
//keyIBC *sdk.KVStoreKey
|
keySlashing *sdk.KVStoreKey
|
||||||
keyStake *sdk.KVStoreKey
|
|
||||||
keySlashing *sdk.KVStoreKey
|
|
||||||
//keyGov *sdk.KVStoreKey
|
|
||||||
keyFeeCollection *sdk.KVStoreKey
|
keyFeeCollection *sdk.KVStoreKey
|
||||||
|
keyParams *sdk.KVStoreKey
|
||||||
|
tkeyParams *sdk.TransientStoreKey
|
||||||
keyPaychan *sdk.KVStoreKey
|
keyPaychan *sdk.KVStoreKey
|
||||||
|
|
||||||
// keepers
|
// keepers
|
||||||
accountMapper auth.AccountMapper
|
accountMapper auth.AccountMapper
|
||||||
feeCollectionKeeper auth.FeeCollectionKeeper
|
feeCollectionKeeper auth.FeeCollectionKeeper
|
||||||
coinKeeper bank.Keeper
|
coinKeeper bank.Keeper
|
||||||
|
stakeKeeper stake.Keeper
|
||||||
|
slashingKeeper slashing.Keeper
|
||||||
|
paramsKeeper params.Keeper
|
||||||
paychanKeeper paychan.Keeper
|
paychanKeeper paychan.Keeper
|
||||||
//ibcMapper ibc.Mapper
|
|
||||||
stakeKeeper stake.Keeper
|
|
||||||
slashingKeeper slashing.Keeper
|
|
||||||
//govKeeper gov.Keeper
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a new KavaApp.
|
// Creates a new KavaApp.
|
||||||
@ -69,49 +66,46 @@ func NewKavaApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptio
|
|||||||
cdc := CreateKavaAppCodec()
|
cdc := CreateKavaAppCodec()
|
||||||
|
|
||||||
// Create a new base app
|
// Create a new base app
|
||||||
bApp := bam.NewBaseApp(appName, cdc, logger, db, baseAppOptions...)
|
bApp := bam.NewBaseApp(appName, logger, db, auth.DefaultTxDecoder(cdc), baseAppOptions...)
|
||||||
bApp.SetCommitMultiStoreTracer(traceStore)
|
bApp.SetCommitMultiStoreTracer(traceStore)
|
||||||
|
|
||||||
// Create the kava app, extending baseApp
|
// Create the kava app, extending baseApp
|
||||||
var app = &KavaApp{
|
var app = &KavaApp{
|
||||||
BaseApp: bApp,
|
BaseApp: bApp,
|
||||||
cdc: cdc,
|
cdc: cdc,
|
||||||
keyMain: sdk.NewKVStoreKey("main"),
|
keyMain: sdk.NewKVStoreKey("main"),
|
||||||
keyAccount: sdk.NewKVStoreKey("acc"),
|
keyAccount: sdk.NewKVStoreKey("acc"),
|
||||||
keyPaychan: sdk.NewKVStoreKey("paychan"),
|
keyStake: sdk.NewKVStoreKey("stake"),
|
||||||
//keyIBC: sdk.NewKVStoreKey("ibc"),
|
keySlashing: sdk.NewKVStoreKey("slashing"),
|
||||||
keyStake: sdk.NewKVStoreKey("stake"),
|
|
||||||
keySlashing: sdk.NewKVStoreKey("slashing"),
|
|
||||||
//keyGov: sdk.NewKVStoreKey("gov"),
|
|
||||||
keyFeeCollection: sdk.NewKVStoreKey("fee"),
|
keyFeeCollection: sdk.NewKVStoreKey("fee"),
|
||||||
|
keyParams: sdk.NewKVStoreKey("params"),
|
||||||
|
tkeyParams: sdk.NewTransientStoreKey("transient_params"),
|
||||||
|
keyPaychan: sdk.NewKVStoreKey("paychan"),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the accountMapper and base account
|
// Define the accountMapper and base account
|
||||||
app.accountMapper = auth.NewAccountMapper(
|
app.accountMapper = auth.NewAccountMapper(
|
||||||
cdc,
|
app.cdc,
|
||||||
app.keyAccount,
|
app.keyAccount,
|
||||||
auth.ProtoBaseAccount,
|
auth.ProtoBaseAccount,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create the keepers
|
// Create the keepers
|
||||||
app.coinKeeper = bank.NewKeeper(app.accountMapper)
|
app.coinKeeper = bank.NewKeeper(app.accountMapper)
|
||||||
app.paychanKeeper = paychan.NewKeeper(app.cdc, app.keyPaychan, app.coinKeeper)
|
app.paramsKeeper = params.NewKeeper(app.cdc, app.keyParams)
|
||||||
//app.ibcMapper = ibc.NewMapper(app.cdc, app.keyIBC, app.RegisterCodespace(ibc.DefaultCodespace))
|
|
||||||
app.stakeKeeper = stake.NewKeeper(app.cdc, app.keyStake, app.coinKeeper, app.RegisterCodespace(stake.DefaultCodespace))
|
app.stakeKeeper = stake.NewKeeper(app.cdc, app.keyStake, app.coinKeeper, app.RegisterCodespace(stake.DefaultCodespace))
|
||||||
app.slashingKeeper = slashing.NewKeeper(app.cdc, app.keySlashing, app.stakeKeeper, app.RegisterCodespace(slashing.DefaultCodespace))
|
|
||||||
//app.govKeeper = gov.NewKeeper(app.cdc, app.keyGov, app.coinKeeper, app.stakeKeeper, app.RegisterCodespace(gov.DefaultCodespace))
|
|
||||||
app.feeCollectionKeeper = auth.NewFeeCollectionKeeper(app.cdc, app.keyFeeCollection)
|
app.feeCollectionKeeper = auth.NewFeeCollectionKeeper(app.cdc, app.keyFeeCollection)
|
||||||
|
app.slashingKeeper = slashing.NewKeeper(app.cdc, app.keySlashing, app.stakeKeeper, app.paramsKeeper.Getter(), app.RegisterCodespace(slashing.DefaultCodespace))
|
||||||
|
app.paychanKeeper = paychan.NewKeeper(app.cdc, app.keyPaychan, app.coinKeeper)
|
||||||
|
|
||||||
// Register the message handlers
|
// Register the message handlers
|
||||||
app.Router().
|
app.Router().
|
||||||
AddRoute("bank", bank.NewHandler(app.coinKeeper)).
|
AddRoute("bank", bank.NewHandler(app.coinKeeper)).
|
||||||
//AddRoute("ibc", ibc.NewHandler(app.ibcMapper, app.coinKeeper)).
|
|
||||||
AddRoute("stake", stake.NewHandler(app.stakeKeeper)).
|
AddRoute("stake", stake.NewHandler(app.stakeKeeper)).
|
||||||
AddRoute("slashing", slashing.NewHandler(app.slashingKeeper)).
|
AddRoute("slashing", slashing.NewHandler(app.slashingKeeper)).
|
||||||
AddRoute("paychan", paychan.NewHandler(app.paychanKeeper))
|
AddRoute("paychan", paychan.NewHandler(app.paychanKeeper))
|
||||||
//AddRoute("gov", gov.NewHandler(app.govKeeper))
|
|
||||||
|
|
||||||
// Set func to initialze the chain from appState in genesis file
|
// Set func to initialize the chain from appState in genesis file
|
||||||
app.SetInitChainer(app.initChainer)
|
app.SetInitChainer(app.initChainer)
|
||||||
|
|
||||||
// Set functions that run before and after txs / blocks
|
// Set functions that run before and after txs / blocks
|
||||||
@ -120,7 +114,8 @@ func NewKavaApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptio
|
|||||||
app.SetAnteHandler(auth.NewAnteHandler(app.accountMapper, app.feeCollectionKeeper))
|
app.SetAnteHandler(auth.NewAnteHandler(app.accountMapper, app.feeCollectionKeeper))
|
||||||
|
|
||||||
// Mount stores
|
// Mount stores
|
||||||
app.MountStoresIAVL(app.keyMain, app.keyAccount, app.keyStake, app.keySlashing, app.keyFeeCollection, app.keyPaychan)
|
app.MountStoresIAVL(app.keyMain, app.keyAccount, app.keyStake, app.keySlashing, app.keyFeeCollection, app.keyParams, app.keyPaychan)
|
||||||
|
app.MountStore(app.tkeyParams, sdk.StoreTypeTransient)
|
||||||
err := app.LoadLatestVersion(app.keyMain)
|
err := app.LoadLatestVersion(app.keyMain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmn.Exit(err.Error())
|
cmn.Exit(err.Error())
|
||||||
@ -132,11 +127,9 @@ func NewKavaApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptio
|
|||||||
func CreateKavaAppCodec() *wire.Codec {
|
func CreateKavaAppCodec() *wire.Codec {
|
||||||
cdc := wire.NewCodec()
|
cdc := wire.NewCodec()
|
||||||
paychan.RegisterWire(cdc)
|
paychan.RegisterWire(cdc)
|
||||||
//ibc.RegisterWire(cdc)
|
|
||||||
bank.RegisterWire(cdc)
|
bank.RegisterWire(cdc)
|
||||||
stake.RegisterWire(cdc)
|
stake.RegisterWire(cdc)
|
||||||
slashing.RegisterWire(cdc)
|
slashing.RegisterWire(cdc)
|
||||||
//gov.RegisterWire(cdc)
|
|
||||||
auth.RegisterWire(cdc)
|
auth.RegisterWire(cdc)
|
||||||
sdk.RegisterWire(cdc)
|
sdk.RegisterWire(cdc)
|
||||||
wire.RegisterCrypto(cdc)
|
wire.RegisterCrypto(cdc)
|
||||||
@ -154,18 +147,18 @@ func (app *KavaApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) ab
|
|||||||
|
|
||||||
// The function baseapp runs on receipt of a EndBlock ABCI message
|
// The function baseapp runs on receipt of a EndBlock ABCI message
|
||||||
func (app *KavaApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
|
func (app *KavaApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
|
||||||
paychan.EndBlocker(ctx, app.paychanKeeper)
|
tags := paychan.EndBlocker(ctx, app.paychanKeeper)
|
||||||
validatorUpdates := stake.EndBlocker(ctx, app.stakeKeeper)
|
|
||||||
|
|
||||||
//tags, _ := gov.EndBlocker(ctx, app.govKeeper)
|
validatorUpdates := stake.EndBlocker(ctx, app.stakeKeeper)
|
||||||
|
app.slashingKeeper.AddValidators(ctx, validatorUpdates)
|
||||||
|
|
||||||
return abci.ResponseEndBlock{
|
return abci.ResponseEndBlock{
|
||||||
ValidatorUpdates: validatorUpdates,
|
ValidatorUpdates: validatorUpdates,
|
||||||
//Tags: tags,
|
Tags: tags,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialzes the app db from the appState in the genesis file. Baseapp runs this on receipt of an InitChain ABCI message
|
// Initializes the app db from the appState in the genesis file. Baseapp runs this on receipt of an InitChain ABCI message
|
||||||
func (app *KavaApp) initChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain {
|
func (app *KavaApp) initChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain {
|
||||||
stateJSON := req.AppStateBytes
|
stateJSON := req.AppStateBytes
|
||||||
|
|
||||||
@ -183,14 +176,16 @@ func (app *KavaApp) initChainer(ctx sdk.Context, req abci.RequestInitChain) abci
|
|||||||
}
|
}
|
||||||
|
|
||||||
// load the initial stake information
|
// load the initial stake information
|
||||||
err = stake.InitGenesis(ctx, app.stakeKeeper, genesisState.StakeData)
|
validators, err := stake.InitGenesis(ctx, app.stakeKeeper, genesisState.StakeData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
//gov.InitGenesis(ctx, app.govKeeper, gov.DefaultGenesisState())
|
slashing.InitGenesis(ctx, app.slashingKeeper, genesisState.StakeData)
|
||||||
|
|
||||||
return abci.ResponseInitChain{}
|
return abci.ResponseInitChain{
|
||||||
|
Validators: validators,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -6,7 +6,9 @@ package app
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
"github.com/tendermint/tendermint/crypto"
|
"github.com/tendermint/tendermint/crypto"
|
||||||
tmtypes "github.com/tendermint/tendermint/types"
|
tmtypes "github.com/tendermint/tendermint/types"
|
||||||
@ -19,6 +21,8 @@ import (
|
|||||||
"github.com/cosmos/cosmos-sdk/x/stake"
|
"github.com/cosmos/cosmos-sdk/x/stake"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const defaultPassword = "password"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// Tokens given to genesis validators and accounts
|
// Tokens given to genesis validators and accounts
|
||||||
numStartingTokensValidators = int64(1000)
|
numStartingTokensValidators = int64(1000)
|
||||||
@ -61,7 +65,7 @@ func (ga *GenesisAccount) ToAccount() (acc *auth.BaseAccount) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the appInit stuct for server init command
|
// Create the appInit struct for server init command
|
||||||
func KavaAppInit() server.AppInit {
|
func KavaAppInit() server.AppInit {
|
||||||
fsAppGenState := pflag.NewFlagSet("", pflag.ContinueOnError)
|
fsAppGenState := pflag.NewFlagSet("", pflag.ContinueOnError)
|
||||||
fsAppGenTx := pflag.NewFlagSet("", pflag.ContinueOnError)
|
fsAppGenTx := pflag.NewFlagSet("", pflag.ContinueOnError)
|
||||||
@ -86,22 +90,41 @@ type KavaGenTx struct {
|
|||||||
PubKey string `json:"pub_key"`
|
PubKey string `json:"pub_key"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate a genesis transsction
|
// Generate a genesis transaction
|
||||||
func KavaAppGenTx(cdc *wire.Codec, pk crypto.PubKey, genTxConfig config.GenTx) (
|
func KavaAppGenTx(cdc *wire.Codec, pk crypto.PubKey, genTxConfig config.GenTx) (
|
||||||
appGenTx, cliPrint json.RawMessage, validator tmtypes.GenesisValidator, err error) {
|
appGenTx, cliPrint json.RawMessage, validator tmtypes.GenesisValidator, err error) {
|
||||||
|
|
||||||
// Generate address and secret key for the validator
|
// check a name for the new validator has been specified
|
||||||
if genTxConfig.Name == "" {
|
if genTxConfig.Name == "" {
|
||||||
return nil, nil, tmtypes.GenesisValidator{}, errors.New("Must specify --name (validator moniker)")
|
return nil, nil, tmtypes.GenesisValidator{}, errors.New("Must specify --name (validator moniker)")
|
||||||
}
|
}
|
||||||
var addr sdk.AccAddress
|
|
||||||
var secret string
|
// get a new password for the new account
|
||||||
addr, secret, err = server.GenerateSaveCoinKey(genTxConfig.CliRoot, genTxConfig.Name, "password", genTxConfig.Overwrite)
|
buf := client.BufferStdin()
|
||||||
|
prompt := fmt.Sprintf("Password for account '%s' (default %s):", genTxConfig.Name, defaultPassword)
|
||||||
|
keyPass, err := client.GetPassword(prompt, buf)
|
||||||
|
if err != nil && keyPass != "" {
|
||||||
|
// An error was returned that either failed to read the password from
|
||||||
|
// STDIN or the given password is not empty but failed to meet minimum
|
||||||
|
// length requirements.
|
||||||
|
return appGenTx, cliPrint, validator, err
|
||||||
|
}
|
||||||
|
if keyPass == "" {
|
||||||
|
keyPass = defaultPassword
|
||||||
|
}
|
||||||
|
|
||||||
|
// generate a new address and secret key
|
||||||
|
addr, secret, err := server.GenerateSaveCoinKey(
|
||||||
|
genTxConfig.CliRoot,
|
||||||
|
genTxConfig.Name,
|
||||||
|
defaultPassword,
|
||||||
|
genTxConfig.Overwrite,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create string to print out
|
// Create message string to print out
|
||||||
mm := map[string]string{"secret": secret}
|
mm := map[string]string{"secret": secret}
|
||||||
var bz []byte
|
var bz []byte
|
||||||
bz, err = cdc.MarshalJSON(mm)
|
bz, err = cdc.MarshalJSON(mm)
|
||||||
|
@ -3,6 +3,7 @@ package cli
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -10,9 +11,11 @@ import (
|
|||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/context"
|
"github.com/cosmos/cosmos-sdk/client/context"
|
||||||
"github.com/cosmos/cosmos-sdk/client/keys"
|
"github.com/cosmos/cosmos-sdk/client/keys"
|
||||||
|
"github.com/cosmos/cosmos-sdk/client/utils"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
"github.com/cosmos/cosmos-sdk/wire"
|
||||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||||
|
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
|
||||||
|
|
||||||
"github.com/kava-labs/kava/internal/x/paychan"
|
"github.com/kava-labs/kava/internal/x/paychan"
|
||||||
)
|
)
|
||||||
@ -31,13 +34,15 @@ func CreateChannelCmd(cdc *wire.Codec) *cobra.Command {
|
|||||||
Args: cobra.NoArgs,
|
Args: cobra.NoArgs,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
|
||||||
// Create a "client context" stuct populated with info from common flags
|
// Create a tx and cli "contexts": structs populated with info from common flags.
|
||||||
ctx := context.NewCoreContextFromViper().WithDecoder(authcmd.GetAccountDecoder(cdc))
|
txCtx := authctx.NewTxContextFromCLI().WithCodec(cdc)
|
||||||
// TODO is this needed for channelID
|
cliCtx := context.NewCLIContext().
|
||||||
// ctx.PrintResponse = true
|
WithCodec(cdc).
|
||||||
|
WithLogger(os.Stdout).
|
||||||
|
WithAccountDecoder(authcmd.GetAccountDecoder(cdc))
|
||||||
|
|
||||||
// Get sender adress
|
// Get sender address
|
||||||
sender, err := ctx.GetFromAddress()
|
sender, err := cliCtx.GetFromAddress()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -67,11 +72,7 @@ func CreateChannelCmd(cdc *wire.Codec) *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build and sign the transaction, then broadcast to the blockchain
|
// Build and sign the transaction, then broadcast to the blockchain
|
||||||
err = ctx.EnsureSignBuildBroadcast(ctx.FromAddressName, []sdk.Msg{msg}, cdc)
|
return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cmd.Flags().String(flagTo, "", "Recipient address of the payment channel.")
|
cmd.Flags().String(flagTo, "", "Recipient address of the payment channel.")
|
||||||
@ -92,8 +93,11 @@ func GeneratePaymentCmd(cdc *wire.Codec) *cobra.Command {
|
|||||||
Args: cobra.NoArgs,
|
Args: cobra.NoArgs,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
|
||||||
// Create a "client context" stuct populated with info from common flags
|
// Create a cli "context": struct populated with info from common flags.
|
||||||
ctx := context.NewCoreContextFromViper().WithDecoder(authcmd.GetAccountDecoder(cdc))
|
cliCtx := context.NewCLIContext().
|
||||||
|
WithCodec(cdc).
|
||||||
|
WithLogger(os.Stdout).
|
||||||
|
WithAccountDecoder(authcmd.GetAccountDecoder(cdc))
|
||||||
|
|
||||||
// Get the paychan id
|
// Get the paychan id
|
||||||
id := paychan.ChannelID(viper.GetInt64(flagId)) // TODO make this default to pulling id from chain
|
id := paychan.ChannelID(viper.GetInt64(flagId)) // TODO make this default to pulling id from chain
|
||||||
@ -121,8 +125,8 @@ func GeneratePaymentCmd(cdc *wire.Codec) *cobra.Command {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
name := ctx.FromAddressName
|
name := cliCtx.FromAddressName
|
||||||
passphrase, err := ctx.GetPassphraseFromStdin(name)
|
passphrase, err := keys.GetPassphrase(cliCtx.FromAddressName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -169,8 +173,11 @@ func VerifyPaymentCmd(cdc *wire.Codec, paychanStoreName string) *cobra.Command {
|
|||||||
Args: cobra.NoArgs,
|
Args: cobra.NoArgs,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
|
||||||
// Create a "client context" stuct populated with info from common flags
|
// Create a cli "context": struct populated with info from common flags.
|
||||||
ctx := context.NewCoreContextFromViper()
|
cliCtx := context.NewCLIContext().
|
||||||
|
WithCodec(cdc).
|
||||||
|
WithLogger(os.Stdout).
|
||||||
|
WithAccountDecoder(authcmd.GetAccountDecoder(cdc))
|
||||||
|
|
||||||
// read in update
|
// read in update
|
||||||
bz, err := ioutil.ReadFile(viper.GetString(flagPaymentFile))
|
bz, err := ioutil.ReadFile(viper.GetString(flagPaymentFile))
|
||||||
@ -183,7 +190,7 @@ func VerifyPaymentCmd(cdc *wire.Codec, paychanStoreName string) *cobra.Command {
|
|||||||
cdc.UnmarshalJSON(bz, &update)
|
cdc.UnmarshalJSON(bz, &update)
|
||||||
|
|
||||||
// get the channel from the node
|
// get the channel from the node
|
||||||
res, err := ctx.QueryStore(paychan.GetChannelKey(update.ChannelID), paychanStoreName)
|
res, err := cliCtx.QueryStore(paychan.GetChannelKey(update.ChannelID), paychanStoreName)
|
||||||
if len(res) == 0 || err != nil {
|
if len(res) == 0 || err != nil {
|
||||||
return errors.Errorf("channel with ID '%d' does not exist", update.ChannelID)
|
return errors.Errorf("channel with ID '%d' does not exist", update.ChannelID)
|
||||||
}
|
}
|
||||||
@ -218,12 +225,15 @@ func SubmitPaymentCmd(cdc *wire.Codec) *cobra.Command {
|
|||||||
Args: cobra.NoArgs,
|
Args: cobra.NoArgs,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
|
||||||
// Create a "client context" stuct populated with info from common flags
|
// Create a tx and cli "contexts": structs populated with info from common flags.
|
||||||
ctx := context.NewCoreContextFromViper().WithDecoder(authcmd.GetAccountDecoder(cdc))
|
txCtx := authctx.NewTxContextFromCLI().WithCodec(cdc)
|
||||||
// ctx.PrintResponse = true TODO is this needed for channelID
|
cliCtx := context.NewCLIContext().
|
||||||
|
WithCodec(cdc).
|
||||||
|
WithLogger(os.Stdout).
|
||||||
|
WithAccountDecoder(authcmd.GetAccountDecoder(cdc))
|
||||||
|
|
||||||
// Get sender adress
|
// Get sender address
|
||||||
submitter, err := ctx.GetFromAddress()
|
submitter, err := cliCtx.GetFromAddress()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -248,11 +258,7 @@ func SubmitPaymentCmd(cdc *wire.Codec) *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build and sign the transaction, then broadcast to the blockchain
|
// Build and sign the transaction, then broadcast to the blockchain
|
||||||
err = ctx.EnsureSignBuildBroadcast(ctx.FromAddressName, []sdk.Msg{msg}, cdc)
|
return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cmd.Flags().String(flagPaymentFile, "payment.json", "File to read the payment from.")
|
cmd.Flags().String(flagPaymentFile, "payment.json", "File to read the payment from.")
|
||||||
@ -268,14 +274,17 @@ func GetChannelCmd(cdc *wire.Codec, paychanStoreName string) *cobra.Command {
|
|||||||
Args: cobra.NoArgs,
|
Args: cobra.NoArgs,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
|
||||||
// Create a "client context" stuct populated with info from common flags
|
// Create a cli "context": struct populated with info from common flags.
|
||||||
ctx := context.NewCoreContextFromViper()
|
cliCtx := context.NewCLIContext().
|
||||||
|
WithCodec(cdc).
|
||||||
|
WithLogger(os.Stdout).
|
||||||
|
WithAccountDecoder(authcmd.GetAccountDecoder(cdc))
|
||||||
|
|
||||||
// Get channel ID
|
// Get channel ID
|
||||||
id := paychan.ChannelID(viper.GetInt64(flagId))
|
id := paychan.ChannelID(viper.GetInt64(flagId))
|
||||||
|
|
||||||
// Get the channel from the node
|
// Get the channel from the node
|
||||||
res, err := ctx.QueryStore(paychan.GetChannelKey(id), paychanStoreName)
|
res, err := cliCtx.QueryStore(paychan.GetChannelKey(id), paychanStoreName)
|
||||||
if len(res) == 0 || err != nil {
|
if len(res) == 0 || err != nil {
|
||||||
return errors.Errorf("channel with ID '%d' does not exist", id)
|
return errors.Errorf("channel with ID '%d' does not exist", id)
|
||||||
}
|
}
|
||||||
@ -291,11 +300,11 @@ func GetChannelCmd(cdc *wire.Codec, paychanStoreName string) *cobra.Command {
|
|||||||
fmt.Println(string(jsonChannel))
|
fmt.Println(string(jsonChannel))
|
||||||
|
|
||||||
// Get any submitted updates from the node
|
// Get any submitted updates from the node
|
||||||
res, err = ctx.QueryStore(paychan.GetSubmittedUpdateKey(id), paychanStoreName)
|
res, err = cliCtx.QueryStore(paychan.GetSubmittedUpdateKey(id), paychanStoreName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Print out the submited update if it exsits
|
// Print out the submitted update if it exists
|
||||||
if len(res) != 0 {
|
if len(res) != 0 {
|
||||||
var submittedUpdate paychan.SubmittedUpdate
|
var submittedUpdate paychan.SubmittedUpdate
|
||||||
cdc.MustUnmarshalBinary(res, &submittedUpdate)
|
cdc.MustUnmarshalBinary(res, &submittedUpdate)
|
@ -1,9 +1,10 @@
|
|||||||
package paychan
|
package paychan
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"testing"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestEndBlocker(t *testing.T) {
|
func TestEndBlocker(t *testing.T) {
|
||||||
@ -14,7 +15,7 @@ func TestEndBlocker(t *testing.T) {
|
|||||||
ctx, _, channelKeeper, addrs, _, _, _ := createMockApp(accountSeeds)
|
ctx, _, channelKeeper, addrs, _, _, _ := createMockApp(accountSeeds)
|
||||||
sender := addrs[0]
|
sender := addrs[0]
|
||||||
receiver := addrs[1]
|
receiver := addrs[1]
|
||||||
coins := sdk.Coins{sdk.NewCoin("KVA", 10)}
|
coins := sdk.Coins{sdk.NewInt64Coin("KVA", 10)}
|
||||||
|
|
||||||
// create new channel
|
// create new channel
|
||||||
channelID := ChannelID(0) // should be 0 as first channel
|
channelID := ChannelID(0) // should be 0 as first channel
|
||||||
@ -26,11 +27,10 @@ func TestEndBlocker(t *testing.T) {
|
|||||||
channelKeeper.setChannel(ctx, channel)
|
channelKeeper.setChannel(ctx, channel)
|
||||||
|
|
||||||
// create closing update and submittedUpdate
|
// create closing update and submittedUpdate
|
||||||
payout := Payout{sdk.Coins{sdk.NewCoin("KVA", 3)}, sdk.Coins{sdk.NewCoin("KVA", 7)}}
|
payout := Payout{sdk.Coins{sdk.NewInt64Coin("KVA", 3)}, sdk.Coins{sdk.NewInt64Coin("KVA", 7)}}
|
||||||
update := Update{
|
update := Update{
|
||||||
ChannelID: channelID,
|
ChannelID: channelID,
|
||||||
Payout: payout,
|
Payout: payout,
|
||||||
//Sigs: [1]crypto.Signature{},
|
|
||||||
}
|
}
|
||||||
sUpdate := SubmittedUpdate{
|
sUpdate := SubmittedUpdate{
|
||||||
Update: update,
|
Update: update,
|
||||||
|
@ -30,7 +30,7 @@ func TestKeeper(t *testing.T) {
|
|||||||
"HappyPath",
|
"HappyPath",
|
||||||
addrs[senderAccountIndex],
|
addrs[senderAccountIndex],
|
||||||
addrs[receiverAccountIndex],
|
addrs[receiverAccountIndex],
|
||||||
sdk.Coins{sdk.NewCoin("KVA", 10)},
|
sdk.Coins{sdk.NewInt64Coin("KVA", 10)},
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
@ -38,7 +38,7 @@ func TestKeeper(t *testing.T) {
|
|||||||
"NilAddress",
|
"NilAddress",
|
||||||
sdk.AccAddress{},
|
sdk.AccAddress{},
|
||||||
sdk.AccAddress{},
|
sdk.AccAddress{},
|
||||||
sdk.Coins{sdk.NewCoin("KVA", 10)},
|
sdk.Coins{sdk.NewInt64Coin("KVA", 10)},
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
@ -54,7 +54,7 @@ func TestKeeper(t *testing.T) {
|
|||||||
"NegativeCoins",
|
"NegativeCoins",
|
||||||
addrs[senderAccountIndex],
|
addrs[senderAccountIndex],
|
||||||
addrs[receiverAccountIndex],
|
addrs[receiverAccountIndex],
|
||||||
sdk.Coins{sdk.NewCoin("KVA", -57)},
|
sdk.Coins{sdk.NewInt64Coin("KVA", -57)},
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
@ -126,7 +126,7 @@ func TestKeeper(t *testing.T) {
|
|||||||
)
|
)
|
||||||
ctx, coinKeeper, channelKeeper, addrs, pubKeys, privKeys, genAccFunding := createMockApp(accountSeeds)
|
ctx, coinKeeper, channelKeeper, addrs, pubKeys, privKeys, genAccFunding := createMockApp(accountSeeds)
|
||||||
|
|
||||||
coins := sdk.Coins{sdk.NewCoin("KVA", 10)}
|
coins := sdk.Coins{sdk.NewInt64Coin("KVA", 10)}
|
||||||
|
|
||||||
// create new channel
|
// create new channel
|
||||||
channelID := ChannelID(0) // should be 0 as first channel
|
channelID := ChannelID(0) // should be 0 as first channel
|
||||||
@ -138,7 +138,7 @@ func TestKeeper(t *testing.T) {
|
|||||||
channelKeeper.setChannel(ctx, channel)
|
channelKeeper.setChannel(ctx, channel)
|
||||||
|
|
||||||
// create closing update
|
// create closing update
|
||||||
payout := Payout{sdk.Coins{sdk.NewCoin("KVA", 3)}, sdk.Coins{sdk.NewCoin("KVA", 7)}}
|
payout := Payout{sdk.Coins{sdk.NewInt64Coin("KVA", 3)}, sdk.Coins{sdk.NewInt64Coin("KVA", 7)}}
|
||||||
update := Update{
|
update := Update{
|
||||||
ChannelID: channelID,
|
ChannelID: channelID,
|
||||||
Payout: payout,
|
Payout: payout,
|
||||||
@ -200,14 +200,14 @@ func TestKeeper(t *testing.T) {
|
|||||||
{
|
{
|
||||||
"HappyPath",
|
"HappyPath",
|
||||||
true,
|
true,
|
||||||
testUpdate{chanID, Payout{sdk.Coins{sdk.NewCoin("KVA", 3)}, sdk.Coins{sdk.NewCoin("KVA", 7)}}, senderAccountIndex, senderAccountIndex},
|
testUpdate{chanID, Payout{sdk.Coins{sdk.NewInt64Coin("KVA", 3)}, sdk.Coins{sdk.NewInt64Coin("KVA", 7)}}, senderAccountIndex, senderAccountIndex},
|
||||||
"sameAsSubmited",
|
"sameAsSubmited",
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"NoChannel",
|
"NoChannel",
|
||||||
false,
|
false,
|
||||||
testUpdate{chanID, Payout{sdk.Coins{sdk.NewCoin("KVA", 3)}, sdk.Coins{sdk.NewCoin("KVA", 7)}}, senderAccountIndex, senderAccountIndex},
|
testUpdate{chanID, Payout{sdk.Coins{sdk.NewInt64Coin("KVA", 3)}, sdk.Coins{sdk.NewInt64Coin("KVA", 7)}}, senderAccountIndex, senderAccountIndex},
|
||||||
"empty",
|
"empty",
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
@ -221,35 +221,35 @@ func TestKeeper(t *testing.T) {
|
|||||||
{
|
{
|
||||||
"NegativeCoins",
|
"NegativeCoins",
|
||||||
true,
|
true,
|
||||||
testUpdate{chanID, Payout{sdk.Coins{sdk.NewCoin("KVA", -5)}, sdk.Coins{sdk.NewCoin("KVA", 15)}}, senderAccountIndex, senderAccountIndex},
|
testUpdate{chanID, Payout{sdk.Coins{sdk.NewInt64Coin("KVA", -5)}, sdk.Coins{sdk.NewInt64Coin("KVA", 15)}}, senderAccountIndex, senderAccountIndex},
|
||||||
"empty",
|
"empty",
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"TooManyCoins",
|
"TooManyCoins",
|
||||||
true,
|
true,
|
||||||
testUpdate{chanID, Payout{sdk.Coins{sdk.NewCoin("KVA", 100)}, sdk.Coins{sdk.NewCoin("KVA", 7)}}, senderAccountIndex, senderAccountIndex},
|
testUpdate{chanID, Payout{sdk.Coins{sdk.NewInt64Coin("KVA", 100)}, sdk.Coins{sdk.NewInt64Coin("KVA", 7)}}, senderAccountIndex, senderAccountIndex},
|
||||||
"empty",
|
"empty",
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"WrongSignature",
|
"WrongSignature",
|
||||||
true,
|
true,
|
||||||
testUpdate{chanID, Payout{sdk.Coins{sdk.NewCoin("KVA", 3)}, sdk.Coins{sdk.NewCoin("KVA", 7)}}, senderAccountIndex, otherAccountIndex},
|
testUpdate{chanID, Payout{sdk.Coins{sdk.NewInt64Coin("KVA", 3)}, sdk.Coins{sdk.NewInt64Coin("KVA", 7)}}, senderAccountIndex, otherAccountIndex},
|
||||||
"empty",
|
"empty",
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"WrongPubKey",
|
"WrongPubKey",
|
||||||
true,
|
true,
|
||||||
testUpdate{chanID, Payout{sdk.Coins{sdk.NewCoin("KVA", 3)}, sdk.Coins{sdk.NewCoin("KVA", 7)}}, otherAccountIndex, senderAccountIndex},
|
testUpdate{chanID, Payout{sdk.Coins{sdk.NewInt64Coin("KVA", 3)}, sdk.Coins{sdk.NewInt64Coin("KVA", 7)}}, otherAccountIndex, senderAccountIndex},
|
||||||
"empty",
|
"empty",
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ReceiverSigned",
|
"ReceiverSigned",
|
||||||
true,
|
true,
|
||||||
testUpdate{chanID, Payout{sdk.Coins{sdk.NewCoin("KVA", 3)}, sdk.Coins{sdk.NewCoin("KVA", 7)}}, receiverAccountIndex, receiverAccountIndex},
|
testUpdate{chanID, Payout{sdk.Coins{sdk.NewInt64Coin("KVA", 3)}, sdk.Coins{sdk.NewInt64Coin("KVA", 7)}}, receiverAccountIndex, receiverAccountIndex},
|
||||||
"empty",
|
"empty",
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
@ -266,7 +266,7 @@ func TestKeeper(t *testing.T) {
|
|||||||
channel := Channel{
|
channel := Channel{
|
||||||
ID: chanID, // should be 0 as first channel
|
ID: chanID, // should be 0 as first channel
|
||||||
Participants: [2]sdk.AccAddress{addrs[senderAccountIndex], addrs[receiverAccountIndex]},
|
Participants: [2]sdk.AccAddress{addrs[senderAccountIndex], addrs[receiverAccountIndex]},
|
||||||
Coins: sdk.Coins{sdk.NewCoin("KVA", 10)},
|
Coins: sdk.Coins{sdk.NewInt64Coin("KVA", 10)},
|
||||||
}
|
}
|
||||||
channelKeeper.setChannel(ctx, channel)
|
channelKeeper.setChannel(ctx, channel)
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ func createMockApp(accountSeeds []string) (sdk.Context, bank.Keeper, Keeper, []s
|
|||||||
mApp.CompleteSetup([]*sdk.KVStoreKey{keyChannel})
|
mApp.CompleteSetup([]*sdk.KVStoreKey{keyChannel})
|
||||||
|
|
||||||
// create some accounts
|
// create some accounts
|
||||||
genAccFunding := sdk.Coins{sdk.NewCoin("KVA", 1000)}
|
genAccFunding := sdk.Coins{sdk.NewInt64Coin("KVA", 1000)}
|
||||||
genAccs, addrs, pubKeys, privKeys := createTestGenAccounts(accountSeeds, genAccFunding)
|
genAccs, addrs, pubKeys, privKeys := createTestGenAccounts(accountSeeds, genAccFunding)
|
||||||
|
|
||||||
// initialize the app with these accounts
|
// initialize the app with these accounts
|
||||||
|
@ -61,7 +61,7 @@ func (p Payout) Sum() sdk.Coins {
|
|||||||
|
|
||||||
type UpdateSignature struct {
|
type UpdateSignature struct {
|
||||||
PubKey crypto.PubKey
|
PubKey crypto.PubKey
|
||||||
CryptoSignature crypto.Signature
|
CryptoSignature []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
// An update that has been submitted to the blockchain, but not yet acted on.
|
// An update that has been submitted to the blockchain, but not yet acted on.
|
||||||
|
@ -28,18 +28,18 @@ func TestSubmittedUpdatesQueue(t *testing.T) {
|
|||||||
|
|
||||||
func TestPayout(t *testing.T) {
|
func TestPayout(t *testing.T) {
|
||||||
t.Run("IsNotNegative", func(t *testing.T) {
|
t.Run("IsNotNegative", func(t *testing.T) {
|
||||||
p := Payout{sdk.Coins{sdk.NewCoin("USD", 4), sdk.NewCoin("GBP", 0)}, sdk.Coins{sdk.NewCoin("USD", 129879234), sdk.NewCoin("GBP", 1)}}
|
p := Payout{sdk.Coins{sdk.NewInt64Coin("USD", 4), sdk.NewInt64Coin("GBP", 0)}, sdk.Coins{sdk.NewInt64Coin("USD", 129879234), sdk.NewInt64Coin("GBP", 1)}}
|
||||||
assert.True(t, p.IsNotNegative())
|
assert.True(t, p.IsNotNegative())
|
||||||
|
|
||||||
p = Payout{sdk.Coins{sdk.NewCoin("USD", -4), sdk.NewCoin("GBP", 0)}, sdk.Coins{sdk.NewCoin("USD", 129879234), sdk.NewCoin("GBP", 1)}}
|
p = Payout{sdk.Coins{sdk.NewInt64Coin("USD", -4), sdk.NewInt64Coin("GBP", 0)}, sdk.Coins{sdk.NewInt64Coin("USD", 129879234), sdk.NewInt64Coin("GBP", 1)}}
|
||||||
assert.False(t, p.IsNotNegative())
|
assert.False(t, p.IsNotNegative())
|
||||||
})
|
})
|
||||||
t.Run("Sum", func(t *testing.T) {
|
t.Run("Sum", func(t *testing.T) {
|
||||||
p := Payout{
|
p := Payout{
|
||||||
sdk.Coins{sdk.NewCoin("EUR", 1), sdk.NewCoin("USD", -5)},
|
sdk.Coins{sdk.NewInt64Coin("EUR", 1), sdk.NewInt64Coin("USD", -5)},
|
||||||
sdk.Coins{sdk.NewCoin("EUR", 1), sdk.NewCoin("USD", 100), sdk.NewCoin("GBP", 1)},
|
sdk.Coins{sdk.NewInt64Coin("EUR", 1), sdk.NewInt64Coin("USD", 100), sdk.NewInt64Coin("GBP", 1)},
|
||||||
}
|
}
|
||||||
expected := sdk.Coins{sdk.NewCoin("EUR", 2), sdk.NewCoin("GBP", 1), sdk.NewCoin("USD", 95)}
|
expected := sdk.Coins{sdk.NewInt64Coin("EUR", 2), sdk.NewInt64Coin("GBP", 1), sdk.NewInt64Coin("USD", 95)}
|
||||||
assert.Equal(t, expected, p.Sum())
|
assert.Equal(t, expected, p.Sum())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user