forked from cerc-io/laconicd-deprecated
Merge pull request #24 from vulcanize/sai/migrate_dxns_modules_to_ethermint_v0.12.2
feat: add dxns modules to ethermint v0.12.2
This commit is contained in:
commit
96393bfc36
3
.gitignore
vendored
3
.gitignore
vendored
@ -70,4 +70,5 @@ dependency-graph.png
|
||||
|
||||
# Node.js
|
||||
tests/**/node_modules/*
|
||||
tests-solidity/**/node_modules/*
|
||||
tests-solidity/**/node_modules/*
|
||||
**/**.json
|
23
CHANGELOG.md
23
CHANGELOG.md
@ -36,14 +36,27 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
# Changelog
|
||||
|
||||
## Unreleased
|
||||
## [v0.12.2] - 2022-03-30
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* (rpc) [tharsis#990](https://github.com/tharsis/ethermint/pull/990) Calculate reward values from all `MsgEthereumTx` from a block in `eth_feeHistory`.
|
||||
* (ante) [tharsis#991](https://github.com/tharsis/ethermint/pull/991) Set an upper bound to gasWanted to prevent DoS attack.
|
||||
* (feemarket) [tharsis#1021](https://github.com/tharsis/ethermint/pull/1021) Fix fee market migration.
|
||||
|
||||
## [v0.12.1] - 2022-03-29
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* (evm) [tharsis#1016](https://github.com/tharsis/ethermint/pull/1016) Update validate basic check for storage state.
|
||||
|
||||
## [v0.12.0] - 2022-03-24
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* (rpc) [tharsis#1012](https://github.com/tharsis/ethermint/pull/1012) fix the tx hash in filter entries created by `eth_newPendingTransactionFilter`.
|
||||
* (rpc) [tharsis#1006](https://github.com/tharsis/ethermint/pull/1006) Use `string` as the parameters type to correct ambiguous results.
|
||||
* (ante) [tharsis#1004](https://github.com/tharsis/ethermint/pull/1004) make MaxTxGasWanted configurable.
|
||||
* (ante) [tharsis#1004](https://github.com/tharsis/ethermint/pull/1004) Make `MaxTxGasWanted` configurable.
|
||||
* (ante) [tharsis#991](https://github.com/tharsis/ethermint/pull/991) Set an upper bound to gasWanted to prevent DoS attack.
|
||||
* (rpc) [tharsis#990](https://github.com/tharsis/ethermint/pull/990) Calculate reward values from all `MsgEthereumTx` from a block in `eth_feeHistory`.
|
||||
|
||||
## [v0.11.0] - 2022-03-06
|
||||
|
||||
@ -57,7 +70,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
### Improvements
|
||||
|
||||
- (rpc) [tharsis#979](https://github.com/tharsis/ethermint/pull/979) Add configurable timeouts to http server
|
||||
- (rpc) [tharsis#979](https://github.com/tharsis/ethermint/pull/979) Add configurable timeouts to http server
|
||||
- (rpc) [tharsis#988](https://github.com/tharsis/ethermint/pull/988) json-rpc server always use local rpc client
|
||||
|
||||
## [v0.10.1] - 2022-03-04
|
||||
|
351
DXNS_MODULES_README.md
Normal file
351
DXNS_MODULES_README.md
Normal file
@ -0,0 +1,351 @@
|
||||
# Vulcanize dxns gql
|
||||
|
||||
> Browser : http://localhost:9473 for gql
|
||||
|
||||
## Start server
|
||||
|
||||
```shell
|
||||
./build/ethermintd start --gql-playground --gql-server
|
||||
```
|
||||
|
||||
Basic node status:
|
||||
|
||||
```graphql
|
||||
{
|
||||
getStatus {
|
||||
version
|
||||
node {
|
||||
id
|
||||
network
|
||||
moniker
|
||||
}
|
||||
sync {
|
||||
latest_block_height
|
||||
catching_up
|
||||
}
|
||||
num_peers
|
||||
peers {
|
||||
is_outbound
|
||||
remote_ip
|
||||
}
|
||||
disk_usage
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Full node status:
|
||||
|
||||
```graphql
|
||||
{
|
||||
getStatus {
|
||||
version
|
||||
node {
|
||||
id
|
||||
network
|
||||
moniker
|
||||
}
|
||||
sync {
|
||||
latest_block_hash
|
||||
latest_block_time
|
||||
latest_block_height
|
||||
catching_up
|
||||
}
|
||||
validator {
|
||||
address
|
||||
voting_power
|
||||
proposer_priority
|
||||
}
|
||||
validators {
|
||||
address
|
||||
voting_power
|
||||
proposer_priority
|
||||
}
|
||||
num_peers
|
||||
peers {
|
||||
node {
|
||||
id
|
||||
network
|
||||
moniker
|
||||
}
|
||||
is_outbound
|
||||
remote_ip
|
||||
}
|
||||
disk_usage
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Get records by IDs.
|
||||
|
||||
```graphql
|
||||
{
|
||||
getRecordsByIds(ids: ["QmYDtNCKtTu6u6jaHaFAC5PWZXcj7fAmry6NoWwMaixFHz"]) {
|
||||
id
|
||||
names
|
||||
bondId
|
||||
createTime
|
||||
expiryTime
|
||||
owners
|
||||
attributes {
|
||||
key
|
||||
value {
|
||||
string
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Query records.
|
||||
|
||||
```graphql
|
||||
{
|
||||
queryRecords(attributes: [{ key: "type", value: { string: "wrn:bot" } }]) {
|
||||
id
|
||||
names
|
||||
bondId
|
||||
createTime
|
||||
expiryTime
|
||||
owners
|
||||
attributes {
|
||||
key
|
||||
value {
|
||||
string
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Get account details:
|
||||
|
||||
```graphql
|
||||
{
|
||||
getAccounts(addresses: ["cosmos1wh8vvd0ymc5nt37h29z8kk2g2ays45ct2qu094"]) {
|
||||
address
|
||||
pubKey
|
||||
number
|
||||
sequence
|
||||
balance {
|
||||
type
|
||||
quantity
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Query bonds:
|
||||
|
||||
```graphql
|
||||
{
|
||||
queryBonds(
|
||||
attributes: [
|
||||
{
|
||||
key: "owner"
|
||||
value: { string: "cosmos1wh8vvd0ymc5nt37h29z8kk2g2ays45ct2qu094" }
|
||||
}
|
||||
]
|
||||
) {
|
||||
id
|
||||
owner
|
||||
balance {
|
||||
type
|
||||
quantity
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Get bonds by IDs.
|
||||
|
||||
```graphql
|
||||
{
|
||||
getBondsByIds(ids :
|
||||
[
|
||||
"1c2b677cb2a27c88cc6bf8acf675c94b69051125b40c4fd073153b10f046dd87",
|
||||
"c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440"
|
||||
])
|
||||
{
|
||||
id
|
||||
owner
|
||||
balance{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Query Bonds by Owner
|
||||
|
||||
```graphql
|
||||
{
|
||||
queryBondsByOwner(ownerAddresses: ["ethm1mfdjngh5jvjs9lqtt9a7y2hlgw8v3syh3hsqzk"])
|
||||
{
|
||||
owner
|
||||
bonds{
|
||||
id
|
||||
owner
|
||||
balance
|
||||
{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Query auctions by ids
|
||||
|
||||
```graphql
|
||||
{
|
||||
getAuctionsByIds(ids: ["be98f2073c246194276554eefdb4c95b682a35a0f06fbe619a6da57c10c93e90"]){
|
||||
id
|
||||
ownerAddress
|
||||
createTime
|
||||
minimumBid{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
commitFee{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
commitsEndTime
|
||||
revealFee{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
revealsEndTime
|
||||
winnerBid{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
winnerPrice{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
winnerAddress
|
||||
bids{
|
||||
bidderAddress
|
||||
commitHash
|
||||
commitTime
|
||||
commitFee{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
revealFee{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
revealTime
|
||||
bidAmount{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
status
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
LookUp Authorities
|
||||
|
||||
```graphql
|
||||
{
|
||||
lookupAuthorities(names: []){
|
||||
ownerAddress
|
||||
ownerAddress
|
||||
height
|
||||
bondId
|
||||
status
|
||||
expiryTime
|
||||
auction {
|
||||
id
|
||||
ownerAddress
|
||||
createTime
|
||||
minimumBid{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
commitFee{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
commitsEndTime
|
||||
revealFee{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
revealsEndTime
|
||||
winnerBid{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
winnerPrice{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
winnerAddress
|
||||
bids{
|
||||
bidderAddress
|
||||
commitHash
|
||||
commitTime
|
||||
commitFee{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
revealFee{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
revealTime
|
||||
bidAmount{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
status
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
LookUp Names
|
||||
|
||||
```graphql
|
||||
{
|
||||
lookupNames(names: ["wrn://hello/test"]){
|
||||
latest{
|
||||
id
|
||||
height
|
||||
}
|
||||
history{
|
||||
id
|
||||
height
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Resolve Names
|
||||
|
||||
```graphql
|
||||
{
|
||||
resolveNames(names: ["asd"]){
|
||||
id
|
||||
names
|
||||
bondId
|
||||
createTime
|
||||
expiryTime
|
||||
owners
|
||||
attributes {
|
||||
key
|
||||
value {
|
||||
string
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
17
app/addr_prefixes.go
Normal file
17
app/addr_prefixes.go
Normal file
@ -0,0 +1,17 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
cmdcfg "github.com/tharsis/ethermint/cmd/config"
|
||||
)
|
||||
|
||||
// sdk config
|
||||
func init() {
|
||||
config := sdk.GetConfig()
|
||||
cmdcfg.SetBech32Prefixes(config)
|
||||
cmdcfg.SetBip44CoinType(config)
|
||||
config.Seal()
|
||||
|
||||
cmdcfg.RegisterDenoms()
|
||||
}
|
72
app/app.go
72
app/app.go
@ -110,6 +110,16 @@ import (
|
||||
// Force-load the tracer engines to trigger registration due to Go-Ethereum v1.10.15 changes
|
||||
_ "github.com/ethereum/go-ethereum/eth/tracers/js"
|
||||
_ "github.com/ethereum/go-ethereum/eth/tracers/native"
|
||||
|
||||
"github.com/tharsis/ethermint/x/auction"
|
||||
auctionkeeper "github.com/tharsis/ethermint/x/auction/keeper"
|
||||
auctiontypes "github.com/tharsis/ethermint/x/auction/types"
|
||||
"github.com/tharsis/ethermint/x/bond"
|
||||
bondkeeper "github.com/tharsis/ethermint/x/bond/keeper"
|
||||
bondtypes "github.com/tharsis/ethermint/x/bond/types"
|
||||
"github.com/tharsis/ethermint/x/nameservice"
|
||||
nameservicekeeper "github.com/tharsis/ethermint/x/nameservice/keeper"
|
||||
nameservicetypes "github.com/tharsis/ethermint/x/nameservice/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -155,6 +165,10 @@ var (
|
||||
// Ethermint modules
|
||||
evm.AppModuleBasic{},
|
||||
feemarket.AppModuleBasic{},
|
||||
// Vulcanize DXNS modules
|
||||
auction.AppModuleBasic{},
|
||||
bond.AppModuleBasic{},
|
||||
nameservice.AppModuleBasic{},
|
||||
)
|
||||
|
||||
// module account permissions
|
||||
@ -167,6 +181,13 @@ var (
|
||||
govtypes.ModuleName: {authtypes.Burner},
|
||||
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
|
||||
evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, // used for secure addition and subtraction of balance using module account
|
||||
|
||||
auctiontypes.ModuleName: nil,
|
||||
auctiontypes.AuctionBurnModuleAccountName: nil,
|
||||
nameservicetypes.ModuleName: nil,
|
||||
nameservicetypes.RecordRentModuleAccountName: nil,
|
||||
nameservicetypes.AuthorityRentModuleAccountName: nil,
|
||||
bondtypes.ModuleName: nil,
|
||||
}
|
||||
|
||||
// module accounts that are allowed to receive tokens
|
||||
@ -223,6 +244,12 @@ type EthermintApp struct {
|
||||
EvmKeeper *evmkeeper.Keeper
|
||||
FeeMarketKeeper feemarketkeeper.Keeper
|
||||
|
||||
// DXNS keepers
|
||||
AuctionKeeper auctionkeeper.Keeper
|
||||
BondKeeper bondkeeper.Keeper
|
||||
NameServiceKeeper nameservicekeeper.Keeper
|
||||
NameServiceRecordKeeper nameservicekeeper.RecordKeeper
|
||||
|
||||
// the module manager
|
||||
mm *module.Manager
|
||||
|
||||
@ -273,6 +300,10 @@ func NewEthermintApp(
|
||||
ibchost.StoreKey, ibctransfertypes.StoreKey,
|
||||
// ethermint keys
|
||||
evmtypes.StoreKey, feemarkettypes.StoreKey,
|
||||
// dxns keys
|
||||
auctiontypes.StoreKey,
|
||||
bondtypes.StoreKey,
|
||||
nameservicetypes.StoreKey,
|
||||
)
|
||||
|
||||
// Add the EVM transient store key
|
||||
@ -347,6 +378,27 @@ func NewEthermintApp(
|
||||
appCodec, keys[feemarkettypes.StoreKey], app.GetSubspace(feemarkettypes.ModuleName),
|
||||
)
|
||||
|
||||
// Create Vulcanize dxns keepers
|
||||
app.AuctionKeeper = auctionkeeper.NewKeeper(
|
||||
app.AccountKeeper, app.BankKeeper, keys[auctiontypes.StoreKey],
|
||||
appCodec, app.GetSubspace(auctiontypes.ModuleName),
|
||||
)
|
||||
|
||||
app.NameServiceRecordKeeper = nameservicekeeper.NewRecordKeeper(app.AuctionKeeper, keys[nameservicetypes.StoreKey], appCodec)
|
||||
|
||||
app.AuctionKeeper.SetUsageKeepers([]auctiontypes.AuctionUsageKeeper{app.NameServiceRecordKeeper})
|
||||
|
||||
app.BondKeeper = bondkeeper.NewKeeper(
|
||||
appCodec, app.AccountKeeper, app.BankKeeper,
|
||||
[]bondtypes.BondUsageKeeper{app.NameServiceRecordKeeper}, keys[bondtypes.StoreKey], app.GetSubspace(bondtypes.ModuleName),
|
||||
)
|
||||
|
||||
app.NameServiceKeeper = nameservicekeeper.NewKeeper(
|
||||
appCodec, app.AccountKeeper, app.BankKeeper,
|
||||
app.NameServiceRecordKeeper, app.BondKeeper, app.AuctionKeeper,
|
||||
keys[nameservicetypes.StoreKey], app.GetSubspace(nameservicetypes.ModuleName),
|
||||
)
|
||||
|
||||
app.EvmKeeper = evmkeeper.NewKeeper(
|
||||
appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], app.GetSubspace(evmtypes.ModuleName),
|
||||
app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper,
|
||||
@ -434,6 +486,10 @@ func NewEthermintApp(
|
||||
// Ethermint app modules
|
||||
evm.NewAppModule(app.EvmKeeper, app.AccountKeeper),
|
||||
feemarket.NewAppModule(app.FeeMarketKeeper),
|
||||
// DXNs modules
|
||||
auction.NewAppModule(appCodec, app.AuctionKeeper),
|
||||
bond.NewAppModule(appCodec, app.BondKeeper),
|
||||
nameservice.NewAppModule(app.NameServiceKeeper),
|
||||
)
|
||||
|
||||
// During begin block slashing happens after distr.BeginBlocker so that
|
||||
@ -464,6 +520,10 @@ func NewEthermintApp(
|
||||
feegrant.ModuleName,
|
||||
paramstypes.ModuleName,
|
||||
vestingtypes.ModuleName,
|
||||
// DXNS modules
|
||||
auctiontypes.ModuleName,
|
||||
bondtypes.ModuleName,
|
||||
nameservicetypes.ModuleName,
|
||||
)
|
||||
|
||||
// NOTE: fee market module must go last in order to retrieve the block gas used.
|
||||
@ -489,6 +549,10 @@ func NewEthermintApp(
|
||||
paramstypes.ModuleName,
|
||||
upgradetypes.ModuleName,
|
||||
vestingtypes.ModuleName,
|
||||
// DXNS modules
|
||||
auctiontypes.ModuleName,
|
||||
bondtypes.ModuleName,
|
||||
nameservicetypes.ModuleName,
|
||||
)
|
||||
|
||||
// NOTE: The genutils module must occur after staking so that pools are
|
||||
@ -518,6 +582,10 @@ func NewEthermintApp(
|
||||
// Ethermint modules
|
||||
evmtypes.ModuleName,
|
||||
feemarkettypes.ModuleName,
|
||||
// DXNS modules
|
||||
auctiontypes.ModuleName,
|
||||
bondtypes.ModuleName,
|
||||
nameservicetypes.ModuleName,
|
||||
|
||||
// NOTE: crisis module must go at the end to check for invariants on each module
|
||||
crisistypes.ModuleName,
|
||||
@ -775,5 +843,9 @@ func initParamsKeeper(
|
||||
// ethermint subspaces
|
||||
paramsKeeper.Subspace(evmtypes.ModuleName)
|
||||
paramsKeeper.Subspace(feemarkettypes.ModuleName)
|
||||
// dxns subspaces
|
||||
paramsKeeper.Subspace(auctiontypes.ModuleName)
|
||||
paramsKeeper.Subspace(bondtypes.ModuleName)
|
||||
paramsKeeper.Subspace(nameservicetypes.ModuleName)
|
||||
return paramsKeeper
|
||||
}
|
||||
|
@ -4,10 +4,13 @@ import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
"github.com/tharsis/ethermint/encoding"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
@ -62,3 +65,15 @@ func Setup(isCheckTx bool, patchGenesis func(*EthermintApp, simapp.GenesisState)
|
||||
|
||||
return app
|
||||
}
|
||||
|
||||
// CreateRandomAccounts will generate random accounts
|
||||
func CreateRandomAccounts(accNum int) []sdk.AccAddress {
|
||||
// createRandomAccounts is a strategy used by addTestAddrs() in order to generated addresses in random order.
|
||||
testAddrs := make([]sdk.AccAddress, accNum)
|
||||
for i := 0; i < accNum; i++ {
|
||||
pk := ed25519.GenPrivKey().PubKey()
|
||||
testAddrs[i] = sdk.AccAddress(pk.Address())
|
||||
}
|
||||
|
||||
return testAddrs
|
||||
}
|
||||
|
@ -208,7 +208,6 @@ func initTestnetFiles(
|
||||
genBalIterator banktypes.GenesisBalancesIterator,
|
||||
args initArgs,
|
||||
) error {
|
||||
|
||||
if args.chainID == "" {
|
||||
args.chainID = fmt.Sprintf("ethermint_%d-1", tmrand.Int63n(9999999999999)+1)
|
||||
}
|
||||
@ -377,7 +376,6 @@ func initGenFiles(
|
||||
genFiles []string,
|
||||
numValidators int,
|
||||
) error {
|
||||
|
||||
appGenState := mbm.DefaultGenesis(clientCtx.Codec)
|
||||
// set the accounts in the genesis state
|
||||
var authGenState authtypes.GenesisState
|
||||
@ -453,7 +451,6 @@ func collectGenFiles(
|
||||
nodeIDs []string, valPubKeys []cryptotypes.PubKey, numValidators int,
|
||||
outputDir, nodeDirPrefix, nodeDaemonHome string, genBalIterator banktypes.GenesisBalancesIterator,
|
||||
) error {
|
||||
|
||||
var appState json.RawMessage
|
||||
genTime := tmtime.Now()
|
||||
|
||||
|
@ -5,16 +5,11 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/tharsis/ethermint/app"
|
||||
cmdcfg "github.com/tharsis/ethermint/cmd/config"
|
||||
)
|
||||
|
||||
func main() {
|
||||
setupConfig()
|
||||
cmdcfg.RegisterDenoms()
|
||||
|
||||
rootCmd, _ := NewRootCmd()
|
||||
|
||||
if err := svrcmd.Execute(rootCmd, app.DefaultNodeHome); err != nil {
|
||||
@ -27,11 +22,3 @@ func main() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func setupConfig() {
|
||||
// set the address prefixes
|
||||
config := sdk.GetConfig()
|
||||
cmdcfg.SetBech32Prefixes(config)
|
||||
cmdcfg.SetBip44CoinType(config)
|
||||
config.Seal()
|
||||
}
|
||||
|
@ -128,6 +128,9 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
|
||||
// add rosetta
|
||||
rootCmd.AddCommand(sdkserver.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Marshaler))
|
||||
|
||||
// Add flags for GQL server.
|
||||
rootCmd = srvflags.AddGQLFlags(rootCmd)
|
||||
|
||||
return rootCmd, encodingConfig
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
36
go.mod
36
go.mod
@ -9,7 +9,9 @@ require (
|
||||
github.com/cosmos/go-bip39 v1.0.0
|
||||
github.com/cosmos/ibc-go/v3 v3.0.0
|
||||
github.com/davecgh/go-spew v1.1.1
|
||||
github.com/deckarep/golang-set v1.8.0
|
||||
github.com/ethereum/go-ethereum v1.10.16
|
||||
github.com/gibson042/canonicaljson-go v1.0.3
|
||||
github.com/gogo/protobuf v1.3.3
|
||||
github.com/golang/protobuf v1.5.2
|
||||
github.com/gorilla/mux v1.8.0
|
||||
@ -17,7 +19,9 @@ require (
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0
|
||||
github.com/holiman/uint256 v1.2.0
|
||||
github.com/improbable-eng/grpc-web v0.15.0
|
||||
github.com/ipfs/go-ipld-cbor v0.0.6
|
||||
github.com/miguelmota/go-ethereum-hdwallet v0.1.1
|
||||
github.com/multiformats/go-multihash v0.1.0
|
||||
github.com/onsi/ginkgo v1.16.5
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/rakyll/statik v0.1.7
|
||||
@ -31,20 +35,23 @@ require (
|
||||
github.com/tendermint/tendermint v0.34.14
|
||||
github.com/tendermint/tm-db v0.6.7
|
||||
github.com/tyler-smith/go-bip39 v1.1.0
|
||||
google.golang.org/genproto v0.0.0-20220211171837-173942840c17
|
||||
google.golang.org/grpc v1.44.0
|
||||
google.golang.org/genproto v0.0.0-20220401170504-314d38edb7de
|
||||
google.golang.org/grpc v1.45.0
|
||||
google.golang.org/protobuf v1.28.0
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
||||
)
|
||||
|
||||
require (
|
||||
filippo.io/edwards25519 v1.0.0-beta.2 // indirect
|
||||
github.com/99designs/gqlgen v0.17.2 // indirect
|
||||
github.com/99designs/keyring v1.1.6 // indirect
|
||||
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect
|
||||
github.com/DataDog/zstd v1.4.5 // indirect
|
||||
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
|
||||
github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
|
||||
github.com/Workiva/go-datastructures v1.0.52 // indirect
|
||||
github.com/agnivade/levenshtein v1.1.0 // indirect
|
||||
github.com/armon/go-metrics v0.3.10 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bgentry/speakeasy v0.1.0 // indirect
|
||||
@ -59,7 +66,6 @@ require (
|
||||
github.com/cosmos/ledger-cosmos-go v0.11.1 // indirect
|
||||
github.com/cosmos/ledger-go v0.9.2 // indirect
|
||||
github.com/danieljoos/wincred v1.0.2 // indirect
|
||||
github.com/deckarep/golang-set v1.8.0 // indirect
|
||||
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
|
||||
github.com/dgraph-io/badger/v2 v2.2007.2 // indirect
|
||||
github.com/dgraph-io/ristretto v0.0.3 // indirect
|
||||
@ -81,7 +87,7 @@ require (
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/google/btree v1.0.0 // indirect
|
||||
github.com/google/orderedcode v0.0.1 // indirect
|
||||
github.com/google/uuid v1.1.5 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/gorilla/handlers v1.5.1 // indirect
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
|
||||
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
|
||||
@ -94,10 +100,15 @@ require (
|
||||
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
|
||||
github.com/huin/goupnp v1.0.2 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||
github.com/ipfs/go-block-format v0.0.2 // indirect
|
||||
github.com/ipfs/go-cid v0.0.3 // indirect
|
||||
github.com/ipfs/go-ipfs-util v0.0.1 // indirect
|
||||
github.com/ipfs/go-ipld-format v0.0.1 // indirect
|
||||
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
|
||||
github.com/jmhodges/levigo v1.0.0 // indirect
|
||||
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect
|
||||
github.com/klauspost/compress v1.11.7 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
|
||||
github.com/lib/pq v1.10.2 // indirect
|
||||
github.com/libp2p/go-buffer-pool v0.0.2 // indirect
|
||||
github.com/magiconair/properties v1.8.5 // indirect
|
||||
@ -105,14 +116,21 @@ require (
|
||||
github.com/mattn/go-runewidth v0.0.9 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
||||
github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect
|
||||
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect
|
||||
github.com/minio/highwayhash v1.0.1 // indirect
|
||||
github.com/minio/sha256-simd v1.0.0 // indirect
|
||||
github.com/mitchellh/mapstructure v1.4.3 // indirect
|
||||
github.com/mr-tron/base58 v1.2.0 // indirect
|
||||
github.com/mtibben/percent v0.2.1 // indirect
|
||||
github.com/multiformats/go-base32 v0.0.3 // indirect
|
||||
github.com/multiformats/go-multibase v0.0.1 // indirect
|
||||
github.com/multiformats/go-varint v0.0.6 // indirect
|
||||
github.com/nxadm/tail v1.4.8 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/pelletier/go-toml v1.9.4 // indirect
|
||||
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/polydawn/refmt v0.0.0-20190221155625-df39d6c2d992 // indirect
|
||||
github.com/prometheus/client_golang v1.11.0 // indirect
|
||||
github.com/prometheus/client_model v0.2.0 // indirect
|
||||
github.com/prometheus/common v0.29.0 // indirect
|
||||
@ -123,6 +141,7 @@ require (
|
||||
github.com/rs/zerolog v1.23.0 // indirect
|
||||
github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa // indirect
|
||||
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
|
||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||
github.com/spf13/afero v1.6.0 // indirect
|
||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
@ -133,20 +152,23 @@ require (
|
||||
github.com/tendermint/go-amino v0.16.0 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.5 // indirect
|
||||
github.com/tklauser/numcpus v0.2.2 // indirect
|
||||
github.com/vektah/gqlparser/v2 v2.4.1 // indirect
|
||||
github.com/whyrusleeping/cbor-gen v0.0.0-20200123233031-1cdf64d27158 // indirect
|
||||
github.com/zondax/hid v0.9.0 // indirect
|
||||
go.etcd.io/bbolt v1.3.6 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220213190939-1e6e3497d506 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29 // indirect
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
|
||||
golang.org/x/sys v0.0.0-20211210111614-af8b64212486 // indirect
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
golang.org/x/tools v0.1.5 // indirect
|
||||
golang.org/x/tools v0.1.9 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
||||
gopkg.in/ini.v1 v1.66.2 // indirect
|
||||
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
|
||||
gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6 // indirect
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
|
||||
lukechampine.com/blake3 v1.1.6 // indirect
|
||||
nhooyr.io/websocket v1.8.6 // indirect
|
||||
)
|
||||
|
||||
|
91
go.sum
91
go.sum
@ -52,6 +52,8 @@ collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
filippo.io/edwards25519 v1.0.0-beta.2 h1:/BZRNzm8N4K4eWfK28dL4yescorxtO7YG1yun8fy+pI=
|
||||
filippo.io/edwards25519 v1.0.0-beta.2/go.mod h1:X+pm78QAUPtFLi1z9PYIlS/bdDnvbCOGKtZ+ACWEf7o=
|
||||
github.com/99designs/gqlgen v0.17.2 h1:yczvlwMsfcVu/JtejqfrLwXuSP0yZFhmcss3caEvHw8=
|
||||
github.com/99designs/gqlgen v0.17.2/go.mod h1:K5fzLKwtph+FFgh9j7nFbRUdBKvTcGnsta51fsMTn3o=
|
||||
github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4=
|
||||
github.com/Azure/azure-pipeline-go v0.2.2/go.mod h1:4rQ/NZncSvGqNkkOsNpOU1tgoNuIlp9AfUH5G1tvCHc=
|
||||
github.com/Azure/azure-storage-blob-go v0.7.0/go.mod h1:f9YQKtsG1nMisotuTPpO0tjNuEjKRYAcJU8/ydDI++4=
|
||||
@ -101,6 +103,9 @@ github.com/adlio/schema v1.1.13 h1:LeNMVg5Z1FX+Qgz8tJUijBLRdcpbFUElz+d1489On98=
|
||||
github.com/adlio/schema v1.1.13/go.mod h1:L5Z7tw+7lRK1Fnpi/LT/ooCP1elkXn0krMWBQHUhEDE=
|
||||
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
|
||||
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
|
||||
github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
|
||||
github.com/agnivade/levenshtein v1.1.0 h1:n6qGwyHG61v3ABce1rPVZklEYRT8NFpCMrpZdBUbYGM=
|
||||
github.com/agnivade/levenshtein v1.1.0/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo=
|
||||
github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
@ -115,6 +120,7 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd
|
||||
github.com/apache/arrow/go/arrow v0.0.0-20191024131854-af6fa24be0db/go.mod h1:VTxUBvSJ3s3eHAg65PNgrsn5BtqCRPdmyXh6rAfdxN0=
|
||||
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||
github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
|
||||
github.com/aristanetworks/goarista v0.0.0-20170210015632-ea17b1a17847/go.mod h1:D/tb0zPVXnP7fmsLZjtdUhSsumbK/ij54UXjjVgMGxQ=
|
||||
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
|
||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||
@ -276,6 +282,7 @@ github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUn
|
||||
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y=
|
||||
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
|
||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||
github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA=
|
||||
github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
|
||||
github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
|
||||
github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
@ -340,6 +347,8 @@ github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x
|
||||
github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4=
|
||||
github.com/getkin/kin-openapi v0.61.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/gibson042/canonicaljson-go v1.0.3 h1:EAyF8L74AWabkyUmrvEFHEt/AGFQeD6RfwbAuf0j1bI=
|
||||
github.com/gibson042/canonicaljson-go v1.0.3/go.mod h1:DsLpJTThXyGNO+KZlI85C1/KDcImpP67k/RKVjcaEqo=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
|
||||
@ -481,12 +490,14 @@ github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm4
|
||||
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.1.5 h1:kxhtnfFVi+rYdOALN0B3k9UT86zVJKfBimRaciULW4I=
|
||||
github.com/google/uuid v1.1.5/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||
github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0=
|
||||
github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU=
|
||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||
@ -524,6 +535,8 @@ github.com/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is=
|
||||
github.com/gtank/merlin v0.1.1/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s=
|
||||
github.com/gtank/ristretto255 v0.1.2 h1:JEqUCPA1NvLq5DwYtuzigd7ss8fwbYay9fi4/5uMzcc=
|
||||
github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIvY4OmlYW69o=
|
||||
github.com/gxed/hashland/keccakpg v0.0.1/go.mod h1:kRzw3HkwxFU1mpmPP8v1WyQzwdGfmKFJ6tItnhQ67kU=
|
||||
github.com/gxed/hashland/murmur3 v0.0.1/go.mod h1:KjXop02n4/ckmZSnY2+HKcLud/tcmvhST0bie/0lS48=
|
||||
github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q=
|
||||
github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE=
|
||||
github.com/hashicorp/consul/api v1.11.0/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M=
|
||||
@ -607,6 +620,17 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y
|
||||
github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE=
|
||||
github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0=
|
||||
github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po=
|
||||
github.com/ipfs/go-block-format v0.0.2 h1:qPDvcP19izTjU8rgo6p7gTXZlkMkF5bz5G3fqIsSCPE=
|
||||
github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY=
|
||||
github.com/ipfs/go-cid v0.0.1/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM=
|
||||
github.com/ipfs/go-cid v0.0.3 h1:UIAh32wymBpStoe83YCzwVQQ5Oy/H0FdxvUS6DJDzms=
|
||||
github.com/ipfs/go-cid v0.0.3/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM=
|
||||
github.com/ipfs/go-ipfs-util v0.0.1 h1:Wz9bL2wB2YBJqggkA4dD7oSmqB4cAnpNbGrlHJulv50=
|
||||
github.com/ipfs/go-ipfs-util v0.0.1/go.mod h1:spsl5z8KUnrve+73pOhSVZND1SIxPW5RyBCNzQxlJBc=
|
||||
github.com/ipfs/go-ipld-cbor v0.0.6 h1:pYuWHyvSpIsOOLw4Jy7NbBkCyzLDcl64Bf/LZW7eBQ0=
|
||||
github.com/ipfs/go-ipld-cbor v0.0.6/go.mod h1:ssdxxaLJPXH7OjF5V4NSjBbcfh+evoR4ukuru0oPXMA=
|
||||
github.com/ipfs/go-ipld-format v0.0.1 h1:HCu4eB/Gh+KD/Q0M8u888RFkorTWNIL3da4oc5dwc80=
|
||||
github.com/ipfs/go-ipld-format v0.0.1/go.mod h1:kyJtbkDALmFHv3QR6et67i35QzO3S0dCDnkOJhcZkms=
|
||||
github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
|
||||
github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus=
|
||||
github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
|
||||
@ -634,6 +658,8 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm
|
||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
||||
github.com/jsternberg/zap-logfmt v1.0.0/go.mod h1:uvPs/4X51zdkcm5jXl5SYoN+4RK21K8mysFmDaM/h+o=
|
||||
github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/julienschmidt/httprouter v1.1.1-0.20170430222011-975b5c4c7c21/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
@ -642,6 +668,7 @@ github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E
|
||||
github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0=
|
||||
github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
|
||||
github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
|
||||
github.com/kevinmbeaulieu/eq-go v1.0.0/go.mod h1:G3S8ajA56gKBZm4UB9AOyoOS37JO3roToPzKNM8dtdM=
|
||||
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d h1:Z+RDyXzjKE0i2sTjZ/b1uxiGtPhFy34Ou/Tk0qwN0kM=
|
||||
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d/go.mod h1:JJNrCn9otv/2QP4D7SMJBgaleKpOf66PnW6F5WGNRIc=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
@ -651,7 +678,11 @@ github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0
|
||||
github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
||||
github.com/klauspost/compress v1.11.7 h1:0hzRabrMN4tSTvMfnL3SCv1ZGeAP23ynzodBgaHeMeg=
|
||||
github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
||||
github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5 h1:2U0HzY8BJ8hVwDKIzp7y4voR9CX/nvcfymLmg2UiOio=
|
||||
github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
|
||||
github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6/go.mod h1:+ZoRqAPRLkC4NPOvfYeR5KNOrY6TD+/sAC3HXPZgDYg=
|
||||
github.com/klauspost/pgzip v1.0.2-0.20170402124221-0bf5dcad4ada/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
@ -680,6 +711,7 @@ github.com/libp2p/go-buffer-pool v0.0.2 h1:QNK2iAFa8gjAe1SPz6mHSMuCcjs+X1wlHzeOS
|
||||
github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM=
|
||||
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
|
||||
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
|
||||
github.com/logrusorgru/aurora/v3 v3.0.0/go.mod h1:vsR12bk5grlLvLXAYrBsb5Oc/N+LxAlxggSjiwMnCUc=
|
||||
github.com/lucasjones/reggen v0.0.0-20180717132126-cdb49ff09d77/go.mod h1:5ELEyG+X8f+meRWHuqUOewBOhvHkl7M76pdGEansxW4=
|
||||
github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w=
|
||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
@ -689,6 +721,7 @@ github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPK
|
||||
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/matryer/moq v0.0.0-20190312154309-6cfb0558e1bd/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ=
|
||||
github.com/matryer/moq v0.2.3/go.mod h1:9RtPYjTnH1bSBIkpvtHkFN7nbWAnO7oRpdJkEIn6UtE=
|
||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-colorable v0.1.0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
@ -727,8 +760,14 @@ github.com/miguelmota/go-ethereum-hdwallet v0.1.1 h1:zdXGlHao7idpCBjEGTXThVAtMKs
|
||||
github.com/miguelmota/go-ethereum-hdwallet v0.1.1/go.mod h1:f9m9uXokAHA6WNoYOPjj4AqjJS5pquQRiYYj/XSyPYc=
|
||||
github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 h1:hLDRPB66XQT/8+wG9WsDpiCvZf1yKO7sz7scAjSlBa0=
|
||||
github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM=
|
||||
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 h1:lYpkrQH5ajf0OXOcUbGjvZxxijuBwbbmlSxLiuofa+g=
|
||||
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ=
|
||||
github.com/minio/highwayhash v1.0.1 h1:dZ6IIu8Z14VlC0VpfKofAhCy74wu/Qb5gcn52yWoz/0=
|
||||
github.com/minio/highwayhash v1.0.1/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY=
|
||||
github.com/minio/sha256-simd v0.0.0-20190131020904-2d45a736cd16/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U=
|
||||
github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM=
|
||||
github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g=
|
||||
github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM=
|
||||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
||||
github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI=
|
||||
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
@ -738,6 +777,7 @@ github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS4
|
||||
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
|
||||
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.2.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs=
|
||||
@ -752,10 +792,24 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8=
|
||||
github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
|
||||
github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
|
||||
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
|
||||
github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ=
|
||||
github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg=
|
||||
github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs=
|
||||
github.com/mtibben/percent v0.2.1/go.mod h1:KG9uO+SZkUp+VkRHsCdYQV3XSZrrSpR3O9ibNBTZrns=
|
||||
github.com/multiformats/go-base32 v0.0.3 h1:tw5+NhuwaOjJCC5Pp82QuXbrmLzWg7uxlMFp8Nq/kkI=
|
||||
github.com/multiformats/go-base32 v0.0.3/go.mod h1:pLiuGC8y0QR3Ue4Zug5UzK9LjgbkL8NSQj0zQ5Nz/AA=
|
||||
github.com/multiformats/go-multibase v0.0.1 h1:PN9/v21eLywrFWdFNsFKaU04kLJzuYzmrJR+ubhT9qA=
|
||||
github.com/multiformats/go-multibase v0.0.1/go.mod h1:bja2MqRZ3ggyXtZSEDKpl0uO/gviWFaSteVbWT51qgs=
|
||||
github.com/multiformats/go-multihash v0.0.1/go.mod h1:w/5tugSrLEbWqlcgJabL3oHFKTwfvkofsjW2Qa1ct4U=
|
||||
github.com/multiformats/go-multihash v0.0.10/go.mod h1:YSLudS+Pi8NHE7o6tb3D8vrpKa63epEDmG8nTduyAew=
|
||||
github.com/multiformats/go-multihash v0.1.0 h1:CgAgwqk3//SVEw3T+6DqI4mWMyRuDwZtOWcJT0q9+EA=
|
||||
github.com/multiformats/go-multihash v0.1.0/go.mod h1:RJlXsxt6vHGaia+S8We0ErjhojtKzPP2AH4+kYM7k84=
|
||||
github.com/multiformats/go-varint v0.0.6 h1:gk85QWKxh3TazbLxED/NlDVv8+q+ReFJk7Y2W/KhfNY=
|
||||
github.com/multiformats/go-varint v0.0.6/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
@ -854,6 +908,8 @@ github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZ
|
||||
github.com/pkg/term v0.0.0-20180730021639-bffc007b7fd5/go.mod h1:eCbImbZ95eXtAUIbLAuAVnBnwf83mjf6QIVH8SHYwqQ=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/polydawn/refmt v0.0.0-20190221155625-df39d6c2d992 h1:bzMe+2coZJYHnhGgVlcQKuRy4FSny4ds8dLQjw5P1XE=
|
||||
github.com/polydawn/refmt v0.0.0-20190221155625-df39d6c2d992/go.mod h1:uIp+gprXxxrWSjjklXD+mN4wed/tMfjMMmN/9+JsA9o=
|
||||
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
|
||||
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
@ -937,6 +993,7 @@ github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KR
|
||||
github.com/segmentio/kafka-go v0.1.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo=
|
||||
github.com/segmentio/kafka-go v0.2.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo=
|
||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
||||
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||
github.com/shirou/gopsutil v2.20.5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
|
||||
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU=
|
||||
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
|
||||
@ -948,7 +1005,10 @@ github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrf
|
||||
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
|
||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/goconvey v0.0.0-20190222223459-a17d461953aa/go.mod h1:2RVY1rIf+2J2o/IM9+vPq9RzmHDSseB7FoXiSNIUsoU=
|
||||
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/snikch/goodman v0.0.0-20171125024755-10e37e294daa/go.mod h1:oJyF+mSPHbB5mVY2iO9KV3pTt/QbIkGaO8gQ2WrDbP4=
|
||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||
@ -1052,10 +1112,18 @@ github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/X
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
|
||||
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||
github.com/vektah/gqlparser/v2 v2.4.0 h1:EmA4dw9mqHm0j6Xzb9T21hOrp3oXmxnS40vwki70DZU=
|
||||
github.com/vektah/gqlparser/v2 v2.4.0/go.mod h1:flJWIR04IMQPGz+BXLrORkrARBxv/rtyIAFvd/MceW0=
|
||||
github.com/vektah/gqlparser/v2 v2.4.1 h1:QOyEn8DAPMUMARGMeshKDkDgNmVoEaEGiDB0uWxcSlQ=
|
||||
github.com/vektah/gqlparser/v2 v2.4.1/go.mod h1:flJWIR04IMQPGz+BXLrORkrARBxv/rtyIAFvd/MceW0=
|
||||
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
|
||||
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
|
||||
github.com/vmihailenco/msgpack/v5 v5.1.4/go.mod h1:C5gboKD0TJPqWDTVTtrQNfRbiBwHZGo8UTqP/9/XvLI=
|
||||
github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
|
||||
github.com/warpfork/go-wish v0.0.0-20180510122957-5ad1f5abf436 h1:qOpVTI+BrstcjTZLm2Yz/3sOnqkzj3FQoh0g+E5s3Gc=
|
||||
github.com/warpfork/go-wish v0.0.0-20180510122957-5ad1f5abf436/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw=
|
||||
github.com/whyrusleeping/cbor-gen v0.0.0-20200123233031-1cdf64d27158 h1:WXhVOwj2USAXB5oMDwRl3piOux2XMV9TANaYxXHdkoE=
|
||||
github.com/whyrusleeping/cbor-gen v0.0.0-20200123233031-1cdf64d27158/go.mod h1:Xj/M2wWU+QdTdRbu/L/1dIZY8/Wb2K9pAhtroQuxJJI=
|
||||
github.com/willf/bitset v1.1.3/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
|
||||
github.com/wsddn/go-ecdh v0.0.0-20161211032359-48726bab9208/go.mod h1:IotVbo4F+mw0EzQ08zFqg7pK3FebNXpaMsRy2RT+Ees=
|
||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||
@ -1067,6 +1135,7 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
|
||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/zondax/hid v0.9.0 h1:eiT3P6vNxAEVxXMw66eZUAAnU2zD33JBkfG/EnfAKl8=
|
||||
github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM=
|
||||
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||
@ -1107,10 +1176,12 @@ golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnf
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190909091759-094676da4a83/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
@ -1124,10 +1195,11 @@ golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPh
|
||||
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20220213190939-1e6e3497d506 h1:EuGTJDfeg/PGZJp3gq1K+14eSLFTsrj1eg8KQuiUyKg=
|
||||
golang.org/x/crypto v0.0.0-20220213190939-1e6e3497d506/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29 h1:tkVvjkPTB7pnW3jnid7kNyAMPVWllTNOf/qKDze4p9o=
|
||||
golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
@ -1171,6 +1243,7 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
|
||||
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
|
||||
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@ -1228,6 +1301,7 @@ golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qx
|
||||
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
@ -1270,6 +1344,7 @@ golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5h
|
||||
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190219092855-153ac476189d/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@ -1334,6 +1409,7 @@ golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@ -1358,6 +1434,7 @@ golang.org/x/sys v0.0.0-20210903071746-97244b99971b/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211210111614-af8b64212486 h1:5hpz5aRr+W1erYCL5JRhSUBJRph7l9XkNveoExlrKYk=
|
||||
@ -1433,6 +1510,7 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY
|
||||
golang.org/x/tools v0.0.0-20200717024301-6ddee64345a6/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200815165600-90abf76919f3/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE=
|
||||
golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
@ -1448,6 +1526,7 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=
|
||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
@ -1572,8 +1651,8 @@ google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12/go.mod h1:5CzLGKJ6
|
||||
google.golang.org/genproto v0.0.0-20211203200212-54befc351ae9/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20220211171837-173942840c17 h1:2X+CNIheCutWRyKRte8szGxrE5ggtV4U+NKAbh/oLhg=
|
||||
google.golang.org/genproto v0.0.0-20220211171837-173942840c17/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI=
|
||||
google.golang.org/genproto v0.0.0-20220401170504-314d38edb7de h1:9Ti5SG2U4cAcluryUo/sFay3TQKoxiFMfaT0pbizU7k=
|
||||
google.golang.org/genproto v0.0.0-20220401170504-314d38edb7de/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo=
|
||||
google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o=
|
||||
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
||||
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
|
||||
@ -1640,6 +1719,8 @@ honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt
|
||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las=
|
||||
lukechampine.com/blake3 v1.1.6 h1:H3cROdztr7RCfoaTpGZFQsrqvweFLrqS73j7L7cmR5c=
|
||||
lukechampine.com/blake3 v1.1.6/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA=
|
||||
nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k=
|
||||
nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0=
|
||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||
|
351
gql/README.md
Normal file
351
gql/README.md
Normal file
@ -0,0 +1,351 @@
|
||||
# Vulcanize dxns gql
|
||||
|
||||
> Browser : http://localhost:9473 for gql
|
||||
|
||||
## Start server
|
||||
|
||||
```shell
|
||||
./build/ethermintd start --gql-playground --gql-server
|
||||
```
|
||||
|
||||
Basic node status:
|
||||
|
||||
```graphql
|
||||
{
|
||||
getStatus {
|
||||
version
|
||||
node {
|
||||
id
|
||||
network
|
||||
moniker
|
||||
}
|
||||
sync {
|
||||
latest_block_height
|
||||
catching_up
|
||||
}
|
||||
num_peers
|
||||
peers {
|
||||
is_outbound
|
||||
remote_ip
|
||||
}
|
||||
disk_usage
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Full node status:
|
||||
|
||||
```graphql
|
||||
{
|
||||
getStatus {
|
||||
version
|
||||
node {
|
||||
id
|
||||
network
|
||||
moniker
|
||||
}
|
||||
sync {
|
||||
latest_block_hash
|
||||
latest_block_time
|
||||
latest_block_height
|
||||
catching_up
|
||||
}
|
||||
validator {
|
||||
address
|
||||
voting_power
|
||||
proposer_priority
|
||||
}
|
||||
validators {
|
||||
address
|
||||
voting_power
|
||||
proposer_priority
|
||||
}
|
||||
num_peers
|
||||
peers {
|
||||
node {
|
||||
id
|
||||
network
|
||||
moniker
|
||||
}
|
||||
is_outbound
|
||||
remote_ip
|
||||
}
|
||||
disk_usage
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Get records by IDs.
|
||||
|
||||
```graphql
|
||||
{
|
||||
getRecordsByIds(ids: ["QmYDtNCKtTu6u6jaHaFAC5PWZXcj7fAmry6NoWwMaixFHz"]) {
|
||||
id
|
||||
names
|
||||
bondId
|
||||
createTime
|
||||
expiryTime
|
||||
owners
|
||||
attributes {
|
||||
key
|
||||
value {
|
||||
string
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Query records.
|
||||
|
||||
```graphql
|
||||
{
|
||||
queryRecords(attributes: [{ key: "type", value: { string: "wrn:bot" } }]) {
|
||||
id
|
||||
names
|
||||
bondId
|
||||
createTime
|
||||
expiryTime
|
||||
owners
|
||||
attributes {
|
||||
key
|
||||
value {
|
||||
string
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Get account details:
|
||||
|
||||
```graphql
|
||||
{
|
||||
getAccounts(addresses: ["cosmos1wh8vvd0ymc5nt37h29z8kk2g2ays45ct2qu094"]) {
|
||||
address
|
||||
pubKey
|
||||
number
|
||||
sequence
|
||||
balance {
|
||||
type
|
||||
quantity
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Query bonds:
|
||||
|
||||
```graphql
|
||||
{
|
||||
queryBonds(
|
||||
attributes: [
|
||||
{
|
||||
key: "owner"
|
||||
value: { string: "cosmos1wh8vvd0ymc5nt37h29z8kk2g2ays45ct2qu094" }
|
||||
}
|
||||
]
|
||||
) {
|
||||
id
|
||||
owner
|
||||
balance {
|
||||
type
|
||||
quantity
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Get bonds by IDs.
|
||||
|
||||
```graphql
|
||||
{
|
||||
getBondsByIds(ids :
|
||||
[
|
||||
"1c2b677cb2a27c88cc6bf8acf675c94b69051125b40c4fd073153b10f046dd87",
|
||||
"c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440"
|
||||
])
|
||||
{
|
||||
id
|
||||
owner
|
||||
balance{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Query Bonds by Owner
|
||||
|
||||
```graphql
|
||||
{
|
||||
queryBondsByOwner(ownerAddresses: ["ethm1mfdjngh5jvjs9lqtt9a7y2hlgw8v3syh3hsqzk"])
|
||||
{
|
||||
owner
|
||||
bonds{
|
||||
id
|
||||
owner
|
||||
balance
|
||||
{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Query auctions by ids
|
||||
|
||||
```graphql
|
||||
{
|
||||
getAuctionsByIds(ids: ["be98f2073c246194276554eefdb4c95b682a35a0f06fbe619a6da57c10c93e90"]){
|
||||
id
|
||||
ownerAddress
|
||||
createTime
|
||||
minimumBid{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
commitFee{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
commitsEndTime
|
||||
revealFee{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
revealsEndTime
|
||||
winnerBid{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
winnerPrice{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
winnerAddress
|
||||
bids{
|
||||
bidderAddress
|
||||
commitHash
|
||||
commitTime
|
||||
commitFee{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
revealFee{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
revealTime
|
||||
bidAmount{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
status
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
LookUp Authorities
|
||||
|
||||
```graphql
|
||||
{
|
||||
lookupAuthorities(names: []){
|
||||
ownerAddress
|
||||
ownerAddress
|
||||
height
|
||||
bondId
|
||||
status
|
||||
expiryTime
|
||||
auction {
|
||||
id
|
||||
ownerAddress
|
||||
createTime
|
||||
minimumBid{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
commitFee{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
commitsEndTime
|
||||
revealFee{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
revealsEndTime
|
||||
winnerBid{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
winnerPrice{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
winnerAddress
|
||||
bids{
|
||||
bidderAddress
|
||||
commitHash
|
||||
commitTime
|
||||
commitFee{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
revealFee{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
revealTime
|
||||
bidAmount{
|
||||
type
|
||||
quantity
|
||||
}
|
||||
status
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
LookUp Names
|
||||
|
||||
```graphql
|
||||
{
|
||||
lookupNames(names: ["wrn://hello/test"]){
|
||||
latest{
|
||||
id
|
||||
height
|
||||
}
|
||||
history{
|
||||
id
|
||||
height
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Resolve Names
|
||||
|
||||
```graphql
|
||||
{
|
||||
resolveNames(names: ["asd"]){
|
||||
id
|
||||
names
|
||||
bondId
|
||||
createTime
|
||||
expiryTime
|
||||
owners
|
||||
attributes {
|
||||
key
|
||||
value {
|
||||
string
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
8781
gql/generated.go
Normal file
8781
gql/generated.go
Normal file
File diff suppressed because it is too large
Load Diff
14
gql/gqlgen.yml
Normal file
14
gql/gqlgen.yml
Normal file
@ -0,0 +1,14 @@
|
||||
# .gqlgen.yml example
|
||||
#
|
||||
# Refer to https://gqlgen.com/config/
|
||||
# for detailed .gqlgen.yml documentation.
|
||||
|
||||
schema:
|
||||
- vulcanize/dxns/*.graphql
|
||||
exec:
|
||||
filename: generated.go
|
||||
model:
|
||||
filename: models_gen.go
|
||||
resolver:
|
||||
filename: resolver.go
|
||||
type: Resolver
|
160
gql/models_gen.go
Normal file
160
gql/models_gen.go
Normal file
@ -0,0 +1,160 @@
|
||||
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
|
||||
|
||||
package gql
|
||||
|
||||
type Account struct {
|
||||
Address string `json:"address"`
|
||||
PubKey *string `json:"pubKey"`
|
||||
Number string `json:"number"`
|
||||
Sequence string `json:"sequence"`
|
||||
Balance []*Coin `json:"balance"`
|
||||
}
|
||||
|
||||
type Auction struct {
|
||||
ID string `json:"id"`
|
||||
Status string `json:"status"`
|
||||
OwnerAddress string `json:"ownerAddress"`
|
||||
CreateTime string `json:"createTime"`
|
||||
CommitsEndTime string `json:"commitsEndTime"`
|
||||
RevealsEndTime string `json:"revealsEndTime"`
|
||||
CommitFee *Coin `json:"commitFee"`
|
||||
RevealFee *Coin `json:"revealFee"`
|
||||
MinimumBid *Coin `json:"minimumBid"`
|
||||
WinnerAddress string `json:"winnerAddress"`
|
||||
WinnerBid *Coin `json:"winnerBid"`
|
||||
WinnerPrice *Coin `json:"winnerPrice"`
|
||||
Bids []*AuctionBid `json:"bids"`
|
||||
}
|
||||
|
||||
type AuctionBid struct {
|
||||
BidderAddress string `json:"bidderAddress"`
|
||||
Status string `json:"status"`
|
||||
CommitHash string `json:"commitHash"`
|
||||
CommitTime string `json:"commitTime"`
|
||||
CommitFee *Coin `json:"commitFee"`
|
||||
RevealTime string `json:"revealTime"`
|
||||
RevealFee *Coin `json:"revealFee"`
|
||||
BidAmount *Coin `json:"bidAmount"`
|
||||
}
|
||||
|
||||
type AuthorityRecord struct {
|
||||
OwnerAddress string `json:"ownerAddress"`
|
||||
OwnerPublicKey string `json:"ownerPublicKey"`
|
||||
Height string `json:"height"`
|
||||
Status string `json:"status"`
|
||||
BondID string `json:"bondId"`
|
||||
ExpiryTime string `json:"expiryTime"`
|
||||
Auction *Auction `json:"auction"`
|
||||
}
|
||||
|
||||
type Bond struct {
|
||||
ID string `json:"id"`
|
||||
Owner string `json:"owner"`
|
||||
Balance []*Coin `json:"balance"`
|
||||
}
|
||||
|
||||
type Coin struct {
|
||||
Type string `json:"type"`
|
||||
Quantity string `json:"quantity"`
|
||||
}
|
||||
|
||||
type KeyValue struct {
|
||||
Key string `json:"key"`
|
||||
Value *Value `json:"value"`
|
||||
}
|
||||
|
||||
type KeyValueInput struct {
|
||||
Key string `json:"key"`
|
||||
Value *ValueInput `json:"value"`
|
||||
}
|
||||
|
||||
type NameRecord struct {
|
||||
Latest *NameRecordEntry `json:"latest"`
|
||||
History []*NameRecordEntry `json:"history"`
|
||||
}
|
||||
|
||||
type NameRecordEntry struct {
|
||||
ID string `json:"id"`
|
||||
Height string `json:"height"`
|
||||
}
|
||||
|
||||
type NodeInfo struct {
|
||||
ID string `json:"id"`
|
||||
Network string `json:"network"`
|
||||
Moniker string `json:"moniker"`
|
||||
}
|
||||
|
||||
type OwnerBonds struct {
|
||||
Owner string `json:"owner"`
|
||||
Bonds []*Bond `json:"bonds"`
|
||||
}
|
||||
|
||||
type PeerInfo struct {
|
||||
Node *NodeInfo `json:"node"`
|
||||
IsOutbound bool `json:"is_outbound"`
|
||||
RemoteIP string `json:"remote_ip"`
|
||||
}
|
||||
|
||||
type Record struct {
|
||||
ID string `json:"id"`
|
||||
Names []string `json:"names"`
|
||||
BondID string `json:"bondId"`
|
||||
CreateTime string `json:"createTime"`
|
||||
ExpiryTime string `json:"expiryTime"`
|
||||
Owners []string `json:"owners"`
|
||||
Attributes []*KeyValue `json:"attributes"`
|
||||
References []*Record `json:"references"`
|
||||
}
|
||||
|
||||
type Reference struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
type ReferenceInput struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
type Status struct {
|
||||
Version string `json:"version"`
|
||||
Node *NodeInfo `json:"node"`
|
||||
Sync *SyncInfo `json:"sync"`
|
||||
Validator *ValidatorInfo `json:"validator"`
|
||||
Validators []*ValidatorInfo `json:"validators"`
|
||||
NumPeers string `json:"num_peers"`
|
||||
Peers []*PeerInfo `json:"peers"`
|
||||
DiskUsage string `json:"disk_usage"`
|
||||
}
|
||||
|
||||
type SyncInfo struct {
|
||||
LatestBlockHash string `json:"latest_block_hash"`
|
||||
LatestBlockHeight string `json:"latest_block_height"`
|
||||
LatestBlockTime string `json:"latest_block_time"`
|
||||
CatchingUp bool `json:"catching_up"`
|
||||
}
|
||||
|
||||
type ValidatorInfo struct {
|
||||
Address string `json:"address"`
|
||||
VotingPower string `json:"voting_power"`
|
||||
ProposerPriority *string `json:"proposer_priority"`
|
||||
}
|
||||
|
||||
type Value struct {
|
||||
Null *bool `json:"null"`
|
||||
Int *int `json:"int"`
|
||||
Float *float64 `json:"float"`
|
||||
String *string `json:"string"`
|
||||
Boolean *bool `json:"boolean"`
|
||||
JSON *string `json:"json"`
|
||||
Reference *Reference `json:"reference"`
|
||||
Values []*Value `json:"values"`
|
||||
}
|
||||
|
||||
type ValueInput struct {
|
||||
Null *bool `json:"null"`
|
||||
Int *int `json:"int"`
|
||||
Float *float64 `json:"float"`
|
||||
String *string `json:"string"`
|
||||
Boolean *bool `json:"boolean"`
|
||||
Reference *ReferenceInput `json:"reference"`
|
||||
Values []*ValueInput `json:"values"`
|
||||
}
|
335
gql/resolver.go
Normal file
335
gql/resolver.go
Normal file
@ -0,0 +1,335 @@
|
||||
package gql
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
auctiontypes "github.com/tharsis/ethermint/x/auction/types"
|
||||
bondtypes "github.com/tharsis/ethermint/x/bond/types"
|
||||
nstypes "github.com/tharsis/ethermint/x/nameservice/types"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// DefaultLogNumLines is the number of log lines to tail by default.
|
||||
const DefaultLogNumLines = 50
|
||||
|
||||
// MaxLogNumLines is the max number of log lines that can be tailed.
|
||||
const MaxLogNumLines = 1000
|
||||
|
||||
type Resolver struct {
|
||||
ctx client.Context
|
||||
logFile string
|
||||
}
|
||||
|
||||
// Query is the entry point to query execution.
|
||||
func (r *Resolver) Query() QueryResolver {
|
||||
return &queryResolver{r}
|
||||
}
|
||||
|
||||
type queryResolver struct{ *Resolver }
|
||||
|
||||
func (q queryResolver) LookupAuthorities(ctx context.Context, names []string) ([]*AuthorityRecord, error) {
|
||||
nsQueryClient := nstypes.NewQueryClient(q.ctx)
|
||||
auctionQueryClient := auctiontypes.NewQueryClient(q.ctx)
|
||||
var gqlResponse []*AuthorityRecord
|
||||
|
||||
for _, name := range names {
|
||||
res, err := nsQueryClient.Whois(context.Background(), &nstypes.QueryWhoisRequest{Name: name})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
nameAuthority := res.GetNameAuthority()
|
||||
gqlNameAuthorityRecord, err := GetGQLNameAuthorityRecord(&nameAuthority)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if nameAuthority.AuctionId == "" {
|
||||
auctionResp, err := auctionQueryClient.GetAuction(context.Background(), &auctiontypes.AuctionRequest{Id: nameAuthority.GetAuctionId()})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
bidsResp, err := auctionQueryClient.GetBids(context.Background(), &auctiontypes.BidsRequest{AuctionId: nameAuthority.GetAuctionId()})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gqlAuctionRecord, err := GetGQLAuction(auctionResp.GetAuction(), bidsResp.GetBids())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gqlNameAuthorityRecord.Auction = gqlAuctionRecord
|
||||
}
|
||||
|
||||
gqlResponse = append(gqlResponse, gqlNameAuthorityRecord)
|
||||
}
|
||||
|
||||
return gqlResponse, nil
|
||||
}
|
||||
|
||||
func (q queryResolver) ResolveNames(ctx context.Context, names []string) ([]*Record, error) {
|
||||
nsQueryClient := nstypes.NewQueryClient(q.ctx)
|
||||
var gqlResponse []*Record
|
||||
for _, name := range names {
|
||||
res, err := nsQueryClient.ResolveWrn(context.Background(), &nstypes.QueryResolveWrn{Wrn: name})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gqlRecord, err := getGQLRecord(context.Background(), q, *res.GetRecord())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gqlResponse = append(gqlResponse, gqlRecord)
|
||||
}
|
||||
|
||||
return gqlResponse, nil
|
||||
}
|
||||
|
||||
func (q queryResolver) LookupNames(ctx context.Context, names []string) ([]*NameRecord, error) {
|
||||
nsQueryClient := nstypes.NewQueryClient(q.ctx)
|
||||
var gqlResponse []*NameRecord
|
||||
|
||||
for _, name := range names {
|
||||
res, err := nsQueryClient.LookupWrn(context.Background(), &nstypes.QueryLookupWrn{Wrn: name})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gqlRecord, err := getGQLNameRecord(res.GetName())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gqlResponse = append(gqlResponse, gqlRecord)
|
||||
}
|
||||
|
||||
return gqlResponse, nil
|
||||
}
|
||||
|
||||
func (q queryResolver) QueryRecords(ctx context.Context, attributes []*KeyValueInput, all *bool) ([]*Record, error) {
|
||||
nsQueryClient := nstypes.NewQueryClient(q.ctx)
|
||||
res, err := nsQueryClient.ListRecords(context.Background(), &nstypes.QueryListRecordsRequest{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
records := res.GetRecords()
|
||||
gqlResponse := make([]*Record, len(records))
|
||||
|
||||
for i, record := range records {
|
||||
gqlRecord, err := getGQLRecord(context.Background(), q, record)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
gqlResponse[i] = gqlRecord
|
||||
}
|
||||
|
||||
return gqlResponse, nil
|
||||
|
||||
}
|
||||
|
||||
func (q queryResolver) GetRecordsByIds(ctx context.Context, ids []string) ([]*Record, error) {
|
||||
nsQueryClient := nstypes.NewQueryClient(q.ctx)
|
||||
gqlResponse := make([]*Record, len(ids))
|
||||
|
||||
for i, id := range ids {
|
||||
res, err := nsQueryClient.GetRecord(context.Background(), &nstypes.QueryRecordByIdRequest{Id: id})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
record, err := getGQLRecord(context.Background(), q, res.GetRecord())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
gqlResponse[i] = record
|
||||
}
|
||||
|
||||
return gqlResponse, nil
|
||||
}
|
||||
|
||||
func (q queryResolver) GetStatus(ctx context.Context) (*Status, error) {
|
||||
nodeInfo, syncInfo, validatorInfo, err := getStatusInfo(q.ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
numPeers, peers, err := getNetInfo(q.ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
validatorSet, err := getValidatorSet(q.ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
diskUsage, err := GetDiskUsage(NodeDataPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Status{
|
||||
Version: NameServiceVersion,
|
||||
Node: nodeInfo,
|
||||
Sync: syncInfo,
|
||||
Validator: validatorInfo,
|
||||
Validators: validatorSet,
|
||||
NumPeers: numPeers,
|
||||
Peers: peers,
|
||||
DiskUsage: diskUsage,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (q queryResolver) GetAccounts(ctx context.Context, addresses []string) ([]*Account, error) {
|
||||
accounts := make([]*Account, len(addresses))
|
||||
for index, address := range addresses {
|
||||
account, err := q.GetAccount(ctx, address)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
accounts[index] = account
|
||||
}
|
||||
return accounts, nil
|
||||
}
|
||||
|
||||
func (q queryResolver) GetAccount(ctx context.Context, address string) (*Account, error) {
|
||||
authQueryClient := authtypes.NewQueryClient(q.ctx)
|
||||
accountResponse, err := authQueryClient.Account(ctx, &authtypes.QueryAccountRequest{Address: address})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var account authtypes.AccountI
|
||||
err = q.ctx.Codec.UnpackAny(accountResponse.GetAccount(), &account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var pubKey *string
|
||||
if account.GetPubKey() != nil {
|
||||
pubKeyStr := base64.StdEncoding.EncodeToString(account.GetPubKey().Bytes())
|
||||
pubKey = &pubKeyStr
|
||||
}
|
||||
|
||||
// Get the account balance
|
||||
bankQueryClient := banktypes.NewQueryClient(q.ctx)
|
||||
balance, err := bankQueryClient.AllBalances(ctx, &banktypes.QueryAllBalancesRequest{Address: address})
|
||||
|
||||
accNum := strconv.FormatUint(account.GetAccountNumber(), 10)
|
||||
seq := strconv.FormatUint(account.GetSequence(), 10)
|
||||
|
||||
return &Account{
|
||||
Address: address,
|
||||
Number: accNum,
|
||||
Sequence: seq,
|
||||
PubKey: pubKey,
|
||||
Balance: getGQLCoins(balance.GetBalances()),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (q queryResolver) GetBondsByIds(ctx context.Context, ids []string) ([]*Bond, error) {
|
||||
bonds := make([]*Bond, len(ids))
|
||||
for index, id := range ids {
|
||||
bondObj, err := q.GetBond(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
bonds[index] = bondObj
|
||||
}
|
||||
|
||||
return bonds, nil
|
||||
}
|
||||
|
||||
func (q *queryResolver) GetBond(ctx context.Context, id string) (*Bond, error) {
|
||||
bondQueryClient := bondtypes.NewQueryClient(q.ctx)
|
||||
bondResp, err := bondQueryClient.GetBondById(context.Background(), &bondtypes.QueryGetBondByIdRequest{Id: id})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bond := bondResp.GetBond()
|
||||
if bond == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return getGQLBond(bondResp.GetBond())
|
||||
}
|
||||
|
||||
func (q queryResolver) QueryBonds(ctx context.Context, attributes []*KeyValueInput) ([]*Bond, error) {
|
||||
bondQueryClient := bondtypes.NewQueryClient(q.ctx)
|
||||
bonds, err := bondQueryClient.Bonds(context.Background(), &bondtypes.QueryGetBondsRequest{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gqlResponse := make([]*Bond, len(bonds.GetBonds()))
|
||||
for i, bondObj := range bonds.GetBonds() {
|
||||
gqlBond, err := getGQLBond(bondObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
gqlResponse[i] = gqlBond
|
||||
}
|
||||
|
||||
return gqlResponse, nil
|
||||
}
|
||||
|
||||
// QueryBondsByOwner will return bonds by owner
|
||||
func (q queryResolver) QueryBondsByOwner(ctx context.Context, ownerAddresses []string) ([]*OwnerBonds, error) {
|
||||
ownerBonds := make([]*OwnerBonds, len(ownerAddresses))
|
||||
for index, ownerAddress := range ownerAddresses {
|
||||
bondsObj, err := q.GetBondsByOwner(ctx, ownerAddress)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ownerBonds[index] = bondsObj
|
||||
}
|
||||
|
||||
return ownerBonds, nil
|
||||
}
|
||||
|
||||
func (q queryResolver) GetBondsByOwner(ctx context.Context, address string) (*OwnerBonds, error) {
|
||||
bondQueryClient := bondtypes.NewQueryClient(q.ctx)
|
||||
bondResp, err := bondQueryClient.GetBondsByOwner(context.Background(), &bondtypes.QueryGetBondsByOwnerRequest{Owner: address})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ownerBonds := make([]*Bond, len(bondResp.GetBonds()))
|
||||
for i, bond := range bondResp.GetBonds() {
|
||||
bondObj, err := getGQLBond(&bond)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ownerBonds[i] = bondObj
|
||||
}
|
||||
|
||||
return &OwnerBonds{Bonds: ownerBonds, Owner: address}, nil
|
||||
}
|
||||
|
||||
func (q queryResolver) GetAuctionsByIds(ctx context.Context, ids []string) ([]*Auction, error) {
|
||||
auctionQueryClient := auctiontypes.NewQueryClient(q.ctx)
|
||||
gqlAuctionResponse := make([]*Auction, len(ids))
|
||||
for i, id := range ids {
|
||||
auctionObj, err := auctionQueryClient.GetAuction(context.Background(), &auctiontypes.AuctionRequest{Id: id})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
bidsObj, err := auctionQueryClient.GetBids(context.Background(), &auctiontypes.BidsRequest{AuctionId: id})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gqlAuction, err := GetGQLAuction(auctionObj.GetAuction(), bidsObj.GetBids())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gqlAuctionResponse[i] = gqlAuction
|
||||
}
|
||||
|
||||
return gqlAuctionResponse, nil
|
||||
}
|
44
gql/server.go
Normal file
44
gql/server.go
Normal file
@ -0,0 +1,44 @@
|
||||
package gql
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/99designs/gqlgen/graphql/handler"
|
||||
"github.com/99designs/gqlgen/graphql/playground"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/spf13/viper"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Server configures and starts the GQL server.
|
||||
func Server(ctx client.Context) {
|
||||
if !viper.GetBool("gql-server") {
|
||||
return
|
||||
}
|
||||
logFile := viper.GetString("log-file")
|
||||
|
||||
port := viper.GetString("gql-port")
|
||||
|
||||
srv := handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: &Resolver{
|
||||
ctx: ctx,
|
||||
logFile: logFile,
|
||||
}}))
|
||||
|
||||
http.Handle("/", playground.Handler("GraphQL playground", "/api"))
|
||||
|
||||
if viper.GetBool("gql-playground") {
|
||||
apiBase := viper.GetString("gql-playground-api-base")
|
||||
|
||||
http.Handle("/webui", playground.Handler("GraphQL playground", apiBase+"/api"))
|
||||
http.Handle("/console", playground.Handler("GraphQL playground", apiBase+"/graphql"))
|
||||
}
|
||||
|
||||
http.Handle("/api", srv)
|
||||
http.Handle("/graphql", srv)
|
||||
|
||||
log.Info("Connect to GraphQL playground", "url", fmt.Sprintf("http://localhost:%s", port))
|
||||
err := http.ListenAndServe(":"+port, nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
99
gql/status.go
Normal file
99
gql/status.go
Normal file
@ -0,0 +1,99 @@
|
||||
package gql
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// NodeDataPath is the path to the ethermintd data folder.
|
||||
var NodeDataPath = os.ExpandEnv("$HOME/.ethermintd/data")
|
||||
|
||||
func getStatusInfo(client client.Context) (*NodeInfo, *SyncInfo, *ValidatorInfo, error) {
|
||||
nodeClient, err := client.GetNode()
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
nodeStatus, err := nodeClient.Status(context.Background())
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
return &NodeInfo{
|
||||
ID: string(nodeStatus.NodeInfo.ID()),
|
||||
Network: nodeStatus.NodeInfo.Network,
|
||||
Moniker: nodeStatus.NodeInfo.Moniker,
|
||||
}, &SyncInfo{
|
||||
LatestBlockHash: nodeStatus.SyncInfo.LatestBlockHash.String(),
|
||||
LatestBlockHeight: strconv.FormatInt(nodeStatus.SyncInfo.LatestBlockHeight, 10),
|
||||
LatestBlockTime: nodeStatus.SyncInfo.LatestBlockTime.String(),
|
||||
CatchingUp: nodeStatus.SyncInfo.CatchingUp,
|
||||
}, &ValidatorInfo{
|
||||
Address: nodeStatus.ValidatorInfo.Address.String(),
|
||||
VotingPower: strconv.FormatInt(nodeStatus.ValidatorInfo.VotingPower, 10),
|
||||
ProposerPriority: nil,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func getNetInfo(client client.Context) (string, []*PeerInfo, error) {
|
||||
nodeClient, err := client.GetNode()
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
netInfo, err := nodeClient.NetInfo(context.Background())
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
|
||||
peers := netInfo.Peers
|
||||
peersInfo := make([]*PeerInfo, len(peers))
|
||||
for index, peer := range peers {
|
||||
peersInfo[index] = &PeerInfo{
|
||||
Node: &NodeInfo{
|
||||
ID: string(peer.NodeInfo.ID()),
|
||||
Moniker: peer.NodeInfo.Moniker,
|
||||
Network: peer.NodeInfo.Network,
|
||||
},
|
||||
IsOutbound: peer.IsOutbound,
|
||||
RemoteIP: peer.RemoteIP,
|
||||
}
|
||||
}
|
||||
|
||||
return strconv.FormatInt(int64(netInfo.NPeers), 10), peersInfo, nil
|
||||
}
|
||||
|
||||
func getValidatorSet(client client.Context) ([]*ValidatorInfo, error) {
|
||||
nodeClient, err := client.GetNode()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res, err := nodeClient.Validators(context.Background(), nil, nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
validatorSet := make([]*ValidatorInfo, len(res.Validators))
|
||||
for index, validator := range res.Validators {
|
||||
proposerPriority := strconv.FormatInt(validator.ProposerPriority, 10)
|
||||
validatorSet[index] = &ValidatorInfo{
|
||||
Address: validator.Address.String(),
|
||||
VotingPower: strconv.FormatInt(validator.VotingPower, 10),
|
||||
ProposerPriority: &proposerPriority,
|
||||
}
|
||||
}
|
||||
|
||||
return validatorSet, nil
|
||||
}
|
||||
|
||||
// GetDiskUsage returns disk usage for the given path.
|
||||
func GetDiskUsage(dirPath string) (string, error) {
|
||||
out, err := exec.Command("du", "-sh", dirPath).Output()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return strings.Fields(string(out))[0], nil
|
||||
}
|
267
gql/util.go
Normal file
267
gql/util.go
Normal file
@ -0,0 +1,267 @@
|
||||
package gql
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
auctiontypes "github.com/tharsis/ethermint/x/auction/types"
|
||||
bondtypes "github.com/tharsis/ethermint/x/bond/types"
|
||||
nstypes "github.com/tharsis/ethermint/x/nameservice/types"
|
||||
"reflect"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// OwnerAttributeName denotes the owner attribute name for a bond.
|
||||
const OwnerAttributeName = "owner"
|
||||
|
||||
// BondIDAttributeName denotes the record bond ID.
|
||||
const BondIDAttributeName = "bondId"
|
||||
|
||||
// ExpiryTimeAttributeName denotes the record expiry time.
|
||||
const ExpiryTimeAttributeName = "expiryTime"
|
||||
|
||||
func getGQLCoin(coin sdk.Coin) *Coin {
|
||||
gqlCoin := Coin{
|
||||
Type: coin.Denom,
|
||||
Quantity: strconv.FormatInt(coin.Amount.Int64(), 10),
|
||||
}
|
||||
|
||||
return &gqlCoin
|
||||
}
|
||||
|
||||
func getGQLCoins(coins sdk.Coins) []*Coin {
|
||||
gqlCoins := make([]*Coin, len(coins))
|
||||
for index, coin := range coins {
|
||||
gqlCoins[index] = getGQLCoin(coin)
|
||||
}
|
||||
|
||||
return gqlCoins
|
||||
}
|
||||
func GetGQLNameAuthorityRecord(record *nstypes.NameAuthority) (*AuthorityRecord, error) {
|
||||
if record == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return &AuthorityRecord{
|
||||
OwnerAddress: record.OwnerAddress,
|
||||
OwnerPublicKey: record.OwnerPublicKey,
|
||||
Height: strconv.FormatUint(record.Height, 10),
|
||||
Status: record.Status,
|
||||
BondID: record.GetBondId(),
|
||||
ExpiryTime: record.GetExpiryTime().String(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func getGQLRecord(ctx context.Context, resolver QueryResolver, record nstypes.Record) (*Record, error) {
|
||||
// Nil record.
|
||||
if record.Deleted {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
recordType := record.ToRecordType()
|
||||
attributes, err := getAttributes(&recordType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
references, err := getReferences(ctx, resolver, &recordType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Record{
|
||||
ID: record.Id,
|
||||
BondID: record.GetBondId(),
|
||||
CreateTime: record.GetCreateTime().String(),
|
||||
ExpiryTime: record.GetExpiryTime().String(),
|
||||
Owners: record.GetOwners(),
|
||||
Attributes: attributes,
|
||||
References: references,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func getGQLNameRecord(record *nstypes.NameRecord) (*NameRecord, error) {
|
||||
if record == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
records := make([]*NameRecordEntry, len(record.History))
|
||||
for index, entry := range record.History {
|
||||
records[index] = getNameRecordEntry(entry)
|
||||
}
|
||||
|
||||
return &NameRecord{
|
||||
Latest: getNameRecordEntry(record.Latest),
|
||||
History: records,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func getNameRecordEntry(record *nstypes.NameRecordEntry) *NameRecordEntry {
|
||||
return &NameRecordEntry{
|
||||
ID: record.Id,
|
||||
Height: strconv.FormatUint(record.Height, 10),
|
||||
}
|
||||
}
|
||||
|
||||
func getGQLBond(bondObj *bondtypes.Bond) (*Bond, error) {
|
||||
// Nil record.
|
||||
if bondObj == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return &Bond{
|
||||
ID: bondObj.Id,
|
||||
Owner: bondObj.Owner,
|
||||
Balance: getGQLCoins(bondObj.Balance),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func matchBondOnAttributes(bondObj *bondtypes.Bond, attributes []*KeyValueInput) bool {
|
||||
for _, attr := range attributes {
|
||||
switch attr.Key {
|
||||
case OwnerAttributeName:
|
||||
{
|
||||
if attr.Value.String == nil || bondObj.Owner != *attr.Value.String {
|
||||
return false
|
||||
}
|
||||
}
|
||||
default:
|
||||
{
|
||||
// Only attributes explicitly listed in the switch are queryable.
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func getAuctionBid(bid *auctiontypes.Bid) *AuctionBid {
|
||||
return &AuctionBid{
|
||||
BidderAddress: bid.BidderAddress,
|
||||
Status: bid.Status,
|
||||
CommitHash: bid.CommitHash,
|
||||
CommitTime: bid.GetCommitTime(),
|
||||
RevealTime: bid.GetRevealTime(),
|
||||
CommitFee: getGQLCoin(bid.CommitFee),
|
||||
RevealFee: getGQLCoin(bid.RevealFee),
|
||||
BidAmount: getGQLCoin(bid.BidAmount),
|
||||
}
|
||||
}
|
||||
|
||||
func GetGQLAuction(auction *auctiontypes.Auction, bids []*auctiontypes.Bid) (*Auction, error) {
|
||||
if auction == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
gqlAuction := Auction{
|
||||
ID: auction.Id,
|
||||
Status: auction.Status,
|
||||
OwnerAddress: auction.OwnerAddress,
|
||||
CreateTime: auction.GetCreateTime(),
|
||||
CommitsEndTime: auction.GetCommitsEndTime(),
|
||||
RevealsEndTime: auction.GetRevealsEndTime(),
|
||||
CommitFee: getGQLCoin(auction.CommitFee),
|
||||
RevealFee: getGQLCoin(auction.RevealFee),
|
||||
MinimumBid: getGQLCoin(auction.MinimumBid),
|
||||
WinnerAddress: auction.WinnerAddress,
|
||||
WinnerBid: getGQLCoin(auction.WinningBid),
|
||||
WinnerPrice: getGQLCoin(auction.WinningPrice),
|
||||
}
|
||||
|
||||
auctionBids := make([]*AuctionBid, len(bids))
|
||||
for index, entry := range bids {
|
||||
auctionBids[index] = getAuctionBid(entry)
|
||||
}
|
||||
|
||||
gqlAuction.Bids = auctionBids
|
||||
|
||||
return &gqlAuction, nil
|
||||
}
|
||||
|
||||
func getReferences(ctx context.Context, resolver QueryResolver, r *nstypes.RecordType) ([]*Record, error) {
|
||||
var ids []string
|
||||
|
||||
for _, value := range r.Attributes {
|
||||
switch value.(type) {
|
||||
case interface{}:
|
||||
if obj, ok := value.(map[string]interface{}); ok {
|
||||
if _, ok := obj["/"]; ok && len(obj) == 1 {
|
||||
if _, ok := obj["/"].(string); ok {
|
||||
ids = append(ids, obj["/"].(string))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resolver.GetRecordsByIds(ctx, ids)
|
||||
}
|
||||
|
||||
func getAttributes(r *nstypes.RecordType) ([]*KeyValue, error) {
|
||||
return mapToKeyValuePairs(r.Attributes)
|
||||
}
|
||||
|
||||
func mapToKeyValuePairs(attrs map[string]interface{}) ([]*KeyValue, error) {
|
||||
var kvPairs []*KeyValue
|
||||
|
||||
trueVal := true
|
||||
falseVal := false
|
||||
|
||||
for key, value := range attrs {
|
||||
kvPair := &KeyValue{
|
||||
Key: key,
|
||||
Value: &Value{},
|
||||
}
|
||||
|
||||
switch val := value.(type) {
|
||||
case nil:
|
||||
kvPair.Value.Null = &trueVal
|
||||
case int:
|
||||
kvPair.Value.Int = &val
|
||||
case float64:
|
||||
kvPair.Value.Float = &val
|
||||
case string:
|
||||
kvPair.Value.String = &val
|
||||
case bool:
|
||||
kvPair.Value.Boolean = &val
|
||||
case interface{}:
|
||||
if obj, ok := value.(map[string]interface{}); ok {
|
||||
if _, ok := obj["/"]; ok && len(obj) == 1 {
|
||||
if _, ok := obj["/"].(string); ok {
|
||||
kvPair.Value.Reference = &Reference{
|
||||
ID: obj["/"].(string),
|
||||
}
|
||||
}
|
||||
} else {
|
||||
bytes, err := json.Marshal(obj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
jsonStr := string(bytes)
|
||||
kvPair.Value.JSON = &jsonStr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if kvPair.Value.Null == nil {
|
||||
kvPair.Value.Null = &falseVal
|
||||
}
|
||||
|
||||
valueType := reflect.ValueOf(value)
|
||||
if valueType.Kind() == reflect.Slice {
|
||||
bytes, err := json.Marshal(value)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
jsonStr := string(bytes)
|
||||
kvPair.Value.JSON = &jsonStr
|
||||
}
|
||||
|
||||
kvPairs = append(kvPairs, kvPair)
|
||||
}
|
||||
|
||||
return kvPairs, nil
|
||||
}
|
4
gql/version.go
Normal file
4
gql/version.go
Normal file
@ -0,0 +1,4 @@
|
||||
package gql
|
||||
|
||||
// NameServiceVersion is the registry API version.
|
||||
const NameServiceVersion = "0.3.0"
|
260
gql/vulcanize/dxns/schema.graphql
Normal file
260
gql/vulcanize/dxns/schema.graphql
Normal file
@ -0,0 +1,260 @@
|
||||
# Reference to another record.
|
||||
type Reference {
|
||||
id: String! # ID of linked record.
|
||||
}
|
||||
|
||||
# Reference to another record.
|
||||
input ReferenceInput {
|
||||
id: String!
|
||||
}
|
||||
|
||||
# Bonds contain funds that are used to pay rent on record registration and renewal.
|
||||
type Bond {
|
||||
id: String! # Primary key, auto-generated by the server.
|
||||
owner: String! # Bond owner cosmos-sdk address.
|
||||
balance: [Coin!] # Current balance for each coin type.
|
||||
}
|
||||
|
||||
# OwnerBonds contains the bonds related the owner
|
||||
type OwnerBonds {
|
||||
owner: String!
|
||||
bonds: [Bond!]
|
||||
}
|
||||
|
||||
# Mutations require payment in coins (e.g. 100wire).
|
||||
# Used by the wallet to get the account balance for display and mutations.
|
||||
type Coin {
|
||||
type: String! # e.g. 'WIRE'
|
||||
quantity: String! # e.g. 1000000
|
||||
}
|
||||
# Represents an account on the blockchain.
|
||||
# Mutations have to be signed by a particular account.
|
||||
type Account {
|
||||
address: String! # Blockchain address.
|
||||
pubKey: String # Public key.
|
||||
number: String! # Account number.
|
||||
sequence: String! # Sequence number used to prevent replays.
|
||||
balance: [Coin!] # Current balance for each coin type.
|
||||
}
|
||||
|
||||
# Value of a given type.
|
||||
type Value {
|
||||
null: Boolean
|
||||
|
||||
int: Int
|
||||
float: Float
|
||||
string: String
|
||||
boolean: Boolean
|
||||
json: String
|
||||
|
||||
reference: Reference
|
||||
|
||||
values: [Value]
|
||||
}
|
||||
# Value of a given type used as input to queries.
|
||||
input ValueInput {
|
||||
null: Boolean
|
||||
|
||||
int: Int
|
||||
float: Float
|
||||
string: String
|
||||
boolean: Boolean
|
||||
|
||||
reference: ReferenceInput
|
||||
|
||||
values: [ValueInput]
|
||||
}
|
||||
|
||||
# Key/value pair.
|
||||
type KeyValue {
|
||||
key: String!
|
||||
value: Value!
|
||||
}
|
||||
|
||||
# Key/value pair for inputs.
|
||||
input KeyValueInput {
|
||||
key: String!
|
||||
value: ValueInput!
|
||||
}
|
||||
|
||||
# Status information about a node (https://docs.tendermint.com/master/rpc/#/Info/status).
|
||||
type NodeInfo {
|
||||
id: String! # Tendermint Node ID.
|
||||
network: String! # Name of the network/blockchain.
|
||||
moniker: String! # Name of the node.
|
||||
}
|
||||
|
||||
# Node sync status.
|
||||
type SyncInfo {
|
||||
latest_block_hash: String!
|
||||
latest_block_height: String!
|
||||
latest_block_time: String!
|
||||
catching_up: Boolean!
|
||||
}
|
||||
|
||||
# Validator set info (https://docs.tendermint.com/master/rpc/#/Info/validators).
|
||||
type ValidatorInfo {
|
||||
address: String!
|
||||
voting_power: String!
|
||||
proposer_priority: String
|
||||
}
|
||||
|
||||
# Network/peer info (https://docs.tendermint.com/master/rpc/#/Info/net_info).
|
||||
type PeerInfo {
|
||||
node: NodeInfo!
|
||||
is_outbound: Boolean!
|
||||
remote_ip: String!
|
||||
}
|
||||
|
||||
# Vulcanize DXNS status.
|
||||
type Status {
|
||||
version: String!
|
||||
node: NodeInfo!
|
||||
sync: SyncInfo!
|
||||
validator: ValidatorInfo
|
||||
validators: [ValidatorInfo]!
|
||||
num_peers: String!
|
||||
peers: [PeerInfo]
|
||||
disk_usage: String!
|
||||
}
|
||||
|
||||
|
||||
# An auction bid.
|
||||
type AuctionBid {
|
||||
bidderAddress: String!
|
||||
status: String!
|
||||
commitHash: String!
|
||||
commitTime: String!
|
||||
commitFee: Coin!
|
||||
revealTime: String!
|
||||
revealFee: Coin!
|
||||
bidAmount: Coin!
|
||||
}
|
||||
|
||||
# A sealed-bid, 2nd price auction.
|
||||
type Auction {
|
||||
id: String! # Auction ID.
|
||||
status: String! # Auction status (commit, reveal, expired).
|
||||
ownerAddress: String! # Auction owner time.
|
||||
createTime: String! # Create time.
|
||||
commitsEndTime: String! # Commit phase end time.
|
||||
revealsEndTime: String! # Reveal phase end time.
|
||||
commitFee: Coin! # Fee required to bid/participate in the auction.
|
||||
revealFee: Coin! # Reveal fee (paid back to bidders only if they unseal/reveal the bid).
|
||||
minimumBid: Coin! # Minimum bid amount.
|
||||
winnerAddress: String! # Winner address.
|
||||
winnerBid: Coin! # The winning bid amount.
|
||||
winnerPrice: Coin! # The price that the winner actually pays (2nd highest bid).
|
||||
bids: [AuctionBid] # Bids make in the auction.
|
||||
}
|
||||
|
||||
|
||||
# Record defines the basic properties of an entity in the graph database.
|
||||
type Record {
|
||||
id: String! # Computed attribute: Multibase encoded content hash (https://github.com/multiformats/multibase).
|
||||
names: [String!] # Names pointing to this CID (reverse lookup).
|
||||
|
||||
bondId: String! # Associated bond ID.
|
||||
createTime: String! # Record create time.
|
||||
expiryTime: String! # Record expiry time.
|
||||
|
||||
owners: [String!] # Addresses of record owners.
|
||||
attributes: [KeyValue] # Record attributes.
|
||||
references: [Record] # Record references.
|
||||
}
|
||||
|
||||
# Name authority record.
|
||||
type AuthorityRecord {
|
||||
ownerAddress: String! # Owner address.
|
||||
ownerPublicKey: String! # Owner public key.
|
||||
height: String! # Height at which record was created.
|
||||
status: String! # Status (active, auction, expired).
|
||||
bondId: String! # Associated bond ID.
|
||||
expiryTime: String! # Authority expiry time.
|
||||
auction: Auction # Authority auction.
|
||||
}
|
||||
|
||||
# Name record entry, created at a particular height.
|
||||
type NameRecordEntry {
|
||||
id: String! # Target record ID.
|
||||
height: String! # Height at which record was created.
|
||||
}
|
||||
|
||||
# Name record stores the latest and historical name -> record ID mappings.
|
||||
type NameRecord {
|
||||
latest: NameRecordEntry! # Latest mame record entry.
|
||||
history: [NameRecordEntry] # Historical name record entries.
|
||||
}
|
||||
|
||||
type Query {
|
||||
#
|
||||
# Status API.
|
||||
#
|
||||
getStatus: Status!
|
||||
|
||||
# Get blockchain accounts.
|
||||
getAccounts(
|
||||
addresses: [String!]
|
||||
): [Account]
|
||||
|
||||
# Get bonds by IDs.
|
||||
getBondsByIds(
|
||||
ids: [String!]
|
||||
): [Bond]
|
||||
|
||||
# Query bonds.
|
||||
queryBonds(
|
||||
attributes: [KeyValueInput]
|
||||
): [Bond]
|
||||
|
||||
# Query bonds by owner.
|
||||
queryBondsByOwner(
|
||||
ownerAddresses: [String!]
|
||||
): [OwnerBonds]
|
||||
|
||||
#
|
||||
# GraphDB API.
|
||||
#
|
||||
|
||||
# Get records by IDs.
|
||||
getRecordsByIds(
|
||||
ids: [String!]
|
||||
): [Record]
|
||||
|
||||
# Query records.
|
||||
queryRecords(
|
||||
# Multiple attribute conditions are in a logical AND.
|
||||
attributes: [KeyValueInput]
|
||||
|
||||
# Whether to query all records, not just named ones (false by default).
|
||||
all: Boolean
|
||||
): [Record]
|
||||
|
||||
#
|
||||
# Naming API.
|
||||
#
|
||||
|
||||
# Lookup authority information.
|
||||
lookupAuthorities(
|
||||
names: [String!]
|
||||
): [AuthorityRecord]!
|
||||
|
||||
# Lookup name to record mapping information.
|
||||
lookupNames(
|
||||
names: [String!]
|
||||
): [NameRecord]!
|
||||
|
||||
# Resolve names to records.
|
||||
resolveNames(
|
||||
names: [String!]
|
||||
): [Record]!
|
||||
|
||||
#
|
||||
# Auctions API.
|
||||
#
|
||||
|
||||
# Get auctions by IDs.
|
||||
getAuctionsByIds(
|
||||
ids: [String!]
|
||||
): [Auction]
|
||||
}
|
15
proto/vulcanize/auction/v1beta1/genesis.proto
Normal file
15
proto/vulcanize/auction/v1beta1/genesis.proto
Normal file
@ -0,0 +1,15 @@
|
||||
syntax = "proto3";
|
||||
package vulcanize.auction.v1beta1;
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "vulcanize/auction/v1beta1/types.proto";
|
||||
|
||||
option go_package = "github.com/tharsis/ethermint/x/auction/types";
|
||||
|
||||
// GenesisState defines the genesis state of the auction module
|
||||
message GenesisState {
|
||||
Params params = 1 [(gogoproto.nullable) = false];
|
||||
repeated Auction auctions = 2 [
|
||||
(gogoproto.moretags) = "json:\"bonds\" yaml:\"bonds\""
|
||||
];
|
||||
}
|
149
proto/vulcanize/auction/v1beta1/query.proto
Normal file
149
proto/vulcanize/auction/v1beta1/query.proto
Normal file
@ -0,0 +1,149 @@
|
||||
syntax = "proto3";
|
||||
package vulcanize.auction.v1beta1;
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "cosmos/base/query/v1beta1/pagination.proto";
|
||||
import "cosmos/base/v1beta1/coin.proto";
|
||||
import "vulcanize/auction/v1beta1/types.proto";
|
||||
|
||||
option go_package = "github.com/tharsis/ethermint/x/auction/types";
|
||||
|
||||
// AuctionsRequest is the format for querying all the auctions
|
||||
message AuctionsRequest {
|
||||
// pagination defines an optional pagination info for the next request
|
||||
cosmos.base.query.v1beta1.PageRequest pagination = 1;
|
||||
}
|
||||
|
||||
// AuctionsResponse returns the list of all auctions
|
||||
message AuctionsResponse {
|
||||
// List of auctions
|
||||
Auctions auctions = 1;
|
||||
// pagination defines an optional pagination info for the next request
|
||||
cosmos.base.query.v1beta1.PageRequest pagination = 2;
|
||||
}
|
||||
|
||||
// AuctionRequest is the format for querying a specific auction
|
||||
message AuctionRequest {
|
||||
// Auction ID
|
||||
string id = 1;
|
||||
}
|
||||
|
||||
// AuctionResponse returns the details of the queried auction
|
||||
message AuctionResponse {
|
||||
// Auction details
|
||||
Auction auction = 1;
|
||||
}
|
||||
|
||||
// BidRequest is the format for querying a specific bid in an auction
|
||||
message BidRequest {
|
||||
// Auction ID
|
||||
string auction_id = 1;
|
||||
// Bidder address
|
||||
string bidder = 2;
|
||||
}
|
||||
|
||||
// BidResponse returns the details of the queried bid
|
||||
message BidResponse {
|
||||
// Bid details
|
||||
Bid bid = 1;
|
||||
}
|
||||
|
||||
// BidsRequest is the format for querying all bids in an auction
|
||||
message BidsRequest {
|
||||
// Auction ID
|
||||
string auction_id = 1;
|
||||
}
|
||||
|
||||
// BidsResponse returns details of all bids in an auction
|
||||
message BidsResponse {
|
||||
// List of bids in the auction
|
||||
repeated Bid bids = 1;
|
||||
}
|
||||
|
||||
// AuctionsByBidderRequest is the format for querying all auctions containing a bidder address
|
||||
message AuctionsByBidderRequest {
|
||||
// Address of the bidder
|
||||
string bidder_address = 1;
|
||||
}
|
||||
|
||||
// AuctionsByBidderResponse returns all auctions containing a bidder
|
||||
message AuctionsByBidderResponse {
|
||||
// List of auctions
|
||||
Auctions auctions = 1;
|
||||
}
|
||||
|
||||
// AuctionsByOwnerRequest is the format for querying all auctions created by an owner
|
||||
message AuctionsByOwnerRequest {
|
||||
// Address of the owner
|
||||
string owner_address = 1;
|
||||
}
|
||||
|
||||
// AuctionsByOwnerResponse returns all auctions created by an owner
|
||||
message AuctionsByOwnerResponse {
|
||||
// List of auctions
|
||||
Auctions auctions = 1;
|
||||
}
|
||||
|
||||
// QueryParamsRequest is the format to query the parameters of the auction module
|
||||
message QueryParamsRequest {
|
||||
}
|
||||
|
||||
// QueryParamsResponse returns parameters of the auction module
|
||||
message QueryParamsResponse {
|
||||
Params params = 1;
|
||||
}
|
||||
|
||||
// BalanceRequest is the format to fetch all balances
|
||||
message BalanceRequest {
|
||||
}
|
||||
|
||||
message BalanceResponse {
|
||||
// Set of all balances within the auction
|
||||
repeated cosmos.base.v1beta1.Coin balance = 1 [
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
}
|
||||
|
||||
// Query defines the gRPC querier interface for the auction module
|
||||
service Query {
|
||||
// Auctions queries all auctions
|
||||
rpc Auctions(AuctionsRequest) returns (AuctionsResponse) {
|
||||
option (google.api.http).get = "/vulcanize/auction/v1beta1/auctions";
|
||||
}
|
||||
|
||||
// GetAuction queries an auction
|
||||
rpc GetAuction(AuctionRequest) returns (AuctionResponse) {
|
||||
option (google.api.http).get = "/vulcanize/auction/v1beta1/auctions/{id}";
|
||||
}
|
||||
|
||||
// GetBid queries an auction bid
|
||||
rpc GetBid(BidRequest) returns (BidResponse) {
|
||||
option (google.api.http).get = "/vulcanize/auction/v1beta1/bids/{auction_id}/{bidder}";
|
||||
}
|
||||
|
||||
// GetBids queries all auction bids
|
||||
rpc GetBids(BidsRequest) returns (BidsResponse) {
|
||||
option (google.api.http).get = "/vulcanize/auction/v1beta1/bids/{auction_id}";
|
||||
}
|
||||
|
||||
// AuctionsByBidder queries auctions by bidder
|
||||
rpc AuctionsByBidder(AuctionsByBidderRequest) returns (AuctionsByBidderResponse) {
|
||||
option (google.api.http).get = "/vulcanize/auction/v1beta1/by-bidder/{bidder_address}";
|
||||
}
|
||||
|
||||
// AuctionsByOwner queries auctions by owner
|
||||
rpc AuctionsByOwner(AuctionsByOwnerRequest) returns (AuctionsByOwnerResponse) {
|
||||
option (google.api.http).get = "/vulcanize/auction/v1beta1/by-owner/{owner_address}";
|
||||
}
|
||||
|
||||
// QueryParams implements the params query command
|
||||
rpc QueryParams(QueryParamsRequest) returns (QueryParamsResponse) {
|
||||
option (google.api.http).get = "/vulcanize/auction/v1beta1/params";
|
||||
}
|
||||
|
||||
// Balance queries the auction module account balance
|
||||
rpc Balance(BalanceRequest) returns (BalanceResponse) {
|
||||
option (google.api.http).get = "/vulcanize/auction/v1beta1/balance";
|
||||
}
|
||||
}
|
122
proto/vulcanize/auction/v1beta1/tx.proto
Normal file
122
proto/vulcanize/auction/v1beta1/tx.proto
Normal file
@ -0,0 +1,122 @@
|
||||
syntax = "proto3";
|
||||
package vulcanize.auction.v1beta1;
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "google/protobuf/duration.proto";
|
||||
import "cosmos/base/v1beta1/coin.proto";
|
||||
import "vulcanize/auction/v1beta1/types.proto";
|
||||
|
||||
option go_package = "github.com/tharsis/ethermint/x/auction/types";
|
||||
|
||||
// MsgCreateAuction defines a create auction message
|
||||
message MsgCreateAuction {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// Duration of the commits phase in seconds
|
||||
google.protobuf.Duration commits_duration = 1 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.stdduration) = true,
|
||||
(gogoproto.moretags) = "json:\"commits_duration\" yaml:\"commits_duration\""
|
||||
];
|
||||
// Duration of the reveals phase in seconds
|
||||
google.protobuf.Duration reveals_duration = 2 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.stdduration) = true,
|
||||
(gogoproto.moretags) = "json:\"reveals_duration\" yaml:\"reveals_duration\""
|
||||
];
|
||||
// Commit fees
|
||||
cosmos.base.v1beta1.Coin commit_fee = 3 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"commit_fee\" yaml:\"commit_fee\""
|
||||
];
|
||||
// Reveal fees
|
||||
cosmos.base.v1beta1.Coin reveal_fee = 4 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"reveal_fee\" yaml:\"reveal_fee\""
|
||||
];
|
||||
// Minimum acceptable bid amount
|
||||
cosmos.base.v1beta1.Coin minimum_bid = 5 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"minimum_bid\" yaml:\"minimum_bid\""
|
||||
];
|
||||
// Address of the signer
|
||||
string signer = 6 [
|
||||
(gogoproto.moretags) = "json:\"signer\" yaml:\"signer\""
|
||||
];
|
||||
}
|
||||
|
||||
// MsgCreateAuctionResponse returns the details of the created auction
|
||||
message MsgCreateAuctionResponse {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
// Auction details
|
||||
Auction auction = 1 [
|
||||
(gogoproto.moretags) = "json:\"auction\" yaml:\"auction\""
|
||||
];
|
||||
}
|
||||
|
||||
// CommitBid defines the message to commit a bid
|
||||
message MsgCommitBid {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// Auction ID
|
||||
string auction_id = 1 [
|
||||
(gogoproto.moretags) = "json:\"auction_id\" yaml:\"auction_id\""
|
||||
];
|
||||
// Commit Hash
|
||||
string commit_hash = 2 [
|
||||
(gogoproto.moretags) = "json:\"commit_hash\" yaml:\"commit_hash\""
|
||||
];
|
||||
// Address of the signer
|
||||
string signer = 3 [
|
||||
(gogoproto.moretags) = "json:\"signer\" yaml:\"signer\""
|
||||
];
|
||||
}
|
||||
|
||||
// RevealBid defines the message to reveal a bid
|
||||
message MsgRevealBid {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// Auction ID
|
||||
string auction_id = 1 [
|
||||
(gogoproto.moretags) = "json:\"auction_id\" yaml:\"auction_id\""
|
||||
];
|
||||
// Commit Hash
|
||||
string reveal = 2 [
|
||||
(gogoproto.moretags) = "json:\"reveal\" yaml:\"reveal\""
|
||||
];
|
||||
// Address of the signer
|
||||
string signer = 3 [
|
||||
(gogoproto.moretags) = "json:\"signer\" yaml:\"signer\""
|
||||
];
|
||||
}
|
||||
|
||||
// MsgCommitBidResponse returns the state of the auction after the bid creation
|
||||
message MsgCommitBidResponse {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
// Auction details
|
||||
Bid bid = 1 [
|
||||
(gogoproto.moretags) = "json:\"bid\" yaml:\"bid\""
|
||||
];
|
||||
}
|
||||
|
||||
// MsgRevealBidResponse returns the state of the auction after the bid reveal
|
||||
message MsgRevealBidResponse {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
// Auction details
|
||||
Auction auction = 1 [
|
||||
(gogoproto.moretags) = "json:\"auction\" yaml:\"auction\""
|
||||
];
|
||||
}
|
||||
|
||||
// Tx defines the gRPC tx interface
|
||||
service Msg {
|
||||
// CreateAuction is the command for creating an auction
|
||||
rpc CreateAuction(MsgCreateAuction) returns (MsgCreateAuctionResponse);
|
||||
|
||||
// CommitBid is the command for committing a bid
|
||||
rpc CommitBid(MsgCommitBid) returns (MsgCommitBidResponse);
|
||||
|
||||
//RevealBid is the command for revealing a bid
|
||||
rpc RevealBid(MsgRevealBid) returns (MsgRevealBidResponse);
|
||||
}
|
||||
|
135
proto/vulcanize/auction/v1beta1/types.proto
Normal file
135
proto/vulcanize/auction/v1beta1/types.proto
Normal file
@ -0,0 +1,135 @@
|
||||
syntax = "proto3";
|
||||
package vulcanize.auction.v1beta1;
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "google/protobuf/duration.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "cosmos/base/v1beta1/coin.proto";
|
||||
|
||||
option go_package = "github.com/tharsis/ethermint/x/auction/types";
|
||||
|
||||
// Params defines the auction module parameters
|
||||
message Params {
|
||||
option (gogoproto.goproto_stringer) = false;
|
||||
|
||||
// Duration of the commits phase in seconds
|
||||
google.protobuf.Duration commits_duration = 1 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.stdduration) = true,
|
||||
(gogoproto.moretags) = "json:\"commits_duration\" yaml:\"commits_duration\""
|
||||
];
|
||||
// Duration of the reveals phase in seconds
|
||||
google.protobuf.Duration reveals_duration = 2 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.stdduration) = true,
|
||||
(gogoproto.moretags) = "json:\"reveals_duration\" yaml:\"reveals_duration\""
|
||||
];
|
||||
// Commit fees
|
||||
cosmos.base.v1beta1.Coin commit_fee = 3 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"commit_fee\" yaml:\"commit_fee\""
|
||||
];
|
||||
// Reveal fees
|
||||
cosmos.base.v1beta1.Coin reveal_fee = 4 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"reveal_fee\" yaml:\"reveal_fee\""
|
||||
];
|
||||
// Minimum acceptable bid amount
|
||||
cosmos.base.v1beta1.Coin minimum_bid = 5 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"minimum_bid\" yaml:\"minimum_bid\""
|
||||
];
|
||||
}
|
||||
|
||||
// Auction represents a sealed-bid on-chain auction
|
||||
message Auction {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
string id = 1;
|
||||
string status = 2;
|
||||
// Address of the creator of the auction
|
||||
string owner_address = 3;
|
||||
// Timestamp at which the auction was created
|
||||
google.protobuf.Timestamp create_time = 4 [
|
||||
(gogoproto.stdtime) = true,
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"create_time\" yaml:\"create_time\""
|
||||
];
|
||||
// Timestamp at which the commits phase concluded
|
||||
google.protobuf.Timestamp commits_end_time = 5 [
|
||||
(gogoproto.stdtime) = true,
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"commits_end_time\" yaml:\"commits_end_time\""
|
||||
];
|
||||
// Timestamp at which the reveals phase concluded
|
||||
google.protobuf.Timestamp reveals_end_time = 6 [
|
||||
(gogoproto.stdtime) = true,
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"reveals_end_time\" yaml:\"reveals_end_time\""
|
||||
];
|
||||
// Commit and reveal fees must both be paid when committing a bid
|
||||
// Reveal fee is returned only if the bid is revealed
|
||||
cosmos.base.v1beta1.Coin commit_fee = 7 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"commit_fee\" yaml:\"commit_fee\""
|
||||
];
|
||||
cosmos.base.v1beta1.Coin reveal_fee = 8 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"reveal_fee\" yaml:\"reveal_fee\""
|
||||
];
|
||||
// Minimum acceptable bid amount for a valid commit
|
||||
cosmos.base.v1beta1.Coin minimum_bid = 9 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"minimum_bid\" yaml:\"minimum_bid\""
|
||||
];
|
||||
// Address of the winner
|
||||
string winner_address = 10;
|
||||
// Winning bid, i.e., the highest bid
|
||||
cosmos.base.v1beta1.Coin winning_bid = 11 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"winning_bid\" yaml:\"winning_bid\""
|
||||
];
|
||||
// Amount the winner pays, i.e. the second highest auction
|
||||
cosmos.base.v1beta1.Coin winning_price = 12 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"winning_price\" yaml:\"winning_price\""
|
||||
];
|
||||
}
|
||||
|
||||
message Auctions {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
repeated Auction auctions = 1 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
// Bid represents a sealed bid (commit) made during the auction
|
||||
message Bid {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
string auction_id = 1;
|
||||
string bidder_address = 2;
|
||||
string status = 3;
|
||||
string commit_hash = 4;
|
||||
google.protobuf.Timestamp commit_time = 5 [
|
||||
(gogoproto.stdtime) = true,
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"commit_time\" yaml:\"commit_time\""
|
||||
];
|
||||
cosmos.base.v1beta1.Coin commit_fee = 6 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"commit_fee\" yaml:\"commit_fee\""
|
||||
];
|
||||
google.protobuf.Timestamp reveal_time = 7 [
|
||||
(gogoproto.stdtime) = true,
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"reveal_time\" yaml:\"reveal_time\""
|
||||
];
|
||||
cosmos.base.v1beta1.Coin reveal_fee = 8 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"reveal_fee\" yaml:\"reveal_fee\""
|
||||
];
|
||||
cosmos.base.v1beta1.Coin bid_amount = 9 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"bid_amount\" yaml:\"bid_amount\""
|
||||
];;
|
||||
}
|
29
proto/vulcanize/bond/v1beta1/bond.proto
Normal file
29
proto/vulcanize/bond/v1beta1/bond.proto
Normal file
@ -0,0 +1,29 @@
|
||||
syntax = "proto3";
|
||||
package vulcanize.bond.v1beta1;
|
||||
|
||||
option go_package = "github.com/tharsis/ethermint/x/bond/types";
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "cosmos/base/v1beta1/coin.proto";
|
||||
|
||||
// Params defines the bond module parameters
|
||||
message Params {
|
||||
// max_bond_amount is maximum amount to bond
|
||||
cosmos.base.v1beta1.Coin max_bond_amount = 1 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"max_bond_amount\" yaml:\"max_bond_amount\""
|
||||
];
|
||||
}
|
||||
|
||||
// Bond represents funds deposited by an account for record rent payments.
|
||||
message Bond {
|
||||
// id is unique identifier of the bond
|
||||
string id = 1;
|
||||
// owner of the bond
|
||||
string owner = 2;
|
||||
// balance of the bond
|
||||
repeated cosmos.base.v1beta1.Coin balance = 3 [
|
||||
(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
|
||||
(gogoproto.moretags) = "json:\"balance\" yaml:\"balance\""
|
||||
];
|
||||
}
|
18
proto/vulcanize/bond/v1beta1/genesis.proto
Normal file
18
proto/vulcanize/bond/v1beta1/genesis.proto
Normal file
@ -0,0 +1,18 @@
|
||||
syntax = "proto3";
|
||||
package vulcanize.bond.v1beta1;
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "vulcanize/bond/v1beta1/bond.proto";
|
||||
|
||||
option go_package = "github.com/tharsis/ethermint/x/bond/types";
|
||||
|
||||
// GenesisState defines the bond module's genesis state.
|
||||
message GenesisState {
|
||||
// params defines all the parameters of the module.
|
||||
Params params = 1 [(gogoproto.nullable) = false];
|
||||
|
||||
// bonds defines all the bonds
|
||||
repeated Bond bonds = 2 [
|
||||
(gogoproto.moretags) = "json:\"bonds\" yaml:\"bonds\""
|
||||
];
|
||||
}
|
109
proto/vulcanize/bond/v1beta1/query.proto
Normal file
109
proto/vulcanize/bond/v1beta1/query.proto
Normal file
@ -0,0 +1,109 @@
|
||||
syntax = "proto3";
|
||||
package vulcanize.bond.v1beta1;
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "vulcanize/bond/v1beta1/bond.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "cosmos/base/query/v1beta1/pagination.proto";
|
||||
import "cosmos/base/v1beta1/coin.proto";
|
||||
|
||||
option go_package = "github.com/tharsis/ethermint/x/bond/types";
|
||||
|
||||
// Query defines the gRPC querier service for bond module
|
||||
service Query {
|
||||
// Params queries bonds module params.
|
||||
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
|
||||
option (google.api.http).get = "/vulcanize/bond/v1beta1/params";
|
||||
}
|
||||
|
||||
// Bonds queries bonds list.
|
||||
rpc Bonds(QueryGetBondsRequest) returns (QueryGetBondsResponse) {
|
||||
option (google.api.http).get = "/vulcanize/bond/v1beta1/bonds";
|
||||
}
|
||||
|
||||
// GetBondById
|
||||
rpc GetBondById(QueryGetBondByIdRequest) returns (QueryGetBondByIdResponse){
|
||||
option (google.api.http).get = "/vulcanize/bond/v1beta1/bonds/{id}";
|
||||
}
|
||||
|
||||
// Get Bonds List by Owner
|
||||
rpc GetBondsByOwner(QueryGetBondsByOwnerRequest) returns (QueryGetBondsByOwnerResponse){
|
||||
option (google.api.http).get = "/vulcanize/bond/v1beta1/by-owner/{owner}";
|
||||
}
|
||||
|
||||
// Get Bonds module balance
|
||||
rpc GetBondsModuleBalance(QueryGetBondModuleBalanceRequest) returns (QueryGetBondModuleBalanceResponse){
|
||||
option (google.api.http).get = "/vulcanize/bond/v1beta1/balance";
|
||||
}
|
||||
}
|
||||
|
||||
// QueryParamsRequest is request for query the bond module params
|
||||
message QueryParamsRequest{
|
||||
}
|
||||
|
||||
// QueryParamsResponse returns response type of bond module params
|
||||
message QueryParamsResponse{
|
||||
Params params = 1 [
|
||||
(gogoproto.moretags) = "json:\"params\" yaml:\"params\""
|
||||
];
|
||||
}
|
||||
|
||||
// QueryGetBondById queries a bond by bond-id.
|
||||
message QueryGetBondsRequest{
|
||||
// pagination defines an optional pagination for the request.
|
||||
cosmos.base.query.v1beta1.PageRequest pagination = 1;
|
||||
}
|
||||
|
||||
// QueryGetBondsResponse is response type for get the bonds by bond-id
|
||||
message QueryGetBondsResponse{
|
||||
repeated Bond bonds = 1 [
|
||||
(gogoproto.moretags) = "json:\"bonds\" yaml:\"bonds\""
|
||||
];
|
||||
// pagination defines the pagination in the response.
|
||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||
}
|
||||
|
||||
// QueryGetBondById
|
||||
message QueryGetBondByIdRequest{
|
||||
string id = 1 [
|
||||
(gogoproto.moretags) = "json:\"id\" yaml:\"id\""
|
||||
];
|
||||
}
|
||||
|
||||
// QueryGetBondByIdResponse returns QueryGetBondById query response
|
||||
message QueryGetBondByIdResponse{
|
||||
Bond bond = 1 [
|
||||
(gogoproto.moretags) = "json:\"bond\" yaml:\"bond\""
|
||||
];
|
||||
}
|
||||
|
||||
// QueryGetBondsByOwnerRequest is request type for Query/GetBondsByOwner RPC Method
|
||||
message QueryGetBondsByOwnerRequest{
|
||||
string owner = 1;
|
||||
// pagination defines the pagination in the response.
|
||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||
}
|
||||
|
||||
// QueryGetBondsByOwnerResponse is response type for Query/GetBondsByOwner RPC Method
|
||||
message QueryGetBondsByOwnerResponse {
|
||||
repeated Bond bonds = 1 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"bonds\" yaml:\"bonds\""
|
||||
];
|
||||
// pagination defines the pagination in the response.
|
||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||
}
|
||||
|
||||
// QueryGetBondModuleBalanceRequest is request type for bond module balance rpc method
|
||||
message QueryGetBondModuleBalanceRequest{
|
||||
|
||||
}
|
||||
|
||||
// QueryGetBondModuleBalanceResponse is the response type for bond module balance rpc method
|
||||
message QueryGetBondModuleBalanceResponse{
|
||||
repeated cosmos.base.v1beta1.Coin balance = 2 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
|
||||
(gogoproto.moretags) = "json:\"coins\" yaml:\"coins\""
|
||||
];
|
||||
}
|
77
proto/vulcanize/bond/v1beta1/tx.proto
Normal file
77
proto/vulcanize/bond/v1beta1/tx.proto
Normal file
@ -0,0 +1,77 @@
|
||||
syntax = "proto3";
|
||||
package vulcanize.bond.v1beta1;
|
||||
|
||||
option go_package = "github.com/tharsis/ethermint/x/bond/types";
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "cosmos/base/v1beta1/coin.proto";
|
||||
|
||||
// Msg defines the bond Msg service.
|
||||
service Msg {
|
||||
// CreateBond defines a method for creating a new bond.
|
||||
rpc CreateBond(MsgCreateBond) returns (MsgCreateBondResponse);
|
||||
|
||||
// RefillBond defines a method for refilling amount for bond.
|
||||
rpc RefillBond(MsgRefillBond) returns (MsgRefillBondResponse);
|
||||
|
||||
// WithdrawBond defines a method for withdrawing amount from bond.
|
||||
rpc WithdrawBond(MsgWithdrawBond) returns (MsgWithdrawBondResponse);
|
||||
|
||||
// CancelBond defines a method for cancelling a bond.
|
||||
rpc CancelBond(MsgCancelBond) returns (MsgCancelBondResponse);
|
||||
}
|
||||
|
||||
// MsgCreateBond defines a SDK message for creating a new bond.
|
||||
message MsgCreateBond{
|
||||
string signer = 1;
|
||||
repeated cosmos.base.v1beta1.Coin coins = 2 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
|
||||
(gogoproto.moretags) = "json:\"coins\" yaml:\"coins\""
|
||||
];
|
||||
}
|
||||
|
||||
// MsgCreateBondResponse defines the Msg/CreateBond response type.
|
||||
message MsgCreateBondResponse{
|
||||
string id = 1;
|
||||
}
|
||||
|
||||
// MsgRefillBond defines a SDK message for refill the amount for bond.
|
||||
message MsgRefillBond{
|
||||
string id = 1;
|
||||
string signer = 2;
|
||||
repeated cosmos.base.v1beta1.Coin coins = 3 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
|
||||
(gogoproto.moretags) = "json:\"coins\" yaml:\"coins\""
|
||||
];
|
||||
}
|
||||
|
||||
// MsgRefillBondResponse defines the Msg/RefillBond response type.
|
||||
message MsgRefillBondResponse{
|
||||
}
|
||||
|
||||
// MsgWithdrawBond defines a SDK message for withdrawing amount from bond.
|
||||
message MsgWithdrawBond {
|
||||
string id = 1;
|
||||
string signer = 2;
|
||||
repeated cosmos.base.v1beta1.Coin coins = 3 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
|
||||
(gogoproto.moretags) = "json:\"coins\" yaml:\"coins\""
|
||||
];
|
||||
}
|
||||
|
||||
// MsgWithdrawBondResponse defines the Msg/WithdrawBond response type.
|
||||
message MsgWithdrawBondResponse{
|
||||
}
|
||||
|
||||
// MsgCancelBond defines a SDK message for the cancel the bond.
|
||||
message MsgCancelBond{
|
||||
string id = 1;
|
||||
string signer = 2;
|
||||
}
|
||||
|
||||
// MsgCancelBondResponse defines the Msg/CancelBond response type.
|
||||
message MsgCancelBondResponse{
|
||||
}
|
30
proto/vulcanize/nameservice/v1beta1/genesis.proto
Normal file
30
proto/vulcanize/nameservice/v1beta1/genesis.proto
Normal file
@ -0,0 +1,30 @@
|
||||
syntax = "proto3";
|
||||
package vulcanize.nameservice.v1beta1;
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "vulcanize/nameservice/v1beta1/nameservice.proto";
|
||||
|
||||
option go_package = "github.com/tharsis/ethermint/x/nameservice/types";
|
||||
|
||||
// GenesisState defines the nameservice module's genesis state.
|
||||
message GenesisState {
|
||||
// params defines all the params of nameservice module.
|
||||
Params params = 1 [
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
// records
|
||||
repeated Record records = 2 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"records\" yaml:\"records\""
|
||||
];
|
||||
// authorities
|
||||
repeated AuthorityEntry authorities = 3 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"authorities\" yaml:\"authorities\""
|
||||
];
|
||||
// names
|
||||
repeated NameEntry names = 4 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"names\" yaml:\"names\""
|
||||
];
|
||||
}
|
170
proto/vulcanize/nameservice/v1beta1/nameservice.proto
Normal file
170
proto/vulcanize/nameservice/v1beta1/nameservice.proto
Normal file
@ -0,0 +1,170 @@
|
||||
syntax = "proto3";
|
||||
package vulcanize.nameservice.v1beta1;
|
||||
|
||||
import "google/protobuf/duration.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
import "cosmos/base/v1beta1/coin.proto";
|
||||
|
||||
option go_package = "github.com/tharsis/ethermint/x/nameservice/types";
|
||||
|
||||
// Params defines the nameservice module parameters
|
||||
message Params {
|
||||
cosmos.base.v1beta1.Coin record_rent = 1 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"record_rent\" yaml:\"record_rent\""
|
||||
];
|
||||
google.protobuf.Duration record_rent_duration = 2 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.stdduration) = true,
|
||||
(gogoproto.moretags) = "json:\"record_rent_duration\" yaml:\"record_rent_duration\""
|
||||
];
|
||||
cosmos.base.v1beta1.Coin authority_rent = 3 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"authority_rent\" yaml:\"authority_rent\""
|
||||
];
|
||||
google.protobuf.Duration authority_rent_duration = 4 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.stdduration) = true,
|
||||
(gogoproto.moretags) = "json:\"authority_rent_duration\" yaml:\"authority_rent_duration\""
|
||||
];
|
||||
google.protobuf.Duration authority_grace_period = 5 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.stdduration) = true,
|
||||
(gogoproto.moretags) = "json:\"authority_grace_period\" yaml:\"authority_grace_period\""
|
||||
];
|
||||
bool authority_auction_enabled = 6 [
|
||||
(gogoproto.moretags) = "json:\"authority_auction_enabled\" yaml:\"authority_auction_enabled\""
|
||||
];
|
||||
google.protobuf.Duration authority_auction_commits_duration = 7 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.stdduration) = true,
|
||||
(gogoproto.moretags) = "json:\"authority_auction_commits_duration\" yaml:\"authority_auction_commits_duration\""
|
||||
];
|
||||
google.protobuf.Duration authority_auction_reveals_duration = 8 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.stdduration) = true,
|
||||
(gogoproto.moretags) = "json:\"authority_auction_reveals_duration\" yaml:\"authority_auction_reveals_duration\""
|
||||
];
|
||||
cosmos.base.v1beta1.Coin authority_auction_commit_fee = 9 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"authority_auction_commit_fee\" yaml:\"authority_auction_commit_fee\""
|
||||
];
|
||||
cosmos.base.v1beta1.Coin authority_auction_reveal_fee = 10 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"authority_auction_reveal_fee\" yaml:\"authority_auction_reveal_fee\""
|
||||
];
|
||||
cosmos.base.v1beta1.Coin authority_auction_minimum_bid = 11 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"authority_auction_minimum_bid\" yaml:\"authority_auction_minimum_bid\""
|
||||
];
|
||||
}
|
||||
|
||||
// Params defines the nameservice module records
|
||||
message Record {
|
||||
string id = 1 [
|
||||
(gogoproto.moretags) = "json:\"id\" yaml:\"id\""
|
||||
];
|
||||
string bond_id = 2 [
|
||||
(gogoproto.moretags) = "json:\"bondId\" yaml:\"bondId\""
|
||||
];
|
||||
google.protobuf.Timestamp create_time = 3 [
|
||||
(gogoproto.stdtime) = true,
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"createTime\" yaml:\"createTime\""
|
||||
];
|
||||
google.protobuf.Timestamp expiry_time = 4 [
|
||||
(gogoproto.stdtime) = true,
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"expiryTime\" yaml:\"expiryTime\""
|
||||
];
|
||||
bool deleted = 5;
|
||||
repeated string owners = 6 [
|
||||
(gogoproto.moretags) = "json:\"owners\" yaml:\"owners\""
|
||||
];
|
||||
bytes attributes = 7 [
|
||||
(gogoproto.moretags) = "json:\"attributes\" yaml:\"attributes\""
|
||||
];
|
||||
}
|
||||
|
||||
// AuthorityEntry defines the nameservice module AuthorityEntries
|
||||
message AuthorityEntry{
|
||||
string name = 1;
|
||||
NameAuthority entry = 2;
|
||||
}
|
||||
|
||||
// NameAuthority
|
||||
message NameAuthority {
|
||||
// Owner public key.
|
||||
string owner_public_key = 1 [
|
||||
(gogoproto.moretags) = "json:\"ownerPublicKey\" yaml:\"ownerPublicKey\""
|
||||
];
|
||||
// Owner address.
|
||||
string owner_address = 2 [
|
||||
(gogoproto.moretags) = "json:\"ownerAddress\" yaml:\"ownerAddress\""
|
||||
];
|
||||
// height at which name/authority was created.
|
||||
uint64 height = 3;
|
||||
string status = 4;
|
||||
string auction_id = 5 [
|
||||
(gogoproto.moretags) = "json:\"auctionID\" yaml:\"auctionID\""
|
||||
];
|
||||
string bond_id = 6 [
|
||||
(gogoproto.moretags) = "json:\"bondID\" yaml:\"bondID\""
|
||||
];
|
||||
google.protobuf.Timestamp expiry_time = 7 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.stdtime) = true,
|
||||
(gogoproto.moretags) = "json:\"expiryTime\" yaml:\"expiryTime\""
|
||||
];
|
||||
}
|
||||
|
||||
// NameEntry
|
||||
message NameEntry{
|
||||
string name = 1;
|
||||
NameRecord entry = 2;
|
||||
}
|
||||
|
||||
// NameRecord
|
||||
message NameRecord {
|
||||
NameRecordEntry latest = 1;
|
||||
repeated NameRecordEntry history = 2;
|
||||
}
|
||||
|
||||
// NameRecordEntry
|
||||
message NameRecordEntry{
|
||||
string id = 1;
|
||||
uint64 height = 2;
|
||||
}
|
||||
|
||||
// Signature
|
||||
message Signature{
|
||||
string sig = 1 [
|
||||
(gogoproto.moretags) = "json:\"sig\" yaml:\"sig\""
|
||||
];
|
||||
string pub_key = 2 [
|
||||
(gogoproto.moretags) = "json:\"pubKey\" yaml:\"pubKey\""
|
||||
];
|
||||
}
|
||||
|
||||
// BlockChangeSet
|
||||
message BlockChangeSet{
|
||||
int64 height = 1;
|
||||
repeated string records = 2;
|
||||
repeated string auctions = 3;
|
||||
repeated AuctionBidInfo auction_bids = 4 [
|
||||
(gogoproto.moretags) = "json:\"auctionBids\" yaml:\"auctionBids\""
|
||||
];
|
||||
repeated string authorities = 5;
|
||||
repeated string names = 6;
|
||||
}
|
||||
|
||||
// AuctionBidInfo
|
||||
message AuctionBidInfo {
|
||||
string auction_id = 1 [
|
||||
(gogoproto.moretags) = "json:\"auctionID\" yaml:\"auctionID\""
|
||||
];
|
||||
string bidder_address = 2 [
|
||||
(gogoproto.moretags) = "json:\"bidderAddress\" yaml:\"bidderAddress\""
|
||||
];
|
||||
}
|
211
proto/vulcanize/nameservice/v1beta1/query.proto
Normal file
211
proto/vulcanize/nameservice/v1beta1/query.proto
Normal file
@ -0,0 +1,211 @@
|
||||
syntax = "proto3";
|
||||
package vulcanize.nameservice.v1beta1;
|
||||
|
||||
import "vulcanize/nameservice/v1beta1/nameservice.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "cosmos/base/query/v1beta1/pagination.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
import "cosmos/base/v1beta1/coin.proto";
|
||||
|
||||
option go_package = "github.com/tharsis/ethermint/x/nameservice/types";
|
||||
|
||||
// Query defines the gRPC querier service for nameservice module
|
||||
service Query {
|
||||
// Params queries the nameservice module params.
|
||||
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
|
||||
option (google.api.http).get = "/vulcanize/nameservice/v1beta1/params";
|
||||
}
|
||||
// List records
|
||||
rpc ListRecords(QueryListRecordsRequest) returns (QueryListRecordsResponse){
|
||||
option (google.api.http).get = "/vulcanize/nameservice/v1beta1/records";
|
||||
}
|
||||
// Get record by id
|
||||
rpc GetRecord(QueryRecordByIdRequest) returns (QueryRecordByIdResponse){
|
||||
option (google.api.http).get = "/vulcanize/nameservice/v1beta1/records/{id}";
|
||||
}
|
||||
// Get records by bond id
|
||||
rpc GetRecordByBondId(QueryRecordByBondIdRequest) returns (QueryRecordByBondIdResponse){
|
||||
option (google.api.http).get = "/vulcanize/nameservice/v1beta1/records-by-bond-id/{id}";
|
||||
}
|
||||
// Get nameservice module balance
|
||||
rpc GetNameServiceModuleBalance(GetNameServiceModuleBalanceRequest) returns (GetNameServiceModuleBalanceResponse){
|
||||
option (google.api.http).get = "/vulcanize/nameservice/v1beta1/balance";
|
||||
}
|
||||
// List name records
|
||||
rpc ListNameRecords(QueryListNameRecordsRequest) returns (QueryListNameRecordsResponse){
|
||||
option (google.api.http).get = "/vulcanize/nameservice/v1beta1/names";
|
||||
}
|
||||
// Whois method retrieve the name authority info
|
||||
rpc Whois(QueryWhoisRequest) returns (QueryWhoisResponse){
|
||||
option (google.api.http).get = "/vulcanize/nameservice/v1beta1/whois/{name}";
|
||||
}
|
||||
// LookupWrn
|
||||
rpc LookupWrn(QueryLookupWrn) returns (QueryLookupWrnResponse){
|
||||
option (google.api.http).get = "/vulcanize/nameservice/v1beta1/lookup";
|
||||
}
|
||||
// ResolveWrn
|
||||
rpc ResolveWrn(QueryResolveWrn) returns (QueryResolveWrnResponse){
|
||||
option (google.api.http).get = "/vulcanize/nameservice/v1beta1/resolve";
|
||||
}
|
||||
// GetRecordExpiryQueue
|
||||
rpc GetRecordExpiryQueue(QueryGetRecordExpiryQueue) returns (QueryGetRecordExpiryQueueResponse){
|
||||
option (google.api.http).get = "/vulcanize/nameservice/v1beta1/record-expiry";
|
||||
}
|
||||
// GetAuthorityExpiryQueue
|
||||
rpc GetAuthorityExpiryQueue(QueryGetAuthorityExpiryQueue) returns (QueryGetAuthorityExpiryQueueResponse){
|
||||
option (google.api.http).get = "/vulcanize/nameservice/v1beta1/authority-expiry";
|
||||
}
|
||||
}
|
||||
|
||||
// QueryParamsRequest is request type for nameservice params
|
||||
message QueryParamsRequest{
|
||||
}
|
||||
|
||||
// QueryParamsResponse is response type for nameservice params
|
||||
message QueryParamsResponse{
|
||||
Params params = 1;
|
||||
}
|
||||
|
||||
// QueryListRecordsRequest is request type for nameservice records list
|
||||
message QueryListRecordsRequest{
|
||||
// pagination defines an optional pagination for the request.
|
||||
cosmos.base.query.v1beta1.PageRequest pagination = 1;
|
||||
}
|
||||
|
||||
// QueryListRecordsResponse is response type for nameservice records list
|
||||
message QueryListRecordsResponse{
|
||||
repeated Record records = 1 [
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
// pagination defines the pagination in the response.
|
||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||
}
|
||||
|
||||
//QueryRecordByIdRequest is request type for nameservice records by id
|
||||
message QueryRecordByIdRequest{
|
||||
string id = 1 ;
|
||||
}
|
||||
|
||||
// QueryRecordByIdResponse is response type for nameservice records by id
|
||||
message QueryRecordByIdResponse{
|
||||
Record record = 1[
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
}
|
||||
|
||||
// QueryRecordByBondIdRequest is request type for get the records by bond-id
|
||||
message QueryRecordByBondIdRequest{
|
||||
string id = 1;
|
||||
// pagination defines an optional pagination for the request.
|
||||
cosmos.base.query.v1beta1.PageRequest pagination = 2;
|
||||
}
|
||||
|
||||
// QueryRecordByBondIdResponse is response type for records list by bond-id
|
||||
message QueryRecordByBondIdResponse{
|
||||
repeated Record records = 1 [
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
// pagination defines the pagination in the response.
|
||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||
}
|
||||
|
||||
// GetNameServiceModuleBalanceRequest is request type for nameservice module accounts balance
|
||||
message GetNameServiceModuleBalanceRequest{
|
||||
}
|
||||
|
||||
// GetNameServiceModuleBalanceResponse is response type for nameservice module accounts balance
|
||||
message GetNameServiceModuleBalanceResponse{
|
||||
repeated AccountBalance balances = 1;
|
||||
}
|
||||
|
||||
// AccountBalance is nameservice module account balance
|
||||
message AccountBalance {
|
||||
string account_name = 1 [
|
||||
(gogoproto.moretags) = "json:\"accountName\" yaml:\"accountName\""
|
||||
];
|
||||
repeated cosmos.base.v1beta1.Coin balance = 3 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
|
||||
(gogoproto.moretags) = "json:\"balance\" yaml:\"balance\""
|
||||
];
|
||||
}
|
||||
|
||||
// QueryListNameRecordsRequest is request type for nameservice names records
|
||||
message QueryListNameRecordsRequest{
|
||||
// pagination defines an optional pagination for the request.
|
||||
cosmos.base.query.v1beta1.PageRequest pagination = 1;
|
||||
}
|
||||
|
||||
// QueryListNameRecordsResponse is response type for nameservice names records
|
||||
message QueryListNameRecordsResponse{
|
||||
repeated NameEntry names = 1 [
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
// pagination defines the pagination in the response.
|
||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||
}
|
||||
|
||||
// QueryWhoisRequest is request type for Get NameAuthority
|
||||
message QueryWhoisRequest{
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
// QueryWhoisResponse is response type for whois request
|
||||
message QueryWhoisResponse{
|
||||
NameAuthority name_authority = 1 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"nameAuthority\" yaml:\"nameAuthority\""
|
||||
];
|
||||
}
|
||||
|
||||
// QueryLookupWrn is request type for LookupWrn
|
||||
message QueryLookupWrn{
|
||||
string wrn = 1;
|
||||
}
|
||||
|
||||
// QueryLookupWrnResponse is response type for QueryLookupWrn
|
||||
message QueryLookupWrnResponse{
|
||||
NameRecord name = 1;
|
||||
}
|
||||
|
||||
// QueryResolveWrn is request type for ResolveWrn
|
||||
message QueryResolveWrn{
|
||||
string wrn = 1;
|
||||
}
|
||||
|
||||
// QueryResolveWrnResponse is response type for QueryResolveWrn
|
||||
message QueryResolveWrnResponse{
|
||||
Record record = 1;
|
||||
}
|
||||
|
||||
// QueryGetRecordExpiryQueue
|
||||
message QueryGetRecordExpiryQueue{
|
||||
// pagination defines an optional pagination for the request.
|
||||
cosmos.base.query.v1beta1.PageRequest pagination = 1;
|
||||
}
|
||||
|
||||
// QueryGetRecordExpiryQueueResponse
|
||||
message QueryGetRecordExpiryQueueResponse{
|
||||
repeated ExpiryQueueRecord records = 1;
|
||||
// pagination defines the pagination in the response.
|
||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||
}
|
||||
|
||||
// ExpiryQueueRecord
|
||||
message ExpiryQueueRecord{
|
||||
string id = 1;
|
||||
repeated string value = 2;
|
||||
}
|
||||
|
||||
// QueryGetAuthorityExpiryQueue
|
||||
message QueryGetAuthorityExpiryQueue{
|
||||
// pagination defines an optional pagination for the request.
|
||||
cosmos.base.query.v1beta1.PageRequest pagination = 1;
|
||||
}
|
||||
|
||||
// QueryGetAuthorityExpiryQueueResponse
|
||||
message QueryGetAuthorityExpiryQueueResponse{
|
||||
repeated ExpiryQueueRecord authorities = 1;
|
||||
// pagination defines the pagination in the response.
|
||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||
}
|
167
proto/vulcanize/nameservice/v1beta1/tx.proto
Normal file
167
proto/vulcanize/nameservice/v1beta1/tx.proto
Normal file
@ -0,0 +1,167 @@
|
||||
syntax = "proto3";
|
||||
package vulcanize.nameservice.v1beta1;
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "vulcanize/nameservice/v1beta1/nameservice.proto";
|
||||
|
||||
option go_package = "github.com/tharsis/ethermint/x/nameservice/types";
|
||||
|
||||
// Msg
|
||||
service Msg {
|
||||
// SetRecord will records a new record with given payload and bond id
|
||||
rpc SetRecord(MsgSetRecord) returns(MsgSetRecordResponse){}
|
||||
// Renew Record will renew the expire record
|
||||
rpc RenewRecord(MsgRenewRecord) returns (MsgRenewRecordResponse){}
|
||||
// AssociateBond
|
||||
rpc AssociateBond(MsgAssociateBond) returns (MsgAssociateBondResponse){}
|
||||
// DissociateBond
|
||||
rpc DissociateBond(MsgDissociateBond) returns (MsgDissociateBondResponse){}
|
||||
// DissociateRecords
|
||||
rpc DissociateRecords(MsgDissociateRecords) returns (MsgDissociateRecordsResponse){}
|
||||
// ReAssociateRecords
|
||||
rpc ReAssociateRecords(MsgReAssociateRecords) returns (MsgReAssociateRecordsResponse){}
|
||||
// SetName will store the name with given wrn and name
|
||||
rpc SetName(MsgSetName) returns (MsgSetNameResponse){}
|
||||
// Reserve name
|
||||
rpc ReserveName(MsgReserveAuthority) returns (MsgReserveAuthorityResponse){}
|
||||
// Delete Name method will remove authority name
|
||||
rpc DeleteName(MsgDeleteNameAuthority) returns (MsgDeleteNameAuthorityResponse){}
|
||||
// SetAuthorityBond
|
||||
rpc SetAuthorityBond(MsgSetAuthorityBond) returns (MsgSetAuthorityBondResponse){}
|
||||
}
|
||||
|
||||
// MsgSetRecord
|
||||
message MsgSetRecord{
|
||||
string bond_id = 1 [
|
||||
(gogoproto.moretags) = "json:\"bondId\" yaml:\"bondId\""
|
||||
];
|
||||
string signer = 2;
|
||||
Payload payload = 3 [
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
}
|
||||
|
||||
// MsgSetRecordResponse
|
||||
message MsgSetRecordResponse{
|
||||
}
|
||||
|
||||
// Payload
|
||||
message Payload {
|
||||
Record record = 1;
|
||||
repeated Signature signatures = 2 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"signatures\" yaml:\"signatures\""
|
||||
];
|
||||
}
|
||||
|
||||
// MsgSetName
|
||||
message MsgSetName{
|
||||
string wrn = 1;
|
||||
string cid = 2;
|
||||
string signer = 3;
|
||||
}
|
||||
|
||||
// MsgSetNameResponse
|
||||
message MsgSetNameResponse{
|
||||
}
|
||||
|
||||
// MsgReserveName
|
||||
message MsgReserveAuthority{
|
||||
string name = 1;
|
||||
string signer = 2;
|
||||
// if creating a sub-authority.
|
||||
string owner = 3;
|
||||
}
|
||||
|
||||
// MsgReserveNameResponse
|
||||
message MsgReserveAuthorityResponse{
|
||||
}
|
||||
|
||||
// MsgSetAuthorityBond is SDK message for SetAuthorityBond
|
||||
message MsgSetAuthorityBond{
|
||||
string name = 1;
|
||||
string bond_id = 2 [
|
||||
(gogoproto.moretags) = "json:\"bondId\" yaml:\"bondId\""
|
||||
];
|
||||
string signer = 3;
|
||||
}
|
||||
|
||||
// MsgSetAuthorityBondResponse
|
||||
message MsgSetAuthorityBondResponse{
|
||||
}
|
||||
|
||||
// MsgDeleteNameAuthority is SDK message for DeleteNameAuthority
|
||||
message MsgDeleteNameAuthority{
|
||||
string wrn = 1;
|
||||
string signer = 2;
|
||||
}
|
||||
|
||||
// MsgDeleteNameAuthorityResponse
|
||||
message MsgDeleteNameAuthorityResponse{
|
||||
}
|
||||
|
||||
//MsgRenewRecord is SDK message for Renew a record
|
||||
message MsgRenewRecord{
|
||||
string record_id = 1 [
|
||||
(gogoproto.moretags) = "json:\"recordId\" yaml:\"recordId\""
|
||||
];
|
||||
string signer = 2;
|
||||
}
|
||||
|
||||
// MsgRenewRecordResponse
|
||||
message MsgRenewRecordResponse{
|
||||
}
|
||||
|
||||
// MsgAssociateBond
|
||||
message MsgAssociateBond{
|
||||
string record_id = 1 [
|
||||
(gogoproto.moretags) = "json:\"recordId\" yaml:\"recordId\""
|
||||
];
|
||||
string bond_id = 2 [
|
||||
(gogoproto.moretags) = "json:\"bondId\" yaml:\"bondId\""
|
||||
];
|
||||
string signer = 3;
|
||||
}
|
||||
|
||||
// MsgAssociateBondResponse
|
||||
message MsgAssociateBondResponse{
|
||||
}
|
||||
|
||||
// MsgDissociateBond is SDK message for Msg/DissociateBond
|
||||
message MsgDissociateBond{
|
||||
string record_id = 1 [
|
||||
(gogoproto.moretags) = "json:\"recordId\" yaml:\"recordId\""
|
||||
];
|
||||
string signer = 2;
|
||||
}
|
||||
|
||||
// MsgDissociateBondResponse is response type for MsgDissociateBond
|
||||
message MsgDissociateBondResponse{
|
||||
}
|
||||
|
||||
// MsgDissociateRecords is SDK message for Msg/DissociateRecords
|
||||
message MsgDissociateRecords{
|
||||
string bond_id = 1 [
|
||||
(gogoproto.moretags) = "json:\"bondId\" yaml:\"bondId\""
|
||||
];
|
||||
string signer = 2;
|
||||
}
|
||||
|
||||
// MsgDissociateRecordsResponse is response type for MsgDissociateRecords
|
||||
message MsgDissociateRecordsResponse{
|
||||
}
|
||||
|
||||
// MsgReAssociateRecords is SDK message for Msg/ReAssociateRecords
|
||||
message MsgReAssociateRecords{
|
||||
string new_bond_id = 1 [
|
||||
(gogoproto.moretags) = "json:\"newBondId\" yaml:\"newBondId\""
|
||||
];
|
||||
string old_bond_id = 2 [
|
||||
(gogoproto.moretags) = "json:\"oldBondId\" yaml:\"oldBondId\""
|
||||
];
|
||||
string signer = 3;
|
||||
}
|
||||
|
||||
// MsgReAssociateRecordsResponse is response type for MsgReAssociateRecords
|
||||
message MsgReAssociateRecordsResponse{
|
||||
}
|
@ -57,7 +57,7 @@ func GetRPCAPIs(ctx *server.Context, clientCtx client.Context, tmWSClient *rpccl
|
||||
rpc.API{
|
||||
Namespace: EthNamespace,
|
||||
Version: apiVersion,
|
||||
Service: filters.NewPublicAPI(ctx.Logger, tmWSClient, evmBackend),
|
||||
Service: filters.NewPublicAPI(ctx.Logger, clientCtx, tmWSClient, evmBackend),
|
||||
Public: true,
|
||||
},
|
||||
)
|
||||
|
@ -35,7 +35,8 @@ func (e *EVMBackend) processBlock(
|
||||
ethBlock *map[string]interface{},
|
||||
rewardPercentiles []float64,
|
||||
tendermintBlockResult *tmrpctypes.ResultBlockResults,
|
||||
targetOneFeeHistory *rpctypes.OneFeeHistory) error {
|
||||
targetOneFeeHistory *rpctypes.OneFeeHistory,
|
||||
) error {
|
||||
blockHeight := tendermintBlock.Block.Height
|
||||
blockBaseFee, err := e.BaseFee(blockHeight)
|
||||
if err != nil {
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/tharsis/ethermint/rpc/ethereum/types"
|
||||
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
@ -56,6 +57,7 @@ type filter struct {
|
||||
// information related to the Ethereum protocol such as blocks, transactions and logs.
|
||||
type PublicFilterAPI struct {
|
||||
logger log.Logger
|
||||
clientCtx client.Context
|
||||
backend Backend
|
||||
events *EventSystem
|
||||
filtersMu sync.Mutex
|
||||
@ -63,13 +65,14 @@ type PublicFilterAPI struct {
|
||||
}
|
||||
|
||||
// NewPublicAPI returns a new PublicFilterAPI instance.
|
||||
func NewPublicAPI(logger log.Logger, tmWSClient *rpcclient.WSClient, backend Backend) *PublicFilterAPI {
|
||||
func NewPublicAPI(logger log.Logger, clientCtx client.Context, tmWSClient *rpcclient.WSClient, backend Backend) *PublicFilterAPI {
|
||||
logger = logger.With("api", "filter")
|
||||
api := &PublicFilterAPI{
|
||||
logger: logger,
|
||||
backend: backend,
|
||||
filters: make(map[rpc.ID]*filter),
|
||||
events: NewEventSystem(logger, tmWSClient),
|
||||
logger: logger,
|
||||
clientCtx: clientCtx,
|
||||
backend: backend,
|
||||
filters: make(map[rpc.ID]*filter),
|
||||
events: NewEventSystem(logger, tmWSClient),
|
||||
}
|
||||
|
||||
go api.timeoutLoop()
|
||||
@ -141,11 +144,20 @@ func (api *PublicFilterAPI) NewPendingTransactionFilter() rpc.ID {
|
||||
continue
|
||||
}
|
||||
|
||||
txHash := common.BytesToHash(tmtypes.Tx(data.Tx).Hash())
|
||||
tx, err := api.clientCtx.TxConfig.TxDecoder()(data.Tx)
|
||||
if err != nil {
|
||||
api.logger.Debug("fail to decode tx", "error", err.Error())
|
||||
continue
|
||||
}
|
||||
|
||||
api.filtersMu.Lock()
|
||||
if f, found := api.filters[pendingTxSub.ID()]; found {
|
||||
f.hashes = append(f.hashes, txHash)
|
||||
for _, msg := range tx.GetMsgs() {
|
||||
ethTx, ok := msg.(*evmtypes.MsgEthereumTx)
|
||||
if ok {
|
||||
f.hashes = append(f.hashes, common.HexToHash(ethTx.Hash))
|
||||
}
|
||||
}
|
||||
}
|
||||
api.filtersMu.Unlock()
|
||||
case <-errCh:
|
||||
@ -198,13 +210,17 @@ func (api *PublicFilterAPI) NewPendingTransactions(ctx context.Context) (*rpc.Su
|
||||
continue
|
||||
}
|
||||
|
||||
txHash := common.BytesToHash(tmtypes.Tx(data.Tx).Hash())
|
||||
|
||||
// To keep the original behavior, send a single tx hash in one notification.
|
||||
// TODO(rjl493456442) Send a batch of tx hashes in one notification
|
||||
err = notifier.Notify(rpcSub.ID, txHash)
|
||||
tx, err := api.clientCtx.TxConfig.TxDecoder()(data.Tx)
|
||||
if err != nil {
|
||||
return
|
||||
api.logger.Debug("fail to decode tx", "error", err.Error())
|
||||
continue
|
||||
}
|
||||
|
||||
for _, msg := range tx.GetMsgs() {
|
||||
ethTx, ok := msg.(*evmtypes.MsgEthereumTx)
|
||||
if ok {
|
||||
_ = notifier.Notify(rpcSub.ID, common.HexToHash(ethTx.Hash))
|
||||
}
|
||||
}
|
||||
case <-rpcSub.Err():
|
||||
pendingTxSub.Unsubscribe(api.events)
|
||||
@ -314,11 +330,7 @@ func (api *PublicFilterAPI) NewHeads(ctx context.Context) (*rpc.Subscription, er
|
||||
|
||||
// TODO: fetch bloom from events
|
||||
header := types.EthHeaderFromTendermint(data.Header, ethtypes.Bloom{}, baseFee)
|
||||
err = notifier.Notify(rpcSub.ID, header)
|
||||
if err != nil {
|
||||
headersSub.err <- err
|
||||
return
|
||||
}
|
||||
_ = notifier.Notify(rpcSub.ID, header)
|
||||
case <-rpcSub.Err():
|
||||
headersSub.Unsubscribe(api.events)
|
||||
return
|
||||
@ -381,10 +393,7 @@ func (api *PublicFilterAPI) Logs(ctx context.Context, crit filters.FilterCriteri
|
||||
logs := FilterLogs(evmtypes.LogsToEthereum(txResponse.Logs), crit.FromBlock, crit.ToBlock, crit.Addresses, crit.Topics)
|
||||
|
||||
for _, log := range logs {
|
||||
err = notifier.Notify(rpcSub.ID, log)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
_ = notifier.Notify(rpcSub.ID, log)
|
||||
}
|
||||
case <-rpcSub.Err(): // client send an unsubscribe request
|
||||
logsSub.Unsubscribe(api.events)
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
)
|
||||
|
||||
// Tendermint full-node start flags
|
||||
@ -68,6 +69,8 @@ func AddTxFlags(cmd *cobra.Command) (*cobra.Command, error) {
|
||||
cmd.PersistentFlags().Float64(flags.FlagGasAdjustment, flags.DefaultGasAdjustment, "adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored ")
|
||||
cmd.PersistentFlags().StringP(flags.FlagBroadcastMode, "b", flags.BroadcastSync, "Transaction broadcasting mode (sync|async|block)")
|
||||
cmd.PersistentFlags().String(flags.FlagKeyringBackend, keyring.BackendOS, "Select keyring's backend")
|
||||
cmd.PersistentFlags().BoolP(flags.FlagSkipConfirmation, "y", false, "Skip tx broadcasting prompt confirmation")
|
||||
cmd.Flags().StringP(tmcli.OutputFlag, "o", "text", "Output format (text|json)")
|
||||
|
||||
// --gas can accept integers and "simulate"
|
||||
// cmd.PersistentFlags().Var(&flags.GasFlagVar, "gas", fmt.Sprintf(
|
||||
@ -84,3 +87,15 @@ func AddTxFlags(cmd *cobra.Command) (*cobra.Command, error) {
|
||||
}
|
||||
return cmd, nil
|
||||
}
|
||||
|
||||
// AddGQLFlags adds gql flags for
|
||||
func AddGQLFlags(cmd *cobra.Command) *cobra.Command {
|
||||
// Add flags for GQL server.
|
||||
cmd.PersistentFlags().Bool("gql-server", false, "Start GQL server.")
|
||||
cmd.PersistentFlags().Bool("gql-playground", false, "Enable GQL playground.")
|
||||
cmd.PersistentFlags().String("gql-playground-api-base", "", "GQL API base path to use in GQL playground.")
|
||||
cmd.PersistentFlags().String("gql-port", "9473", "Port to use for the GQL server.")
|
||||
cmd.PersistentFlags().String("log-file", "", "File to tail for GQL 'getLogs' API.")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
@ -44,6 +44,8 @@ import (
|
||||
ethdebug "github.com/tharsis/ethermint/rpc/ethereum/namespaces/debug"
|
||||
"github.com/tharsis/ethermint/server/config"
|
||||
srvflags "github.com/tharsis/ethermint/server/flags"
|
||||
|
||||
"github.com/tharsis/ethermint/gql"
|
||||
)
|
||||
|
||||
// StartCmd runs the service passed in, either stand-alone or in-process with
|
||||
@ -432,6 +434,9 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, appCreator ty
|
||||
}
|
||||
}
|
||||
|
||||
// Start the GQL Server
|
||||
go gql.Server(clientCtx)
|
||||
|
||||
defer func() {
|
||||
if tmNode.IsRunning() {
|
||||
_ = tmNode.Stop()
|
||||
|
@ -721,3 +721,29 @@ func (s *IntegrationTestSuite) TestWeb3Sha3() {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestPendingTransactionFilter() {
|
||||
var (
|
||||
filterID string
|
||||
filterResult []common.Hash
|
||||
)
|
||||
// create filter
|
||||
err := s.rpcClient.Call(&filterID, "eth_newPendingTransactionFilter")
|
||||
s.Require().NoError(err)
|
||||
// check filter result is empty
|
||||
err = s.rpcClient.Call(&filterResult, "eth_getFilterChanges", filterID)
|
||||
s.Require().NoError(err)
|
||||
s.Require().Empty(filterResult)
|
||||
// send transaction
|
||||
signedTx := s.signValidTx(common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), big.NewInt(10)).AsTransaction()
|
||||
err = s.network.Validators[0].JSONRPCClient.SendTransaction(s.ctx, signedTx)
|
||||
s.Require().NoError(err)
|
||||
|
||||
s.waitForTransaction()
|
||||
s.expectSuccessReceipt(signedTx.Hash())
|
||||
|
||||
// check filter changes match the tx hash
|
||||
err = s.rpcClient.Call(&filterResult, "eth_getFilterChanges", filterID)
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal([]common.Hash{signedTx.Hash()}, filterResult)
|
||||
}
|
||||
|
@ -97,7 +97,8 @@ func (cc *ChainContext) Finalize(
|
||||
// consensus rules that happen at finalization (e.g. block rewards).
|
||||
// TODO: Figure out if this needs to be hooked up to any part of the ABCI?
|
||||
func (cc *ChainContext) FinalizeAndAssemble(_ ethcons.ChainHeaderReader, _ *ethtypes.Header, _ *ethstate.StateDB, _ []*ethtypes.Transaction,
|
||||
_ []*ethtypes.Header, _ []*ethtypes.Receipt) (*ethtypes.Block, error) {
|
||||
_ []*ethtypes.Header, _ []*ethtypes.Receipt,
|
||||
) (*ethtypes.Block, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
@ -429,6 +429,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
|
||||
stakingtypes.NewCommissionRates(commission, sdk.OneDec(), sdk.OneDec()),
|
||||
sdk.OneInt(),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ func startInProcess(cfg Config, val *Validator) error {
|
||||
}
|
||||
|
||||
tmEndpoint := "/websocket"
|
||||
tmRPCAddr := fmt.Sprintf("tcp://%s", val.AppConfig.GRPC.Address)
|
||||
tmRPCAddr := val.RPCAddress
|
||||
|
||||
val.jsonrpc, val.jsonrpcDone, err = server.StartJSONRPC(val.Ctx, val.ClientCtx, tmRPCAddr, tmEndpoint, *val.AppConfig)
|
||||
if err != nil {
|
||||
@ -196,6 +196,7 @@ func initGenFiles(cfg Config, genAccounts []authtypes.GenesisAccount, genBalance
|
||||
|
||||
// set the balances in the genesis state
|
||||
var bankGenState banktypes.GenesisState
|
||||
cfg.Codec.MustUnmarshalJSON(cfg.GenesisState[banktypes.ModuleName], &bankGenState)
|
||||
bankGenState.Balances = genBalances
|
||||
cfg.GenesisState[banktypes.ModuleName] = cfg.Codec.MustMarshalJSON(&bankGenState)
|
||||
|
||||
|
52
utils/json.go
Normal file
52
utils/json.go
Normal file
@ -0,0 +1,52 @@
|
||||
//
|
||||
// Copyright 2020 Wireline, Inc.
|
||||
//
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
|
||||
canonicalJson "github.com/gibson042/canonicaljson-go"
|
||||
cbor "github.com/ipfs/go-ipld-cbor"
|
||||
mh "github.com/multiformats/go-multihash"
|
||||
)
|
||||
|
||||
// GenerateHash returns the hash of the canonicalized JSON input.
|
||||
func GenerateHash(json map[string]interface{}) (string, []byte, error) {
|
||||
content, err := canonicalJson.Marshal(json)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
|
||||
cid, err := CIDFromJSONBytes(content)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
|
||||
return cid, content, nil
|
||||
}
|
||||
|
||||
// CIDFromJSONBytes returns CID (cbor) for json (as bytes).
|
||||
func CIDFromJSONBytes(content []byte) (string, error) {
|
||||
cid, err := cbor.FromJSON(bytes.NewReader(content), mh.SHA2_256, -1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return cid.String(), nil
|
||||
}
|
||||
|
||||
// GetAttributeAsString returns a map attribute as string, if possible.
|
||||
func GetAttributeAsString(obj map[string]interface{}, attr string) (string, error) {
|
||||
if value, ok := obj[attr]; ok {
|
||||
if valueStr, ok := value.(string); ok {
|
||||
return valueStr, nil
|
||||
}
|
||||
|
||||
return "", errors.New("attribute not of string type")
|
||||
}
|
||||
|
||||
return "", errors.New("attribute not found")
|
||||
}
|
25
utils/mnemonic.go
Normal file
25
utils/mnemonic.go
Normal file
@ -0,0 +1,25 @@
|
||||
//
|
||||
// Copyright 2020 Wireline, Inc.
|
||||
//
|
||||
|
||||
package utils
|
||||
|
||||
import "github.com/cosmos/go-bip39"
|
||||
|
||||
const (
|
||||
mnemonicEntropySize = 256
|
||||
)
|
||||
|
||||
func GenerateMnemonic() (string, error) {
|
||||
entropySeed, err := bip39.NewEntropy(mnemonicEntropySize)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
mnemonic, err := bip39.NewMnemonic(entropySeed[:])
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return mnemonic, nil
|
||||
}
|
52
utils/types.go
Normal file
52
utils/types.go
Normal file
@ -0,0 +1,52 @@
|
||||
//
|
||||
// Copyright 2020 Wireline, Inc.
|
||||
//
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"sort"
|
||||
|
||||
set "github.com/deckarep/golang-set"
|
||||
)
|
||||
|
||||
func Int64ToBytes(num int64) []byte {
|
||||
buf := new(bytes.Buffer)
|
||||
binary.Write(buf, binary.BigEndian, num)
|
||||
return buf.Bytes()
|
||||
}
|
||||
|
||||
func SetToSlice(set set.Set) []string {
|
||||
names := []string{}
|
||||
|
||||
for name := range set.Iter() {
|
||||
if name, ok := name.(string); ok && name != "" {
|
||||
names = append(names, name)
|
||||
}
|
||||
}
|
||||
|
||||
sort.SliceStable(names, func(i, j int) bool { return names[i] < names[j] })
|
||||
|
||||
return names
|
||||
}
|
||||
|
||||
func SliceToSet(names []string) set.Set {
|
||||
set := set.NewThreadUnsafeSet()
|
||||
|
||||
for _, name := range names {
|
||||
if name != "" {
|
||||
set.Add(name)
|
||||
}
|
||||
}
|
||||
|
||||
return set
|
||||
}
|
||||
|
||||
func AppendUnique(list []string, element string) []string {
|
||||
set := SliceToSet(list)
|
||||
set.Add(element)
|
||||
|
||||
return SetToSlice(set)
|
||||
}
|
298
x/auction/README.md
Normal file
298
x/auction/README.md
Normal file
@ -0,0 +1,298 @@
|
||||
# Auction Module CLI Commands
|
||||
|
||||
## Build the Chain
|
||||
|
||||
The following command builds the Ethermint daemon and places the binary in the `build` directory
|
||||
|
||||
```
|
||||
make build
|
||||
|
||||
```
|
||||
|
||||
## Setup the Chain
|
||||
|
||||
The following steps need to be followed only before running the chain for the first time.
|
||||
|
||||
1. Add the root key:
|
||||
```
|
||||
./build/ethermintd keys add root
|
||||
```
|
||||
Keep a note of the keyring passphrase if you set it.
|
||||
2. Init the chain:
|
||||
```
|
||||
./build/ethermintd init test-moniker --chain-id ethermint_9000-1
|
||||
```
|
||||
3. Add genesis account:
|
||||
```
|
||||
./build/ethermintd add-genesis-account $(./build/ethermintd keys show root -a) 1000000000000000000aphoton,1000000000000000000stake
|
||||
```
|
||||
4. Make a genesis tx:
|
||||
```
|
||||
./build/ethermintd gentx root 1000000000000000000stake --chain-id ethermint_9000-1
|
||||
```
|
||||
5. Collect gentxs:
|
||||
```
|
||||
./build/ethermintd collect-gentxs
|
||||
```
|
||||
|
||||
The chain can now be started using:
|
||||
|
||||
```
|
||||
./build/ethermintd start
|
||||
```
|
||||
|
||||
## Querying the Params
|
||||
|
||||
The following command will dislay the default params for the `auction` module:
|
||||
|
||||
```
|
||||
# ./build/ethermintd q auction params -o json | jq
|
||||
|
||||
{
|
||||
"params": {
|
||||
"commits_duration": "0s",
|
||||
"reveals_duration": "0s",
|
||||
"commit_fee": {
|
||||
"denom": "",
|
||||
"amount": "0"
|
||||
},
|
||||
"reveal_fee": {
|
||||
"denom": "",
|
||||
"amount": "0"
|
||||
},
|
||||
"minimum_bid": {
|
||||
"denom": "",
|
||||
"amount": "0"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Auction TX CLI Commands
|
||||
|
||||
### Create Auction
|
||||
|
||||
```
|
||||
# ./build/ethermintd tx auction create 100s 100s 10aphoton 10aphoton 1000aphoton --from root --chain-id $(./build/ethermintd status | jq .NodeInfo.network -r)
|
||||
|
||||
Enter keyring passphrase:
|
||||
|
||||
{"body":{"messages":[{"@type":"/vulcanize.auction.v1beta1.MsgCreateAuction","commits_duration":"100s","reveals_duration":"100s","commit_fee":{"denom":"aphoton","amount":"10"},"reveal_fee":{"denom":"aphoton","amount":"10"},"minimum_bid":{"denom":"aphoton","amount":"1000"},"signer":"ethm1l7cstwtf2lvev27ka67c23yk7mmj8ad7tetpqc"}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}
|
||||
|
||||
confirm transaction before signing and broadcasting [y/N]: y
|
||||
|
||||
code: 0
|
||||
codespace: ""
|
||||
data: ""
|
||||
gas_used: "0"
|
||||
gas_wanted: "0"
|
||||
height: "0"
|
||||
info: ""
|
||||
logs: []
|
||||
raw_log: '[]'
|
||||
timestamp: ""
|
||||
tx: null
|
||||
txhash: ECAD6DF1ECA763FBD26EB7C2C0B77425FFE2FBEA2BEC57CE0FBC173AE0F45298
|
||||
```
|
||||
|
||||
### Commit Bid
|
||||
|
||||
```
|
||||
# ./build/ethermintd tx auction commit-bid e7d14c7e7a6d7537cbdb8fbe62f22b1553c2ef4ce3705ada7c28f80faf2fbe0d 2000aphoton --from root --chain-id $(./build/ethermintd status | jq .NodeInfo.network -r)
|
||||
|
||||
Enter keyring passphrase:
|
||||
|
||||
{"body":{"messages":[{"@type":"/vulcanize.auction.v1beta1.MsgCommitBid","auction_id":"e7d14c7e7a6d7537cbdb8fbe62f22b1553c2ef4ce3705ada7c28f80faf2fbe0d","commit_hash":"bafyreibt4twofrc3xi2es27cfrroy346iy6lr3gkw33i5dltkqqarlyltm","signer":"ethm1l7cstwtf2lvev27ka67c23yk7mmj8ad7tetpqc"}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}
|
||||
|
||||
confirm transaction before signing and broadcasting [y/N]: y
|
||||
|
||||
code: 0
|
||||
codespace: ""
|
||||
data: ""
|
||||
gas_used: "0"
|
||||
gas_wanted: "0"
|
||||
height: "0"
|
||||
info: ""
|
||||
logs: []
|
||||
raw_log: '[]'
|
||||
timestamp: ""
|
||||
tx: null
|
||||
txhash: 71D8CF34026E32A3A34C2C2D4ADF25ABC8D7943A4619761BE27F196603D91B9D
|
||||
```
|
||||
|
||||
### Reveal Bid
|
||||
|
||||
```
|
||||
# ./build/ethermintd tx auction reveal-bid e7d14c7e7a6d7537cbdb8fbe62f22b1553c2ef4ce3705ada7c28f80faf2fbe0d root-bafyreibt4twofrc3xi2es27cfrroy346iy6lr3gkw33i5dltkqqarlyltm.json --from root --chain-id $(./build/ethermintd status | jq .NodeInfo.network -r)
|
||||
|
||||
Enter keyring passphrase:
|
||||
|
||||
{"body":{"messages":[{"@type":"/vulcanize.auction.v1beta1.MsgRevealBid","auction_id":"e7d14c7e7a6d7537cbdb8fbe62f22b1553c2ef4ce3705ada7c28f80faf2fbe0d","reveal":"7b2261756374696f6e4964223a2265376431346337653761366437353337636264623866626536326632326231353533633265663463653337303561646137633238663830666166326662653064222c22626964416d6f756e74223a22323030306170686f746f6e222c2262696464657241646472657373223a226574686d316c37637374777466326c76657632376b613637633233796b376d6d6a38616437746574707163222c22636861696e4964223a2265746865726d696e745f393030302d31222c226e6f697365223a22636c69666620737566666572206472616d6120676f7370656c2077656173656c207061706572206c696272617279206469736f726465722063757276652073706f74206375727461696e207a6562726120696e76657374206465766f74652072656e64657220636c6970207377616c6c6f77206d6f6e6b6579206f62736572766520726573706f6e7365206c696e6b206372616e6520766961626c6520736576656e227d","signer":"ethm1l7cstwtf2lvev27ka67c23yk7mmj8ad7tetpqc"}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}
|
||||
|
||||
confirm transaction before signing and broadcasting [y/N]: y
|
||||
|
||||
code: 0
|
||||
codespace: ""
|
||||
data: ""
|
||||
gas_used: "0"
|
||||
gas_wanted: "0"
|
||||
height: "0"
|
||||
info: ""
|
||||
logs: []
|
||||
raw_log: '[]'
|
||||
timestamp: ""
|
||||
tx: null
|
||||
txhash: 4D1C0B3DDA4050F9BB32240FBD5234229E5C32543C1A0A78033B9531EB0CF8BA
|
||||
```
|
||||
|
||||
## Auction Query CLI Commands
|
||||
|
||||
### List Auctions
|
||||
|
||||
```
|
||||
# ./build/ethermintd q auction list
|
||||
|
||||
auctions:
|
||||
auctions:
|
||||
- commit_fee:
|
||||
amount: "10"
|
||||
denom: aphoton
|
||||
commits_end_time: "2021-09-30T07:57:07.933412800Z"
|
||||
create_time: "2021-09-30T07:55:27.933412800Z"
|
||||
id: e7d14c7e7a6d7537cbdb8fbe62f22b1553c2ef4ce3705ada7c28f80faf2fbe0d
|
||||
minimum_bid:
|
||||
amount: "1000"
|
||||
denom: aphoton
|
||||
owner_address: ethm1l7cstwtf2lvev27ka67c23yk7mmj8ad7tetpqc
|
||||
reveal_fee:
|
||||
amount: "10"
|
||||
denom: aphoton
|
||||
reveals_end_time: "2021-09-30T07:58:47.933412800Z"
|
||||
status: commit
|
||||
winner_address: ""
|
||||
winning_bid:
|
||||
amount: "0"
|
||||
denom: ""
|
||||
winning_price:
|
||||
amount: "0"
|
||||
denom: ""
|
||||
pagination: null
|
||||
```
|
||||
|
||||
### Get Bid
|
||||
|
||||
```
|
||||
# ./build/ethermintd q auction get-bid e7d14c7e7a6d7537cbdb8fbe62f22b1553c2ef4ce3705ada7c28f80faf2fbe0e ethm1l7cstwtf2lvev27ka67c23yk7mmj8ad7tetpqc
|
||||
|
||||
bid:
|
||||
auction_id: e7d14c7e7a6d7537cbdb8fbe62f22b1553c2ef4ce3705ada7c28f80faf2fbe0d
|
||||
bid_amount:
|
||||
amount: "0"
|
||||
denom: ""
|
||||
bidder_address: ethm1l7cstwtf2lvev27ka67c23yk7mmj8ad7tetpqc
|
||||
commit_fee:
|
||||
amount: "10"
|
||||
denom: aphoton
|
||||
commit_hash: bafyreibt4twofrc3xi2es27cfrroy346iy6lr3gkw33i5dltkqqarlyltm
|
||||
commit_time: "2021-09-30T08:49:48.358878200Z"
|
||||
reveal_fee:
|
||||
amount: "10"
|
||||
denom: aphoton
|
||||
reveal_time: "0001-01-01T00:00:00Z"
|
||||
status: commit
|
||||
```
|
||||
|
||||
### Get All Bids for an Auction
|
||||
|
||||
```
|
||||
./build/ethermintd q auction get-bids e7d14c7e7a6d7537cbdb8fbe62f22b1553c2ef4ce3705ada7c28f80faf2fbe0d
|
||||
|
||||
bids:
|
||||
- auction_id: e7d14c7e7a6d7537cbdb8fbe62f22b1553c2ef4ce3705ada7c28f80faf2fbe0d
|
||||
bid_amount:
|
||||
amount: "0"
|
||||
denom: ""
|
||||
bidder_address: ethm1l7cstwtf2lvev27ka67c23yk7mmj8ad7tetpqc
|
||||
commit_fee:
|
||||
amount: "10"
|
||||
denom: aphoton
|
||||
commit_hash: bafyreibt4twofrc3xi2es27cfrroy346iy6lr3gkw33i5dltkqqarlyltm
|
||||
commit_time: "2021-09-30T08:49:48.358878200Z"
|
||||
reveal_fee:
|
||||
amount: "10"
|
||||
denom: aphoton
|
||||
reveal_time: "0001-01-01T00:00:00Z"
|
||||
status: commit
|
||||
```
|
||||
|
||||
### Get Auction by AuctionID
|
||||
|
||||
```
|
||||
# ./build/ethermintd q auction get e7d14c7e7a6d7537cbdb8fbe62f22b1553c2ef4ce3705ada7c28f80faf2fbe0d
|
||||
|
||||
auction:
|
||||
commit_fee:
|
||||
amount: "10"
|
||||
denom: aphoton
|
||||
commits_end_time: "2021-09-30T07:57:07.933412800Z"
|
||||
create_time: "2021-09-30T07:55:27.933412800Z"
|
||||
id: e7d14c7e7a6d7537cbdb8fbe62f22b1553c2ef4ce3705ada7c28f80faf2fbe0d
|
||||
minimum_bid:
|
||||
amount: "1000"
|
||||
denom: aphoton
|
||||
owner_address: ethm1l7cstwtf2lvev27ka67c23yk7mmj8ad7tetpqc
|
||||
reveal_fee:
|
||||
amount: "10"
|
||||
denom: aphoton
|
||||
reveals_end_time: "2021-09-30T07:58:47.933412800Z"
|
||||
status: commit
|
||||
winner_address: ""
|
||||
winning_bid:
|
||||
amount: "0"
|
||||
denom: ""
|
||||
winning_price:
|
||||
amount: "0"
|
||||
denom: ""
|
||||
|
||||
```
|
||||
|
||||
### Get Auction by Bidder
|
||||
|
||||
```
|
||||
# ./build/ethermintd q auction query-by-owner ethm1l7cstwtf2lvev27ka67c23yk7mmj8ad7tetpqc
|
||||
|
||||
auctions:
|
||||
auctions:
|
||||
- commit_fee:
|
||||
amount: "10"
|
||||
denom: aphoton
|
||||
commits_end_time: "2021-09-30T07:57:07.933412800Z"
|
||||
create_time: "2021-09-30T07:55:27.933412800Z"
|
||||
id: e7d14c7e7a6d7537cbdb8fbe62f22b1553c2ef4ce3705ada7c28f80faf2fbe0d
|
||||
minimum_bid:
|
||||
amount: "1000"
|
||||
denom: aphoton
|
||||
owner_address: ethm1l7cstwtf2lvev27ka67c23yk7mmj8ad7tetpqc
|
||||
reveal_fee:
|
||||
amount: "10"
|
||||
denom: aphoton
|
||||
reveals_end_time: "2021-09-30T07:58:47.933412800Z"
|
||||
status: commit
|
||||
winner_address: ""
|
||||
winning_bid:
|
||||
amount: "0"
|
||||
denom: ""
|
||||
winning_price:
|
||||
amount: "0"
|
||||
denom: ""
|
||||
```
|
||||
|
||||
### Query Account Balance
|
||||
|
||||
```
|
||||
# ./build/ethermintd q auction balance
|
||||
|
||||
balance:
|
||||
- amount: "20"
|
||||
denom: aphoton
|
||||
```
|
13
x/auction/abci.go
Normal file
13
x/auction/abci.go
Normal file
@ -0,0 +1,13 @@
|
||||
package auction
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tharsis/ethermint/x/auction/keeper"
|
||||
)
|
||||
|
||||
// EndBlocker is called every block, returns updated validator set.
|
||||
func EndBlocker(ctx sdk.Context, k keeper.Keeper) []abci.ValidatorUpdate {
|
||||
k.EndBlockerProcessAuctions(ctx)
|
||||
return []abci.ValidatorUpdate{}
|
||||
}
|
263
x/auction/client/cli/query.go
Normal file
263
x/auction/client/cli/query.go
Normal file
@ -0,0 +1,263 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/tharsis/ethermint/x/auction/types"
|
||||
)
|
||||
|
||||
func GetQueryCmd() *cobra.Command {
|
||||
auctionQueryCmd := &cobra.Command{
|
||||
Use: types.ModuleName,
|
||||
Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName),
|
||||
DisableFlagParsing: true,
|
||||
SuggestionsMinimumDistance: 2,
|
||||
RunE: client.ValidateCmd,
|
||||
}
|
||||
auctionQueryCmd.AddCommand(
|
||||
GetCmdList(),
|
||||
GetCmdGetAuction(),
|
||||
GetCmdGetBid(),
|
||||
GetCmdGetBids(),
|
||||
GetCmdAuctionsByBidder(),
|
||||
GetCmdAuctionsByOwner(),
|
||||
GetCmdQueryParams(),
|
||||
GetCmdBalance(),
|
||||
)
|
||||
|
||||
return auctionQueryCmd
|
||||
}
|
||||
|
||||
// GetCmdList queries all auctions.
|
||||
func GetCmdList() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List auctions.",
|
||||
Args: cobra.ExactArgs(0),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
res, err := queryClient.Auctions(cmd.Context(), &types.AuctionsRequest{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdGetBid queries an auction bid.
|
||||
func GetCmdGetBid() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "get-bid [auction-id] [bidder]",
|
||||
Short: "Get auction bid.",
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
id := args[0]
|
||||
bidder := args[1]
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
res, err := queryClient.GetBid(cmd.Context(), &types.BidRequest{AuctionId: id, Bidder: bidder})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdGetBids queries all auction bids.
|
||||
func GetCmdGetBids() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "get-bids [auction-id]",
|
||||
Short: "Get all auction bids.",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
id := args[0]
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
res, err := queryClient.GetBids(cmd.Context(), &types.BidsRequest{AuctionId: id})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdGetAuction queries an auction.
|
||||
func GetCmdGetAuction() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "get [ID]",
|
||||
Short: "Get auction.",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
id := args[0]
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
res, err := queryClient.GetAuction(cmd.Context(), &types.AuctionRequest{Id: id})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdAuctionsByBidder queries auctions by bidder.
|
||||
func GetCmdAuctionsByBidder() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "query-by-bidder [address]",
|
||||
Short: "Query auctions by bidder.",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
address := args[0]
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
res, err := queryClient.AuctionsByBidder(cmd.Context(), &types.AuctionsByBidderRequest{BidderAddress: address})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdAuctionsByOwner queries auctions by owner
|
||||
func GetCmdAuctionsByOwner() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "query-by-owner [address]",
|
||||
Short: "Query auctions by owner/creator.",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
address := args[0]
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
res, err := queryClient.AuctionsByOwner(cmd.Context(), &types.AuctionsByOwnerRequest{OwnerAddress: address})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdQueryParams implements the params query command.
|
||||
func GetCmdQueryParams() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "params",
|
||||
Args: cobra.NoArgs,
|
||||
Short: "Query the current auction parameters information.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Query values set as auction parameters.
|
||||
Example:
|
||||
$ %s query auction params
|
||||
`,
|
||||
version.AppName,
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
res, err := queryClient.QueryParams(cmd.Context(), &types.QueryParamsRequest{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdBalance queries the auction module account balance.
|
||||
func GetCmdBalance() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "balance",
|
||||
Short: "Get auction module account balance.",
|
||||
Args: cobra.ExactArgs(0),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
res, err := queryClient.Balance(cmd.Context(), &types.BalanceRequest{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
187
x/auction/client/cli/tx.go
Normal file
187
x/auction/client/cli/tx.go
Normal file
@ -0,0 +1,187 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"time"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/tharsis/ethermint/x/auction/types"
|
||||
|
||||
wnsUtils "github.com/tharsis/ethermint/utils"
|
||||
)
|
||||
|
||||
// GetTxCmd returns transaction commands for this module.
|
||||
func GetTxCmd() *cobra.Command {
|
||||
auctionTxCmd := &cobra.Command{
|
||||
Use: types.ModuleName,
|
||||
Short: "Auction transactions subcommands",
|
||||
DisableFlagParsing: true,
|
||||
SuggestionsMinimumDistance: 2,
|
||||
RunE: client.ValidateCmd,
|
||||
}
|
||||
|
||||
auctionTxCmd.AddCommand(
|
||||
GetCmdCreateAuction(),
|
||||
GetCmdCommitBid(),
|
||||
GetCmdRevealBid(),
|
||||
)
|
||||
|
||||
return auctionTxCmd
|
||||
}
|
||||
|
||||
func GetCmdCreateAuction() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "create [commits-duration] [reveals-duration] [commit-fee] [reveal-fee] [minimum-bid]",
|
||||
Short: "Create auction.",
|
||||
Args: cobra.ExactArgs(5),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
commitsDuration, err := time.ParseDuration(args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
revealsDuration, err := time.ParseDuration(args[1])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
commitFee, err := sdk.ParseCoinNormalized(args[2])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
revealFee, err := sdk.ParseCoinNormalized(args[3])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
minimumBid, err := sdk.ParseCoinNormalized(args[4])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params := types.Params{
|
||||
CommitsDuration: commitsDuration,
|
||||
RevealsDuration: revealsDuration,
|
||||
CommitFee: commitFee,
|
||||
RevealFee: revealFee,
|
||||
MinimumBid: minimumBid,
|
||||
}
|
||||
msg := types.NewMsgCreateAuction(params, clientCtx.GetFromAddress())
|
||||
err = msg.ValidateBasic()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdCommitBid is the CLI command for committing a bid.
|
||||
func GetCmdCommitBid() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "commit-bid [auction-id] [bid-amount]",
|
||||
Short: "Commit sealed bid.",
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
bidAmount, err := sdk.ParseCoinNormalized(args[1])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mnemonic, err := wnsUtils.GenerateMnemonic()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
chainID := viper.GetString("chain-id")
|
||||
auctionID := args[0]
|
||||
|
||||
reveal := map[string]interface{}{
|
||||
"chainId": chainID,
|
||||
"auctionId": auctionID,
|
||||
"bidderAddress": clientCtx.GetFromAddress().String(),
|
||||
"bidAmount": bidAmount.String(),
|
||||
"noise": mnemonic,
|
||||
}
|
||||
|
||||
commitHash, content, err := wnsUtils.GenerateHash(reveal)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Save reveal file.
|
||||
ioutil.WriteFile(fmt.Sprintf("%s-%s.json", clientCtx.GetFromName(), commitHash), content, 0600)
|
||||
|
||||
msg := types.NewMsgCommitBid(auctionID, commitHash, clientCtx.GetFromAddress())
|
||||
err = msg.ValidateBasic()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdRevealBid is the CLI command for revealing a bid.
|
||||
func GetCmdRevealBid() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "reveal-bid [auction-id] [reveal-file-path]",
|
||||
Short: "Reveal bid.",
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
auctionID := args[0]
|
||||
revealFilePath := args[1]
|
||||
|
||||
revealBytes, err := ioutil.ReadFile(revealFilePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
msg := types.NewMsgRevealBid(auctionID, hex.EncodeToString(revealBytes), clientCtx.GetFromAddress())
|
||||
err = msg.ValidateBasic()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
16
x/auction/client/testutil/cli_test.go
Normal file
16
x/auction/client/testutil/cli_test.go
Normal file
@ -0,0 +1,16 @@
|
||||
package testutil
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/tharsis/ethermint/testutil/network"
|
||||
)
|
||||
|
||||
func TestIntegrationTestSuite(t *testing.T) {
|
||||
cfg := network.DefaultConfig()
|
||||
cfg.NumValidators = 1
|
||||
|
||||
suite.Run(t, NewIntegrationTestSuite(cfg))
|
||||
}
|
80
x/auction/client/testutil/common.go
Normal file
80
x/auction/client/testutil/common.go
Normal file
@ -0,0 +1,80 @@
|
||||
package testutil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
banktestutil "github.com/cosmos/cosmos-sdk/x/bank/client/testutil"
|
||||
"github.com/stretchr/testify/suite"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
"github.com/tharsis/ethermint/crypto/hd"
|
||||
"github.com/tharsis/ethermint/testutil/network"
|
||||
)
|
||||
|
||||
type IntegrationTestSuite struct {
|
||||
suite.Suite
|
||||
|
||||
cfg network.Config
|
||||
network *network.Network
|
||||
defaultAuctionID string
|
||||
}
|
||||
|
||||
var (
|
||||
ownerAccount = "owner"
|
||||
bidderAccount = "bidder"
|
||||
ownerAddress string
|
||||
bidderAddress string
|
||||
)
|
||||
|
||||
func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite {
|
||||
return &IntegrationTestSuite{cfg: cfg}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) SetupSuite() {
|
||||
s.T().Log("setting up integration test suite")
|
||||
|
||||
var err error
|
||||
s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg)
|
||||
s.Require().NoError(err)
|
||||
|
||||
_, err = s.network.WaitForHeight(1)
|
||||
s.Require().NoError(err)
|
||||
|
||||
// setting up random owner and bidder accounts
|
||||
s.createAccountWithBalance(ownerAccount, &ownerAddress)
|
||||
s.createAccountWithBalance(bidderAccount, &bidderAddress)
|
||||
|
||||
s.defaultAuctionID = s.createAuctionAndBid(true, false)
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TearDownSuite() {
|
||||
s.T().Log("tearing down integration test suite")
|
||||
s.network.Cleanup()
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) createAccountWithBalance(accountName string, accountAddress *string) {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
|
||||
info, _, err := val.ClientCtx.Keyring.NewMnemonic(accountName, keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.EthSecp256k1)
|
||||
sr.NoError(err)
|
||||
|
||||
val.ClientCtx.Keyring.SavePubKey(accountName, info.GetPubKey(), hd.EthSecp256k1Type)
|
||||
|
||||
newAddr := sdk.AccAddress(info.GetPubKey().Address())
|
||||
_, err = banktestutil.MsgSendExec(
|
||||
val.ClientCtx,
|
||||
val.Address,
|
||||
newAddr,
|
||||
sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(200000))),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||
)
|
||||
sr.NoError(err)
|
||||
*accountAddress = newAddr.String()
|
||||
}
|
255
x/auction/client/testutil/grpc.go
Normal file
255
x/auction/client/testutil/grpc.go
Normal file
@ -0,0 +1,255 @@
|
||||
package testutil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/types/rest"
|
||||
auctiontypes "github.com/tharsis/ethermint/x/auction/types"
|
||||
)
|
||||
|
||||
const (
|
||||
randomAuctionID = "randomAuctionID"
|
||||
randomBidderAddress = "randomBidderAddress"
|
||||
randomOwnerAddress = "randomOwnerAddress"
|
||||
)
|
||||
|
||||
func (suite *IntegrationTestSuite) TestGetAllAuctionsGrpc() {
|
||||
val := suite.network.Validators[0]
|
||||
sr := suite.Require()
|
||||
reqUrl := fmt.Sprintf("%s/vulcanize/auction/v1beta1/auctions", val.APIAddress)
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
url string
|
||||
errorMsg string
|
||||
isErrorExpected bool
|
||||
}{
|
||||
{
|
||||
"invalid request to get all auctions",
|
||||
reqUrl + randomAuctionID,
|
||||
"",
|
||||
true,
|
||||
},
|
||||
{
|
||||
"valid request to get all auctions",
|
||||
reqUrl,
|
||||
"",
|
||||
false,
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
suite.Run(tc.msg, func() {
|
||||
resp, err := rest.GetRequest(tc.url)
|
||||
if tc.isErrorExpected {
|
||||
sr.Contains(string(resp), tc.errorMsg)
|
||||
} else {
|
||||
sr.NoError(err)
|
||||
var auctions auctiontypes.AuctionsResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &auctions)
|
||||
sr.NotZero(len(auctions.Auctions.Auctions))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *IntegrationTestSuite) TestQueryParamsGrpc() {
|
||||
val := suite.network.Validators[0]
|
||||
sr := suite.Require()
|
||||
reqUrl := fmt.Sprintf("%s/vulcanize/auction/v1beta1/params", val.APIAddress)
|
||||
|
||||
suite.Run("valid request to get auction params", func() {
|
||||
resp, err := rest.GetRequest(reqUrl)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
var params auctiontypes.QueryParamsResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(resp, ¶ms)
|
||||
|
||||
sr.NoError(err)
|
||||
sr.Equal(*params.GetParams(), auctiontypes.DefaultParams())
|
||||
})
|
||||
}
|
||||
|
||||
func (suite *IntegrationTestSuite) TestGetAuctionGrpc() {
|
||||
val := suite.network.Validators[0]
|
||||
sr := suite.Require()
|
||||
reqUrl := fmt.Sprintf("%s/vulcanize/auction/v1beta1/auctions/", val.APIAddress)
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
url string
|
||||
errorMsg string
|
||||
isErrorExpected bool
|
||||
preRun func() string
|
||||
}{
|
||||
{
|
||||
"invalid request to get an auction",
|
||||
reqUrl + randomAuctionID,
|
||||
"",
|
||||
true,
|
||||
func() string { return "" },
|
||||
},
|
||||
{
|
||||
"valid request to get an auction",
|
||||
reqUrl,
|
||||
"",
|
||||
false,
|
||||
func() string { return suite.defaultAuctionID },
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
suite.Run(tc.msg, func() {
|
||||
auctionID := tc.preRun()
|
||||
resp, err := rest.GetRequest(tc.url + auctionID)
|
||||
if tc.isErrorExpected {
|
||||
sr.Contains(string(resp), tc.errorMsg)
|
||||
} else {
|
||||
sr.NoError(err)
|
||||
var auction auctiontypes.AuctionResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &auction)
|
||||
sr.NoError(err)
|
||||
sr.Equal(auctionID, auction.Auction.Id)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *IntegrationTestSuite) TestGetBidsGrpc() {
|
||||
val := suite.network.Validators[0]
|
||||
sr := suite.Require()
|
||||
reqUrl := fmt.Sprintf("%s/vulcanize/auction/v1beta1/bids/", val.APIAddress)
|
||||
testCases := []struct {
|
||||
msg string
|
||||
url string
|
||||
errorMsg string
|
||||
isErrorExpected bool
|
||||
preRun func() string
|
||||
}{
|
||||
{
|
||||
"invalid request to get all bids",
|
||||
reqUrl,
|
||||
"",
|
||||
true,
|
||||
func() string { return "" },
|
||||
},
|
||||
{
|
||||
"valid request to get all bids",
|
||||
reqUrl,
|
||||
"",
|
||||
false,
|
||||
func() string { return suite.createAuctionAndBid(false, true) },
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
suite.Run(tc.msg, func() {
|
||||
auctionID := tc.preRun()
|
||||
tc.url += auctionID
|
||||
resp, err := rest.GetRequest(tc.url)
|
||||
if tc.isErrorExpected {
|
||||
sr.Contains(string(resp), tc.errorMsg)
|
||||
} else {
|
||||
sr.NoError(err)
|
||||
var bids auctiontypes.BidsResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &bids)
|
||||
sr.NoError(err)
|
||||
sr.Equal(auctionID, bids.Bids[0].AuctionId)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *IntegrationTestSuite) TestGetBidGrpc() {
|
||||
val := suite.network.Validators[0]
|
||||
sr := suite.Require()
|
||||
reqUrl := fmt.Sprintf("%s/vulcanize/auction/v1beta1/bids/", val.APIAddress)
|
||||
testCases := []struct {
|
||||
msg string
|
||||
url string
|
||||
errorMsg string
|
||||
isErrorExpected bool
|
||||
}{
|
||||
{
|
||||
"invalid request to get bid",
|
||||
fmt.Sprintf("%s/%s/", reqUrl, randomAuctionID),
|
||||
"",
|
||||
true,
|
||||
},
|
||||
{
|
||||
"valid request to get bid",
|
||||
fmt.Sprintf("%s/%s/%s", reqUrl, randomAuctionID, randomBidderAddress),
|
||||
"",
|
||||
false,
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
suite.Run(tc.msg, func() {
|
||||
resp, err := rest.GetRequest(tc.url)
|
||||
if tc.isErrorExpected {
|
||||
sr.Contains(string(resp), tc.errorMsg)
|
||||
} else {
|
||||
sr.NoError(err)
|
||||
var bid auctiontypes.BidResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &bid)
|
||||
sr.NoError(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *IntegrationTestSuite) TestGetAuctionsByOwnerGrpc() {
|
||||
val := suite.network.Validators[0]
|
||||
sr := suite.Require()
|
||||
reqUrl := fmt.Sprintf("%s/vulcanize/auction/v1beta1/by-owner/", val.APIAddress)
|
||||
testCases := []struct {
|
||||
msg string
|
||||
url string
|
||||
errorMsg string
|
||||
isErrorExpected bool
|
||||
}{
|
||||
{
|
||||
"invalid request to get auctions by owner",
|
||||
reqUrl,
|
||||
"",
|
||||
true,
|
||||
},
|
||||
{
|
||||
"valid request to get auctions by owner",
|
||||
fmt.Sprintf("%s/%s", reqUrl, randomOwnerAddress),
|
||||
"",
|
||||
false,
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
suite.Run(tc.msg, func() {
|
||||
resp, err := rest.GetRequest(tc.url)
|
||||
if tc.isErrorExpected {
|
||||
sr.Contains(string(resp), tc.errorMsg)
|
||||
} else {
|
||||
sr.NoError(err)
|
||||
var auctions auctiontypes.AuctionsResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &auctions)
|
||||
sr.NoError(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *IntegrationTestSuite) TestQueryBalanceGrpc() {
|
||||
val := suite.network.Validators[0]
|
||||
sr := suite.Require()
|
||||
reqUrl := fmt.Sprintf("%s/vulcanize/auction/v1beta1/balance", val.APIAddress)
|
||||
msg := "valid request to get the auction module balance"
|
||||
|
||||
suite.createAuctionAndBid(false, true)
|
||||
|
||||
suite.Run(msg, func() {
|
||||
resp, err := rest.GetRequest(reqUrl)
|
||||
sr.NoError(err)
|
||||
|
||||
var response auctiontypes.BalanceResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &response)
|
||||
|
||||
sr.NoError(err)
|
||||
sr.NotZero(len(response.GetBalance()))
|
||||
})
|
||||
}
|
311
x/auction/client/testutil/query.go
Normal file
311
x/auction/client/testutil/query.go
Normal file
@ -0,0 +1,311 @@
|
||||
package testutil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
"github.com/tharsis/ethermint/x/auction/client/cli"
|
||||
"github.com/tharsis/ethermint/x/auction/types"
|
||||
)
|
||||
|
||||
var queryJSONFlag = []string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)}
|
||||
|
||||
func (suite *IntegrationTestSuite) TestGetCmdQueryParams() {
|
||||
val := suite.network.Validators[0]
|
||||
sr := suite.Require()
|
||||
|
||||
suite.Run(fmt.Sprintf("Case %s", "fetch query params"), func() {
|
||||
out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cli.GetCmdQueryParams(), queryJSONFlag)
|
||||
sr.NoError(err)
|
||||
var params types.QueryParamsResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), ¶ms)
|
||||
sr.NoError(err)
|
||||
sr.Equal(types.DefaultParams(), *params.Params)
|
||||
})
|
||||
}
|
||||
|
||||
func (suite *IntegrationTestSuite) TestGetCmdBalance() {
|
||||
val := suite.network.Validators[0]
|
||||
sr := suite.Require()
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
createAuctionAndBid bool
|
||||
}{
|
||||
{
|
||||
"fetch module balance without creating auction and bid",
|
||||
false,
|
||||
},
|
||||
{
|
||||
"fetch module balance with valid auction and bid",
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", test.msg), func() {
|
||||
if test.createAuctionAndBid {
|
||||
suite.createAuctionAndBid(false, true)
|
||||
}
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cli.GetCmdBalance(), queryJSONFlag)
|
||||
sr.NoError(err)
|
||||
var balance types.BalanceResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &balance)
|
||||
sr.NoError(err)
|
||||
if test.createAuctionAndBid {
|
||||
sr.NotZero(len(balance.Balance))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *IntegrationTestSuite) TestGetCmdList() {
|
||||
val := suite.network.Validators[0]
|
||||
sr := suite.Require()
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
createAuction bool
|
||||
}{
|
||||
{
|
||||
"list auctions when no auctions exist",
|
||||
false,
|
||||
},
|
||||
{
|
||||
"list auctions after creating an auction",
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", test.msg), func() {
|
||||
out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cli.GetCmdList(), queryJSONFlag)
|
||||
sr.NoError(err)
|
||||
var auctions types.AuctionsResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &auctions)
|
||||
sr.NoError(err)
|
||||
if test.createAuction {
|
||||
sr.NotZero(len(auctions.Auctions.Auctions))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *IntegrationTestSuite) TestGetCmdGetBid() {
|
||||
val := suite.network.Validators[0]
|
||||
sr := suite.Require()
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
args []string
|
||||
createAuctionAndBid bool
|
||||
}{
|
||||
{
|
||||
"get bid without creating auction",
|
||||
[]string{},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"get bid after creating auction and bid",
|
||||
[]string{},
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", test.msg), func() {
|
||||
if test.createAuctionAndBid {
|
||||
auctionID := suite.createAuctionAndBid(false, true)
|
||||
test.args = append(test.args, auctionID)
|
||||
getBidsArgs := []string{auctionID, queryJSONFlag[0]}
|
||||
out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cli.GetCmdGetBids(), getBidsArgs)
|
||||
sr.NoError(err)
|
||||
var bids types.BidsResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &bids)
|
||||
sr.NoError(err)
|
||||
test.args = append(test.args, bids.GetBids()[0].BidderAddress)
|
||||
}
|
||||
|
||||
test.args = append(test.args, queryJSONFlag...)
|
||||
out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cli.GetCmdGetBid(), test.args)
|
||||
if test.createAuctionAndBid {
|
||||
sr.NoError(err)
|
||||
var bid types.BidResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &bid)
|
||||
sr.NoError(err)
|
||||
sr.NotNil(bid.GetBid())
|
||||
} else {
|
||||
sr.Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *IntegrationTestSuite) TestGetCmdGetBids() {
|
||||
val := suite.network.Validators[0]
|
||||
sr := suite.Require()
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
args []string
|
||||
createAuctionAndBid bool
|
||||
}{
|
||||
{
|
||||
"get bids without creating auction",
|
||||
[]string{},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"get bids after creating auction and bid",
|
||||
[]string{},
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", test.msg), func() {
|
||||
if test.createAuctionAndBid {
|
||||
auctionID := suite.createAuctionAndBid(false, true)
|
||||
test.args = append(test.args, auctionID)
|
||||
}
|
||||
|
||||
test.args = append(test.args, queryJSONFlag...)
|
||||
out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cli.GetCmdGetBids(), test.args)
|
||||
if test.createAuctionAndBid {
|
||||
sr.NoError(err)
|
||||
var bids types.BidsResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &bids)
|
||||
sr.NoError(err)
|
||||
sr.NotZero(len(bids.Bids))
|
||||
} else {
|
||||
sr.Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *IntegrationTestSuite) TestGetCmdGetAuction() {
|
||||
val := suite.network.Validators[0]
|
||||
sr := suite.Require()
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
auctionID string
|
||||
createAuction bool
|
||||
}{
|
||||
{
|
||||
"get auction with empty auction ID",
|
||||
"",
|
||||
false,
|
||||
},
|
||||
{
|
||||
"get auction with valid auction ID",
|
||||
"",
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", test.msg), func() {
|
||||
if test.createAuction {
|
||||
test.auctionID = suite.defaultAuctionID
|
||||
}
|
||||
|
||||
args := []string{test.auctionID, queryJSONFlag[0]}
|
||||
out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cli.GetCmdGetAuction(), args)
|
||||
if test.createAuction {
|
||||
sr.NoError(err)
|
||||
var auction types.AuctionResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &auction)
|
||||
sr.NoError(err)
|
||||
sr.NotNil(auction.GetAuction())
|
||||
sr.Equal(test.auctionID, auction.GetAuction().Id)
|
||||
} else {
|
||||
sr.Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *IntegrationTestSuite) TestGetCmdAuctionsByBidder() {
|
||||
val := suite.network.Validators[0]
|
||||
sr := suite.Require()
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
createAuctionAndBid bool
|
||||
bidderAddress string
|
||||
}{
|
||||
{
|
||||
"get auctions by bidder without creating auctions",
|
||||
false,
|
||||
"",
|
||||
},
|
||||
{
|
||||
"get auctions by bidder for valid bidder address",
|
||||
true,
|
||||
"",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", test.msg), func() {
|
||||
if test.createAuctionAndBid {
|
||||
auctionID := suite.createAuctionAndBid(false, true)
|
||||
args := []string{auctionID, queryJSONFlag[0]}
|
||||
out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cli.GetCmdGetBids(), args)
|
||||
sr.NoError(err)
|
||||
var bids types.BidsResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &bids)
|
||||
sr.NoError(err)
|
||||
test.bidderAddress = bids.Bids[0].BidderAddress
|
||||
}
|
||||
|
||||
getByBidderArgs := []string{test.bidderAddress, queryJSONFlag[0]}
|
||||
_, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cli.GetCmdAuctionsByBidder(), getByBidderArgs)
|
||||
if test.createAuctionAndBid {
|
||||
sr.NoError(err)
|
||||
} else {
|
||||
sr.Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite IntegrationTestSuite) createAuctionAndBid(createAuction, createBid bool) string {
|
||||
val := suite.network.Validators[0]
|
||||
sr := suite.Require()
|
||||
auctionID := ""
|
||||
|
||||
if createAuction {
|
||||
auctionArgs := []string{
|
||||
sampleCommitTime, sampleRevealTime,
|
||||
fmt.Sprintf("10%s", suite.cfg.BondDenom),
|
||||
fmt.Sprintf("10%s", suite.cfg.BondDenom),
|
||||
fmt.Sprintf("100%s", suite.cfg.BondDenom),
|
||||
}
|
||||
|
||||
resp, err := suite.executeTx(cli.GetCmdCreateAuction(), auctionArgs, ownerAccount)
|
||||
sr.NoError(err)
|
||||
sr.Zero(resp.Code)
|
||||
out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cli.GetCmdList(), queryJSONFlag)
|
||||
sr.NoError(err)
|
||||
var queryResponse types.AuctionsResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &queryResponse)
|
||||
sr.NoError(err)
|
||||
auctionID = queryResponse.Auctions.Auctions[0].Id
|
||||
} else {
|
||||
auctionID = suite.defaultAuctionID
|
||||
}
|
||||
|
||||
if createBid {
|
||||
bidArgs := []string{auctionID, fmt.Sprintf("200%s", suite.cfg.BondDenom)}
|
||||
resp, err := suite.executeTx(cli.GetCmdCommitBid(), bidArgs, bidderAccount)
|
||||
sr.NoError(err)
|
||||
sr.Zero(resp.Code)
|
||||
}
|
||||
|
||||
return auctionID
|
||||
}
|
141
x/auction/client/testutil/tx.go
Normal file
141
x/auction/client/testutil/tx.go
Normal file
@ -0,0 +1,141 @@
|
||||
package testutil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/spf13/cobra"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
"github.com/tharsis/ethermint/x/auction/client/cli"
|
||||
"github.com/tharsis/ethermint/x/auction/types"
|
||||
)
|
||||
|
||||
const (
|
||||
sampleCommitTime = "90s"
|
||||
sampleRevealTime = "5s"
|
||||
placeholderAuctionID = "placeholder_auction_id"
|
||||
)
|
||||
|
||||
func (suite *IntegrationTestSuite) TestTxCreateAuction() {
|
||||
sr := suite.Require()
|
||||
testCases := []struct {
|
||||
msg string
|
||||
args []string
|
||||
expectErr bool
|
||||
}{
|
||||
{
|
||||
"create auction with missing arguments",
|
||||
[]string{sampleCommitTime, sampleRevealTime},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"create auction with proper arguments",
|
||||
[]string{
|
||||
sampleCommitTime, sampleRevealTime,
|
||||
fmt.Sprintf("10%s", suite.cfg.BondDenom),
|
||||
fmt.Sprintf("10%s", suite.cfg.BondDenom),
|
||||
fmt.Sprintf("100%s", suite.cfg.BondDenom),
|
||||
},
|
||||
false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", test.msg), func() {
|
||||
resp, err := suite.executeTx(cli.GetCmdCreateAuction(), test.args, ownerAccount)
|
||||
if test.expectErr {
|
||||
sr.Error(err)
|
||||
} else {
|
||||
sr.NoError(err)
|
||||
sr.Zero(resp.Code)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *IntegrationTestSuite) TestTxCommitBid() {
|
||||
val := suite.network.Validators[0]
|
||||
sr := suite.Require()
|
||||
testCases := []struct {
|
||||
msg string
|
||||
args []string
|
||||
createAuction bool
|
||||
}{
|
||||
{
|
||||
"commit bid with missing args",
|
||||
[]string{fmt.Sprintf("200%s", suite.cfg.BondDenom)},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"commit bid with valid args",
|
||||
[]string{
|
||||
placeholderAuctionID,
|
||||
fmt.Sprintf("200%s", suite.cfg.BondDenom),
|
||||
},
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", test.msg), func() {
|
||||
if test.createAuction {
|
||||
auctionArgs := []string{
|
||||
sampleCommitTime, sampleRevealTime,
|
||||
fmt.Sprintf("10%s", suite.cfg.BondDenom),
|
||||
fmt.Sprintf("10%s", suite.cfg.BondDenom),
|
||||
fmt.Sprintf("100%s", suite.cfg.BondDenom),
|
||||
}
|
||||
_, err := suite.executeTx(cli.GetCmdCreateAuction(), auctionArgs, ownerAccount)
|
||||
sr.NoError(err)
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cli.GetCmdList(),
|
||||
[]string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)})
|
||||
sr.NoError(err)
|
||||
var queryResponse types.AuctionsResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &queryResponse)
|
||||
sr.NoError(err)
|
||||
sr.NotNil(queryResponse.GetAuctions())
|
||||
test.args[0] = queryResponse.GetAuctions().Auctions[0].Id
|
||||
}
|
||||
|
||||
resp, err := suite.executeTx(cli.GetCmdCommitBid(), test.args, bidderAccount)
|
||||
if test.createAuction {
|
||||
sr.NoError(err)
|
||||
sr.Zero(resp.Code)
|
||||
} else {
|
||||
sr.Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *IntegrationTestSuite) executeTx(cmd *cobra.Command, args []string, caller string) (sdk.TxResponse, error) {
|
||||
val := suite.network.Validators[0]
|
||||
additionalArgs := []string{
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, caller),
|
||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, fmt.Sprintf("3%s", suite.cfg.BondDenom)),
|
||||
}
|
||||
args = append(args, additionalArgs...)
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args)
|
||||
if err != nil {
|
||||
return sdk.TxResponse{}, err
|
||||
}
|
||||
|
||||
var resp sdk.TxResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp)
|
||||
if err != nil {
|
||||
return sdk.TxResponse{}, err
|
||||
}
|
||||
|
||||
err = suite.network.WaitForNextBlock()
|
||||
if err != nil {
|
||||
return sdk.TxResponse{}, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
44
x/auction/genesis.go
Normal file
44
x/auction/genesis.go
Normal file
@ -0,0 +1,44 @@
|
||||
package auction
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
"github.com/tharsis/ethermint/x/auction/keeper"
|
||||
"github.com/tharsis/ethermint/x/auction/types"
|
||||
)
|
||||
|
||||
// func NewGenesisState(params types.Params, auctions []types.Auction) types.GenesisState {
|
||||
// return types.GenesisState{Params: params, Auctions: &types.Auctions{Auctions: auctions}}
|
||||
// }
|
||||
|
||||
func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, data types.GenesisState) []abci.ValidatorUpdate {
|
||||
keeper.SetParams(ctx, data.Params)
|
||||
|
||||
for _, auction := range data.Auctions {
|
||||
keeper.SaveAuction(ctx, auction)
|
||||
}
|
||||
|
||||
return []abci.ValidatorUpdate{}
|
||||
}
|
||||
|
||||
func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) types.GenesisState {
|
||||
params := keeper.GetParams(ctx)
|
||||
auctions := keeper.ListAuctions(ctx)
|
||||
|
||||
var genesisAuctions []*types.Auction
|
||||
for _, auction := range auctions {
|
||||
genesisAuctions = append(genesisAuctions, &auction)
|
||||
}
|
||||
return types.GenesisState{Params: params, Auctions: genesisAuctions}
|
||||
}
|
||||
|
||||
func ValidateGenesis(data types.GenesisState) error {
|
||||
err := data.Params.Validate()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
91
x/auction/keeper/grpc_query.go
Normal file
91
x/auction/keeper/grpc_query.go
Normal file
@ -0,0 +1,91 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
|
||||
"github.com/tharsis/ethermint/x/auction/types"
|
||||
)
|
||||
|
||||
type Querier struct {
|
||||
Keeper
|
||||
}
|
||||
|
||||
var _ types.QueryServer = Querier{}
|
||||
|
||||
// Auctions queries all auctions
|
||||
func (q Querier) Auctions(c context.Context, req *types.AuctionsRequest) (*types.AuctionsResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
resp := q.Keeper.ListAuctions(ctx)
|
||||
return &types.AuctionsResponse{Auctions: &types.Auctions{Auctions: resp}}, nil
|
||||
}
|
||||
|
||||
// GetAuction queries an auction
|
||||
func (q Querier) GetAuction(c context.Context, req *types.AuctionRequest) (*types.AuctionResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
if req.Id == "" {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "auction ID is required")
|
||||
}
|
||||
|
||||
resp := q.Keeper.GetAuction(ctx, req.Id)
|
||||
return &types.AuctionResponse{Auction: resp}, nil
|
||||
}
|
||||
|
||||
// GetBid queries and auction bid
|
||||
func (q Querier) GetBid(c context.Context, req *types.BidRequest) (*types.BidResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
if req.AuctionId == "" {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "auction ID is required")
|
||||
}
|
||||
if req.Bidder == "" {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "bidder address is required")
|
||||
}
|
||||
resp := q.Keeper.GetBid(ctx, req.AuctionId, req.Bidder)
|
||||
return &types.BidResponse{Bid: &resp}, nil
|
||||
}
|
||||
|
||||
// GetBids queries all auction bids
|
||||
func (q Querier) GetBids(c context.Context, req *types.BidsRequest) (*types.BidsResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
if req.AuctionId == "" {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "auction ID is required")
|
||||
}
|
||||
resp := q.Keeper.GetBids(ctx, req.AuctionId)
|
||||
return &types.BidsResponse{Bids: resp}, nil
|
||||
}
|
||||
|
||||
// AuctionsByBidder queries auctions by bidder
|
||||
func (q Querier) AuctionsByBidder(c context.Context, req *types.AuctionsByBidderRequest) (*types.AuctionsByBidderResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
if req.BidderAddress == "" {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "bidder address is required")
|
||||
}
|
||||
resp := q.Keeper.QueryAuctionsByBidder(ctx, req.BidderAddress)
|
||||
return &types.AuctionsByBidderResponse{Auctions: &types.Auctions{Auctions: resp}}, nil
|
||||
}
|
||||
|
||||
// AuctionsByOwner queries auctions by owner
|
||||
func (q Querier) AuctionsByOwner(c context.Context, req *types.AuctionsByOwnerRequest) (*types.AuctionsByOwnerResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
if req.OwnerAddress == "" {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "owner address is required")
|
||||
}
|
||||
resp := q.Keeper.QueryAuctionsByOwner(ctx, req.OwnerAddress)
|
||||
return &types.AuctionsByOwnerResponse{Auctions: &types.Auctions{Auctions: resp}}, nil
|
||||
}
|
||||
|
||||
// QueryParams implements the params query command
|
||||
func (q Querier) QueryParams(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
resp := q.Keeper.GetParams(ctx)
|
||||
return &types.QueryParamsResponse{Params: &resp}, nil
|
||||
}
|
||||
|
||||
// Balance queries the auction module account balance
|
||||
func (q Querier) Balance(c context.Context, req *types.BalanceRequest) (*types.BalanceResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
resp := q.Keeper.GetAuctionModuleBalances(ctx)
|
||||
return &types.BalanceResponse{Balance: resp}, nil
|
||||
}
|
355
x/auction/keeper/grpc_query_test.go
Normal file
355
x/auction/keeper/grpc_query_test.go
Normal file
@ -0,0 +1,355 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/tharsis/ethermint/app"
|
||||
"github.com/tharsis/ethermint/x/auction/types"
|
||||
)
|
||||
|
||||
const testCommitHash = "71D8CF34026E32A3A34C2C2D4ADF25ABC8D7943A4619761BE27F196603D91B9D"
|
||||
|
||||
func (suite *KeeperTestSuite) TestGrpcGetAllAuctions() {
|
||||
client, ctx, k := suite.queryClient, suite.ctx, suite.app.AuctionKeeper
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
req *types.AuctionsRequest
|
||||
createAuctions bool
|
||||
auctionCount int
|
||||
}{
|
||||
{
|
||||
"fetch auctions when no auctions exist",
|
||||
&types.AuctionsRequest{},
|
||||
false,
|
||||
0,
|
||||
},
|
||||
|
||||
{
|
||||
"fetch auctions with one auction created",
|
||||
&types.AuctionsRequest{},
|
||||
true,
|
||||
1,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", test.msg), func() {
|
||||
if test.createAuctions {
|
||||
account := app.CreateRandomAccounts(1)[0]
|
||||
err := simapp.FundAccount(suite.app.BankKeeper, ctx, account, sdk.NewCoins(
|
||||
sdk.Coin{Amount: sdk.NewInt(100), Denom: sdk.DefaultBondDenom},
|
||||
))
|
||||
|
||||
_, err = k.CreateAuction(ctx, types.NewMsgCreateAuction(k.GetParams(ctx), account))
|
||||
suite.Require().NoError(err)
|
||||
}
|
||||
|
||||
resp, _ := client.Auctions(context.Background(), test.req)
|
||||
suite.Require().Equal(test.auctionCount, len(resp.GetAuctions().Auctions))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestGrpcQueryParams() {
|
||||
testCases := []struct {
|
||||
msg string
|
||||
req *types.QueryParamsRequest
|
||||
}{
|
||||
{
|
||||
"fetch params",
|
||||
&types.QueryParamsRequest{},
|
||||
},
|
||||
}
|
||||
for _, test := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", test.msg), func() {
|
||||
resp, err := suite.queryClient.QueryParams(context.Background(), test.req)
|
||||
suite.Require().Nil(err)
|
||||
suite.Require().Equal(*(resp.Params), types.DefaultParams())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestGrpcGetAuction() {
|
||||
testCases := []struct {
|
||||
msg string
|
||||
req *types.AuctionRequest
|
||||
createAuction bool
|
||||
}{
|
||||
{
|
||||
"fetch auction with empty auction ID",
|
||||
&types.AuctionRequest{},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"fetch auction with valid auction ID",
|
||||
&types.AuctionRequest{},
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", test.msg), func() {
|
||||
if test.createAuction {
|
||||
auction, _, err := suite.createAuctionAndCommitBid(false)
|
||||
suite.Require().NoError(err)
|
||||
test.req.Id = auction.Id
|
||||
}
|
||||
|
||||
resp, err := suite.queryClient.GetAuction(context.Background(), test.req)
|
||||
if test.createAuction {
|
||||
suite.Require().Nil(err)
|
||||
suite.Require().NotNil(resp.GetAuction())
|
||||
suite.Require().Equal(test.req.Id, resp.GetAuction().Id)
|
||||
} else {
|
||||
suite.Require().NotNil(err)
|
||||
suite.Require().Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestGrpcGetBids() {
|
||||
testCases := []struct {
|
||||
msg string
|
||||
req *types.BidsRequest
|
||||
createAuction bool
|
||||
commitBid bool
|
||||
bidCount int
|
||||
}{
|
||||
{
|
||||
"fetch all bids when no auction exists",
|
||||
&types.BidsRequest{},
|
||||
false,
|
||||
false,
|
||||
0,
|
||||
},
|
||||
{
|
||||
"fetch all bids for valid auction but no added bids",
|
||||
&types.BidsRequest{},
|
||||
true,
|
||||
false,
|
||||
0,
|
||||
},
|
||||
{
|
||||
"fetch all bids for valid auction and valid bid",
|
||||
&types.BidsRequest{},
|
||||
true,
|
||||
true,
|
||||
1,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", test.msg), func() {
|
||||
if test.createAuction {
|
||||
auction, _, err := suite.createAuctionAndCommitBid(test.commitBid)
|
||||
suite.Require().NoError(err)
|
||||
test.req.AuctionId = auction.Id
|
||||
}
|
||||
|
||||
resp, err := suite.queryClient.GetBids(context.Background(), test.req)
|
||||
if test.createAuction {
|
||||
suite.Require().Nil(err)
|
||||
suite.Require().Equal(test.bidCount, len(resp.GetBids()))
|
||||
} else {
|
||||
suite.Require().NotNil(err)
|
||||
suite.Require().Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestGrpcGetBid() {
|
||||
testCases := []struct {
|
||||
msg string
|
||||
req *types.BidRequest
|
||||
createAuctionAndBid bool
|
||||
}{
|
||||
{
|
||||
"fetch bid when bid does not exist",
|
||||
&types.BidRequest{},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"fetch bid when valid bid exists",
|
||||
&types.BidRequest{},
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", test.msg), func() {
|
||||
if test.createAuctionAndBid {
|
||||
auction, bid, err := suite.createAuctionAndCommitBid(test.createAuctionAndBid)
|
||||
suite.Require().NoError(err)
|
||||
test.req.AuctionId = auction.Id
|
||||
test.req.Bidder = bid.BidderAddress
|
||||
}
|
||||
|
||||
resp, err := suite.queryClient.GetBid(context.Background(), test.req)
|
||||
if test.createAuctionAndBid {
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().NotNil(resp.Bid)
|
||||
suite.Require().Equal(test.req.Bidder, resp.Bid.BidderAddress)
|
||||
} else {
|
||||
suite.Require().NotNil(err)
|
||||
suite.Require().Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestGrpcGetAuctionsByBidder() {
|
||||
testCases := []struct {
|
||||
msg string
|
||||
req *types.AuctionsByBidderRequest
|
||||
createAuctionAndCommitBid bool
|
||||
auctionCount int
|
||||
}{
|
||||
{
|
||||
"get auctions by bidder with invalid bidder address",
|
||||
&types.AuctionsByBidderRequest{},
|
||||
false,
|
||||
0,
|
||||
},
|
||||
{
|
||||
"get auctions by bidder with valid auction and bid",
|
||||
&types.AuctionsByBidderRequest{},
|
||||
true,
|
||||
1,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", test.msg), func() {
|
||||
if test.createAuctionAndCommitBid {
|
||||
_, bid, err := suite.createAuctionAndCommitBid(test.createAuctionAndCommitBid)
|
||||
suite.Require().NoError(err)
|
||||
test.req.BidderAddress = bid.BidderAddress
|
||||
}
|
||||
|
||||
resp, err := suite.queryClient.AuctionsByBidder(context.Background(), test.req)
|
||||
if test.createAuctionAndCommitBid {
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().NotNil(resp.Auctions)
|
||||
suite.Require().Equal(test.auctionCount, len(resp.Auctions.Auctions))
|
||||
} else {
|
||||
suite.Require().NotNil(err)
|
||||
suite.Require().Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestGrpcGetAuctionsByOwner() {
|
||||
testCases := []struct {
|
||||
msg string
|
||||
req *types.AuctionsByOwnerRequest
|
||||
createAuction bool
|
||||
auctionCount int
|
||||
}{
|
||||
{
|
||||
"get auctions by owner with invalid owner address",
|
||||
&types.AuctionsByOwnerRequest{},
|
||||
false,
|
||||
0,
|
||||
},
|
||||
{
|
||||
"get auctions by owner with valid auction",
|
||||
&types.AuctionsByOwnerRequest{},
|
||||
true,
|
||||
1,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", test.msg), func() {
|
||||
if test.createAuction {
|
||||
auction, _, err := suite.createAuctionAndCommitBid(false)
|
||||
suite.Require().NoError(err)
|
||||
test.req.OwnerAddress = auction.OwnerAddress
|
||||
}
|
||||
|
||||
resp, err := suite.queryClient.AuctionsByOwner(context.Background(), test.req)
|
||||
if test.createAuction {
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().NotNil(resp.Auctions)
|
||||
suite.Require().Equal(test.auctionCount, len(resp.Auctions.Auctions))
|
||||
} else {
|
||||
suite.Require().NotNil(err)
|
||||
suite.Require().Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite KeeperTestSuite) TestGrpcQueryBalance() {
|
||||
testCases := []struct {
|
||||
msg string
|
||||
req *types.BalanceRequest
|
||||
createAuction bool
|
||||
auctionCount int
|
||||
}{
|
||||
{
|
||||
"get balance with no auctions created",
|
||||
&types.BalanceRequest{},
|
||||
false,
|
||||
0,
|
||||
},
|
||||
{
|
||||
"get balance with single auction created",
|
||||
&types.BalanceRequest{},
|
||||
true,
|
||||
1,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
if test.createAuction {
|
||||
_, _, err := suite.createAuctionAndCommitBid(true)
|
||||
suite.Require().NoError(err)
|
||||
}
|
||||
|
||||
resp, err := suite.queryClient.Balance(context.Background(), test.req)
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().Equal(test.auctionCount, len(resp.GetBalance()))
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) createAuctionAndCommitBid(commitBid bool) (*types.Auction, *types.Bid, error) {
|
||||
ctx, k := suite.ctx, suite.app.AuctionKeeper
|
||||
accCount := 1
|
||||
if commitBid {
|
||||
accCount++
|
||||
}
|
||||
|
||||
accounts := app.CreateRandomAccounts(accCount)
|
||||
for _, account := range accounts {
|
||||
err := simapp.FundAccount(suite.app.BankKeeper, ctx, account, sdk.NewCoins(
|
||||
sdk.Coin{Amount: sdk.NewInt(100), Denom: sdk.DefaultBondDenom},
|
||||
))
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
}
|
||||
|
||||
auction, err := k.CreateAuction(ctx, types.NewMsgCreateAuction(k.GetParams(ctx), accounts[0]))
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
if commitBid {
|
||||
bid, err := k.CommitBid(ctx, types.NewMsgCommitBid(auction.Id, testCommitHash, accounts[1]))
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return auction, bid, nil
|
||||
}
|
||||
|
||||
return auction, nil, nil
|
||||
}
|
37
x/auction/keeper/invariants.go
Normal file
37
x/auction/keeper/invariants.go
Normal file
@ -0,0 +1,37 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/tharsis/ethermint/x/auction/types"
|
||||
)
|
||||
|
||||
// RegisterInvariants registers all auction module invariants.
|
||||
func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper) {
|
||||
ir.RegisterRoute(types.ModuleName, "module-account", ModuleAccountInvariant(k))
|
||||
}
|
||||
|
||||
// ModuleAccountInvariant checks that the 'auction' module account balance is non-negative.
|
||||
func ModuleAccountInvariant(k Keeper) sdk.Invariant {
|
||||
return func(ctx sdk.Context) (string, bool) {
|
||||
moduleAddress := k.accountKeeper.GetModuleAddress(types.ModuleName)
|
||||
if k.bankKeeper.GetAllBalances(ctx, moduleAddress).IsAnyNegative() {
|
||||
return sdk.FormatInvariant(
|
||||
types.ModuleName,
|
||||
"module-account",
|
||||
fmt.Sprintf("Module account '%s' has negative balance.", types.ModuleName)),
|
||||
true
|
||||
}
|
||||
|
||||
return "", false
|
||||
}
|
||||
}
|
||||
|
||||
// AllInvariants runs all invariants of the auctions module.
|
||||
func AllInvariants(k Keeper) sdk.Invariant {
|
||||
return func(ctx sdk.Context) (string, bool) {
|
||||
return ModuleAccountInvariant(k)(ctx)
|
||||
}
|
||||
}
|
658
x/auction/keeper/keeper.go
Normal file
658
x/auction/keeper/keeper.go
Normal file
@ -0,0 +1,658 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
||||
params "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
|
||||
"github.com/tharsis/ethermint/x/auction/types"
|
||||
|
||||
wnsUtils "github.com/tharsis/ethermint/utils"
|
||||
)
|
||||
|
||||
// CompletedAuctionDeleteTimeout => Completed auctions are deleted after this timeout (after reveals end time).
|
||||
const CompletedAuctionDeleteTimeout = time.Hour * 24
|
||||
|
||||
// PrefixIDToAuctionIndex is the prefix for Id -> Auction index in the KVStore.
|
||||
// Note: This is the primary index in the system.
|
||||
// Note: Golang doesn't support const arrays.
|
||||
var PrefixIDToAuctionIndex = []byte{0x00}
|
||||
|
||||
// prefixOwnerToAuctionsIndex is the prefix for the Owner -> [Auction] index in the KVStore.
|
||||
var prefixOwnerToAuctionsIndex = []byte{0x01}
|
||||
|
||||
// PrefixAuctionBidsIndex is the prefix for the (auction, bidder) -> Bid index in the KVStore.
|
||||
var PrefixAuctionBidsIndex = []byte{0x02}
|
||||
|
||||
// PrefixBidderToAuctionsIndex is the prefix for the Bidder -> [Auction] index in the KVStore.
|
||||
var PrefixBidderToAuctionsIndex = []byte{0x03}
|
||||
|
||||
// Keeper maintains the link to storage and exposes getter/setter methods for the various parts of the state machine
|
||||
type Keeper struct {
|
||||
accountKeeper auth.AccountKeeper
|
||||
bankKeeper bank.Keeper
|
||||
|
||||
// Track auction usage in other cosmos-sdk modules (more like a usage tracker).
|
||||
usageKeepers []types.AuctionUsageKeeper
|
||||
|
||||
storeKey sdk.StoreKey // Unexposed key to access store from sdk.Context
|
||||
|
||||
cdc codec.BinaryCodec // The wire codec for binary encoding/decoding.
|
||||
|
||||
paramSubspace params.Subspace
|
||||
}
|
||||
|
||||
// AuctionClientKeeper is the subset of functionality exposed to other modules.
|
||||
type AuctionClientKeeper interface {
|
||||
HasAuction(ctx sdk.Context, id string) bool
|
||||
GetAuction(ctx sdk.Context, id string) types.Auction
|
||||
MatchAuctions(ctx sdk.Context, matchFn func(*types.Auction) bool) []*types.Auction
|
||||
}
|
||||
|
||||
// NewKeeper creates new instances of the auction Keeper
|
||||
func NewKeeper(accountKeeper auth.AccountKeeper, bankKeeper bank.Keeper, storeKey sdk.StoreKey, cdc codec.BinaryCodec, ps params.Subspace) Keeper {
|
||||
if !ps.HasKeyTable() {
|
||||
ps = ps.WithKeyTable(types.ParamKeyTable())
|
||||
}
|
||||
|
||||
return Keeper{
|
||||
accountKeeper: accountKeeper,
|
||||
bankKeeper: bankKeeper,
|
||||
storeKey: storeKey,
|
||||
cdc: cdc,
|
||||
paramSubspace: ps,
|
||||
}
|
||||
}
|
||||
|
||||
func (k *Keeper) SetUsageKeepers(usageKeepers []types.AuctionUsageKeeper) {
|
||||
k.usageKeepers = usageKeepers
|
||||
}
|
||||
|
||||
func (k Keeper) GetUsageKeepers() []types.AuctionUsageKeeper {
|
||||
return k.usageKeepers
|
||||
}
|
||||
|
||||
// Generates Auction Id -> Auction index key.
|
||||
func GetAuctionIndexKey(id string) []byte {
|
||||
return append(PrefixIDToAuctionIndex, []byte(id)...)
|
||||
}
|
||||
|
||||
// Generates Owner -> Auctions index key.
|
||||
func GetOwnerToAuctionsIndexKey(owner string, auctionID string) []byte {
|
||||
return append(append(prefixOwnerToAuctionsIndex, []byte(owner)...), []byte(auctionID)...)
|
||||
}
|
||||
|
||||
func GetBidderToAuctionsIndexKey(bidder string, auctionID string) []byte {
|
||||
return append(append(PrefixBidderToAuctionsIndex, []byte(bidder)...), []byte(auctionID)...)
|
||||
}
|
||||
|
||||
func GetBidIndexKey(auctionID string, bidder string) []byte {
|
||||
return append(GetAuctionBidsIndexPrefix(auctionID), []byte(bidder)...)
|
||||
}
|
||||
|
||||
func GetAuctionBidsIndexPrefix(auctionID string) []byte {
|
||||
return append(append(PrefixAuctionBidsIndex, []byte(auctionID)...))
|
||||
}
|
||||
|
||||
// SaveAuction - saves a auction to the store.
|
||||
func (k Keeper) SaveAuction(ctx sdk.Context, auction *types.Auction) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
|
||||
// Auction Id -> Auction index.
|
||||
store.Set(GetAuctionIndexKey(auction.Id), k.cdc.MustMarshal(auction))
|
||||
|
||||
// Owner -> [Auction] index.
|
||||
store.Set(GetOwnerToAuctionsIndexKey(auction.OwnerAddress, auction.Id), []byte{})
|
||||
|
||||
// Notify interested parties.
|
||||
for _, keeper := range k.usageKeepers {
|
||||
keeper.OnAuction(ctx, auction.Id)
|
||||
}
|
||||
}
|
||||
|
||||
func (k Keeper) SaveBid(ctx sdk.Context, bid *types.Bid) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
store.Set(GetBidIndexKey(bid.AuctionId, bid.BidderAddress), k.cdc.MustMarshal(bid))
|
||||
store.Set(GetBidderToAuctionsIndexKey(bid.BidderAddress, bid.AuctionId), []byte{})
|
||||
|
||||
// Notify interested parties.
|
||||
for _, keeper := range k.usageKeepers {
|
||||
keeper.OnAuctionBid(ctx, bid.AuctionId, bid.BidderAddress)
|
||||
}
|
||||
}
|
||||
|
||||
func (k Keeper) DeleteBid(ctx sdk.Context, bid types.Bid) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
store.Delete(GetBidIndexKey(bid.AuctionId, bid.BidderAddress))
|
||||
store.Delete(GetOwnerToAuctionsIndexKey(bid.BidderAddress, bid.AuctionId))
|
||||
}
|
||||
|
||||
// HasAuction - checks if a auction by the given Id exists.
|
||||
func (k Keeper) HasAuction(ctx sdk.Context, id string) bool {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
return store.Has(GetAuctionIndexKey(id))
|
||||
}
|
||||
|
||||
func (k Keeper) HasBid(ctx sdk.Context, id string, bidder string) bool {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
return store.Has(GetBidIndexKey(id, bidder))
|
||||
}
|
||||
|
||||
// DeleteAuction - deletes the auction.
|
||||
func (k Keeper) DeleteAuction(ctx sdk.Context, auction types.Auction) {
|
||||
// Delete all bids first.
|
||||
bids := k.GetBids(ctx, auction.Id)
|
||||
for _, bid := range bids {
|
||||
k.DeleteBid(ctx, *bid)
|
||||
}
|
||||
|
||||
// Delete the auction itself.
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
store.Delete(GetAuctionIndexKey(auction.Id))
|
||||
store.Delete(GetOwnerToAuctionsIndexKey(auction.OwnerAddress, auction.Id))
|
||||
}
|
||||
|
||||
// GetAuction - gets a record from the store.
|
||||
func (k Keeper) GetAuction(ctx sdk.Context, id string) *types.Auction {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
auctionKey := GetAuctionIndexKey(id)
|
||||
if !store.Has(auctionKey) {
|
||||
return nil
|
||||
}
|
||||
|
||||
bz := store.Get(auctionKey)
|
||||
var obj types.Auction
|
||||
k.cdc.MustUnmarshal(bz, &obj)
|
||||
|
||||
return &obj
|
||||
}
|
||||
|
||||
// GetBids gets the auction bids.
|
||||
func (k Keeper) GetBids(ctx sdk.Context, id string) []*types.Bid {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bids := []*types.Bid{}
|
||||
itr := sdk.KVStorePrefixIterator(store, GetAuctionBidsIndexPrefix(id))
|
||||
defer itr.Close()
|
||||
for ; itr.Valid(); itr.Next() {
|
||||
bz := store.Get(itr.Key())
|
||||
if bz != nil {
|
||||
var obj types.Bid
|
||||
k.cdc.MustUnmarshal(bz, &obj)
|
||||
bids = append(bids, &obj)
|
||||
}
|
||||
}
|
||||
|
||||
return bids
|
||||
}
|
||||
|
||||
func (k Keeper) GetBid(ctx sdk.Context, id string, bidder string) types.Bid {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
|
||||
bz := store.Get(GetBidIndexKey(id, bidder))
|
||||
var obj types.Bid
|
||||
k.cdc.MustUnmarshal(bz, &obj)
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
// ListAuctions - get all auctions.
|
||||
func (k Keeper) ListAuctions(ctx sdk.Context) []types.Auction {
|
||||
var auctions []types.Auction
|
||||
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
itr := sdk.KVStorePrefixIterator(store, PrefixIDToAuctionIndex)
|
||||
defer itr.Close()
|
||||
for ; itr.Valid(); itr.Next() {
|
||||
bz := store.Get(itr.Key())
|
||||
if bz != nil {
|
||||
var obj types.Auction
|
||||
k.cdc.MustUnmarshal(bz, &obj)
|
||||
auctions = append(auctions, obj)
|
||||
}
|
||||
}
|
||||
|
||||
return auctions
|
||||
}
|
||||
|
||||
// QueryAuctionsByOwner - query auctions by owner.
|
||||
func (k Keeper) QueryAuctionsByOwner(ctx sdk.Context, ownerAddress string) []types.Auction {
|
||||
auctions := []types.Auction{}
|
||||
|
||||
ownerPrefix := append(prefixOwnerToAuctionsIndex, []byte(ownerAddress)...)
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
itr := sdk.KVStorePrefixIterator(store, ownerPrefix)
|
||||
defer itr.Close()
|
||||
for ; itr.Valid(); itr.Next() {
|
||||
auctionID := itr.Key()[len(ownerPrefix):]
|
||||
bz := store.Get(append(PrefixIDToAuctionIndex, auctionID...))
|
||||
if bz != nil {
|
||||
var obj types.Auction
|
||||
k.cdc.MustUnmarshal(bz, &obj)
|
||||
auctions = append(auctions, obj)
|
||||
}
|
||||
}
|
||||
|
||||
return auctions
|
||||
}
|
||||
|
||||
// QueryAuctionsByBidder - query auctions by bidder
|
||||
func (k Keeper) QueryAuctionsByBidder(ctx sdk.Context, bidderAddress string) []types.Auction {
|
||||
auctions := []types.Auction{}
|
||||
|
||||
bidderPrefix := append(PrefixBidderToAuctionsIndex, []byte(bidderAddress)...)
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
itr := sdk.KVStorePrefixIterator(store, []byte(bidderPrefix))
|
||||
defer itr.Close()
|
||||
for ; itr.Valid(); itr.Next() {
|
||||
auctionID := itr.Key()[len(bidderPrefix):]
|
||||
bz := store.Get(append(PrefixIDToAuctionIndex, auctionID...))
|
||||
if bz != nil {
|
||||
var obj types.Auction
|
||||
k.cdc.MustUnmarshal(bz, &obj)
|
||||
auctions = append(auctions, obj)
|
||||
}
|
||||
}
|
||||
|
||||
return auctions
|
||||
}
|
||||
|
||||
// MatchAuctions - get all matching auctions.
|
||||
func (k Keeper) MatchAuctions(ctx sdk.Context, matchFn func(*types.Auction) bool) []*types.Auction {
|
||||
var auctions []*types.Auction
|
||||
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
itr := sdk.KVStorePrefixIterator(store, PrefixIDToAuctionIndex)
|
||||
defer itr.Close()
|
||||
for ; itr.Valid(); itr.Next() {
|
||||
bz := store.Get(itr.Key())
|
||||
if bz != nil {
|
||||
var obj types.Auction
|
||||
k.cdc.MustUnmarshal(bz, &obj)
|
||||
if matchFn(&obj) {
|
||||
auctions = append(auctions, &obj)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return auctions
|
||||
}
|
||||
|
||||
// CreateAuction creates a new auction.
|
||||
func (k Keeper) CreateAuction(ctx sdk.Context, msg types.MsgCreateAuction) (*types.Auction, error) {
|
||||
// Might be called from another module directly, always validate.
|
||||
err := msg.ValidateBasic()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Generate auction Id.
|
||||
account := k.accountKeeper.GetAccount(ctx, signerAddress)
|
||||
if account == nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "Account not found.")
|
||||
}
|
||||
|
||||
auctionID := types.AuctionID{
|
||||
Address: signerAddress,
|
||||
AccNum: account.GetAccountNumber(),
|
||||
Sequence: account.GetSequence(),
|
||||
}.Generate()
|
||||
|
||||
// Compute timestamps.
|
||||
now := ctx.BlockTime()
|
||||
commitsEndTime := now.Add(time.Duration(msg.CommitsDuration))
|
||||
revealsEndTime := now.Add(time.Duration(msg.CommitsDuration + msg.RevealsDuration))
|
||||
|
||||
auction := types.Auction{
|
||||
Id: auctionID,
|
||||
Status: types.AuctionStatusCommitPhase,
|
||||
OwnerAddress: signerAddress.String(),
|
||||
CreateTime: now,
|
||||
CommitsEndTime: commitsEndTime,
|
||||
RevealsEndTime: revealsEndTime,
|
||||
CommitFee: msg.CommitFee,
|
||||
RevealFee: msg.RevealFee,
|
||||
MinimumBid: msg.MinimumBid,
|
||||
}
|
||||
|
||||
// Save auction in store.
|
||||
k.SaveAuction(ctx, &auction)
|
||||
|
||||
return &auction, nil
|
||||
}
|
||||
|
||||
func (k Keeper) CommitBid(ctx sdk.Context, msg types.MsgCommitBid) (*types.Bid, error) {
|
||||
if !k.HasAuction(ctx, msg.AuctionId) {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Auction not found.")
|
||||
}
|
||||
|
||||
auction := k.GetAuction(ctx, msg.AuctionId)
|
||||
if auction.Status != types.AuctionStatusCommitPhase {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Auction is not in commit phase.")
|
||||
}
|
||||
|
||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Take auction fees from account.
|
||||
totalFee := auction.CommitFee.Add(auction.RevealFee)
|
||||
sdkErr := k.bankKeeper.SendCoinsFromAccountToModule(ctx, signerAddress, types.ModuleName, sdk.NewCoins(totalFee))
|
||||
if sdkErr != nil {
|
||||
return nil, sdkErr
|
||||
}
|
||||
|
||||
// Check if an old bid already exists, if so, return old bids auction fee (update bid scenario).
|
||||
bidder := signerAddress.String()
|
||||
if k.HasBid(ctx, msg.AuctionId, bidder) {
|
||||
oldBid := k.GetBid(ctx, msg.AuctionId, bidder)
|
||||
oldTotalFee := oldBid.CommitFee.Add(oldBid.RevealFee)
|
||||
sdkErr := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, signerAddress, sdk.NewCoins(oldTotalFee))
|
||||
if sdkErr != nil {
|
||||
return nil, sdkErr
|
||||
}
|
||||
}
|
||||
|
||||
// Save new bid.
|
||||
bid := types.Bid{
|
||||
AuctionId: msg.AuctionId,
|
||||
BidderAddress: bidder,
|
||||
Status: types.BidStatusCommitted,
|
||||
CommitHash: msg.CommitHash,
|
||||
CommitTime: ctx.BlockTime(),
|
||||
CommitFee: auction.CommitFee,
|
||||
RevealFee: auction.RevealFee,
|
||||
}
|
||||
|
||||
k.SaveBid(ctx, &bid)
|
||||
|
||||
return &bid, nil
|
||||
}
|
||||
|
||||
// RevealBid reeals a bid comitted earlier.
|
||||
func (k Keeper) RevealBid(ctx sdk.Context, msg types.MsgRevealBid) (*types.Auction, error) {
|
||||
if !k.HasAuction(ctx, msg.AuctionId) {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Auction not found.")
|
||||
}
|
||||
|
||||
auction := k.GetAuction(ctx, msg.AuctionId)
|
||||
if auction.Status != types.AuctionStatusRevealPhase {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Auction is not in reveal phase.")
|
||||
}
|
||||
|
||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !k.HasBid(ctx, msg.AuctionId, signerAddress.String()) {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Bid not found.")
|
||||
}
|
||||
|
||||
bid := k.GetBid(ctx, auction.Id, signerAddress.String())
|
||||
if bid.Status != types.BidStatusCommitted {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Bid not in committed state.")
|
||||
}
|
||||
|
||||
revealBytes, err := hex.DecodeString(msg.Reveal)
|
||||
if err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal string.")
|
||||
}
|
||||
|
||||
cid, err := wnsUtils.CIDFromJSONBytes(revealBytes)
|
||||
if err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal JSON.")
|
||||
}
|
||||
|
||||
if bid.CommitHash != cid {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Commit hash mismatch.")
|
||||
}
|
||||
|
||||
var reveal map[string]interface{}
|
||||
err = json.Unmarshal(revealBytes, &reveal)
|
||||
if err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Reveal JSON unmarshal error.")
|
||||
}
|
||||
|
||||
chainID, err := wnsUtils.GetAttributeAsString(reveal, "chainId")
|
||||
if err != nil || chainID != ctx.ChainID() {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal chainID.")
|
||||
}
|
||||
|
||||
auctionID, err := wnsUtils.GetAttributeAsString(reveal, "auctionId")
|
||||
if err != nil || auctionID != msg.AuctionId {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal auction Id.")
|
||||
}
|
||||
|
||||
bidderAddress, err := wnsUtils.GetAttributeAsString(reveal, "bidderAddress")
|
||||
if err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal bid address.")
|
||||
}
|
||||
|
||||
if bidderAddress != signerAddress.String() {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Reveal bid address mismatch.")
|
||||
}
|
||||
|
||||
bidAmountStr, err := wnsUtils.GetAttributeAsString(reveal, "bidAmount")
|
||||
if err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal bid amount.")
|
||||
}
|
||||
|
||||
bidAmount, err := sdk.ParseCoinNormalized(bidAmountStr)
|
||||
if err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal bid amount.")
|
||||
}
|
||||
|
||||
if bidAmount.IsLT(auction.MinimumBid) {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Bid is lower than minimum bid.")
|
||||
}
|
||||
|
||||
// Lock bid amount.
|
||||
sdkErr := k.bankKeeper.SendCoinsFromAccountToModule(ctx, signerAddress, types.ModuleName, sdk.NewCoins(bidAmount))
|
||||
if sdkErr != nil {
|
||||
return nil, sdkErr
|
||||
}
|
||||
|
||||
// Update bid.
|
||||
bid.BidAmount = bidAmount
|
||||
bid.RevealTime = ctx.BlockTime()
|
||||
bid.Status = types.BidStatusRevealed
|
||||
k.SaveBid(ctx, &bid)
|
||||
|
||||
return auction, nil
|
||||
}
|
||||
|
||||
// GetAuctionModuleBalances gets the auction module account(s) balances.
|
||||
func (k Keeper) GetAuctionModuleBalances(ctx sdk.Context) sdk.Coins {
|
||||
moduleAddress := k.accountKeeper.GetModuleAddress(types.ModuleName)
|
||||
balances := k.bankKeeper.GetAllBalances(ctx, moduleAddress)
|
||||
return balances
|
||||
}
|
||||
|
||||
func (k Keeper) EndBlockerProcessAuctions(ctx sdk.Context) {
|
||||
// Transition auction state (commit, reveal, expired, completed).
|
||||
k.processAuctionPhases(ctx)
|
||||
|
||||
// Delete stale auctions.
|
||||
k.deleteCompletedAuctions(ctx)
|
||||
}
|
||||
|
||||
func (k Keeper) processAuctionPhases(ctx sdk.Context) {
|
||||
auctions := k.MatchAuctions(ctx, func(_ *types.Auction) bool {
|
||||
return true
|
||||
})
|
||||
|
||||
for _, auction := range auctions {
|
||||
// Commit -> Reveal state.
|
||||
if auction.Status == types.AuctionStatusCommitPhase && ctx.BlockTime().After(auction.CommitsEndTime) {
|
||||
auction.Status = types.AuctionStatusRevealPhase
|
||||
k.SaveAuction(ctx, auction)
|
||||
ctx.Logger().Info(fmt.Sprintf("Moved auction %s to reveal phase.", auction.Id))
|
||||
}
|
||||
|
||||
// Reveal -> Expired state.
|
||||
if auction.Status == types.AuctionStatusRevealPhase && ctx.BlockTime().After(auction.RevealsEndTime) {
|
||||
auction.Status = types.AuctionStatusExpired
|
||||
k.SaveAuction(ctx, auction)
|
||||
ctx.Logger().Info(fmt.Sprintf("Moved auction %s to expired state.", auction.Id))
|
||||
}
|
||||
|
||||
// If auction has expired, pick a winner from revealed bids.
|
||||
if auction.Status == types.AuctionStatusExpired {
|
||||
k.pickAuctionWinner(ctx, auction)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Delete completed stale auctions.
|
||||
func (k Keeper) deleteCompletedAuctions(ctx sdk.Context) {
|
||||
auctions := k.MatchAuctions(ctx, func(auction *types.Auction) bool {
|
||||
deleteTime := auction.RevealsEndTime.Add(CompletedAuctionDeleteTimeout)
|
||||
return auction.Status == types.AuctionStatusCompleted && ctx.BlockTime().After(deleteTime)
|
||||
})
|
||||
|
||||
for _, auction := range auctions {
|
||||
ctx.Logger().Info(fmt.Sprintf("Deleting completed auction %s after timeout.", auction.Id))
|
||||
k.DeleteAuction(ctx, *auction)
|
||||
}
|
||||
}
|
||||
|
||||
func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *types.Auction) {
|
||||
ctx.Logger().Info(fmt.Sprintf("Picking auction %s winner.", auction.Id))
|
||||
|
||||
var highestBid *types.Bid
|
||||
var secondHighestBid *types.Bid
|
||||
|
||||
bids := k.GetBids(ctx, auction.Id)
|
||||
for _, bid := range bids {
|
||||
ctx.Logger().Info(fmt.Sprintf("Processing bid %s %s", bid.BidderAddress, bid.BidAmount.String()))
|
||||
|
||||
// Only consider revealed bids.
|
||||
if bid.Status != types.BidStatusRevealed {
|
||||
ctx.Logger().Info(fmt.Sprintf("Ignoring unrevealed bid %s %s", bid.BidderAddress, bid.BidAmount.String()))
|
||||
continue
|
||||
}
|
||||
|
||||
// Init highest bid.
|
||||
if highestBid == nil {
|
||||
highestBid = bid
|
||||
ctx.Logger().Info(fmt.Sprintf("Initializing 1st bid %s %s", bid.BidderAddress, bid.BidAmount.String()))
|
||||
continue
|
||||
}
|
||||
|
||||
if highestBid.BidAmount.IsLT(bid.BidAmount) {
|
||||
ctx.Logger().Info(fmt.Sprintf("New highest bid %s %s", bid.BidderAddress, bid.BidAmount.String()))
|
||||
|
||||
secondHighestBid = highestBid
|
||||
highestBid = bid
|
||||
|
||||
ctx.Logger().Info(fmt.Sprintf("Updated 1st bid %s %s", highestBid.BidderAddress, highestBid.BidAmount.String()))
|
||||
ctx.Logger().Info(fmt.Sprintf("Updated 2nd bid %s %s", secondHighestBid.BidderAddress, secondHighestBid.BidAmount.String()))
|
||||
|
||||
} else if secondHighestBid == nil || secondHighestBid.BidAmount.IsLT(bid.BidAmount) {
|
||||
ctx.Logger().Info(fmt.Sprintf("New 2nd highest bid %s %s", bid.BidderAddress, bid.BidAmount.String()))
|
||||
|
||||
secondHighestBid = bid
|
||||
ctx.Logger().Info(fmt.Sprintf("Updated 2nd bid %s %s", secondHighestBid.BidderAddress, secondHighestBid.BidAmount.String()))
|
||||
} else {
|
||||
ctx.Logger().Info(fmt.Sprintf("Ignoring bid as it doesn't affect 1st/2nd price %s %s", bid.BidderAddress, bid.BidAmount.String()))
|
||||
}
|
||||
}
|
||||
|
||||
// Highest bid is the winner, but pays second highest bid price.
|
||||
auction.Status = types.AuctionStatusCompleted
|
||||
|
||||
if highestBid != nil {
|
||||
auction.WinnerAddress = highestBid.BidderAddress
|
||||
auction.WinningBid = highestBid.BidAmount
|
||||
|
||||
// Winner pays 2nd price, if a 2nd price exists.
|
||||
auction.WinningPrice = highestBid.BidAmount
|
||||
if secondHighestBid != nil {
|
||||
auction.WinningPrice = secondHighestBid.BidAmount
|
||||
}
|
||||
|
||||
ctx.Logger().Info(fmt.Sprintf("Auction %s winner %s.", auction.Id, auction.WinnerAddress))
|
||||
ctx.Logger().Info(fmt.Sprintf("Auction %s winner bid %s.", auction.Id, auction.WinningBid.String()))
|
||||
ctx.Logger().Info(fmt.Sprintf("Auction %s winner price %s.", auction.Id, auction.WinningPrice.String()))
|
||||
|
||||
} else {
|
||||
ctx.Logger().Info(fmt.Sprintf("Auction %s has no valid revealed bids (no winner).", auction.Id))
|
||||
}
|
||||
|
||||
k.SaveAuction(ctx, auction)
|
||||
|
||||
for _, bid := range bids {
|
||||
bidderAddress, err := sdk.AccAddressFromBech32(bid.BidderAddress)
|
||||
if err != nil {
|
||||
ctx.Logger().Error(fmt.Sprintf("Invalid bidderAddress address. %v", err))
|
||||
panic("Invalid bidder address.")
|
||||
}
|
||||
|
||||
if bid.Status == types.BidStatusRevealed {
|
||||
// Send reveal fee back to bidders that've revealed the bid.
|
||||
sdkErr := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, bidderAddress, sdk.NewCoins(bid.RevealFee))
|
||||
if sdkErr != nil {
|
||||
ctx.Logger().Error(fmt.Sprintf("Auction error returning reveal fee: %v", sdkErr))
|
||||
panic(sdkErr)
|
||||
}
|
||||
}
|
||||
|
||||
// Send back locked bid amount to all bidders.
|
||||
sdkErr := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, bidderAddress, sdk.NewCoins(bid.BidAmount))
|
||||
if sdkErr != nil {
|
||||
ctx.Logger().Error(fmt.Sprintf("Auction error returning bid amount: %v", sdkErr))
|
||||
panic(sdkErr)
|
||||
}
|
||||
}
|
||||
|
||||
// Process winner account (if nobody bids, there won't be a winner).
|
||||
if auction.WinnerAddress != "" {
|
||||
winnerAddress, err := sdk.AccAddressFromBech32(auction.WinnerAddress)
|
||||
if err != nil {
|
||||
ctx.Logger().Error(fmt.Sprintf("Invalid winner address. %v", err))
|
||||
panic("Invalid winner address.")
|
||||
}
|
||||
|
||||
// Take 2nd price from winner.
|
||||
sdkErr := k.bankKeeper.SendCoinsFromAccountToModule(ctx, winnerAddress, types.ModuleName, sdk.NewCoins(auction.WinningPrice))
|
||||
if sdkErr != nil {
|
||||
ctx.Logger().Error(fmt.Sprintf("Auction error taking funds from winner: %v", sdkErr))
|
||||
panic(sdkErr)
|
||||
}
|
||||
|
||||
// Burn anything over the min. bid amount.
|
||||
amountToBurn := auction.WinningPrice.Sub(auction.MinimumBid)
|
||||
if amountToBurn.IsNegative() {
|
||||
ctx.Logger().Error(fmt.Sprintf("Auction coins to burn cannot be negative."))
|
||||
panic("Auction coins to burn cannot be negative.")
|
||||
}
|
||||
|
||||
// Use auction burn module account instead of actually burning coins to better keep track of supply.
|
||||
sdkErr = k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, types.AuctionBurnModuleAccountName, sdk.NewCoins(amountToBurn))
|
||||
if sdkErr != nil {
|
||||
ctx.Logger().Error(fmt.Sprintf("Auction error burning coins: %v", sdkErr))
|
||||
panic(sdkErr)
|
||||
}
|
||||
}
|
||||
|
||||
// Notify other modules (hook).
|
||||
ctx.Logger().Info(fmt.Sprintf("Auction %s notifying %d modules.", auction.Id, len(k.usageKeepers)))
|
||||
for _, keeper := range k.usageKeepers {
|
||||
ctx.Logger().Info(fmt.Sprintf("Auction %s notifying module %s.", auction.Id, keeper.ModuleName()))
|
||||
keeper.OnAuctionWinnerSelected(ctx, auction.Id)
|
||||
}
|
||||
}
|
56
x/auction/keeper/keeper_test.go
Normal file
56
x/auction/keeper/keeper_test.go
Normal file
@ -0,0 +1,56 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
"github.com/tharsis/ethermint/app"
|
||||
auctionkeeper "github.com/tharsis/ethermint/x/auction/keeper"
|
||||
"github.com/tharsis/ethermint/x/auction/types"
|
||||
)
|
||||
|
||||
type KeeperTestSuite struct {
|
||||
suite.Suite
|
||||
app *app.EthermintApp
|
||||
ctx sdk.Context
|
||||
queryClient types.QueryClient
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) SetupTest() {
|
||||
testApp := app.Setup(false, func(ea *app.EthermintApp, genesis simapp.GenesisState) simapp.GenesisState {
|
||||
return genesis
|
||||
})
|
||||
ctx := testApp.BaseApp.NewContext(false, tmproto.Header{})
|
||||
|
||||
querier := auctionkeeper.Querier{Keeper: testApp.AuctionKeeper}
|
||||
|
||||
queryHelper := baseapp.NewQueryServerTestHelper(ctx, testApp.InterfaceRegistry())
|
||||
types.RegisterQueryServer(queryHelper, querier)
|
||||
queryClient := types.NewQueryClient(queryHelper)
|
||||
|
||||
suite.app, suite.ctx, suite.queryClient = testApp, ctx, queryClient
|
||||
}
|
||||
|
||||
func TestParams(t *testing.T) {
|
||||
testApp := app.Setup(false, func(ea *app.EthermintApp, genesis simapp.GenesisState) simapp.GenesisState {
|
||||
return genesis
|
||||
})
|
||||
ctx := testApp.BaseApp.NewContext(false, tmproto.Header{})
|
||||
|
||||
expParams := types.DefaultParams()
|
||||
params := testApp.AuctionKeeper.GetParams(ctx)
|
||||
require.Equal(t, expParams.CommitsDuration, params.CommitsDuration)
|
||||
require.Equal(t, expParams.RevealsDuration, params.RevealsDuration)
|
||||
require.Equal(t, expParams.CommitFee, params.CommitFee)
|
||||
require.Equal(t, expParams.RevealFee, params.RevealFee)
|
||||
require.Equal(t, expParams.MinimumBid, params.MinimumBid)
|
||||
}
|
||||
|
||||
func TestKeeperTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(KeeperTestSuite))
|
||||
}
|
110
x/auction/keeper/msg_server.go
Normal file
110
x/auction/keeper/msg_server.go
Normal file
@ -0,0 +1,110 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/tharsis/ethermint/x/auction/types"
|
||||
)
|
||||
|
||||
type msgServer struct {
|
||||
Keeper
|
||||
}
|
||||
|
||||
func NewMsgServer(keeper Keeper) types.MsgServer {
|
||||
return &msgServer{Keeper: keeper}
|
||||
}
|
||||
|
||||
var _ types.MsgServer = msgServer{}
|
||||
|
||||
func (s msgServer) CreateAuction(c context.Context, msg *types.MsgCreateAuction) (*types.MsgCreateAuctionResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := s.Keeper.CreateAuction(ctx, *msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvents(sdk.Events{
|
||||
sdk.NewEvent(
|
||||
types.EventTypeCreateAuction,
|
||||
sdk.NewAttribute(types.AttributeKeyCommitsDuration, msg.CommitsDuration.String()),
|
||||
sdk.NewAttribute(types.AttributeKeyCommitFee, msg.CommitFee.String()),
|
||||
sdk.NewAttribute(types.AttributeKeyRevealFee, msg.RevealFee.String()),
|
||||
sdk.NewAttribute(types.AttributeKeyMinimumBid, msg.MinimumBid.String()),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(types.AttributeKeySigner, signerAddress.String()),
|
||||
),
|
||||
})
|
||||
|
||||
return &types.MsgCreateAuctionResponse{Auction: resp}, nil
|
||||
}
|
||||
|
||||
// CommitBid is the command for committing a bid
|
||||
func (s msgServer) CommitBid(c context.Context, msg *types.MsgCommitBid) (*types.MsgCommitBidResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := s.Keeper.CommitBid(ctx, *msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvents(sdk.Events{
|
||||
sdk.NewEvent(
|
||||
types.EventTypeCommitBid,
|
||||
sdk.NewAttribute(types.AttributeKeyAuctionID, msg.AuctionId),
|
||||
sdk.NewAttribute(types.AttributeKeyCommitHash, msg.CommitHash),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(types.AttributeKeySigner, signerAddress.String()),
|
||||
),
|
||||
})
|
||||
|
||||
return &types.MsgCommitBidResponse{Bid: resp}, nil
|
||||
}
|
||||
|
||||
//RevealBid is the command for revealing a bid
|
||||
func (s msgServer) RevealBid(c context.Context, msg *types.MsgRevealBid) (*types.MsgRevealBidResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := s.Keeper.RevealBid(ctx, *msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvents(sdk.Events{
|
||||
sdk.NewEvent(
|
||||
types.EventTypeRevealBid,
|
||||
sdk.NewAttribute(types.AttributeKeyAuctionID, msg.AuctionId),
|
||||
sdk.NewAttribute(types.AttributeKeyReveal, msg.Reveal),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(types.AttributeKeySigner, signerAddress.String()),
|
||||
),
|
||||
})
|
||||
|
||||
return &types.MsgRevealBidResponse{Auction: resp}, nil
|
||||
}
|
18
x/auction/keeper/params.go
Normal file
18
x/auction/keeper/params.go
Normal file
@ -0,0 +1,18 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/tharsis/ethermint/x/auction/types"
|
||||
)
|
||||
|
||||
// GetParams - Get all parameteras as types.Params.
|
||||
func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
|
||||
k.paramSubspace.GetParamSet(ctx, ¶ms)
|
||||
return
|
||||
}
|
||||
|
||||
// SetParams - set the params.
|
||||
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
|
||||
k.paramSubspace.SetParamSet(ctx, ¶ms)
|
||||
}
|
142
x/auction/module.go
Normal file
142
x/auction/module.go
Normal file
@ -0,0 +1,142 @@
|
||||
package auction
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
"github.com/tharsis/ethermint/x/auction/client/cli"
|
||||
"github.com/tharsis/ethermint/x/auction/keeper"
|
||||
"github.com/tharsis/ethermint/x/auction/types"
|
||||
)
|
||||
|
||||
// type check to ensure the interface is properly implemented
|
||||
var (
|
||||
_ module.AppModule = AppModule{}
|
||||
_ module.AppModuleBasic = AppModuleBasic{}
|
||||
)
|
||||
|
||||
// app module Basics object
|
||||
type AppModuleBasic struct {
|
||||
cdc codec.Codec
|
||||
}
|
||||
|
||||
func (b AppModuleBasic) Name() string {
|
||||
return types.ModuleName
|
||||
}
|
||||
|
||||
func (b AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
|
||||
types.RegisterLegacyAminoCodec(cdc)
|
||||
}
|
||||
|
||||
func (b AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
|
||||
types.RegisterInterfaces(registry)
|
||||
}
|
||||
|
||||
func (b AppModuleBasic) DefaultGenesis(jsonCodec codec.JSONCodec) json.RawMessage {
|
||||
return jsonCodec.MustMarshalJSON(types.DefaultGenesisState())
|
||||
}
|
||||
|
||||
// Validation check of the Genesis
|
||||
func (b AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error {
|
||||
var data types.GenesisState
|
||||
err := cdc.UnmarshalJSON(bz, &data)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
|
||||
}
|
||||
// Once json successfully marshalled, passes along to genesis.go
|
||||
return ValidateGenesis(data)
|
||||
}
|
||||
|
||||
// Register rest routes
|
||||
func (b AppModuleBasic) RegisterRESTRoutes(ctx client.Context, rtr *mux.Router) {
|
||||
// No-op.
|
||||
}
|
||||
|
||||
func (b AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, serveMux *runtime.ServeMux) {
|
||||
err := types.RegisterQueryHandlerClient(context.Background(), serveMux, types.NewQueryClient(clientCtx))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Get the root query command of this module
|
||||
func (b AppModuleBasic) GetQueryCmd() *cobra.Command {
|
||||
return cli.GetQueryCmd()
|
||||
}
|
||||
|
||||
// Get the root tx command of this module
|
||||
func (b AppModuleBasic) GetTxCmd() *cobra.Command {
|
||||
return cli.GetTxCmd()
|
||||
}
|
||||
|
||||
type AppModule struct {
|
||||
AppModuleBasic
|
||||
keeper keeper.Keeper
|
||||
}
|
||||
|
||||
// NewAppModule creates a new AppModule Object
|
||||
func NewAppModule(cdc codec.Codec, k keeper.Keeper) AppModule {
|
||||
return AppModule{
|
||||
AppModuleBasic: AppModuleBasic{cdc: cdc},
|
||||
keeper: k,
|
||||
}
|
||||
}
|
||||
|
||||
func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {
|
||||
keeper.RegisterInvariants(ir, am.keeper)
|
||||
}
|
||||
|
||||
func (am AppModule) Route() sdk.Route {
|
||||
return sdk.Route{}
|
||||
}
|
||||
|
||||
func (am AppModule) QuerierRoute() string {
|
||||
return types.QuerierRoute
|
||||
}
|
||||
|
||||
func (am AppModule) LegacyQuerierHandler(cdc *codec.LegacyAmino) sdk.Querier {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (am AppModule) RegisterServices(cfg module.Configurator) {
|
||||
querier := keeper.Querier{Keeper: am.keeper}
|
||||
types.RegisterQueryServer(cfg.QueryServer(), querier)
|
||||
|
||||
msgServer := keeper.NewMsgServer(am.keeper)
|
||||
types.RegisterMsgServer(cfg.MsgServer(), msgServer)
|
||||
}
|
||||
|
||||
func (am AppModule) ConsensusVersion() uint64 {
|
||||
return 1
|
||||
}
|
||||
|
||||
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}
|
||||
|
||||
func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
|
||||
return EndBlocker(ctx, am.keeper)
|
||||
}
|
||||
|
||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
|
||||
var genesisState types.GenesisState
|
||||
cdc.MustUnmarshalJSON(data, &genesisState)
|
||||
InitGenesis(ctx, am.keeper, genesisState)
|
||||
return []abci.ValidatorUpdate{}
|
||||
}
|
||||
|
||||
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
gs := ExportGenesis(ctx, am.keeper)
|
||||
return cdc.MustMarshalJSON(&gs)
|
||||
}
|
14
x/auction/module_test.go
Normal file
14
x/auction/module_test.go
Normal file
@ -0,0 +1,14 @@
|
||||
package auction_test
|
||||
|
||||
// func TestItCreatesModuleAccountOnInitBlock(t *testing.T) {
|
||||
// app := app2.Setup(false)
|
||||
// ctx := app.BaseApp.NewContext(false, tmproto.Header{})
|
||||
|
||||
// app.InitChain(abcitypes.RequestInitChain{
|
||||
// AppStateBytes: []byte("{}"),
|
||||
// ChainId: "test-chain-id",
|
||||
// })
|
||||
|
||||
// acc := app.AccountKeeper.GetModuleAccount(ctx, auctiontypes.ModuleName)
|
||||
// require.NotNil(t, acc)
|
||||
// }
|
37
x/auction/types/codec.go
Normal file
37
x/auction/types/codec.go
Normal file
@ -0,0 +1,37 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/msgservice"
|
||||
)
|
||||
|
||||
// RegisterLegacyAminoCodec registers the necessary x/auction interfaces and concrete types
|
||||
// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
|
||||
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
|
||||
cdc.RegisterConcrete(&MsgCreateAuction{}, "auction/MsgCreateAuction", nil)
|
||||
cdc.RegisterConcrete(&MsgCommitBid{}, "auction/MsgCommitBid", nil)
|
||||
cdc.RegisterConcrete(&MsgRevealBid{}, "auction/MsgRevealBid", nil)
|
||||
}
|
||||
|
||||
func RegisterInterfaces(registry types.InterfaceRegistry) {
|
||||
registry.RegisterImplementations((*sdk.Msg)(nil),
|
||||
&MsgCreateAuction{},
|
||||
&MsgCommitBid{},
|
||||
&MsgRevealBid{},
|
||||
)
|
||||
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
|
||||
}
|
||||
|
||||
var (
|
||||
amino = codec.NewLegacyAmino()
|
||||
ModuleCdc = codec.NewAminoCodec(amino)
|
||||
)
|
||||
|
||||
func init() {
|
||||
RegisterLegacyAminoCodec(amino)
|
||||
cryptocodec.RegisterCrypto(amino)
|
||||
amino.Seal()
|
||||
}
|
19
x/auction/types/events.go
Normal file
19
x/auction/types/events.go
Normal file
@ -0,0 +1,19 @@
|
||||
package types
|
||||
|
||||
const (
|
||||
EventTypeCreateAuction = "create-auction"
|
||||
EventTypeCommitBid = "commit-bid"
|
||||
EventTypeRevealBid = "reveal-bid"
|
||||
|
||||
AttributeKeyCommitsDuration = "commits-duration"
|
||||
AttributeKeyRevealsDuration = "reveals-duration"
|
||||
AttributeKeyCommitFee = "commit-fee"
|
||||
AttributeKeyRevealFee = "reveal-fee"
|
||||
AttributeKeyMinimumBid = "minimum-bid"
|
||||
AttributeKeySigner = "signer"
|
||||
AttributeKeyAuctionID = "auction-id"
|
||||
AttributeKeyCommitHash = "commit-hash"
|
||||
AttributeKeyReveal = "reveal"
|
||||
|
||||
AttributeValueCategory = ModuleName
|
||||
)
|
16
x/auction/types/expected_keepers.go
Normal file
16
x/auction/types/expected_keepers.go
Normal file
@ -0,0 +1,16 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// AuctionUsageKeeper keep track of auction usage in other modules.
|
||||
// Used to, for example, prevent deletion of a auction that's in use.
|
||||
type AuctionUsageKeeper interface {
|
||||
ModuleName() string
|
||||
UsesAuction(ctx sdk.Context, auctionID string) bool
|
||||
|
||||
OnAuction(ctx sdk.Context, auctionID string)
|
||||
OnAuctionBid(ctx sdk.Context, auctionID string, bidderAddress string)
|
||||
OnAuctionWinnerSelected(ctx sdk.Context, auctionID string)
|
||||
}
|
9
x/auction/types/genesis.go
Normal file
9
x/auction/types/genesis.go
Normal file
@ -0,0 +1,9 @@
|
||||
package types
|
||||
|
||||
// DefaultGenesisState sets default evm genesis state with empty accounts and default params and
|
||||
// chain config values.
|
||||
func DefaultGenesisState() *GenesisState {
|
||||
return &GenesisState{
|
||||
Params: DefaultParams(),
|
||||
}
|
||||
}
|
389
x/auction/types/genesis.pb.go
generated
Normal file
389
x/auction/types/genesis.pb.go
generated
Normal file
@ -0,0 +1,389 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: vulcanize/auction/v1beta1/genesis.proto
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
io "io"
|
||||
math "math"
|
||||
math_bits "math/bits"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// GenesisState defines the genesis state of the auction module
|
||||
type GenesisState struct {
|
||||
Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
|
||||
Auctions []*Auction `protobuf:"bytes,2,rep,name=auctions,proto3" json:"auctions,omitempty" json:"bonds" yaml:"bonds"`
|
||||
}
|
||||
|
||||
func (m *GenesisState) Reset() { *m = GenesisState{} }
|
||||
func (m *GenesisState) String() string { return proto.CompactTextString(m) }
|
||||
func (*GenesisState) ProtoMessage() {}
|
||||
func (*GenesisState) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_23ebfbd3a1e67fe6, []int{0}
|
||||
}
|
||||
func (m *GenesisState) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *GenesisState) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GenesisState.Merge(m, src)
|
||||
}
|
||||
func (m *GenesisState) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *GenesisState) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GenesisState.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GenesisState proto.InternalMessageInfo
|
||||
|
||||
func (m *GenesisState) GetParams() Params {
|
||||
if m != nil {
|
||||
return m.Params
|
||||
}
|
||||
return Params{}
|
||||
}
|
||||
|
||||
func (m *GenesisState) GetAuctions() []*Auction {
|
||||
if m != nil {
|
||||
return m.Auctions
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*GenesisState)(nil), "vulcanize.auction.v1beta1.GenesisState")
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterFile("vulcanize/auction/v1beta1/genesis.proto", fileDescriptor_23ebfbd3a1e67fe6)
|
||||
}
|
||||
|
||||
var fileDescriptor_23ebfbd3a1e67fe6 = []byte{
|
||||
// 264 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2f, 0x2b, 0xcd, 0x49,
|
||||
0x4e, 0xcc, 0xcb, 0xac, 0x4a, 0xd5, 0x4f, 0x2c, 0x4d, 0x2e, 0xc9, 0xcc, 0xcf, 0xd3, 0x2f, 0x33,
|
||||
0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28,
|
||||
0xca, 0x2f, 0xc9, 0x17, 0x92, 0x84, 0x2b, 0xd4, 0x83, 0x2a, 0xd4, 0x83, 0x2a, 0x94, 0x12, 0x49,
|
||||
0xcf, 0x4f, 0xcf, 0x07, 0xab, 0xd2, 0x07, 0xb1, 0x20, 0x1a, 0xa4, 0x54, 0x71, 0x9b, 0x5c, 0x52,
|
||||
0x59, 0x90, 0x0a, 0x35, 0x57, 0x69, 0x1d, 0x23, 0x17, 0x8f, 0x3b, 0xc4, 0xa6, 0xe0, 0x92, 0xc4,
|
||||
0x92, 0x54, 0x21, 0x7b, 0x2e, 0xb6, 0x82, 0xc4, 0xa2, 0xc4, 0xdc, 0x62, 0x09, 0x46, 0x05, 0x46,
|
||||
0x0d, 0x6e, 0x23, 0x45, 0x3d, 0x9c, 0x36, 0xeb, 0x05, 0x80, 0x15, 0x3a, 0xb1, 0x9c, 0xb8, 0x27,
|
||||
0xcf, 0x10, 0x04, 0xd5, 0x26, 0x14, 0xcb, 0xc5, 0x01, 0x55, 0x57, 0x2c, 0xc1, 0xa4, 0xc0, 0xac,
|
||||
0xc1, 0x6d, 0xa4, 0x84, 0xc7, 0x08, 0x47, 0x08, 0xdf, 0x49, 0xf6, 0xd3, 0x3d, 0x79, 0xc9, 0xac,
|
||||
0xe2, 0xfc, 0x3c, 0x2b, 0xa5, 0xa4, 0xfc, 0xbc, 0x94, 0x62, 0x25, 0x85, 0xca, 0xc4, 0xdc, 0x1c,
|
||||
0x18, 0x27, 0x08, 0x6e, 0xa4, 0x93, 0xdb, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e,
|
||||
0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31,
|
||||
0x44, 0xe9, 0xa4, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x97, 0x64, 0x24,
|
||||
0x16, 0x15, 0x67, 0x16, 0xeb, 0xa7, 0x96, 0x64, 0xa4, 0x16, 0xe5, 0x66, 0xe6, 0x95, 0xe8, 0x57,
|
||||
0xc0, 0x83, 0x01, 0xec, 0xfd, 0x24, 0x36, 0xb0, 0xff, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff,
|
||||
0x40, 0x0a, 0x31, 0x1a, 0x82, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Auctions) > 0 {
|
||||
for iNdEx := len(m.Auctions) - 1; iNdEx >= 0; iNdEx-- {
|
||||
{
|
||||
size, err := m.Auctions[iNdEx].MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintGenesis(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
}
|
||||
{
|
||||
size, err := m.Params.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintGenesis(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovGenesis(v)
|
||||
base := offset
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
v >>= 7
|
||||
offset++
|
||||
}
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *GenesisState) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = m.Params.Size()
|
||||
n += 1 + l + sovGenesis(uint64(l))
|
||||
if len(m.Auctions) > 0 {
|
||||
for _, e := range m.Auctions {
|
||||
l = e.Size()
|
||||
n += 1 + l + sovGenesis(uint64(l))
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovGenesis(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
func sozGenesis(x uint64) (n int) {
|
||||
return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *GenesisState) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowGenesis
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: GenesisState: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowGenesis
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthGenesis
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthGenesis
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Auctions", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowGenesis
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthGenesis
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthGenesis
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Auctions = append(m.Auctions, &Auction{})
|
||||
if err := m.Auctions[len(m.Auctions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipGenesis(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthGenesis
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipGenesis(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
depth := 0
|
||||
for iNdEx < l {
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowGenesis
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
wireType := int(wire & 0x7)
|
||||
switch wireType {
|
||||
case 0:
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowGenesis
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx++
|
||||
if dAtA[iNdEx-1] < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
iNdEx += 8
|
||||
case 2:
|
||||
var length int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowGenesis
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
length |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if length < 0 {
|
||||
return 0, ErrInvalidLengthGenesis
|
||||
}
|
||||
iNdEx += length
|
||||
case 3:
|
||||
depth++
|
||||
case 4:
|
||||
if depth == 0 {
|
||||
return 0, ErrUnexpectedEndOfGroupGenesis
|
||||
}
|
||||
depth--
|
||||
case 5:
|
||||
iNdEx += 4
|
||||
default:
|
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||
}
|
||||
if iNdEx < 0 {
|
||||
return 0, ErrInvalidLengthGenesis
|
||||
}
|
||||
if depth == 0 {
|
||||
return iNdEx, nil
|
||||
}
|
||||
}
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group")
|
||||
)
|
18
x/auction/types/key.go
Normal file
18
x/auction/types/key.go
Normal file
@ -0,0 +1,18 @@
|
||||
package types
|
||||
|
||||
const (
|
||||
// ModuleName is the name of the module
|
||||
ModuleName = "auction"
|
||||
|
||||
// AuctionBurnModuleAccountName is the name of the auction burn module account.
|
||||
AuctionBurnModuleAccountName = "auction_burn"
|
||||
|
||||
// StoreKey to be used when creating the KVStore
|
||||
StoreKey = ModuleName
|
||||
|
||||
// QuerierRoute is the querier route for the staking module
|
||||
QuerierRoute = ModuleName
|
||||
|
||||
// RouterKey is the msg router key for the staking module
|
||||
RouterKey = ModuleName
|
||||
)
|
150
x/auction/types/msgs.go
Normal file
150
x/auction/types/msgs.go
Normal file
@ -0,0 +1,150 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
_ sdk.Msg = &MsgCreateAuction{}
|
||||
_ sdk.Msg = &MsgCommitBid{}
|
||||
_ sdk.Msg = &MsgRevealBid{}
|
||||
)
|
||||
|
||||
// NewMsgCreateAuction is the constructor function for MsgCreateAuction.
|
||||
func NewMsgCreateAuction(params Params, signer sdk.AccAddress) MsgCreateAuction {
|
||||
return MsgCreateAuction{
|
||||
CommitsDuration: params.CommitsDuration,
|
||||
RevealsDuration: params.RevealsDuration,
|
||||
CommitFee: params.CommitFee,
|
||||
RevealFee: params.RevealFee,
|
||||
MinimumBid: params.MinimumBid,
|
||||
Signer: signer.String(),
|
||||
}
|
||||
}
|
||||
|
||||
// Route Implements Msg.
|
||||
func (msg MsgCreateAuction) Route() string { return RouterKey }
|
||||
|
||||
// Type Implements Msg.
|
||||
func (msg MsgCreateAuction) Type() string { return "create" }
|
||||
|
||||
// ValidateBasic Implements Msg.
|
||||
func (msg MsgCreateAuction) ValidateBasic() error {
|
||||
if msg.Signer == "" {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.Signer)
|
||||
}
|
||||
|
||||
if msg.CommitsDuration <= 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "commit phase duration invalid.")
|
||||
}
|
||||
|
||||
if msg.RevealsDuration <= 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "reveal phase duration invalid.")
|
||||
}
|
||||
|
||||
if !msg.MinimumBid.IsPositive() {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "minimum bid should be greater than zero.")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSignBytes Implements Msg.
|
||||
func (msg MsgCreateAuction) GetSignBytes() []byte {
|
||||
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
|
||||
}
|
||||
|
||||
// GetSigners Implements Msg.
|
||||
func (msg MsgCreateAuction) GetSigners() []sdk.AccAddress {
|
||||
accAddr, _ := sdk.AccAddressFromBech32(msg.Signer)
|
||||
return []sdk.AccAddress{accAddr}
|
||||
}
|
||||
|
||||
// NewMsgCommitBid is the constructor function for MsgCommitBid.
|
||||
func NewMsgCommitBid(auctionID string, commitHash string, signer sdk.AccAddress) MsgCommitBid {
|
||||
|
||||
return MsgCommitBid{
|
||||
AuctionId: auctionID,
|
||||
CommitHash: commitHash,
|
||||
Signer: signer.String(),
|
||||
}
|
||||
}
|
||||
|
||||
// Route Implements Msg.
|
||||
func (msg MsgCommitBid) Route() string { return RouterKey }
|
||||
|
||||
// Type Implements Msg.
|
||||
func (msg MsgCommitBid) Type() string { return "commit" }
|
||||
|
||||
// ValidateBasic Implements Msg.
|
||||
func (msg MsgCommitBid) ValidateBasic() error {
|
||||
if msg.Signer == "" {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer address.")
|
||||
}
|
||||
|
||||
if msg.AuctionId == "" {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "invalid auction ID.")
|
||||
}
|
||||
|
||||
if msg.CommitHash == "" {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "invalid commit hash.")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSignBytes Implements Msg.
|
||||
func (msg MsgCommitBid) GetSignBytes() []byte {
|
||||
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
|
||||
}
|
||||
|
||||
// GetSigners Implements Msg.
|
||||
func (msg MsgCommitBid) GetSigners() []sdk.AccAddress {
|
||||
accAddr, _ := sdk.AccAddressFromBech32(msg.Signer)
|
||||
return []sdk.AccAddress{accAddr}
|
||||
}
|
||||
|
||||
// NewMsgRevealBid is the constructor function for MsgRevealBid.
|
||||
func NewMsgRevealBid(auctionID string, reveal string, signer sdk.AccAddress) MsgRevealBid {
|
||||
|
||||
return MsgRevealBid{
|
||||
AuctionId: auctionID,
|
||||
Reveal: reveal,
|
||||
Signer: signer.String(),
|
||||
}
|
||||
}
|
||||
|
||||
// Route Implements Msg.
|
||||
func (msg MsgRevealBid) Route() string { return RouterKey }
|
||||
|
||||
// Type Implements Msg.
|
||||
func (msg MsgRevealBid) Type() string { return "reveal" }
|
||||
|
||||
// ValidateBasic Implements Msg.
|
||||
func (msg MsgRevealBid) ValidateBasic() error {
|
||||
if msg.Signer == "" {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer address.")
|
||||
}
|
||||
|
||||
if msg.AuctionId == "" {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "invalid auction ID.")
|
||||
}
|
||||
|
||||
if msg.Reveal == "" {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "invalid reveal data.")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSignBytes Implements Msg.
|
||||
func (msg MsgRevealBid) GetSignBytes() []byte {
|
||||
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
|
||||
}
|
||||
|
||||
// GetSigners Implements Msg.
|
||||
func (msg MsgRevealBid) GetSigners() []sdk.AccAddress {
|
||||
accAddr, _ := sdk.AccAddressFromBech32(msg.Signer)
|
||||
return []sdk.AccAddress{accAddr}
|
||||
}
|
173
x/auction/types/params.go
Normal file
173
x/auction/types/params.go
Normal file
@ -0,0 +1,173 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
// Default parameter namespace.
|
||||
const (
|
||||
DefaultParamspace = ModuleName
|
||||
)
|
||||
|
||||
var (
|
||||
DefaultCommitsDuration = 5 * time.Minute
|
||||
DefaultRevealsDuration = 5 * time.Minute
|
||||
DefaultCommitFee = sdk.Coin{Amount: sdk.NewInt(10), Denom: sdk.DefaultBondDenom}
|
||||
DefaultRevealFee = sdk.Coin{Amount: sdk.NewInt(10), Denom: sdk.DefaultBondDenom}
|
||||
DefaultMinimumBid = sdk.Coin{Amount: sdk.NewInt(1000), Denom: sdk.DefaultBondDenom}
|
||||
|
||||
ParamStoreKeyCommitsDuration = []byte("CommitsDuration")
|
||||
ParamStoreKeyRevealsDuration = []byte("RevealsDuration")
|
||||
ParamStoreKeyCommitFee = []byte("CommitFee")
|
||||
ParamStoreKeyRevealFee = []byte("RevealFee")
|
||||
ParamStoreKeyMinimumBid = []byte("MinimumBid")
|
||||
)
|
||||
|
||||
var _ types.ParamSet = &Params{}
|
||||
|
||||
func NewParams() Params {
|
||||
return DefaultParams()
|
||||
}
|
||||
|
||||
// ParamKeyTable - ParamTable for bond module.
|
||||
func ParamKeyTable() types.KeyTable {
|
||||
return types.NewKeyTable().RegisterParamSet(&Params{})
|
||||
}
|
||||
|
||||
// ParamSetPairs - implements params.ParamSet
|
||||
func (p *Params) ParamSetPairs() types.ParamSetPairs {
|
||||
return types.ParamSetPairs{
|
||||
types.NewParamSetPair(ParamStoreKeyCommitsDuration, &p.CommitsDuration, validateCommitsDuration),
|
||||
types.NewParamSetPair(ParamStoreKeyRevealsDuration, &p.RevealsDuration, validateRevealsDuration),
|
||||
types.NewParamSetPair(ParamStoreKeyCommitFee, &p.CommitFee, validateCommitFee),
|
||||
types.NewParamSetPair(ParamStoreKeyRevealFee, &p.RevealFee, validateRevealFee),
|
||||
types.NewParamSetPair(ParamStoreKeyMinimumBid, &p.MinimumBid, validateMinimumBid),
|
||||
}
|
||||
}
|
||||
|
||||
// Equal returns a boolean determining if two Params types are identical.
|
||||
func (p Params) Equal(p2 Params) bool {
|
||||
bz1 := ModuleCdc.MustMarshalLengthPrefixed(&p)
|
||||
bz2 := ModuleCdc.MustMarshalLengthPrefixed(&p2)
|
||||
return bytes.Equal(bz1, bz2)
|
||||
}
|
||||
|
||||
// DefaultParams returns a default set of parameters.
|
||||
func DefaultParams() Params {
|
||||
return Params{
|
||||
CommitsDuration: DefaultCommitsDuration,
|
||||
RevealsDuration: DefaultRevealsDuration,
|
||||
CommitFee: DefaultCommitFee,
|
||||
RevealFee: DefaultRevealFee,
|
||||
MinimumBid: DefaultMinimumBid,
|
||||
}
|
||||
}
|
||||
|
||||
// String returns a human readable string representation of the parameters.
|
||||
func (p Params) String() string {
|
||||
var sb strings.Builder
|
||||
sb.WriteString("Params: \n")
|
||||
sb.WriteString(fmt.Sprintf("CommitsDuration: %s\n", p.CommitsDuration.String()))
|
||||
sb.WriteString(fmt.Sprintf("RevealsDuration: %s\n", p.RevealsDuration.String()))
|
||||
sb.WriteString(fmt.Sprintf("CommitFee: %s\n", p.CommitFee.String()))
|
||||
sb.WriteString(fmt.Sprintf("RevealFee: %s\n", p.RevealFee.String()))
|
||||
sb.WriteString(fmt.Sprintf("MinimumBid: %s\n", p.MinimumBid.String()))
|
||||
return sb.String()
|
||||
}
|
||||
|
||||
func validateCommitsDuration(i interface{}) error {
|
||||
v, ok := i.(time.Duration)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid parameter type: %T", i)
|
||||
}
|
||||
|
||||
if v < 0 {
|
||||
return errors.New("commits duration cannot be negative")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateRevealsDuration(i interface{}) error {
|
||||
v, ok := i.(time.Duration)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid parameter type: %T", i)
|
||||
}
|
||||
|
||||
if v < 0 {
|
||||
return errors.New("commits duration cannot be negative")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateCommitFee(i interface{}) error {
|
||||
v, ok := i.(sdk.Coin)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid parameter type: %T", i)
|
||||
}
|
||||
|
||||
if v.Amount.IsNegative() {
|
||||
return errors.New("commit fee must be positive")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateRevealFee(i interface{}) error {
|
||||
v, ok := i.(sdk.Coin)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid parameter type: %T", i)
|
||||
}
|
||||
|
||||
if v.Amount.IsNegative() {
|
||||
return errors.New("reveal fee must be positive")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateMinimumBid(i interface{}) error {
|
||||
v, ok := i.(sdk.Coin)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid parameter type: %T", i)
|
||||
}
|
||||
|
||||
if v.Amount.IsNegative() {
|
||||
return errors.New("minimum bid must be positive")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Validate a set of params.
|
||||
func (p Params) Validate() error {
|
||||
if err := validateCommitsDuration(p.CommitsDuration); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validateRevealsDuration(p.RevealsDuration); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validateCommitFee(p.CommitFee); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validateRevealFee(p.RevealFee); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validateMinimumBid(p.MinimumBid); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
3390
x/auction/types/query.pb.go
generated
Normal file
3390
x/auction/types/query.pb.go
generated
Normal file
File diff suppressed because it is too large
Load Diff
802
x/auction/types/query.pb.gw.go
generated
Normal file
802
x/auction/types/query.pb.gw.go
generated
Normal file
@ -0,0 +1,802 @@
|
||||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
||||
// source: vulcanize/auction/v1beta1/query.proto
|
||||
|
||||
/*
|
||||
Package types is a reverse proxy.
|
||||
|
||||
It translates gRPC into RESTful JSON APIs.
|
||||
*/
|
||||
package types
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/golang/protobuf/descriptor"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/utilities"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// Suppress "imported and not used" errors
|
||||
var _ codes.Code
|
||||
var _ io.Reader
|
||||
var _ status.Status
|
||||
var _ = runtime.String
|
||||
var _ = utilities.NewDoubleArray
|
||||
var _ = descriptor.ForMessage
|
||||
|
||||
var (
|
||||
filter_Query_Auctions_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||
)
|
||||
|
||||
func request_Query_Auctions_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq AuctionsRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Auctions_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.Auctions(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_Auctions_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq AuctionsRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Auctions_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.Auctions(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_Query_GetAuction_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq AuctionRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
|
||||
}
|
||||
|
||||
protoReq.Id, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
|
||||
}
|
||||
|
||||
msg, err := client.GetAuction(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_GetAuction_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq AuctionRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
|
||||
}
|
||||
|
||||
protoReq.Id, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
|
||||
}
|
||||
|
||||
msg, err := server.GetAuction(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_Query_GetBid_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq BidRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["auction_id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "auction_id")
|
||||
}
|
||||
|
||||
protoReq.AuctionId, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auction_id", err)
|
||||
}
|
||||
|
||||
val, ok = pathParams["bidder"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "bidder")
|
||||
}
|
||||
|
||||
protoReq.Bidder, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "bidder", err)
|
||||
}
|
||||
|
||||
msg, err := client.GetBid(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_GetBid_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq BidRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["auction_id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "auction_id")
|
||||
}
|
||||
|
||||
protoReq.AuctionId, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auction_id", err)
|
||||
}
|
||||
|
||||
val, ok = pathParams["bidder"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "bidder")
|
||||
}
|
||||
|
||||
protoReq.Bidder, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "bidder", err)
|
||||
}
|
||||
|
||||
msg, err := server.GetBid(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_Query_GetBids_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq BidsRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["auction_id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "auction_id")
|
||||
}
|
||||
|
||||
protoReq.AuctionId, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auction_id", err)
|
||||
}
|
||||
|
||||
msg, err := client.GetBids(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_GetBids_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq BidsRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["auction_id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "auction_id")
|
||||
}
|
||||
|
||||
protoReq.AuctionId, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auction_id", err)
|
||||
}
|
||||
|
||||
msg, err := server.GetBids(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_Query_AuctionsByBidder_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq AuctionsByBidderRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["bidder_address"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "bidder_address")
|
||||
}
|
||||
|
||||
protoReq.BidderAddress, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "bidder_address", err)
|
||||
}
|
||||
|
||||
msg, err := client.AuctionsByBidder(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_AuctionsByBidder_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq AuctionsByBidderRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["bidder_address"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "bidder_address")
|
||||
}
|
||||
|
||||
protoReq.BidderAddress, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "bidder_address", err)
|
||||
}
|
||||
|
||||
msg, err := server.AuctionsByBidder(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_Query_AuctionsByOwner_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq AuctionsByOwnerRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["owner_address"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "owner_address")
|
||||
}
|
||||
|
||||
protoReq.OwnerAddress, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "owner_address", err)
|
||||
}
|
||||
|
||||
msg, err := client.AuctionsByOwner(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_AuctionsByOwner_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq AuctionsByOwnerRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["owner_address"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "owner_address")
|
||||
}
|
||||
|
||||
protoReq.OwnerAddress, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "owner_address", err)
|
||||
}
|
||||
|
||||
msg, err := server.AuctionsByOwner(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_Query_QueryParams_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryParamsRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := client.QueryParams(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_QueryParams_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryParamsRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := server.QueryParams(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_Query_Balance_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq BalanceRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := client.Balance(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_Balance_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq BalanceRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := server.Balance(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
|
||||
// UnaryRPC :call QueryServer directly.
|
||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||
// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.
|
||||
func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
|
||||
|
||||
mux.Handle("GET", pattern_Query_Auctions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_Auctions_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_Auctions_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_GetAuction_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_GetAuction_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_GetAuction_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_GetBid_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_GetBid_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_GetBid_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_GetBids_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_GetBids_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_GetBids_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_AuctionsByBidder_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_AuctionsByBidder_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_AuctionsByBidder_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_AuctionsByOwner_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_AuctionsByOwner_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_AuctionsByOwner_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_QueryParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_QueryParams_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_QueryParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_Balance_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_Balance_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_Balance_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but
|
||||
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
|
||||
func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
|
||||
conn, err := grpc.Dial(endpoint, opts...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if err != nil {
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
|
||||
}
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
|
||||
}
|
||||
}()
|
||||
}()
|
||||
|
||||
return RegisterQueryHandler(ctx, mux, conn)
|
||||
}
|
||||
|
||||
// RegisterQueryHandler registers the http handlers for service Query to "mux".
|
||||
// The handlers forward requests to the grpc endpoint over "conn".
|
||||
func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
|
||||
return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn))
|
||||
}
|
||||
|
||||
// RegisterQueryHandlerClient registers the http handlers for service Query
|
||||
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient".
|
||||
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient"
|
||||
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
|
||||
// "QueryClient" to call the correct interceptors.
|
||||
func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error {
|
||||
|
||||
mux.Handle("GET", pattern_Query_Auctions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_Auctions_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_Auctions_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_GetAuction_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_GetAuction_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_GetAuction_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_GetBid_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_GetBid_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_GetBid_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_GetBids_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_GetBids_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_GetBids_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_AuctionsByBidder_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_AuctionsByBidder_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_AuctionsByBidder_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_AuctionsByOwner_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_AuctionsByOwner_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_AuctionsByOwner_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_QueryParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_QueryParams_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_QueryParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_Balance_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_Balance_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_Balance_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_Query_Auctions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"vulcanize", "auction", "v1beta1", "auctions"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_GetAuction_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"vulcanize", "auction", "v1beta1", "auctions", "id"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_GetBid_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"vulcanize", "auction", "v1beta1", "bids", "auction_id", "bidder"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_GetBids_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"vulcanize", "auction", "v1beta1", "bids", "auction_id"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_AuctionsByBidder_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"vulcanize", "auction", "v1beta1", "by-bidder", "bidder_address"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_AuctionsByOwner_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"vulcanize", "auction", "v1beta1", "by-owner", "owner_address"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_QueryParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"vulcanize", "auction", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_Balance_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"vulcanize", "auction", "v1beta1", "balance"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
)
|
||||
|
||||
var (
|
||||
forward_Query_Auctions_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_GetAuction_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_GetBid_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_GetBids_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_AuctionsByBidder_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_AuctionsByOwner_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_QueryParams_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_Balance_0 = runtime.ForwardResponseMessage
|
||||
)
|
1777
x/auction/types/tx.pb.go
generated
Normal file
1777
x/auction/types/tx.pb.go
generated
Normal file
File diff suppressed because it is too large
Load Diff
65
x/auction/types/types.go
Normal file
65
x/auction/types/types.go
Normal file
@ -0,0 +1,65 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// Auction status values.
|
||||
const (
|
||||
// Auction is in commit phase.
|
||||
AuctionStatusCommitPhase = "commit"
|
||||
|
||||
// Auction is in reveal phase.
|
||||
AuctionStatusRevealPhase = "reveal"
|
||||
|
||||
// Auction has ended (no reveals allowed).
|
||||
AuctionStatusExpired = "expired"
|
||||
|
||||
// Auction has completed (winner selected).
|
||||
AuctionStatusCompleted = "completed"
|
||||
)
|
||||
|
||||
// Bid status values.
|
||||
const (
|
||||
BidStatusCommitted = "commit"
|
||||
BidStatusRevealed = "reveal"
|
||||
)
|
||||
|
||||
// AuctionID simplifies generation of auction IDs.
|
||||
type AuctionID struct {
|
||||
Address sdk.Address
|
||||
AccNum uint64
|
||||
Sequence uint64
|
||||
}
|
||||
|
||||
// Generate creates the auction ID.
|
||||
func (auctionID AuctionID) Generate() string {
|
||||
hasher := sha256.New()
|
||||
str := fmt.Sprintf("%s:%d:%d", auctionID.Address.String(), auctionID.AccNum, auctionID.Sequence)
|
||||
hasher.Write([]byte(str))
|
||||
return hex.EncodeToString(hasher.Sum(nil))
|
||||
}
|
||||
|
||||
func (auction Auction) GetCreateTime() string {
|
||||
return string(sdk.FormatTimeBytes(auction.CreateTime))
|
||||
}
|
||||
|
||||
func (auction Auction) GetCommitsEndTime() string {
|
||||
return string(sdk.FormatTimeBytes(auction.CommitsEndTime))
|
||||
}
|
||||
|
||||
func (auction Auction) GetRevealsEndTime() string {
|
||||
return string(sdk.FormatTimeBytes(auction.RevealsEndTime))
|
||||
}
|
||||
|
||||
func (bid Bid) GetCommitTime() string {
|
||||
return string(sdk.FormatTimeBytes(bid.CommitTime))
|
||||
}
|
||||
|
||||
func (bid Bid) GetRevealTime() string {
|
||||
return string(sdk.FormatTimeBytes(bid.RevealTime))
|
||||
}
|
1943
x/auction/types/types.pb.go
generated
Normal file
1943
x/auction/types/types.pb.go
generated
Normal file
File diff suppressed because it is too large
Load Diff
196
x/bond/README.md
Normal file
196
x/bond/README.md
Normal file
@ -0,0 +1,196 @@
|
||||
# Build chain
|
||||
```bash
|
||||
# it will create binary in build folder with `ethermintd`
|
||||
$ make build
|
||||
```
|
||||
# Setup Chain
|
||||
```bash
|
||||
./build/ethermintd keys add root
|
||||
./build/ethermintd init test-moniker --chain-id ethermint_9000-1
|
||||
./build/ethermintd add-genesis-account $(./build/ethermintd keys show root -a) 1000000000000000000aphoton,1000000000000000000stake
|
||||
./build/ethermintd gentx root 1000000000000000000stake --chain-id ethermint_9000-1
|
||||
./build/ethermintd collect-gentxs
|
||||
./build/ethermintd start
|
||||
```
|
||||
|
||||
# Params
|
||||
```
|
||||
$ ./build/ethermintd q bond params -o json | jq .
|
||||
|
||||
{
|
||||
"params": {
|
||||
"max_bond_amount": {
|
||||
"denom": "stake",
|
||||
"amount": "100000000000"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
# Create Bond
|
||||
```
|
||||
$ ./build/ethermintd tx bond create 100aphoton --from root --chain-id $(./build/ethermintd status | jq .NodeInfo.network -r)
|
||||
|
||||
{"body":{"messages":[{"@type":"/vulcanize.bond.v1beta1.MsgCreateBond","signer":"ethm1mfdjngh5jvjs9lqtt9a7y2hlgw8v3syh3hsqzk","coins":[{"denom":"aphoton","amount":"100"}]}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}
|
||||
|
||||
confirm transaction before signing and broadcasting [y/N]: y
|
||||
code: 0
|
||||
codespace: ""
|
||||
data: ""
|
||||
gas_used: "0"
|
||||
gas_wanted: "0"
|
||||
height: "0"
|
||||
info: ""
|
||||
logs: []
|
||||
raw_log: '[]'
|
||||
timestamp: ""
|
||||
tx: null
|
||||
txhash: C6D362E11D4C9FB06D620F3CCAF363A69A074297A00E9CAECBDA5BE1CC302EB8
|
||||
```
|
||||
# Refill Bond
|
||||
```
|
||||
$ ./build/ethermintd tx bond refill c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440 1000aphoton --from root --chain-id $(./build/ethermintd status | jq .NodeInfo.network -r)
|
||||
{"body":{"messages":[{"@type":"/vulcanize.bond.v1beta1.MsgRefillBond","id":"c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440","signer":"ethm1mfdjngh5jvjs9lqtt9a7y2hlgw8v3syh3hsqzk","coins":[{"denom":"aphoton","amount":"1000"}]}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}
|
||||
|
||||
confirm transaction before signing and broadcasting [y/N]: y
|
||||
code: 0
|
||||
codespace: ""
|
||||
data: ""
|
||||
gas_used: "0"
|
||||
gas_wanted: "0"
|
||||
height: "0"
|
||||
info: ""
|
||||
logs: []
|
||||
raw_log: '[]'
|
||||
timestamp: ""
|
||||
tx: null
|
||||
txhash: 025B04E2C923EFE2299CD171B40829CB1FE4D1A69DA7563C64AAC3D5C27BDFC9
|
||||
|
||||
```
|
||||
# Withdraw from bond
|
||||
```
|
||||
$ ./build/ethermintd tx bond withdraw c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440 1000aphoton --from root --chain-id $(./build/ethermintd status | jq .NodeInfo.network -r)
|
||||
{"body":{"messages":[{"@type":"/vulcanize.bond.v1beta1.MsgWithdrawBond","id":"c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440","signer":"ethm1mfdjngh5jvjs9lqtt9a7y2hlgw8v3syh3hsqzk","coins":[{"denom":"aphoton","amount":"1000"}]}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}
|
||||
|
||||
confirm transaction before signing and broadcasting [y/N]: y
|
||||
code: 0
|
||||
codespace: ""
|
||||
data: ""
|
||||
gas_used: "0"
|
||||
gas_wanted: "0"
|
||||
height: "0"
|
||||
info: ""
|
||||
logs: []
|
||||
raw_log: '[]'
|
||||
timestamp: ""
|
||||
tx: null
|
||||
txhash: 7C5E2FE674577CD6BFFF9F92FCCBC61EDFE8F1A00CE29AC84D58FB8F013D2F03
|
||||
```
|
||||
# List Bond
|
||||
```
|
||||
$ ./build/ethermintd q bond list -o json | jq .
|
||||
{
|
||||
"bonds": [
|
||||
{
|
||||
"id": "c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440",
|
||||
"owner": "ethm1mfdjngh5jvjs9lqtt9a7y2hlgw8v3syh3hsqzk",
|
||||
"balance": [
|
||||
{
|
||||
"denom": "aphoton",
|
||||
"amount": "100"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"pagination": null
|
||||
}
|
||||
|
||||
```
|
||||
# Get Bond by Id
|
||||
```
|
||||
$ ./build/ethermintd q bond get c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440 -o json | jq .
|
||||
{
|
||||
"bond": {
|
||||
"id": "c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440",
|
||||
"owner": "ethm1mfdjngh5jvjs9lqtt9a7y2hlgw8v3syh3hsqzk",
|
||||
"balance": [
|
||||
{
|
||||
"denom": "aphoton",
|
||||
"amount": "100"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
# Get Bond Module Balance
|
||||
```
|
||||
$ ./build/ethermintd q bond balance -o json | jq .
|
||||
{
|
||||
"balance": [
|
||||
{
|
||||
"denom": "aphoton",
|
||||
"amount": "100"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
# Get Bonds By Owner
|
||||
```
|
||||
$ ./build/ethermintd q bond by-owner ethm1mfdjngh5jvjs9lqtt9a7y2hlgw8v3syh3hsqzk -o json | jq .
|
||||
{
|
||||
"bonds": [
|
||||
{
|
||||
"id": "c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440",
|
||||
"owner": "ethm1mfdjngh5jvjs9lqtt9a7y2hlgw8v3syh3hsqzk",
|
||||
"balance": [
|
||||
{
|
||||
"denom": "aphoton",
|
||||
"amount": "100"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"pagination": null
|
||||
}
|
||||
```
|
||||
|
||||
# Cancel the bond
|
||||
```
|
||||
$ ./build/ethermintd tx bond cancel c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440 --from root --chain-id $(./build/ethermintd status | jq .NodeInfo.network -r)
|
||||
{"body":{"messages":[{"@type":"/vulcanize.bond.v1beta1.MsgCancelBond","id":"c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440","signer":"ethm1mfdjngh5jvjs9lqtt9a7y2hlgw8v3syh3hsqzk"}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}
|
||||
|
||||
confirm transaction before signing and broadcasting [y/N]: y
|
||||
code: 0
|
||||
codespace: ""
|
||||
data: ""
|
||||
gas_used: "0"
|
||||
gas_wanted: "0"
|
||||
height: "0"
|
||||
info: ""
|
||||
logs: []
|
||||
raw_log: '[]'
|
||||
timestamp: ""
|
||||
tx: null
|
||||
txhash: 06440D0B35A862E3A6783E147F0E1CDD3374870DAE07E471D465E2830DAF7044
|
||||
|
||||
```
|
||||
|
||||
Note : After the bond create and withdraw bond and cancel bond , account amount needs change as per module
|
||||
```
|
||||
$ ./build/ethermintd q bank balances $(./build/ethermintd keys show root -a) -o json | jq .
|
||||
{
|
||||
"balances": [
|
||||
{
|
||||
"denom": "aphoton",
|
||||
"amount": "1000000000000000000"
|
||||
}
|
||||
],
|
||||
"pagination": {
|
||||
"next_key": null,
|
||||
"total": "0"
|
||||
}
|
||||
}
|
||||
```
|
17
x/bond/abci.go
Normal file
17
x/bond/abci.go
Normal file
@ -0,0 +1,17 @@
|
||||
package bond
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tharsis/ethermint/x/bond/keeper"
|
||||
)
|
||||
|
||||
// BeginBlocker will persist the current header and validator set as a historical entry
|
||||
// and prune the oldest entry based on the HistoricalEntries parameter
|
||||
func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
|
||||
}
|
||||
|
||||
// EndBlocker Called every block, update validator set
|
||||
func EndBlocker(ctx sdk.Context, k keeper.Keeper) []abci.ValidatorUpdate {
|
||||
return []abci.ValidatorUpdate{}
|
||||
}
|
203
x/bond/client/cli/query.go
Normal file
203
x/bond/client/cli/query.go
Normal file
@ -0,0 +1,203 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/tharsis/ethermint/x/bond/types"
|
||||
)
|
||||
|
||||
// GetQueryCmd returns the cli query commands for this module
|
||||
func GetQueryCmd() *cobra.Command {
|
||||
bondQueryCmd := &cobra.Command{
|
||||
Use: types.ModuleName,
|
||||
Short: "Querying commands for the bond module",
|
||||
DisableFlagParsing: true,
|
||||
SuggestionsMinimumDistance: 2,
|
||||
RunE: client.ValidateCmd,
|
||||
}
|
||||
|
||||
bondQueryCmd.AddCommand(
|
||||
GetQueryParamsCmd(),
|
||||
GetQueryBondLists(),
|
||||
GetBondByIdCmd(),
|
||||
GetBondListByOwnerCmd(),
|
||||
GetBondModuleBalanceCmd(),
|
||||
)
|
||||
|
||||
return bondQueryCmd
|
||||
}
|
||||
|
||||
// GetQueryParamsCmd implements the params query command.
|
||||
func GetQueryParamsCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "params",
|
||||
Args: cobra.NoArgs,
|
||||
Short: "Query the current bond parameters information.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Query values set as bond parameters.
|
||||
|
||||
Example:
|
||||
$ %s query %s params
|
||||
`,
|
||||
version.AppName, types.ModuleName,
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetQueryBondLists implements the bond lists query command.
|
||||
func GetQueryBondLists() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List bonds.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Get bond list .
|
||||
|
||||
Example:
|
||||
$ %s query %s list
|
||||
`,
|
||||
version.AppName, types.ModuleName,
|
||||
),
|
||||
),
|
||||
Args: cobra.ExactArgs(0),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
res, err := queryClient.Bonds(cmd.Context(), &types.QueryGetBondsRequest{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetBondByIdCmd implements the bond info by id query command.
|
||||
func GetBondByIdCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "get [bond Id]",
|
||||
Short: "Get bond.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Get bond info by bond id .
|
||||
|
||||
Example:
|
||||
$ %s query bond get {BOND ID}
|
||||
`,
|
||||
version.AppName,
|
||||
),
|
||||
),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
|
||||
id := args[0]
|
||||
|
||||
res, err := queryClient.GetBondById(cmd.Context(), &types.QueryGetBondByIdRequest{Id: id})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetBondListByOwnerCmd queries the bond list by owner.
|
||||
func GetBondListByOwnerCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "by-owner [address]",
|
||||
Short: "Query bonds by owner.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Get bond list by owner.
|
||||
|
||||
Example:
|
||||
$ %s query %s query-by-owner [address]
|
||||
`,
|
||||
version.AppName, types.ModuleName,
|
||||
),
|
||||
),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
owner := args[0]
|
||||
res, err := queryClient.GetBondsByOwner(cmd.Context(), &types.QueryGetBondsByOwnerRequest{Owner: owner})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetBondModuleBalanceCmd queries the bond module account balance.
|
||||
func GetBondModuleBalanceCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "balance",
|
||||
Short: "Get bond module account balance.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Get bond module balance.
|
||||
|
||||
Example:
|
||||
$ %s query %s balance
|
||||
`,
|
||||
version.AppName, types.ModuleName,
|
||||
),
|
||||
),
|
||||
Args: cobra.ExactArgs(0),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
|
||||
res, err := queryClient.GetBondsModuleBalance(cmd.Context(), &types.QueryGetBondModuleBalanceRequest{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
125
x/bond/client/cli/tx.go
Normal file
125
x/bond/client/cli/tx.go
Normal file
@ -0,0 +1,125 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/tharsis/ethermint/server/flags"
|
||||
"github.com/tharsis/ethermint/x/bond/types"
|
||||
)
|
||||
|
||||
// NewTxCmd returns a root CLI command handler for all x/bond transaction commands.
|
||||
func NewTxCmd() *cobra.Command {
|
||||
bondTxCmd := &cobra.Command{
|
||||
Use: types.ModuleName,
|
||||
Short: "bond transaction subcommands",
|
||||
DisableFlagParsing: true,
|
||||
SuggestionsMinimumDistance: 2,
|
||||
RunE: client.ValidateCmd,
|
||||
}
|
||||
|
||||
bondTxCmd.AddCommand(
|
||||
NewCreateBondCmd(),
|
||||
RefillBondCmd(),
|
||||
WithdrawBondCmd(),
|
||||
CancelBondCmd(),
|
||||
)
|
||||
|
||||
return bondTxCmd
|
||||
}
|
||||
|
||||
// NewCreateBondCmd is the CLI command for creating a bond.
|
||||
func NewCreateBondCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "create [amount]",
|
||||
Short: "Create bond.",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
coin, err := sdk.ParseCoinNormalized(args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
msg := types.NewMsgCreateBond(sdk.NewCoins(coin), clientCtx.GetFromAddress())
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// RefillBondCmd is the CLI command for creating a bond.
|
||||
func RefillBondCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "refill [bond Id] [amount]",
|
||||
Short: "Refill bond.",
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
bondId := args[0]
|
||||
coin, err := sdk.ParseCoinNormalized(args[1])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
msg := types.NewMsgRefillBond(bondId, coin, clientCtx.GetFromAddress())
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// WithdrawBondCmd is the CLI command for withdrawing funds from a bond.
|
||||
func WithdrawBondCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "withdraw [bond Id] [amount]",
|
||||
Short: "Withdraw amount from bond.",
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
bondId := args[0]
|
||||
coin, err := sdk.ParseCoinNormalized(args[1])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
msg := types.NewMsgWithdrawBond(bondId, coin, clientCtx.GetFromAddress())
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// CancelBondCmd is the CLI command for cancelling a bond.
|
||||
func CancelBondCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "cancel [bond Id]",
|
||||
Short: "cancel bond.",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
bondId := args[0]
|
||||
msg := types.NewMsgCancelBond(bondId, clientCtx.GetFromAddress())
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
14
x/bond/client/testutil/cli_test.go
Normal file
14
x/bond/client/testutil/cli_test.go
Normal file
@ -0,0 +1,14 @@
|
||||
package testutil
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/tharsis/ethermint/testutil/network"
|
||||
)
|
||||
|
||||
func TestIntegrationTestSuite(t *testing.T) {
|
||||
cfg := network.DefaultConfig()
|
||||
cfg.NumValidators = 1
|
||||
suite.Run(t, NewIntegrationTestSuite(cfg))
|
||||
}
|
213
x/bond/client/testutil/grpc.go
Normal file
213
x/bond/client/testutil/grpc.go
Normal file
@ -0,0 +1,213 @@
|
||||
package testutil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
"github.com/cosmos/cosmos-sdk/types/rest"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
"github.com/tharsis/ethermint/x/bond/client/cli"
|
||||
bondtypes "github.com/tharsis/ethermint/x/bond/types"
|
||||
)
|
||||
|
||||
func (s *IntegrationTestSuite) TestGRPCGetBonds() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
reqUrl := fmt.Sprintf("%s/vulcanize/bond/v1beta1/bonds", val.APIAddress)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
url string
|
||||
expErr bool
|
||||
errorMsg string
|
||||
preRun func()
|
||||
}{
|
||||
{
|
||||
"invalid request with headers",
|
||||
reqUrl + "asdasdas",
|
||||
true,
|
||||
"",
|
||||
func() {
|
||||
|
||||
},
|
||||
},
|
||||
{
|
||||
"valid request",
|
||||
reqUrl,
|
||||
false,
|
||||
"",
|
||||
func() {
|
||||
s.createBond()
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
resp, _ := rest.GetRequest(tc.url)
|
||||
if tc.expErr {
|
||||
sr.Contains(string(resp), tc.errorMsg)
|
||||
} else {
|
||||
var response bondtypes.QueryGetBondsResponse
|
||||
err := val.ClientCtx.Codec.UnmarshalJSON(resp, &response)
|
||||
sr.NoError(err)
|
||||
sr.NotZero(len(response.GetBonds()))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestGRPCGetParams() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
reqUrl := fmt.Sprintf("%s/vulcanize/bond/v1beta1/params", val.APIAddress)
|
||||
|
||||
resp, err := rest.GetRequest(reqUrl)
|
||||
s.Require().NoError(err)
|
||||
|
||||
var params bondtypes.QueryParamsResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(resp, ¶ms)
|
||||
|
||||
sr.NoError(err)
|
||||
sr.Equal(params.GetParams().MaxBondAmount, bondtypes.DefaultParams().MaxBondAmount)
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestGRPCGetBondsByOwner() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
reqUrl := val.APIAddress + "/vulcanize/bond/v1beta1/by-owner/%s"
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
url string
|
||||
expErr bool
|
||||
preRun func()
|
||||
}{
|
||||
{
|
||||
"empty list",
|
||||
fmt.Sprintf(reqUrl, "asdasd"),
|
||||
true,
|
||||
func() {
|
||||
|
||||
},
|
||||
},
|
||||
{
|
||||
"valid request",
|
||||
fmt.Sprintf(reqUrl, s.accountAddress),
|
||||
false,
|
||||
func() {
|
||||
s.createBond()
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
if !tc.expErr {
|
||||
tc.preRun()
|
||||
}
|
||||
|
||||
resp, err := rest.GetRequest(tc.url)
|
||||
s.Require().NoError(err)
|
||||
|
||||
var bonds bondtypes.QueryGetBondsByOwnerResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &bonds)
|
||||
sr.NoError(err)
|
||||
if tc.expErr {
|
||||
sr.Empty(bonds.GetBonds())
|
||||
} else {
|
||||
bondsList := bonds.GetBonds()
|
||||
sr.NotZero(len(bondsList))
|
||||
sr.Equal(s.accountAddress, bondsList[0].GetOwner())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestGRPCGetBondById() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
reqUrl := val.APIAddress + "/vulcanize/bond/v1beta1/bonds/%s"
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
url string
|
||||
expErr bool
|
||||
preRun func() string
|
||||
}{
|
||||
{
|
||||
"invalid request",
|
||||
fmt.Sprintf(reqUrl, "asdadad"),
|
||||
true,
|
||||
func() string {
|
||||
return ""
|
||||
},
|
||||
},
|
||||
{
|
||||
"valid request",
|
||||
reqUrl,
|
||||
false,
|
||||
func() string {
|
||||
// creating the bond
|
||||
s.createBond()
|
||||
|
||||
// getting the bonds list and returning the bond-id
|
||||
clientCtx := val.ClientCtx
|
||||
cmd := cli.GetQueryBondLists()
|
||||
args := []string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
}
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, args)
|
||||
sr.NoError(err)
|
||||
var queryResponse bondtypes.QueryGetBondsResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &queryResponse)
|
||||
sr.NoError(err)
|
||||
|
||||
// extract bond id from bonds list
|
||||
bond := queryResponse.GetBonds()[0]
|
||||
return bond.GetId()
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
var bondId string
|
||||
if !tc.expErr {
|
||||
bondId = tc.preRun()
|
||||
tc.url = fmt.Sprintf(reqUrl, bondId)
|
||||
}
|
||||
|
||||
resp, err := rest.GetRequest(tc.url)
|
||||
s.Require().NoError(err)
|
||||
|
||||
var bonds bondtypes.QueryGetBondByIdResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &bonds)
|
||||
|
||||
if tc.expErr {
|
||||
sr.Empty(bonds.GetBond().GetId())
|
||||
} else {
|
||||
sr.NoError(err)
|
||||
sr.NotZero(bonds.GetBond().GetId())
|
||||
sr.Equal(bonds.GetBond().GetId(), bondId)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestGRPCGetBondModuleBalance() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
reqUrl := fmt.Sprintf("%s/vulcanize/bond/v1beta1/balance", val.APIAddress)
|
||||
|
||||
// creating the bond
|
||||
s.createBond()
|
||||
|
||||
s.Run("valid request", func() {
|
||||
resp, err := rest.GetRequest(reqUrl)
|
||||
sr.NoError(err)
|
||||
|
||||
var response bondtypes.QueryGetBondModuleBalanceResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &response)
|
||||
|
||||
sr.NoError(err)
|
||||
sr.False(response.GetBalance().IsZero())
|
||||
})
|
||||
}
|
330
x/bond/client/testutil/query.go
Normal file
330
x/bond/client/testutil/query.go
Normal file
@ -0,0 +1,330 @@
|
||||
package testutil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
banktestutil "github.com/cosmos/cosmos-sdk/x/bank/client/testutil"
|
||||
"github.com/stretchr/testify/suite"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
"github.com/tharsis/ethermint/testutil/network"
|
||||
"github.com/tharsis/ethermint/x/bond/client/cli"
|
||||
"github.com/tharsis/ethermint/x/bond/types"
|
||||
)
|
||||
|
||||
type IntegrationTestSuite struct {
|
||||
suite.Suite
|
||||
|
||||
cfg network.Config
|
||||
network *network.Network
|
||||
accountName string
|
||||
accountAddress string
|
||||
}
|
||||
|
||||
func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite {
|
||||
return &IntegrationTestSuite{cfg: cfg}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) SetupSuite() {
|
||||
s.T().Log("setting up integration test suite")
|
||||
var err error
|
||||
s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg)
|
||||
s.Require().NoError(err)
|
||||
|
||||
_, err = s.network.WaitForHeight(1)
|
||||
s.Require().NoError(err)
|
||||
|
||||
s.accountName = "accountName"
|
||||
// setting up random account
|
||||
s.createAccountWithBalance(s.accountName)
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TearDownSuite() {
|
||||
s.T().Log("tearing down integration test suite")
|
||||
s.network.Cleanup()
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestGetCmdQueryParams() {
|
||||
val := s.network.Validators[0]
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
outputType string
|
||||
}{
|
||||
{
|
||||
"json output",
|
||||
[]string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
"json",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
cmd := cli.GetQueryParamsCmd()
|
||||
clientCtx := val.ClientCtx
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
|
||||
s.Require().NoError(err)
|
||||
var response types.QueryParamsResponse
|
||||
err = clientCtx.Codec.UnmarshalJSON(out.Bytes(), &response)
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(response.Params.MaxBondAmount, types.DefaultParams().MaxBondAmount)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) createAccountWithBalance(accountName string) {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
consPrivKey := ed25519.GenPrivKey()
|
||||
consPubKeyBz, err := s.cfg.Codec.MarshalInterfaceJSON(consPrivKey.PubKey())
|
||||
sr.NoError(err)
|
||||
sr.NotNil(consPubKeyBz)
|
||||
info, _, err := val.ClientCtx.Keyring.NewMnemonic(accountName, keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1)
|
||||
sr.NoError(err)
|
||||
|
||||
newAddr := sdk.AccAddress(info.GetPubKey().Address())
|
||||
_, err = banktestutil.MsgSendExec(
|
||||
val.ClientCtx,
|
||||
val.Address,
|
||||
newAddr,
|
||||
sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(200))),
|
||||
fmt.Sprintf("--%s", flags.FlagSkipConfirmation),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||
)
|
||||
sr.NoError(err)
|
||||
s.accountAddress = newAddr.String()
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) createBond() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
createBondCmd := cli.NewCreateBondCmd()
|
||||
args := []string{
|
||||
fmt.Sprintf("10%s", s.cfg.BondDenom),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, s.accountName),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, fmt.Sprintf("3%s", s.cfg.BondDenom)),
|
||||
}
|
||||
out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, createBondCmd, args)
|
||||
sr.NoError(err)
|
||||
var d sdk.TxResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &d)
|
||||
sr.NoError(err)
|
||||
sr.Zero(d.Code)
|
||||
err = s.network.WaitForNextBlock()
|
||||
sr.NoError(err)
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestGetQueryBondLists() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
createBond bool
|
||||
preRun func()
|
||||
}{
|
||||
{
|
||||
"create and get bond lists",
|
||||
[]string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
true,
|
||||
func() {
|
||||
s.createBond()
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||
clientCtx := val.ClientCtx
|
||||
if tc.createBond {
|
||||
tc.preRun()
|
||||
}
|
||||
|
||||
cmd := cli.GetQueryBondLists()
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
|
||||
sr.NoError(err)
|
||||
var queryResponse types.QueryGetBondsResponse
|
||||
err = clientCtx.Codec.UnmarshalJSON(out.Bytes(), &queryResponse)
|
||||
sr.NoError(err)
|
||||
sr.NotZero(len(queryResponse.GetBonds()))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestGetQueryBondById() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
err bool
|
||||
preRun func() string
|
||||
}{
|
||||
{
|
||||
"invalid bond id",
|
||||
[]string{
|
||||
fmt.Sprint("not_found_bond_id"),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
},
|
||||
true,
|
||||
func() string {
|
||||
return ""
|
||||
},
|
||||
},
|
||||
{
|
||||
"create and get bond by id",
|
||||
[]string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
false,
|
||||
func() string {
|
||||
// creating the bond
|
||||
s.createBond()
|
||||
|
||||
// getting the bonds list and returning the bond-id
|
||||
clientCtx := val.ClientCtx
|
||||
cmd := cli.GetQueryBondLists()
|
||||
args := []string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
}
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, args)
|
||||
sr.NoError(err)
|
||||
var queryResponse types.QueryGetBondsResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &queryResponse)
|
||||
sr.NoError(err)
|
||||
|
||||
// extract bond id from bonds list
|
||||
bond := queryResponse.GetBonds()[0]
|
||||
return bond.GetId()
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||
clientCtx := val.ClientCtx
|
||||
if !tc.err {
|
||||
bondId := tc.preRun()
|
||||
tc.args = append([]string{bondId}, tc.args...)
|
||||
}
|
||||
cmd := cli.GetBondByIdCmd()
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
|
||||
sr.NoError(err)
|
||||
var queryResponse types.QueryGetBondByIdResponse
|
||||
err = clientCtx.Codec.UnmarshalJSON(out.Bytes(), &queryResponse)
|
||||
sr.NoError(err)
|
||||
if tc.err {
|
||||
sr.Zero(len(queryResponse.GetBond().GetId()))
|
||||
} else {
|
||||
sr.NotZero(len(queryResponse.GetBond().GetId()))
|
||||
sr.Equal(s.accountAddress, queryResponse.GetBond().GetOwner())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestGetQueryBondListsByOwner() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
err bool
|
||||
preRun func()
|
||||
}{
|
||||
{
|
||||
"invalid owner address",
|
||||
[]string{
|
||||
fmt.Sprint("not_found_bond_id"),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
},
|
||||
true,
|
||||
func() {
|
||||
|
||||
},
|
||||
},
|
||||
{
|
||||
"get bond lists by owner address",
|
||||
[]string{
|
||||
fmt.Sprint(s.accountAddress),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
},
|
||||
false,
|
||||
func() {
|
||||
s.createBond()
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||
clientCtx := val.ClientCtx
|
||||
if !tc.err {
|
||||
tc.preRun()
|
||||
}
|
||||
cmd := cli.GetBondListByOwnerCmd()
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
|
||||
sr.NoError(err)
|
||||
var queryResponse types.QueryGetBondsByOwnerResponse
|
||||
err = clientCtx.Codec.UnmarshalJSON(out.Bytes(), &queryResponse)
|
||||
sr.NoError(err)
|
||||
if tc.err {
|
||||
sr.Zero(len(queryResponse.GetBonds()))
|
||||
} else {
|
||||
sr.NotZero(len(queryResponse.GetBonds()))
|
||||
sr.Equal(s.accountAddress, queryResponse.GetBonds()[0].GetOwner())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestGetQueryBondModuleBalance() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
err bool
|
||||
preRun func()
|
||||
}{
|
||||
{
|
||||
"get bond module balance",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
},
|
||||
false,
|
||||
func() {
|
||||
s.createBond()
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||
clientCtx := val.ClientCtx
|
||||
if !tc.err {
|
||||
tc.preRun()
|
||||
}
|
||||
|
||||
cmd := cli.GetBondModuleBalanceCmd()
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
|
||||
sr.NoError(err)
|
||||
var queryResponse types.QueryGetBondModuleBalanceResponse
|
||||
err = clientCtx.Codec.UnmarshalJSON(out.Bytes(), &queryResponse)
|
||||
sr.NoError(err)
|
||||
sr.False(queryResponse.GetBalance().IsZero())
|
||||
})
|
||||
}
|
||||
}
|
317
x/bond/client/testutil/tx.go
Normal file
317
x/bond/client/testutil/tx.go
Normal file
@ -0,0 +1,317 @@
|
||||
package testutil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
"github.com/tharsis/ethermint/x/bond/client/cli"
|
||||
"github.com/tharsis/ethermint/x/bond/types"
|
||||
)
|
||||
|
||||
func (s *IntegrationTestSuite) TestTxCreateBond() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
err bool
|
||||
}{
|
||||
{
|
||||
"without deposit",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, s.accountName),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, fmt.Sprintf("3%s", s.cfg.BondDenom)),
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"create bond",
|
||||
[]string{
|
||||
fmt.Sprintf("10%s", s.cfg.BondDenom),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, s.accountName),
|
||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, fmt.Sprintf("3%s", s.cfg.BondDenom)),
|
||||
},
|
||||
false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||
clientCtx := val.ClientCtx
|
||||
cmd := cli.NewCreateBondCmd()
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
|
||||
if tc.err {
|
||||
sr.Error(err)
|
||||
} else {
|
||||
sr.NoError(err)
|
||||
var d sdk.TxResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &d)
|
||||
sr.Nil(err)
|
||||
sr.NoError(err)
|
||||
sr.Zero(d.Code)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestTxRefillBond() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
getBondId bool
|
||||
err bool
|
||||
}{
|
||||
{
|
||||
"without refill amount and bond id",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, s.accountName),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, fmt.Sprintf("3%s", s.cfg.BondDenom)),
|
||||
},
|
||||
false,
|
||||
true,
|
||||
},
|
||||
{
|
||||
"refill bond",
|
||||
[]string{
|
||||
fmt.Sprintf("10%s", s.cfg.BondDenom),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, s.accountName),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, fmt.Sprintf("3%s", s.cfg.BondDenom)),
|
||||
},
|
||||
true,
|
||||
false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||
clientCtx := val.ClientCtx
|
||||
cmd := cli.RefillBondCmd()
|
||||
if tc.getBondId {
|
||||
cmd := cli.GetQueryBondLists()
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
})
|
||||
sr.NoError(err)
|
||||
var queryResponse types.QueryGetBondsResponse
|
||||
err = clientCtx.Codec.UnmarshalJSON(out.Bytes(), &queryResponse)
|
||||
sr.NoError(err)
|
||||
|
||||
// extract bond id from bonds list
|
||||
bond := queryResponse.GetBonds()[0]
|
||||
tc.args = append([]string{bond.GetId()}, tc.args...)
|
||||
}
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
|
||||
if tc.err {
|
||||
sr.Error(err)
|
||||
} else {
|
||||
sr.NoError(err)
|
||||
var d sdk.TxResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &d)
|
||||
sr.NoError(err)
|
||||
sr.Zero(d.Code)
|
||||
|
||||
// checking the balance of bond
|
||||
cmd := cli.GetBondByIdCmd()
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{
|
||||
fmt.Sprintf(tc.args[0]),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
})
|
||||
sr.NoError(err)
|
||||
var queryResponse types.QueryGetBondByIdResponse
|
||||
err = clientCtx.Codec.UnmarshalJSON(out.Bytes(), &queryResponse)
|
||||
sr.NoError(err)
|
||||
|
||||
sr.True(queryResponse.GetBond().GetBalance().IsEqual(
|
||||
sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(20)))))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestTxWithdrawAmountFromBond() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
getBondId bool
|
||||
err bool
|
||||
}{
|
||||
{
|
||||
"without withdraw amount and bond id",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, s.accountName),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, fmt.Sprintf("3%s", s.cfg.BondDenom)),
|
||||
},
|
||||
false,
|
||||
true,
|
||||
},
|
||||
{
|
||||
"withdraw amount from bond",
|
||||
[]string{
|
||||
fmt.Sprintf("10%s", s.cfg.BondDenom),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, s.accountName),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, fmt.Sprintf("3%s", s.cfg.BondDenom)),
|
||||
},
|
||||
true,
|
||||
false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||
clientCtx := val.ClientCtx
|
||||
cmd := cli.WithdrawBondCmd()
|
||||
if tc.getBondId {
|
||||
cmd := cli.GetQueryBondLists()
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
})
|
||||
sr.NoError(err)
|
||||
var queryResponse types.QueryGetBondsResponse
|
||||
err = clientCtx.Codec.UnmarshalJSON(out.Bytes(), &queryResponse)
|
||||
sr.NoError(err)
|
||||
|
||||
// extract bond id from bonds list
|
||||
bond := queryResponse.GetBonds()[0]
|
||||
tc.args = append([]string{bond.GetId()}, tc.args...)
|
||||
}
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
|
||||
if tc.err {
|
||||
sr.Error(err)
|
||||
} else {
|
||||
sr.NoError(err)
|
||||
var d sdk.TxResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &d)
|
||||
sr.NoError(err)
|
||||
sr.Zero(d.Code)
|
||||
|
||||
// checking the balance of bond
|
||||
cmd := cli.GetBondByIdCmd()
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{
|
||||
fmt.Sprintf(tc.args[0]),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
})
|
||||
sr.NoError(err)
|
||||
var queryResponse types.QueryGetBondByIdResponse
|
||||
err = clientCtx.Codec.UnmarshalJSON(out.Bytes(), &queryResponse)
|
||||
sr.NoError(err)
|
||||
|
||||
sr.True(queryResponse.GetBond().GetBalance().IsEqual(
|
||||
sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)))))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestTxCancelBond() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
getBondId bool
|
||||
err bool
|
||||
}{
|
||||
{
|
||||
"without bond id",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, s.accountName),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, fmt.Sprintf("3%s", s.cfg.BondDenom)),
|
||||
},
|
||||
false,
|
||||
true,
|
||||
},
|
||||
{
|
||||
"cancel bond",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, s.accountName),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, fmt.Sprintf("3%s", s.cfg.BondDenom)),
|
||||
},
|
||||
true,
|
||||
false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||
clientCtx := val.ClientCtx
|
||||
cmd := cli.CancelBondCmd()
|
||||
if tc.getBondId {
|
||||
cmd := cli.GetQueryBondLists()
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
})
|
||||
sr.NoError(err)
|
||||
var queryResponse types.QueryGetBondsResponse
|
||||
err = clientCtx.Codec.UnmarshalJSON(out.Bytes(), &queryResponse)
|
||||
sr.NoError(err)
|
||||
|
||||
// extract bond id from bonds list
|
||||
bond := queryResponse.GetBonds()[0]
|
||||
tc.args = append([]string{bond.GetId()}, tc.args...)
|
||||
}
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
|
||||
if tc.err {
|
||||
sr.Error(err)
|
||||
} else {
|
||||
sr.NoError(err)
|
||||
var d sdk.TxResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &d)
|
||||
sr.NoError(err)
|
||||
sr.Zero(d.Code)
|
||||
|
||||
// checking the bond exists or not after cancel
|
||||
cmd := cli.GetBondByIdCmd()
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{
|
||||
fmt.Sprintf(tc.args[0]),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
})
|
||||
sr.NoError(err)
|
||||
var queryResponse types.QueryGetBondByIdResponse
|
||||
err = clientCtx.Codec.UnmarshalJSON(out.Bytes(), &queryResponse)
|
||||
sr.NoError(err)
|
||||
|
||||
sr.Zero(queryResponse.GetBond().GetId())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
40
x/bond/genesis.go
Normal file
40
x/bond/genesis.go
Normal file
@ -0,0 +1,40 @@
|
||||
package bond
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tharsis/ethermint/x/bond/keeper"
|
||||
"github.com/tharsis/ethermint/x/bond/types"
|
||||
)
|
||||
|
||||
// InitGenesis initializes genesis state based on exported genesis
|
||||
func InitGenesis(
|
||||
ctx sdk.Context,
|
||||
k keeper.Keeper, data types.GenesisState) []abci.ValidatorUpdate {
|
||||
|
||||
k.SetParams(ctx, data.Params)
|
||||
|
||||
for _, bond := range data.Bonds {
|
||||
k.SaveBond(ctx, bond)
|
||||
}
|
||||
|
||||
return []abci.ValidatorUpdate{}
|
||||
}
|
||||
|
||||
// ExportGenesis - output genesis parameters
|
||||
func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) types.GenesisState {
|
||||
params := keeper.GetParams(ctx)
|
||||
bonds := keeper.ListBonds(ctx)
|
||||
|
||||
return types.GenesisState{Params: params, Bonds: bonds}
|
||||
}
|
||||
|
||||
// ValidateGenesis - validating the genesis data
|
||||
func ValidateGenesis(data types.GenesisState) error {
|
||||
err := data.Params.Validate()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
53
x/bond/keeper/grpc_query.go
Normal file
53
x/bond/keeper/grpc_query.go
Normal file
@ -0,0 +1,53 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/tharsis/ethermint/x/bond/types"
|
||||
)
|
||||
|
||||
type Querier struct {
|
||||
Keeper
|
||||
}
|
||||
|
||||
var _ types.QueryServer = Querier{}
|
||||
|
||||
func (q Querier) Bonds(c context.Context, _ *types.QueryGetBondsRequest) (*types.QueryGetBondsResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
resp := q.Keeper.ListBonds(ctx)
|
||||
return &types.QueryGetBondsResponse{Bonds: resp}, nil
|
||||
}
|
||||
|
||||
func (q Querier) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
params := q.Keeper.GetParams(ctx)
|
||||
return &types.QueryParamsResponse{Params: ¶ms}, nil
|
||||
}
|
||||
|
||||
func (q Querier) GetBondById(c context.Context, req *types.QueryGetBondByIdRequest) (*types.QueryGetBondByIdResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
bondId := req.GetId()
|
||||
if len(bondId) == 0 {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "bond id required")
|
||||
}
|
||||
bond := q.Keeper.GetBond(ctx, req.GetId())
|
||||
return &types.QueryGetBondByIdResponse{Bond: &bond}, nil
|
||||
}
|
||||
|
||||
func (q Querier) GetBondsByOwner(c context.Context, req *types.QueryGetBondsByOwnerRequest) (*types.QueryGetBondsByOwnerResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
owner := req.GetOwner()
|
||||
if len(owner) == 0 {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "owner id required")
|
||||
}
|
||||
bonds := q.Keeper.QueryBondsByOwner(ctx, owner)
|
||||
return &types.QueryGetBondsByOwnerResponse{Bonds: bonds}, nil
|
||||
}
|
||||
|
||||
func (q Querier) GetBondsModuleBalance(c context.Context, _ *types.QueryGetBondModuleBalanceRequest) (*types.QueryGetBondModuleBalanceResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
balance := q.Keeper.GetBondModuleBalances(ctx)
|
||||
return &types.QueryGetBondModuleBalanceResponse{Balance: balance}, nil
|
||||
}
|
221
x/bond/keeper/grpc_query_test.go
Normal file
221
x/bond/keeper/grpc_query_test.go
Normal file
@ -0,0 +1,221 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/tharsis/ethermint/app"
|
||||
"github.com/tharsis/ethermint/x/bond/types"
|
||||
)
|
||||
|
||||
func (suite *KeeperTestSuite) TestGrpcQueryBondsList() {
|
||||
grpcClient, ctx, k := suite.queryClient, suite.ctx, suite.app.BondKeeper
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
req *types.QueryGetBondsRequest
|
||||
resp *types.QueryGetBondsResponse
|
||||
noOfBonds int
|
||||
createBonds bool
|
||||
}{
|
||||
{
|
||||
"empty request",
|
||||
&types.QueryGetBondsRequest{},
|
||||
&types.QueryGetBondsResponse{},
|
||||
0,
|
||||
false,
|
||||
},
|
||||
{
|
||||
"Get Bonds",
|
||||
&types.QueryGetBondsRequest{},
|
||||
&types.QueryGetBondsResponse{},
|
||||
1,
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s ", test.msg), func() {
|
||||
if test.createBonds {
|
||||
account := app.CreateRandomAccounts(1)[0]
|
||||
err := simapp.FundAccount(suite.app.BankKeeper, ctx, account, sdk.NewCoins(sdk.Coin{
|
||||
Denom: sdk.DefaultBondDenom,
|
||||
Amount: sdk.NewInt(1000),
|
||||
}))
|
||||
_, err = k.CreateBond(ctx, account, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))))
|
||||
suite.Require().NoError(err)
|
||||
}
|
||||
resp, _ := grpcClient.Bonds(context.Background(), test.req)
|
||||
suite.Require().Equal(test.noOfBonds, len(resp.GetBonds()))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestGrpcQueryParams() {
|
||||
grpcClient := suite.queryClient
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
req *types.QueryParamsRequest
|
||||
}{
|
||||
{
|
||||
"Get Params",
|
||||
&types.QueryParamsRequest{},
|
||||
},
|
||||
}
|
||||
for _, test := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s ", test.msg), func() {
|
||||
resp, _ := grpcClient.Params(context.Background(), test.req)
|
||||
suite.Require().Equal(resp.GetParams().MaxBondAmount, types.DefaultParams().MaxBondAmount)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestGrpcQueryBondBondId() {
|
||||
grpcClient, ctx, k, suiteRequire := suite.queryClient, suite.ctx, suite.app.BondKeeper, suite.Require()
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
req *types.QueryGetBondByIdRequest
|
||||
createBonds bool
|
||||
errResponse bool
|
||||
bondId string
|
||||
}{
|
||||
{
|
||||
"empty request",
|
||||
&types.QueryGetBondByIdRequest{},
|
||||
false,
|
||||
true,
|
||||
"",
|
||||
},
|
||||
{
|
||||
"Get Bond By ID",
|
||||
&types.QueryGetBondByIdRequest{},
|
||||
true,
|
||||
false,
|
||||
"",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s ", test.msg), func() {
|
||||
if test.createBonds {
|
||||
account := app.CreateRandomAccounts(1)[0]
|
||||
err := simapp.FundAccount(suite.app.BankKeeper, ctx, account, sdk.NewCoins(sdk.Coin{
|
||||
Denom: sdk.DefaultBondDenom,
|
||||
Amount: sdk.NewInt(1000),
|
||||
}))
|
||||
bond, err := k.CreateBond(ctx, account, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))))
|
||||
suiteRequire.NoError(err)
|
||||
test.req.Id = bond.Id
|
||||
}
|
||||
resp, err := grpcClient.GetBondById(context.Background(), test.req)
|
||||
if !test.errResponse {
|
||||
suiteRequire.Nil(err)
|
||||
suiteRequire.NotNil(resp.GetBond())
|
||||
suiteRequire.Equal(test.req.Id, resp.GetBond().GetId())
|
||||
} else {
|
||||
suiteRequire.NotNil(err)
|
||||
suiteRequire.Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestGrpcGetBondsByOwner() {
|
||||
grpcClient, ctx, k, suiteRequire := suite.queryClient, suite.ctx, suite.app.BondKeeper, suite.Require()
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
req *types.QueryGetBondsByOwnerRequest
|
||||
noOfBonds int
|
||||
createBonds bool
|
||||
errResponse bool
|
||||
bondId string
|
||||
}{
|
||||
{
|
||||
"empty request",
|
||||
&types.QueryGetBondsByOwnerRequest{},
|
||||
0,
|
||||
false,
|
||||
true,
|
||||
"",
|
||||
},
|
||||
{
|
||||
"Get Bond By Owner",
|
||||
&types.QueryGetBondsByOwnerRequest{},
|
||||
1,
|
||||
true,
|
||||
false,
|
||||
"",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s ", test.msg), func() {
|
||||
if test.createBonds {
|
||||
account := app.CreateRandomAccounts(1)[0]
|
||||
_ = simapp.FundAccount(suite.app.BankKeeper, ctx, account, sdk.NewCoins(sdk.Coin{
|
||||
Denom: sdk.DefaultBondDenom,
|
||||
Amount: sdk.NewInt(1000),
|
||||
}))
|
||||
_, err := k.CreateBond(ctx, account, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))))
|
||||
suiteRequire.NoError(err)
|
||||
test.req.Owner = account.String()
|
||||
}
|
||||
resp, err := grpcClient.GetBondsByOwner(context.Background(), test.req)
|
||||
if !test.errResponse {
|
||||
suiteRequire.Nil(err)
|
||||
suiteRequire.NotNil(resp.GetBonds())
|
||||
suiteRequire.Equal(test.noOfBonds, len(resp.GetBonds()))
|
||||
} else {
|
||||
suiteRequire.NotNil(err)
|
||||
suiteRequire.Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestGrpcGetModuleBalance() {
|
||||
grpcClient, ctx, k, suiteRequire := suite.queryClient, suite.ctx, suite.app.BondKeeper, suite.Require()
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
req *types.QueryGetBondModuleBalanceRequest
|
||||
noOfBonds int
|
||||
createBonds bool
|
||||
errResponse bool
|
||||
}{
|
||||
{
|
||||
"empty request",
|
||||
&types.QueryGetBondModuleBalanceRequest{},
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s ", test.msg), func() {
|
||||
if test.createBonds {
|
||||
account := app.CreateRandomAccounts(1)[0]
|
||||
_ = simapp.FundAccount(suite.app.BankKeeper, ctx, account, sdk.NewCoins(sdk.Coin{
|
||||
Denom: sdk.DefaultBondDenom,
|
||||
Amount: sdk.NewInt(1000),
|
||||
}))
|
||||
_, err := k.CreateBond(ctx, account, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))))
|
||||
suiteRequire.NoError(err)
|
||||
}
|
||||
resp, err := grpcClient.GetBondsModuleBalance(context.Background(), test.req)
|
||||
if !test.errResponse {
|
||||
suiteRequire.Nil(err)
|
||||
suiteRequire.NotNil(resp.GetBalance())
|
||||
suiteRequire.Equal(resp.GetBalance(), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))))
|
||||
} else {
|
||||
suiteRequire.NotNil(err)
|
||||
suiteRequire.Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
37
x/bond/keeper/invariants.go
Normal file
37
x/bond/keeper/invariants.go
Normal file
@ -0,0 +1,37 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/tharsis/ethermint/x/bond/types"
|
||||
)
|
||||
|
||||
// RegisterInvariants registers all bond invariants
|
||||
func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper) {
|
||||
ir.RegisterRoute(types.ModuleName, "module-account", ModuleAccountInvariant(k))
|
||||
}
|
||||
|
||||
// ModuleAccountInvariant checks that the 'bond' module account balance is non-negative.
|
||||
func ModuleAccountInvariant(k Keeper) sdk.Invariant {
|
||||
return func(ctx sdk.Context) (string, bool) {
|
||||
moduleAddress := k.accountKeeper.GetModuleAddress(types.ModuleName)
|
||||
balances := k.bankKeeper.GetAllBalances(ctx, moduleAddress)
|
||||
for _, balance := range balances {
|
||||
if balance.IsNegative() {
|
||||
return sdk.FormatInvariant(
|
||||
types.ModuleName,
|
||||
"module-account",
|
||||
fmt.Sprintf("Module account '%s' has negative balance.", types.ModuleName)),
|
||||
true
|
||||
}
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
}
|
||||
|
||||
// AllInvariants runs all invariants of the bonds module.
|
||||
func AllInvariants(k Keeper) sdk.Invariant {
|
||||
return func(ctx sdk.Context) (string, bool) {
|
||||
return ModuleAccountInvariant(k)(ctx)
|
||||
}
|
||||
}
|
355
x/bond/keeper/keeper.go
Normal file
355
x/bond/keeper/keeper.go
Normal file
@ -0,0 +1,355 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
"github.com/tharsis/ethermint/x/bond/types"
|
||||
)
|
||||
|
||||
// prefixIDToBondIndex is the prefix for ID -> Bond index in the KVStore.
|
||||
// Note: This is the primary index in the system.
|
||||
// Note: Golang doesn't support const arrays.
|
||||
var prefixIDToBondIndex = []byte{0x00}
|
||||
|
||||
// prefixOwnerToBondsIndex is the prefix for the Owner -> [Bond] index in the KVStore.
|
||||
var prefixOwnerToBondsIndex = []byte{0x01}
|
||||
|
||||
// Keeper maintains the link to storage and exposes getter/setter methods for the various parts of the state machine
|
||||
type Keeper struct {
|
||||
accountKeeper auth.AccountKeeper
|
||||
bankKeeper bank.Keeper
|
||||
|
||||
// Track bond usage in other cosmos-sdk modules (more like a usage tracker).
|
||||
usageKeepers []types.BondUsageKeeper
|
||||
|
||||
storeKey sdk.StoreKey
|
||||
|
||||
cdc codec.BinaryCodec
|
||||
|
||||
paramSubspace paramtypes.Subspace
|
||||
}
|
||||
|
||||
// NewKeeper creates new instances of the bond Keeper
|
||||
func NewKeeper(cdc codec.BinaryCodec, accountKeeper auth.AccountKeeper, bankKeeper bank.Keeper, usageKeepers []types.BondUsageKeeper, storeKey sdk.StoreKey, ps paramtypes.Subspace) Keeper {
|
||||
// set KeyTable if it has not already been set
|
||||
if !ps.HasKeyTable() {
|
||||
ps = ps.WithKeyTable(types.ParamKeyTable())
|
||||
}
|
||||
|
||||
return Keeper{
|
||||
accountKeeper: accountKeeper,
|
||||
bankKeeper: bankKeeper,
|
||||
storeKey: storeKey,
|
||||
cdc: cdc,
|
||||
usageKeepers: usageKeepers,
|
||||
paramSubspace: ps,
|
||||
}
|
||||
}
|
||||
|
||||
// Generates Bond ID -> Bond index key.
|
||||
func getBondIndexKey(id string) []byte {
|
||||
return append(prefixIDToBondIndex, []byte(id)...)
|
||||
}
|
||||
|
||||
// Generates Owner -> Bonds index key.
|
||||
func getOwnerToBondsIndexKey(owner string, bondID string) []byte {
|
||||
return append(append(prefixOwnerToBondsIndex, []byte(owner)...), []byte(bondID)...)
|
||||
}
|
||||
|
||||
// BondID simplifies generation of bond IDs.
|
||||
type BondID struct {
|
||||
Address sdk.Address
|
||||
AccNum uint64
|
||||
Sequence uint64
|
||||
}
|
||||
|
||||
// Generate creates the bond ID.
|
||||
func (bondID BondID) Generate() string {
|
||||
hasher := sha256.New()
|
||||
str := fmt.Sprintf("%s:%d:%d", bondID.Address.String(), bondID.AccNum, bondID.Sequence)
|
||||
hasher.Write([]byte(str))
|
||||
return hex.EncodeToString(hasher.Sum(nil))
|
||||
}
|
||||
|
||||
// MatchBonds - get all matching bonds.
|
||||
func (k Keeper) MatchBonds(ctx sdk.Context, matchFn func(*types.Bond) bool) []*types.Bond {
|
||||
var bonds []*types.Bond
|
||||
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
itr := sdk.KVStorePrefixIterator(store, prefixIDToBondIndex)
|
||||
defer itr.Close()
|
||||
for ; itr.Valid(); itr.Next() {
|
||||
bz := store.Get(itr.Key())
|
||||
if bz != nil {
|
||||
var obj types.Bond
|
||||
k.cdc.MustUnmarshal(bz, &obj)
|
||||
if matchFn(&obj) {
|
||||
bonds = append(bonds, &obj)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bonds
|
||||
}
|
||||
|
||||
// CreateBond creates a new bond.
|
||||
func (k Keeper) CreateBond(ctx sdk.Context, ownerAddress sdk.AccAddress, coins sdk.Coins) (*types.Bond, error) {
|
||||
// Check if account has funds.
|
||||
for _, coin := range coins {
|
||||
balance := k.bankKeeper.HasBalance(ctx, ownerAddress, coin)
|
||||
if !balance {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInsufficientFunds, "failed to create bond; Insufficient funds")
|
||||
}
|
||||
}
|
||||
|
||||
// Generate bond ID.
|
||||
account := k.accountKeeper.GetAccount(ctx, ownerAddress)
|
||||
bondID := BondID{
|
||||
Address: ownerAddress,
|
||||
AccNum: account.GetAccountNumber(),
|
||||
Sequence: account.GetSequence(),
|
||||
}.Generate()
|
||||
|
||||
maxBondAmount, err := k.getMaxBondAmount(ctx)
|
||||
if err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid max bond amount.")
|
||||
}
|
||||
|
||||
bond := types.Bond{Id: bondID, Owner: ownerAddress.String(), Balance: coins}
|
||||
if bond.Balance.IsAnyGT(maxBondAmount) {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Max bond amount exceeded.")
|
||||
}
|
||||
|
||||
// Move funds into the bond account module.
|
||||
err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, ownerAddress, types.ModuleName, bond.Balance)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Save bond in store.
|
||||
k.SaveBond(ctx, &bond)
|
||||
|
||||
return &bond, nil
|
||||
}
|
||||
|
||||
// SaveBond - saves a bond to the store.
|
||||
func (k Keeper) SaveBond(ctx sdk.Context, bond *types.Bond) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
|
||||
// Bond ID -> Bond index.
|
||||
store.Set(getBondIndexKey(bond.Id), k.cdc.MustMarshal(bond))
|
||||
|
||||
// Owner -> [Bond] index.
|
||||
store.Set(getOwnerToBondsIndexKey(bond.Owner, bond.Id), []byte{})
|
||||
}
|
||||
|
||||
// HasBond - checks if a bond by the given ID exists.
|
||||
func (k Keeper) HasBond(ctx sdk.Context, id string) bool {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
return store.Has(getBondIndexKey(id))
|
||||
}
|
||||
|
||||
// GetBond - gets a record from the store.
|
||||
func (k Keeper) GetBond(ctx sdk.Context, id string) types.Bond {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
|
||||
bz := store.Get(getBondIndexKey(id))
|
||||
var obj types.Bond
|
||||
k.cdc.MustUnmarshal(bz, &obj)
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
// DeleteBond - deletes the bond.
|
||||
func (k Keeper) DeleteBond(ctx sdk.Context, bond types.Bond) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
store.Delete(getBondIndexKey(bond.Id))
|
||||
store.Delete(getOwnerToBondsIndexKey(bond.Owner, bond.Id))
|
||||
}
|
||||
|
||||
// ListBonds - get all bonds.
|
||||
func (k Keeper) ListBonds(ctx sdk.Context) []*types.Bond {
|
||||
var bonds []*types.Bond
|
||||
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
itr := sdk.KVStorePrefixIterator(store, prefixIDToBondIndex)
|
||||
defer itr.Close()
|
||||
for ; itr.Valid(); itr.Next() {
|
||||
bz := store.Get(itr.Key())
|
||||
if bz != nil {
|
||||
var obj types.Bond
|
||||
k.cdc.MustUnmarshal(bz, &obj)
|
||||
bonds = append(bonds, &obj)
|
||||
}
|
||||
}
|
||||
return bonds
|
||||
}
|
||||
|
||||
// QueryBondsByOwner - query bonds by owner.
|
||||
func (k Keeper) QueryBondsByOwner(ctx sdk.Context, ownerAddress string) []types.Bond {
|
||||
var bonds []types.Bond
|
||||
|
||||
ownerPrefix := append(prefixOwnerToBondsIndex, []byte(ownerAddress)...)
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
itr := sdk.KVStorePrefixIterator(store, ownerPrefix)
|
||||
defer itr.Close()
|
||||
for ; itr.Valid(); itr.Next() {
|
||||
bondID := itr.Key()[len(ownerPrefix):]
|
||||
bz := store.Get(append(prefixIDToBondIndex, bondID...))
|
||||
if bz != nil {
|
||||
var obj types.Bond
|
||||
k.cdc.MustUnmarshal(bz, &obj)
|
||||
bonds = append(bonds, obj)
|
||||
}
|
||||
}
|
||||
|
||||
return bonds
|
||||
}
|
||||
|
||||
// RefillBond refills an existing bond.
|
||||
func (k Keeper) RefillBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddress, coins sdk.Coins) (*types.Bond, error) {
|
||||
if !k.HasBond(ctx, id) {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found.")
|
||||
}
|
||||
|
||||
bond := k.GetBond(ctx, id)
|
||||
if bond.Owner != ownerAddress.String() {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.")
|
||||
}
|
||||
|
||||
// Check if account has funds.
|
||||
for _, coin := range coins {
|
||||
if !k.bankKeeper.HasBalance(ctx, ownerAddress, coin) {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInsufficientFunds, "Insufficient funds.")
|
||||
}
|
||||
}
|
||||
|
||||
maxBondAmount, err := k.getMaxBondAmount(ctx)
|
||||
if err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid max bond amount.")
|
||||
}
|
||||
|
||||
updatedBalance := bond.Balance.Add(coins...)
|
||||
if updatedBalance.IsAnyGT(maxBondAmount) {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Max bond amount exceeded.")
|
||||
}
|
||||
|
||||
// Move funds into the bond account module.
|
||||
err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, ownerAddress, types.ModuleName, coins)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Update bond balance and save.
|
||||
bond.Balance = updatedBalance
|
||||
k.SaveBond(ctx, &bond)
|
||||
|
||||
return &bond, nil
|
||||
}
|
||||
|
||||
// WithdrawBond withdraws funds from a bond.
|
||||
func (k Keeper) WithdrawBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddress, coins sdk.Coins) (*types.Bond, error) {
|
||||
if !k.HasBond(ctx, id) {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found.")
|
||||
}
|
||||
|
||||
bond := k.GetBond(ctx, id)
|
||||
if bond.Owner != ownerAddress.String() {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.")
|
||||
}
|
||||
|
||||
updatedBalance, isNeg := bond.Balance.SafeSub(coins)
|
||||
if isNeg {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInsufficientFunds, "Insufficient bond balance.")
|
||||
}
|
||||
|
||||
// Move funds from the bond into the account.
|
||||
err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, ownerAddress, coins)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Update bond balance and save.
|
||||
bond.Balance = updatedBalance
|
||||
k.SaveBond(ctx, &bond)
|
||||
|
||||
return &bond, nil
|
||||
}
|
||||
|
||||
// CancelBond cancels a bond, returning funds to the owner.
|
||||
func (k Keeper) CancelBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddress) (*types.Bond, error) {
|
||||
if !k.HasBond(ctx, id) {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found.")
|
||||
}
|
||||
|
||||
bond := k.GetBond(ctx, id)
|
||||
if bond.Owner != ownerAddress.String() {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.")
|
||||
}
|
||||
|
||||
// Check if bond is used in other modules.
|
||||
for _, usageKeeper := range k.usageKeepers {
|
||||
if usageKeeper.UsesBond(ctx, id) {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, fmt.Sprintf("Bond in use by the '%s' module.", usageKeeper.ModuleName()))
|
||||
}
|
||||
}
|
||||
|
||||
// Move funds from the bond into the account.
|
||||
err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, ownerAddress, bond.Balance)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
k.DeleteBond(ctx, bond)
|
||||
|
||||
return &bond, nil
|
||||
}
|
||||
|
||||
func (k Keeper) getMaxBondAmount(ctx sdk.Context) (sdk.Coins, error) {
|
||||
params := k.GetParams(ctx)
|
||||
maxBondAmount := params.MaxBondAmount
|
||||
return sdk.NewCoins(maxBondAmount), nil
|
||||
}
|
||||
|
||||
// GetBondModuleBalances gets the bond module account(s) balances.
|
||||
func (k Keeper) GetBondModuleBalances(ctx sdk.Context) sdk.Coins {
|
||||
moduleAddress := k.accountKeeper.GetModuleAddress(types.ModuleName)
|
||||
balances := k.bankKeeper.GetAllBalances(ctx, moduleAddress)
|
||||
return balances
|
||||
}
|
||||
|
||||
// TransferCoinsToModuleAccount moves funds from the bonds module account to another module account.
|
||||
func (k Keeper) TransferCoinsToModuleAccount(ctx sdk.Context, id, moduleAccount string, coins sdk.Coins) error {
|
||||
if !k.HasBond(ctx, id) {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Bond not found.")
|
||||
}
|
||||
|
||||
bondObj := k.GetBond(ctx, id)
|
||||
|
||||
// Deduct rent from bond.
|
||||
updatedBalance, isNeg := bondObj.Balance.SafeSub(coins)
|
||||
|
||||
if isNeg {
|
||||
// Check if bond has sufficient funds.
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInsufficientFunds, "Insufficient funds.")
|
||||
}
|
||||
|
||||
// Move funds from bond module to record rent module.
|
||||
err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, moduleAccount, coins)
|
||||
if err != nil {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Error transferring funds.")
|
||||
}
|
||||
|
||||
// Update bond balance.
|
||||
bondObj.Balance = updatedBalance
|
||||
k.SaveBond(ctx, &bondObj)
|
||||
|
||||
return nil
|
||||
}
|
52
x/bond/keeper/keeper_test.go
Normal file
52
x/bond/keeper/keeper_test.go
Normal file
@ -0,0 +1,52 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
"github.com/tharsis/ethermint/app"
|
||||
bondkeeper "github.com/tharsis/ethermint/x/bond/keeper"
|
||||
"github.com/tharsis/ethermint/x/bond/types"
|
||||
)
|
||||
|
||||
type KeeperTestSuite struct {
|
||||
suite.Suite
|
||||
app *app.EthermintApp
|
||||
ctx sdk.Context
|
||||
queryClient types.QueryClient
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) SetupTest() {
|
||||
testApp := app.Setup(false, func(ea *app.EthermintApp, genesis simapp.GenesisState) simapp.GenesisState {
|
||||
return genesis
|
||||
})
|
||||
ctx := testApp.BaseApp.NewContext(false, tmproto.Header{})
|
||||
|
||||
querier := bondkeeper.Querier{Keeper: testApp.BondKeeper}
|
||||
|
||||
queryHelper := baseapp.NewQueryServerTestHelper(ctx, testApp.InterfaceRegistry())
|
||||
types.RegisterQueryServer(queryHelper, querier)
|
||||
queryClient := types.NewQueryClient(queryHelper)
|
||||
|
||||
suite.app, suite.ctx, suite.queryClient = testApp, ctx, queryClient
|
||||
}
|
||||
|
||||
func TestParams(t *testing.T) {
|
||||
testApp := app.Setup(false, func(ea *app.EthermintApp, genesis simapp.GenesisState) simapp.GenesisState {
|
||||
return genesis
|
||||
})
|
||||
ctx := testApp.BaseApp.NewContext(false, tmproto.Header{})
|
||||
|
||||
expParams := types.DefaultParams()
|
||||
params := testApp.BondKeeper.GetParams(ctx)
|
||||
require.Equal(t, expParams.MaxBondAmount, params.MaxBondAmount)
|
||||
}
|
||||
|
||||
func TestKeeperTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(KeeperTestSuite))
|
||||
}
|
130
x/bond/keeper/msg_server.go
Normal file
130
x/bond/keeper/msg_server.go
Normal file
@ -0,0 +1,130 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/tharsis/ethermint/x/bond/types"
|
||||
)
|
||||
|
||||
type msgServer struct {
|
||||
Keeper
|
||||
}
|
||||
|
||||
// NewMsgServerImpl returns an implementation of the bond MsgServer interface for the provided Keeper.
|
||||
func NewMsgServerImpl(keeper Keeper) types.MsgServer {
|
||||
return &msgServer{Keeper: keeper}
|
||||
}
|
||||
|
||||
var _ types.MsgServer = msgServer{}
|
||||
|
||||
func (k msgServer) CreateBond(c context.Context, msg *types.MsgCreateBond) (*types.MsgCreateBondResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err = k.Keeper.CreateBond(ctx, signerAddress, msg.Coins)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvents(sdk.Events{
|
||||
sdk.NewEvent(
|
||||
types.EventTypeCreateBond,
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Coins.String()),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
),
|
||||
})
|
||||
|
||||
return &types.MsgCreateBondResponse{}, nil
|
||||
}
|
||||
|
||||
func (k msgServer) RefillBond(c context.Context, msg *types.MsgRefillBond) (*types.MsgRefillBondResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, err = k.Keeper.RefillBond(ctx, msg.Id, signerAddress, msg.Coins)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvents(sdk.Events{
|
||||
sdk.NewEvent(
|
||||
types.EventTypeRefillBond,
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
sdk.NewAttribute(types.AttributeKeyBondId, msg.Id),
|
||||
sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Coins.String()),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
),
|
||||
})
|
||||
|
||||
return &types.MsgRefillBondResponse{}, nil
|
||||
}
|
||||
|
||||
func (k msgServer) WithdrawBond(c context.Context, msg *types.MsgWithdrawBond) (*types.MsgWithdrawBondResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, err = k.Keeper.WithdrawBond(ctx, msg.Id, signerAddress, msg.Coins)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvents(sdk.Events{
|
||||
sdk.NewEvent(
|
||||
types.EventTypeWithdrawBond,
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
sdk.NewAttribute(types.AttributeKeyBondId, msg.Id),
|
||||
sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Coins.String()),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
),
|
||||
})
|
||||
|
||||
return &types.MsgWithdrawBondResponse{}, nil
|
||||
}
|
||||
|
||||
func (k msgServer) CancelBond(c context.Context, msg *types.MsgCancelBond) (*types.MsgCancelBondResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err = k.Keeper.CancelBond(ctx, msg.Id, signerAddress)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvents(sdk.Events{
|
||||
sdk.NewEvent(
|
||||
types.EventTypeCancelBond,
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
sdk.NewAttribute(types.AttributeKeyBondId, msg.Id),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
),
|
||||
})
|
||||
|
||||
return &types.MsgCancelBondResponse{}, nil
|
||||
}
|
23
x/bond/keeper/params.go
Normal file
23
x/bond/keeper/params.go
Normal file
@ -0,0 +1,23 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/tharsis/ethermint/x/bond/types"
|
||||
)
|
||||
|
||||
// GetMaxBondAmount max bond amount
|
||||
func (k Keeper) GetMaxBondAmount(ctx sdk.Context) (res sdk.Coin) {
|
||||
k.paramSubspace.Get(ctx, types.ParamStoreKeyMaxBondAmount, &res)
|
||||
return
|
||||
}
|
||||
|
||||
// GetParams - Get all parameter as types.Params.
|
||||
func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
|
||||
getMaxBondAmount := k.GetMaxBondAmount(ctx)
|
||||
return types.Params{MaxBondAmount: getMaxBondAmount}
|
||||
}
|
||||
|
||||
// SetParams - set the params.
|
||||
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
|
||||
k.paramSubspace.SetParamSet(ctx, ¶ms)
|
||||
}
|
135
x/bond/module.go
Normal file
135
x/bond/module.go
Normal file
@ -0,0 +1,135 @@
|
||||
package bond
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/spf13/cobra"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tharsis/ethermint/x/bond/client/cli"
|
||||
"github.com/tharsis/ethermint/x/bond/keeper"
|
||||
"github.com/tharsis/ethermint/x/bond/types"
|
||||
)
|
||||
|
||||
var (
|
||||
_ module.AppModule = AppModule{}
|
||||
_ module.AppModuleBasic = AppModuleBasic{}
|
||||
)
|
||||
|
||||
// AppModuleBasic defines the basic application module used by the staking module.
|
||||
type AppModuleBasic struct {
|
||||
cdc codec.Codec
|
||||
}
|
||||
|
||||
func (b AppModuleBasic) RegisterLegacyAminoCodec(amino *codec.LegacyAmino) {
|
||||
types.RegisterLegacyAminoCodec(amino)
|
||||
}
|
||||
|
||||
func (b AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
|
||||
types.RegisterInterfaces(registry)
|
||||
}
|
||||
|
||||
func (b AppModuleBasic) DefaultGenesis(jsonCodec codec.JSONCodec) json.RawMessage {
|
||||
return jsonCodec.MustMarshalJSON(types.DefaultGenesisState())
|
||||
}
|
||||
|
||||
func (b AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, message json.RawMessage) error {
|
||||
var data types.GenesisState
|
||||
if err := cdc.UnmarshalJSON(message, &data); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
|
||||
}
|
||||
|
||||
return ValidateGenesis(data)
|
||||
}
|
||||
|
||||
func (b AppModuleBasic) RegisterRESTRoutes(context client.Context, router *mux.Router) {
|
||||
}
|
||||
|
||||
func (b AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, serveMux *runtime.ServeMux) {
|
||||
err := types.RegisterQueryHandlerClient(context.Background(), serveMux, types.NewQueryClient(clientCtx))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (b AppModuleBasic) GetTxCmd() *cobra.Command {
|
||||
return cli.NewTxCmd()
|
||||
}
|
||||
|
||||
func (b AppModuleBasic) GetQueryCmd() *cobra.Command {
|
||||
return cli.GetQueryCmd()
|
||||
}
|
||||
|
||||
// Name returns the staking module's name.
|
||||
func (AppModuleBasic) Name() string {
|
||||
return types.ModuleName
|
||||
}
|
||||
|
||||
type AppModule struct {
|
||||
AppModuleBasic
|
||||
keeper keeper.Keeper
|
||||
}
|
||||
|
||||
// NewAppModule creates a new AppModule Object
|
||||
func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule {
|
||||
return AppModule{
|
||||
AppModuleBasic: AppModuleBasic{cdc: cdc},
|
||||
keeper: keeper,
|
||||
}
|
||||
}
|
||||
|
||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, message json.RawMessage) []abci.ValidatorUpdate {
|
||||
var genesisState types.GenesisState
|
||||
|
||||
cdc.MustUnmarshalJSON(message, &genesisState)
|
||||
|
||||
return InitGenesis(ctx, am.keeper, genesisState)
|
||||
}
|
||||
|
||||
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
gs := ExportGenesis(ctx, am.keeper)
|
||||
return cdc.MustMarshalJSON(&gs)
|
||||
}
|
||||
|
||||
func (am AppModule) RegisterInvariants(registry sdk.InvariantRegistry) {
|
||||
keeper.RegisterInvariants(registry, am.keeper)
|
||||
}
|
||||
|
||||
func (am AppModule) Route() sdk.Route {
|
||||
return sdk.Route{}
|
||||
}
|
||||
|
||||
func (am AppModule) QuerierRoute() string {
|
||||
return types.QuerierRoute
|
||||
}
|
||||
|
||||
func (am AppModule) LegacyQuerierHandler(amino *codec.LegacyAmino) sdk.Querier {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (am AppModule) RegisterServices(cfg module.Configurator) {
|
||||
querier := keeper.Querier{Keeper: am.keeper}
|
||||
types.RegisterQueryServer(cfg.QueryServer(), querier)
|
||||
|
||||
msgServer := keeper.NewMsgServerImpl(am.keeper)
|
||||
types.RegisterMsgServer(cfg.MsgServer(), msgServer)
|
||||
}
|
||||
|
||||
func (am AppModule) ConsensusVersion() uint64 {
|
||||
return 1
|
||||
}
|
||||
|
||||
func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {
|
||||
BeginBlocker(ctx, am.keeper)
|
||||
}
|
||||
|
||||
func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
|
||||
return EndBlocker(ctx, am.keeper)
|
||||
}
|
27
x/bond/module_test.go
Normal file
27
x/bond/module_test.go
Normal file
@ -0,0 +1,27 @@
|
||||
package bond_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
"github.com/stretchr/testify/require"
|
||||
abcitypes "github.com/tendermint/tendermint/abci/types"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
app "github.com/tharsis/ethermint/app"
|
||||
bondtypes "github.com/tharsis/ethermint/x/bond/types"
|
||||
)
|
||||
|
||||
func TestItCreatesModuleAccountOnInitBlock(t *testing.T) {
|
||||
app := app.Setup(false, func(ea *app.EthermintApp, genesis simapp.GenesisState) simapp.GenesisState {
|
||||
return genesis
|
||||
})
|
||||
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
|
||||
|
||||
app.InitChain(abcitypes.RequestInitChain{
|
||||
AppStateBytes: []byte("{}"),
|
||||
ChainId: "test-chain-id",
|
||||
})
|
||||
|
||||
acc := app.AccountKeeper.GetModuleAccount(ctx, bondtypes.ModuleName)
|
||||
require.NotNil(t, acc)
|
||||
}
|
620
x/bond/types/bond.pb.go
generated
Normal file
620
x/bond/types/bond.pb.go
generated
Normal file
@ -0,0 +1,620 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: vulcanize/bond/v1beta1/bond.proto
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
|
||||
types "github.com/cosmos/cosmos-sdk/types"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
io "io"
|
||||
math "math"
|
||||
math_bits "math/bits"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// Params defines the bond module parameters
|
||||
type Params struct {
|
||||
// max_bond_amount is maximum amount to bond
|
||||
MaxBondAmount types.Coin `protobuf:"bytes,1,opt,name=max_bond_amount,json=maxBondAmount,proto3" json:"max_bond_amount" json:"max_bond_amount" yaml:"max_bond_amount"`
|
||||
}
|
||||
|
||||
func (m *Params) Reset() { *m = Params{} }
|
||||
func (m *Params) String() string { return proto.CompactTextString(m) }
|
||||
func (*Params) ProtoMessage() {}
|
||||
func (*Params) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ff3ef02fadb61511, []int{0}
|
||||
}
|
||||
func (m *Params) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_Params.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *Params) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Params.Merge(m, src)
|
||||
}
|
||||
func (m *Params) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *Params) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Params.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Params proto.InternalMessageInfo
|
||||
|
||||
func (m *Params) GetMaxBondAmount() types.Coin {
|
||||
if m != nil {
|
||||
return m.MaxBondAmount
|
||||
}
|
||||
return types.Coin{}
|
||||
}
|
||||
|
||||
// Bond represents funds deposited by an account for record rent payments.
|
||||
type Bond struct {
|
||||
// id is unique identifier of the bond
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
// owner of the bond
|
||||
Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"`
|
||||
// balance of the bond
|
||||
Balance github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=balance,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"balance" json:"balance" yaml:"balance"`
|
||||
}
|
||||
|
||||
func (m *Bond) Reset() { *m = Bond{} }
|
||||
func (m *Bond) String() string { return proto.CompactTextString(m) }
|
||||
func (*Bond) ProtoMessage() {}
|
||||
func (*Bond) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ff3ef02fadb61511, []int{1}
|
||||
}
|
||||
func (m *Bond) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *Bond) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_Bond.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *Bond) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Bond.Merge(m, src)
|
||||
}
|
||||
func (m *Bond) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *Bond) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Bond.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Bond proto.InternalMessageInfo
|
||||
|
||||
func (m *Bond) GetId() string {
|
||||
if m != nil {
|
||||
return m.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Bond) GetOwner() string {
|
||||
if m != nil {
|
||||
return m.Owner
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Bond) GetBalance() github_com_cosmos_cosmos_sdk_types.Coins {
|
||||
if m != nil {
|
||||
return m.Balance
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Params)(nil), "vulcanize.bond.v1beta1.Params")
|
||||
proto.RegisterType((*Bond)(nil), "vulcanize.bond.v1beta1.Bond")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("vulcanize/bond/v1beta1/bond.proto", fileDescriptor_ff3ef02fadb61511) }
|
||||
|
||||
var fileDescriptor_ff3ef02fadb61511 = []byte{
|
||||
// 344 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0xc1, 0x4e, 0x32, 0x31,
|
||||
0x14, 0x85, 0xa7, 0xf0, 0xff, 0x18, 0xc7, 0xa8, 0xc9, 0x84, 0x18, 0x24, 0xb1, 0x20, 0x2b, 0x5c,
|
||||
0x30, 0x0d, 0x1a, 0x37, 0xee, 0x84, 0x17, 0x50, 0x96, 0x6e, 0x48, 0x67, 0xa6, 0x81, 0x2a, 0xed,
|
||||
0x25, 0xd3, 0x82, 0x83, 0x4b, 0x17, 0xae, 0x7d, 0x0e, 0xf7, 0xbe, 0x03, 0x4b, 0x96, 0xae, 0xd0,
|
||||
0xc0, 0x1b, 0xf8, 0x04, 0x66, 0xda, 0x19, 0x62, 0x34, 0x71, 0xd5, 0x9e, 0xdb, 0x73, 0xbf, 0x7b,
|
||||
0xd2, 0xeb, 0x1e, 0x4f, 0x27, 0xa3, 0x90, 0x4a, 0xfe, 0xc0, 0x48, 0x00, 0x32, 0x22, 0xd3, 0x76,
|
||||
0xc0, 0x34, 0x6d, 0x1b, 0xe1, 0x8f, 0x63, 0xd0, 0xe0, 0x1d, 0x6c, 0x2c, 0xbe, 0xa9, 0x66, 0x96,
|
||||
0x6a, 0x79, 0x00, 0x03, 0x30, 0x16, 0x92, 0xde, 0xac, 0xbb, 0x8a, 0x43, 0x50, 0x02, 0x14, 0x09,
|
||||
0xa8, 0x62, 0x1b, 0x5a, 0x08, 0x5c, 0xda, 0xf7, 0xc6, 0x23, 0x72, 0x4b, 0x57, 0x34, 0xa6, 0x42,
|
||||
0x79, 0x89, 0xbb, 0x2f, 0x68, 0xd2, 0x4f, 0xa1, 0x7d, 0x2a, 0x60, 0x22, 0x75, 0x05, 0xd5, 0x51,
|
||||
0x73, 0xe7, 0xf4, 0xd0, 0xb7, 0x10, 0x3f, 0x85, 0xe4, 0xf3, 0xfc, 0x2e, 0x70, 0xd9, 0x39, 0x9f,
|
||||
0x2f, 0x6b, 0xce, 0xe7, 0xb2, 0xd6, 0xba, 0x55, 0x20, 0x2f, 0x1a, 0x3f, 0xfa, 0x1b, 0xf5, 0x19,
|
||||
0x15, 0xa3, 0xdf, 0xe5, 0xde, 0xae, 0xa0, 0x49, 0x07, 0x64, 0x74, 0x69, 0xf5, 0x2b, 0x72, 0xff,
|
||||
0xa5, 0xd2, 0xdb, 0x73, 0x0b, 0x3c, 0x32, 0x53, 0xb7, 0x7b, 0x05, 0x1e, 0x79, 0x65, 0xf7, 0x3f,
|
||||
0xdc, 0x4b, 0x16, 0x57, 0x0a, 0xa6, 0x64, 0x85, 0xf7, 0x84, 0xdc, 0xad, 0x80, 0x8e, 0xa8, 0x0c,
|
||||
0x59, 0xa5, 0x58, 0x2f, 0xfe, 0x9d, 0xf0, 0x3a, 0x4b, 0x78, 0x64, 0x13, 0x66, 0x7d, 0x79, 0xb2,
|
||||
0x5c, 0xbe, 0xbc, 0xd7, 0x9a, 0x03, 0xae, 0x87, 0x93, 0xc0, 0x0f, 0x41, 0x90, 0xec, 0xd3, 0xec,
|
||||
0xd1, 0x52, 0xd1, 0x1d, 0xd1, 0xb3, 0x31, 0x53, 0x86, 0xa8, 0x7a, 0xf9, 0xf0, 0x4e, 0x77, 0xbe,
|
||||
0xc2, 0x68, 0xb1, 0xc2, 0xe8, 0x63, 0x85, 0xd1, 0xf3, 0x1a, 0x3b, 0x8b, 0x35, 0x76, 0xde, 0xd6,
|
||||
0xd8, 0xb9, 0x39, 0xf9, 0x06, 0xd3, 0x43, 0x1a, 0x2b, 0xae, 0x08, 0xd3, 0x43, 0x16, 0x0b, 0x2e,
|
||||
0x35, 0x49, 0xec, 0x72, 0x0d, 0x33, 0x28, 0x99, 0x45, 0x9c, 0x7d, 0x05, 0x00, 0x00, 0xff, 0xff,
|
||||
0x45, 0xf7, 0x5e, 0x13, 0xfb, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *Params) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *Params) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
{
|
||||
size, err := m.MaxBondAmount.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintBond(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *Bond) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *Bond) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *Bond) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Balance) > 0 {
|
||||
for iNdEx := len(m.Balance) - 1; iNdEx >= 0; iNdEx-- {
|
||||
{
|
||||
size, err := m.Balance[iNdEx].MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintBond(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x1a
|
||||
}
|
||||
}
|
||||
if len(m.Owner) > 0 {
|
||||
i -= len(m.Owner)
|
||||
copy(dAtA[i:], m.Owner)
|
||||
i = encodeVarintBond(dAtA, i, uint64(len(m.Owner)))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
if len(m.Id) > 0 {
|
||||
i -= len(m.Id)
|
||||
copy(dAtA[i:], m.Id)
|
||||
i = encodeVarintBond(dAtA, i, uint64(len(m.Id)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintBond(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovBond(v)
|
||||
base := offset
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
v >>= 7
|
||||
offset++
|
||||
}
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *Params) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = m.MaxBondAmount.Size()
|
||||
n += 1 + l + sovBond(uint64(l))
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *Bond) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.Id)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovBond(uint64(l))
|
||||
}
|
||||
l = len(m.Owner)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovBond(uint64(l))
|
||||
}
|
||||
if len(m.Balance) > 0 {
|
||||
for _, e := range m.Balance {
|
||||
l = e.Size()
|
||||
n += 1 + l + sovBond(uint64(l))
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovBond(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
func sozBond(x uint64) (n int) {
|
||||
return sovBond(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *Params) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowBond
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: Params: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field MaxBondAmount", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowBond
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthBond
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthBond
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if err := m.MaxBondAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipBond(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthBond
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *Bond) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowBond
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: Bond: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: Bond: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowBond
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthBond
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthBond
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Id = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowBond
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthBond
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthBond
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Owner = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 3:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Balance", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowBond
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthBond
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthBond
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Balance = append(m.Balance, types.Coin{})
|
||||
if err := m.Balance[len(m.Balance)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipBond(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthBond
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipBond(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
depth := 0
|
||||
for iNdEx < l {
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowBond
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
wireType := int(wire & 0x7)
|
||||
switch wireType {
|
||||
case 0:
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowBond
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx++
|
||||
if dAtA[iNdEx-1] < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
iNdEx += 8
|
||||
case 2:
|
||||
var length int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowBond
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
length |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if length < 0 {
|
||||
return 0, ErrInvalidLengthBond
|
||||
}
|
||||
iNdEx += length
|
||||
case 3:
|
||||
depth++
|
||||
case 4:
|
||||
if depth == 0 {
|
||||
return 0, ErrUnexpectedEndOfGroupBond
|
||||
}
|
||||
depth--
|
||||
case 5:
|
||||
iNdEx += 4
|
||||
default:
|
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||
}
|
||||
if iNdEx < 0 {
|
||||
return 0, ErrInvalidLengthBond
|
||||
}
|
||||
if depth == 0 {
|
||||
return iNdEx, nil
|
||||
}
|
||||
}
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthBond = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowBond = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupBond = fmt.Errorf("proto: unexpected end of group")
|
||||
)
|
39
x/bond/types/codec.go
Normal file
39
x/bond/types/codec.go
Normal file
@ -0,0 +1,39 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/msgservice"
|
||||
)
|
||||
|
||||
// RegisterLegacyAminoCodec registers the necessary x/bond interfaces and concrete types
|
||||
// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
|
||||
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
|
||||
cdc.RegisterConcrete(&MsgCreateBond{}, "bond/MsgCreateBond", nil)
|
||||
cdc.RegisterConcrete(&MsgRefillBond{}, "bond/MsgRefillBond", nil)
|
||||
cdc.RegisterConcrete(&MsgWithdrawBond{}, "bond/MsgWithdrawBond", nil)
|
||||
cdc.RegisterConcrete(&MsgCancelBond{}, "bond/MsgCancelBond", nil)
|
||||
}
|
||||
|
||||
func RegisterInterfaces(registry types.InterfaceRegistry) {
|
||||
registry.RegisterImplementations((*sdk.Msg)(nil),
|
||||
&MsgCreateBond{},
|
||||
&MsgRefillBond{},
|
||||
&MsgCancelBond{},
|
||||
&MsgWithdrawBond{},
|
||||
)
|
||||
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
|
||||
}
|
||||
|
||||
var (
|
||||
amino = codec.NewLegacyAmino()
|
||||
ModuleCdc = codec.NewAminoCodec(amino)
|
||||
)
|
||||
|
||||
func init() {
|
||||
RegisterLegacyAminoCodec(amino)
|
||||
cryptocodec.RegisterCrypto(amino)
|
||||
amino.Seal()
|
||||
}
|
15
x/bond/types/events.go
Normal file
15
x/bond/types/events.go
Normal file
@ -0,0 +1,15 @@
|
||||
package types
|
||||
|
||||
// bond module event types
|
||||
|
||||
const (
|
||||
EventTypeCreateBond = "crate_bond"
|
||||
EventTypeRefillBond = "refill_bond"
|
||||
EventTypeCancelBond = "cancel_bond"
|
||||
EventTypeWithdrawBond = "withdraw_bond"
|
||||
|
||||
AttributeKeySigner = "signer"
|
||||
AttributeKeyAmount = "amount"
|
||||
AttributeKeyBondId = "bond_id"
|
||||
AttributeValueCategory = ModuleName
|
||||
)
|
12
x/bond/types/expected_keeper.go
Normal file
12
x/bond/types/expected_keeper.go
Normal file
@ -0,0 +1,12 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// BondUsageKeeper keep track of bond usage in other modules.
|
||||
// Used to, for example, prevent deletion of a bond that's in use.
|
||||
type BondUsageKeeper interface {
|
||||
ModuleName() string
|
||||
UsesBond(ctx sdk.Context, bondId string) bool
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user