Merge pull request #233 from cosmos/rename-cosmos-sdk
Rename basecoin to cosmos-sdk
This commit is contained in:
commit
d77e81ae46
2
Makefile
2
Makefile
|
@ -3,7 +3,7 @@ GOTOOLS = github.com/mitchellh/gox \
|
|||
github.com/rigelrozanski/shelldown/cmd/shelldown
|
||||
TUTORIALS=$(shell find docs/guide -name "*md" -type f)
|
||||
|
||||
LINKER_FLAGS:="-X github.com/tendermint/basecoin/client/commands.CommitHash=`git rev-parse --short HEAD`"
|
||||
LINKER_FLAGS:="-X github.com/cosmos/cosmos-sdk/client/commands.CommitHash=`git rev-parse --short HEAD`"
|
||||
|
||||
all: get_vendor_deps install test
|
||||
|
||||
|
|
22
app/app.go
22
app/app.go
|
@ -9,11 +9,11 @@ import (
|
|||
cmn "github.com/tendermint/tmlibs/common"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
sm "github.com/tendermint/basecoin/state"
|
||||
"github.com/tendermint/basecoin/version"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/errors"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
sm "github.com/cosmos/cosmos-sdk/state"
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
)
|
||||
|
||||
//nolint
|
||||
|
@ -27,7 +27,7 @@ type Basecoin struct {
|
|||
info *sm.ChainState
|
||||
state *Store
|
||||
|
||||
handler basecoin.Handler
|
||||
handler sdk.Handler
|
||||
|
||||
pending []*abci.Validator
|
||||
height uint64
|
||||
|
@ -37,7 +37,7 @@ type Basecoin struct {
|
|||
var _ abci.Application = &Basecoin{}
|
||||
|
||||
// NewBasecoin - create a new instance of the basecoin application
|
||||
func NewBasecoin(handler basecoin.Handler, store *Store, logger log.Logger) *Basecoin {
|
||||
func NewBasecoin(handler sdk.Handler, store *Store, logger log.Logger) *Basecoin {
|
||||
return &Basecoin{
|
||||
handler: handler,
|
||||
info: sm.NewChainState(),
|
||||
|
@ -96,7 +96,7 @@ func (app *Basecoin) SetOption(key string, value string) string {
|
|||
|
||||
// DeliverTx - ABCI
|
||||
func (app *Basecoin) DeliverTx(txBytes []byte) abci.Result {
|
||||
tx, err := basecoin.LoadTx(txBytes)
|
||||
tx, err := sdk.LoadTx(txBytes)
|
||||
if err != nil {
|
||||
return errors.Result(err)
|
||||
}
|
||||
|
@ -112,12 +112,12 @@ func (app *Basecoin) DeliverTx(txBytes []byte) abci.Result {
|
|||
return errors.Result(err)
|
||||
}
|
||||
app.addValChange(res.Diff)
|
||||
return basecoin.ToABCI(res)
|
||||
return sdk.ToABCI(res)
|
||||
}
|
||||
|
||||
// CheckTx - ABCI
|
||||
func (app *Basecoin) CheckTx(txBytes []byte) abci.Result {
|
||||
tx, err := basecoin.LoadTx(txBytes)
|
||||
tx, err := sdk.LoadTx(txBytes)
|
||||
if err != nil {
|
||||
return errors.Result(err)
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ func (app *Basecoin) CheckTx(txBytes []byte) abci.Result {
|
|||
if err != nil {
|
||||
return errors.Result(err)
|
||||
}
|
||||
return basecoin.ToABCI(res)
|
||||
return sdk.ToABCI(res)
|
||||
}
|
||||
|
||||
// Query - ABCI
|
||||
|
|
|
@ -8,22 +8,22 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
abci "github.com/tendermint/abci/types"
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/modules/auth"
|
||||
"github.com/tendermint/basecoin/modules/base"
|
||||
"github.com/tendermint/basecoin/modules/coin"
|
||||
"github.com/tendermint/basecoin/modules/fee"
|
||||
"github.com/tendermint/basecoin/modules/ibc"
|
||||
"github.com/tendermint/basecoin/modules/nonce"
|
||||
"github.com/tendermint/basecoin/modules/roles"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/modules/auth"
|
||||
"github.com/cosmos/cosmos-sdk/modules/base"
|
||||
"github.com/cosmos/cosmos-sdk/modules/coin"
|
||||
"github.com/cosmos/cosmos-sdk/modules/fee"
|
||||
"github.com/cosmos/cosmos-sdk/modules/ibc"
|
||||
"github.com/cosmos/cosmos-sdk/modules/nonce"
|
||||
"github.com/cosmos/cosmos-sdk/modules/roles"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
wire "github.com/tendermint/go-wire"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
)
|
||||
|
||||
// DefaultHandler for the tests (coin, roles, ibc)
|
||||
func DefaultHandler(feeDenom string) basecoin.Handler {
|
||||
func DefaultHandler(feeDenom string) sdk.Handler {
|
||||
// use the default stack
|
||||
r := roles.NewHandler()
|
||||
i := ibc.NewHandler()
|
||||
|
@ -70,30 +70,30 @@ func newAppTest(t *testing.T) *appTest {
|
|||
}
|
||||
|
||||
// baseTx is the
|
||||
func (at *appTest) baseTx(coins coin.Coins) basecoin.Tx {
|
||||
func (at *appTest) baseTx(coins coin.Coins) sdk.Tx {
|
||||
in := []coin.TxInput{{Address: at.acctIn.Actor(), Coins: coins}}
|
||||
out := []coin.TxOutput{{Address: at.acctOut.Actor(), Coins: coins}}
|
||||
tx := coin.NewSendTx(in, out)
|
||||
return tx
|
||||
}
|
||||
|
||||
func (at *appTest) signTx(tx basecoin.Tx) basecoin.Tx {
|
||||
func (at *appTest) signTx(tx sdk.Tx) sdk.Tx {
|
||||
stx := auth.NewMulti(tx)
|
||||
auth.Sign(stx, at.acctIn.Key)
|
||||
return stx.Wrap()
|
||||
}
|
||||
|
||||
func (at *appTest) getTx(coins coin.Coins, sequence uint32) basecoin.Tx {
|
||||
func (at *appTest) getTx(coins coin.Coins, sequence uint32) sdk.Tx {
|
||||
tx := at.baseTx(coins)
|
||||
tx = nonce.NewTx(sequence, []basecoin.Actor{at.acctIn.Actor()}, tx)
|
||||
tx = nonce.NewTx(sequence, []sdk.Actor{at.acctIn.Actor()}, tx)
|
||||
tx = base.NewChainTx(at.chainID, 0, tx)
|
||||
return at.signTx(tx)
|
||||
}
|
||||
|
||||
func (at *appTest) feeTx(coins coin.Coins, toll coin.Coin, sequence uint32) basecoin.Tx {
|
||||
func (at *appTest) feeTx(coins coin.Coins, toll coin.Coin, sequence uint32) sdk.Tx {
|
||||
tx := at.baseTx(coins)
|
||||
tx = fee.NewFee(tx, toll, at.acctIn.Actor())
|
||||
tx = nonce.NewTx(sequence, []basecoin.Actor{at.acctIn.Actor()}, tx)
|
||||
tx = nonce.NewTx(sequence, []sdk.Actor{at.acctIn.Actor()}, tx)
|
||||
tx = base.NewChainTx(at.chainID, 0, tx)
|
||||
return at.signTx(tx)
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ func (at *appTest) reset() {
|
|||
require.True(at.t, resabci.IsOK(), resabci)
|
||||
}
|
||||
|
||||
func getBalance(key basecoin.Actor, store state.SimpleDB) (coin.Coins, error) {
|
||||
func getBalance(key sdk.Actor, store state.SimpleDB) (coin.Coins, error) {
|
||||
cspace := stack.PrefixedStore(coin.NameCoin, store)
|
||||
acct, err := coin.GetAccount(cspace, key)
|
||||
return acct.Coins, err
|
||||
|
@ -143,7 +143,7 @@ func getAddr(addr []byte, state state.SimpleDB) (coin.Coins, error) {
|
|||
}
|
||||
|
||||
// returns the final balance and expected balance for input and output accounts
|
||||
func (at *appTest) exec(t *testing.T, tx basecoin.Tx, checkTx bool) (res abci.Result, diffIn, diffOut coin.Coins) {
|
||||
func (at *appTest) exec(t *testing.T, tx sdk.Tx, checkTx bool) (res abci.Result, diffIn, diffOut coin.Coins) {
|
||||
require := require.New(t)
|
||||
|
||||
initBalIn, err := getBalance(at.acctIn.Actor(), at.app.GetState())
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
abci "github.com/tendermint/abci/types"
|
||||
"github.com/tendermint/basecoin/modules/base"
|
||||
"github.com/cosmos/cosmos-sdk/modules/base"
|
||||
wire "github.com/tendermint/go-wire"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
cmn "github.com/tendermint/tmlibs/common"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin/modules/coin"
|
||||
"github.com/cosmos/cosmos-sdk/modules/coin"
|
||||
)
|
||||
|
||||
const genesisFilepath = "./testdata/genesis.json"
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
dbm "github.com/tendermint/tmlibs/db"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin/state"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
)
|
||||
|
||||
// Store contains the merkle tree, and all info to handle abci requests
|
||||
|
|
|
@ -9,15 +9,15 @@ import (
|
|||
cmn "github.com/tendermint/tmlibs/common"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/app"
|
||||
"github.com/tendermint/basecoin/modules/auth"
|
||||
"github.com/tendermint/basecoin/modules/base"
|
||||
"github.com/tendermint/basecoin/modules/coin"
|
||||
"github.com/tendermint/basecoin/modules/fee"
|
||||
"github.com/tendermint/basecoin/modules/nonce"
|
||||
"github.com/tendermint/basecoin/modules/roles"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/app"
|
||||
"github.com/cosmos/cosmos-sdk/modules/auth"
|
||||
"github.com/cosmos/cosmos-sdk/modules/base"
|
||||
"github.com/cosmos/cosmos-sdk/modules/coin"
|
||||
"github.com/cosmos/cosmos-sdk/modules/fee"
|
||||
"github.com/cosmos/cosmos-sdk/modules/nonce"
|
||||
"github.com/cosmos/cosmos-sdk/modules/roles"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
)
|
||||
|
||||
type BenchApp struct {
|
||||
|
@ -27,7 +27,7 @@ type BenchApp struct {
|
|||
}
|
||||
|
||||
// DefaultHandler - placeholder to just handle sendtx
|
||||
func DefaultHandler(feeDenom string) basecoin.Handler {
|
||||
func DefaultHandler(feeDenom string) sdk.Handler {
|
||||
// use the default stack
|
||||
c := coin.NewHandler()
|
||||
r := roles.NewHandler()
|
||||
|
@ -46,7 +46,7 @@ func DefaultHandler(feeDenom string) basecoin.Handler {
|
|||
).Use(d)
|
||||
}
|
||||
|
||||
func NewBenchApp(h basecoin.Handler, chainID string, n int,
|
||||
func NewBenchApp(h sdk.Handler, chainID string, n int,
|
||||
persist bool) BenchApp {
|
||||
|
||||
logger := log.NewNopLogger()
|
||||
|
@ -107,7 +107,7 @@ func (b BenchApp) makeTx(useFee bool) []byte {
|
|||
tx = fee.NewFee(tx, toll, sender.Actor())
|
||||
}
|
||||
sequence := sender.NextSequence()
|
||||
tx = nonce.NewTx(sequence, []basecoin.Actor{sender.Actor()}, tx)
|
||||
tx = nonce.NewTx(sequence, []sdk.Actor{sender.Actor()}, tx)
|
||||
tx = base.NewChainTx(b.ChainID, 0, tx)
|
||||
stx := auth.NewMulti(tx)
|
||||
auth.Sign(stx, sender.Key)
|
||||
|
|
|
@ -20,8 +20,8 @@ import (
|
|||
|
||||
rpcclient "github.com/tendermint/tendermint/rpc/client"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/modules/auth"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/modules/auth"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -86,9 +86,9 @@ func GetCertifier() (*certifiers.InquiringCertifier, error) {
|
|||
|
||||
// ParseActor parses an address of form:
|
||||
// [<chain>:][<app>:]<hex address>
|
||||
// into a basecoin.Actor.
|
||||
// into a sdk.Actor.
|
||||
// If app is not specified or "", then assume auth.NameSigs
|
||||
func ParseActor(input string) (res basecoin.Actor, err error) {
|
||||
func ParseActor(input string) (res sdk.Actor, err error) {
|
||||
chain, app := "", auth.NameSigs
|
||||
input = strings.TrimSpace(input)
|
||||
spl := strings.SplitN(input, ":", 3)
|
||||
|
@ -108,7 +108,7 @@ func ParseActor(input string) (res basecoin.Actor, err error) {
|
|||
if err != nil {
|
||||
return res, errors.Errorf("Address is invalid hex: %v\n", err)
|
||||
}
|
||||
res = basecoin.Actor{
|
||||
res = sdk.Actor{
|
||||
ChainID: chain,
|
||||
App: app,
|
||||
Address: addr,
|
||||
|
@ -118,8 +118,8 @@ func ParseActor(input string) (res basecoin.Actor, err error) {
|
|||
|
||||
// ParseActors takes a comma-separated list of actors and parses them into
|
||||
// a slice
|
||||
func ParseActors(key string) (signers []basecoin.Actor, err error) {
|
||||
var act basecoin.Actor
|
||||
func ParseActors(key string) (signers []sdk.Actor, err error) {
|
||||
var act sdk.Actor
|
||||
for _, k := range strings.Split(key, ",") {
|
||||
act, err = ParseActor(k)
|
||||
if err != nil {
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
cmn "github.com/tendermint/tmlibs/common"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
)
|
||||
|
||||
// RootCmd represents the base command when called without any subcommands
|
||||
|
|
|
@ -16,7 +16,7 @@ import (
|
|||
"github.com/tendermint/merkleeyes/iavl"
|
||||
"github.com/tendermint/tendermint/rpc/client"
|
||||
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
)
|
||||
|
||||
// GetParsed does most of the work of the query commands, but is quite
|
||||
|
|
|
@ -17,8 +17,8 @@ import (
|
|||
"github.com/tendermint/tendermint/types"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin/app"
|
||||
"github.com/tendermint/basecoin/modules/eyes"
|
||||
"github.com/cosmos/cosmos-sdk/app"
|
||||
"github.com/cosmos/cosmos-sdk/modules/eyes"
|
||||
)
|
||||
|
||||
var node *nm.Node
|
||||
|
|
|
@ -2,7 +2,7 @@ package query
|
|||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
)
|
||||
|
||||
// nolint
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
)
|
||||
|
||||
// KeyQueryCmd - CLI command to query a state by key with proof
|
||||
|
|
|
@ -4,11 +4,11 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
wire "github.com/tendermint/go-wire"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
)
|
||||
|
||||
// TxQueryCmd - CLI command to query a transaction with proof
|
||||
|
@ -65,9 +65,9 @@ func txQueryCmd(cmd *cobra.Command, args []string) error {
|
|||
return showTx(res.Height, res.Proof.Data)
|
||||
}
|
||||
|
||||
// showTx parses anything that was previously registered as basecoin.Tx
|
||||
// showTx parses anything that was previously registered as sdk.Tx
|
||||
func showTx(h int, tx types.Tx) error {
|
||||
var info basecoin.Tx
|
||||
var info sdk.Tx
|
||||
err := wire.ReadBinaryBytes(tx, &info)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
|
||||
"github.com/tendermint/tendermint/rpc/client"
|
||||
)
|
||||
|
|
|
@ -3,7 +3,7 @@ package rpc
|
|||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
)
|
||||
|
||||
var statusCmd = &cobra.Command{
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
certclient "github.com/tendermint/light-client/certifiers/client"
|
||||
"github.com/tendermint/tendermint/rpc/client"
|
||||
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
"github.com/tendermint/light-client/certifiers"
|
||||
)
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
"github.com/tendermint/light-client/certifiers"
|
||||
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
"github.com/tendermint/light-client/certifiers"
|
||||
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
"github.com/tendermint/light-client/certifiers"
|
||||
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
)
|
||||
|
||||
var updateCmd = &cobra.Command{
|
||||
|
|
|
@ -22,9 +22,9 @@ import (
|
|||
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/tendermint/basecoin/modules/auth"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/modules/auth"
|
||||
)
|
||||
|
||||
// Validatable represents anything that can be Validated
|
||||
|
@ -43,7 +43,7 @@ func GetSigner() crypto.PubKey {
|
|||
|
||||
// GetSignerAct returns the address of the signer of the tx
|
||||
// (as we still only support single sig)
|
||||
func GetSignerAct() (res basecoin.Actor) {
|
||||
func GetSignerAct() (res sdk.Actor) {
|
||||
// this could be much cooler with multisig...
|
||||
signer := GetSigner()
|
||||
if !signer.Empty() {
|
||||
|
@ -61,7 +61,7 @@ func GetSignerAct() (res basecoin.Actor) {
|
|||
// If you want a non-standard flow, just call the various functions directly.
|
||||
// eg. if you already set the middleware layers in your code, or want to
|
||||
// output in another format.
|
||||
func DoTx(tx basecoin.Tx) (err error) {
|
||||
func DoTx(tx sdk.Tx) (err error) {
|
||||
tx, err = Middleware.Wrap(tx)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -85,7 +85,7 @@ func DoTx(tx basecoin.Tx) (err error) {
|
|||
|
||||
// SignTx will validate the tx, and signs it if it is wrapping a Signable.
|
||||
// Modifies tx in place, and returns an error if it should sign but couldn't
|
||||
func SignTx(tx basecoin.Tx) error {
|
||||
func SignTx(tx sdk.Tx) error {
|
||||
// validate tx client-side
|
||||
err := tx.ValidateBasic()
|
||||
if err != nil {
|
||||
|
@ -114,7 +114,7 @@ func SignTx(tx basecoin.Tx) error {
|
|||
// multisig, or to post it to the node. Returns error on any failure.
|
||||
// If no error and the result is nil, it means it already wrote to file,
|
||||
// no post, no need to do more.
|
||||
func PrepareOrPostTx(tx basecoin.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
func PrepareOrPostTx(tx sdk.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
wrote, err := PrepareTx(tx)
|
||||
// error in prep
|
||||
if err != nil {
|
||||
|
@ -132,7 +132,7 @@ func PrepareOrPostTx(tx basecoin.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
|||
// to the specified location for later multi-sig. Returns true if it
|
||||
// handled the tx (no futher work required), false if it did nothing
|
||||
// (and we should post the tx)
|
||||
func PrepareTx(tx basecoin.Tx) (bool, error) {
|
||||
func PrepareTx(tx sdk.Tx) (bool, error) {
|
||||
prep := viper.GetString(FlagPrepare)
|
||||
if prep == "" {
|
||||
return false, nil
|
||||
|
@ -152,7 +152,7 @@ func PrepareTx(tx basecoin.Tx) (bool, error) {
|
|||
// PostTx does all work once we construct a proper struct
|
||||
// it validates the data, signs if needed, transforms to bytes,
|
||||
// and posts to the node.
|
||||
func PostTx(tx basecoin.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
func PostTx(tx sdk.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
packet := wire.BinaryBytes(tx)
|
||||
// post the bytes
|
||||
node := commands.GetNode()
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
)
|
||||
|
||||
// nolint
|
||||
|
@ -39,7 +39,7 @@ func doRawTx(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
|
||||
// parse the input
|
||||
var tx basecoin.Tx
|
||||
var tx sdk.Tx
|
||||
err = json.Unmarshal(raw, &tx)
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
|
|
|
@ -3,7 +3,7 @@ package txs
|
|||
import (
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -14,7 +14,7 @@ var (
|
|||
// Wrapper defines the information needed for each middleware package that
|
||||
// wraps the data. They should read all configuration out of bounds via viper.
|
||||
type Wrapper interface {
|
||||
Wrap(basecoin.Tx) (basecoin.Tx, error)
|
||||
Wrap(sdk.Tx) (sdk.Tx, error)
|
||||
Register(*pflag.FlagSet)
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ var _ Wrapper = Wrappers{}
|
|||
|
||||
// Wrap applies the wrappers to the passed in tx in order,
|
||||
// aborting on the first error
|
||||
func (ws Wrappers) Wrap(tx basecoin.Tx) (basecoin.Tx, error) {
|
||||
func (ws Wrappers) Wrap(tx sdk.Tx) (sdk.Tx, error) {
|
||||
var err error
|
||||
for _, w := range ws {
|
||||
tx, err = w.Wrap(tx)
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/tendermint/basecoin/version"
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
)
|
||||
|
||||
// CommitHash should be filled by linker flags
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/gorilla/mux"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
keysutils "github.com/tendermint/go-crypto/cmd"
|
||||
keys "github.com/tendermint/go-crypto/keys"
|
||||
"github.com/tendermint/tmlibs/common"
|
||||
|
@ -126,7 +126,7 @@ func (k *Keys) DeleteKey(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
func doPostTx(w http.ResponseWriter, r *http.Request) {
|
||||
tx := new(basecoin.Tx)
|
||||
tx := new(sdk.Tx)
|
||||
if err := common.ParseRequestAndValidateJSON(r, tx); err != nil {
|
||||
common.WriteError(w, err)
|
||||
return
|
||||
|
|
|
@ -7,12 +7,12 @@ import (
|
|||
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
)
|
||||
|
||||
// PostTx is same as a tx
|
||||
func PostTx(tx basecoin.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
func PostTx(tx sdk.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
packet := wire.BinaryBytes(tx)
|
||||
// post the bytes
|
||||
node := commands.GetNode()
|
||||
|
@ -20,7 +20,7 @@ func PostTx(tx basecoin.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
|||
}
|
||||
|
||||
// SignTx will modify the tx in-place, adding a signature if possible
|
||||
func SignTx(name, pass string, tx basecoin.Tx) error {
|
||||
func SignTx(name, pass string, tx sdk.Tx) error {
|
||||
if sign, ok := tx.Unwrap().(keys.Signable); ok {
|
||||
manager := keycmd.GetKeyManager()
|
||||
return manager.Sign(name, pass, sign)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package rest
|
||||
|
||||
import (
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/modules/coin"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/modules/coin"
|
||||
"github.com/tendermint/go-crypto/keys"
|
||||
)
|
||||
|
||||
|
@ -29,7 +29,7 @@ type SignRequest struct {
|
|||
Name string `json:"name,omitempty" validate:"required,min=3,printascii"`
|
||||
Password string `json:"password,omitempty" validate:"required,min=10"`
|
||||
|
||||
Tx basecoin.Tx `json:"tx" validate:"required"`
|
||||
Tx sdk.Tx `json:"tx" validate:"required"`
|
||||
}
|
||||
|
||||
type CreateKeyResponse struct {
|
||||
|
@ -46,7 +46,7 @@ type SendInput struct {
|
|||
Multi bool `json:"multi,omitempty"`
|
||||
Sequence uint32 `json:"sequence"`
|
||||
|
||||
To *basecoin.Actor `json:"to"`
|
||||
From *basecoin.Actor `json:"from"`
|
||||
To *sdk.Actor `json:"to"`
|
||||
From *sdk.Actor `json:"from"`
|
||||
Amount coin.Coins `json:"amount"`
|
||||
}
|
||||
|
|
|
@ -8,20 +8,20 @@ import (
|
|||
keycmd "github.com/tendermint/go-crypto/cmd"
|
||||
"github.com/tendermint/tmlibs/cli"
|
||||
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/tendermint/basecoin/client/commands/auto"
|
||||
"github.com/tendermint/basecoin/client/commands/proxy"
|
||||
"github.com/tendermint/basecoin/client/commands/query"
|
||||
rpccmd "github.com/tendermint/basecoin/client/commands/rpc"
|
||||
"github.com/tendermint/basecoin/client/commands/seeds"
|
||||
txcmd "github.com/tendermint/basecoin/client/commands/txs"
|
||||
authcmd "github.com/tendermint/basecoin/modules/auth/commands"
|
||||
basecmd "github.com/tendermint/basecoin/modules/base/commands"
|
||||
coincmd "github.com/tendermint/basecoin/modules/coin/commands"
|
||||
feecmd "github.com/tendermint/basecoin/modules/fee/commands"
|
||||
ibccmd "github.com/tendermint/basecoin/modules/ibc/commands"
|
||||
noncecmd "github.com/tendermint/basecoin/modules/nonce/commands"
|
||||
rolecmd "github.com/tendermint/basecoin/modules/roles/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands/auto"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands/proxy"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands/query"
|
||||
rpccmd "github.com/cosmos/cosmos-sdk/client/commands/rpc"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands/seeds"
|
||||
txcmd "github.com/cosmos/cosmos-sdk/client/commands/txs"
|
||||
authcmd "github.com/cosmos/cosmos-sdk/modules/auth/commands"
|
||||
basecmd "github.com/cosmos/cosmos-sdk/modules/base/commands"
|
||||
coincmd "github.com/cosmos/cosmos-sdk/modules/coin/commands"
|
||||
feecmd "github.com/cosmos/cosmos-sdk/modules/fee/commands"
|
||||
ibccmd "github.com/cosmos/cosmos-sdk/modules/ibc/commands"
|
||||
noncecmd "github.com/cosmos/cosmos-sdk/modules/nonce/commands"
|
||||
rolecmd "github.com/cosmos/cosmos-sdk/modules/roles/commands"
|
||||
)
|
||||
|
||||
// BaseCli - main basecoin client command
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package commands
|
||||
|
||||
// import "github.com/tendermint/basecoin/plugins/ibc"
|
||||
// import "github.com/cosmos/cosmos-sdk/plugins/ibc"
|
||||
|
||||
// // returns a new IBC plugin to be registered with Basecoin
|
||||
// func NewIBCPlugin() *ibc.IBCPlugin {
|
||||
|
|
|
@ -17,8 +17,8 @@ package commands
|
|||
// "github.com/tendermint/merkleeyes/iavl"
|
||||
// cmn "github.com/tendermint/tmlibs/common"
|
||||
|
||||
// "github.com/tendermint/basecoin/plugins/ibc"
|
||||
// "github.com/tendermint/basecoin/types"
|
||||
// "github.com/cosmos/cosmos-sdk/plugins/ibc"
|
||||
// "github.com/cosmos/cosmos-sdk/types"
|
||||
// "github.com/tendermint/tendermint/rpc/client"
|
||||
// tmtypes "github.com/tendermint/tendermint/types"
|
||||
// )
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/tendermint/abci/server"
|
||||
"github.com/tendermint/basecoin"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/tendermint/tmlibs/cli"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
|
||||
|
@ -19,7 +19,7 @@ import (
|
|||
"github.com/tendermint/tendermint/proxy"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
|
||||
"github.com/tendermint/basecoin/app"
|
||||
"github.com/cosmos/cosmos-sdk/app"
|
||||
)
|
||||
|
||||
// StartCmd - command to start running the basecoin node!
|
||||
|
@ -41,7 +41,7 @@ const (
|
|||
var (
|
||||
// Handler - use a global to store the handler, so we can set it in main.
|
||||
// TODO: figure out a cleaner way to register plugins
|
||||
Handler basecoin.Handler
|
||||
Handler sdk.Handler
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
|
@ -5,21 +5,21 @@ import (
|
|||
|
||||
"github.com/tendermint/tmlibs/cli"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
client "github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/tendermint/basecoin/cmd/basecoin/commands"
|
||||
"github.com/tendermint/basecoin/modules/auth"
|
||||
"github.com/tendermint/basecoin/modules/base"
|
||||
"github.com/tendermint/basecoin/modules/coin"
|
||||
"github.com/tendermint/basecoin/modules/fee"
|
||||
"github.com/tendermint/basecoin/modules/ibc"
|
||||
"github.com/tendermint/basecoin/modules/nonce"
|
||||
"github.com/tendermint/basecoin/modules/roles"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
client "github.com/cosmos/cosmos-sdk/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/cmd/basecoin/commands"
|
||||
"github.com/cosmos/cosmos-sdk/modules/auth"
|
||||
"github.com/cosmos/cosmos-sdk/modules/base"
|
||||
"github.com/cosmos/cosmos-sdk/modules/coin"
|
||||
"github.com/cosmos/cosmos-sdk/modules/fee"
|
||||
"github.com/cosmos/cosmos-sdk/modules/ibc"
|
||||
"github.com/cosmos/cosmos-sdk/modules/nonce"
|
||||
"github.com/cosmos/cosmos-sdk/modules/roles"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
)
|
||||
|
||||
// BuildApp constructs the stack we want to use for this app
|
||||
func BuildApp(feeDenom string) basecoin.Handler {
|
||||
func BuildApp(feeDenom string) sdk.Handler {
|
||||
return stack.New(
|
||||
base.Logger{},
|
||||
stack.Recovery{},
|
||||
|
|
|
@ -10,11 +10,11 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
rest "github.com/tendermint/basecoin/client/rest"
|
||||
coinrest "github.com/tendermint/basecoin/modules/coin/rest"
|
||||
noncerest "github.com/tendermint/basecoin/modules/nonce/rest"
|
||||
rolerest "github.com/tendermint/basecoin/modules/roles/rest"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
rest "github.com/cosmos/cosmos-sdk/client/rest"
|
||||
coinrest "github.com/cosmos/cosmos-sdk/modules/coin/rest"
|
||||
noncerest "github.com/cosmos/cosmos-sdk/modules/nonce/rest"
|
||||
rolerest "github.com/cosmos/cosmos-sdk/modules/roles/rest"
|
||||
"github.com/tendermint/tmlibs/cli"
|
||||
)
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
|
||||
|
||||
"github.com/tendermint/basecoin/cmd/basecoin/commands"
|
||||
"github.com/cosmos/cosmos-sdk/cmd/basecoin/commands"
|
||||
)
|
||||
|
||||
// InitCmd - node initialization command
|
||||
|
|
|
@ -5,16 +5,16 @@ import (
|
|||
|
||||
"github.com/tendermint/tmlibs/cli"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
client "github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/tendermint/basecoin/cmd/basecoin/commands"
|
||||
"github.com/tendermint/basecoin/modules/base"
|
||||
"github.com/tendermint/basecoin/modules/eyes"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
client "github.com/cosmos/cosmos-sdk/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/cmd/basecoin/commands"
|
||||
"github.com/cosmos/cosmos-sdk/modules/base"
|
||||
"github.com/cosmos/cosmos-sdk/modules/eyes"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
)
|
||||
|
||||
// BuildApp constructs the stack we want to use for this app
|
||||
func BuildApp() basecoin.Handler {
|
||||
func BuildApp() sdk.Handler {
|
||||
return stack.New(
|
||||
base.Logger{},
|
||||
stack.Recovery{},
|
||||
|
|
|
@ -8,14 +8,14 @@ import (
|
|||
keycmd "github.com/tendermint/go-crypto/cmd"
|
||||
"github.com/tendermint/tmlibs/cli"
|
||||
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/tendermint/basecoin/client/commands/auto"
|
||||
"github.com/tendermint/basecoin/client/commands/proxy"
|
||||
"github.com/tendermint/basecoin/client/commands/query"
|
||||
rpccmd "github.com/tendermint/basecoin/client/commands/rpc"
|
||||
"github.com/tendermint/basecoin/client/commands/seeds"
|
||||
txcmd "github.com/tendermint/basecoin/client/commands/txs"
|
||||
eyescmd "github.com/tendermint/basecoin/modules/eyes/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands/auto"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands/proxy"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands/query"
|
||||
rpccmd "github.com/cosmos/cosmos-sdk/client/commands/rpc"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands/seeds"
|
||||
txcmd "github.com/cosmos/cosmos-sdk/client/commands/txs"
|
||||
eyescmd "github.com/cosmos/cosmos-sdk/modules/eyes/commands"
|
||||
)
|
||||
|
||||
// EyesCli - main basecoin client command
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package basecoin
|
||||
package sdk
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
|
|
@ -7,9 +7,9 @@ import (
|
|||
|
||||
"github.com/tendermint/tmlibs/cli"
|
||||
|
||||
client "github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/tendermint/basecoin/cmd/basecoin/commands"
|
||||
"github.com/tendermint/basecoin/docs/guide/counter/plugins/counter"
|
||||
client "github.com/cosmos/cosmos-sdk/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/cmd/basecoin/commands"
|
||||
"github.com/cosmos/cosmos-sdk/docs/guide/counter/plugins/counter"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
@ -4,10 +4,10 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
txcmd "github.com/tendermint/basecoin/client/commands/txs"
|
||||
"github.com/tendermint/basecoin/docs/guide/counter/plugins/counter"
|
||||
"github.com/tendermint/basecoin/modules/coin"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
txcmd "github.com/cosmos/cosmos-sdk/client/commands/txs"
|
||||
"github.com/cosmos/cosmos-sdk/docs/guide/counter/plugins/counter"
|
||||
"github.com/cosmos/cosmos-sdk/modules/coin"
|
||||
)
|
||||
|
||||
//CounterTxCmd is the CLI command to execute the counter
|
||||
|
@ -41,7 +41,7 @@ func counterTx(cmd *cobra.Command, args []string) error {
|
|||
return txcmd.DoTx(tx)
|
||||
}
|
||||
|
||||
func readCounterTxFlags() (tx basecoin.Tx, err error) {
|
||||
func readCounterTxFlags() (tx sdk.Tx, err error) {
|
||||
feeCoins, err := coin.ParseCoins(viper.GetString(FlagCountFee))
|
||||
if err != nil {
|
||||
return tx, err
|
||||
|
|
|
@ -4,11 +4,11 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/tendermint/basecoin/client/commands/query"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands/query"
|
||||
|
||||
"github.com/tendermint/basecoin/docs/guide/counter/plugins/counter"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/cosmos/cosmos-sdk/docs/guide/counter/plugins/counter"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
)
|
||||
|
||||
//CounterQueryCmd - CLI command to query the counter state
|
||||
|
|
|
@ -8,17 +8,17 @@ import (
|
|||
keycmd "github.com/tendermint/go-crypto/cmd"
|
||||
"github.com/tendermint/tmlibs/cli"
|
||||
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/tendermint/basecoin/client/commands/proxy"
|
||||
"github.com/tendermint/basecoin/client/commands/query"
|
||||
"github.com/tendermint/basecoin/client/commands/seeds"
|
||||
txcmd "github.com/tendermint/basecoin/client/commands/txs"
|
||||
bcount "github.com/tendermint/basecoin/docs/guide/counter/cmd/countercli/commands"
|
||||
authcmd "github.com/tendermint/basecoin/modules/auth/commands"
|
||||
basecmd "github.com/tendermint/basecoin/modules/base/commands"
|
||||
coincmd "github.com/tendermint/basecoin/modules/coin/commands"
|
||||
feecmd "github.com/tendermint/basecoin/modules/fee/commands"
|
||||
noncecmd "github.com/tendermint/basecoin/modules/nonce/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands/proxy"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands/query"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands/seeds"
|
||||
txcmd "github.com/cosmos/cosmos-sdk/client/commands/txs"
|
||||
bcount "github.com/cosmos/cosmos-sdk/docs/guide/counter/cmd/countercli/commands"
|
||||
authcmd "github.com/cosmos/cosmos-sdk/modules/auth/commands"
|
||||
basecmd "github.com/cosmos/cosmos-sdk/modules/base/commands"
|
||||
coincmd "github.com/cosmos/cosmos-sdk/modules/coin/commands"
|
||||
feecmd "github.com/cosmos/cosmos-sdk/modules/fee/commands"
|
||||
noncecmd "github.com/cosmos/cosmos-sdk/modules/nonce/commands"
|
||||
)
|
||||
|
||||
// BaseCli represents the base command when called without any subcommands
|
||||
|
|
|
@ -6,17 +6,17 @@ import (
|
|||
abci "github.com/tendermint/abci/types"
|
||||
"github.com/tendermint/go-wire"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/tendermint/basecoin/modules/auth"
|
||||
"github.com/tendermint/basecoin/modules/base"
|
||||
"github.com/tendermint/basecoin/modules/coin"
|
||||
"github.com/tendermint/basecoin/modules/fee"
|
||||
"github.com/tendermint/basecoin/modules/ibc"
|
||||
"github.com/tendermint/basecoin/modules/nonce"
|
||||
"github.com/tendermint/basecoin/modules/roles"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/errors"
|
||||
"github.com/cosmos/cosmos-sdk/modules/auth"
|
||||
"github.com/cosmos/cosmos-sdk/modules/base"
|
||||
"github.com/cosmos/cosmos-sdk/modules/coin"
|
||||
"github.com/cosmos/cosmos-sdk/modules/fee"
|
||||
"github.com/cosmos/cosmos-sdk/modules/ibc"
|
||||
"github.com/cosmos/cosmos-sdk/modules/nonce"
|
||||
"github.com/cosmos/cosmos-sdk/modules/roles"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
)
|
||||
|
||||
// Tx
|
||||
|
@ -32,7 +32,7 @@ const (
|
|||
)
|
||||
|
||||
func init() {
|
||||
basecoin.TxMapper.RegisterImplementation(Tx{}, TypeTx, ByteTx)
|
||||
sdk.TxMapper.RegisterImplementation(Tx{}, TypeTx, ByteTx)
|
||||
}
|
||||
|
||||
// Tx - struct for all counter transactions
|
||||
|
@ -42,7 +42,7 @@ type Tx struct {
|
|||
}
|
||||
|
||||
// NewTx - return a new counter transaction struct wrapped as a basecoin transaction
|
||||
func NewTx(valid bool, fee coin.Coins) basecoin.Tx {
|
||||
func NewTx(valid bool, fee coin.Coins) sdk.Tx {
|
||||
return Tx{
|
||||
Valid: valid,
|
||||
Fee: fee,
|
||||
|
@ -50,8 +50,8 @@ func NewTx(valid bool, fee coin.Coins) basecoin.Tx {
|
|||
}
|
||||
|
||||
// Wrap - Wrap a Tx as a Basecoin Tx, used to satisfy the XXX interface
|
||||
func (c Tx) Wrap() basecoin.Tx {
|
||||
return basecoin.Tx{TxInner: c}
|
||||
func (c Tx) Wrap() sdk.Tx {
|
||||
return sdk.Tx{TxInner: c}
|
||||
}
|
||||
|
||||
// ValidateBasic just makes sure the Fee is a valid, non-negative value
|
||||
|
@ -91,7 +91,7 @@ func ErrDecoding() error {
|
|||
//--------------------------------------------------------------------------------
|
||||
|
||||
// NewHandler returns a new counter transaction processing handler
|
||||
func NewHandler(feeDenom string) basecoin.Handler {
|
||||
func NewHandler(feeDenom string) sdk.Handler {
|
||||
return stack.New(
|
||||
base.Logger{},
|
||||
stack.Recovery{},
|
||||
|
@ -129,13 +129,13 @@ func (Handler) Name() string {
|
|||
func (Handler) AssertDispatcher() {}
|
||||
|
||||
// CheckTx checks if the tx is properly structured
|
||||
func (h Handler) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, _ basecoin.Checker) (res basecoin.CheckResult, err error) {
|
||||
func (h Handler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, _ sdk.Checker) (res sdk.CheckResult, err error) {
|
||||
_, err = checkTx(ctx, tx)
|
||||
return
|
||||
}
|
||||
|
||||
// DeliverTx executes the tx if valid
|
||||
func (h Handler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, dispatch basecoin.Deliver) (res basecoin.DeliverResult, err error) {
|
||||
func (h Handler) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, dispatch sdk.Deliver) (res sdk.DeliverResult, err error) {
|
||||
ctr, err := checkTx(ctx, tx)
|
||||
if err != nil {
|
||||
return res, err
|
||||
|
@ -175,7 +175,7 @@ func (h Handler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx baseco
|
|||
return res, err
|
||||
}
|
||||
|
||||
func checkTx(ctx basecoin.Context, tx basecoin.Tx) (ctr Tx, err error) {
|
||||
func checkTx(ctx sdk.Context, tx sdk.Tx) (ctr Tx, err error) {
|
||||
ctr, ok := tx.Unwrap().(Tx)
|
||||
if !ok {
|
||||
return ctr, errors.ErrInvalidFormat(TypeTx, tx)
|
||||
|
@ -191,8 +191,8 @@ func checkTx(ctx basecoin.Context, tx basecoin.Tx) (ctr Tx, err error) {
|
|||
//--------------------------------------------------------------------------------
|
||||
|
||||
// StoreActor - return the basecoin actor for the account
|
||||
func StoreActor() basecoin.Actor {
|
||||
return basecoin.Actor{App: NameCounter, Address: []byte{0x04, 0x20}} //XXX what do these bytes represent? - should use typebyte variables
|
||||
func StoreActor() sdk.Actor {
|
||||
return sdk.Actor{App: NameCounter, Address: []byte{0x04, 0x20}} //XXX what do these bytes represent? - should use typebyte variables
|
||||
}
|
||||
|
||||
// State - state of the counter applicaton
|
||||
|
|
|
@ -10,12 +10,12 @@ import (
|
|||
"github.com/tendermint/go-wire"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/app"
|
||||
"github.com/tendermint/basecoin/modules/auth"
|
||||
"github.com/tendermint/basecoin/modules/base"
|
||||
"github.com/tendermint/basecoin/modules/coin"
|
||||
"github.com/tendermint/basecoin/modules/nonce"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/app"
|
||||
"github.com/cosmos/cosmos-sdk/modules/auth"
|
||||
"github.com/cosmos/cosmos-sdk/modules/base"
|
||||
"github.com/cosmos/cosmos-sdk/modules/coin"
|
||||
"github.com/cosmos/cosmos-sdk/modules/nonce"
|
||||
)
|
||||
|
||||
func TestCounterPlugin(t *testing.T) {
|
||||
|
@ -47,7 +47,7 @@ func TestCounterPlugin(t *testing.T) {
|
|||
// Deliver a CounterTx
|
||||
DeliverCounterTx := func(valid bool, counterFee coin.Coins, sequence uint32) abci.Result {
|
||||
tx := NewTx(valid, counterFee)
|
||||
tx = nonce.NewTx(sequence, []basecoin.Actor{acct.Actor()}, tx)
|
||||
tx = nonce.NewTx(sequence, []sdk.Actor{acct.Actor()}, tx)
|
||||
tx = base.NewChainTx(chainID, 0, tx)
|
||||
stx := auth.NewSig(tx)
|
||||
auth.Sign(stx, acct.Key)
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package basecoin
|
||||
package sdk
|
||||
|
||||
import (
|
||||
abci "github.com/tendermint/abci/types"
|
||||
"github.com/tendermint/go-wire/data"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin/state"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
)
|
||||
|
||||
// Handler is anything that processes a transaction
|
||||
|
|
|
@ -8,12 +8,12 @@ import (
|
|||
cmn "github.com/tendermint/tmlibs/common"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
)
|
||||
|
||||
func makeSignTx() basecoin.Tx {
|
||||
func makeSignTx() sdk.Tx {
|
||||
key := crypto.GenPrivKeyEd25519().Wrap()
|
||||
payload := cmn.RandBytes(32)
|
||||
tx := NewSig(stack.NewRawTx(payload))
|
||||
|
@ -21,7 +21,7 @@ func makeSignTx() basecoin.Tx {
|
|||
return tx.Wrap()
|
||||
}
|
||||
|
||||
func makeMultiSignTx(cnt int) basecoin.Tx {
|
||||
func makeMultiSignTx(cnt int) sdk.Tx {
|
||||
payload := cmn.RandBytes(32)
|
||||
tx := NewMulti(stack.NewRawTx(payload))
|
||||
for i := 0; i < cnt; i++ {
|
||||
|
@ -31,7 +31,7 @@ func makeMultiSignTx(cnt int) basecoin.Tx {
|
|||
return tx.Wrap()
|
||||
}
|
||||
|
||||
func makeHandler() basecoin.Handler {
|
||||
func makeHandler() sdk.Handler {
|
||||
return stack.New(Signatures{}).Use(stack.OKHandler{})
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"github.com/spf13/pflag"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
txcmd "github.com/tendermint/basecoin/client/commands/txs"
|
||||
"github.com/tendermint/basecoin/modules/auth"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
txcmd "github.com/cosmos/cosmos-sdk/client/commands/txs"
|
||||
"github.com/cosmos/cosmos-sdk/modules/auth"
|
||||
)
|
||||
|
||||
//nolint
|
||||
|
@ -20,7 +20,7 @@ type SigWrapper struct{}
|
|||
var _ txcmd.Wrapper = SigWrapper{}
|
||||
|
||||
// Wrap will wrap the tx with OneSig or MultiSig depending on flags
|
||||
func (SigWrapper) Wrap(tx basecoin.Tx) (res basecoin.Tx, err error) {
|
||||
func (SigWrapper) Wrap(tx sdk.Tx) (res sdk.Tx, err error) {
|
||||
if !viper.GetBool(FlagMulti) {
|
||||
res = auth.NewSig(tx).Wrap()
|
||||
} else {
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
abci "github.com/tendermint/abci/types"
|
||||
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/cosmos/cosmos-sdk/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/cosmos/cosmos-sdk/errors"
|
||||
)
|
||||
|
||||
func TestChecks(t *testing.T) {
|
||||
|
|
|
@ -3,10 +3,10 @@ package auth
|
|||
import (
|
||||
crypto "github.com/tendermint/go-crypto"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/errors"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
)
|
||||
|
||||
//nolint
|
||||
|
@ -29,18 +29,18 @@ func (Signatures) Name() string {
|
|||
var _ stack.Middleware = Signatures{}
|
||||
|
||||
// SigPerm takes the binary address from PubKey.Address and makes it an Actor
|
||||
func SigPerm(addr []byte) basecoin.Actor {
|
||||
return basecoin.NewActor(NameSigs, addr)
|
||||
func SigPerm(addr []byte) sdk.Actor {
|
||||
return sdk.NewActor(NameSigs, addr)
|
||||
}
|
||||
|
||||
// Signable allows us to use txs.OneSig and txs.MultiSig (and others??)
|
||||
type Signable interface {
|
||||
basecoin.TxLayer
|
||||
sdk.TxLayer
|
||||
Signers() ([]crypto.PubKey, error)
|
||||
}
|
||||
|
||||
// CheckTx verifies the signatures are correct - fulfills Middlware interface
|
||||
func (Signatures) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Checker) (res basecoin.CheckResult, err error) {
|
||||
func (Signatures) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error) {
|
||||
sigs, tnext, err := getSigners(tx)
|
||||
if err != nil {
|
||||
return res, err
|
||||
|
@ -50,7 +50,7 @@ func (Signatures) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoi
|
|||
}
|
||||
|
||||
// DeliverTx verifies the signatures are correct - fulfills Middlware interface
|
||||
func (Signatures) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.DeliverResult, err error) {
|
||||
func (Signatures) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error) {
|
||||
sigs, tnext, err := getSigners(tx)
|
||||
if err != nil {
|
||||
return res, err
|
||||
|
@ -59,8 +59,8 @@ func (Signatures) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basec
|
|||
return next.DeliverTx(ctx2, store, tnext)
|
||||
}
|
||||
|
||||
func addSigners(ctx basecoin.Context, sigs []crypto.PubKey) basecoin.Context {
|
||||
perms := make([]basecoin.Actor, len(sigs))
|
||||
func addSigners(ctx sdk.Context, sigs []crypto.PubKey) sdk.Context {
|
||||
perms := make([]sdk.Actor, len(sigs))
|
||||
for i, s := range sigs {
|
||||
perms[i] = SigPerm(s.Address())
|
||||
}
|
||||
|
@ -68,10 +68,10 @@ func addSigners(ctx basecoin.Context, sigs []crypto.PubKey) basecoin.Context {
|
|||
return ctx.WithPermissions(perms...)
|
||||
}
|
||||
|
||||
func getSigners(tx basecoin.Tx) ([]crypto.PubKey, basecoin.Tx, error) {
|
||||
func getSigners(tx sdk.Tx) ([]crypto.PubKey, sdk.Tx, error) {
|
||||
stx, ok := tx.Unwrap().(Signable)
|
||||
if !ok {
|
||||
return nil, basecoin.Tx{}, errors.ErrUnauthorized()
|
||||
return nil, sdk.Tx{}, errors.ErrUnauthorized()
|
||||
}
|
||||
sig, err := stx.Signers()
|
||||
return sig, stx.Next(), err
|
||||
|
|
|
@ -9,9 +9,9 @@ import (
|
|||
crypto "github.com/tendermint/go-crypto"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
)
|
||||
|
||||
func TestSignatureChecks(t *testing.T) {
|
||||
|
@ -32,7 +32,7 @@ func TestSignatureChecks(t *testing.T) {
|
|||
cases := []struct {
|
||||
useMultiSig bool
|
||||
keys []crypto.PrivKey
|
||||
check basecoin.Actor
|
||||
check sdk.Actor
|
||||
valid bool
|
||||
}{
|
||||
// test with single sigs
|
||||
|
@ -61,7 +61,7 @@ func TestSignatureChecks(t *testing.T) {
|
|||
stack.CheckMiddleware{Required: tc.check},
|
||||
).Use(stack.OKHandler{})
|
||||
|
||||
var tx basecoin.Tx
|
||||
var tx sdk.Tx
|
||||
// this does the signing as needed
|
||||
if tc.useMultiSig {
|
||||
mtx := NewMulti(raw)
|
||||
|
|
|
@ -9,7 +9,7 @@ complex algorithms (although it would be great to add them).
|
|||
|
||||
You can create them with NewSig() and NewMultiSig(), and they fulfill
|
||||
the keys.Signable interface. You can then .Wrap() them to create
|
||||
a basecoin.Tx.
|
||||
a sdk.Tx.
|
||||
*/
|
||||
package auth
|
||||
|
||||
|
@ -18,8 +18,8 @@ import (
|
|||
"github.com/tendermint/go-crypto/keys"
|
||||
"github.com/tendermint/go-wire/data"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/errors"
|
||||
)
|
||||
|
||||
// nolint
|
||||
|
@ -50,7 +50,7 @@ func (s Signed) Empty() bool {
|
|||
/**** Registration ****/
|
||||
|
||||
func init() {
|
||||
basecoin.TxMapper.
|
||||
sdk.TxMapper.
|
||||
RegisterImplementation(&OneSig{}, TypeSingleTx, ByteSingleTx).
|
||||
RegisterImplementation(&MultiSig{}, TypeMultiSig, ByteMultiSig)
|
||||
}
|
||||
|
@ -59,23 +59,23 @@ func init() {
|
|||
|
||||
// OneSig lets us wrap arbitrary data with a go-crypto signature
|
||||
type OneSig struct {
|
||||
Tx basecoin.Tx `json:"tx"`
|
||||
Tx sdk.Tx `json:"tx"`
|
||||
Signed `json:"signature"`
|
||||
}
|
||||
|
||||
var _ keys.Signable = &OneSig{}
|
||||
var _ basecoin.TxLayer = &OneSig{}
|
||||
var _ sdk.TxLayer = &OneSig{}
|
||||
|
||||
// NewSig wraps the tx with a Signable that accepts exactly one signature
|
||||
func NewSig(tx basecoin.Tx) *OneSig {
|
||||
func NewSig(tx sdk.Tx) *OneSig {
|
||||
return &OneSig{Tx: tx}
|
||||
}
|
||||
|
||||
//nolint
|
||||
func (s *OneSig) Wrap() basecoin.Tx {
|
||||
return basecoin.Tx{s}
|
||||
func (s *OneSig) Wrap() sdk.Tx {
|
||||
return sdk.Tx{s}
|
||||
}
|
||||
func (s *OneSig) Next() basecoin.Tx {
|
||||
func (s *OneSig) Next() sdk.Tx {
|
||||
return s.Tx
|
||||
}
|
||||
func (s *OneSig) ValidateBasic() error {
|
||||
|
@ -130,23 +130,23 @@ func (s *OneSig) Signers() ([]crypto.PubKey, error) {
|
|||
|
||||
// MultiSig lets us wrap arbitrary data with a go-crypto signature
|
||||
type MultiSig struct {
|
||||
Tx basecoin.Tx `json:"tx"`
|
||||
Tx sdk.Tx `json:"tx"`
|
||||
Sigs []Signed `json:"signatures"`
|
||||
}
|
||||
|
||||
var _ keys.Signable = &MultiSig{}
|
||||
var _ basecoin.TxLayer = &MultiSig{}
|
||||
var _ sdk.TxLayer = &MultiSig{}
|
||||
|
||||
// NewMulti wraps the tx with a Signable that accepts arbitrary numbers of signatures
|
||||
func NewMulti(tx basecoin.Tx) *MultiSig {
|
||||
func NewMulti(tx sdk.Tx) *MultiSig {
|
||||
return &MultiSig{Tx: tx}
|
||||
}
|
||||
|
||||
// nolint
|
||||
func (s *MultiSig) Wrap() basecoin.Tx {
|
||||
return basecoin.Tx{s}
|
||||
func (s *MultiSig) Wrap() sdk.Tx {
|
||||
return sdk.Tx{s}
|
||||
}
|
||||
func (s *MultiSig) Next() basecoin.Tx {
|
||||
func (s *MultiSig) Next() sdk.Tx {
|
||||
return s.Tx
|
||||
}
|
||||
func (s *MultiSig) ValidateBasic() error {
|
||||
|
|
|
@ -12,13 +12,13 @@ import (
|
|||
"github.com/tendermint/go-crypto/keys/storage/memstorage"
|
||||
wire "github.com/tendermint/go-wire"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
)
|
||||
|
||||
func checkSignBytes(t *testing.T, bytes []byte, expected string) {
|
||||
// load it back... unwrap the tx
|
||||
var preTx basecoin.Tx
|
||||
var preTx sdk.Tx
|
||||
err := wire.ReadBinaryBytes(bytes, &preTx)
|
||||
require.Nil(t, err)
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package base
|
||||
|
||||
import (
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
)
|
||||
|
||||
//nolint
|
||||
|
@ -25,7 +25,7 @@ func (Chain) Name() string {
|
|||
var _ stack.Middleware = Chain{}
|
||||
|
||||
// CheckTx makes sure we are on the proper chain - fulfills Middlware interface
|
||||
func (c Chain) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Checker) (res basecoin.CheckResult, err error) {
|
||||
func (c Chain) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error) {
|
||||
stx, err := c.checkChainTx(ctx.ChainID(), ctx.BlockHeight(), tx)
|
||||
if err != nil {
|
||||
return res, err
|
||||
|
@ -34,7 +34,7 @@ func (c Chain) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.T
|
|||
}
|
||||
|
||||
// DeliverTx makes sure we are on the proper chain - fulfills Middlware interface
|
||||
func (c Chain) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.DeliverResult, err error) {
|
||||
func (c Chain) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error) {
|
||||
stx, err := c.checkChainTx(ctx.ChainID(), ctx.BlockHeight(), tx)
|
||||
if err != nil {
|
||||
return res, err
|
||||
|
@ -44,7 +44,7 @@ func (c Chain) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin
|
|||
|
||||
// checkChainTx makes sure the tx is a Chain Tx, it is on the proper chain,
|
||||
// and it has not expired.
|
||||
func (c Chain) checkChainTx(chainID string, height uint64, tx basecoin.Tx) (basecoin.Tx, error) {
|
||||
func (c Chain) checkChainTx(chainID string, height uint64, tx sdk.Tx) (sdk.Tx, error) {
|
||||
// make sure it is a chaintx
|
||||
ctx, ok := tx.Unwrap().(ChainTx)
|
||||
if !ok {
|
||||
|
|
|
@ -8,9 +8,9 @@ import (
|
|||
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
)
|
||||
|
||||
func TestChainValidate(t *testing.T) {
|
||||
|
@ -39,7 +39,7 @@ func TestChainValidate(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
empty := NewChainTx("okay", 0, basecoin.Tx{})
|
||||
empty := NewChainTx("okay", 0, sdk.Tx{})
|
||||
err := empty.ValidateBasic()
|
||||
assert.NotNil(err)
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ func TestChain(t *testing.T) {
|
|||
|
||||
raw := stack.NewRawTx([]byte{1, 2, 3, 4})
|
||||
cases := []struct {
|
||||
tx basecoin.Tx
|
||||
tx sdk.Tx
|
||||
valid bool
|
||||
errorMsg string
|
||||
}{
|
||||
|
|
|
@ -6,10 +6,10 @@ import (
|
|||
"github.com/spf13/pflag"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
txcmd "github.com/tendermint/basecoin/client/commands/txs"
|
||||
"github.com/tendermint/basecoin/modules/base"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
txcmd "github.com/cosmos/cosmos-sdk/client/commands/txs"
|
||||
"github.com/cosmos/cosmos-sdk/modules/base"
|
||||
)
|
||||
|
||||
//nolint
|
||||
|
@ -23,7 +23,7 @@ type ChainWrapper struct{}
|
|||
var _ txcmd.Wrapper = ChainWrapper{}
|
||||
|
||||
// Wrap will wrap the tx with a ChainTx from the standard flags
|
||||
func (ChainWrapper) Wrap(tx basecoin.Tx) (res basecoin.Tx, err error) {
|
||||
func (ChainWrapper) Wrap(tx sdk.Tx) (res sdk.Tx, err error) {
|
||||
expires := viper.GetInt64(FlagExpires)
|
||||
chain := commands.GetChainID()
|
||||
if chain == "" {
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
abci "github.com/tendermint/abci/types"
|
||||
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/cosmos/cosmos-sdk/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/cosmos/cosmos-sdk/errors"
|
||||
)
|
||||
|
||||
func TestErrorMatches(t *testing.T) {
|
||||
|
|
|
@ -3,9 +3,9 @@ package base
|
|||
import (
|
||||
abci "github.com/tendermint/abci/types"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/errors"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
)
|
||||
|
||||
//nolint
|
||||
|
@ -21,7 +21,7 @@ const (
|
|||
)
|
||||
|
||||
func init() {
|
||||
basecoin.TxMapper.
|
||||
sdk.TxMapper.
|
||||
RegisterImplementation(ValChangeTx{}, TypeValChange, ByteValChange).
|
||||
RegisterImplementation(PriceShowTx{}, TypePriceShow, BytePriceShow)
|
||||
}
|
||||
|
@ -30,19 +30,19 @@ func init() {
|
|||
// Setup tx and handler for validation test cases
|
||||
|
||||
type ValSetHandler struct {
|
||||
basecoin.NopCheck
|
||||
basecoin.NopInitState
|
||||
basecoin.NopInitValidate
|
||||
sdk.NopCheck
|
||||
sdk.NopInitState
|
||||
sdk.NopInitValidate
|
||||
}
|
||||
|
||||
var _ basecoin.Handler = ValSetHandler{}
|
||||
var _ sdk.Handler = ValSetHandler{}
|
||||
|
||||
func (ValSetHandler) Name() string {
|
||||
return NameVal
|
||||
}
|
||||
|
||||
func (ValSetHandler) DeliverTx(ctx basecoin.Context, store state.SimpleDB,
|
||||
tx basecoin.Tx) (res basecoin.DeliverResult, err error) {
|
||||
func (ValSetHandler) DeliverTx(ctx sdk.Context, store state.SimpleDB,
|
||||
tx sdk.Tx) (res sdk.DeliverResult, err error) {
|
||||
change, ok := tx.Unwrap().(ValChangeTx)
|
||||
if !ok {
|
||||
return res, errors.ErrUnknownTxType(tx)
|
||||
|
@ -55,8 +55,8 @@ type ValChangeTx struct {
|
|||
Diff []*abci.Validator
|
||||
}
|
||||
|
||||
func (v ValChangeTx) Wrap() basecoin.Tx {
|
||||
return basecoin.Tx{v}
|
||||
func (v ValChangeTx) Wrap() sdk.Tx {
|
||||
return sdk.Tx{v}
|
||||
}
|
||||
|
||||
func (v ValChangeTx) ValidateBasic() error { return nil }
|
||||
|
@ -69,18 +69,18 @@ var PriceData = []byte{0xCA, 0xFE}
|
|||
|
||||
// PriceHandler returns checktx results based on the input
|
||||
type PriceHandler struct {
|
||||
basecoin.NopInitState
|
||||
basecoin.NopInitValidate
|
||||
sdk.NopInitState
|
||||
sdk.NopInitValidate
|
||||
}
|
||||
|
||||
var _ basecoin.Handler = PriceHandler{}
|
||||
var _ sdk.Handler = PriceHandler{}
|
||||
|
||||
func (PriceHandler) Name() string {
|
||||
return NamePrice
|
||||
}
|
||||
|
||||
func (PriceHandler) CheckTx(ctx basecoin.Context, store state.SimpleDB,
|
||||
tx basecoin.Tx) (res basecoin.CheckResult, err error) {
|
||||
func (PriceHandler) CheckTx(ctx sdk.Context, store state.SimpleDB,
|
||||
tx sdk.Tx) (res sdk.CheckResult, err error) {
|
||||
price, ok := tx.Unwrap().(PriceShowTx)
|
||||
if !ok {
|
||||
return res, errors.ErrUnknownTxType(tx)
|
||||
|
@ -91,8 +91,8 @@ func (PriceHandler) CheckTx(ctx basecoin.Context, store state.SimpleDB,
|
|||
return
|
||||
}
|
||||
|
||||
func (PriceHandler) DeliverTx(ctx basecoin.Context, store state.SimpleDB,
|
||||
tx basecoin.Tx) (res basecoin.DeliverResult, err error) {
|
||||
func (PriceHandler) DeliverTx(ctx sdk.Context, store state.SimpleDB,
|
||||
tx sdk.Tx) (res sdk.DeliverResult, err error) {
|
||||
_, ok := tx.Unwrap().(PriceShowTx)
|
||||
if !ok {
|
||||
return res, errors.ErrUnknownTxType(tx)
|
||||
|
@ -107,12 +107,12 @@ type PriceShowTx struct {
|
|||
GasPayment uint64
|
||||
}
|
||||
|
||||
func NewPriceShowTx(gasAllocated, gasPayment uint64) basecoin.Tx {
|
||||
func NewPriceShowTx(gasAllocated, gasPayment uint64) sdk.Tx {
|
||||
return PriceShowTx{GasAllocated: gasAllocated, GasPayment: gasPayment}.Wrap()
|
||||
}
|
||||
|
||||
func (p PriceShowTx) Wrap() basecoin.Tx {
|
||||
return basecoin.Tx{p}
|
||||
func (p PriceShowTx) Wrap() sdk.Tx {
|
||||
return sdk.Tx{p}
|
||||
}
|
||||
|
||||
func (v PriceShowTx) ValidateBasic() error { return nil }
|
||||
|
|
|
@ -6,9 +6,9 @@ import (
|
|||
abci "github.com/tendermint/abci/types"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
)
|
||||
|
||||
// nolint
|
||||
|
@ -27,7 +27,7 @@ func (Logger) Name() string {
|
|||
var _ stack.Middleware = Logger{}
|
||||
|
||||
// CheckTx logs time and result - fulfills Middlware interface
|
||||
func (Logger) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Checker) (res basecoin.CheckResult, err error) {
|
||||
func (Logger) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error) {
|
||||
start := time.Now()
|
||||
res, err = next.CheckTx(ctx, store, tx)
|
||||
delta := time.Now().Sub(start)
|
||||
|
@ -42,7 +42,7 @@ func (Logger) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx
|
|||
}
|
||||
|
||||
// DeliverTx logs time and result - fulfills Middlware interface
|
||||
func (Logger) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.DeliverResult, err error) {
|
||||
func (Logger) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error) {
|
||||
start := time.Now()
|
||||
res, err = next.DeliverTx(ctx, store, tx)
|
||||
delta := time.Now().Sub(start)
|
||||
|
@ -57,7 +57,7 @@ func (Logger) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.
|
|||
}
|
||||
|
||||
// InitState logs time and result - fulfills Middlware interface
|
||||
func (Logger) InitState(l log.Logger, store state.SimpleDB, module, key, value string, next basecoin.InitStater) (string, error) {
|
||||
func (Logger) InitState(l log.Logger, store state.SimpleDB, module, key, value string, next sdk.InitStater) (string, error) {
|
||||
start := time.Now()
|
||||
res, err := next.InitState(l, store, module, key, value)
|
||||
delta := time.Now().Sub(start)
|
||||
|
@ -72,7 +72,7 @@ func (Logger) InitState(l log.Logger, store state.SimpleDB, module, key, value s
|
|||
}
|
||||
|
||||
// InitValidate logs time and result - fulfills Middlware interface
|
||||
func (Logger) InitValidate(l log.Logger, store state.SimpleDB, vals []*abci.Validator, next basecoin.InitValidater) {
|
||||
func (Logger) InitValidate(l log.Logger, store state.SimpleDB, vals []*abci.Validator, next sdk.InitValidater) {
|
||||
start := time.Now()
|
||||
next.InitValidate(l, store, vals)
|
||||
delta := time.Now().Sub(start)
|
||||
|
|
|
@ -7,9 +7,9 @@ import (
|
|||
wire "github.com/tendermint/go-wire"
|
||||
"github.com/tendermint/go-wire/data"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
)
|
||||
|
||||
//nolint
|
||||
|
@ -31,7 +31,7 @@ func (Multiplexer) Name() string {
|
|||
var _ stack.Middleware = Multiplexer{}
|
||||
|
||||
// CheckTx splits the input tx and checks them all - fulfills Middlware interface
|
||||
func (Multiplexer) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Checker) (res basecoin.CheckResult, err error) {
|
||||
func (Multiplexer) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error) {
|
||||
if mtx, ok := tx.Unwrap().(MultiTx); ok {
|
||||
return runAllChecks(ctx, store, mtx.Txs, next)
|
||||
}
|
||||
|
@ -39,16 +39,16 @@ func (Multiplexer) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx baseco
|
|||
}
|
||||
|
||||
// DeliverTx splits the input tx and checks them all - fulfills Middlware interface
|
||||
func (Multiplexer) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.DeliverResult, err error) {
|
||||
func (Multiplexer) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error) {
|
||||
if mtx, ok := tx.Unwrap().(MultiTx); ok {
|
||||
return runAllDelivers(ctx, store, mtx.Txs, next)
|
||||
}
|
||||
return next.DeliverTx(ctx, store, tx)
|
||||
}
|
||||
|
||||
func runAllChecks(ctx basecoin.Context, store state.SimpleDB, txs []basecoin.Tx, next basecoin.Checker) (res basecoin.CheckResult, err error) {
|
||||
func runAllChecks(ctx sdk.Context, store state.SimpleDB, txs []sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error) {
|
||||
// store all results, unless anything errors
|
||||
rs := make([]basecoin.CheckResult, len(txs))
|
||||
rs := make([]sdk.CheckResult, len(txs))
|
||||
for i, stx := range txs {
|
||||
rs[i], err = next.CheckTx(ctx, store, stx)
|
||||
if err != nil {
|
||||
|
@ -59,9 +59,9 @@ func runAllChecks(ctx basecoin.Context, store state.SimpleDB, txs []basecoin.Tx,
|
|||
return combineChecks(rs), nil
|
||||
}
|
||||
|
||||
func runAllDelivers(ctx basecoin.Context, store state.SimpleDB, txs []basecoin.Tx, next basecoin.Deliver) (res basecoin.DeliverResult, err error) {
|
||||
func runAllDelivers(ctx sdk.Context, store state.SimpleDB, txs []sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error) {
|
||||
// store all results, unless anything errors
|
||||
rs := make([]basecoin.DeliverResult, len(txs))
|
||||
rs := make([]sdk.DeliverResult, len(txs))
|
||||
for i, stx := range txs {
|
||||
rs[i], err = next.DeliverTx(ctx, store, stx)
|
||||
if err != nil {
|
||||
|
@ -74,7 +74,7 @@ func runAllDelivers(ctx basecoin.Context, store state.SimpleDB, txs []basecoin.T
|
|||
|
||||
// combines all data bytes as a go-wire array.
|
||||
// joins all log messages with \n
|
||||
func combineChecks(all []basecoin.CheckResult) basecoin.CheckResult {
|
||||
func combineChecks(all []sdk.CheckResult) sdk.CheckResult {
|
||||
datas := make([]data.Bytes, len(all))
|
||||
logs := make([]string, len(all))
|
||||
var allocated, payments uint64
|
||||
|
@ -84,7 +84,7 @@ func combineChecks(all []basecoin.CheckResult) basecoin.CheckResult {
|
|||
allocated += r.GasAllocated
|
||||
payments += r.GasPayment
|
||||
}
|
||||
return basecoin.CheckResult{
|
||||
return sdk.CheckResult{
|
||||
Data: wire.BinaryBytes(datas),
|
||||
Log: strings.Join(logs, "\n"),
|
||||
GasAllocated: allocated,
|
||||
|
@ -94,7 +94,7 @@ func combineChecks(all []basecoin.CheckResult) basecoin.CheckResult {
|
|||
|
||||
// combines all data bytes as a go-wire array.
|
||||
// joins all log messages with \n
|
||||
func combineDelivers(all []basecoin.DeliverResult) basecoin.DeliverResult {
|
||||
func combineDelivers(all []sdk.DeliverResult) sdk.DeliverResult {
|
||||
datas := make([]data.Bytes, len(all))
|
||||
logs := make([]string, len(all))
|
||||
var used uint64
|
||||
|
@ -107,7 +107,7 @@ func combineDelivers(all []basecoin.DeliverResult) basecoin.DeliverResult {
|
|||
diffs = append(diffs, r.Diff...)
|
||||
}
|
||||
}
|
||||
return basecoin.DeliverResult{
|
||||
return sdk.DeliverResult{
|
||||
Data: wire.BinaryBytes(datas),
|
||||
Log: strings.Join(logs, "\n"),
|
||||
GasUsed: used,
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
wire "github.com/tendermint/go-wire"
|
||||
"github.com/tendermint/go-wire/data"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
@ -41,7 +41,7 @@ func TestMultiplexer(t *testing.T) {
|
|||
}
|
||||
|
||||
cases := [...]struct {
|
||||
tx basecoin.Tx
|
||||
tx sdk.Tx
|
||||
valid bool
|
||||
gasAllocated uint64
|
||||
gasPayment uint64
|
||||
|
|
|
@ -3,8 +3,8 @@ package base
|
|||
import (
|
||||
"regexp"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/errors"
|
||||
)
|
||||
|
||||
// nolint
|
||||
|
@ -21,7 +21,7 @@ const (
|
|||
)
|
||||
|
||||
func init() {
|
||||
basecoin.TxMapper.
|
||||
sdk.TxMapper.
|
||||
RegisterImplementation(MultiTx{}, TypeMultiTx, ByteMultiTx).
|
||||
RegisterImplementation(ChainTx{}, TypeChainTx, ByteChainTx)
|
||||
}
|
||||
|
@ -30,17 +30,17 @@ func init() {
|
|||
|
||||
// MultiTx - a transaction containing multiple transactions
|
||||
type MultiTx struct {
|
||||
Txs []basecoin.Tx `json:"txs"`
|
||||
Txs []sdk.Tx `json:"txs"`
|
||||
}
|
||||
|
||||
var _ basecoin.TxInner = &MultiTx{}
|
||||
var _ sdk.TxInner = &MultiTx{}
|
||||
|
||||
//nolint - TxInner Functions
|
||||
func NewMultiTx(txs ...basecoin.Tx) basecoin.Tx {
|
||||
func NewMultiTx(txs ...sdk.Tx) sdk.Tx {
|
||||
return (MultiTx{Txs: txs}).Wrap()
|
||||
}
|
||||
func (mt MultiTx) Wrap() basecoin.Tx {
|
||||
return basecoin.Tx{mt}
|
||||
func (mt MultiTx) Wrap() sdk.Tx {
|
||||
return sdk.Tx{mt}
|
||||
}
|
||||
func (mt MultiTx) ValidateBasic() error {
|
||||
for _, t := range mt.Txs {
|
||||
|
@ -60,10 +60,10 @@ type ChainTx struct {
|
|||
ChainID string `json:"chain_id"`
|
||||
// block height at which it is no longer valid, 0 means no expiration
|
||||
ExpiresAt uint64 `json:"expires_at"`
|
||||
Tx basecoin.Tx `json:"tx"`
|
||||
Tx sdk.Tx `json:"tx"`
|
||||
}
|
||||
|
||||
var _ basecoin.TxInner = &ChainTx{}
|
||||
var _ sdk.TxInner = &ChainTx{}
|
||||
|
||||
var (
|
||||
chainPattern = regexp.MustCompile("^[A-Za-z0-9_-]+$")
|
||||
|
@ -71,7 +71,7 @@ var (
|
|||
|
||||
// NewChainTx wraps a particular tx with the ChainTx wrapper,
|
||||
// to enforce chain and height
|
||||
func NewChainTx(chainID string, expires uint64, tx basecoin.Tx) basecoin.Tx {
|
||||
func NewChainTx(chainID string, expires uint64, tx sdk.Tx) sdk.Tx {
|
||||
c := ChainTx{
|
||||
ChainID: chainID,
|
||||
ExpiresAt: expires,
|
||||
|
@ -81,8 +81,8 @@ func NewChainTx(chainID string, expires uint64, tx basecoin.Tx) basecoin.Tx {
|
|||
}
|
||||
|
||||
//nolint - TxInner Functions
|
||||
func (c ChainTx) Wrap() basecoin.Tx {
|
||||
return basecoin.Tx{c}
|
||||
func (c ChainTx) Wrap() sdk.Tx {
|
||||
return sdk.Tx{c}
|
||||
}
|
||||
func (c ChainTx) ValidateBasic() error {
|
||||
if c.ChainID == "" {
|
||||
|
|
|
@ -9,8 +9,8 @@ import (
|
|||
|
||||
"github.com/tendermint/go-wire/data"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
)
|
||||
|
||||
func TestEncoding(t *testing.T) {
|
||||
|
@ -21,7 +21,7 @@ func TestEncoding(t *testing.T) {
|
|||
// raw2 := stack.NewRawTx([]byte{0x73, 0x86, 0x22})
|
||||
|
||||
cases := []struct {
|
||||
Tx basecoin.Tx
|
||||
Tx sdk.Tx
|
||||
}{
|
||||
{raw},
|
||||
// {NewMultiTx(raw, raw2)},
|
||||
|
@ -35,7 +35,7 @@ func TestEncoding(t *testing.T) {
|
|||
// test json in and out
|
||||
js, err := data.ToJSON(tx)
|
||||
require.Nil(err, i)
|
||||
var jtx basecoin.Tx
|
||||
var jtx sdk.Tx
|
||||
err = data.FromJSON(js, &jtx)
|
||||
require.Nil(err, i)
|
||||
assert.Equal(tx, jtx, i)
|
||||
|
@ -43,7 +43,7 @@ func TestEncoding(t *testing.T) {
|
|||
// test wire in and out
|
||||
bin, err := data.ToWire(tx)
|
||||
require.Nil(err, i)
|
||||
var wtx basecoin.Tx
|
||||
var wtx sdk.Tx
|
||||
err = data.FromWire(bin, &wtx)
|
||||
require.Nil(err, i)
|
||||
assert.Equal(tx, wtx, i)
|
||||
|
|
|
@ -6,16 +6,16 @@ import (
|
|||
cmn "github.com/tendermint/tmlibs/common"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
)
|
||||
|
||||
func makeHandler() stack.Dispatchable {
|
||||
return NewHandler()
|
||||
}
|
||||
|
||||
func makeSimpleTx(from, to basecoin.Actor, amount Coins) basecoin.Tx {
|
||||
func makeSimpleTx(from, to sdk.Actor, amount Coins) sdk.Tx {
|
||||
in := []TxInput{{Address: from, Coins: amount}}
|
||||
out := []TxOutput{{Address: to, Coins: amount}}
|
||||
return NewSendTx(in, out)
|
||||
|
@ -30,7 +30,7 @@ func BenchmarkSimpleTransfer(b *testing.B) {
|
|||
acct := NewAccountWithKey(Coins{{"mycoin", 1234567890}})
|
||||
h.InitState(logger, store, NameCoin, "account", acct.MakeOption(), nil)
|
||||
sender := acct.Actor()
|
||||
receiver := basecoin.Actor{App: "foo", Address: cmn.RandBytes(20)}
|
||||
receiver := sdk.Actor{App: "foo", Address: cmn.RandBytes(20)}
|
||||
|
||||
// now, loop...
|
||||
for i := 1; i <= b.N; i++ {
|
||||
|
|
|
@ -7,10 +7,10 @@ import (
|
|||
|
||||
lc "github.com/tendermint/light-client"
|
||||
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/tendermint/basecoin/client/commands/query"
|
||||
"github.com/tendermint/basecoin/modules/coin"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands/query"
|
||||
"github.com/cosmos/cosmos-sdk/modules/coin"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
)
|
||||
|
||||
// AccountQueryCmd - command to query an account
|
||||
|
|
|
@ -4,10 +4,10 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
txcmd "github.com/tendermint/basecoin/client/commands/txs"
|
||||
"github.com/tendermint/basecoin/modules/coin"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
txcmd "github.com/cosmos/cosmos-sdk/client/commands/txs"
|
||||
"github.com/cosmos/cosmos-sdk/modules/coin"
|
||||
)
|
||||
|
||||
// SendTxCmd is CLI command to send tokens between basecoin accounts
|
||||
|
@ -50,7 +50,7 @@ func sendTxCmd(cmd *cobra.Command, args []string) error {
|
|||
return txcmd.DoTx(tx)
|
||||
}
|
||||
|
||||
func readSendTxFlags() (tx basecoin.Tx, err error) {
|
||||
func readSendTxFlags() (tx sdk.Tx, err error) {
|
||||
// parse to address
|
||||
toAddr, err := commands.ParseActor(viper.GetString(FlagTo))
|
||||
if err != nil {
|
||||
|
@ -80,7 +80,7 @@ func creditTxCmd(cmd *cobra.Command, args []string) error {
|
|||
return txcmd.DoTx(tx)
|
||||
}
|
||||
|
||||
func readCreditTxFlags() (tx basecoin.Tx, err error) {
|
||||
func readCreditTxFlags() (tx sdk.Tx, err error) {
|
||||
// parse to address
|
||||
toAddr, err := commands.ParseActor(viper.GetString(FlagTo))
|
||||
if err != nil {
|
||||
|
@ -96,7 +96,7 @@ func readCreditTxFlags() (tx basecoin.Tx, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func readFromAddr() (basecoin.Actor, error) {
|
||||
func readFromAddr() (sdk.Actor, error) {
|
||||
from := viper.GetString(FlagFrom)
|
||||
if from == "" {
|
||||
return txcmd.GetSignerAct(), nil
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
abci "github.com/tendermint/abci/types"
|
||||
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/cosmos/cosmos-sdk/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
@ -4,12 +4,12 @@ import (
|
|||
"github.com/tendermint/go-wire/data"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/tendermint/basecoin/modules/auth"
|
||||
"github.com/tendermint/basecoin/modules/ibc"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/errors"
|
||||
"github.com/cosmos/cosmos-sdk/modules/auth"
|
||||
"github.com/cosmos/cosmos-sdk/modules/ibc"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -42,8 +42,8 @@ func (Handler) Name() string {
|
|||
func (Handler) AssertDispatcher() {}
|
||||
|
||||
// CheckTx checks if there is enough money in the account
|
||||
func (h Handler) CheckTx(ctx basecoin.Context, store state.SimpleDB,
|
||||
tx basecoin.Tx, _ basecoin.Checker) (res basecoin.CheckResult, err error) {
|
||||
func (h Handler) CheckTx(ctx sdk.Context, store state.SimpleDB,
|
||||
tx sdk.Tx, _ sdk.Checker) (res sdk.CheckResult, err error) {
|
||||
|
||||
err = tx.ValidateBasic()
|
||||
if err != nil {
|
||||
|
@ -54,17 +54,17 @@ func (h Handler) CheckTx(ctx basecoin.Context, store state.SimpleDB,
|
|||
case SendTx:
|
||||
// price based on inputs and outputs
|
||||
used := uint64(len(t.Inputs) + len(t.Outputs))
|
||||
return basecoin.NewCheck(used*CostSend, ""), h.checkSendTx(ctx, store, t)
|
||||
return sdk.NewCheck(used*CostSend, ""), h.checkSendTx(ctx, store, t)
|
||||
case CreditTx:
|
||||
// default price of 20, constant work
|
||||
return basecoin.NewCheck(CostCredit, ""), h.creditTx(ctx, store, t)
|
||||
return sdk.NewCheck(CostCredit, ""), h.creditTx(ctx, store, t)
|
||||
}
|
||||
return res, errors.ErrUnknownTxType(tx.Unwrap())
|
||||
}
|
||||
|
||||
// DeliverTx moves the money
|
||||
func (h Handler) DeliverTx(ctx basecoin.Context, store state.SimpleDB,
|
||||
tx basecoin.Tx, cb basecoin.Deliver) (res basecoin.DeliverResult, err error) {
|
||||
func (h Handler) DeliverTx(ctx sdk.Context, store state.SimpleDB,
|
||||
tx sdk.Tx, cb sdk.Deliver) (res sdk.DeliverResult, err error) {
|
||||
|
||||
err = tx.ValidateBasic()
|
||||
if err != nil {
|
||||
|
@ -82,7 +82,7 @@ func (h Handler) DeliverTx(ctx basecoin.Context, store state.SimpleDB,
|
|||
|
||||
// InitState - sets the genesis account balance
|
||||
func (h Handler) InitState(l log.Logger, store state.SimpleDB,
|
||||
module, key, value string, cb basecoin.InitStater) (log string, err error) {
|
||||
module, key, value string, cb sdk.InitStater) (log string, err error) {
|
||||
if module != NameCoin {
|
||||
return "", errors.ErrUnknownModule(module)
|
||||
}
|
||||
|
@ -95,8 +95,8 @@ func (h Handler) InitState(l log.Logger, store state.SimpleDB,
|
|||
return "", errors.ErrUnknownKey(key)
|
||||
}
|
||||
|
||||
func (h Handler) sendTx(ctx basecoin.Context, store state.SimpleDB,
|
||||
send SendTx, cb basecoin.Deliver) error {
|
||||
func (h Handler) sendTx(ctx sdk.Context, store state.SimpleDB,
|
||||
send SendTx, cb sdk.Deliver) error {
|
||||
|
||||
err := checkTx(ctx, send)
|
||||
if err != nil {
|
||||
|
@ -104,7 +104,7 @@ func (h Handler) sendTx(ctx basecoin.Context, store state.SimpleDB,
|
|||
}
|
||||
|
||||
// deduct from all input accounts
|
||||
senders := basecoin.Actors{}
|
||||
senders := sdk.Actors{}
|
||||
for _, in := range send.Inputs {
|
||||
_, err = ChangeCoins(store, in.Address, in.Coins.Negative())
|
||||
if err != nil {
|
||||
|
@ -153,7 +153,7 @@ func (h Handler) sendTx(ctx basecoin.Context, store state.SimpleDB,
|
|||
return nil
|
||||
}
|
||||
|
||||
func (h Handler) creditTx(ctx basecoin.Context, store state.SimpleDB,
|
||||
func (h Handler) creditTx(ctx sdk.Context, store state.SimpleDB,
|
||||
credit CreditTx) error {
|
||||
|
||||
// first check permissions!!
|
||||
|
@ -186,7 +186,7 @@ func (h Handler) creditTx(ctx basecoin.Context, store state.SimpleDB,
|
|||
return err
|
||||
}
|
||||
|
||||
func checkTx(ctx basecoin.Context, send SendTx) error {
|
||||
func checkTx(ctx sdk.Context, send SendTx) error {
|
||||
// check if all inputs have permission
|
||||
for _, in := range send.Inputs {
|
||||
if !ctx.HasPermission(in.Address) {
|
||||
|
@ -196,7 +196,7 @@ func checkTx(ctx basecoin.Context, send SendTx) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (Handler) checkSendTx(ctx basecoin.Context, store state.SimpleDB, send SendTx) error {
|
||||
func (Handler) checkSendTx(ctx sdk.Context, store state.SimpleDB, send SendTx) error {
|
||||
err := checkTx(ctx, send)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -234,7 +234,7 @@ func setAccount(store state.SimpleDB, value string) (log string, err error) {
|
|||
// setIssuer sets a permission for some super-powerful account to
|
||||
// mint money
|
||||
func setIssuer(store state.SimpleDB, value string) (log string, err error) {
|
||||
var issuer basecoin.Actor
|
||||
var issuer sdk.Actor
|
||||
err = data.FromJSON([]byte(value), &issuer)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
|
|
@ -10,11 +10,11 @@ import (
|
|||
crypto "github.com/tendermint/go-crypto"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/tendermint/basecoin/modules/auth"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/errors"
|
||||
"github.com/cosmos/cosmos-sdk/modules/auth"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
)
|
||||
|
||||
// this makes sure that txs are rejected with invalid data or permissions
|
||||
|
@ -22,56 +22,56 @@ func TestHandlerValidation(t *testing.T) {
|
|||
assert := assert.New(t)
|
||||
|
||||
// these are all valid, except for minusCoins
|
||||
addr1 := basecoin.Actor{App: "coin", Address: []byte{1, 2}}
|
||||
addr2 := basecoin.Actor{App: "role", Address: []byte{7, 8}}
|
||||
addr1 := sdk.Actor{App: "coin", Address: []byte{1, 2}}
|
||||
addr2 := sdk.Actor{App: "role", Address: []byte{7, 8}}
|
||||
someCoins := Coins{{"atom", 123}}
|
||||
doubleCoins := Coins{{"atom", 246}}
|
||||
minusCoins := Coins{{"eth", -34}}
|
||||
|
||||
cases := []struct {
|
||||
valid bool
|
||||
tx basecoin.Tx
|
||||
perms []basecoin.Actor
|
||||
tx sdk.Tx
|
||||
perms []sdk.Actor
|
||||
}{
|
||||
// auth works with different apps
|
||||
{true,
|
||||
NewSendTx(
|
||||
[]TxInput{NewTxInput(addr1, someCoins)},
|
||||
[]TxOutput{NewTxOutput(addr2, someCoins)}),
|
||||
[]basecoin.Actor{addr1}},
|
||||
[]sdk.Actor{addr1}},
|
||||
{true,
|
||||
NewSendTx(
|
||||
[]TxInput{NewTxInput(addr2, someCoins)},
|
||||
[]TxOutput{NewTxOutput(addr1, someCoins)}),
|
||||
[]basecoin.Actor{addr1, addr2}},
|
||||
[]sdk.Actor{addr1, addr2}},
|
||||
// check multi-input with both sigs
|
||||
{true,
|
||||
NewSendTx(
|
||||
[]TxInput{NewTxInput(addr1, someCoins), NewTxInput(addr2, someCoins)},
|
||||
[]TxOutput{NewTxOutput(addr1, doubleCoins)}),
|
||||
[]basecoin.Actor{addr1, addr2}},
|
||||
[]sdk.Actor{addr1, addr2}},
|
||||
// wrong permissions fail
|
||||
{false,
|
||||
NewSendTx(
|
||||
[]TxInput{NewTxInput(addr1, someCoins)},
|
||||
[]TxOutput{NewTxOutput(addr2, someCoins)}),
|
||||
[]basecoin.Actor{}},
|
||||
[]sdk.Actor{}},
|
||||
{false,
|
||||
NewSendTx(
|
||||
[]TxInput{NewTxInput(addr1, someCoins)},
|
||||
[]TxOutput{NewTxOutput(addr2, someCoins)}),
|
||||
[]basecoin.Actor{addr2}},
|
||||
[]sdk.Actor{addr2}},
|
||||
{false,
|
||||
NewSendTx(
|
||||
[]TxInput{NewTxInput(addr1, someCoins), NewTxInput(addr2, someCoins)},
|
||||
[]TxOutput{NewTxOutput(addr1, doubleCoins)}),
|
||||
[]basecoin.Actor{addr1}},
|
||||
[]sdk.Actor{addr1}},
|
||||
// invalid input fails
|
||||
{false,
|
||||
NewSendTx(
|
||||
[]TxInput{NewTxInput(addr1, minusCoins)},
|
||||
[]TxOutput{NewTxOutput(addr2, minusCoins)}),
|
||||
[]basecoin.Actor{addr2}},
|
||||
[]sdk.Actor{addr2}},
|
||||
}
|
||||
|
||||
for i, tc := range cases {
|
||||
|
@ -90,9 +90,9 @@ func TestCheckDeliverSendTx(t *testing.T) {
|
|||
require := require.New(t)
|
||||
|
||||
// some sample settings
|
||||
addr1 := basecoin.Actor{App: "coin", Address: []byte{1, 2}}
|
||||
addr2 := basecoin.Actor{App: "role", Address: []byte{7, 8}}
|
||||
addr3 := basecoin.Actor{App: "coin", Address: []byte{6, 5, 4, 3}}
|
||||
addr1 := sdk.Actor{App: "coin", Address: []byte{1, 2}}
|
||||
addr2 := sdk.Actor{App: "role", Address: []byte{7, 8}}
|
||||
addr3 := sdk.Actor{App: "coin", Address: []byte{6, 5, 4, 3}}
|
||||
|
||||
someCoins := Coins{{"atom", 123}}
|
||||
moreCoins := Coins{{"atom", 6487}}
|
||||
|
@ -101,14 +101,14 @@ func TestCheckDeliverSendTx(t *testing.T) {
|
|||
mixedCoins := someCoins.Plus(otherCoins)
|
||||
|
||||
type money struct {
|
||||
addr basecoin.Actor
|
||||
addr sdk.Actor
|
||||
coins Coins
|
||||
}
|
||||
|
||||
cases := []struct {
|
||||
init []money
|
||||
tx basecoin.Tx
|
||||
perms []basecoin.Actor
|
||||
tx sdk.Tx
|
||||
perms []sdk.Actor
|
||||
final []money // nil for error
|
||||
cost uint64 // gas allocated (if not error)
|
||||
}{
|
||||
|
@ -117,7 +117,7 @@ func TestCheckDeliverSendTx(t *testing.T) {
|
|||
NewSendTx(
|
||||
[]TxInput{NewTxInput(addr1, someCoins)},
|
||||
[]TxOutput{NewTxOutput(addr2, someCoins)}),
|
||||
[]basecoin.Actor{addr1},
|
||||
[]sdk.Actor{addr1},
|
||||
[]money{{addr1, diffCoins}, {addr2, someCoins}},
|
||||
20,
|
||||
},
|
||||
|
@ -127,7 +127,7 @@ func TestCheckDeliverSendTx(t *testing.T) {
|
|||
NewSendTx(
|
||||
[]TxInput{NewTxInput(addr1, otherCoins), NewTxInput(addr2, someCoins)},
|
||||
[]TxOutput{NewTxOutput(addr3, mixedCoins)}),
|
||||
[]basecoin.Actor{addr1, addr2},
|
||||
[]sdk.Actor{addr1, addr2},
|
||||
[]money{{addr1, someCoins}, {addr2, diffCoins}, {addr3, mixedCoins}},
|
||||
30,
|
||||
},
|
||||
|
@ -137,7 +137,7 @@ func TestCheckDeliverSendTx(t *testing.T) {
|
|||
NewSendTx(
|
||||
[]TxInput{NewTxInput(addr1, otherCoins), NewTxInput(addr1, someCoins)},
|
||||
[]TxOutput{NewTxOutput(addr2, mixedCoins)}),
|
||||
[]basecoin.Actor{addr1},
|
||||
[]sdk.Actor{addr1},
|
||||
[]money{{addr1, diffCoins}, {addr2, mixedCoins}},
|
||||
30,
|
||||
},
|
||||
|
@ -147,7 +147,7 @@ func TestCheckDeliverSendTx(t *testing.T) {
|
|||
NewSendTx(
|
||||
[]TxInput{NewTxInput(addr2, moreCoins)},
|
||||
[]TxOutput{NewTxOutput(addr1, moreCoins)}),
|
||||
[]basecoin.Actor{addr1, addr2},
|
||||
[]sdk.Actor{addr1, addr2},
|
||||
nil,
|
||||
0,
|
||||
},
|
||||
|
@ -206,7 +206,7 @@ func TestInitState(t *testing.T) {
|
|||
mixedCoins := someCoins.Plus(otherCoins)
|
||||
|
||||
type money struct {
|
||||
addr basecoin.Actor
|
||||
addr sdk.Actor
|
||||
coins Coins
|
||||
}
|
||||
|
||||
|
@ -248,12 +248,12 @@ func TestSetIssuer(t *testing.T) {
|
|||
require := require.New(t)
|
||||
|
||||
cases := []struct {
|
||||
issuer basecoin.Actor
|
||||
issuer sdk.Actor
|
||||
}{
|
||||
{basecoin.Actor{App: "sig", Address: []byte("gwkfgk")}},
|
||||
{sdk.Actor{App: "sig", Address: []byte("gwkfgk")}},
|
||||
// and set back to empty (nil is valid, but assert.Equals doesn't match)
|
||||
{basecoin.Actor{Address: []byte{}}},
|
||||
{basecoin.Actor{ChainID: "other", App: "role", Address: []byte("vote")}},
|
||||
{sdk.Actor{Address: []byte{}}},
|
||||
{sdk.Actor{ChainID: "other", App: "role", Address: []byte("vote")}},
|
||||
}
|
||||
|
||||
h := NewHandler()
|
||||
|
@ -286,11 +286,11 @@ func TestDeliverCreditTx(t *testing.T) {
|
|||
mixedCoins := someCoins.Plus(otherCoins)
|
||||
|
||||
// some sample addresses
|
||||
owner := basecoin.Actor{App: "foo", Address: []byte("rocks")}
|
||||
addr1 := basecoin.Actor{App: "coin", Address: []byte{1, 2}}
|
||||
owner := sdk.Actor{App: "foo", Address: []byte("rocks")}
|
||||
addr1 := sdk.Actor{App: "coin", Address: []byte{1, 2}}
|
||||
key := NewAccountWithKey(someCoins)
|
||||
addr2 := key.Actor()
|
||||
addr3 := basecoin.Actor{ChainID: "other", App: "sigs", Address: []byte{3, 9}}
|
||||
addr3 := sdk.Actor{ChainID: "other", App: "sigs", Address: []byte{3, 9}}
|
||||
|
||||
h := NewHandler()
|
||||
store := state.NewMemKVStore()
|
||||
|
@ -307,10 +307,10 @@ func TestDeliverCreditTx(t *testing.T) {
|
|||
require.Nil(err, "%+v", err)
|
||||
|
||||
cases := []struct {
|
||||
tx basecoin.Tx
|
||||
perm basecoin.Actor
|
||||
tx sdk.Tx
|
||||
perm sdk.Actor
|
||||
check errors.CheckErr
|
||||
addr basecoin.Actor
|
||||
addr sdk.Actor
|
||||
expected Account
|
||||
}{
|
||||
// require permission
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
crypto "github.com/tendermint/go-crypto"
|
||||
"github.com/tendermint/go-wire/data"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/modules/auth"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/modules/auth"
|
||||
)
|
||||
|
||||
// AccountWithKey is a helper for tests, that includes and account
|
||||
|
@ -31,7 +31,7 @@ func (a *AccountWithKey) Address() []byte {
|
|||
}
|
||||
|
||||
// Actor returns the basecoin actor associated with this account
|
||||
func (a *AccountWithKey) Actor() basecoin.Actor {
|
||||
func (a *AccountWithKey) Actor() sdk.Actor {
|
||||
return auth.SigPerm(a.Key.PubKey().Address())
|
||||
}
|
||||
|
||||
|
|
|
@ -5,12 +5,12 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/tendermint/basecoin/modules/auth"
|
||||
"github.com/tendermint/basecoin/modules/ibc"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/errors"
|
||||
"github.com/cosmos/cosmos-sdk/modules/auth"
|
||||
"github.com/cosmos/cosmos-sdk/modules/ibc"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
wire "github.com/tendermint/go-wire"
|
||||
)
|
||||
|
||||
|
@ -48,7 +48,7 @@ func TestIBCPostPacket(t *testing.T) {
|
|||
require.Nil(err, "%+v", err)
|
||||
|
||||
// sends money to another guy on a different chain, now other chain has credit
|
||||
buddy := basecoin.Actor{ChainID: otherID, App: auth.NameSigs, Address: []byte("dude")}
|
||||
buddy := sdk.Actor{ChainID: otherID, App: auth.NameSigs, Address: []byte("dude")}
|
||||
outTx := NewSendOneTx(rich.Actor(), buddy, wealth)
|
||||
_, err = ourChain.DeliverTx(outTx, rich.Actor())
|
||||
require.Nil(err, "%+v", err)
|
||||
|
@ -64,8 +64,8 @@ func TestIBCPostPacket(t *testing.T) {
|
|||
assertPacket(t, istore, otherID, wealth)
|
||||
|
||||
// these are the people for testing incoming ibc from the other chain
|
||||
recipient := basecoin.Actor{ChainID: ourID, App: auth.NameSigs, Address: []byte("bar")}
|
||||
sender := basecoin.Actor{ChainID: otherID, App: auth.NameSigs, Address: []byte("foo")}
|
||||
recipient := sdk.Actor{ChainID: ourID, App: auth.NameSigs, Address: []byte("bar")}
|
||||
sender := sdk.Actor{ChainID: otherID, App: auth.NameSigs, Address: []byte("foo")}
|
||||
payment := Coins{{"eth", 100}, {"ltc", 300}}
|
||||
coinTx := NewSendOneTx(sender, recipient, payment)
|
||||
wrongCoin := NewSendOneTx(sender, recipient, Coins{{"missing", 20}})
|
||||
|
@ -82,10 +82,10 @@ func TestIBCPostPacket(t *testing.T) {
|
|||
packet2, update2 := otherChain.MakePostPacket(p2, start+50)
|
||||
require.Nil(ourChain.Update(update2))
|
||||
|
||||
ibcPerm := basecoin.Actors{ibc.AllowIBC(NameCoin)}
|
||||
ibcPerm := sdk.Actors{ibc.AllowIBC(NameCoin)}
|
||||
cases := []struct {
|
||||
packet ibc.PostPacketTx
|
||||
permissions basecoin.Actors
|
||||
permissions sdk.Actors
|
||||
checker errors.CheckErr
|
||||
}{
|
||||
// out of order -> error
|
||||
|
|
|
@ -8,15 +8,15 @@ import (
|
|||
"github.com/gorilla/mux"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/tendermint/basecoin/client/commands/query"
|
||||
"github.com/tendermint/basecoin/modules/auth"
|
||||
"github.com/tendermint/basecoin/modules/base"
|
||||
"github.com/tendermint/basecoin/modules/coin"
|
||||
"github.com/tendermint/basecoin/modules/fee"
|
||||
"github.com/tendermint/basecoin/modules/nonce"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands/query"
|
||||
"github.com/cosmos/cosmos-sdk/modules/auth"
|
||||
"github.com/cosmos/cosmos-sdk/modules/base"
|
||||
"github.com/cosmos/cosmos-sdk/modules/coin"
|
||||
"github.com/cosmos/cosmos-sdk/modules/fee"
|
||||
"github.com/cosmos/cosmos-sdk/modules/nonce"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
lightclient "github.com/tendermint/light-client"
|
||||
"github.com/tendermint/tmlibs/common"
|
||||
)
|
||||
|
@ -30,8 +30,8 @@ type SendInput struct {
|
|||
Multi bool `json:"multi,omitempty"`
|
||||
Sequence uint32 `json:"sequence"`
|
||||
|
||||
To *basecoin.Actor `json:"to"`
|
||||
From *basecoin.Actor `json:"from"`
|
||||
To *sdk.Actor `json:"to"`
|
||||
From *sdk.Actor `json:"from"`
|
||||
Amount coin.Coins `json:"amount"`
|
||||
}
|
||||
|
||||
|
@ -64,14 +64,14 @@ func doQueryAccount(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
}
|
||||
|
||||
func PrepareSendTx(si *SendInput) basecoin.Tx {
|
||||
func PrepareSendTx(si *SendInput) sdk.Tx {
|
||||
tx := coin.NewSendOneTx(*si.From, *si.To, si.Amount)
|
||||
// fees are optional
|
||||
if si.Fees != nil && !si.Fees.IsZero() {
|
||||
tx = fee.NewFee(tx, *si.Fees, *si.From)
|
||||
}
|
||||
// only add the actual signer to the nonce
|
||||
signers := []basecoin.Actor{*si.From}
|
||||
signers := []sdk.Actor{*si.From}
|
||||
tx = nonce.NewTx(si.Sequence, signers, tx)
|
||||
tx = base.NewChainTx(commands.GetChainID(), 0, tx)
|
||||
|
||||
|
|
|
@ -5,13 +5,13 @@ import (
|
|||
|
||||
wire "github.com/tendermint/go-wire"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/errors"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
)
|
||||
|
||||
// GetAccount - Get account from store and address
|
||||
func GetAccount(store state.SimpleDB, addr basecoin.Actor) (Account, error) {
|
||||
func GetAccount(store state.SimpleDB, addr sdk.Actor) (Account, error) {
|
||||
// if the actor is another chain, we use one address for the chain....
|
||||
addr = ChainAddr(addr)
|
||||
acct, err := loadAccount(store, addr.Bytes())
|
||||
|
@ -24,7 +24,7 @@ func GetAccount(store state.SimpleDB, addr basecoin.Actor) (Account, error) {
|
|||
}
|
||||
|
||||
// CheckCoins makes sure there are funds, but doesn't change anything
|
||||
func CheckCoins(store state.SimpleDB, addr basecoin.Actor, coins Coins) (Coins, error) {
|
||||
func CheckCoins(store state.SimpleDB, addr sdk.Actor, coins Coins) (Coins, error) {
|
||||
// if the actor is another chain, we use one address for the chain....
|
||||
addr = ChainAddr(addr)
|
||||
|
||||
|
@ -33,7 +33,7 @@ func CheckCoins(store state.SimpleDB, addr basecoin.Actor, coins Coins) (Coins,
|
|||
}
|
||||
|
||||
// ChangeCoins changes the money, returns error if it would be negative
|
||||
func ChangeCoins(store state.SimpleDB, addr basecoin.Actor, coins Coins) (Coins, error) {
|
||||
func ChangeCoins(store state.SimpleDB, addr sdk.Actor, coins Coins) (Coins, error) {
|
||||
// if the actor is another chain, we use one address for the chain....
|
||||
addr = ChainAddr(addr)
|
||||
|
||||
|
@ -50,7 +50,7 @@ func ChangeCoins(store state.SimpleDB, addr basecoin.Actor, coins Coins) (Coins,
|
|||
// keep an over-all balance
|
||||
//
|
||||
// TODO: is there a better way to do this?
|
||||
func ChainAddr(addr basecoin.Actor) basecoin.Actor {
|
||||
func ChainAddr(addr sdk.Actor) sdk.Actor {
|
||||
if addr.ChainID == "" {
|
||||
return addr
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ func ChainAddr(addr basecoin.Actor) basecoin.Actor {
|
|||
// updateCoins will load the account, make all checks, and return the updated account.
|
||||
//
|
||||
// it doesn't save anything, that is up to you to decide (Check/Change Coins)
|
||||
func updateCoins(store state.SimpleDB, addr basecoin.Actor, coins Coins) (acct Account, err error) {
|
||||
func updateCoins(store state.SimpleDB, addr sdk.Actor, coins Coins) (acct Account, err error) {
|
||||
acct, err = loadAccount(store, addr.Bytes())
|
||||
// we can increase an empty account...
|
||||
if IsNoAccountErr(err) && coins.IsPositive() {
|
||||
|
@ -114,7 +114,7 @@ func storeAccount(store state.SimpleDB, key []byte, acct Account) error {
|
|||
|
||||
// HandlerInfo - this is global info on the coin handler
|
||||
type HandlerInfo struct {
|
||||
Issuer basecoin.Actor `json:"issuer"`
|
||||
Issuer sdk.Actor `json:"issuer"`
|
||||
}
|
||||
|
||||
// TODO: where to store these special pieces??
|
||||
|
@ -133,7 +133,7 @@ func loadHandlerInfo(store state.KVStore) (info HandlerInfo, err error) {
|
|||
return info, nil
|
||||
}
|
||||
|
||||
func storeIssuer(store state.KVStore, issuer basecoin.Actor) error {
|
||||
func storeIssuer(store state.KVStore, issuer sdk.Actor) error {
|
||||
info, err := loadHandlerInfo(store)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -3,11 +3,11 @@ package coin
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
)
|
||||
|
||||
func init() {
|
||||
basecoin.TxMapper.
|
||||
sdk.TxMapper.
|
||||
RegisterImplementation(SendTx{}, TypeSend, ByteSend).
|
||||
RegisterImplementation(CreditTx{}, TypeCredit, ByteCredit)
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ const (
|
|||
|
||||
// TxInput - expected coin movement outputs, used with SendTx
|
||||
type TxInput struct {
|
||||
Address basecoin.Actor `json:"address"`
|
||||
Address sdk.Actor `json:"address"`
|
||||
Coins Coins `json:"coins"`
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ func (txIn TxInput) String() string {
|
|||
}
|
||||
|
||||
// NewTxInput - create a transaction input, used with SendTx
|
||||
func NewTxInput(addr basecoin.Actor, coins Coins) TxInput {
|
||||
func NewTxInput(addr sdk.Actor, coins Coins) TxInput {
|
||||
input := TxInput{
|
||||
Address: addr,
|
||||
Coins: coins,
|
||||
|
@ -63,7 +63,7 @@ func NewTxInput(addr basecoin.Actor, coins Coins) TxInput {
|
|||
|
||||
// TxOutput - expected coin movement output, used with SendTx
|
||||
type TxOutput struct {
|
||||
Address basecoin.Actor `json:"address"`
|
||||
Address sdk.Actor `json:"address"`
|
||||
Coins Coins `json:"coins"`
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ func (txOut TxOutput) String() string {
|
|||
}
|
||||
|
||||
// NewTxOutput - create a transaction output, used with SendTx
|
||||
func NewTxOutput(addr basecoin.Actor, coins Coins) TxOutput {
|
||||
func NewTxOutput(addr sdk.Actor, coins Coins) TxOutput {
|
||||
output := TxOutput{
|
||||
Address: addr,
|
||||
Coins: coins,
|
||||
|
@ -107,16 +107,16 @@ type SendTx struct {
|
|||
Outputs []TxOutput `json:"outputs"`
|
||||
}
|
||||
|
||||
var _ basecoin.Tx = NewSendTx(nil, nil)
|
||||
var _ sdk.Tx = NewSendTx(nil, nil)
|
||||
|
||||
// NewSendTx - construct arbitrary multi-in, multi-out sendtx
|
||||
func NewSendTx(in []TxInput, out []TxOutput) basecoin.Tx {
|
||||
func NewSendTx(in []TxInput, out []TxOutput) sdk.Tx {
|
||||
return SendTx{Inputs: in, Outputs: out}.Wrap()
|
||||
}
|
||||
|
||||
// NewSendOneTx is a helper for the standard (?) case where there is exactly
|
||||
// one sender and one recipient
|
||||
func NewSendOneTx(sender, recipient basecoin.Actor, amount Coins) basecoin.Tx {
|
||||
func NewSendOneTx(sender, recipient sdk.Actor, amount Coins) sdk.Tx {
|
||||
in := []TxInput{{Address: sender, Coins: amount}}
|
||||
out := []TxOutput{{Address: recipient, Coins: amount}}
|
||||
return SendTx{Inputs: in, Outputs: out}.Wrap()
|
||||
|
@ -158,8 +158,8 @@ func (tx SendTx) String() string {
|
|||
}
|
||||
|
||||
// Wrap - used to satisfy TxInner
|
||||
func (tx SendTx) Wrap() basecoin.Tx {
|
||||
return basecoin.Tx{tx}
|
||||
func (tx SendTx) Wrap() sdk.Tx {
|
||||
return sdk.Tx{tx}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -167,7 +167,7 @@ func (tx SendTx) Wrap() basecoin.Tx {
|
|||
// CreditTx - this allows a special issuer to give an account credit
|
||||
// Satisfies: TxInner
|
||||
type CreditTx struct {
|
||||
Debitor basecoin.Actor `json:"debitor"`
|
||||
Debitor sdk.Actor `json:"debitor"`
|
||||
// Credit is the amount to change the credit...
|
||||
// This may be negative to remove some over-issued credit,
|
||||
// but can never bring the credit or the balance to negative
|
||||
|
@ -175,13 +175,13 @@ type CreditTx struct {
|
|||
}
|
||||
|
||||
// NewCreditTx - modify the credit granted to a given account
|
||||
func NewCreditTx(debitor basecoin.Actor, credit Coins) basecoin.Tx {
|
||||
func NewCreditTx(debitor sdk.Actor, credit Coins) sdk.Tx {
|
||||
return CreditTx{Debitor: debitor, Credit: credit}.Wrap()
|
||||
}
|
||||
|
||||
// Wrap - used to satisfy TxInner
|
||||
func (tx CreditTx) Wrap() basecoin.Tx {
|
||||
return basecoin.Tx{tx}
|
||||
func (tx CreditTx) Wrap() sdk.Tx {
|
||||
return sdk.Tx{tx}
|
||||
}
|
||||
|
||||
// ValidateBasic - used to satisfy TxInner
|
||||
|
|
|
@ -8,20 +8,20 @@ import (
|
|||
|
||||
"github.com/tendermint/go-wire/data"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
)
|
||||
|
||||
// these are some constructs for the test cases
|
||||
var actors = []struct {
|
||||
actor basecoin.Actor
|
||||
actor sdk.Actor
|
||||
valid bool
|
||||
}{
|
||||
{basecoin.Actor{}, false},
|
||||
{basecoin.Actor{App: "fooz"}, false},
|
||||
{basecoin.Actor{Address: []byte{1, 2, 3, 4}}, false},
|
||||
{basecoin.Actor{App: "fooz", Address: []byte{1, 2, 3, 4}}, true},
|
||||
{basecoin.Actor{ChainID: "dings", App: "fooz", Address: []byte{1, 2, 3, 4}}, true},
|
||||
{basecoin.Actor{ChainID: "dat", App: "fooz"}, false},
|
||||
{sdk.Actor{}, false},
|
||||
{sdk.Actor{App: "fooz"}, false},
|
||||
{sdk.Actor{Address: []byte{1, 2, 3, 4}}, false},
|
||||
{sdk.Actor{App: "fooz", Address: []byte{1, 2, 3, 4}}, true},
|
||||
{sdk.Actor{ChainID: "dings", App: "fooz", Address: []byte{1, 2, 3, 4}}, true},
|
||||
{sdk.Actor{ChainID: "dat", App: "fooz"}, false},
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -78,10 +78,10 @@ func TestTxValidateOutput(t *testing.T) {
|
|||
func TestTxValidateTx(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
addr1 := basecoin.Actor{App: "coin", Address: []byte{1, 2}}
|
||||
addr2 := basecoin.Actor{App: "coin", Address: []byte{3, 4}, ChainID: "over-there"}
|
||||
addr3 := basecoin.Actor{App: "role", Address: []byte{7, 8}}
|
||||
noAddr := basecoin.Actor{}
|
||||
addr1 := sdk.Actor{App: "coin", Address: []byte{1, 2}}
|
||||
addr2 := sdk.Actor{App: "coin", Address: []byte{3, 4}, ChainID: "over-there"}
|
||||
addr3 := sdk.Actor{App: "role", Address: []byte{7, 8}}
|
||||
noAddr := sdk.Actor{}
|
||||
|
||||
noCoins := Coins{}
|
||||
someCoins := Coins{{"atom", 123}}
|
||||
|
@ -95,7 +95,7 @@ func TestTxValidateTx(t *testing.T) {
|
|||
// totals don't match
|
||||
cases := []struct {
|
||||
valid bool
|
||||
tx basecoin.Tx
|
||||
tx sdk.Tx
|
||||
}{
|
||||
// 0-2. valid cases
|
||||
{true, NewSendTx(
|
||||
|
@ -164,8 +164,8 @@ func TestTxSerializeTx(t *testing.T) {
|
|||
assert := assert.New(t)
|
||||
require := require.New(t)
|
||||
|
||||
addr1 := basecoin.Actor{App: "coin", Address: []byte{1, 2}}
|
||||
addr2 := basecoin.Actor{App: "coin", Address: []byte{3, 4}}
|
||||
addr1 := sdk.Actor{App: "coin", Address: []byte{1, 2}}
|
||||
addr2 := sdk.Actor{App: "coin", Address: []byte{3, 4}}
|
||||
someCoins := Coins{{"atom", 123}}
|
||||
|
||||
send := NewSendTx(
|
||||
|
@ -175,14 +175,14 @@ func TestTxSerializeTx(t *testing.T) {
|
|||
|
||||
js, err := data.ToJSON(send)
|
||||
require.Nil(err)
|
||||
var tx basecoin.Tx
|
||||
var tx sdk.Tx
|
||||
err = data.FromJSON(js, &tx)
|
||||
require.Nil(err)
|
||||
assert.Equal(send, tx)
|
||||
|
||||
bin, err := data.ToWire(send)
|
||||
require.Nil(err)
|
||||
var tx2 basecoin.Tx
|
||||
var tx2 sdk.Tx
|
||||
err = data.FromWire(bin, &tx2)
|
||||
require.Nil(err)
|
||||
assert.Equal(send, tx2)
|
||||
|
|
|
@ -8,10 +8,10 @@ import (
|
|||
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/tendermint/basecoin/client/commands/query"
|
||||
"github.com/tendermint/basecoin/modules/eyes"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands/query"
|
||||
"github.com/cosmos/cosmos-sdk/modules/eyes"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
)
|
||||
|
||||
// EyesQueryCmd - command to query raw data
|
||||
|
|
|
@ -3,9 +3,9 @@ package commands
|
|||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/tendermint/basecoin/client/commands/txs"
|
||||
"github.com/tendermint/basecoin/modules/eyes"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands/txs"
|
||||
"github.com/cosmos/cosmos-sdk/modules/eyes"
|
||||
)
|
||||
|
||||
// SetTxCmd is CLI command to set data
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
abci "github.com/tendermint/abci/types"
|
||||
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/cosmos/cosmos-sdk/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package eyes
|
||||
|
||||
import (
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/errors"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
wire "github.com/tendermint/go-wire"
|
||||
)
|
||||
|
||||
|
@ -19,11 +19,11 @@ const (
|
|||
|
||||
// Handler allows us to set and remove data
|
||||
type Handler struct {
|
||||
basecoin.NopInitState
|
||||
basecoin.NopInitValidate
|
||||
sdk.NopInitState
|
||||
sdk.NopInitValidate
|
||||
}
|
||||
|
||||
var _ basecoin.Handler = Handler{}
|
||||
var _ sdk.Handler = Handler{}
|
||||
|
||||
// NewHandler makes a role handler to modify data
|
||||
func NewHandler() Handler {
|
||||
|
@ -36,7 +36,7 @@ func (Handler) Name() string {
|
|||
}
|
||||
|
||||
// CheckTx verifies if the transaction is properly formated
|
||||
func (h Handler) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (res basecoin.CheckResult, err error) {
|
||||
func (h Handler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error) {
|
||||
err = tx.ValidateBasic()
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -44,9 +44,9 @@ func (h Handler) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin
|
|||
|
||||
switch tx.Unwrap().(type) {
|
||||
case SetTx:
|
||||
res = basecoin.NewCheck(CostSet, "")
|
||||
res = sdk.NewCheck(CostSet, "")
|
||||
case RemoveTx:
|
||||
res = basecoin.NewCheck(CostRemove, "")
|
||||
res = sdk.NewCheck(CostRemove, "")
|
||||
default:
|
||||
err = errors.ErrUnknownTxType(tx)
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ func (h Handler) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin
|
|||
// DeliverTx tries to create a new role.
|
||||
//
|
||||
// Returns an error if the role already exists
|
||||
func (h Handler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (res basecoin.DeliverResult, err error) {
|
||||
func (h Handler) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.DeliverResult, err error) {
|
||||
err = tx.ValidateBasic()
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -75,7 +75,7 @@ func (h Handler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx baseco
|
|||
|
||||
// doSetTx writes to the store, overwriting any previous value
|
||||
// note that an empty response in DeliverTx is OK with no log or data returned
|
||||
func (h Handler) doSetTx(ctx basecoin.Context, store state.SimpleDB, tx SetTx) (res basecoin.DeliverResult, err error) {
|
||||
func (h Handler) doSetTx(ctx sdk.Context, store state.SimpleDB, tx SetTx) (res sdk.DeliverResult, err error) {
|
||||
data := NewData(tx.Value, ctx.BlockHeight())
|
||||
store.Set(tx.Key, wire.BinaryBytes(data))
|
||||
return
|
||||
|
@ -83,7 +83,7 @@ func (h Handler) doSetTx(ctx basecoin.Context, store state.SimpleDB, tx SetTx) (
|
|||
|
||||
// doRemoveTx deletes the value from the store and returns the last value
|
||||
// here we let res.Data to return the value over abci
|
||||
func (h Handler) doRemoveTx(ctx basecoin.Context, store state.SimpleDB, tx RemoveTx) (res basecoin.DeliverResult, err error) {
|
||||
func (h Handler) doRemoveTx(ctx sdk.Context, store state.SimpleDB, tx RemoveTx) (res sdk.DeliverResult, err error) {
|
||||
// we set res.Data so it gets returned to the client over the abci interface
|
||||
res.Data = store.Get(tx.Key)
|
||||
if len(res.Data) != 0 {
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
wire "github.com/tendermint/go-wire"
|
||||
)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package eyes
|
||||
|
||||
import (
|
||||
"github.com/tendermint/basecoin"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/tendermint/go-wire/data"
|
||||
)
|
||||
|
||||
|
@ -15,7 +15,7 @@ const (
|
|||
)
|
||||
|
||||
func init() {
|
||||
basecoin.TxMapper.
|
||||
sdk.TxMapper.
|
||||
RegisterImplementation(SetTx{}, TypeSet, ByteSet).
|
||||
RegisterImplementation(RemoveTx{}, TypeRemove, ByteRemove)
|
||||
}
|
||||
|
@ -26,13 +26,13 @@ type SetTx struct {
|
|||
Value data.Bytes `json:"value"`
|
||||
}
|
||||
|
||||
func NewSetTx(key, value []byte) basecoin.Tx {
|
||||
func NewSetTx(key, value []byte) sdk.Tx {
|
||||
return SetTx{Key: key, Value: value}.Wrap()
|
||||
}
|
||||
|
||||
// Wrap - fulfills TxInner interface
|
||||
func (t SetTx) Wrap() basecoin.Tx {
|
||||
return basecoin.Tx{t}
|
||||
func (t SetTx) Wrap() sdk.Tx {
|
||||
return sdk.Tx{t}
|
||||
}
|
||||
|
||||
// ValidateBasic makes sure it is valid
|
||||
|
@ -48,13 +48,13 @@ type RemoveTx struct {
|
|||
Key data.Bytes `json:"key"`
|
||||
}
|
||||
|
||||
func NewRemoveTx(key []byte) basecoin.Tx {
|
||||
func NewRemoveTx(key []byte) sdk.Tx {
|
||||
return RemoveTx{Key: key}.Wrap()
|
||||
}
|
||||
|
||||
// Wrap - fulfills TxInner interface
|
||||
func (t RemoveTx) Wrap() basecoin.Tx {
|
||||
return basecoin.Tx{t}
|
||||
func (t RemoveTx) Wrap() sdk.Tx {
|
||||
return sdk.Tx{t}
|
||||
}
|
||||
|
||||
// ValidateBasic makes sure it is valid
|
||||
|
|
|
@ -4,11 +4,11 @@ import (
|
|||
"github.com/spf13/pflag"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
txcmd "github.com/tendermint/basecoin/client/commands/txs"
|
||||
"github.com/tendermint/basecoin/modules/coin"
|
||||
"github.com/tendermint/basecoin/modules/fee"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
txcmd "github.com/cosmos/cosmos-sdk/client/commands/txs"
|
||||
"github.com/cosmos/cosmos-sdk/modules/coin"
|
||||
"github.com/cosmos/cosmos-sdk/modules/fee"
|
||||
)
|
||||
|
||||
//nolint
|
||||
|
@ -24,7 +24,7 @@ var _ txcmd.Wrapper = FeeWrapper{}
|
|||
|
||||
// Wrap checks for FlagFee and if present wraps the tx with a
|
||||
// FeeTx of the given amount, paid by the signer
|
||||
func (FeeWrapper) Wrap(tx basecoin.Tx) (res basecoin.Tx, err error) {
|
||||
func (FeeWrapper) Wrap(tx sdk.Tx) (res sdk.Tx, err error) {
|
||||
//parse the fee and amounts into coin types
|
||||
toll, err := coin.ParseCoin(viper.GetString(FlagFee))
|
||||
if err != nil {
|
||||
|
@ -50,7 +50,7 @@ func (FeeWrapper) Register(fs *pflag.FlagSet) {
|
|||
fs.String(FlagPayer, "", "Account to pay fee if not current signer (for multisig)")
|
||||
}
|
||||
|
||||
func readPayer() (basecoin.Actor, error) {
|
||||
func readPayer() (sdk.Actor, error) {
|
||||
payer := viper.GetString(FlagPayer)
|
||||
if payer == "" {
|
||||
return txcmd.GetSignerAct(), nil
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
abci "github.com/tendermint/abci/types"
|
||||
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/cosmos/cosmos-sdk/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package fee
|
||||
|
||||
import (
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/tendermint/basecoin/modules/coin"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/errors"
|
||||
"github.com/cosmos/cosmos-sdk/modules/coin"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
)
|
||||
|
||||
// NameFee - namespace for the fee module
|
||||
|
@ -13,7 +13,7 @@ const NameFee = "fee"
|
|||
|
||||
// Bank is a default location for the fees, but pass anything into
|
||||
// the middleware constructor
|
||||
var Bank = basecoin.Actor{App: NameFee, Address: []byte("bank")}
|
||||
var Bank = sdk.Actor{App: NameFee, Address: []byte("bank")}
|
||||
|
||||
// SimpleFeeMiddleware - middleware for fee checking, constant amount
|
||||
// It used modules.coin to move the money
|
||||
|
@ -23,7 +23,7 @@ type SimpleFeeMiddleware struct {
|
|||
MinFee coin.Coin
|
||||
// all fees go here, which could be a dump (Bank) or something reachable
|
||||
// by other app logic
|
||||
Collector basecoin.Actor
|
||||
Collector sdk.Actor
|
||||
stack.PassInitState
|
||||
stack.PassInitValidate
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ var _ stack.Middleware = SimpleFeeMiddleware{}
|
|||
// NewSimpleFeeMiddleware returns a fee handler with a fixed minimum fee.
|
||||
//
|
||||
// If minFee is 0, then the FeeTx is optional
|
||||
func NewSimpleFeeMiddleware(minFee coin.Coin, collector basecoin.Actor) SimpleFeeMiddleware {
|
||||
func NewSimpleFeeMiddleware(minFee coin.Coin, collector sdk.Actor) SimpleFeeMiddleware {
|
||||
return SimpleFeeMiddleware{
|
||||
MinFee: minFee,
|
||||
Collector: collector,
|
||||
|
@ -46,7 +46,7 @@ func (SimpleFeeMiddleware) Name() string {
|
|||
}
|
||||
|
||||
// CheckTx - check the transaction
|
||||
func (h SimpleFeeMiddleware) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Checker) (res basecoin.CheckResult, err error) {
|
||||
func (h SimpleFeeMiddleware) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error) {
|
||||
fee, err := h.verifyFee(ctx, tx)
|
||||
if err != nil {
|
||||
if IsSkipFeesErr(err) {
|
||||
|
@ -76,7 +76,7 @@ func (h SimpleFeeMiddleware) CheckTx(ctx basecoin.Context, store state.SimpleDB,
|
|||
}
|
||||
|
||||
// DeliverTx - send the fee handler transaction
|
||||
func (h SimpleFeeMiddleware) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.DeliverResult, err error) {
|
||||
func (h SimpleFeeMiddleware) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error) {
|
||||
fee, err := h.verifyFee(ctx, tx)
|
||||
if IsSkipFeesErr(err) {
|
||||
return next.DeliverTx(ctx, store, tx)
|
||||
|
@ -95,7 +95,7 @@ func (h SimpleFeeMiddleware) DeliverTx(ctx basecoin.Context, store state.SimpleD
|
|||
return next.DeliverTx(ctx, store, fee.Tx)
|
||||
}
|
||||
|
||||
func (h SimpleFeeMiddleware) verifyFee(ctx basecoin.Context, tx basecoin.Tx) (Fee, error) {
|
||||
func (h SimpleFeeMiddleware) verifyFee(ctx sdk.Context, tx sdk.Tx) (Fee, error) {
|
||||
feeTx, ok := tx.Unwrap().(Fee)
|
||||
if !ok {
|
||||
// the fee wrapper is not required if there is no minimum
|
||||
|
|
|
@ -8,11 +8,11 @@ import (
|
|||
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/modules/coin"
|
||||
"github.com/tendermint/basecoin/modules/fee"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/modules/coin"
|
||||
"github.com/cosmos/cosmos-sdk/modules/fee"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
)
|
||||
|
||||
func TestFeeChecks(t *testing.T) {
|
||||
|
@ -30,7 +30,7 @@ func TestFeeChecks(t *testing.T) {
|
|||
pure := atoms(46657)
|
||||
|
||||
// these are some accounts
|
||||
collector := basecoin.Actor{App: fee.NameFee, Address: []byte("mine")}
|
||||
collector := sdk.Actor{App: fee.NameFee, Address: []byte("mine")}
|
||||
key1 := coin.NewAccountWithKey(mixed)
|
||||
key2 := coin.NewAccountWithKey(pure)
|
||||
act1, act2 := key1.Actor(), key2.Actor()
|
||||
|
@ -60,12 +60,12 @@ func TestFeeChecks(t *testing.T) {
|
|||
cases := []struct {
|
||||
valid bool
|
||||
// this is the middleware stack to test
|
||||
app basecoin.Handler
|
||||
app sdk.Handler
|
||||
// they sign the tx
|
||||
signer basecoin.Actor
|
||||
signer sdk.Actor
|
||||
// wrap with the given fee if hasFee is true
|
||||
hasFee bool
|
||||
payer basecoin.Actor
|
||||
payer sdk.Actor
|
||||
fee coin.Coin
|
||||
// expected balance after the tx
|
||||
left coin.Coins
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package fee
|
||||
|
||||
import (
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/modules/coin"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/modules/coin"
|
||||
)
|
||||
|
||||
// nolint
|
||||
|
@ -12,7 +12,7 @@ const (
|
|||
)
|
||||
|
||||
func init() {
|
||||
basecoin.TxMapper.
|
||||
sdk.TxMapper.
|
||||
RegisterImplementation(Fee{}, TypeFees, ByteFees)
|
||||
}
|
||||
|
||||
|
@ -22,12 +22,12 @@ func init() {
|
|||
type Fee struct {
|
||||
// Gas coin.Coin `json:"gas"` // ?????
|
||||
Fee coin.Coin `json:"fee"`
|
||||
Payer basecoin.Actor `json:"payer"` // the address who pays the fee
|
||||
Tx basecoin.Tx `json:"tx"`
|
||||
Payer sdk.Actor `json:"payer"` // the address who pays the fee
|
||||
Tx sdk.Tx `json:"tx"`
|
||||
}
|
||||
|
||||
// NewFee wraps a tx with a promised fee from this actor
|
||||
func NewFee(tx basecoin.Tx, fee coin.Coin, payer basecoin.Actor) basecoin.Tx {
|
||||
func NewFee(tx sdk.Tx, fee coin.Coin, payer sdk.Actor) sdk.Tx {
|
||||
return Fee{Tx: tx, Fee: fee, Payer: payer}.Wrap()
|
||||
}
|
||||
|
||||
|
@ -36,9 +36,9 @@ func (f Fee) ValidateBasic() error {
|
|||
// TODO: more checks
|
||||
return f.Tx.ValidateBasic()
|
||||
}
|
||||
func (f Fee) Wrap() basecoin.Tx {
|
||||
return basecoin.Tx{f}
|
||||
func (f Fee) Wrap() sdk.Tx {
|
||||
return sdk.Tx{f}
|
||||
}
|
||||
func (f Fee) Next() basecoin.Tx {
|
||||
func (f Fee) Next() sdk.Tx {
|
||||
return f.Tx
|
||||
}
|
||||
|
|
|
@ -7,10 +7,10 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
"github.com/tendermint/basecoin/client/commands/query"
|
||||
"github.com/tendermint/basecoin/modules/ibc"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands/query"
|
||||
"github.com/cosmos/cosmos-sdk/modules/ibc"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
wire "github.com/tendermint/go-wire"
|
||||
"github.com/tendermint/go-wire/data"
|
||||
)
|
||||
|
|
|
@ -8,9 +8,9 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
txcmd "github.com/tendermint/basecoin/client/commands/txs"
|
||||
"github.com/tendermint/basecoin/modules/ibc"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
txcmd "github.com/cosmos/cosmos-sdk/client/commands/txs"
|
||||
"github.com/cosmos/cosmos-sdk/modules/ibc"
|
||||
"github.com/tendermint/light-client/certifiers"
|
||||
)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
abci "github.com/tendermint/abci/types"
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/cosmos/cosmos-sdk/errors"
|
||||
)
|
||||
|
||||
// nolint
|
||||
|
|
|
@ -6,10 +6,10 @@ import (
|
|||
"github.com/tendermint/go-wire/data"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/errors"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -29,16 +29,16 @@ var (
|
|||
|
||||
// AllowIBC returns a specially crafted Actor that
|
||||
// enables sending IBC packets for this app type
|
||||
func AllowIBC(app string) basecoin.Actor {
|
||||
return basecoin.Actor{App: app, Address: allowIBC}
|
||||
func AllowIBC(app string) sdk.Actor {
|
||||
return sdk.Actor{App: app, Address: allowIBC}
|
||||
}
|
||||
|
||||
// Handler updates the chain state or creates an ibc packet
|
||||
type Handler struct {
|
||||
basecoin.NopInitValidate
|
||||
sdk.NopInitValidate
|
||||
}
|
||||
|
||||
var _ basecoin.Handler = Handler{}
|
||||
var _ sdk.Handler = Handler{}
|
||||
|
||||
// NewHandler returns a Handler that allows all chains to connect via IBC.
|
||||
// Set a Registrar via InitState to restrict it.
|
||||
|
@ -57,7 +57,7 @@ func (h Handler) InitState(l log.Logger, store state.SimpleDB, module, key, valu
|
|||
return "", errors.ErrUnknownModule(module)
|
||||
}
|
||||
if key == OptionRegistrar {
|
||||
var act basecoin.Actor
|
||||
var act sdk.Actor
|
||||
err = data.FromJSON([]byte(value), &act)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
@ -72,7 +72,7 @@ func (h Handler) InitState(l log.Logger, store state.SimpleDB, module, key, valu
|
|||
|
||||
// CheckTx verifies the packet is formated correctly, and has the proper sequence
|
||||
// for a registered chain
|
||||
func (h Handler) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (res basecoin.CheckResult, err error) {
|
||||
func (h Handler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error) {
|
||||
err = tx.ValidateBasic()
|
||||
if err != nil {
|
||||
return res, err
|
||||
|
@ -92,7 +92,7 @@ func (h Handler) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin
|
|||
|
||||
// DeliverTx verifies all signatures on the tx and updates the chain state
|
||||
// apropriately
|
||||
func (h Handler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (res basecoin.DeliverResult, err error) {
|
||||
func (h Handler) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.DeliverResult, err error) {
|
||||
err = tx.ValidateBasic()
|
||||
if err != nil {
|
||||
return res, err
|
||||
|
@ -113,8 +113,8 @@ func (h Handler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx baseco
|
|||
// accepts it as the root of trust.
|
||||
//
|
||||
// only the registrar, if set, is allowed to do this
|
||||
func (h Handler) initSeed(ctx basecoin.Context, store state.SimpleDB,
|
||||
t RegisterChainTx) (res basecoin.DeliverResult, err error) {
|
||||
func (h Handler) initSeed(ctx sdk.Context, store state.SimpleDB,
|
||||
t RegisterChainTx) (res sdk.DeliverResult, err error) {
|
||||
|
||||
info := LoadInfo(store)
|
||||
if !info.Registrar.Empty() && !ctx.HasPermission(info.Registrar) {
|
||||
|
@ -137,8 +137,8 @@ func (h Handler) initSeed(ctx basecoin.Context, store state.SimpleDB,
|
|||
|
||||
// updateSeed checks the seed against the existing chain data and rejects it if it
|
||||
// doesn't fit (or no chain data)
|
||||
func (h Handler) updateSeed(ctx basecoin.Context, store state.SimpleDB,
|
||||
t UpdateChainTx) (res basecoin.DeliverResult, err error) {
|
||||
func (h Handler) updateSeed(ctx sdk.Context, store state.SimpleDB,
|
||||
t UpdateChainTx) (res sdk.DeliverResult, err error) {
|
||||
|
||||
chainID := t.ChainID()
|
||||
s := NewChainSet(store)
|
||||
|
@ -167,8 +167,8 @@ func (h Handler) updateSeed(ctx basecoin.Context, store state.SimpleDB,
|
|||
|
||||
// createPacket makes sure all permissions are good and the destination
|
||||
// chain is registed. If so, it appends it to the outgoing queue
|
||||
func (h Handler) createPacket(ctx basecoin.Context, store state.SimpleDB,
|
||||
t CreatePacketTx) (res basecoin.DeliverResult, err error) {
|
||||
func (h Handler) createPacket(ctx sdk.Context, store state.SimpleDB,
|
||||
t CreatePacketTx) (res sdk.DeliverResult, err error) {
|
||||
|
||||
// make sure the chain is registed
|
||||
dest := t.DestChain
|
||||
|
@ -189,7 +189,7 @@ func (h Handler) createPacket(ctx basecoin.Context, store state.SimpleDB,
|
|||
packet := Packet{
|
||||
DestChain: dest,
|
||||
Tx: t.Tx,
|
||||
Permissions: make([]basecoin.Actor, len(t.Permissions)),
|
||||
Permissions: make([]sdk.Actor, len(t.Permissions)),
|
||||
}
|
||||
|
||||
// make sure we have all the permissions we want to send
|
||||
|
@ -206,6 +206,6 @@ func (h Handler) createPacket(ctx basecoin.Context, store state.SimpleDB,
|
|||
packet.Sequence = q.Tail()
|
||||
q.Push(packet.Bytes())
|
||||
|
||||
res = basecoin.DeliverResult{Log: fmt.Sprintf("Packet %s %d", dest, packet.Sequence)}
|
||||
res = sdk.DeliverResult{Log: fmt.Sprintf("Packet %s %d", dest, packet.Sequence)}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@ import (
|
|||
"github.com/tendermint/light-client/certifiers"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/errors"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
)
|
||||
|
||||
// this tests registration without registrar permissions
|
||||
|
@ -73,14 +73,14 @@ func TestIBCRegisterPermissions(t *testing.T) {
|
|||
keys := certifiers.GenValKeys(4)
|
||||
appHash := []byte{0x17, 0x21, 0x5, 0x1e}
|
||||
|
||||
foobar := basecoin.Actor{App: "foo", Address: []byte("bar")}
|
||||
baz := basecoin.Actor{App: "baz", Address: []byte("bar")}
|
||||
foobaz := basecoin.Actor{App: "foo", Address: []byte("baz")}
|
||||
foobar := sdk.Actor{App: "foo", Address: []byte("bar")}
|
||||
baz := sdk.Actor{App: "baz", Address: []byte("bar")}
|
||||
foobaz := sdk.Actor{App: "foo", Address: []byte("baz")}
|
||||
|
||||
cases := []struct {
|
||||
seed certifiers.Seed
|
||||
registrar basecoin.Actor
|
||||
signer basecoin.Actor
|
||||
registrar sdk.Actor
|
||||
signer sdk.Actor
|
||||
checker errors.CheckErr
|
||||
}{
|
||||
// no sig, no registrar
|
||||
|
@ -240,18 +240,18 @@ func TestIBCCreatePacket(t *testing.T) {
|
|||
// this is the tx we send, and the needed permission to send it
|
||||
raw := stack.NewRawTx([]byte{0xbe, 0xef})
|
||||
ibcPerm := AllowIBC(stack.NameOK)
|
||||
somePerm := basecoin.Actor{App: "some", Address: []byte("perm")}
|
||||
somePerm := sdk.Actor{App: "some", Address: []byte("perm")}
|
||||
|
||||
cases := []struct {
|
||||
dest string
|
||||
ibcPerms basecoin.Actors
|
||||
ctxPerms basecoin.Actors
|
||||
ibcPerms sdk.Actors
|
||||
ctxPerms sdk.Actors
|
||||
checker errors.CheckErr
|
||||
}{
|
||||
// wrong chain -> error
|
||||
{
|
||||
dest: "some-other-chain",
|
||||
ctxPerms: basecoin.Actors{ibcPerm},
|
||||
ctxPerms: sdk.Actors{ibcPerm},
|
||||
checker: IsNotRegisteredErr,
|
||||
},
|
||||
|
||||
|
@ -264,23 +264,23 @@ func TestIBCCreatePacket(t *testing.T) {
|
|||
// correct -> nice sequence
|
||||
{
|
||||
dest: chainID,
|
||||
ctxPerms: basecoin.Actors{ibcPerm},
|
||||
ctxPerms: sdk.Actors{ibcPerm},
|
||||
checker: errors.NoErr,
|
||||
},
|
||||
|
||||
// requesting invalid permissions -> error
|
||||
{
|
||||
dest: chainID,
|
||||
ibcPerms: basecoin.Actors{somePerm},
|
||||
ctxPerms: basecoin.Actors{ibcPerm},
|
||||
ibcPerms: sdk.Actors{somePerm},
|
||||
ctxPerms: sdk.Actors{ibcPerm},
|
||||
checker: IsCannotSetPermissionErr,
|
||||
},
|
||||
|
||||
// requesting extra permissions when present
|
||||
{
|
||||
dest: chainID,
|
||||
ibcPerms: basecoin.Actors{somePerm},
|
||||
ctxPerms: basecoin.Actors{ibcPerm, somePerm},
|
||||
ibcPerms: sdk.Actors{somePerm},
|
||||
ctxPerms: sdk.Actors{ibcPerm, somePerm},
|
||||
checker: errors.NoErr,
|
||||
},
|
||||
}
|
||||
|
@ -303,10 +303,10 @@ func TestIBCCreatePacket(t *testing.T) {
|
|||
if assert.Equal(2, q.Size()) {
|
||||
expected := []struct {
|
||||
seq uint64
|
||||
perm basecoin.Actors
|
||||
perm sdk.Actors
|
||||
}{
|
||||
{0, nil},
|
||||
{1, basecoin.Actors{somePerm}},
|
||||
{1, sdk.Actors{somePerm}},
|
||||
}
|
||||
|
||||
for _, tc := range expected {
|
||||
|
@ -359,7 +359,7 @@ func TestIBCPostPacket(t *testing.T) {
|
|||
packet0badHeight := packet0
|
||||
packet0badHeight.FromChainHeight -= 2
|
||||
|
||||
theirActor := basecoin.Actor{ChainID: otherID, App: "foo", Address: []byte{1}}
|
||||
theirActor := sdk.Actor{ChainID: otherID, App: "foo", Address: []byte{1}}
|
||||
p1 := NewPacket(rawTx, ourID, 1, theirActor)
|
||||
packet1, update1 := otherChain.MakePostPacket(p1, start+25)
|
||||
require.Nil(ourChain.Update(update1))
|
||||
|
@ -367,15 +367,15 @@ func TestIBCPostPacket(t *testing.T) {
|
|||
packet1badProof := packet1
|
||||
packet1badProof.Key = []byte("random-data")
|
||||
|
||||
ourActor := basecoin.Actor{ChainID: ourID, App: "bar", Address: []byte{2}}
|
||||
ourActor := sdk.Actor{ChainID: ourID, App: "bar", Address: []byte{2}}
|
||||
p2 := NewPacket(rawTx, ourID, 2, ourActor)
|
||||
packet2, update2 := otherChain.MakePostPacket(p2, start+50)
|
||||
require.Nil(ourChain.Update(update2))
|
||||
|
||||
ibcPerm := basecoin.Actors{AllowIBC(stack.NameOK)}
|
||||
ibcPerm := sdk.Actors{AllowIBC(stack.NameOK)}
|
||||
cases := []struct {
|
||||
packet PostPacketTx
|
||||
permissions basecoin.Actors
|
||||
permissions sdk.Actors
|
||||
checker errors.CheckErr
|
||||
}{
|
||||
// bad chain -> error
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package ibc
|
||||
|
||||
import (
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package ibc
|
||||
|
||||
import (
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
)
|
||||
|
||||
// Middleware allows us to verify the IBC proof on a packet and
|
||||
|
@ -27,7 +27,7 @@ func (Middleware) Name() string {
|
|||
|
||||
// CheckTx verifies the named chain and height is present, and verifies
|
||||
// the merkle proof in the packet
|
||||
func (m Middleware) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Checker) (res basecoin.CheckResult, err error) {
|
||||
func (m Middleware) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error) {
|
||||
// if it is not a PostPacket, just let it go through
|
||||
post, ok := tx.Unwrap().(PostPacketTx)
|
||||
if !ok {
|
||||
|
@ -44,7 +44,7 @@ func (m Middleware) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basec
|
|||
|
||||
// DeliverTx verifies the named chain and height is present, and verifies
|
||||
// the merkle proof in the packet
|
||||
func (m Middleware) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.DeliverResult, err error) {
|
||||
func (m Middleware) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error) {
|
||||
// if it is not a PostPacket, just let it go through
|
||||
post, ok := tx.Unwrap().(PostPacketTx)
|
||||
if !ok {
|
||||
|
@ -61,8 +61,8 @@ func (m Middleware) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx bas
|
|||
|
||||
// verifyPost accepts a message bound for this chain...
|
||||
// TODO: think about relay
|
||||
func (m Middleware) verifyPost(ctx basecoin.Context, store state.SimpleDB,
|
||||
tx PostPacketTx) (ictx basecoin.Context, itx basecoin.Tx, err error) {
|
||||
func (m Middleware) verifyPost(ctx sdk.Context, store state.SimpleDB,
|
||||
tx PostPacketTx) (ictx sdk.Context, itx sdk.Tx, err error) {
|
||||
|
||||
// make sure the chain is registered
|
||||
from := tx.FromChainID
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
wire "github.com/tendermint/go-wire"
|
||||
"github.com/tendermint/light-client/certifiers"
|
||||
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/tendermint/basecoin/state"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
"github.com/tendermint/light-client/certifiers"
|
||||
)
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package ibc
|
||||
|
||||
import (
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
wire "github.com/tendermint/go-wire"
|
||||
)
|
||||
|
||||
// HandlerInfo is the global state of the ibc.Handler
|
||||
type HandlerInfo struct {
|
||||
Registrar basecoin.Actor `json:"registrar"`
|
||||
Registrar sdk.Actor `json:"registrar"`
|
||||
}
|
||||
|
||||
// Save the HandlerInfo to the store
|
||||
|
@ -88,12 +88,12 @@ func (c ChainSet) Update(chainID string, theirHeight int) error {
|
|||
type Packet struct {
|
||||
DestChain string `json:"dest_chain"`
|
||||
Sequence uint64 `json:"sequence"`
|
||||
Permissions basecoin.Actors `json:"permissions"`
|
||||
Tx basecoin.Tx `json:"tx"`
|
||||
Permissions sdk.Actors `json:"permissions"`
|
||||
Tx sdk.Tx `json:"tx"`
|
||||
}
|
||||
|
||||
// NewPacket creates a new outgoing packet
|
||||
func NewPacket(tx basecoin.Tx, dest string, seq uint64, perm ...basecoin.Actor) Packet {
|
||||
func NewPacket(tx sdk.Tx, dest string, seq uint64, perm ...sdk.Actor) Packet {
|
||||
return Packet{
|
||||
DestChain: dest,
|
||||
Sequence: seq,
|
||||
|
|
|
@ -7,9 +7,9 @@ import (
|
|||
"github.com/tendermint/merkleeyes/iavl"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/stack"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
"github.com/cosmos/cosmos-sdk/state"
|
||||
)
|
||||
|
||||
// MockChain is used to simulate a chain for ibc tests.
|
||||
|
@ -79,13 +79,13 @@ func makePostPacket(tree *iavl.IAVLTree, packet Packet, fromID string, fromHeigh
|
|||
// AppChain is ready to handle tx
|
||||
type AppChain struct {
|
||||
chainID string
|
||||
app basecoin.Handler
|
||||
app sdk.Handler
|
||||
store state.SimpleDB
|
||||
height int
|
||||
}
|
||||
|
||||
// NewAppChain returns a chain that is ready to respond to tx
|
||||
func NewAppChain(app basecoin.Handler, chainID string) *AppChain {
|
||||
func NewAppChain(app sdk.Handler, chainID string) *AppChain {
|
||||
return &AppChain{
|
||||
chainID: chainID,
|
||||
app: app,
|
||||
|
@ -103,7 +103,7 @@ func (a *AppChain) IncrementHeight(delta int) int {
|
|||
|
||||
// DeliverTx runs the tx and commits the new tree, incrementing height
|
||||
// by one.
|
||||
func (a *AppChain) DeliverTx(tx basecoin.Tx, perms ...basecoin.Actor) (basecoin.DeliverResult, error) {
|
||||
func (a *AppChain) DeliverTx(tx sdk.Tx, perms ...sdk.Actor) (sdk.DeliverResult, error) {
|
||||
ctx := stack.MockContext(a.chainID, uint64(a.height)).WithPermissions(perms...)
|
||||
store := a.store.Checkpoint()
|
||||
res, err := a.app.DeliverTx(ctx, store, tx)
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"github.com/tendermint/light-client/certifiers"
|
||||
"github.com/tendermint/merkleeyes/iavl"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
)
|
||||
|
||||
// nolint
|
||||
|
@ -23,7 +23,7 @@ const (
|
|||
)
|
||||
|
||||
func init() {
|
||||
basecoin.TxMapper.
|
||||
sdk.TxMapper.
|
||||
RegisterImplementation(RegisterChainTx{}, TypeRegisterChain, ByteRegisterChain).
|
||||
RegisterImplementation(UpdateChainTx{}, TypeUpdateChain, ByteUpdateChain).
|
||||
RegisterImplementation(CreatePacketTx{}, TypeCreatePacket, ByteCreatePacket).
|
||||
|
@ -50,8 +50,8 @@ func (r RegisterChainTx) ValidateBasic() error {
|
|||
}
|
||||
|
||||
// Wrap - used to satisfy TxInner
|
||||
func (r RegisterChainTx) Wrap() basecoin.Tx {
|
||||
return basecoin.Tx{r}
|
||||
func (r RegisterChainTx) Wrap() sdk.Tx {
|
||||
return sdk.Tx{r}
|
||||
}
|
||||
|
||||
// UpdateChainTx updates the state of this chain
|
||||
|
@ -74,8 +74,8 @@ func (u UpdateChainTx) ValidateBasic() error {
|
|||
}
|
||||
|
||||
// Wrap - used to satisfy TxInner
|
||||
func (u UpdateChainTx) Wrap() basecoin.Tx {
|
||||
return basecoin.Tx{u}
|
||||
func (u UpdateChainTx) Wrap() sdk.Tx {
|
||||
return sdk.Tx{u}
|
||||
}
|
||||
|
||||
// CreatePacketTx is meant to be called by IPC, another module...
|
||||
|
@ -87,8 +87,8 @@ func (u UpdateChainTx) Wrap() basecoin.Tx {
|
|||
// that can send this packet (so only coins can request SendTx packet)
|
||||
type CreatePacketTx struct {
|
||||
DestChain string `json:"dest_chain"`
|
||||
Permissions basecoin.Actors `json:"permissions"`
|
||||
Tx basecoin.Tx `json:"tx"`
|
||||
Permissions sdk.Actors `json:"permissions"`
|
||||
Tx sdk.Tx `json:"tx"`
|
||||
}
|
||||
|
||||
// ValidateBasic makes sure this is consistent - used to satisfy TxInner
|
||||
|
@ -100,8 +100,8 @@ func (p CreatePacketTx) ValidateBasic() error {
|
|||
}
|
||||
|
||||
// Wrap - used to satisfy TxInner
|
||||
func (p CreatePacketTx) Wrap() basecoin.Tx {
|
||||
return basecoin.Tx{p}
|
||||
func (p CreatePacketTx) Wrap() sdk.Tx {
|
||||
return sdk.Tx{p}
|
||||
}
|
||||
|
||||
// PostPacketTx takes a wrapped packet from another chain and
|
||||
|
@ -127,6 +127,6 @@ func (p PostPacketTx) ValidateBasic() error {
|
|||
}
|
||||
|
||||
// Wrap - used to satisfy TxInner
|
||||
func (p PostPacketTx) Wrap() basecoin.Tx {
|
||||
return basecoin.Tx{p}
|
||||
func (p PostPacketTx) Wrap() sdk.Tx {
|
||||
return sdk.Tx{p}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue