diff --git a/docs/Makefile b/_attic/docs/Makefile similarity index 100% rename from docs/Makefile rename to _attic/docs/Makefile diff --git a/docs/architecture/API.md b/_attic/docs/architecture/API.md similarity index 100% rename from docs/architecture/API.md rename to _attic/docs/architecture/API.md diff --git a/docs/basecoin-basics.rst b/_attic/docs/basecoin-basics.rst similarity index 100% rename from docs/basecoin-basics.rst rename to _attic/docs/basecoin-basics.rst diff --git a/docs/basecoin-kubernetes.rst b/_attic/docs/basecoin-kubernetes.rst similarity index 100% rename from docs/basecoin-kubernetes.rst rename to _attic/docs/basecoin-kubernetes.rst diff --git a/docs/basecoin-plugins.rst b/_attic/docs/basecoin-plugins.rst similarity index 100% rename from docs/basecoin-plugins.rst rename to _attic/docs/basecoin-plugins.rst diff --git a/docs/basecoin-tool.rst b/_attic/docs/basecoin-tool.rst similarity index 100% rename from docs/basecoin-tool.rst rename to _attic/docs/basecoin-tool.rst diff --git a/docs/conf.py b/_attic/docs/conf.py similarity index 100% rename from docs/conf.py rename to _attic/docs/conf.py diff --git a/docs/glossary.rst b/_attic/docs/glossary.rst similarity index 100% rename from docs/glossary.rst rename to _attic/docs/glossary.rst diff --git a/docs/graphics/README.md b/_attic/docs/graphics/README.md similarity index 100% rename from docs/graphics/README.md rename to _attic/docs/graphics/README.md diff --git a/docs/graphics/cosmos-sdk-image.png b/_attic/docs/graphics/cosmos-sdk-image.png similarity index 100% rename from docs/graphics/cosmos-sdk-image.png rename to _attic/docs/graphics/cosmos-sdk-image.png diff --git a/docs/graphics/datastore.png b/_attic/docs/graphics/datastore.png similarity index 100% rename from docs/graphics/datastore.png rename to _attic/docs/graphics/datastore.png diff --git a/docs/graphics/dispatcher.png b/_attic/docs/graphics/dispatcher.png similarity index 100% rename from docs/graphics/dispatcher.png rename to _attic/docs/graphics/dispatcher.png diff --git a/docs/graphics/infographic.xml b/_attic/docs/graphics/infographic.xml similarity index 100% rename from docs/graphics/infographic.xml rename to _attic/docs/graphics/infographic.xml diff --git a/docs/graphics/middleware.png b/_attic/docs/graphics/middleware.png similarity index 100% rename from docs/graphics/middleware.png rename to _attic/docs/graphics/middleware.png diff --git a/docs/graphics/overview-framework.png b/_attic/docs/graphics/overview-framework.png similarity index 100% rename from docs/graphics/overview-framework.png rename to _attic/docs/graphics/overview-framework.png diff --git a/docs/graphics/overview-security.png b/_attic/docs/graphics/overview-security.png similarity index 100% rename from docs/graphics/overview-security.png rename to _attic/docs/graphics/overview-security.png diff --git a/docs/graphics/permission.png b/_attic/docs/graphics/permission.png similarity index 100% rename from docs/graphics/permission.png rename to _attic/docs/graphics/permission.png diff --git a/docs/graphics/tx.png b/_attic/docs/graphics/tx.png similarity index 100% rename from docs/graphics/tx.png rename to _attic/docs/graphics/tx.png diff --git a/docs/guide/shunit2 b/_attic/docs/guide/shunit2 similarity index 100% rename from docs/guide/shunit2 rename to _attic/docs/guide/shunit2 diff --git a/docs/ibc.rst b/_attic/docs/ibc.rst similarity index 100% rename from docs/ibc.rst rename to _attic/docs/ibc.rst diff --git a/docs/index.rst b/_attic/docs/index.rst similarity index 100% rename from docs/index.rst rename to _attic/docs/index.rst diff --git a/docs/install.rst b/_attic/docs/install.rst similarity index 100% rename from docs/install.rst rename to _attic/docs/install.rst diff --git a/docs/key-management.rst b/_attic/docs/key-management.rst similarity index 100% rename from docs/key-management.rst rename to _attic/docs/key-management.rst diff --git a/docs/make.bat b/_attic/docs/make.bat similarity index 100% rename from docs/make.bat rename to _attic/docs/make.bat diff --git a/docs/overview.rst b/_attic/docs/overview.rst similarity index 100% rename from docs/overview.rst rename to _attic/docs/overview.rst diff --git a/docs/roles-and-multi-sig.rst b/_attic/docs/roles-and-multi-sig.rst similarity index 100% rename from docs/roles-and-multi-sig.rst rename to _attic/docs/roles-and-multi-sig.rst diff --git a/docs/stdlib.rst b/_attic/docs/stdlib.rst similarity index 100% rename from docs/stdlib.rst rename to _attic/docs/stdlib.rst diff --git a/context.go b/context.go deleted file mode 100644 index 75677f0857..0000000000 --- a/context.go +++ /dev/null @@ -1,109 +0,0 @@ -package sdk - -import ( - "bytes" - "fmt" - "sort" - - wire "github.com/tendermint/go-wire" - "github.com/tendermint/go-wire/data" - "github.com/tendermint/tmlibs/log" -) - -// Actor abstracts any address that can authorize actions, hold funds, -// or initiate any sort of transaction. -// -// It doesn't just have to be a pubkey on this chain, it could stem from -// another app (like multi-sig account), or even another chain (via IBC) -type Actor struct { - ChainID string `json:"chain"` // this is empty unless it comes from a different chain - App string `json:"app"` // the app that the actor belongs to - Address data.Bytes `json:"addr"` // arbitrary app-specific unique id -} - -// NewActor - create a new actor -func NewActor(app string, addr []byte) Actor { - return Actor{App: app, Address: addr} -} - -// Bytes makes a binary coding, useful for turning this into a key in the store -func (a Actor) Bytes() []byte { - return wire.BinaryBytes(a) -} - -// Equals checks if two actors are the same -func (a Actor) Equals(b Actor) bool { - return a.ChainID == b.ChainID && - a.App == b.App && - bytes.Equal(a.Address, b.Address) -} - -// Empty checks if the actor is not initialized -func (a Actor) Empty() bool { - return a.ChainID == "" && a.App == "" && len(a.Address) == 0 -} - -// WithChain creates a copy of the actor with a different chainID -func (a Actor) WithChain(chainID string) (b Actor) { - b = a - b.ChainID = chainID - return -} - -type Actors []Actor - -func (a Actors) AllHaveChain(chainID string) bool { - for _, b := range a { - if b.ChainID != chainID { - return false - } - } - return true -} - -// Context is an interface, so we can implement "secure" variants that -// rely on private fields to control the actions -type Context interface { - // context.Context - log.Logger - WithPermissions(perms ...Actor) Context - HasPermission(perm Actor) bool - GetPermissions(chain, app string) []Actor - IsParent(ctx Context) bool - Reset() Context - ChainID() string - BlockHeight() uint64 -} - -//////////////////////////////// Sort Interface -// USAGE sort.Sort(ByAll()) - -func (a Actor) String() string { - return fmt.Sprintf("%x", a.Address) -} - -// ByAll implements sort.Interface for []Actor. -// It sorts be the ChainID, followed by the App, followed by the Address -type ByAll []Actor - -// Verify the sort interface at compile time -var _ sort.Interface = ByAll{} - -func (a ByAll) Len() int { return len(a) } -func (a ByAll) Swap(i, j int) { a[i], a[j] = a[j], a[i] } -func (a ByAll) Less(i, j int) bool { - - if a[i].ChainID < a[j].ChainID { - return true - } - if a[i].ChainID > a[j].ChainID { - return false - } - if a[i].App < a[j].App { - return true - } - if a[i].App > a[j].App { - return false - } - return bytes.Compare(a[i].Address, a[j].Address) == -1 -} diff --git a/x/auth/bench_test.go b/x/auth/bench_test.go deleted file mode 100644 index 66a5511d57..0000000000 --- a/x/auth/bench_test.go +++ /dev/null @@ -1,77 +0,0 @@ -package auth - -import ( - "fmt" - "testing" - - crypto "github.com/tendermint/go-crypto" - cmn "github.com/tendermint/tmlibs/common" - - sdk "github.com/cosmos/cosmos-sdk" - "github.com/cosmos/cosmos-sdk/state" - "github.com/cosmos/cosmos-sdk/util" -) - -func makeSignTx() interface{} { - key := crypto.GenPrivKeyEd25519().Wrap() - payload := cmn.RandBytes(32) - tx := newSingle(payload) - Sign(tx, key) - return tx -} - -func makeMultiSignTx(cnt int) interface{} { - payload := cmn.RandBytes(32) - tx := newMulti(payload) - for i := 0; i < cnt; i++ { - key := crypto.GenPrivKeyEd25519().Wrap() - Sign(tx, key) - } - return tx -} - -func makeHandler() sdk.Handler { - return sdk.ChainDecorators( - Signatures{}, - ).WithHandler( - util.OKHandler{}, - ) -} - -func BenchmarkCheckOneSig(b *testing.B) { - tx := makeSignTx() - h := makeHandler() - store := state.NewMemKVStore() - for i := 1; i <= b.N; i++ { - ctx := util.MockContext("foo", 100) - _, err := h.DeliverTx(ctx, store, tx) - // never should error - if err != nil { - panic(err) - } - } -} - -func BenchmarkCheckMultiSig(b *testing.B) { - sigs := []int{1, 3, 8, 20} - for _, cnt := range sigs { - label := fmt.Sprintf("%dsigs", cnt) - b.Run(label, func(sub *testing.B) { - benchmarkCheckMultiSig(sub, cnt) - }) - } -} - -func benchmarkCheckMultiSig(b *testing.B, cnt int) { - tx := makeMultiSignTx(cnt) - h := makeHandler() - store := state.NewMemKVStore() - for i := 1; i <= b.N; i++ { - ctx := util.MockContext("foo", 100) - _, err := h.DeliverTx(ctx, store, tx) - // never should error - if err != nil { - panic(err) - } - } -} diff --git a/x/auth/errors.go b/x/auth/errors.go deleted file mode 100644 index 46b562cf4e..0000000000 --- a/x/auth/errors.go +++ /dev/null @@ -1,31 +0,0 @@ -//nolint -package auth - -import ( - "fmt" - - abci "github.com/tendermint/abci/types" - - "github.com/cosmos/cosmos-sdk/errors" -) - -var ( - errInvalidSignature = fmt.Errorf("Invalid Signature") //move auth - errTooManySignatures = fmt.Errorf("Too many signatures") //move auth - - unauthorized = abci.CodeType_Unauthorized -) - -func ErrTooManySignatures() errors.TMError { - return errors.WithCode(errTooManySignatures, unauthorized) -} -func IsTooManySignaturesErr(err error) bool { - return errors.IsSameError(errTooManySignatures, err) -} - -func ErrInvalidSignature() errors.TMError { - return errors.WithCode(errInvalidSignature, unauthorized) -} -func IsInvalidSignatureErr(err error) bool { - return errors.IsSameError(errInvalidSignature, err) -} diff --git a/x/auth/errors_test.go b/x/auth/errors_test.go deleted file mode 100644 index d23d3b14db..0000000000 --- a/x/auth/errors_test.go +++ /dev/null @@ -1,29 +0,0 @@ -package auth - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/cosmos/cosmos-sdk/errors" -) - -func TestChecks(t *testing.T) { - // TODO: make sure the Is and Err methods match - assert := assert.New(t) - - cases := []struct { - err error - check func(error) bool - match bool - }{ - // unauthorized includes InvalidSignature, but not visa versa - {ErrInvalidSignature(), IsInvalidSignatureErr, true}, - {ErrInvalidSignature(), errors.IsUnauthorizedErr, true}, - } - - for i, tc := range cases { - match := tc.check(tc.err) - assert.Equal(tc.match, match, "%d", i) - } -}