BVS demo using cosmos-sdk
- Copied basecoin example from cosmos-sdk
- Rebranding: Basecoin → BVS or Bvs
- Added test-purpose genesis.json with pre-allocated assets
- Added Travis CI configuration (build only for now, no deploy)
- Added several types for BVS application
- install golang (see cosmos doc)
- install dep command
go get dep - clone this repo into
$GOPATH/src/github.com/dcgraph/bvs-cosmos - cd to
$GOPATH/src/github.com/dcgraph/bvs-cosmos - run
dep ensure -v - run
make(build and test) - run
make install(build and install)
- run
bvsd init - copy
testdata/genesis.jsonto$HOME/.bvsd/config/genesis.jsonor simply runmake installagain - run
bvsd start - wait until the first block generated and committed
- press
^Cto stop bvsd - run
bvsd exportto see internal state of bvsd
In one terminal:
- run
bvsd start(leave this terminal)
In another terminal:
- run
bvscli status - run
bvscli account ... - run
bvscli codex ... - run
bvscli voucher ... - run
bvscli send ... - ...
See Gaia CLI document for more information.
BvsAppinapp/app.gois a fork ofBasecoinexample, which implements ABCI application in cosmos terms.- types:
UserAccountmeans every user account associated with a private key.UserAccountis an extension ofBaseAccount. So, in order to handle genesis state this type needsGenesisAccountwhich has flat member fields.UserAccounthasAddress(typesdk.AccAddress) member to handle operations associated with digital signatures.UserAccountalso hasId(typestring) member to handle BVS-related operations.
CodexandVoucherare system account without private key associated.- They are simple structs and do not need
GenesisSomethingstruct to handle genesis state. CodexandVoucherhaveIdmember to handle BVS-related operations.
- They are simple structs and do not need
- data stores:
AccountKVStore stores user accounts with the help ofAccountMapper.CodexKVStore stores codex accounts with the help ofCodexMapper.VoucherKVStore stores vouchers with the help ofVoucherMapper.
- BVS asset
BvsAssetintypes/voucher.gorepresent arbitrary asset in BVS environment.BvsAssetshall be moved intotypes/asset.go.UserAccountandCodexcan hold coins, which are handled assdk.Coins.UserAccountandCodexusecosmos-sdk/x/bankmodule in order to handlesdk.Coins.