Migrating the nameservice module from dxns (#2)
* WIP: migrating the nameservice module * WIP: migrating the nameservice module from dxns to ethermint * refactor: move the proto package version from `v1` to `v1beta1` for vulcanize modules * refactor: added bond module dependency to nameserivce module * feat: added auction module dependency to nameservice module * refactor: refactored the nameservice module * refactor: add human-readable attributes output to cli nameservice `list` * fix: fix the sub names authority storing issue * refactor: removed legacyCodec from nameservice * fix: fix the responses for `authority-expiry` and `records-expiry` commands query result * refactor: sort the imports in app * refactor: removed json encoder and decoder
This commit is contained in:
parent
9301487351
commit
95dde36e1c
85
app/app.go
85
app/app.go
|
@ -2,6 +2,7 @@ package app
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
|
@ -98,12 +99,14 @@ import (
|
|||
"github.com/tharsis/ethermint/app/ante"
|
||||
srvflags "github.com/tharsis/ethermint/server/flags"
|
||||
ethermint "github.com/tharsis/ethermint/types"
|
||||
|
||||
"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/evm"
|
||||
evmrest "github.com/tharsis/ethermint/x/evm/client/rest"
|
||||
evmkeeper "github.com/tharsis/ethermint/x/evm/keeper"
|
||||
|
@ -111,6 +114,10 @@ import (
|
|||
"github.com/tharsis/ethermint/x/feemarket"
|
||||
feemarketkeeper "github.com/tharsis/ethermint/x/feemarket/keeper"
|
||||
feemarkettypes "github.com/tharsis/ethermint/x/feemarket/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() {
|
||||
|
@ -154,26 +161,31 @@ var (
|
|||
transfer.AppModuleBasic{},
|
||||
vesting.AppModuleBasic{},
|
||||
// Ethermint modules
|
||||
auction.AppModuleBasic{},
|
||||
evm.AppModuleBasic{},
|
||||
feemarket.AppModuleBasic{},
|
||||
// DXNS modules
|
||||
// Vulcanize DXNS modules
|
||||
auction.AppModuleBasic{},
|
||||
bond.AppModuleBasic{},
|
||||
nameservice.AppModuleBasic{},
|
||||
)
|
||||
|
||||
// module account permissions
|
||||
maccPerms = map[string][]string{
|
||||
authtypes.FeeCollectorName: nil,
|
||||
distrtypes.ModuleName: nil,
|
||||
minttypes.ModuleName: {authtypes.Minter},
|
||||
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
|
||||
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
|
||||
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,
|
||||
bondtypes.ModuleName: nil,
|
||||
authtypes.FeeCollectorName: nil,
|
||||
distrtypes.ModuleName: nil,
|
||||
minttypes.ModuleName: {authtypes.Minter},
|
||||
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
|
||||
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
|
||||
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
|
||||
|
@ -227,12 +239,14 @@ type EthermintApp struct {
|
|||
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
|
||||
|
||||
// Ethermint keepers
|
||||
AuctionKeeper auctionkeeper.Keeper
|
||||
EvmKeeper *evmkeeper.Keeper
|
||||
FeeMarketKeeper feemarketkeeper.Keeper
|
||||
|
||||
// DXNS keepers
|
||||
BondKeeper bondkeeper.Keeper
|
||||
AuctionKeeper auctionkeeper.Keeper
|
||||
BondKeeper bondkeeper.Keeper
|
||||
NameServiceKeeper nameservicekeeper.Keeper
|
||||
NameServiceRecordKeeper nameservicekeeper.RecordKeeper
|
||||
|
||||
// the module manager
|
||||
mm *module.Manager
|
||||
|
@ -287,6 +301,7 @@ func NewEthermintApp(
|
|||
// dxns keys
|
||||
auctiontypes.StoreKey,
|
||||
bondtypes.StoreKey,
|
||||
nameservicetypes.StoreKey,
|
||||
)
|
||||
|
||||
// Add the EVM transient store key
|
||||
|
@ -357,11 +372,6 @@ func NewEthermintApp(
|
|||
tracer := cast.ToString(appOpts.Get(srvflags.EVMTracer))
|
||||
|
||||
// Create Ethermint keepers
|
||||
app.AuctionKeeper = auctionkeeper.NewKeeper(
|
||||
app.AccountKeeper, app.BankKeeper, keys[auctiontypes.StoreKey],
|
||||
appCodec, app.GetSubspace(auctiontypes.ModuleName),
|
||||
)
|
||||
|
||||
app.EvmKeeper = evmkeeper.NewKeeper(
|
||||
appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], app.GetSubspace(evmtypes.ModuleName),
|
||||
app.AccountKeeper, app.BankKeeper, app.StakingKeeper,
|
||||
|
@ -372,8 +382,27 @@ func NewEthermintApp(
|
|||
appCodec, keys[feemarkettypes.StoreKey], app.GetSubspace(feemarkettypes.ModuleName),
|
||||
)
|
||||
|
||||
// Create DXNS keepers
|
||||
app.BondKeeper = bondkeeper.NewKeeper(appCodec, app.AccountKeeper, app.BankKeeper, keys[bondtypes.StoreKey], app.GetSubspace(bondtypes.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),
|
||||
)
|
||||
|
||||
// Create IBC Keeper
|
||||
app.IBCKeeper = ibckeeper.NewKeeper(
|
||||
|
@ -453,11 +482,12 @@ func NewEthermintApp(
|
|||
ibc.NewAppModule(app.IBCKeeper),
|
||||
transferModule,
|
||||
// Ethermint app modules
|
||||
auction.NewAppModule(appCodec, app.AuctionKeeper),
|
||||
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
|
||||
|
@ -477,7 +507,9 @@ func NewEthermintApp(
|
|||
// NOTE: fee market module must go last in order to retrieve the block gas used.
|
||||
app.mm.SetOrderEndBlockers(
|
||||
crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName,
|
||||
evmtypes.ModuleName, feemarkettypes.ModuleName, auctiontypes.ModuleName,
|
||||
evmtypes.ModuleName, feemarkettypes.ModuleName,
|
||||
nameservicetypes.ModuleName,
|
||||
auctiontypes.ModuleName,
|
||||
)
|
||||
|
||||
// NOTE: The genutils module must occur after staking so that pools are
|
||||
|
@ -496,6 +528,7 @@ func NewEthermintApp(
|
|||
// 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,
|
||||
|
@ -736,10 +769,12 @@ func initParamsKeeper(
|
|||
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
|
||||
paramsKeeper.Subspace(ibchost.ModuleName)
|
||||
// ethermint subspaces
|
||||
paramsKeeper.Subspace(auctiontypes.ModuleName)
|
||||
paramsKeeper.Subspace(evmtypes.ModuleName)
|
||||
paramsKeeper.Subspace(feemarkettypes.ModuleName)
|
||||
// dxns subspaces
|
||||
paramsKeeper.Subspace(auctiontypes.ModuleName)
|
||||
paramsKeeper.Subspace(bondtypes.ModuleName)
|
||||
paramsKeeper.Subspace(nameservicetypes.ModuleName)
|
||||
|
||||
return paramsKeeper
|
||||
}
|
||||
|
|
|
@ -150,6 +150,74 @@
|
|||
|
||||
- [Msg](#vulcanize.bond.v1beta1.Msg)
|
||||
|
||||
- [vulcanize/nameservice/v1beta1/nameservice.proto](#vulcanize/nameservice/v1beta1/nameservice.proto)
|
||||
- [AuctionBidInfo](#vulcanize.nameservice.v1beta1.AuctionBidInfo)
|
||||
- [AuthorityEntry](#vulcanize.nameservice.v1beta1.AuthorityEntry)
|
||||
- [BlockChangeSet](#vulcanize.nameservice.v1beta1.BlockChangeSet)
|
||||
- [NameAuthority](#vulcanize.nameservice.v1beta1.NameAuthority)
|
||||
- [NameEntry](#vulcanize.nameservice.v1beta1.NameEntry)
|
||||
- [NameRecord](#vulcanize.nameservice.v1beta1.NameRecord)
|
||||
- [NameRecordEntry](#vulcanize.nameservice.v1beta1.NameRecordEntry)
|
||||
- [Params](#vulcanize.nameservice.v1beta1.Params)
|
||||
- [Record](#vulcanize.nameservice.v1beta1.Record)
|
||||
- [Signature](#vulcanize.nameservice.v1beta1.Signature)
|
||||
|
||||
- [vulcanize/nameservice/v1beta1/genesis.proto](#vulcanize/nameservice/v1beta1/genesis.proto)
|
||||
- [GenesisState](#vulcanize.nameservice.v1beta1.GenesisState)
|
||||
|
||||
- [vulcanize/nameservice/v1beta1/query.proto](#vulcanize/nameservice/v1beta1/query.proto)
|
||||
- [AccountBalance](#vulcanize.nameservice.v1beta1.AccountBalance)
|
||||
- [ExpiryQueueRecord](#vulcanize.nameservice.v1beta1.ExpiryQueueRecord)
|
||||
- [GetNameServiceModuleBalanceRequest](#vulcanize.nameservice.v1beta1.GetNameServiceModuleBalanceRequest)
|
||||
- [GetNameServiceModuleBalanceResponse](#vulcanize.nameservice.v1beta1.GetNameServiceModuleBalanceResponse)
|
||||
- [QueryGetAuthorityExpiryQueue](#vulcanize.nameservice.v1beta1.QueryGetAuthorityExpiryQueue)
|
||||
- [QueryGetAuthorityExpiryQueueResponse](#vulcanize.nameservice.v1beta1.QueryGetAuthorityExpiryQueueResponse)
|
||||
- [QueryGetRecordExpiryQueue](#vulcanize.nameservice.v1beta1.QueryGetRecordExpiryQueue)
|
||||
- [QueryGetRecordExpiryQueueResponse](#vulcanize.nameservice.v1beta1.QueryGetRecordExpiryQueueResponse)
|
||||
- [QueryListNameRecordsRequest](#vulcanize.nameservice.v1beta1.QueryListNameRecordsRequest)
|
||||
- [QueryListNameRecordsResponse](#vulcanize.nameservice.v1beta1.QueryListNameRecordsResponse)
|
||||
- [QueryListRecordsRequest](#vulcanize.nameservice.v1beta1.QueryListRecordsRequest)
|
||||
- [QueryListRecordsResponse](#vulcanize.nameservice.v1beta1.QueryListRecordsResponse)
|
||||
- [QueryLookupWrn](#vulcanize.nameservice.v1beta1.QueryLookupWrn)
|
||||
- [QueryLookupWrnResponse](#vulcanize.nameservice.v1beta1.QueryLookupWrnResponse)
|
||||
- [QueryParamsRequest](#vulcanize.nameservice.v1beta1.QueryParamsRequest)
|
||||
- [QueryParamsResponse](#vulcanize.nameservice.v1beta1.QueryParamsResponse)
|
||||
- [QueryRecordByBondIdRequest](#vulcanize.nameservice.v1beta1.QueryRecordByBondIdRequest)
|
||||
- [QueryRecordByBondIdResponse](#vulcanize.nameservice.v1beta1.QueryRecordByBondIdResponse)
|
||||
- [QueryRecordByIdRequest](#vulcanize.nameservice.v1beta1.QueryRecordByIdRequest)
|
||||
- [QueryRecordByIdResponse](#vulcanize.nameservice.v1beta1.QueryRecordByIdResponse)
|
||||
- [QueryResolveWrn](#vulcanize.nameservice.v1beta1.QueryResolveWrn)
|
||||
- [QueryResolveWrnResponse](#vulcanize.nameservice.v1beta1.QueryResolveWrnResponse)
|
||||
- [QueryWhoisRequest](#vulcanize.nameservice.v1beta1.QueryWhoisRequest)
|
||||
- [QueryWhoisResponse](#vulcanize.nameservice.v1beta1.QueryWhoisResponse)
|
||||
|
||||
- [Query](#vulcanize.nameservice.v1beta1.Query)
|
||||
|
||||
- [vulcanize/nameservice/v1beta1/tx.proto](#vulcanize/nameservice/v1beta1/tx.proto)
|
||||
- [MsgAssociateBond](#vulcanize.nameservice.v1beta1.MsgAssociateBond)
|
||||
- [MsgAssociateBondResponse](#vulcanize.nameservice.v1beta1.MsgAssociateBondResponse)
|
||||
- [MsgDeleteNameAuthority](#vulcanize.nameservice.v1beta1.MsgDeleteNameAuthority)
|
||||
- [MsgDeleteNameAuthorityResponse](#vulcanize.nameservice.v1beta1.MsgDeleteNameAuthorityResponse)
|
||||
- [MsgDissociateBond](#vulcanize.nameservice.v1beta1.MsgDissociateBond)
|
||||
- [MsgDissociateBondResponse](#vulcanize.nameservice.v1beta1.MsgDissociateBondResponse)
|
||||
- [MsgDissociateRecords](#vulcanize.nameservice.v1beta1.MsgDissociateRecords)
|
||||
- [MsgDissociateRecordsResponse](#vulcanize.nameservice.v1beta1.MsgDissociateRecordsResponse)
|
||||
- [MsgReAssociateRecords](#vulcanize.nameservice.v1beta1.MsgReAssociateRecords)
|
||||
- [MsgReAssociateRecordsResponse](#vulcanize.nameservice.v1beta1.MsgReAssociateRecordsResponse)
|
||||
- [MsgRenewRecord](#vulcanize.nameservice.v1beta1.MsgRenewRecord)
|
||||
- [MsgRenewRecordResponse](#vulcanize.nameservice.v1beta1.MsgRenewRecordResponse)
|
||||
- [MsgReserveAuthority](#vulcanize.nameservice.v1beta1.MsgReserveAuthority)
|
||||
- [MsgReserveAuthorityResponse](#vulcanize.nameservice.v1beta1.MsgReserveAuthorityResponse)
|
||||
- [MsgSetAuthorityBond](#vulcanize.nameservice.v1beta1.MsgSetAuthorityBond)
|
||||
- [MsgSetAuthorityBondResponse](#vulcanize.nameservice.v1beta1.MsgSetAuthorityBondResponse)
|
||||
- [MsgSetName](#vulcanize.nameservice.v1beta1.MsgSetName)
|
||||
- [MsgSetNameResponse](#vulcanize.nameservice.v1beta1.MsgSetNameResponse)
|
||||
- [MsgSetRecord](#vulcanize.nameservice.v1beta1.MsgSetRecord)
|
||||
- [MsgSetRecordResponse](#vulcanize.nameservice.v1beta1.MsgSetRecordResponse)
|
||||
- [Payload](#vulcanize.nameservice.v1beta1.Payload)
|
||||
|
||||
- [Msg](#vulcanize.nameservice.v1beta1.Msg)
|
||||
|
||||
- [Scalar Value Types](#scalar-value-types)
|
||||
|
||||
|
||||
|
@ -2089,6 +2157,900 @@ Msg defines the bond Msg service.
|
|||
|
||||
|
||||
|
||||
<a name="vulcanize/nameservice/v1beta1/nameservice.proto"></a>
|
||||
<p align="right"><a href="#top">Top</a></p>
|
||||
|
||||
## vulcanize/nameservice/v1beta1/nameservice.proto
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.AuctionBidInfo"></a>
|
||||
|
||||
### AuctionBidInfo
|
||||
|
||||
AuctionBidInfo
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `auction_id` | [string](#string) | | |
|
||||
| `bidder_address` | [string](#string) | | |
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.AuthorityEntry"></a>
|
||||
|
||||
### AuthorityEntry
|
||||
|
||||
AuthorityEntry defines the nameservice module AuthorityEntries
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `name` | [string](#string) | | |
|
||||
| `entry` | [NameAuthority](#vulcanize.nameservice.v1beta1.NameAuthority) | | |
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.BlockChangeSet"></a>
|
||||
|
||||
### BlockChangeSet
|
||||
|
||||
BlockChangeSet
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `height` | [int64](#int64) | | |
|
||||
| `records` | [string](#string) | repeated | |
|
||||
| `auctions` | [string](#string) | repeated | |
|
||||
| `auction_bids` | [AuctionBidInfo](#vulcanize.nameservice.v1beta1.AuctionBidInfo) | repeated | |
|
||||
| `authorities` | [string](#string) | repeated | |
|
||||
| `names` | [string](#string) | repeated | |
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.NameAuthority"></a>
|
||||
|
||||
### NameAuthority
|
||||
|
||||
NameAuthority
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `owner_public_key` | [string](#string) | | Owner public key. |
|
||||
| `owner_address` | [string](#string) | | Owner address. |
|
||||
| `height` | [uint64](#uint64) | | height at which name/authority was created. |
|
||||
| `status` | [string](#string) | | |
|
||||
| `auction_id` | [string](#string) | | |
|
||||
| `bond_id` | [string](#string) | | |
|
||||
| `expiry_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.NameEntry"></a>
|
||||
|
||||
### NameEntry
|
||||
NameEntry
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `name` | [string](#string) | | |
|
||||
| `entry` | [NameRecord](#vulcanize.nameservice.v1beta1.NameRecord) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.NameRecord"></a>
|
||||
|
||||
### NameRecord
|
||||
NameRecord
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `latest` | [NameRecordEntry](#vulcanize.nameservice.v1beta1.NameRecordEntry) | | |
|
||||
| `history` | [NameRecordEntry](#vulcanize.nameservice.v1beta1.NameRecordEntry) | repeated | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.NameRecordEntry"></a>
|
||||
|
||||
### NameRecordEntry
|
||||
NameRecordEntry
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `id` | [string](#string) | | |
|
||||
| `height` | [uint64](#uint64) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.Params"></a>
|
||||
|
||||
### Params
|
||||
Params defines the nameservice module parameters
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `record_rent` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | |
|
||||
| `record_rent_duration` | [google.protobuf.Duration](#google.protobuf.Duration) | | |
|
||||
| `authority_rent` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | |
|
||||
| `authority_rent_duration` | [google.protobuf.Duration](#google.protobuf.Duration) | | |
|
||||
| `authority_grace_period` | [google.protobuf.Duration](#google.protobuf.Duration) | | |
|
||||
| `authority_auction_enabled` | [bool](#bool) | | |
|
||||
| `authority_auction_commits_duration` | [google.protobuf.Duration](#google.protobuf.Duration) | | |
|
||||
| `authority_auction_reveals_duration` | [google.protobuf.Duration](#google.protobuf.Duration) | | |
|
||||
| `authority_auction_commit_fee` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | |
|
||||
| `authority_auction_reveal_fee` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | |
|
||||
| `authority_auction_minimum_bid` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.Record"></a>
|
||||
|
||||
### Record
|
||||
Params defines the nameservice module records
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `id` | [string](#string) | | |
|
||||
| `bond_id` | [string](#string) | | |
|
||||
| `create_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | |
|
||||
| `expiry_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | |
|
||||
| `deleted` | [bool](#bool) | | |
|
||||
| `owners` | [string](#string) | repeated | |
|
||||
| `attributes` | [bytes](#bytes) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.Signature"></a>
|
||||
|
||||
### Signature
|
||||
Signature
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `sig` | [string](#string) | | |
|
||||
| `pub_key` | [string](#string) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- end messages -->
|
||||
|
||||
<!-- end enums -->
|
||||
|
||||
<!-- end HasExtensions -->
|
||||
|
||||
<!-- end services -->
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize/nameservice/v1beta1/genesis.proto"></a>
|
||||
<p align="right"><a href="#top">Top</a></p>
|
||||
|
||||
## vulcanize/nameservice/v1beta1/genesis.proto
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.GenesisState"></a>
|
||||
|
||||
### GenesisState
|
||||
GenesisState defines the nameservice module's genesis state.
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `params` | [Params](#vulcanize.nameservice.v1beta1.Params) | | params defines all the params of nameservice module. |
|
||||
| `records` | [Record](#vulcanize.nameservice.v1beta1.Record) | repeated | records |
|
||||
| `authorities` | [AuthorityEntry](#vulcanize.nameservice.v1beta1.AuthorityEntry) | repeated | authorities |
|
||||
| `names` | [NameEntry](#vulcanize.nameservice.v1beta1.NameEntry) | repeated | names |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- end messages -->
|
||||
|
||||
<!-- end enums -->
|
||||
|
||||
<!-- end HasExtensions -->
|
||||
|
||||
<!-- end services -->
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize/nameservice/v1beta1/query.proto"></a>
|
||||
<p align="right"><a href="#top">Top</a></p>
|
||||
|
||||
## vulcanize/nameservice/v1beta1/query.proto
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.AccountBalance"></a>
|
||||
|
||||
### AccountBalance
|
||||
|
||||
AccountBalance is nameservice module account balance
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `account_name` | [string](#string) | | |
|
||||
| `balance` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | |
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.ExpiryQueueRecord"></a>
|
||||
|
||||
### ExpiryQueueRecord
|
||||
|
||||
ExpiryQueueRecord
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `id` | [string](#string) | | |
|
||||
| `value` | [string](#string) | repeated | |
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.GetNameServiceModuleBalanceRequest"></a>
|
||||
|
||||
### GetNameServiceModuleBalanceRequest
|
||||
|
||||
GetNameServiceModuleBalanceRequest is request type for nameservice module accounts balance
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.GetNameServiceModuleBalanceResponse"></a>
|
||||
|
||||
### GetNameServiceModuleBalanceResponse
|
||||
|
||||
GetNameServiceModuleBalanceResponse is response type for nameservice module accounts balance
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `balances` | [AccountBalance](#vulcanize.nameservice.v1beta1.AccountBalance) | repeated | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.QueryGetAuthorityExpiryQueue"></a>
|
||||
|
||||
### QueryGetAuthorityExpiryQueue
|
||||
QueryGetAuthorityExpiryQueue
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.QueryGetAuthorityExpiryQueueResponse"></a>
|
||||
|
||||
### QueryGetAuthorityExpiryQueueResponse
|
||||
QueryGetAuthorityExpiryQueueResponse
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `authorities` | [ExpiryQueueRecord](#vulcanize.nameservice.v1beta1.ExpiryQueueRecord) | repeated | |
|
||||
| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.QueryGetRecordExpiryQueue"></a>
|
||||
|
||||
### QueryGetRecordExpiryQueue
|
||||
QueryGetRecordExpiryQueue
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.QueryGetRecordExpiryQueueResponse"></a>
|
||||
|
||||
### QueryGetRecordExpiryQueueResponse
|
||||
QueryGetRecordExpiryQueueResponse
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `records` | [ExpiryQueueRecord](#vulcanize.nameservice.v1beta1.ExpiryQueueRecord) | repeated | |
|
||||
| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.QueryListNameRecordsRequest"></a>
|
||||
|
||||
### QueryListNameRecordsRequest
|
||||
QueryListNameRecordsRequest is request type for nameservice names records
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.QueryListNameRecordsResponse"></a>
|
||||
|
||||
### QueryListNameRecordsResponse
|
||||
QueryListNameRecordsResponse is response type for nameservice names records
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `names` | [NameEntry](#vulcanize.nameservice.v1beta1.NameEntry) | repeated | |
|
||||
| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.QueryListRecordsRequest"></a>
|
||||
|
||||
### QueryListRecordsRequest
|
||||
QueryListRecordsRequest is request type for nameservice records list
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.QueryListRecordsResponse"></a>
|
||||
|
||||
### QueryListRecordsResponse
|
||||
QueryListRecordsResponse is response type for nameservice records list
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `records` | [Record](#vulcanize.nameservice.v1beta1.Record) | repeated | |
|
||||
| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. |
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.QueryLookupWrn"></a>
|
||||
|
||||
### QueryLookupWrn
|
||||
|
||||
QueryLookupWrn is request type for LookupWrn
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `wrn` | [string](#string) | | |
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.QueryLookupWrnResponse"></a>
|
||||
|
||||
### QueryLookupWrnResponse
|
||||
|
||||
QueryLookupWrnResponse is response type for QueryLookupWrn
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `name` | [NameRecord](#vulcanize.nameservice.v1beta1.NameRecord) | | |
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.QueryParamsRequest"></a>
|
||||
|
||||
### QueryParamsRequest
|
||||
|
||||
QueryParamsRequest is request type for nameservice params
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.QueryParamsResponse"></a>
|
||||
|
||||
### QueryParamsResponse
|
||||
|
||||
QueryParamsResponse is response type for nameservice params
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `params` | [Params](#vulcanize.nameservice.v1beta1.Params) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.QueryRecordByBondIdRequest"></a>
|
||||
|
||||
### QueryRecordByBondIdRequest
|
||||
QueryRecordByBondIdRequest is request type for get the records by bond-id
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `id` | [string](#string) | | |
|
||||
| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.QueryRecordByBondIdResponse"></a>
|
||||
|
||||
### QueryRecordByBondIdResponse
|
||||
QueryRecordByBondIdResponse is response type for records list by bond-id
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `records` | [Record](#vulcanize.nameservice.v1beta1.Record) | repeated | |
|
||||
| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.QueryRecordByIdRequest"></a>
|
||||
|
||||
### QueryRecordByIdRequest
|
||||
QueryRecordByIdRequest is request type for nameservice records by id
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `id` | [string](#string) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.QueryRecordByIdResponse"></a>
|
||||
|
||||
### QueryRecordByIdResponse
|
||||
QueryRecordByIdResponse is response type for nameservice records by id
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `record` | [Record](#vulcanize.nameservice.v1beta1.Record) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.QueryResolveWrn"></a>
|
||||
|
||||
### QueryResolveWrn
|
||||
QueryResolveWrn is request type for ResolveWrn
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `wrn` | [string](#string) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.QueryResolveWrnResponse"></a>
|
||||
|
||||
### QueryResolveWrnResponse
|
||||
QueryResolveWrnResponse is response type for QueryResolveWrn
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `record` | [Record](#vulcanize.nameservice.v1beta1.Record) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.QueryWhoisRequest"></a>
|
||||
|
||||
### QueryWhoisRequest
|
||||
QueryWhoisRequest is request type for Get NameAuthority
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `name` | [string](#string) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.QueryWhoisResponse"></a>
|
||||
|
||||
### QueryWhoisResponse
|
||||
QueryWhoisResponse is response type for whois request
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `name_authority` | [NameAuthority](#vulcanize.nameservice.v1beta1.NameAuthority) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- end messages -->
|
||||
|
||||
<!-- end enums -->
|
||||
|
||||
<!-- end HasExtensions -->
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.Query"></a>
|
||||
|
||||
### Query
|
||||
Query defines the gRPC querier service for nameservice module
|
||||
|
||||
| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint |
|
||||
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
|
||||
| `Params` | [QueryParamsRequest](#vulcanize.nameservice.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#vulcanize.nameservice.v1beta1.QueryParamsResponse) | Params queries the nameservice module params. | GET|/ethermint/nameservice/v1/params|
|
||||
| `ListRecords` | [QueryListRecordsRequest](#vulcanize.nameservice.v1beta1.QueryListRecordsRequest) | [QueryListRecordsResponse](#vulcanize.nameservice.v1beta1.QueryListRecordsResponse) | List records | GET|/ethermint/nameservice/v1/records|
|
||||
| `GetRecord` | [QueryRecordByIdRequest](#vulcanize.nameservice.v1beta1.QueryRecordByIdRequest) | [QueryRecordByIdResponse](#vulcanize.nameservice.v1beta1.QueryRecordByIdResponse) | Get record by id | GET|/ethermint/nameservice/v1/records/{id}|
|
||||
| `GetRecordByBondId` | [QueryRecordByBondIdRequest](#vulcanize.nameservice.v1beta1.QueryRecordByBondIdRequest) | [QueryRecordByBondIdResponse](#vulcanize.nameservice.v1beta1.QueryRecordByBondIdResponse) | Get records by bond id | GET|/ethermint/nameservice/v1/records-by-bond-id/{id}|
|
||||
| `GetNameServiceModuleBalance` | [GetNameServiceModuleBalanceRequest](#vulcanize.nameservice.v1beta1.GetNameServiceModuleBalanceRequest) | [GetNameServiceModuleBalanceResponse](#vulcanize.nameservice.v1beta1.GetNameServiceModuleBalanceResponse) | Get nameservice module balance | GET|/ethermint/nameservice/v1/balance|
|
||||
| `ListNameRecords` | [QueryListNameRecordsRequest](#vulcanize.nameservice.v1beta1.QueryListNameRecordsRequest) | [QueryListNameRecordsResponse](#vulcanize.nameservice.v1beta1.QueryListNameRecordsResponse) | List name records | GET|/ethermint/nameservice/v1/names|
|
||||
| `Whois` | [QueryWhoisRequest](#vulcanize.nameservice.v1beta1.QueryWhoisRequest) | [QueryWhoisResponse](#vulcanize.nameservice.v1beta1.QueryWhoisResponse) | Whois method retrieve the name authority info | GET|/ethermint/nameservice/v1/whois/{name}|
|
||||
| `LookupWrn` | [QueryLookupWrn](#vulcanize.nameservice.v1beta1.QueryLookupWrn) | [QueryLookupWrnResponse](#vulcanize.nameservice.v1beta1.QueryLookupWrnResponse) | LookupWrn | GET|/ethermint/nameservice/v1/lookup/{wrn}|
|
||||
| `ResolveWrn` | [QueryResolveWrn](#vulcanize.nameservice.v1beta1.QueryResolveWrn) | [QueryResolveWrnResponse](#vulcanize.nameservice.v1beta1.QueryResolveWrnResponse) | ResolveWrn | GET|/ethermint/nameservice/v1/resolve/{wrn}|
|
||||
| `GetRecordExpiryQueue` | [QueryGetRecordExpiryQueue](#vulcanize.nameservice.v1beta1.QueryGetRecordExpiryQueue) | [QueryGetRecordExpiryQueueResponse](#vulcanize.nameservice.v1beta1.QueryGetRecordExpiryQueueResponse) | GetRecordExpiryQueue | GET|/ethermint/nameservice/v1/record-expiry|
|
||||
| `GetAuthorityExpiryQueue` | [QueryGetAuthorityExpiryQueue](#vulcanize.nameservice.v1beta1.QueryGetAuthorityExpiryQueue) | [QueryGetAuthorityExpiryQueueResponse](#vulcanize.nameservice.v1beta1.QueryGetAuthorityExpiryQueueResponse) | GetAuthorityExpiryQueue | GET|/ethermint/nameservice/v1/authority-expiry|
|
||||
|
||||
<!-- end services -->
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize/nameservice/v1beta1/tx.proto"></a>
|
||||
<p align="right"><a href="#top">Top</a></p>
|
||||
|
||||
## vulcanize/nameservice/v1beta1/tx.proto
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.MsgAssociateBond"></a>
|
||||
|
||||
### MsgAssociateBond
|
||||
MsgAssociateBond
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `record_id` | [string](#string) | | |
|
||||
| `bond_id` | [string](#string) | | |
|
||||
| `signer` | [string](#string) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.MsgAssociateBondResponse"></a>
|
||||
|
||||
### MsgAssociateBondResponse
|
||||
MsgAssociateBondResponse
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.MsgDeleteNameAuthority"></a>
|
||||
|
||||
### MsgDeleteNameAuthority
|
||||
MsgDeleteNameAuthority is SDK message for DeleteNameAuthority
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `wrn` | [string](#string) | | |
|
||||
| `signer` | [string](#string) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.MsgDeleteNameAuthorityResponse"></a>
|
||||
|
||||
### MsgDeleteNameAuthorityResponse
|
||||
MsgDeleteNameAuthorityResponse
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.MsgDissociateBond"></a>
|
||||
|
||||
### MsgDissociateBond
|
||||
MsgDissociateBond is SDK message for Msg/DissociateBond
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `record_id` | [string](#string) | | |
|
||||
| `signer` | [string](#string) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.MsgDissociateBondResponse"></a>
|
||||
|
||||
### MsgDissociateBondResponse
|
||||
MsgDissociateBondResponse is response type for MsgDissociateBond
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.MsgDissociateRecords"></a>
|
||||
|
||||
### MsgDissociateRecords
|
||||
MsgDissociateRecords is SDK message for Msg/DissociateRecords
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `bond_id` | [string](#string) | | |
|
||||
| `signer` | [string](#string) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.MsgDissociateRecordsResponse"></a>
|
||||
|
||||
### MsgDissociateRecordsResponse
|
||||
MsgDissociateRecordsResponse is response type for MsgDissociateRecords
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.MsgReAssociateRecords"></a>
|
||||
|
||||
### MsgReAssociateRecords
|
||||
MsgReAssociateRecords is SDK message for Msg/ReAssociateRecords
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `new_bond_id` | [string](#string) | | |
|
||||
| `old_bond_id` | [string](#string) | | |
|
||||
| `signer` | [string](#string) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.MsgReAssociateRecordsResponse"></a>
|
||||
|
||||
### MsgReAssociateRecordsResponse
|
||||
MsgReAssociateRecordsResponse is response type for MsgReAssociateRecords
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.MsgRenewRecord"></a>
|
||||
|
||||
### MsgRenewRecord
|
||||
MsgRenewRecord is SDK message for Renew a record
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `record_id` | [string](#string) | | |
|
||||
| `signer` | [string](#string) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.MsgRenewRecordResponse"></a>
|
||||
|
||||
### MsgRenewRecordResponse
|
||||
MsgRenewRecordResponse
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.MsgReserveAuthority"></a>
|
||||
|
||||
### MsgReserveAuthority
|
||||
MsgReserveName
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `name` | [string](#string) | | |
|
||||
| `signer` | [string](#string) | | |
|
||||
| `owner` | [string](#string) | | if creating a sub-authority. |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.MsgReserveAuthorityResponse"></a>
|
||||
|
||||
### MsgReserveAuthorityResponse
|
||||
MsgReserveNameResponse
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.MsgSetAuthorityBond"></a>
|
||||
|
||||
### MsgSetAuthorityBond
|
||||
MsgSetAuthorityBond is SDK message for SetAuthorityBond
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `name` | [string](#string) | | |
|
||||
| `bond_id` | [string](#string) | | |
|
||||
| `signer` | [string](#string) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.MsgSetAuthorityBondResponse"></a>
|
||||
|
||||
### MsgSetAuthorityBondResponse
|
||||
MsgSetAuthorityBondResponse
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.MsgSetName"></a>
|
||||
|
||||
### MsgSetName
|
||||
MsgSetName
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `wrn` | [string](#string) | | |
|
||||
| `cid` | [string](#string) | | |
|
||||
| `signer` | [string](#string) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.MsgSetNameResponse"></a>
|
||||
|
||||
### MsgSetNameResponse
|
||||
MsgSetNameResponse
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.MsgSetRecord"></a>
|
||||
|
||||
### MsgSetRecord
|
||||
MsgSetRecord
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `bond_id` | [string](#string) | | |
|
||||
| `signer` | [string](#string) | | |
|
||||
| `payload` | [Payload](#vulcanize.nameservice.v1beta1.Payload) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.MsgSetRecordResponse"></a>
|
||||
|
||||
### MsgSetRecordResponse
|
||||
MsgSetRecordResponse
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.Payload"></a>
|
||||
|
||||
### Payload
|
||||
Payload
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `record` | [Record](#vulcanize.nameservice.v1beta1.Record) | | |
|
||||
| `signatures` | [Signature](#vulcanize.nameservice.v1beta1.Signature) | repeated | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- end messages -->
|
||||
|
||||
<!-- end enums -->
|
||||
|
||||
<!-- end HasExtensions -->
|
||||
|
||||
|
||||
<a name="vulcanize.nameservice.v1beta1.Msg"></a>
|
||||
|
||||
### Msg
|
||||
Msg
|
||||
|
||||
| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint |
|
||||
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
|
||||
| `SetRecord` | [MsgSetRecord](#vulcanize.nameservice.v1beta1.MsgSetRecord) | [MsgSetRecordResponse](#vulcanize.nameservice.v1beta1.MsgSetRecordResponse) | SetRecord will records a new record with given payload and bond id | |
|
||||
| `RenewRecord` | [MsgRenewRecord](#vulcanize.nameservice.v1beta1.MsgRenewRecord) | [MsgRenewRecordResponse](#vulcanize.nameservice.v1beta1.MsgRenewRecordResponse) | Renew Record will renew the expire record | |
|
||||
| `AssociateBond` | [MsgAssociateBond](#vulcanize.nameservice.v1beta1.MsgAssociateBond) | [MsgAssociateBondResponse](#vulcanize.nameservice.v1beta1.MsgAssociateBondResponse) | AssociateBond | |
|
||||
| `DissociateBond` | [MsgDissociateBond](#vulcanize.nameservice.v1beta1.MsgDissociateBond) | [MsgDissociateBondResponse](#vulcanize.nameservice.v1beta1.MsgDissociateBondResponse) | DissociateBond | |
|
||||
| `DissociateRecords` | [MsgDissociateRecords](#vulcanize.nameservice.v1beta1.MsgDissociateRecords) | [MsgDissociateRecordsResponse](#vulcanize.nameservice.v1beta1.MsgDissociateRecordsResponse) | DissociateRecords | |
|
||||
| `ReAssociateRecords` | [MsgReAssociateRecords](#vulcanize.nameservice.v1beta1.MsgReAssociateRecords) | [MsgReAssociateRecordsResponse](#vulcanize.nameservice.v1beta1.MsgReAssociateRecordsResponse) | ReAssociateRecords | |
|
||||
| `SetName` | [MsgSetName](#vulcanize.nameservice.v1beta1.MsgSetName) | [MsgSetNameResponse](#vulcanize.nameservice.v1beta1.MsgSetNameResponse) | SetName will store the name with given wrn and name | |
|
||||
| `ReserveName` | [MsgReserveAuthority](#vulcanize.nameservice.v1beta1.MsgReserveAuthority) | [MsgReserveAuthorityResponse](#vulcanize.nameservice.v1beta1.MsgReserveAuthorityResponse) | Reserve name | |
|
||||
| `DeleteName` | [MsgDeleteNameAuthority](#vulcanize.nameservice.v1beta1.MsgDeleteNameAuthority) | [MsgDeleteNameAuthorityResponse](#vulcanize.nameservice.v1beta1.MsgDeleteNameAuthorityResponse) | Delete Name method will remove authority name | |
|
||||
| `SetAuthorityBond` | [MsgSetAuthorityBond](#vulcanize.nameservice.v1beta1.MsgSetAuthorityBond) | [MsgSetAuthorityBondResponse](#vulcanize.nameservice.v1beta1.MsgSetAuthorityBondResponse) | SetAuthorityBond | |
|
||||
|
||||
<!-- end services -->
|
||||
|
||||
|
||||
|
||||
## Scalar Value Types
|
||||
|
||||
| .proto Type | Notes | C++ | Java | Python | Go | C# | PHP | Ruby |
|
||||
|
|
29
go.mod
29
go.mod
|
@ -8,7 +8,6 @@ require (
|
|||
github.com/cosmos/cosmos-sdk v0.44.0
|
||||
github.com/cosmos/go-bip39 v1.0.0
|
||||
github.com/cosmos/ibc-go v1.2.0
|
||||
github.com/deckarep/golang-set v1.7.1
|
||||
github.com/ethereum/go-ethereum v1.10.3
|
||||
github.com/gibson042/canonicaljson-go v1.0.3
|
||||
github.com/gogo/protobuf v1.3.3
|
||||
|
@ -17,9 +16,9 @@ require (
|
|||
github.com/gorilla/websocket v1.4.2
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0
|
||||
github.com/improbable-eng/grpc-web v0.14.1
|
||||
github.com/ipfs/go-ipld-cbor v0.0.4
|
||||
github.com/ipfs/go-ipld-cbor v0.0.5
|
||||
github.com/miguelmota/go-ethereum-hdwallet v0.0.1
|
||||
github.com/multiformats/go-multihash v0.0.14
|
||||
github.com/multiformats/go-multihash v0.0.10
|
||||
github.com/palantir/stacktrace v0.0.0-20161112013806-78658fd2d177
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/rakyll/statik v0.1.7
|
||||
|
@ -38,20 +37,25 @@ require (
|
|||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
|
||||
golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f // indirect
|
||||
golang.org/x/sys v0.0.0-20210903071746-97244b99971b // indirect
|
||||
google.golang.org/genproto v0.0.0-20210929214142-896c89f843d2
|
||||
google.golang.org/genproto v0.0.0-20211001223012-bfb93cce50d9
|
||||
google.golang.org/grpc v1.40.0
|
||||
google.golang.org/protobuf v1.27.1
|
||||
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/keyring v1.1.6 // indirect
|
||||
github.com/ChainSafe/go-schnorrkel v0.0.0-20200626160457-b38283118816 // indirect
|
||||
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect
|
||||
github.com/DataDog/zstd v1.4.8 // indirect
|
||||
github.com/Masterminds/goutils v1.1.1 // indirect
|
||||
github.com/Masterminds/semver v1.5.0 // indirect
|
||||
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
|
||||
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
|
||||
github.com/VictoriaMetrics/fastcache v1.5.7 // indirect
|
||||
github.com/Workiva/go-datastructures v1.0.52 // indirect
|
||||
github.com/aokoli/goutils v1.1.1 // indirect
|
||||
github.com/armon/go-metrics v0.3.9 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bgentry/speakeasy v0.1.0 // indirect
|
||||
|
@ -62,8 +66,9 @@ require (
|
|||
github.com/cosmos/iavl v0.16.0 // indirect
|
||||
github.com/cosmos/ledger-cosmos-go v0.11.1 // indirect
|
||||
github.com/cosmos/ledger-go v0.9.2 // indirect
|
||||
github.com/danieljoos/wincred v1.1.0 // indirect
|
||||
github.com/danieljoos/wincred v1.0.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea // 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
|
||||
|
@ -72,6 +77,7 @@ require (
|
|||
github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b // indirect
|
||||
github.com/edsrzf/mmap-go v1.0.0 // indirect
|
||||
github.com/enigmampc/btcutil v1.0.3-0.20200723161021-e2fb6adb2a25 // indirect
|
||||
github.com/envoyproxy/protoc-gen-validate v0.6.1 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.1 // indirect
|
||||
github.com/fsnotify/fsnotify v1.4.9 // indirect
|
||||
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
|
||||
|
@ -96,7 +102,9 @@ require (
|
|||
github.com/hdevalence/ed25519consensus v0.0.0-20210204194344-59a8610d2b87 // indirect
|
||||
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
|
||||
github.com/holiman/uint256 v1.1.1 // indirect
|
||||
github.com/huandu/xstrings v1.3.2 // indirect
|
||||
github.com/huin/goupnp v1.0.1-0.20210310174557-0ca763054c88 // indirect
|
||||
github.com/imdario/mergo v0.3.12 // 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
|
||||
|
@ -104,7 +112,7 @@ require (
|
|||
github.com/ipfs/go-ipld-format v0.0.1 // indirect
|
||||
github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458 // indirect
|
||||
github.com/jmhodges/levigo v1.0.0 // indirect
|
||||
github.com/keybase/go-keychain v0.0.0-20200502122510-cda31fe0c86d // indirect
|
||||
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect
|
||||
github.com/klauspost/compress v1.11.9 // indirect
|
||||
github.com/libp2p/go-buffer-pool v0.0.2 // indirect
|
||||
github.com/magiconair/properties v1.8.5 // indirect
|
||||
|
@ -115,12 +123,13 @@ require (
|
|||
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect
|
||||
github.com/minio/highwayhash v1.0.1 // indirect
|
||||
github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771 // indirect
|
||||
github.com/mitchellh/copystructure v1.2.0 // indirect
|
||||
github.com/mitchellh/mapstructure v1.4.1 // indirect
|
||||
github.com/mr-tron/base58 v1.1.3 // indirect
|
||||
github.com/mr-tron/base58 v1.1.2 // 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.5 // indirect
|
||||
github.com/mwitkow/go-proto-validators v0.3.2 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/pelletier/go-toml v1.9.3 // indirect
|
||||
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
|
||||
|
@ -131,6 +140,7 @@ require (
|
|||
github.com/prometheus/common v0.29.0 // indirect
|
||||
github.com/prometheus/procfs v0.6.0 // indirect
|
||||
github.com/prometheus/tsdb v0.7.1 // indirect
|
||||
github.com/pseudomuto/protoc-gen-doc v1.5.0 // indirect
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
|
||||
github.com/rjeczalik/notify v0.9.1 // indirect
|
||||
github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa // indirect
|
||||
|
@ -156,7 +166,6 @@ require (
|
|||
gopkg.in/ini.v1 v1.62.0 // 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/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
|
||||
nhooyr.io/websocket v1.8.6 // indirect
|
||||
)
|
||||
|
||||
|
|
82
go.sum
82
go.sum
|
@ -61,9 +61,8 @@ github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6L
|
|||
github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg=
|
||||
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4=
|
||||
github.com/ChainSafe/go-schnorrkel v0.0.0-20200626160457-b38283118816 h1:X5jJ3e/jgFSnSoYOep/mf6pF1RuLZfvF1ts8NZIyzqE=
|
||||
github.com/ChainSafe/go-schnorrkel v0.0.0-20200626160457-b38283118816/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4=
|
||||
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
|
||||
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
|
||||
github.com/DataDog/zstd v1.3.6-0.20190409195224-796139022798/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
|
||||
|
@ -72,6 +71,14 @@ github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t
|
|||
github.com/DataDog/zstd v1.4.8 h1:Rpmta4xZ/MgZnriKNd24iZMhGpP5dvUcs/uqfBapKZY=
|
||||
github.com/DataDog/zstd v1.4.8/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
|
||||
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
||||
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
|
||||
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
|
||||
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
|
||||
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
|
||||
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
|
||||
github.com/Masterminds/sprig v2.15.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
|
||||
github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCSYp4Z0m2dk6cEM60=
|
||||
github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
|
||||
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
|
||||
github.com/Microsoft/go-winio v0.5.0 h1:Elr9Wn+sGKPlkaBvwu4mTrxtmOp3F3yV9qhaHbXGjwU=
|
||||
github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
|
||||
|
@ -106,6 +113,9 @@ github.com/allegro/bigcache v1.2.1 h1:hg1sY1raCwic3Vnsvje6TT7/pnZba83LeFck5NrFKS
|
|||
github.com/allegro/bigcache v1.2.1/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
|
||||
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
github.com/aokoli/goutils v1.0.1/go.mod h1:SijmP0QR8LtwsmDs8Yii5Z/S4trXFGFC2oO5g9DP+DQ=
|
||||
github.com/aokoli/goutils v1.1.1 h1:/hA+Ywo3AxoDZY5ZMnkiEkUvkK4BPp927ax110KCqqg=
|
||||
github.com/aokoli/goutils v1.1.1/go.mod h1:SijmP0QR8LtwsmDs8Yii5Z/S4trXFGFC2oO5g9DP+DQ=
|
||||
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=
|
||||
|
@ -241,17 +251,16 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsr
|
|||
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4=
|
||||
github.com/danieljoos/wincred v1.0.2 h1:zf4bhty2iLuwgjgpraD2E9UbvO+fe54XXGJbOwe23fU=
|
||||
github.com/danieljoos/wincred v1.0.2/go.mod h1:SnuYRW9lp1oJrZX/dXJqr0cPK5gYXqx3EJbmjhLdK9U=
|
||||
github.com/danieljoos/wincred v1.1.0 h1:3RNcEpBg4IhIChZdFRSdlQt1QjCp1sMAPIrOnm7Yf8g=
|
||||
github.com/danieljoos/wincred v1.1.0/go.mod h1:XYlo+eRTsVA9aHGp7NGjFkPla4m+DCL7hqDjlFjiygg=
|
||||
github.com/dave/jennifer v1.2.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhrIygKg=
|
||||
github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea h1:j4317fAZh7X6GqbFowYdYdI0L9bwxL07jyPZIdepyZ0=
|
||||
github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ=
|
||||
github.com/deckarep/golang-set v1.7.1 h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9rTHJQ=
|
||||
github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ=
|
||||
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
|
||||
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I=
|
||||
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE=
|
||||
|
@ -293,6 +302,9 @@ github.com/enigmampc/btcutil v1.0.3-0.20200723161021-e2fb6adb2a25 h1:2vLKys4RBU4
|
|||
github.com/enigmampc/btcutil v1.0.3-0.20200723161021-e2fb6adb2a25/go.mod h1:hTr8+TLQmkUkgcuh3mcr5fjrT9c64ZzsBCdCEC6UppY=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.3.0-java/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.6.1 h1:4CF52PCseTFt4bE+Yk3dIpdVi7XWuPVMhPtm4FaIJPM=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.6.1/go.mod h1:txg5va2Qkip90uYoSKH+nkAAmXrb2j3iq4FLwdrCbXQ=
|
||||
github.com/ethereum/go-ethereum v1.9.25/go.mod h1:vMkFiYLHI4tgPw4k2j4MHKoovchFE8plZ0M9VMk4/oM=
|
||||
github.com/ethereum/go-ethereum v1.10.1/go.mod h1:E5e/zvdfUVr91JZ0AwjyuJM3x+no51zZJRz61orLLSk=
|
||||
github.com/ethereum/go-ethereum v1.10.3 h1:SEYOYARvbWnoDl1hOSks3ZJQpRiiRJe8ubaQGJQwq0s=
|
||||
|
@ -454,6 +466,7 @@ github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLe
|
|||
github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/protobuf v3.14.0+incompatible/go.mod h1:lUQ9D1ePzbH2PrIS7ob/bjm9HXyH5WHB0Akwh7URreM=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/uuid v0.0.0-20161128191214-064e2069ce9c/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
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=
|
||||
|
@ -544,14 +557,21 @@ github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iU
|
|||
github.com/holiman/uint256 v1.1.1 h1:4JywC80b+/hSfljFlEBLHrrh+CIONLDz9NuFl0af4Mw=
|
||||
github.com/holiman/uint256 v1.1.1/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/huandu/xstrings v1.0.0/go.mod h1:4qWG/gcEcfX4z/mBDHJ++3ReCw9ibxbsNJbcucJdbSo=
|
||||
github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw=
|
||||
github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
||||
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
|
||||
github.com/huin/goupnp v1.0.0/go.mod h1:n9v9KO1tAxYH82qOn+UTIFQDmx5n1Zxd/ClZDMX7Bnc=
|
||||
github.com/huin/goupnp v1.0.1-0.20200620063722-49508fba0031/go.mod h1:nNs7wvRfN1eKaMknBydLNQU6146XQim8t4h+q90biWo=
|
||||
github.com/huin/goupnp v1.0.1-0.20210310174557-0ca763054c88 h1:bcAj8KroPf552TScjFPIakjH2/tdIrIH8F+cc4v4SRo=
|
||||
github.com/huin/goupnp v1.0.1-0.20210310174557-0ca763054c88/go.mod h1:nNs7wvRfN1eKaMknBydLNQU6146XQim8t4h+q90biWo=
|
||||
github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o=
|
||||
github.com/iancoleman/strcase v0.0.0-20180726023541-3605ed457bf7/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/imdario/mergo v0.3.4/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
|
||||
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
||||
github.com/improbable-eng/grpc-web v0.14.0/go.mod h1:6hRR09jOEG81ADP5wCQju1z71g6OL4eEvELdran/3cs=
|
||||
github.com/improbable-eng/grpc-web v0.14.1 h1:NrN4PY71A6tAz2sKDvC5JCauENWp0ykG8Oq1H3cpFvw=
|
||||
github.com/improbable-eng/grpc-web v0.14.1/go.mod h1:zEjGHa8DAlkoOXmswrNvhUGEYQA9UI7DhrGeHR1DMGU=
|
||||
|
@ -575,8 +595,8 @@ 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.4 h1:Aw3KPOKXjvrm6VjwJvFf1F1ekR/BH3jdof3Bk7OTiSA=
|
||||
github.com/ipfs/go-ipld-cbor v0.0.4/go.mod h1:BkCduEx3XBCO6t2Sfo5BaHzuok7hbhdMm9Oh8B2Ftq4=
|
||||
github.com/ipfs/go-ipld-cbor v0.0.5 h1:ovz4CHKogtG2KB/h1zUp5U0c/IzZrL435rCh5+K/5G8=
|
||||
github.com/ipfs/go-ipld-cbor v0.0.5/go.mod h1:BkCduEx3XBCO6t2Sfo5BaHzuok7hbhdMm9Oh8B2Ftq4=
|
||||
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 h1:6OvNmYgJyexcZ3pYbTI9jWx5tHo1Dee/tWbLMfPe2TA=
|
||||
|
@ -620,10 +640,8 @@ 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 h1:I/yrLt2WilKxlQKCM52clh5rGzTKpVctGT1lH4Dc8Jw=
|
||||
github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
|
||||
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/keybase/go-keychain v0.0.0-20200502122510-cda31fe0c86d h1:gVjhBCfVGl32RIBooOANzfw+0UqX8HU+yPlMv8vypcg=
|
||||
github.com/keybase/go-keychain v0.0.0-20200502122510-cda31fe0c86d/go.mod h1:W6EbaYmb4RldPn0N3gvVHjY1wmU59kbymhW9NATWhwY=
|
||||
github.com/keybase/go.dbus v0.0.0-20200324223359-a94be52c0b03/go.mod h1:a8clEhrrGV/d76/f9r2I41BwANMihfZYV9C223vaxqE=
|
||||
github.com/kilic/bls12-381 v0.0.0-20201226121925-69dacb279461/go.mod h1:vDTTHJONJ6G+P2R74EhnyotQDTliQDnFEwhdmfzw1ig=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
|
@ -667,6 +685,7 @@ github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoR
|
|||
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/lucasjones/reggen v0.0.0-20180717132126-cdb49ff09d77/go.mod h1:5ELEyG+X8f+meRWHuqUOewBOhvHkl7M76pdGEansxW4=
|
||||
github.com/lyft/protoc-gen-star v0.5.1/go.mod h1:9toiA3cC7z5uVbODF7kEQ91Xn7XNFkVUl+SrEe+ZORU=
|
||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls=
|
||||
|
@ -706,6 +725,8 @@ github.com/minio/sha256-simd v0.0.0-20190131020904-2d45a736cd16/go.mod h1:2FMWW+
|
|||
github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771 h1:MHkK1uRtFbVqvAgvWxafZe54+5uBxLluGylDiKgdhwo=
|
||||
github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM=
|
||||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
||||
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
|
||||
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
|
||||
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
|
||||
|
@ -716,6 +737,8 @@ github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh
|
|||
github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag=
|
||||
github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
|
||||
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
|
||||
github.com/moby/sys/mountinfo v0.4.1/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
|
@ -724,9 +747,8 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN
|
|||
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8=
|
||||
github.com/mr-tron/base58 v1.1.2 h1:ZEw4I2EgPKDJ2iEw0cNmLB3ROrEmkOtXIkaG7wZg+78=
|
||||
github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
|
||||
github.com/mr-tron/base58 v1.1.3 h1:v+sk57XuaCKGXpWtVBX8YJzO7hMGx4Aajh4TQbdEFdc=
|
||||
github.com/mr-tron/base58 v1.1.3/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=
|
||||
|
@ -736,14 +758,14 @@ github.com/multiformats/go-base32 v0.0.3/go.mod h1:pLiuGC8y0QR3Ue4Zug5UzK9LjgbkL
|
|||
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 h1:lMoNbh2Ssd9PUF74Nz008KGzGPlfeV6wH3rit5IIGCM=
|
||||
github.com/multiformats/go-multihash v0.0.10/go.mod h1:YSLudS+Pi8NHE7o6tb3D8vrpKa63epEDmG8nTduyAew=
|
||||
github.com/multiformats/go-multihash v0.0.14 h1:QoBceQYQQtNUuf6s7wHxnE2c8bhbMqhfGzNI032se/I=
|
||||
github.com/multiformats/go-multihash v0.0.14/go.mod h1:VdAWLKTwram9oKAatUcLxBNUjdtcVwxObEQBtRfuyjc=
|
||||
github.com/multiformats/go-varint v0.0.5 h1:XVZwSo04Cs3j/jS0uAEPpT3JY6DzMcVLLoWOSnCxOjg=
|
||||
github.com/multiformats/go-varint v0.0.5/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=
|
||||
github.com/mwitkow/go-proto-validators v0.0.0-20180403085117-0950a7990007/go.mod h1:m2XC9Qq0AlmmVksL6FktJCdTYyLk7V3fKyp0sl1yWQo=
|
||||
github.com/mwitkow/go-proto-validators v0.3.2 h1:qRlmpTzm2pstMKKzTdvwPCF5QfBNURSlAgN/R+qbKos=
|
||||
github.com/mwitkow/go-proto-validators v0.3.2/go.mod h1:ej0Qp0qMgHN/KtDyUt+Q1/tA7a5VarXUOUxD+oeD30w=
|
||||
github.com/mwitkow/grpc-proxy v0.0.0-20181017164139-0f1106ef9c76/go.mod h1:x5OoJHDHqxHS801UIuhqGl6QdSAEJvtausosHSdazIo=
|
||||
github.com/naoina/go-stringutil v0.1.0/go.mod h1:XJ2SJL9jCtBh+P9q5btrd/Ylo8XwT/h1USek5+NqSA0=
|
||||
github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E=
|
||||
|
@ -840,6 +862,7 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
|
|||
github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
|
||||
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
|
||||
github.com/pkg/term v0.0.0-20180730021639-bffc007b7fd5/go.mod h1:eCbImbZ95eXtAUIbLAuAVnBnwf83mjf6QIVH8SHYwqQ=
|
||||
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
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=
|
||||
|
@ -890,6 +913,10 @@ github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1
|
|||
github.com/prometheus/tsdb v0.6.2-0.20190402121629-4f204dcbc150/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
||||
github.com/prometheus/tsdb v0.7.1 h1:YZcsG11NqnK4czYLrWd9mpEuAJIHVQLwdrleYfszMAA=
|
||||
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
||||
github.com/pseudomuto/protoc-gen-doc v1.5.0 h1:pHZp0MEiT68jrZV8js8BS7E9ZEnlSLegoQbbtXj5lfo=
|
||||
github.com/pseudomuto/protoc-gen-doc v1.5.0/go.mod h1:exDTOVwqpp30eV/EDPFLZy3Pwr2sn6hBC1WIYH/UbIg=
|
||||
github.com/pseudomuto/protokit v0.2.0 h1:hlnBDcy3YEDXH7kc9gV+NLaN0cDzhDvD1s7Y6FZ8RpM=
|
||||
github.com/pseudomuto/protokit v0.2.0/go.mod h1:2PdH30hxVHsup8KpBTOXTBeMVhJZVio3Q8ViKSAXT0Q=
|
||||
github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ=
|
||||
github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||
|
@ -953,6 +980,8 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO
|
|||
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
|
||||
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4=
|
||||
github.com/spf13/afero v1.3.4/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
|
||||
github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY=
|
||||
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
|
||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
|
@ -992,6 +1021,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
|
|||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
|
||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||
github.com/stretchr/testify v0.0.0-20170130113145-4d4bfba8f1d1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.2.0/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
|
@ -1109,6 +1139,7 @@ go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
|||
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
|
||||
go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
|
||||
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20180501155221-613d6eafa307/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
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=
|
||||
|
@ -1125,7 +1156,6 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
|
|||
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
|
@ -1138,6 +1168,8 @@ golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWP
|
|||
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-20210920023735-84f357641f63 h1:kETrAMYZq6WVGPa8IIixL0CaEcIUNi+1WX7grUoi3y8=
|
||||
golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
|
@ -1255,6 +1287,7 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJ
|
|||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
|
@ -1474,6 +1507,7 @@ google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCID
|
|||
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20181107211654-5fc9ac540362/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
|
@ -1522,8 +1556,16 @@ google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6D
|
|||
google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A=
|
||||
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
|
||||
google.golang.org/genproto v0.0.0-20210929214142-896c89f843d2 h1:G7kbolbig6UyfoRItVUeBGV/38VzxjAZYTavVGbYYss=
|
||||
google.golang.org/genproto v0.0.0-20210929214142-896c89f843d2/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20210920155426-26f343e4c215 h1:bdVWLCdfDvdxf+qXZp5iip6vl2zJGgzhkULcsAiBNmE=
|
||||
google.golang.org/genproto v0.0.0-20210920155426-26f343e4c215/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20210921142501-181ce0d877f6 h1:2ncG/LajxmrclaZH+ppVi02rQxz4eXYJzGHdFN4Y9UA=
|
||||
google.golang.org/genproto v0.0.0-20210921142501-181ce0d877f6/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0 h1:5Tbluzus3QxoAJx4IefGt1W0HQZW4nuMrVk684jI74Q=
|
||||
google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20210930144712-2e2e1008e8a3 h1:+F3FcO6LTrzNq5wp1Z6JtoBvnJzX6euyN70FoyMDXy4=
|
||||
google.golang.org/genproto v0.0.0-20210930144712-2e2e1008e8a3/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20211001223012-bfb93cce50d9 h1:eF1wcrhdz56Vugf8qNX5dD93ItkrhothojQyHXqloe0=
|
||||
google.golang.org/genproto v0.0.0-20211001223012-bfb93cce50d9/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
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.0.1/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
|
||||
|
|
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 = "/ethermint/nameservice/v1/params";
|
||||
}
|
||||
// List records
|
||||
rpc ListRecords(QueryListRecordsRequest) returns (QueryListRecordsResponse){
|
||||
option (google.api.http).get = "/ethermint/nameservice/v1/records";
|
||||
}
|
||||
// Get record by id
|
||||
rpc GetRecord(QueryRecordByIdRequest) returns (QueryRecordByIdResponse){
|
||||
option (google.api.http).get = "/ethermint/nameservice/v1/records/{id}";
|
||||
}
|
||||
// Get records by bond id
|
||||
rpc GetRecordByBondId(QueryRecordByBondIdRequest) returns (QueryRecordByBondIdResponse){
|
||||
option (google.api.http).get = "/ethermint/nameservice/v1/records-by-bond-id/{id}";
|
||||
}
|
||||
// Get nameservice module balance
|
||||
rpc GetNameServiceModuleBalance(GetNameServiceModuleBalanceRequest) returns (GetNameServiceModuleBalanceResponse){
|
||||
option (google.api.http).get = "/ethermint/nameservice/v1/balance";
|
||||
}
|
||||
// List name records
|
||||
rpc ListNameRecords(QueryListNameRecordsRequest) returns (QueryListNameRecordsResponse){
|
||||
option (google.api.http).get = "/ethermint/nameservice/v1/names";
|
||||
}
|
||||
// Whois method retrieve the name authority info
|
||||
rpc Whois(QueryWhoisRequest) returns (QueryWhoisResponse){
|
||||
option (google.api.http).get = "/ethermint/nameservice/v1/whois/{name}";
|
||||
}
|
||||
// LookupWrn
|
||||
rpc LookupWrn(QueryLookupWrn) returns (QueryLookupWrnResponse){
|
||||
option (google.api.http).get = "/ethermint/nameservice/v1/lookup/{wrn}";
|
||||
}
|
||||
// ResolveWrn
|
||||
rpc ResolveWrn(QueryResolveWrn) returns (QueryResolveWrnResponse){
|
||||
option (google.api.http).get = "/ethermint/nameservice/v1/resolve/{wrn}";
|
||||
}
|
||||
// GetRecordExpiryQueue
|
||||
rpc GetRecordExpiryQueue(QueryGetRecordExpiryQueue) returns (QueryGetRecordExpiryQueueResponse){
|
||||
option (google.api.http).get = "/ethermint/nameservice/v1/record-expiry";
|
||||
}
|
||||
// GetAuthorityExpiryQueue
|
||||
rpc GetAuthorityExpiryQueue(QueryGetAuthorityExpiryQueue) returns (QueryGetAuthorityExpiryQueueResponse){
|
||||
option (google.api.http).get = "/ethermint/nameservice/v1/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{
|
||||
}
|
|
@ -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
|
||||
|
@ -49,6 +50,7 @@ func AddTxFlags(cmd *cobra.Command) *cobra.Command {
|
|||
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(
|
||||
|
|
|
@ -19,7 +19,7 @@ import (
|
|||
)
|
||||
|
||||
// CompletedAuctionDeleteTimeout => Completed auctions are deleted after this timeout (after reveals end time).
|
||||
const CompletedAuctionDeleteTimeout time.Duration = time.Hour * 24
|
||||
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.
|
||||
|
@ -55,16 +55,16 @@ type AuctionClientKeeper interface {
|
|||
}
|
||||
|
||||
// NewKeeper creates new instances of the auction Keeper
|
||||
func NewKeeper(accountKeeper auth.AccountKeeper, bankKeeper bank.Keeper, storeKey sdk.StoreKey, cdc codec.BinaryCodec, paramstore params.Subspace) Keeper {
|
||||
if !paramstore.HasKeyTable() {
|
||||
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
|
||||
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: paramstore,
|
||||
paramSubspace: ps,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -512,16 +512,13 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *types.Auction) {
|
|||
// 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
|
||||
}
|
||||
|
||||
|
@ -570,6 +567,7 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *types.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.")
|
||||
}
|
||||
|
||||
|
@ -594,6 +592,7 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *types.Auction) {
|
|||
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.")
|
||||
}
|
||||
|
||||
|
@ -607,6 +606,7 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *types.Auction) {
|
|||
// 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.")
|
||||
}
|
||||
|
||||
|
|
|
@ -63,9 +63,3 @@ func (bid Bid) GetCommitTime() string {
|
|||
func (bid Bid) GetRevealTime() string {
|
||||
return string(sdk.FormatTimeBytes(bid.RevealTime))
|
||||
}
|
||||
|
||||
// AuctionBidInfo is used in the block changeset.
|
||||
type AuctionBidInfo struct {
|
||||
AuctionID string
|
||||
BidderAddress string
|
||||
}
|
||||
|
|
|
@ -26,6 +26,9 @@ 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
|
||||
|
@ -34,7 +37,7 @@ type Keeper struct {
|
|||
}
|
||||
|
||||
// NewKeeper creates new instances of the bond Keeper
|
||||
func NewKeeper(cdc codec.BinaryCodec, accountKeeper auth.AccountKeeper, bankKeeper bank.Keeper, storeKey sdk.StoreKey, ps paramtypes.Subspace) 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())
|
||||
|
@ -45,6 +48,7 @@ func NewKeeper(cdc codec.BinaryCodec, accountKeeper auth.AccountKeeper, bankKeep
|
|||
bankKeeper: bankKeeper,
|
||||
storeKey: storeKey,
|
||||
cdc: cdc,
|
||||
usageKeepers: usageKeepers,
|
||||
paramSubspace: ps,
|
||||
}
|
||||
}
|
||||
|
@ -269,13 +273,12 @@ func (k Keeper) CancelBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddre
|
|||
return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.")
|
||||
}
|
||||
|
||||
// todo: continue this once nameservice is implemented
|
||||
// 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()))
|
||||
// }
|
||||
//}
|
||||
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)
|
||||
|
@ -300,3 +303,32 @@ func (k Keeper) GetBondModuleBalances(ctx sdk.Context) sdk.Coins {
|
|||
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
|
||||
}
|
||||
|
|
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
|
||||
}
|
340
x/nameservice/README.md
Normal file
340
x/nameservice/README.md
Normal file
|
@ -0,0 +1,340 @@
|
|||
# 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
|
||||
```
|
||||
|
||||
## Get Params
|
||||
|
||||
```bash
|
||||
$ ./build/ethermintd q nameservice params -o json | jq .
|
||||
{
|
||||
"params": {
|
||||
"record_rent": {
|
||||
"denom": "stake",
|
||||
"amount": "1000000"
|
||||
},
|
||||
|
||||
"record_rent_duration": "31536000s",
|
||||
"authority_rent": {
|
||||
"denom": "stake",
|
||||
"amount": "1000000"
|
||||
},
|
||||
"authority_rent_duration": "31536000s",
|
||||
"authority_grace_period": "172800s",
|
||||
"authority_auction_enabled": false,
|
||||
"authority_auction_commits_duration": "86400s",
|
||||
"authority_auction_reveals_duration": "86400s",
|
||||
"authority_auction_commit_fee": {
|
||||
"denom": "stake",
|
||||
"amount": "1000000"
|
||||
},
|
||||
"authority_auction_reveal_fee": {
|
||||
"denom": "stake",
|
||||
"amount": "1000000"
|
||||
},
|
||||
"authority_auction_minimum_bid": {
|
||||
"denom": "stake",
|
||||
"amount": "5000000"
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Create (Set) Record
|
||||
|
||||
> First you have to Create bond
|
||||
|
||||
```bash
|
||||
$ ./build/ethermintd tx nameservice set ~/Desktop/examples/records/example1.yml 95f68b1b862bfd1609b0c9aaf7300287b92fec90ac64027092c3e723af36e83d --from root --chain-id ethermint_9000-1 --yes -o json
|
||||
{
|
||||
"height": "0",
|
||||
"txhash": "BA44ABE1194724694E7CB290F9F3121DB4E63E1A030D95CB84813EEA132CF95F",
|
||||
"codespace": "",
|
||||
"code": 0,
|
||||
"data": "",
|
||||
"raw_log": "[]",
|
||||
"logs": [],
|
||||
"info": "",
|
||||
"gas_wanted": "0",
|
||||
"gas_used": "0",
|
||||
"tx": null,
|
||||
"timestamp": ""
|
||||
}
|
||||
```
|
||||
|
||||
## Get records list
|
||||
|
||||
```bash
|
||||
$ ./build/ethermintd q nameservice list -o json | jq
|
||||
[
|
||||
{
|
||||
"id": "bafyreih7un2ntk235wshncebus5emlozdhdixrrv675my5umb6fgdergae",
|
||||
"bondId": "c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440",
|
||||
"createTime": "2021-10-04T06:50:06.369025861Z",
|
||||
"expiryTime": "2022-10-04T06:50:06.369025861Z",
|
||||
"attributes": {
|
||||
"attr1": "value1",
|
||||
"attr2": "value2",
|
||||
"link1": {
|
||||
"/": "QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D"
|
||||
},
|
||||
"link2": {
|
||||
"/": "QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
```
|
||||
|
||||
## Get record by id
|
||||
|
||||
```bash
|
||||
$ ./build/ethermintd q nameservice get bafyreih7un2ntk235wshncebus5emlozdhdixrrv675my5umb6fgdergae -o json | jq .
|
||||
{
|
||||
"record": {
|
||||
"id": "bafyreih7un2ntk235wshncebus5emlozdhdixrrv675my5umb6fgdergae",
|
||||
"bond_id": "95f68b1b862bfd1609b0c9aaf7300287b92fec90ac64027092c3e723af36e83d",
|
||||
"create_time": "2021-09-27T07:23:25.558111606Z",
|
||||
"expiry_time": "2022-09-27T07:23:25.558111606Z",
|
||||
"deleted": false,
|
||||
"owners": [],
|
||||
"attributes": "eyJhdHRyMSI6InZhbHVlMSIsImF0dHIyIjoidmFsdWUyIiwibGluazEiOnsiLyI6IlFtU251V214cHRKWmRMSnBLUmFyeEJNUzJKdTJvQU5WcmdicjJ4V2JpZTliMkQifSwibGluazIiOnsiLyI6IlFtUDhqVEcxbTlHU0RKTENiZVdoVlNWZ0V6Q1BQd1hSZENSdUp0UTVUejlLYzkifX0="
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Reserve name
|
||||
|
||||
```bash
|
||||
./build/ethermintd tx nameservice reserve-name hello --from root --chain-id ethermint_9000-1 --owner $(./build/ethermintd key
|
||||
s show root -a) -y -o json | jq .
|
||||
{
|
||||
"height": "0",
|
||||
"txhash": "7EC19157AC89279DEBE840EA3384FC95D1E2A0931C27746CA42AC23AE285B7ED",
|
||||
"codespace": "",
|
||||
"code": 0,
|
||||
"data": "",
|
||||
"raw_log": "[]",
|
||||
"logs": [],
|
||||
"info": "",
|
||||
"gas_wanted": "0",
|
||||
"gas_used": "0",
|
||||
"tx": null,
|
||||
"timestamp": ""
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Query Whois for name authority
|
||||
|
||||
```bash
|
||||
./build/ethermintd q nameservice whois hello -o json | jq .
|
||||
{
|
||||
"name_authority": {
|
||||
"owner_public_key": "Au3hH1tzL1KgZfXfA71jGYSe5RV9Wg95kwhBWs8V+N+h",
|
||||
"owner_address": "ethm1mfdjngh5jvjs9lqtt9a7y2hlgw8v3syh3hsqzk",
|
||||
"height": "174",
|
||||
"status": "active",
|
||||
"auction_id": "",
|
||||
"bond_id": "",
|
||||
"expiry_time": "2021-09-29T07:34:36.304545965Z"
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Query the nameservice module balance
|
||||
|
||||
```bash
|
||||
$ ./build/ethermintd q nameservice balance -o json | jq .
|
||||
{
|
||||
"balances": [
|
||||
{
|
||||
"account_name": "record_rent",
|
||||
"balance": [
|
||||
{
|
||||
"denom": "stake",
|
||||
"amount": "1000000"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## add bond to the authority
|
||||
|
||||
```bash
|
||||
$ ./build/ethermintd tx nameservice authority-bond [Authority Name] [Bond ID ] --from root --chain-id ethermint_9000-1 -y -o json | jq .
|
||||
$ ./build/ethermintd tx nameservice authority-bond hello 95f68b1b862bfd1609b0c9aaf7300287b92fec90ac64027092c3e723af36e83d --from root --chain-id ethermint_9000-1 -y -o json | jq .
|
||||
```
|
||||
|
||||
## Query the records by associate bond id
|
||||
|
||||
```bash
|
||||
$ ./build/ethermintd q nameservice query-by-bond 95f68b1b862bfd1609b0c9aaf7300287b92fec90ac64027092c3e723af36e83d -o json | jq .
|
||||
{
|
||||
"records": [
|
||||
{
|
||||
"id": "bafyreih7un2ntk235wshncebus5emlozdhdixrrv675my5umb6fgdergae",
|
||||
"bond_id": "95f68b1b862bfd1609b0c9aaf7300287b92fec90ac64027092c3e723af36e83d",
|
||||
"create_time": "2021-09-27T08:25:32.893155609Z",
|
||||
"expiry_time": "2022-09-27T08:25:32.893155609Z",
|
||||
"deleted": false,
|
||||
"owners": [],
|
||||
"attributes": "eyJhdHRyMSI6InZhbHVlMSIsImF0dHIyIjoidmFsdWUyIiwibGluazEiOnsiLyI6IlFtU251V214cHRKWmRMSnBLUmFyeEJNUzJKdTJvQU5WcmdicjJ4V2JpZTliMkQifSwibGluazIiOnsiLyI6IlFtUDhqVEcxbTlHU0RKTENiZVdoVlNWZ0V6Q1BQd1hSZENSdUp0UTVUejlLYzkifX0="
|
||||
}
|
||||
],
|
||||
"pagination": null
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## dissociate bond from record
|
||||
|
||||
```bash
|
||||
$ ./build/ethermintd tx nameservice dissociate-bond bafyreih7un2ntk235wshncebus5emlozdhdixrrv675my5umb6fgdergae --from root --chain-id ethermint_9000-1
|
||||
{"body":{"messages":[{"@type":"/vulcanize.nameservice.v1beta1.MsgDissociateBond","record_id":"bafyreih7un2ntk235wshncebus5emlozdhdixrrv675my5umb6fgdergae","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: 7AFEF524CB0D92D6576FC08601A787786E802449888FD8DDAA7635698CC85060
|
||||
|
||||
```
|
||||
|
||||
## Associate bond with record
|
||||
|
||||
```bash
|
||||
./build/ethermintd tx nameservice associate-bond bafyreih7un2ntk235wshncebus5emlozdhdixrrv675my5umb6fgdergae c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440 --from root --chain-id ethermint_9000-1 -y -o json | jq .
|
||||
{
|
||||
"height": "0",
|
||||
"txhash": "F75C2BF2FE73668AE1332E1237F924AC549E31E822A56394DE5AC17200B199F9",
|
||||
"codespace": "",
|
||||
"code": 0,
|
||||
"data": "",
|
||||
"raw_log": "[]",
|
||||
"logs": [],
|
||||
"info": "",
|
||||
"gas_wanted": "0",
|
||||
"gas_used": "0",
|
||||
"tx": null,
|
||||
"timestamp": ""
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## dissociate-records => remove all record from bond
|
||||
|
||||
```bash
|
||||
$./build/ethermintd tx nameservice dissociate-records c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440 --from root --chain-id ethermint_9000-1 -y -o json | jq .
|
||||
{
|
||||
"height": "0",
|
||||
"txhash": "0316F503E5DEA47CB108AE6C7C7FFAF3F71CC56BC22F63CB97322E1BE48B33B9",
|
||||
"codespace": "",
|
||||
"code": 0,
|
||||
"data": "",
|
||||
"raw_log": "[]",
|
||||
"logs": [],
|
||||
"info": "",
|
||||
"gas_wanted": "0",
|
||||
"gas_used": "0",
|
||||
"tx": null,
|
||||
"timestamp": ""
|
||||
}
|
||||
```
|
||||
|
||||
## Renew a record
|
||||
|
||||
> When a record is expires , needs to renew record
|
||||
|
||||
```bash
|
||||
$ ./build/ethermintd tx nameservice renew-record bafyreih7un2ntk235wshncebus5emlozdhdixrrv675my5umb6fgdergae --from root --chain-id ethermint_9000-1
|
||||
|
||||
```
|
||||
|
||||
## Set the authority name
|
||||
|
||||
```bash
|
||||
$ ./build/ethermintd tx nameservice set-name wrn://hello/test test_hello_cid --from root --chain-id ethermint_9000-1 -y -o json | jq .
|
||||
{
|
||||
"height": "0",
|
||||
"txhash": "66A63C73B076EEE9A2F7605354448EDEB161F0115D4D03AF68C01BA28DB97486",
|
||||
"codespace": "",
|
||||
"code": 0,
|
||||
"data": "",
|
||||
"raw_log": "[]",
|
||||
"logs": [],
|
||||
"info": "",
|
||||
"gas_wanted": "0",
|
||||
"gas_used": "0",
|
||||
"tx": null,
|
||||
"timestamp": ""
|
||||
}
|
||||
```
|
||||
|
||||
## Delete the name
|
||||
|
||||
```bash
|
||||
$./build/ethermintd tx nameservice delete-name wrn://hello/test --from root --chain-id ethermint_9000-1 -y
|
||||
code: 0
|
||||
codespace: ""
|
||||
data: ""
|
||||
gas_used: "0"
|
||||
gas_wanted: "0"
|
||||
height: "0"
|
||||
info: ""
|
||||
logs: []
|
||||
raw_log: '[]'
|
||||
timestamp: ""
|
||||
tx: null
|
||||
txhash: A3FF4C46BAC7BD6E54BBB743A49830AE8C6F6FE59282384789CBA323C1FE540C
|
||||
|
||||
```
|
||||
|
||||
## List of Authorities Expire Queue
|
||||
|
||||
```bash
|
||||
$ ./build/ethermintd q nameservice authority-expiry -o json | jq .
|
||||
{
|
||||
"authorities": [],
|
||||
"pagination": null
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## List of Records Expire Queue
|
||||
|
||||
```bash
|
||||
$ ./build/ethermintd q nameservice record-expiry -o json | jq .
|
||||
{
|
||||
"records": [],
|
||||
"pagination": null
|
||||
}
|
||||
|
||||
```
|
17
x/nameservice/abci.go
Normal file
17
x/nameservice/abci.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
package nameservice
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tharsis/ethermint/x/nameservice/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{}
|
||||
}
|
397
x/nameservice/cli/query.go
Normal file
397
x/nameservice/cli/query.go
Normal file
|
@ -0,0 +1,397 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"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/nameservice/types"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// GetQueryCmd returns the cli query commands for this module
|
||||
func GetQueryCmd() *cobra.Command {
|
||||
bondQueryCmd := &cobra.Command{
|
||||
Use: types.ModuleName,
|
||||
Short: "Querying commands for the nameservice module",
|
||||
DisableFlagParsing: true,
|
||||
SuggestionsMinimumDistance: 2,
|
||||
RunE: client.ValidateCmd,
|
||||
}
|
||||
bondQueryCmd.AddCommand(
|
||||
GetCmdWhoIs(),
|
||||
GetCmdResolve(),
|
||||
GetCmdLookupWRN(),
|
||||
GetRecordExpiryQueue(),
|
||||
GetAuthorityExpiryQueue(),
|
||||
GetQueryParamsCmd(),
|
||||
GetCmdList(),
|
||||
GetCmdGetResource(),
|
||||
GetCmdQueryByBond(),
|
||||
GetCmdBalance(),
|
||||
GetCmdNames(),
|
||||
)
|
||||
return bondQueryCmd
|
||||
}
|
||||
|
||||
// GetCmdWhoIs queries a whois info for a name.
|
||||
func GetCmdWhoIs() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "whois [name]",
|
||||
Short: "Get name owner info.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Get name owner info.
|
||||
Example:
|
||||
$ %s query %s whois [name]
|
||||
`,
|
||||
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)
|
||||
res, err := queryClient.Whois(cmd.Context(), &types.QueryWhoisRequest{Name: args[0]})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdLookupWRN queries naming info for a WRN.
|
||||
func GetCmdLookupWRN() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "lookup [wrn]",
|
||||
Short: "Get naming info for WRN.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Get naming info for WRN.
|
||||
Example:
|
||||
$ %s query %s lookup [wrn]
|
||||
`,
|
||||
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)
|
||||
res, err := queryClient.LookupWrn(cmd.Context(), &types.QueryLookupWrn{Wrn: args[0]})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// GetCmdList queries all records.
|
||||
func GetCmdList() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List records.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Get the records.
|
||||
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.ListRecords(cmd.Context(), &types.QueryListRecordsRequest{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
recordsList := res.GetRecords()
|
||||
records := make([]types.RecordType, len(recordsList))
|
||||
for i, record := range res.GetRecords() {
|
||||
records[i] = record.ToRecordType()
|
||||
}
|
||||
bytesResult, err := json.Marshal(records)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return clientCtx.PrintBytes(bytesResult)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdGetResource queries a record record.
|
||||
func GetCmdGetResource() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "get [ID]",
|
||||
Short: "Get record.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Get the record by id.
|
||||
Example:
|
||||
$ %s query %s get [ID]
|
||||
`,
|
||||
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)
|
||||
record, err := queryClient.GetRecord(cmd.Context(), &types.QueryRecordByIdRequest{Id: args[0]})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return clientCtx.PrintProto(record)
|
||||
},
|
||||
}
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdResolve resolves a WRN to a record.
|
||||
func GetCmdResolve() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "resolve [wrn]",
|
||||
Short: "Resolve WRN to record.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Resolve WRN to record.
|
||||
Example:
|
||||
$ %s query %s resolve [wrn]
|
||||
`,
|
||||
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)
|
||||
record, err := queryClient.ResolveWrn(cmd.Context(), &types.QueryResolveWrn{Wrn: args[0]})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return clientCtx.PrintProto(record)
|
||||
},
|
||||
}
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdQueryByBond queries records by bond ID.
|
||||
func GetCmdQueryByBond() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "query-by-bond [bond-id]",
|
||||
Short: "Query records by bond ID.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Get the record by bond id.
|
||||
Example:
|
||||
$ %s query %s query-by-bond [bond id]
|
||||
`,
|
||||
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)
|
||||
|
||||
bondID := args[0]
|
||||
res, err := queryClient.GetRecordByBondId(cmd.Context(), &types.QueryRecordByBondIdRequest{Id: bondID})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return clientCtx.PrintProto(res)
|
||||
|
||||
},
|
||||
}
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdBalance queries the bond module account balance.
|
||||
func GetCmdBalance() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "balance",
|
||||
Short: "Get record rent module account balance.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Get the record rent module account 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.GetNameServiceModuleBalance(cmd.Context(), &types.GetNameServiceModuleBalanceRequest{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdNames queries all naming records.
|
||||
func GetCmdNames() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "names",
|
||||
Short: "List name records.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Get the names list.
|
||||
Example:
|
||||
$ %s query %s names
|
||||
`,
|
||||
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.ListNameRecords(cmd.Context(), &types.QueryListNameRecordsRequest{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetRecordExpiryQueue gets the record expiry queue.
|
||||
func GetRecordExpiryQueue() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "record-expiry",
|
||||
Short: "Get record expiry queue.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Get record expiry queue.
|
||||
Example:
|
||||
$ %s query %s record-expiry
|
||||
`,
|
||||
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.GetRecordExpiryQueue(cmd.Context(), &types.QueryGetRecordExpiryQueue{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetAuthorityExpiryQueue gets the authority expiry queue.
|
||||
func GetAuthorityExpiryQueue() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "authority-expiry",
|
||||
Short: "Get authority expiry queue.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Get authority expiry queue.
|
||||
Example:
|
||||
$ %s query %s authority-expiry
|
||||
`,
|
||||
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.GetAuthorityExpiryQueue(cmd.Context(), &types.QueryGetAuthorityExpiryQueue{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
388
x/nameservice/cli/tx.go
Normal file
388
x/nameservice/cli/tx.go
Normal file
|
@ -0,0 +1,388 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/tharsis/ethermint/server/flags"
|
||||
"github.com/tharsis/ethermint/x/nameservice/types"
|
||||
"gopkg.in/yaml.v3"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// NewTxCmd returns a root CLI command handler for all x/bond transaction commands.
|
||||
func NewTxCmd() *cobra.Command {
|
||||
bondTxCmd := &cobra.Command{
|
||||
Use: types.ModuleName,
|
||||
Short: "nameservice transaction subcommands",
|
||||
DisableFlagParsing: true,
|
||||
SuggestionsMinimumDistance: 2,
|
||||
RunE: client.ValidateCmd,
|
||||
}
|
||||
|
||||
bondTxCmd.AddCommand(
|
||||
GetCmdSetRecord(),
|
||||
GetCmdRenewRecord(),
|
||||
GetCmdAssociateBond(),
|
||||
GetCmdDissociateBond(),
|
||||
GetCmdDissociateRecords(),
|
||||
GetCmdReAssociateRecords(),
|
||||
GetCmdSetName(),
|
||||
GetCmdReserveName(),
|
||||
GetCmdSetAuthorityBond(),
|
||||
GetCmdDeleteName(),
|
||||
)
|
||||
|
||||
return bondTxCmd
|
||||
}
|
||||
|
||||
// GetCmdSetRecord is the CLI command for creating/updating a record.
|
||||
func GetCmdSetRecord() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "set [payload file path] [bond-id]",
|
||||
Short: "Set record.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Create a new record with payload and bond id.
|
||||
Example:
|
||||
$ %s tx %s set [payload file path] [bond-id]
|
||||
`,
|
||||
version.AppName, types.ModuleName,
|
||||
),
|
||||
),
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
payload, err := getPayloadFromFile(args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
msg := types.NewMsgSetRecord(payload.ToPayload(), args[1], clientCtx.GetFromAddress())
|
||||
err = msg.ValidateBasic()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdRenewRecord is the CLI command for renewing an expired record.
|
||||
func GetCmdRenewRecord() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "renew-record [record-id]",
|
||||
Short: "Renew (expired) record.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Renew record.
|
||||
Example:
|
||||
$ %s tx %s renew-record [record-id]
|
||||
`,
|
||||
version.AppName, types.ModuleName,
|
||||
),
|
||||
),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
msg := types.NewMsgRenewRecord(args[0], clientCtx.GetFromAddress())
|
||||
err = msg.ValidateBasic()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdAssociateBond is the CLI command for associating a record with a bond.
|
||||
func GetCmdAssociateBond() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "associate-bond [record-id] [bond-id]",
|
||||
Short: "Associate record with bond.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Associate record with bond.
|
||||
Example:
|
||||
$ %s tx %s associate-bond [record-id] [bond-id]
|
||||
`,
|
||||
version.AppName, types.ModuleName,
|
||||
),
|
||||
),
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
msg := types.NewMsgAssociateBond(args[0], args[1], clientCtx.GetFromAddress())
|
||||
err = msg.ValidateBasic()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdDissociateBond is the CLI command for dissociating a record from a bond.
|
||||
func GetCmdDissociateBond() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "dissociate-bond [record-id]",
|
||||
Short: "Dissociate record from (existing) bond.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Dissociate record from (existing) bond.
|
||||
Example:
|
||||
$ %s tx %s dissociate-bond [record-id]
|
||||
`,
|
||||
version.AppName, types.ModuleName,
|
||||
),
|
||||
),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
msg := types.NewMsgDissociateBond(args[0], clientCtx.GetFromAddress())
|
||||
err = msg.ValidateBasic()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdDissociateRecords is the CLI command for dissociating all records from a bond.
|
||||
func GetCmdDissociateRecords() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "dissociate-records [bond-id]",
|
||||
Short: "Dissociate all records from bond.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Dissociate all records from bond.
|
||||
Example:
|
||||
$ %s tx %s dissociate-bond [record-id]
|
||||
`,
|
||||
version.AppName, types.ModuleName,
|
||||
),
|
||||
),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
msg := types.NewMsgDissociateRecords(args[0], clientCtx.GetFromAddress())
|
||||
err = msg.ValidateBasic()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdReAssociateRecords is the CLI command for reassociating all records from old to new bond.
|
||||
func GetCmdReAssociateRecords() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "reassociate-records [old-bond-id] [new-bond-id]",
|
||||
Short: "Re-Associates all records from old to new bond.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Re-Associates all records from old to new bond.
|
||||
Example:
|
||||
$ %s tx %s reassociate-records [old-bond-id] [new-bond-id]
|
||||
`,
|
||||
version.AppName, types.ModuleName,
|
||||
),
|
||||
),
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
msg := types.NewMsgReAssociateRecords(args[0], args[1], clientCtx.GetFromAddress())
|
||||
err = msg.ValidateBasic()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdSetName is the CLI command for mapping a name to a CID.
|
||||
func GetCmdSetName() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "set-name [wrn] [cid]",
|
||||
Short: "Set WRN to CID mapping.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Set name with wrn and cid.
|
||||
Example:
|
||||
$ %s tx %s set-name [wrn] [cid]
|
||||
`,
|
||||
version.AppName, types.ModuleName,
|
||||
),
|
||||
),
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
msg := types.NewMsgSetName(args[0], args[1], clientCtx.GetFromAddress())
|
||||
err = msg.ValidateBasic()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdReserveName is the CLI command for reserving a name.
|
||||
func GetCmdReserveName() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "reserve-name [name]",
|
||||
Short: "Reserve name.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Reserver name with owner address .
|
||||
Example:
|
||||
$ %s tx %s reserve-name [name] --owner [ownerAddress]
|
||||
`,
|
||||
version.AppName, types.ModuleName,
|
||||
),
|
||||
),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
owner, err := cmd.Flags().GetString("owner")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ownerAddress, err := sdk.AccAddressFromBech32(owner)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
msg := types.NewMsgReserveAuthority(args[0], clientCtx.GetFromAddress(), ownerAddress)
|
||||
err = msg.ValidateBasic()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().String("owner", "", "Owner address, if creating a sub-authority.")
|
||||
|
||||
flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdSetAuthorityBond is the CLI command for associating a bond with an authority.
|
||||
func GetCmdSetAuthorityBond() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "authority-bond [name] [bond-id]",
|
||||
Short: "Associate authority with bond.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Reserver name with owner address .
|
||||
Example:
|
||||
$ %s tx %s authority-bond [name] [bond-id]
|
||||
`,
|
||||
version.AppName, types.ModuleName,
|
||||
),
|
||||
),
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
msg := types.NewMsgSetAuthorityBond(args[0], args[1], clientCtx.GetFromAddress())
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func GetCmdDeleteName() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "delete-name [wrn]",
|
||||
Short: "Delete WRN.",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Delete WRN.
|
||||
Example:
|
||||
$ %s tx %s delete-name [wrn]
|
||||
`,
|
||||
version.AppName, types.ModuleName,
|
||||
),
|
||||
),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
msg := types.NewMsgDeleteNameAuthority(args[0], clientCtx.GetFromAddress())
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// Load payload object from YAML file.
|
||||
func getPayloadFromFile(filePath string) (*types.PayloadType, error) {
|
||||
var payload types.PayloadType
|
||||
|
||||
data, err := ioutil.ReadFile(filePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = yaml.Unmarshal(data, &payload)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &payload, nil
|
||||
}
|
71
x/nameservice/genesis.go
Normal file
71
x/nameservice/genesis.go
Normal file
|
@ -0,0 +1,71 @@
|
|||
package nameservice
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tharsis/ethermint/x/nameservice/keeper"
|
||||
"github.com/tharsis/ethermint/x/nameservice/types"
|
||||
)
|
||||
|
||||
func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, data types.GenesisState) []abci.ValidatorUpdate {
|
||||
keeper.SetParams(ctx, data.Params)
|
||||
|
||||
for _, record := range data.Records {
|
||||
keeper.PutRecord(ctx, record)
|
||||
|
||||
// Add to record expiry queue if expiry time is in the future.
|
||||
if record.ExpiryTime.After(ctx.BlockTime()) {
|
||||
keeper.InsertRecordExpiryQueue(ctx, record)
|
||||
}
|
||||
|
||||
// Note: Bond genesis runs first, so bonds will already be present.
|
||||
if record.BondId != "" {
|
||||
keeper.AddBondToRecordIndexEntry(ctx, record.BondId, record.Id)
|
||||
}
|
||||
}
|
||||
|
||||
for _, authority := range data.Authorities {
|
||||
//Only import authorities that are marked active.
|
||||
if authority.Entry.Status == types.AuthorityActive {
|
||||
keeper.SetNameAuthority(ctx, authority.Name, authority.Entry)
|
||||
|
||||
// Add authority name to expiry queue.
|
||||
keeper.InsertAuthorityExpiryQueue(ctx, authority.Name, authority.Entry.ExpiryTime)
|
||||
|
||||
// Note: Bond genesis runs first, so bonds will already be present.
|
||||
if authority.Entry.BondId != "" {
|
||||
keeper.AddBondToAuthorityIndexEntry(ctx, authority.Entry.BondId, authority.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, nameEntry := range data.Names {
|
||||
keeper.SetNameRecord(ctx, nameEntry.Name, nameEntry.Entry.Latest.Id)
|
||||
}
|
||||
|
||||
return []abci.ValidatorUpdate{}
|
||||
}
|
||||
|
||||
func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) types.GenesisState {
|
||||
params := keeper.GetParams(ctx)
|
||||
|
||||
records := keeper.ListRecords(ctx)
|
||||
|
||||
authorities := keeper.ListNameAuthorityRecords(ctx)
|
||||
var authorityEntries []types.AuthorityEntry
|
||||
for name, record := range authorities {
|
||||
authorityEntries = append(authorityEntries, types.AuthorityEntry{
|
||||
Name: name,
|
||||
Entry: &record,
|
||||
})
|
||||
}
|
||||
|
||||
names := keeper.ListNameRecords(ctx)
|
||||
|
||||
return types.GenesisState{
|
||||
Params: params,
|
||||
Records: records,
|
||||
Authorities: authorityEntries,
|
||||
Names: names,
|
||||
}
|
||||
}
|
144
x/nameservice/helpers/helpers.go
Normal file
144
x/nameservice/helpers/helpers.go
Normal file
|
@ -0,0 +1,144 @@
|
|||
package helpers
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/binary"
|
||||
"encoding/gob"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
set "github.com/deckarep/golang-set"
|
||||
cbor "github.com/ipfs/go-ipld-cbor"
|
||||
mh "github.com/multiformats/go-multihash"
|
||||
|
||||
"sort"
|
||||
)
|
||||
|
||||
func StringToBytes(val string) []byte {
|
||||
return []byte(val)
|
||||
}
|
||||
|
||||
func BytesToString(val []byte) string {
|
||||
return string(val)
|
||||
}
|
||||
|
||||
func StrArrToBytesArr(val []string) ([]byte, error) {
|
||||
buffer := &bytes.Buffer{}
|
||||
|
||||
err := gob.NewEncoder(buffer).Encode(val)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return buffer.Bytes(), nil
|
||||
}
|
||||
|
||||
func BytesArrToStringArr(val []byte) ([]string, error) {
|
||||
buffer := bytes.NewReader(val)
|
||||
var v []string
|
||||
err := gob.NewDecoder(buffer).Decode(&v)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
func Int64ToBytes(num int64) []byte {
|
||||
buf := new(bytes.Buffer)
|
||||
binary.Write(buf, binary.BigEndian, num)
|
||||
return buf.Bytes()
|
||||
}
|
||||
|
||||
// MarshalMapToJSONBytes converts map[string]interface{} to bytes.
|
||||
func MarshalMapToJSONBytes(val map[string]interface{}) (bytes []byte) {
|
||||
bytes, err := json.Marshal(val)
|
||||
if err != nil {
|
||||
panic("Marshal error.")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UnMarshalMapFromJSONBytes converts bytes to map[string]interface{}.
|
||||
func UnMarshalMapFromJSONBytes(bytes []byte) map[string]interface{} {
|
||||
var val map[string]interface{}
|
||||
err := json.Unmarshal(bytes, &val)
|
||||
|
||||
if err != nil {
|
||||
panic("Marshal error.")
|
||||
}
|
||||
|
||||
return val
|
||||
}
|
||||
|
||||
// GetCid gets the content ID.
|
||||
func GetCid(content []byte) (string, error) {
|
||||
node, err := cbor.FromJSON(bytes.NewReader(content), mh.SHA2_256, -1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return node.Cid().String(), nil
|
||||
}
|
||||
|
||||
// BytesToBase64 encodes a byte array as a base64 string.
|
||||
func BytesToBase64(bytes []byte) string {
|
||||
return base64.StdEncoding.EncodeToString(bytes)
|
||||
}
|
||||
|
||||
// BytesFromBase64 decodes a byte array from a base64 string.
|
||||
func BytesFromBase64(str string) []byte {
|
||||
bytes, err := base64.StdEncoding.DecodeString(str)
|
||||
if err != nil {
|
||||
panic("Error decoding string to bytes.")
|
||||
}
|
||||
|
||||
return bytes
|
||||
}
|
||||
|
||||
// BytesToHex encodes a byte array as a hex string.
|
||||
func BytesToHex(bytes []byte) string {
|
||||
return hex.EncodeToString(bytes)
|
||||
}
|
||||
|
||||
// BytesFromHex decodes a byte array from a hex string.
|
||||
func BytesFromHex(str string) []byte {
|
||||
bytes, err := hex.DecodeString(str)
|
||||
if err != nil {
|
||||
panic("Error decoding hex to bytes.")
|
||||
}
|
||||
|
||||
return 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)
|
||||
}
|
97
x/nameservice/keeper/grpc_query.go
Normal file
97
x/nameservice/keeper/grpc_query.go
Normal file
|
@ -0,0 +1,97 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/tharsis/ethermint/x/nameservice/types"
|
||||
)
|
||||
|
||||
type Querier struct {
|
||||
Keeper
|
||||
}
|
||||
|
||||
var _ types.QueryServer = Querier{}
|
||||
|
||||
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) ListRecords(c context.Context, _ *types.QueryListRecordsRequest) (*types.QueryListRecordsResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
records := q.Keeper.ListRecords(ctx)
|
||||
return &types.QueryListRecordsResponse{Records: records}, nil
|
||||
}
|
||||
|
||||
func (q Querier) GetRecord(c context.Context, req *types.QueryRecordByIdRequest) (*types.QueryRecordByIdResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
id := req.GetId()
|
||||
if !q.Keeper.HasRecord(ctx, id) {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "Record not found.")
|
||||
}
|
||||
record := q.Keeper.GetRecord(ctx, id)
|
||||
return &types.QueryRecordByIdResponse{Record: record}, nil
|
||||
}
|
||||
|
||||
func (q Querier) GetRecordByBondId(c context.Context, req *types.QueryRecordByBondIdRequest) (*types.QueryRecordByBondIdResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
records := q.recordKeeper.QueryRecordsByBond(ctx, req.GetId())
|
||||
return &types.QueryRecordByBondIdResponse{Records: records}, nil
|
||||
}
|
||||
|
||||
func (q Querier) GetNameServiceModuleBalance(c context.Context, _ *types.GetNameServiceModuleBalanceRequest) (*types.GetNameServiceModuleBalanceResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
balances := q.Keeper.GetModuleBalances(ctx)
|
||||
return &types.GetNameServiceModuleBalanceResponse{
|
||||
Balances: balances,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (q Querier) ListNameRecords(c context.Context, _ *types.QueryListNameRecordsRequest) (*types.QueryListNameRecordsResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
nameRecords := q.Keeper.ListNameRecords(ctx)
|
||||
return &types.QueryListNameRecordsResponse{Names: nameRecords}, nil
|
||||
}
|
||||
|
||||
func (q Querier) Whois(c context.Context, request *types.QueryWhoisRequest) (*types.QueryWhoisResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
nameAuthority := q.Keeper.GetNameAuthority(ctx, request.GetName())
|
||||
return &types.QueryWhoisResponse{NameAuthority: *nameAuthority}, nil
|
||||
}
|
||||
|
||||
func (q Querier) LookupWrn(c context.Context, req *types.QueryLookupWrn) (*types.QueryLookupWrnResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
wrn := req.GetWrn()
|
||||
if !q.Keeper.HasNameRecord(ctx, wrn) {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "WRN not found.")
|
||||
}
|
||||
nameRecord := q.Keeper.GetNameRecord(ctx, wrn)
|
||||
if nameRecord == nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "name record not found.")
|
||||
}
|
||||
return &types.QueryLookupWrnResponse{Name: nameRecord}, nil
|
||||
}
|
||||
|
||||
func (q Querier) ResolveWrn(c context.Context, req *types.QueryResolveWrn) (*types.QueryResolveWrnResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
wrn := req.GetWrn()
|
||||
record := q.Keeper.ResolveWRN(ctx, wrn)
|
||||
if record == nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "record not found.")
|
||||
}
|
||||
return &types.QueryResolveWrnResponse{Record: record}, nil
|
||||
}
|
||||
|
||||
func (q Querier) GetRecordExpiryQueue(c context.Context, _ *types.QueryGetRecordExpiryQueue) (*types.QueryGetRecordExpiryQueueResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
records := q.Keeper.GetRecordExpiryQueue(ctx)
|
||||
return &types.QueryGetRecordExpiryQueueResponse{Records: records}, nil
|
||||
}
|
||||
|
||||
func (q Querier) GetAuthorityExpiryQueue(c context.Context, _ *types.QueryGetAuthorityExpiryQueue) (*types.QueryGetAuthorityExpiryQueueResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
authorities := q.Keeper.GetAuthorityExpiryQueue(ctx)
|
||||
return &types.QueryGetAuthorityExpiryQueueResponse{Authorities: authorities}, nil
|
||||
}
|
36
x/nameservice/keeper/invariants.go
Normal file
36
x/nameservice/keeper/invariants.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/tharsis/ethermint/x/nameservice/types"
|
||||
)
|
||||
|
||||
// RegisterInvariants registers all nameservice module invariants.
|
||||
func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper) {
|
||||
ir.RegisterRoute(types.ModuleName, "record", RecordInvariants(k))
|
||||
}
|
||||
|
||||
// RecordInvariants checks that every record:
|
||||
// (1) has a corresponding naming record &
|
||||
// (2) associated bond exists, if bondID is not null.
|
||||
func RecordInvariants(k Keeper) sdk.Invariant {
|
||||
return func(ctx sdk.Context) (string, bool) {
|
||||
//store := ctx.KVStore(k.storeKey)
|
||||
//itr := sdk.KVStorePrefixIterator(store, PrefixCIDToRecordIndex)
|
||||
//defer itr.Close()
|
||||
//for ; itr.Valid(); itr.Next() {
|
||||
// bz := store.Get(itr.Key())
|
||||
// if bz != nil {
|
||||
// var obj types.RecordObj
|
||||
// k.cdc.MustUnmarshalBinaryBare(bz, &obj)
|
||||
// record := obj.ToRecord()
|
||||
//
|
||||
// if record.BondID != "" && !k.bondKeeper.HasBond(ctx, record.BondID) {
|
||||
// return sdk.FormatInvariant(types.ModuleName, "record-bond", fmt.Sprintf("Bond not found for record ID: '%s'.", record.ID)), true
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
return "", false
|
||||
}
|
||||
}
|
296
x/nameservice/keeper/keeper.go
Normal file
296
x/nameservice/keeper/keeper.go
Normal file
|
@ -0,0 +1,296 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/codec/legacy"
|
||||
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"
|
||||
auctionkeeper "github.com/tharsis/ethermint/x/auction/keeper"
|
||||
bondkeeper "github.com/tharsis/ethermint/x/bond/keeper"
|
||||
"github.com/tharsis/ethermint/x/nameservice/helpers"
|
||||
"github.com/tharsis/ethermint/x/nameservice/types"
|
||||
"sort"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
// PrefixCIDToRecordIndex is the prefix for CID -> Record index.
|
||||
// Note: This is the primary index in the system.
|
||||
// Note: Golang doesn't support const arrays.
|
||||
PrefixCIDToRecordIndex = []byte{0x00}
|
||||
|
||||
// PrefixNameAuthorityRecordIndex is the prefix for the name -> NameAuthority index.
|
||||
PrefixNameAuthorityRecordIndex = []byte{0x01}
|
||||
|
||||
// PrefixWRNToNameRecordIndex is the prefix for the WRN -> NamingRecord index.
|
||||
PrefixWRNToNameRecordIndex = []byte{0x02}
|
||||
|
||||
// PrefixBondIDToRecordsIndex is the prefix for the Bond ID -> [Record] index.
|
||||
PrefixBondIDToRecordsIndex = []byte{0x03}
|
||||
|
||||
// PrefixBlockChangesetIndex is the prefix for the block changeset index.
|
||||
PrefixBlockChangesetIndex = []byte{0x04}
|
||||
|
||||
// PrefixAuctionToAuthorityNameIndex is the prefix for the auction ID -> authority name index.
|
||||
PrefixAuctionToAuthorityNameIndex = []byte{0x05}
|
||||
|
||||
// PrefixBondIDToAuthoritiesIndex is the prefix for the Bond ID -> [Authority] index.
|
||||
PrefixBondIDToAuthoritiesIndex = []byte{0x06}
|
||||
|
||||
// PrefixExpiryTimeToRecordsIndex is the prefix for the Expiry Time -> [Record] index.
|
||||
PrefixExpiryTimeToRecordsIndex = []byte{0x10}
|
||||
|
||||
// PrefixExpiryTimeToAuthoritiesIndex is the prefix for the Expiry Time -> [Authority] index.
|
||||
PrefixExpiryTimeToAuthoritiesIndex = []byte{0x11}
|
||||
|
||||
// PrefixCIDToNamesIndex the the reverse index for naming, i.e. maps CID -> []Names.
|
||||
// TODO(ashwin): Move out of WNS once we have an indexing service.
|
||||
PrefixCIDToNamesIndex = []byte{0xe0}
|
||||
)
|
||||
|
||||
// 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
|
||||
recordKeeper RecordKeeper
|
||||
bondKeeper bondkeeper.Keeper
|
||||
auctionKeeper auctionkeeper.Keeper
|
||||
|
||||
storeKey sdk.StoreKey // Unexposed key to access store from sdk.Context
|
||||
|
||||
cdc codec.BinaryCodec // The wire codec for binary encoding/decoding.
|
||||
|
||||
paramSubspace paramtypes.Subspace
|
||||
}
|
||||
|
||||
// NewKeeper creates new instances of the nameservice Keeper
|
||||
func NewKeeper(cdc codec.BinaryCodec, accountKeeper auth.AccountKeeper, bankKeeper bank.Keeper, recordKeeper RecordKeeper,
|
||||
bondKeeper bondkeeper.Keeper, auctionKeeper auctionkeeper.Keeper, 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,
|
||||
recordKeeper: recordKeeper,
|
||||
bondKeeper: bondKeeper,
|
||||
auctionKeeper: auctionKeeper,
|
||||
storeKey: storeKey,
|
||||
cdc: cdc,
|
||||
paramSubspace: ps,
|
||||
}
|
||||
}
|
||||
|
||||
// GetRecordIndexKey Generates Bond ID -> Bond index key.
|
||||
func GetRecordIndexKey(id string) []byte {
|
||||
return append(PrefixCIDToRecordIndex, []byte(id)...)
|
||||
}
|
||||
|
||||
// HasRecord - checks if a record by the given ID exists.
|
||||
func (k Keeper) HasRecord(ctx sdk.Context, id string) bool {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
return store.Has(GetRecordIndexKey(id))
|
||||
}
|
||||
|
||||
// GetRecord - gets a record from the store.
|
||||
func (k Keeper) GetRecord(ctx sdk.Context, id string) (record types.Record) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
result := store.Get(GetRecordIndexKey(id))
|
||||
k.cdc.MustUnmarshal(result, &record)
|
||||
return record
|
||||
}
|
||||
|
||||
// ListRecords - get all records.
|
||||
func (k Keeper) ListRecords(ctx sdk.Context) []types.Record {
|
||||
var records []types.Record
|
||||
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
itr := sdk.KVStorePrefixIterator(store, PrefixCIDToRecordIndex)
|
||||
defer itr.Close()
|
||||
for ; itr.Valid(); itr.Next() {
|
||||
bz := store.Get(itr.Key())
|
||||
if bz != nil {
|
||||
var obj types.Record
|
||||
k.cdc.MustUnmarshal(bz, &obj)
|
||||
//records = append(records, recordObjToRecord(store, k.cdc, obj))
|
||||
records = append(records, obj)
|
||||
}
|
||||
}
|
||||
|
||||
return records
|
||||
}
|
||||
|
||||
func (k Keeper) GetRecordExpiryQueue(ctx sdk.Context) []*types.ExpiryQueueRecord {
|
||||
var records []*types.ExpiryQueueRecord
|
||||
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
itr := sdk.KVStorePrefixIterator(store, PrefixExpiryTimeToRecordsIndex)
|
||||
defer itr.Close()
|
||||
for ; itr.Valid(); itr.Next() {
|
||||
var record []string
|
||||
err := json.Unmarshal(itr.Value(), &record)
|
||||
if err != nil {
|
||||
return records
|
||||
}
|
||||
records = append(records, &types.ExpiryQueueRecord{
|
||||
Id: string(itr.Key()[len(PrefixExpiryTimeToRecordsIndex):]),
|
||||
Value: record,
|
||||
})
|
||||
}
|
||||
|
||||
return records
|
||||
}
|
||||
|
||||
// ProcessSetRecord creates a record.
|
||||
func (k Keeper) ProcessSetRecord(ctx sdk.Context, msg types.MsgSetRecord) error {
|
||||
payload := msg.Payload.ToReadablePayload()
|
||||
record := types.RecordType{Attributes: payload.Record, BondId: msg.BondId}
|
||||
|
||||
// Check signatures.
|
||||
resourceSignBytes, _ := record.GetSignBytes()
|
||||
cid, err := record.GetCID()
|
||||
if err != nil {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid record JSON")
|
||||
}
|
||||
|
||||
record.Id = cid
|
||||
|
||||
if exists := k.HasRecord(ctx, record.Id); exists {
|
||||
return nil
|
||||
}
|
||||
|
||||
record.Owners = []string{}
|
||||
for _, sig := range payload.Signatures {
|
||||
pubKey, err := legacy.PubKeyFromBytes(helpers.BytesFromBase64(sig.PubKey))
|
||||
if err != nil {
|
||||
fmt.Println("Error decoding pubKey from bytes: ", err)
|
||||
return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Invalid public key.")
|
||||
}
|
||||
|
||||
sigOK := pubKey.VerifySignature(resourceSignBytes, helpers.BytesFromBase64(sig.Sig))
|
||||
if !sigOK {
|
||||
fmt.Println("Signature mismatch: ", sig.PubKey)
|
||||
return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Invalid signature.")
|
||||
}
|
||||
record.Owners = append(record.Owners, pubKey.Address().String())
|
||||
}
|
||||
|
||||
// Sort owners list.
|
||||
sort.Strings(record.Owners)
|
||||
sdkErr := k.processRecord(ctx, &record, false)
|
||||
if sdkErr != nil {
|
||||
return sdkErr
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (k Keeper) processRecord(ctx sdk.Context, record *types.RecordType, isRenewal bool) error {
|
||||
params := k.GetParams(ctx)
|
||||
rent := params.RecordRent
|
||||
|
||||
err := k.bondKeeper.TransferCoinsToModuleAccount(ctx, record.BondId, types.RecordRentModuleAccountName, sdk.NewCoins(rent))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
record.CreateTime = ctx.BlockHeader().Time
|
||||
record.ExpiryTime = ctx.BlockHeader().Time.Add(params.RecordRentDuration)
|
||||
record.Deleted = false
|
||||
|
||||
k.PutRecord(ctx, record.ToRecordObj())
|
||||
k.InsertRecordExpiryQueue(ctx, record.ToRecordObj())
|
||||
|
||||
// Renewal doesn't change the name and bond indexes.
|
||||
if !isRenewal {
|
||||
k.AddBondToRecordIndexEntry(ctx, record.BondId, record.Id)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// PutRecord - saves a record to the store and updates ID -> Record index.
|
||||
func (k Keeper) PutRecord(ctx sdk.Context, record types.Record) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
store.Set(GetRecordIndexKey(record.Id), k.cdc.MustMarshal(&record))
|
||||
k.updateBlockChangeSetForRecord(ctx, record.Id)
|
||||
}
|
||||
|
||||
// AddBondToRecordIndexEntry adds the Bond ID -> [Record] index entry.
|
||||
func (k Keeper) AddBondToRecordIndexEntry(ctx sdk.Context, bondID string, id string) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
store.Set(getBondIDToRecordsIndexKey(bondID, id), []byte{})
|
||||
}
|
||||
|
||||
// Generates Bond ID -> Records index key.
|
||||
func getBondIDToRecordsIndexKey(bondID string, id string) []byte {
|
||||
return append(append(PrefixBondIDToRecordsIndex, []byte(bondID)...), []byte(id)...)
|
||||
}
|
||||
|
||||
// getRecordExpiryQueueTimeKey gets the prefix for the record expiry queue.
|
||||
func getRecordExpiryQueueTimeKey(timestamp time.Time) []byte {
|
||||
timeBytes := sdk.FormatTimeBytes(timestamp)
|
||||
return append(PrefixExpiryTimeToRecordsIndex, timeBytes...)
|
||||
}
|
||||
|
||||
// SetRecordExpiryQueueTimeSlice sets a specific record expiry queue timeslice.
|
||||
func (k Keeper) SetRecordExpiryQueueTimeSlice(ctx sdk.Context, timestamp time.Time, cids []string) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz, _ := helpers.StrArrToBytesArr(cids)
|
||||
store.Set(getRecordExpiryQueueTimeKey(timestamp), bz)
|
||||
}
|
||||
|
||||
// DeleteRecordExpiryQueueTimeSlice deletes a specific record expiry queue timeslice.
|
||||
func (k Keeper) DeleteRecordExpiryQueueTimeSlice(ctx sdk.Context, timestamp time.Time) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
store.Delete(getRecordExpiryQueueTimeKey(timestamp))
|
||||
}
|
||||
|
||||
// GetRecordExpiryQueueTimeSlice gets a specific record queue timeslice.
|
||||
// A timeslice is a slice of CIDs corresponding to records that expire at a certain time.
|
||||
func (k Keeper) GetRecordExpiryQueueTimeSlice(ctx sdk.Context, timestamp time.Time) []string {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
|
||||
bz := store.Get(getRecordExpiryQueueTimeKey(timestamp))
|
||||
if bz == nil {
|
||||
return []string{}
|
||||
}
|
||||
cids, err := helpers.BytesArrToStringArr(bz)
|
||||
if err != nil {
|
||||
return []string{}
|
||||
}
|
||||
return cids
|
||||
}
|
||||
|
||||
// InsertRecordExpiryQueue inserts a record CID to the appropriate timeslice in the record expiry queue.
|
||||
func (k Keeper) InsertRecordExpiryQueue(ctx sdk.Context, val types.Record) {
|
||||
timeSlice := k.GetRecordExpiryQueueTimeSlice(ctx, val.ExpiryTime)
|
||||
timeSlice = append(timeSlice, val.Id)
|
||||
k.SetRecordExpiryQueueTimeSlice(ctx, val.ExpiryTime, timeSlice)
|
||||
}
|
||||
|
||||
// GetModuleBalances gets the nameservice module account(s) balances.
|
||||
func (k Keeper) GetModuleBalances(ctx sdk.Context) []*types.AccountBalance {
|
||||
var balances []*types.AccountBalance
|
||||
accountNames := []string{types.RecordRentModuleAccountName, types.AuthorityRentModuleAccountName}
|
||||
|
||||
for _, accountName := range accountNames {
|
||||
moduleAddress := k.accountKeeper.GetModuleAddress(accountName)
|
||||
moduleAccount := k.accountKeeper.GetAccount(ctx, moduleAddress)
|
||||
if moduleAccount != nil {
|
||||
accountBalance := k.bankKeeper.GetAllBalances(ctx, moduleAddress)
|
||||
balances = append(balances, &types.AccountBalance{
|
||||
AccountName: accountName,
|
||||
Balance: accountBalance,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return balances
|
||||
}
|
280
x/nameservice/keeper/msg_server.go
Normal file
280
x/nameservice/keeper/msg_server.go
Normal file
|
@ -0,0 +1,280 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/tharsis/ethermint/x/nameservice/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 (m msgServer) SetRecord(c context.Context, msg *types.MsgSetRecord) (*types.MsgSetRecordResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = m.Keeper.ProcessSetRecord(ctx, types.MsgSetRecord{
|
||||
BondId: msg.GetBondId(),
|
||||
Signer: msg.GetSigner(),
|
||||
Payload: msg.GetPayload(),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvents(sdk.Events{
|
||||
sdk.NewEvent(
|
||||
types.EventTypeSetRecord,
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.GetSigner()),
|
||||
sdk.NewAttribute(types.AttributeKeyBondId, msg.GetBondId()),
|
||||
sdk.NewAttribute(types.AttributeKeyPayload, msg.Payload.String()),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
),
|
||||
})
|
||||
|
||||
return &types.MsgSetRecordResponse{}, nil
|
||||
}
|
||||
|
||||
func (m msgServer) SetName(c context.Context, msg *types.MsgSetName) (*types.MsgSetNameResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = m.Keeper.ProcessSetName(ctx, *msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ctx.EventManager().EmitEvents(sdk.Events{
|
||||
sdk.NewEvent(
|
||||
types.EventTypeSetRecord,
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
sdk.NewAttribute(types.AttributeKeyWRN, msg.Wrn),
|
||||
sdk.NewAttribute(types.AttributeKeyCID, msg.Cid),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
),
|
||||
})
|
||||
return &types.MsgSetNameResponse{}, nil
|
||||
}
|
||||
|
||||
func (m msgServer) ReserveName(c context.Context, msg *types.MsgReserveAuthority) (*types.MsgReserveAuthorityResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err = sdk.AccAddressFromBech32(msg.Owner)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = m.Keeper.ProcessReserveAuthority(ctx, *msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ctx.EventManager().EmitEvents(sdk.Events{
|
||||
sdk.NewEvent(
|
||||
types.EventTypeReserveNameAuthority,
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
sdk.NewAttribute(types.AttributeKeyName, msg.Name),
|
||||
sdk.NewAttribute(types.AttributeKeyOwner, msg.Owner),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
),
|
||||
})
|
||||
return &types.MsgReserveAuthorityResponse{}, nil
|
||||
}
|
||||
|
||||
func (m msgServer) SetAuthorityBond(c context.Context, msg *types.MsgSetAuthorityBond) (*types.MsgSetAuthorityBondResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = m.Keeper.ProcessSetAuthorityBond(ctx, *msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ctx.EventManager().EmitEvents(sdk.Events{
|
||||
sdk.NewEvent(
|
||||
types.EventTypeAuthorityBond,
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
sdk.NewAttribute(types.AttributeKeyName, msg.Name),
|
||||
sdk.NewAttribute(types.AttributeKeyBondId, msg.BondId),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
),
|
||||
})
|
||||
return &types.MsgSetAuthorityBondResponse{}, nil
|
||||
}
|
||||
|
||||
func (m msgServer) DeleteName(c context.Context, msg *types.MsgDeleteNameAuthority) (*types.MsgDeleteNameAuthorityResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = m.Keeper.ProcessDeleteName(ctx, *msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ctx.EventManager().EmitEvents(sdk.Events{
|
||||
sdk.NewEvent(
|
||||
types.EventTypeDeleteName,
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
sdk.NewAttribute(types.AttributeKeyWRN, msg.Wrn),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
),
|
||||
})
|
||||
return &types.MsgDeleteNameAuthorityResponse{}, nil
|
||||
}
|
||||
|
||||
func (m msgServer) RenewRecord(c context.Context, msg *types.MsgRenewRecord) (*types.MsgRenewRecordResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
err = m.Keeper.ProcessRenewRecord(ctx, *msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ctx.EventManager().EmitEvents(sdk.Events{
|
||||
sdk.NewEvent(
|
||||
types.EventTypeRenewRecord,
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
sdk.NewAttribute(types.AttributeKeyRecordId, msg.RecordId),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
),
|
||||
})
|
||||
return &types.MsgRenewRecordResponse{}, nil
|
||||
}
|
||||
|
||||
func (m msgServer) AssociateBond(c context.Context, msg *types.MsgAssociateBond) (*types.MsgAssociateBondResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = m.Keeper.ProcessAssociateBond(ctx, *msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ctx.EventManager().EmitEvents(sdk.Events{
|
||||
sdk.NewEvent(
|
||||
types.EventTypeAssociateBond,
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
sdk.NewAttribute(types.AttributeKeyRecordId, msg.RecordId),
|
||||
sdk.NewAttribute(types.AttributeKeyBondId, msg.BondId),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
),
|
||||
})
|
||||
return &types.MsgAssociateBondResponse{}, nil
|
||||
}
|
||||
|
||||
func (m msgServer) DissociateBond(c context.Context, msg *types.MsgDissociateBond) (*types.MsgDissociateBondResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = m.Keeper.ProcessDissociateBond(ctx, *msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ctx.EventManager().EmitEvents(sdk.Events{
|
||||
sdk.NewEvent(
|
||||
types.EventTypeDissociateBond,
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
sdk.NewAttribute(types.AttributeKeyRecordId, msg.RecordId),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
),
|
||||
})
|
||||
return &types.MsgDissociateBondResponse{}, nil
|
||||
}
|
||||
|
||||
func (m msgServer) DissociateRecords(c context.Context, msg *types.MsgDissociateRecords) (*types.MsgDissociateRecordsResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = m.Keeper.ProcessDissociateRecords(ctx, *msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ctx.EventManager().EmitEvents(sdk.Events{
|
||||
sdk.NewEvent(
|
||||
types.EventTypeDissociateRecords,
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
sdk.NewAttribute(types.AttributeKeyBondId, msg.BondId),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
),
|
||||
})
|
||||
return &types.MsgDissociateRecordsResponse{}, nil
|
||||
}
|
||||
|
||||
func (m msgServer) ReAssociateRecords(c context.Context, msg *types.MsgReAssociateRecords) (*types.MsgReAssociateRecordsResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = m.Keeper.ProcessReAssociateRecords(ctx, *msg)
|
||||
ctx.EventManager().EmitEvents(sdk.Events{
|
||||
sdk.NewEvent(
|
||||
types.EventTypeReAssociateRecords,
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
sdk.NewAttribute(types.AttributeKeyOldBondId, msg.OldBondId),
|
||||
sdk.NewAttribute(types.AttributeKeyNewBondId, msg.NewBondId),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||
),
|
||||
})
|
||||
return &types.MsgReAssociateRecordsResponse{}, nil
|
||||
}
|
616
x/nameservice/keeper/naming_keeper.go
Normal file
616
x/nameservice/keeper/naming_keeper.go
Normal file
|
@ -0,0 +1,616 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
auctiontypes "github.com/tharsis/ethermint/x/auction/types"
|
||||
"github.com/tharsis/ethermint/x/nameservice/helpers"
|
||||
"github.com/tharsis/ethermint/x/nameservice/types"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func getAuthorityPubKey(pubKey cryptotypes.PubKey) string {
|
||||
if pubKey != nil {
|
||||
return helpers.BytesToBase64(pubKey.Bytes())
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// GetNameAuthorityIndexKey Generates name -> NameAuthority index key.
|
||||
func GetNameAuthorityIndexKey(name string) []byte {
|
||||
return append(PrefixNameAuthorityRecordIndex, []byte(name)...)
|
||||
}
|
||||
|
||||
// GetNameRecordIndexKey Generates WRN -> NameRecord index key.
|
||||
func GetNameRecordIndexKey(wrn string) []byte {
|
||||
return append(PrefixWRNToNameRecordIndex, []byte(wrn)...)
|
||||
}
|
||||
|
||||
func GetCIDToNamesIndexKey(id string) []byte {
|
||||
return append(PrefixCIDToNamesIndex, []byte(id)...)
|
||||
}
|
||||
|
||||
func SetNameAuthority(ctx sdk.Context, store sdk.KVStore, codec codec.BinaryCodec, name string, authority *types.NameAuthority) {
|
||||
store.Set(GetNameAuthorityIndexKey(name), codec.MustMarshal(authority))
|
||||
updateBlockChangeSetForNameAuthority(ctx, codec, store, name)
|
||||
}
|
||||
|
||||
// SetNameAuthority creates the NameAuthority record.
|
||||
func (k Keeper) SetNameAuthority(ctx sdk.Context, name string, authority *types.NameAuthority) {
|
||||
SetNameAuthority(ctx, ctx.KVStore(k.storeKey), k.cdc, name, authority)
|
||||
}
|
||||
|
||||
func removeAuctionToAuthorityMapping(store sdk.KVStore, auctionID string) {
|
||||
store.Delete(GetAuctionToAuthorityIndexKey(auctionID))
|
||||
}
|
||||
|
||||
func (k Keeper) RemoveAuctionToAuthorityMapping(ctx sdk.Context, auctionID string) {
|
||||
removeAuctionToAuthorityMapping(ctx.KVStore(k.storeKey), auctionID)
|
||||
}
|
||||
|
||||
// GetNameAuthority - gets a name authority from the store.
|
||||
func GetNameAuthority(store sdk.KVStore, codec codec.BinaryCodec, name string) *types.NameAuthority {
|
||||
authorityKey := GetNameAuthorityIndexKey(name)
|
||||
if !store.Has(authorityKey) {
|
||||
return nil
|
||||
}
|
||||
|
||||
bz := store.Get(authorityKey)
|
||||
var obj types.NameAuthority
|
||||
codec.MustUnmarshal(bz, &obj)
|
||||
|
||||
return &obj
|
||||
}
|
||||
|
||||
// GetNameAuthority - gets a name authority from the store.
|
||||
func (k Keeper) GetNameAuthority(ctx sdk.Context, name string) *types.NameAuthority {
|
||||
return GetNameAuthority(ctx.KVStore(k.storeKey), k.cdc, name)
|
||||
}
|
||||
|
||||
// HasNameAuthority - checks if a name authority entry exists.
|
||||
func HasNameAuthority(store sdk.KVStore, name string) bool {
|
||||
return store.Has(GetNameAuthorityIndexKey(name))
|
||||
}
|
||||
|
||||
// HasNameAuthority - checks if a name/authority exists.
|
||||
func (k Keeper) HasNameAuthority(ctx sdk.Context, name string) bool {
|
||||
return HasNameAuthority(ctx.KVStore(k.storeKey), name)
|
||||
}
|
||||
|
||||
func getBondIDToAuthoritiesIndexKey(bondID string, name string) []byte {
|
||||
return append(append(PrefixBondIDToAuthoritiesIndex, []byte(bondID)...), []byte(name)...)
|
||||
}
|
||||
|
||||
// AddBondToAuthorityIndexEntry adds the Bond ID -> [Authority] index entry.
|
||||
func (k Keeper) AddBondToAuthorityIndexEntry(ctx sdk.Context, bondID string, name string) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
store.Set(getBondIDToAuthoritiesIndexKey(bondID, name), []byte{})
|
||||
}
|
||||
|
||||
// RemoveBondToAuthorityIndexEntry removes the Bond ID -> [Authority] index entry.
|
||||
func (k Keeper) RemoveBondToAuthorityIndexEntry(ctx sdk.Context, bondID string, name string) {
|
||||
RemoveBondToAuthorityIndexEntry(ctx.KVStore(k.storeKey), bondID, name)
|
||||
}
|
||||
|
||||
func RemoveBondToAuthorityIndexEntry(store sdk.KVStore, bondID string, name string) {
|
||||
store.Delete(getBondIDToAuthoritiesIndexKey(bondID, name))
|
||||
}
|
||||
|
||||
func (k Keeper) updateBlockChangeSetForName(ctx sdk.Context, wrn string) {
|
||||
changeSet := k.getOrCreateBlockChangeSet(ctx, ctx.BlockHeight())
|
||||
changeSet.Names = append(changeSet.Names, wrn)
|
||||
k.saveBlockChangeSet(ctx, changeSet)
|
||||
}
|
||||
|
||||
func (k Keeper) getAuthority(ctx sdk.Context, wrn string) (string, *url.URL, *types.NameAuthority, error) {
|
||||
parsedWRN, err := url.Parse(wrn)
|
||||
if err != nil {
|
||||
return "", nil, nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid WRN.")
|
||||
}
|
||||
|
||||
name := parsedWRN.Host
|
||||
authority := k.GetNameAuthority(ctx, name)
|
||||
if authority == nil {
|
||||
return name, nil, nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Name authority not found.")
|
||||
}
|
||||
|
||||
return name, parsedWRN, authority, nil
|
||||
}
|
||||
|
||||
func (k Keeper) checkWRNAccess(ctx sdk.Context, signer sdk.AccAddress, wrn string) error {
|
||||
name, parsedWRN, authority, err := k.getAuthority(ctx, wrn)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
formattedWRN := fmt.Sprintf("wrn://%s%s", name, parsedWRN.RequestURI())
|
||||
if formattedWRN != wrn {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid WRN.")
|
||||
}
|
||||
|
||||
if authority.OwnerAddress != signer.String() {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Access denied.")
|
||||
}
|
||||
|
||||
if authority.Status != types.AuthorityActive {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Authority is not active.")
|
||||
}
|
||||
|
||||
if authority.BondId == "" || len(authority.BondId) == 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Authority bond not found.")
|
||||
}
|
||||
|
||||
if authority.OwnerPublicKey == "" {
|
||||
// Try to set owner public key if account has it available now.
|
||||
ownerAccount := k.accountKeeper.GetAccount(ctx, signer)
|
||||
pubKey := ownerAccount.GetPubKey()
|
||||
if pubKey != nil {
|
||||
// Update public key in authority record.
|
||||
authority.OwnerPublicKey = getAuthorityPubKey(pubKey)
|
||||
k.SetNameAuthority(ctx, name, authority)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// HasNameRecord - checks if a name record exists.
|
||||
func (k Keeper) HasNameRecord(ctx sdk.Context, wrn string) bool {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
return store.Has(GetNameRecordIndexKey(wrn))
|
||||
}
|
||||
|
||||
// GetNameRecord - gets a name record from the store.
|
||||
func GetNameRecord(store sdk.KVStore, codec codec.BinaryCodec, wrn string) *types.NameRecord {
|
||||
nameRecordKey := GetNameRecordIndexKey(wrn)
|
||||
if !store.Has(nameRecordKey) {
|
||||
return nil
|
||||
}
|
||||
|
||||
bz := store.Get(nameRecordKey)
|
||||
var obj types.NameRecord
|
||||
codec.MustUnmarshal(bz, &obj)
|
||||
|
||||
return &obj
|
||||
}
|
||||
|
||||
// GetNameRecord - gets a name record from the store.
|
||||
func (k Keeper) GetNameRecord(ctx sdk.Context, wrn string) *types.NameRecord {
|
||||
_, _, authority, err := k.getAuthority(ctx, wrn)
|
||||
if err != nil || authority.Status != types.AuthorityActive {
|
||||
// If authority is not active (or any other error), lookup fails.
|
||||
return nil
|
||||
}
|
||||
|
||||
nameRecord := GetNameRecord(ctx.KVStore(k.storeKey), k.cdc, wrn)
|
||||
|
||||
// Name record may not exist.
|
||||
if nameRecord == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Name lookup should fail if the name record is stale.
|
||||
// i.e. authority was registered later than the name.
|
||||
if authority.Height > nameRecord.Latest.Height {
|
||||
return nil
|
||||
}
|
||||
|
||||
return nameRecord
|
||||
}
|
||||
|
||||
// RemoveRecordToNameMapping removes a name from the record ID -> []names index.
|
||||
func RemoveRecordToNameMapping(store sdk.KVStore, codec codec.BinaryCodec, id string, wrn string) {
|
||||
reverseNameIndexKey := GetCIDToNamesIndexKey(id)
|
||||
|
||||
names, _ := helpers.BytesArrToStringArr(store.Get(reverseNameIndexKey))
|
||||
nameSet := helpers.SliceToSet(names)
|
||||
nameSet.Remove(wrn)
|
||||
|
||||
if nameSet.Cardinality() == 0 {
|
||||
// Delete as storing empty slice throws error from baseapp.
|
||||
store.Delete(reverseNameIndexKey)
|
||||
} else {
|
||||
data, _ := helpers.StrArrToBytesArr(helpers.SetToSlice(nameSet))
|
||||
store.Set(reverseNameIndexKey, data)
|
||||
}
|
||||
}
|
||||
|
||||
// AddRecordToNameMapping adds a name to the record ID -> []names index.
|
||||
func AddRecordToNameMapping(store sdk.KVStore, id string, wrn string) {
|
||||
reverseNameIndexKey := GetCIDToNamesIndexKey(id)
|
||||
|
||||
var names []string
|
||||
if store.Has(reverseNameIndexKey) {
|
||||
names, _ = helpers.BytesArrToStringArr(store.Get(reverseNameIndexKey))
|
||||
}
|
||||
|
||||
nameSet := helpers.SliceToSet(names)
|
||||
nameSet.Add(wrn)
|
||||
bz, _ := helpers.StrArrToBytesArr(helpers.SetToSlice(nameSet))
|
||||
store.Set(reverseNameIndexKey, bz)
|
||||
}
|
||||
|
||||
// SetNameRecord - sets a name record.
|
||||
func SetNameRecord(store sdk.KVStore, codec codec.BinaryCodec, wrn string, id string, height int64) {
|
||||
nameRecordIndexKey := GetNameRecordIndexKey(wrn)
|
||||
|
||||
var nameRecord types.NameRecord
|
||||
if store.Has(nameRecordIndexKey) {
|
||||
bz := store.Get(nameRecordIndexKey)
|
||||
codec.MustUnmarshal(bz, &nameRecord)
|
||||
nameRecord.History = append(nameRecord.History, nameRecord.Latest)
|
||||
|
||||
// Update old CID -> []Name index.
|
||||
if nameRecord.Latest.Id != "" || len(nameRecord.Latest.Id) != 0 {
|
||||
RemoveRecordToNameMapping(store, codec, nameRecord.Latest.Id, wrn)
|
||||
}
|
||||
}
|
||||
|
||||
nameRecord.Latest = &types.NameRecordEntry{
|
||||
Id: id,
|
||||
Height: uint64(height),
|
||||
}
|
||||
|
||||
store.Set(nameRecordIndexKey, codec.MustMarshal(&nameRecord))
|
||||
|
||||
// Update new CID -> []Name index.
|
||||
if id != "" {
|
||||
AddRecordToNameMapping(store, id, wrn)
|
||||
}
|
||||
}
|
||||
|
||||
// SetNameRecord - sets a name record.
|
||||
func (k Keeper) SetNameRecord(ctx sdk.Context, wrn string, id string) {
|
||||
SetNameRecord(ctx.KVStore(k.storeKey), k.cdc, wrn, id, ctx.BlockHeight())
|
||||
|
||||
// Update changeSet for name.
|
||||
k.updateBlockChangeSetForName(ctx, wrn)
|
||||
}
|
||||
|
||||
// ProcessSetName creates a WRN -> Record ID mapping.
|
||||
func (k Keeper) ProcessSetName(ctx sdk.Context, msg types.MsgSetName) error {
|
||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = k.checkWRNAccess(ctx, signerAddress, msg.Wrn)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
nameRecord := k.GetNameRecord(ctx, msg.Wrn)
|
||||
if nameRecord != nil && nameRecord.Latest.Id == msg.Cid {
|
||||
return nil
|
||||
}
|
||||
|
||||
k.SetNameRecord(ctx, msg.Wrn, msg.Cid)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ListNameRecords - get all name records.
|
||||
func (k Keeper) ListNameRecords(ctx sdk.Context) []types.NameEntry {
|
||||
var nameEntries []types.NameEntry
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
itr := sdk.KVStorePrefixIterator(store, PrefixWRNToNameRecordIndex)
|
||||
defer itr.Close()
|
||||
for ; itr.Valid(); itr.Next() {
|
||||
bz := store.Get(itr.Key())
|
||||
if bz != nil {
|
||||
var record types.NameRecord
|
||||
k.cdc.MustUnmarshal(bz, &record)
|
||||
nameEntries = append(nameEntries, types.NameEntry{
|
||||
Name: string(itr.Key()[len(PrefixWRNToNameRecordIndex):]),
|
||||
Entry: &record,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return nameEntries
|
||||
}
|
||||
|
||||
// ProcessReserveSubAuthority reserves a sub-authority.
|
||||
func (k Keeper) ProcessReserveSubAuthority(ctx sdk.Context, name string, msg types.MsgReserveAuthority) error {
|
||||
// Get parent authority name.
|
||||
names := strings.Split(name, ".")
|
||||
parent := strings.Join(names[1:], ".")
|
||||
|
||||
// Check if parent authority exists.
|
||||
parentAuthority := k.GetNameAuthority(ctx, parent)
|
||||
if parentAuthority == nil {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Parent authority not found.")
|
||||
}
|
||||
|
||||
// Sub-authority creator needs to be the owner of the parent authority.
|
||||
if parentAuthority.OwnerAddress != msg.Signer {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Access denied.")
|
||||
}
|
||||
|
||||
// Sub-authority owner defaults to parent authority owner.
|
||||
subAuthorityOwner := msg.Signer
|
||||
if len(msg.Owner) != 0 {
|
||||
// Override sub-authority owner if provided in message.
|
||||
subAuthorityOwner = msg.Owner
|
||||
}
|
||||
|
||||
sdkErr := k.createAuthority(ctx, name, subAuthorityOwner, false)
|
||||
if sdkErr != nil {
|
||||
return sdkErr
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetAuctionToAuthorityIndexKey(auctionID string) []byte {
|
||||
return append(PrefixAuctionToAuthorityNameIndex, []byte(auctionID)...)
|
||||
}
|
||||
|
||||
func (k Keeper) AddAuctionToAuthorityMapping(ctx sdk.Context, auctionID string, name string) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
store.Set(GetAuctionToAuthorityIndexKey(auctionID), []byte(name))
|
||||
}
|
||||
|
||||
func (k Keeper) createAuthority(ctx sdk.Context, name string, owner string, isRoot bool) error {
|
||||
moduleParams := k.GetParams(ctx)
|
||||
|
||||
if k.HasNameAuthority(ctx, name) {
|
||||
authority := k.GetNameAuthority(ctx, name)
|
||||
if authority.Status != types.AuthorityExpired {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Name already reserved.")
|
||||
}
|
||||
}
|
||||
|
||||
ownerAddress, err := sdk.AccAddressFromBech32(owner)
|
||||
if err != nil {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid owner address.")
|
||||
}
|
||||
ownerAccount := k.accountKeeper.GetAccount(ctx, ownerAddress)
|
||||
if ownerAccount == nil {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrUnknownAddress, "Account not found.")
|
||||
}
|
||||
|
||||
authority := types.NameAuthority{
|
||||
OwnerPublicKey: getAuthorityPubKey(ownerAccount.GetPubKey()),
|
||||
OwnerAddress: owner,
|
||||
Height: uint64(ctx.BlockHeight()),
|
||||
Status: types.AuthorityActive,
|
||||
AuctionId: "",
|
||||
BondId: "",
|
||||
ExpiryTime: ctx.BlockTime().Add(moduleParams.AuthorityGracePeriod),
|
||||
}
|
||||
|
||||
if isRoot && moduleParams.AuthorityAuctionEnabled {
|
||||
// If auctions are enabled, clear out owner fields. They will be set after a winner is picked.
|
||||
authority.OwnerAddress = ""
|
||||
authority.OwnerPublicKey = ""
|
||||
// Reset bond ID if required.
|
||||
if authority.BondId != "" || len(authority.BondId) != 0 {
|
||||
k.RemoveBondToAuthorityIndexEntry(ctx, authority.BondId, name)
|
||||
authority.BondId = ""
|
||||
}
|
||||
|
||||
params := auctiontypes.Params{
|
||||
CommitsDuration: moduleParams.AuthorityAuctionCommitsDuration,
|
||||
RevealsDuration: moduleParams.AuthorityAuctionRevealsDuration,
|
||||
CommitFee: moduleParams.AuthorityAuctionCommitFee,
|
||||
RevealFee: moduleParams.AuthorityAuctionRevealFee,
|
||||
MinimumBid: moduleParams.AuthorityAuctionMinimumBid,
|
||||
}
|
||||
|
||||
// Create an auction.
|
||||
msg := auctiontypes.NewMsgCreateAuction(params, ownerAddress)
|
||||
|
||||
auction, sdkErr := k.auctionKeeper.CreateAuction(ctx, msg)
|
||||
if sdkErr != nil {
|
||||
return sdkErr
|
||||
}
|
||||
|
||||
// Create auction ID -> authority name index.
|
||||
k.AddAuctionToAuthorityMapping(ctx, auction.Id, name)
|
||||
|
||||
authority.Status = types.AuthorityUnderAuction
|
||||
authority.AuctionId = auction.Id
|
||||
authority.ExpiryTime = auction.RevealsEndTime.Add(moduleParams.AuthorityGracePeriod)
|
||||
}
|
||||
k.SetNameAuthority(ctx, name, &authority)
|
||||
k.InsertAuthorityExpiryQueue(ctx, name, authority.ExpiryTime)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ProcessReserveAuthority reserves a name authority.
|
||||
func (k Keeper) ProcessReserveAuthority(ctx sdk.Context, msg types.MsgReserveAuthority) error {
|
||||
wrn := fmt.Sprintf("wrn://%s", msg.GetName())
|
||||
parsedWrn, err := url.Parse(wrn)
|
||||
if err != nil {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid name")
|
||||
}
|
||||
name := parsedWrn.Host
|
||||
if fmt.Sprintf("wrn://%s", name) != wrn {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid name")
|
||||
}
|
||||
if strings.Contains(name, ".") {
|
||||
return k.ProcessReserveSubAuthority(ctx, name, msg)
|
||||
}
|
||||
err = k.createAuthority(ctx, name, msg.GetSigner(), true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (k Keeper) ProcessSetAuthorityBond(ctx sdk.Context, msg types.MsgSetAuthorityBond) error {
|
||||
name := msg.GetName()
|
||||
signer := msg.GetSigner()
|
||||
authority := k.GetNameAuthority(ctx, name)
|
||||
if authority == nil {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Name authority not found.")
|
||||
}
|
||||
if authority.OwnerAddress != signer {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Access denied")
|
||||
}
|
||||
|
||||
if !k.bondKeeper.HasBond(ctx, msg.BondId) {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found.")
|
||||
}
|
||||
//
|
||||
bond := k.bondKeeper.GetBond(ctx, msg.BondId)
|
||||
if bond.Owner != signer {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.")
|
||||
}
|
||||
|
||||
// No-op if bond hasn't changed.
|
||||
if authority.BondId == msg.BondId {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Remove old bond ID mapping, if any.
|
||||
if authority.BondId != "" {
|
||||
k.RemoveBondToAuthorityIndexEntry(ctx, authority.BondId, name)
|
||||
}
|
||||
|
||||
// Update bond ID for authority.
|
||||
authority.BondId = bond.Id
|
||||
k.SetNameAuthority(ctx, name, authority)
|
||||
// Add new bond ID mapping.
|
||||
k.AddBondToAuthorityIndexEntry(ctx, authority.BondId, name)
|
||||
return nil
|
||||
}
|
||||
|
||||
// ProcessDeleteName removes a WRN -> Record ID mapping.
|
||||
func (k Keeper) ProcessDeleteName(ctx sdk.Context, msg types.MsgDeleteNameAuthority) error {
|
||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = k.checkWRNAccess(ctx, signerAddress, msg.Wrn)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !k.HasNameRecord(ctx, msg.Wrn) {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Name not found.")
|
||||
}
|
||||
|
||||
// Set CID to empty string.
|
||||
k.SetNameRecord(ctx, msg.Wrn, "")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (k Keeper) GetAuthorityExpiryQueue(ctx sdk.Context) []*types.ExpiryQueueRecord {
|
||||
var authorities []*types.ExpiryQueueRecord
|
||||
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
itr := sdk.KVStorePrefixIterator(store, PrefixExpiryTimeToAuthoritiesIndex)
|
||||
defer itr.Close()
|
||||
for ; itr.Valid(); itr.Next() {
|
||||
var record []string
|
||||
record, err := helpers.BytesArrToStringArr(itr.Value())
|
||||
if err != nil {
|
||||
return authorities
|
||||
}
|
||||
authorities = append(authorities, &types.ExpiryQueueRecord{
|
||||
Id: string(itr.Key()[len(PrefixExpiryTimeToAuthoritiesIndex):]),
|
||||
Value: record,
|
||||
})
|
||||
}
|
||||
|
||||
return authorities
|
||||
}
|
||||
|
||||
// ResolveWRN resolves a WRN to a record.
|
||||
func (k Keeper) ResolveWRN(ctx sdk.Context, wrn string) *types.Record {
|
||||
_, _, authority, err := k.getAuthority(ctx, wrn)
|
||||
if err != nil || authority.Status != types.AuthorityActive {
|
||||
// If authority is not active (or any other error), resolution fails.
|
||||
return nil
|
||||
}
|
||||
|
||||
// Name should not resolve if it's stale.
|
||||
// i.e. authority was registered later than the name.
|
||||
record, nameRecord := ResolveWRN(ctx.KVStore(k.storeKey), wrn, k, ctx)
|
||||
if authority.Height > nameRecord.Latest.Height {
|
||||
return nil
|
||||
}
|
||||
|
||||
return record
|
||||
}
|
||||
|
||||
// ResolveWRN resolves a WRN to a record.
|
||||
func ResolveWRN(store sdk.KVStore, wrn string, k Keeper, c sdk.Context) (*types.Record, *types.NameRecord) {
|
||||
nameKey := GetNameRecordIndexKey(wrn)
|
||||
|
||||
if store.Has(nameKey) {
|
||||
bz := store.Get(nameKey)
|
||||
var obj types.NameRecord
|
||||
k.cdc.MustUnmarshal(bz, &obj)
|
||||
|
||||
recordExists := k.HasRecord(c, obj.Latest.Id)
|
||||
if !recordExists || obj.Latest.Id == "" {
|
||||
return nil, &obj
|
||||
}
|
||||
|
||||
record := k.GetRecord(c, obj.Latest.Id)
|
||||
return &record, &obj
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func getAuthorityExpiryQueueTimeKey(timestamp time.Time) []byte {
|
||||
timeBytes := sdk.FormatTimeBytes(timestamp)
|
||||
return append(PrefixExpiryTimeToAuthoritiesIndex, timeBytes...)
|
||||
}
|
||||
|
||||
func (k Keeper) InsertAuthorityExpiryQueue(ctx sdk.Context, name string, expiryTime time.Time) {
|
||||
timeSlice := k.GetAuthorityExpiryQueueTimeSlice(ctx, expiryTime)
|
||||
timeSlice = append(timeSlice, name)
|
||||
k.SetAuthorityExpiryQueueTimeSlice(ctx, expiryTime, timeSlice)
|
||||
}
|
||||
|
||||
func (k Keeper) GetAuthorityExpiryQueueTimeSlice(ctx sdk.Context, timestamp time.Time) []string {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
|
||||
bz := store.Get(getAuthorityExpiryQueueTimeKey(timestamp))
|
||||
if bz == nil {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
names, err := helpers.BytesArrToStringArr(bz)
|
||||
if err != nil {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
return names
|
||||
}
|
||||
|
||||
func (k Keeper) SetAuthorityExpiryQueueTimeSlice(ctx sdk.Context, timestamp time.Time, names []string) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz, _ := helpers.StrArrToBytesArr(names)
|
||||
store.Set(getAuthorityExpiryQueueTimeKey(timestamp), bz)
|
||||
}
|
||||
|
||||
// ListNameAuthorityRecords - get all name authority records.
|
||||
func (k Keeper) ListNameAuthorityRecords(ctx sdk.Context) map[string]types.NameAuthority {
|
||||
nameAuthorityRecords := make(map[string]types.NameAuthority)
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
|
||||
itr := sdk.KVStorePrefixIterator(store, PrefixNameAuthorityRecordIndex)
|
||||
defer itr.Close()
|
||||
for ; itr.Valid(); itr.Next() {
|
||||
bz := store.Get(itr.Key())
|
||||
if bz != nil {
|
||||
var record types.NameAuthority
|
||||
k.cdc.MustUnmarshal(bz, &record)
|
||||
nameAuthorityRecords[string(itr.Key()[len(PrefixNameAuthorityRecordIndex):])] = record
|
||||
}
|
||||
}
|
||||
|
||||
return nameAuthorityRecords
|
||||
}
|
17
x/nameservice/keeper/params.go
Normal file
17
x/nameservice/keeper/params.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/tharsis/ethermint/x/nameservice/types"
|
||||
)
|
||||
|
||||
// GetParams - Get all parameters 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)
|
||||
}
|
299
x/nameservice/keeper/record_keeper.go
Normal file
299
x/nameservice/keeper/record_keeper.go
Normal file
|
@ -0,0 +1,299 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
auctionkeeper "github.com/tharsis/ethermint/x/auction/keeper"
|
||||
auctiontypes "github.com/tharsis/ethermint/x/auction/types"
|
||||
bondtypes "github.com/tharsis/ethermint/x/bond/types"
|
||||
"github.com/tharsis/ethermint/x/nameservice/types"
|
||||
)
|
||||
|
||||
// RecordKeeper exposes the bare minimal read-only API for other modules.
|
||||
type RecordKeeper struct {
|
||||
auctionKeeper auctionkeeper.Keeper
|
||||
storeKey sdk.StoreKey // Unexposed key to access store from sdk.Context
|
||||
cdc codec.BinaryCodec // The wire codec for binary encoding/decoding.
|
||||
}
|
||||
|
||||
func (k RecordKeeper) UsesAuction(ctx sdk.Context, auctionID string) bool {
|
||||
return k.GetAuctionToAuthorityMapping(ctx, auctionID) != ""
|
||||
}
|
||||
|
||||
func (k RecordKeeper) OnAuction(ctx sdk.Context, auctionId string) {
|
||||
updateBlockChangeSetForAuction(ctx, k, auctionId)
|
||||
}
|
||||
|
||||
func (k RecordKeeper) OnAuctionBid(ctx sdk.Context, auctionID string, bidderAddress string) {
|
||||
updateBlockChangeSetForAuctionBid(ctx, k, auctionID, bidderAddress)
|
||||
}
|
||||
|
||||
func (k RecordKeeper) OnAuctionWinnerSelected(ctx sdk.Context, auctionID string) {
|
||||
// Update authority status based on auction status/winner.
|
||||
name := k.GetAuctionToAuthorityMapping(ctx, auctionID)
|
||||
if name == "" {
|
||||
// We don't know about this auction, ignore.
|
||||
ctx.Logger().Info(fmt.Sprintf("Ignoring auction notification, name mapping not found: %s", auctionID))
|
||||
return
|
||||
}
|
||||
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
if !HasNameAuthority(store, name) {
|
||||
// We don't know about this authority, ignore.
|
||||
ctx.Logger().Info(fmt.Sprintf("Ignoring auction notification, authority not found: %s", auctionID))
|
||||
return
|
||||
}
|
||||
|
||||
authority := GetNameAuthority(store, k.cdc, name)
|
||||
auctionObj := k.auctionKeeper.GetAuction(ctx, auctionID)
|
||||
|
||||
if auctionObj.Status == auctiontypes.AuctionStatusCompleted {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
|
||||
if auctionObj.WinnerAddress != "" {
|
||||
// Mark authority owner and change status to active.
|
||||
authority.OwnerAddress = auctionObj.WinnerAddress
|
||||
authority.Status = types.AuthorityActive
|
||||
|
||||
// Reset bond ID if required, as owner has changed.
|
||||
if authority.BondId != "" {
|
||||
RemoveBondToAuthorityIndexEntry(store, authority.BondId, name)
|
||||
authority.BondId = ""
|
||||
}
|
||||
|
||||
// Update height for updated/changed authority (owner).
|
||||
// Can be used to check if names are older than the authority itself (stale names).
|
||||
authority.Height = uint64(ctx.BlockHeight())
|
||||
|
||||
ctx.Logger().Info(fmt.Sprintf("Winner selected, marking authority as active: %s", name))
|
||||
} else {
|
||||
// Mark as expired.
|
||||
authority.Status = types.AuthorityExpired
|
||||
|
||||
ctx.Logger().Info(fmt.Sprintf("No winner, marking authority as expired: %s", name))
|
||||
}
|
||||
|
||||
authority.AuctionId = ""
|
||||
SetNameAuthority(ctx, store, k.cdc, name, authority)
|
||||
|
||||
// Forget about this auction now, we no longer need it.
|
||||
removeAuctionToAuthorityMapping(store, auctionID)
|
||||
} else {
|
||||
ctx.Logger().Info(fmt.Sprintf("Ignoring auction notification, status: %s", auctionObj.Status))
|
||||
}
|
||||
}
|
||||
|
||||
// Record keeper implements the bond usage keeper interface.
|
||||
var _ bondtypes.BondUsageKeeper = (*RecordKeeper)(nil)
|
||||
var _ auctiontypes.AuctionUsageKeeper = (*RecordKeeper)(nil)
|
||||
|
||||
// ModuleName returns the module name.
|
||||
func (k RecordKeeper) ModuleName() string {
|
||||
return types.ModuleName
|
||||
}
|
||||
|
||||
func (k RecordKeeper) GetAuctionToAuthorityMapping(ctx sdk.Context, auctionID string) string {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
|
||||
auctionToAuthorityIndexKey := GetAuctionToAuthorityIndexKey(auctionID)
|
||||
if store.Has(auctionToAuthorityIndexKey) {
|
||||
bz := store.Get(auctionToAuthorityIndexKey)
|
||||
return string(bz)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// UsesBond returns true if the bond has associated records.
|
||||
func (k RecordKeeper) UsesBond(ctx sdk.Context, bondId string) bool {
|
||||
bondIDPrefix := append(PrefixBondIDToRecordsIndex, []byte(bondId)...)
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
itr := sdk.KVStorePrefixIterator(store, bondIDPrefix)
|
||||
defer itr.Close()
|
||||
return itr.Valid()
|
||||
}
|
||||
|
||||
// RemoveBondToRecordIndexEntry removes the Bond ID -> [Record] index entry.
|
||||
func (k Keeper) RemoveBondToRecordIndexEntry(ctx sdk.Context, bondID string, id string) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
store.Delete(getBondIDToRecordsIndexKey(bondID, id))
|
||||
}
|
||||
|
||||
// NewRecordKeeper creates new instances of the nameservice RecordKeeper
|
||||
func NewRecordKeeper(auctionKeeper auctionkeeper.Keeper, storeKey sdk.StoreKey, cdc codec.BinaryCodec) RecordKeeper {
|
||||
return RecordKeeper{
|
||||
auctionKeeper: auctionKeeper,
|
||||
storeKey: storeKey,
|
||||
cdc: cdc,
|
||||
}
|
||||
}
|
||||
|
||||
// QueryRecordsByBond - get all records for the given bond.
|
||||
func (k RecordKeeper) QueryRecordsByBond(ctx sdk.Context, bondID string) []types.Record {
|
||||
var records []types.Record
|
||||
|
||||
bondIDPrefix := append(PrefixBondIDToRecordsIndex, []byte(bondID)...)
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
itr := sdk.KVStorePrefixIterator(store, bondIDPrefix)
|
||||
defer itr.Close()
|
||||
for ; itr.Valid(); itr.Next() {
|
||||
cid := itr.Key()[len(bondIDPrefix):]
|
||||
bz := store.Get(append(PrefixCIDToRecordIndex, cid...))
|
||||
if bz != nil {
|
||||
var obj types.Record
|
||||
k.cdc.MustUnmarshal(bz, &obj)
|
||||
//records = append(records, recordObjToRecord(store, k.cdc, obj))
|
||||
records = append(records, obj)
|
||||
}
|
||||
}
|
||||
|
||||
return records
|
||||
}
|
||||
|
||||
// ProcessRenewRecord renews a record.
|
||||
func (k Keeper) ProcessRenewRecord(ctx sdk.Context, msg types.MsgRenewRecord) error {
|
||||
if !k.HasRecord(ctx, msg.RecordId) {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Record not found.")
|
||||
}
|
||||
|
||||
// Check if renewal is required (i.e. expired record marked as deleted).
|
||||
record := k.GetRecord(ctx, msg.RecordId)
|
||||
if !record.Deleted || record.ExpiryTime.After(ctx.BlockTime()) {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Renewal not required.")
|
||||
}
|
||||
|
||||
recordType := record.ToRecordType()
|
||||
err := k.processRecord(ctx, &recordType, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ProcessAssociateBond associates a record with a bond.
|
||||
func (k Keeper) ProcessAssociateBond(ctx sdk.Context, msg types.MsgAssociateBond) error {
|
||||
|
||||
if !k.HasRecord(ctx, msg.RecordId) {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Record not found.")
|
||||
}
|
||||
|
||||
if !k.bondKeeper.HasBond(ctx, msg.BondId) {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found.")
|
||||
}
|
||||
|
||||
// Check if already associated with a bond.
|
||||
record := k.GetRecord(ctx, msg.RecordId)
|
||||
if record.BondId != "" || len(record.BondId) != 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Bond already exists.")
|
||||
}
|
||||
|
||||
// Only the bond owner can associate a record with the bond.
|
||||
bond := k.bondKeeper.GetBond(ctx, msg.BondId)
|
||||
if msg.Signer != bond.Owner {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.")
|
||||
}
|
||||
|
||||
record.BondId = msg.BondId
|
||||
k.PutRecord(ctx, record)
|
||||
k.AddBondToRecordIndexEntry(ctx, msg.BondId, msg.RecordId)
|
||||
|
||||
// Required so that renewal is triggered (with new bond ID) for expired records.
|
||||
if record.Deleted {
|
||||
k.InsertRecordExpiryQueue(ctx, record)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ProcessDissociateBond dissociates a record from its bond.
|
||||
func (k Keeper) ProcessDissociateBond(ctx sdk.Context, msg types.MsgDissociateBond) error {
|
||||
if !k.HasRecord(ctx, msg.RecordId) {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Record not found.")
|
||||
}
|
||||
|
||||
// Check if associated with a bond.
|
||||
record := k.GetRecord(ctx, msg.RecordId)
|
||||
bondID := record.BondId
|
||||
if bondID == "" || len(bondID) == 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Bond not found.")
|
||||
}
|
||||
|
||||
// Only the bond owner can dissociate a record from the bond.
|
||||
bond := k.bondKeeper.GetBond(ctx, bondID)
|
||||
if msg.Signer != bond.Owner {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.")
|
||||
}
|
||||
|
||||
// Clear bond ID.
|
||||
record.BondId = ""
|
||||
k.PutRecord(ctx, record)
|
||||
k.RemoveBondToRecordIndexEntry(ctx, bondID, record.Id)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ProcessDissociateRecords dissociates all records associated with a given bond.
|
||||
func (k Keeper) ProcessDissociateRecords(ctx sdk.Context, msg types.MsgDissociateRecords) error {
|
||||
if !k.bondKeeper.HasBond(ctx, msg.BondId) {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found.")
|
||||
}
|
||||
|
||||
// Only the bond owner can dissociate all records from the bond.
|
||||
bond := k.bondKeeper.GetBond(ctx, msg.BondId)
|
||||
if msg.Signer != bond.Owner {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.")
|
||||
}
|
||||
|
||||
// Dissociate all records from the bond.
|
||||
records := k.recordKeeper.QueryRecordsByBond(ctx, msg.BondId)
|
||||
for _, record := range records {
|
||||
// Clear bond ID.
|
||||
record.BondId = ""
|
||||
k.PutRecord(ctx, record)
|
||||
k.RemoveBondToRecordIndexEntry(ctx, msg.BondId, record.Id)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ProcessReAssociateRecords switches records from and old to new bond.
|
||||
func (k Keeper) ProcessReAssociateRecords(ctx sdk.Context, msg types.MsgReAssociateRecords) error {
|
||||
if !k.bondKeeper.HasBond(ctx, msg.OldBondId) {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Old bond not found.")
|
||||
}
|
||||
|
||||
if !k.bondKeeper.HasBond(ctx, msg.NewBondId) {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "New bond not found.")
|
||||
}
|
||||
|
||||
// Only the bond owner can re-associate all records.
|
||||
oldBond := k.bondKeeper.GetBond(ctx, msg.OldBondId)
|
||||
if msg.Signer != oldBond.Owner {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Old bond owner mismatch.")
|
||||
}
|
||||
|
||||
newBond := k.bondKeeper.GetBond(ctx, msg.NewBondId)
|
||||
if msg.Signer != newBond.Owner {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "New bond owner mismatch.")
|
||||
}
|
||||
|
||||
// Re-associate all records.
|
||||
records := k.recordKeeper.QueryRecordsByBond(ctx, msg.OldBondId)
|
||||
for _, record := range records {
|
||||
// Switch bond ID.
|
||||
record.BondId = msg.NewBondId
|
||||
k.PutRecord(ctx, record)
|
||||
|
||||
k.RemoveBondToRecordIndexEntry(ctx, msg.OldBondId, record.Id)
|
||||
k.AddBondToRecordIndexEntry(ctx, msg.NewBondId, record.Id)
|
||||
|
||||
// Required so that renewal is triggered (with new bond ID) for expired records.
|
||||
if record.Deleted {
|
||||
k.InsertRecordExpiryQueue(ctx, record)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
99
x/nameservice/keeper/sync.go
Normal file
99
x/nameservice/keeper/sync.go
Normal file
|
@ -0,0 +1,99 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/tharsis/ethermint/x/nameservice/helpers"
|
||||
"github.com/tharsis/ethermint/x/nameservice/types"
|
||||
)
|
||||
|
||||
func GetBlockChangeSetIndexKey(height int64) []byte {
|
||||
return append(PrefixBlockChangesetIndex, helpers.Int64ToBytes(height)...)
|
||||
}
|
||||
|
||||
func getOrCreateBlockChangeset(store sdk.KVStore, codec codec.BinaryCodec, height int64) *types.BlockChangeSet {
|
||||
bz := store.Get(GetBlockChangeSetIndexKey(height))
|
||||
|
||||
if bz != nil {
|
||||
var changeSet types.BlockChangeSet
|
||||
err := codec.Unmarshal(bz, &changeSet)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return &changeSet
|
||||
}
|
||||
|
||||
return &types.BlockChangeSet{
|
||||
Height: height,
|
||||
Records: []string{},
|
||||
Names: []string{},
|
||||
Auctions: []string{},
|
||||
AuctionBids: []*types.AuctionBidInfo{},
|
||||
}
|
||||
}
|
||||
|
||||
func updateBlockChangeSetForAuction(ctx sdk.Context, k RecordKeeper, id string) {
|
||||
changeSet := getOrCreateBlockChangeset(ctx.KVStore(k.storeKey), k.cdc, ctx.BlockHeight())
|
||||
|
||||
found := false
|
||||
for _, elem := range changeSet.Auctions {
|
||||
if id == elem {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
changeSet.Auctions = append(changeSet.Auctions, id)
|
||||
saveBlockChangeSet(ctx.KVStore(k.storeKey), k.cdc, changeSet)
|
||||
}
|
||||
}
|
||||
|
||||
func saveBlockChangeSet(store sdk.KVStore, codec codec.BinaryCodec, changeset *types.BlockChangeSet) {
|
||||
bz := codec.MustMarshal(changeset)
|
||||
store.Set(GetBlockChangeSetIndexKey(changeset.Height), bz)
|
||||
}
|
||||
|
||||
func (k Keeper) saveBlockChangeSet(ctx sdk.Context, changeSet *types.BlockChangeSet) {
|
||||
saveBlockChangeSet(ctx.KVStore(k.storeKey), k.cdc, changeSet)
|
||||
}
|
||||
|
||||
func (k Keeper) updateBlockChangeSetForRecord(ctx sdk.Context, id string) {
|
||||
changeSet := k.getOrCreateBlockChangeSet(ctx, ctx.BlockHeight())
|
||||
changeSet.Records = append(changeSet.Records, id)
|
||||
k.saveBlockChangeSet(ctx, changeSet)
|
||||
}
|
||||
|
||||
func (k Keeper) getOrCreateBlockChangeSet(ctx sdk.Context, height int64) *types.BlockChangeSet {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := store.Get(GetBlockChangeSetIndexKey(height))
|
||||
|
||||
if bz != nil {
|
||||
var changeSet types.BlockChangeSet
|
||||
err := k.cdc.Unmarshal(bz, &changeSet)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return &changeSet
|
||||
}
|
||||
|
||||
return &types.BlockChangeSet{
|
||||
Height: height,
|
||||
Records: []string{},
|
||||
Names: []string{},
|
||||
Auctions: []string{},
|
||||
AuctionBids: []*types.AuctionBidInfo{},
|
||||
}
|
||||
}
|
||||
|
||||
func updateBlockChangeSetForAuctionBid(ctx sdk.Context, k RecordKeeper, id, bidderAddress string) {
|
||||
changeSet := getOrCreateBlockChangeset(ctx.KVStore(k.storeKey), k.cdc, ctx.BlockHeight())
|
||||
changeSet.AuctionBids = append(changeSet.AuctionBids, &types.AuctionBidInfo{AuctionId: id, BidderAddress: bidderAddress})
|
||||
saveBlockChangeSet(ctx.KVStore(k.storeKey), k.cdc, changeSet)
|
||||
}
|
||||
|
||||
func updateBlockChangeSetForNameAuthority(ctx sdk.Context, codec codec.BinaryCodec, store sdk.KVStore, name string) {
|
||||
changeSet := getOrCreateBlockChangeset(store, codec, ctx.BlockHeight())
|
||||
changeSet.Authorities = append(changeSet.Authorities, name)
|
||||
saveBlockChangeSet(store, codec, changeSet)
|
||||
}
|
129
x/nameservice/module.go
Normal file
129
x/nameservice/module.go
Normal file
|
@ -0,0 +1,129 @@
|
|||
package nameservice
|
||||
|
||||
import (
|
||||
"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/nameservice/cli"
|
||||
"github.com/tharsis/ethermint/x/nameservice/keeper"
|
||||
"github.com/tharsis/ethermint/x/nameservice/types"
|
||||
)
|
||||
|
||||
// type check to ensure the interface is properly implemented
|
||||
var (
|
||||
_ module.AppModule = AppModule{}
|
||||
_ module.AppModuleBasic = AppModuleBasic{}
|
||||
)
|
||||
|
||||
// AppModuleBasic _ app module Basics object
|
||||
type AppModuleBasic struct{}
|
||||
|
||||
func (a AppModuleBasic) Name() string {
|
||||
return types.ModuleName
|
||||
}
|
||||
|
||||
func (a AppModuleBasic) RegisterLegacyAminoCodec(amino *codec.LegacyAmino) {
|
||||
types.RegisterLegacyAminoCodec(amino)
|
||||
}
|
||||
|
||||
func (a AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
|
||||
types.RegisterInterfaces(registry)
|
||||
}
|
||||
|
||||
func (a AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
|
||||
return cdc.MustMarshalJSON(types.DefaultGenesisState())
|
||||
}
|
||||
|
||||
func (a 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 types.ValidateGenesis(data)
|
||||
}
|
||||
|
||||
func (a AppModuleBasic) RegisterRESTRoutes(context client.Context, router *mux.Router) {
|
||||
}
|
||||
|
||||
func (a AppModuleBasic) RegisterGRPCGatewayRoutes(context client.Context, mux *runtime.ServeMux) {
|
||||
}
|
||||
|
||||
func (a AppModuleBasic) GetTxCmd() *cobra.Command {
|
||||
return cli.NewTxCmd()
|
||||
}
|
||||
|
||||
func (a AppModuleBasic) GetQueryCmd() *cobra.Command {
|
||||
return cli.GetQueryCmd()
|
||||
}
|
||||
|
||||
type AppModule struct {
|
||||
AppModuleBasic
|
||||
keeper 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)
|
||||
}
|
||||
|
||||
// NewAppModule creates a new AppModule Object
|
||||
func NewAppModule(k keeper.Keeper) AppModule {
|
||||
return AppModule{
|
||||
AppModuleBasic: AppModuleBasic{},
|
||||
keeper: k,
|
||||
}
|
||||
}
|
53
x/nameservice/types/codec.go
Normal file
53
x/nameservice/types/codec.go
Normal file
|
@ -0,0 +1,53 @@
|
|||
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(&MsgSetName{}, "nameservice/SetName", nil)
|
||||
cdc.RegisterConcrete(&MsgReserveAuthority{}, "nameservice/ReserveAuthority", nil)
|
||||
cdc.RegisterConcrete(&MsgDeleteNameAuthority{}, "nameservice/DeleteAuthority", nil)
|
||||
cdc.RegisterConcrete(&MsgSetAuthorityBond{}, "nameservice/SetAuthorityBond", nil)
|
||||
|
||||
cdc.RegisterConcrete(&MsgSetRecord{}, "nameservice/SetRecord", nil)
|
||||
cdc.RegisterConcrete(&MsgRenewRecord{}, "nameservice/RenewRecord", nil)
|
||||
cdc.RegisterConcrete(&MsgAssociateBond{}, "nameservice/AssociateBond", nil)
|
||||
cdc.RegisterConcrete(&MsgDissociateBond{}, "nameservice/DissociateBond", nil)
|
||||
cdc.RegisterConcrete(&MsgDissociateRecords{}, "nameservice/DissociateRecords", nil)
|
||||
cdc.RegisterConcrete(&MsgReAssociateRecords{}, "nameservice/ReassociateRecords", nil)
|
||||
}
|
||||
|
||||
func RegisterInterfaces(registry types.InterfaceRegistry) {
|
||||
registry.RegisterImplementations((*sdk.Msg)(nil),
|
||||
&MsgSetName{},
|
||||
&MsgReserveAuthority{},
|
||||
&MsgDeleteNameAuthority{},
|
||||
&MsgSetAuthorityBond{},
|
||||
|
||||
&MsgSetRecord{},
|
||||
&MsgRenewRecord{},
|
||||
&MsgAssociateBond{},
|
||||
&MsgDissociateBond{},
|
||||
&MsgDissociateRecords{},
|
||||
&MsgReAssociateRecords{},
|
||||
)
|
||||
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
|
||||
}
|
||||
|
||||
var (
|
||||
amino = codec.NewLegacyAmino()
|
||||
ModuleCdc = codec.NewAminoCodec(amino)
|
||||
)
|
||||
|
||||
func init() {
|
||||
RegisterLegacyAminoCodec(amino)
|
||||
cryptocodec.RegisterCrypto(amino)
|
||||
amino.Seal()
|
||||
}
|
25
x/nameservice/types/events.go
Normal file
25
x/nameservice/types/events.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
package types
|
||||
|
||||
const (
|
||||
EventTypeSetRecord = "set"
|
||||
EventTypeDeleteName = "delete-name"
|
||||
EventTypeReserveNameAuthority = "reserve-authority"
|
||||
EventTypeAuthorityBond = "authority-bond"
|
||||
EventTypeRenewRecord = "renew-record"
|
||||
EventTypeAssociateBond = "associate-bond"
|
||||
EventTypeDissociateBond = "dissociate-bond"
|
||||
EventTypeDissociateRecords = "dissociate-record"
|
||||
EventTypeReAssociateRecords = "re-associate-records"
|
||||
|
||||
AttributeKeySigner = "signer"
|
||||
AttributeKeyOwner = "owner"
|
||||
AttributeKeyBondId = "bond-id"
|
||||
AttributeKeyPayload = "payload"
|
||||
AttributeKeyOldBondId = "old-bond-id"
|
||||
AttributeKeyNewBondId = "new-bond-id"
|
||||
AttributeKeyCID = "cid"
|
||||
AttributeKeyName = "name"
|
||||
AttributeKeyWRN = "wrn"
|
||||
AttributeKeyRecordId = "record-id"
|
||||
AttributeValueCategory = ModuleName
|
||||
)
|
27
x/nameservice/types/genesis.go
Normal file
27
x/nameservice/types/genesis.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
package types
|
||||
|
||||
func NewGenesisState(params Params, records []Record, authorities []AuthorityEntry, names []NameEntry) GenesisState {
|
||||
return GenesisState{
|
||||
Params: params,
|
||||
Records: records,
|
||||
Authorities: authorities,
|
||||
Names: names,
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultGenesisState sets default evm genesis state with empty accounts and default params and
|
||||
// chain config values.
|
||||
func DefaultGenesisState() *GenesisState {
|
||||
return &GenesisState{
|
||||
Params: DefaultParams(),
|
||||
}
|
||||
}
|
||||
|
||||
func ValidateGenesis(data GenesisState) error {
|
||||
err := data.Params.Validate()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
522
x/nameservice/types/genesis.pb.go
Normal file
522
x/nameservice/types/genesis.pb.go
Normal file
|
@ -0,0 +1,522 @@
|
|||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: vulcanize/nameservice/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 nameservice module's genesis state.
|
||||
type GenesisState struct {
|
||||
// params defines all the params of nameservice module.
|
||||
Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
|
||||
// records
|
||||
Records []Record `protobuf:"bytes,2,rep,name=records,proto3" json:"records" json:"records" yaml:"records"`
|
||||
// authorities
|
||||
Authorities []AuthorityEntry `protobuf:"bytes,3,rep,name=authorities,proto3" json:"authorities" json:"authorities" yaml:"authorities"`
|
||||
// names
|
||||
Names []NameEntry `protobuf:"bytes,4,rep,name=names,proto3" json:"names" json:"names" yaml:"names"`
|
||||
}
|
||||
|
||||
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_fe7037a2b22e67ef, []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) GetRecords() []Record {
|
||||
if m != nil {
|
||||
return m.Records
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GenesisState) GetAuthorities() []AuthorityEntry {
|
||||
if m != nil {
|
||||
return m.Authorities
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GenesisState) GetNames() []NameEntry {
|
||||
if m != nil {
|
||||
return m.Names
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*GenesisState)(nil), "vulcanize.nameservice.v1beta1.GenesisState")
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterFile("vulcanize/nameservice/v1beta1/genesis.proto", fileDescriptor_fe7037a2b22e67ef)
|
||||
}
|
||||
|
||||
var fileDescriptor_fe7037a2b22e67ef = []byte{
|
||||
// 347 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0xd2, 0xb1, 0x4a, 0xfb, 0x40,
|
||||
0x1c, 0x07, 0xf0, 0xe4, 0xdf, 0xfe, 0x2b, 0xa4, 0x4e, 0xc1, 0x21, 0x16, 0x9a, 0xd6, 0x42, 0xa1,
|
||||
0x20, 0xcd, 0x59, 0xdd, 0xdc, 0x8c, 0x88, 0xe0, 0x20, 0x12, 0x37, 0xb7, 0x6b, 0xfc, 0x99, 0x9c,
|
||||
0x34, 0xb9, 0x72, 0xf7, 0x6b, 0x31, 0x0e, 0x3e, 0x83, 0x4f, 0xe0, 0xf3, 0x74, 0xec, 0xe8, 0x54,
|
||||
0xa4, 0x7d, 0x03, 0x9f, 0x40, 0x7a, 0x97, 0x68, 0x5c, 0x5a, 0xb7, 0x5c, 0xf8, 0x7e, 0xbf, 0x9f,
|
||||
0x40, 0xce, 0x3a, 0x9c, 0x4e, 0x46, 0x21, 0x4d, 0xd9, 0x33, 0x90, 0x94, 0x26, 0x20, 0x41, 0x4c,
|
||||
0x59, 0x08, 0x64, 0x3a, 0x18, 0x02, 0xd2, 0x01, 0x89, 0x20, 0x05, 0xc9, 0xa4, 0x37, 0x16, 0x1c,
|
||||
0xb9, 0xdd, 0xfc, 0x0e, 0x7b, 0xa5, 0xb0, 0x97, 0x87, 0x1b, 0x7b, 0x11, 0x8f, 0xb8, 0x4a, 0x92,
|
||||
0xf5, 0x93, 0x2e, 0x35, 0xc8, 0x66, 0xa1, 0x3c, 0xa4, 0x0a, 0x9d, 0xb7, 0x8a, 0xb5, 0x7b, 0xa9,
|
||||
0xdd, 0x5b, 0xa4, 0x08, 0xf6, 0xb9, 0x55, 0x1b, 0x53, 0x41, 0x13, 0xe9, 0x98, 0x6d, 0xb3, 0x57,
|
||||
0x3f, 0xee, 0x7a, 0x1b, 0xbf, 0xc3, 0xbb, 0x51, 0x61, 0xbf, 0x3a, 0x5b, 0xb4, 0x8c, 0x20, 0xaf,
|
||||
0xda, 0x0f, 0xd6, 0x8e, 0x80, 0x90, 0x8b, 0x7b, 0xe9, 0xfc, 0x6b, 0x57, 0xfe, 0xb0, 0x12, 0xa8,
|
||||
0xb4, 0xdf, 0x5d, 0xaf, 0x7c, 0x2e, 0x5a, 0xcd, 0x47, 0xc9, 0xd3, 0xd3, 0x4e, 0xbe, 0xd1, 0x69,
|
||||
0x67, 0x34, 0x19, 0xfd, 0x1c, 0x83, 0x62, 0xdc, 0x7e, 0xb1, 0xea, 0x74, 0x82, 0x31, 0x17, 0x0c,
|
||||
0x19, 0x48, 0xa7, 0xa2, 0xac, 0xfe, 0x16, 0xeb, 0x2c, 0x6f, 0x64, 0x17, 0x29, 0x8a, 0xcc, 0xef,
|
||||
0xe7, 0x66, 0x57, 0x9b, 0xa5, 0xbd, 0xc2, 0x2d, 0xbf, 0x0a, 0xca, 0xa0, 0x4d, 0xad, 0xff, 0x4a,
|
||||
0x70, 0xaa, 0x4a, 0xee, 0x6d, 0x91, 0xaf, 0x69, 0x02, 0x1a, 0x3d, 0xc8, 0xd1, 0x7d, 0x8d, 0xaa,
|
||||
0x70, 0xc1, 0xe9, 0x43, 0xa0, 0x97, 0xfd, 0xab, 0xd9, 0xd2, 0x35, 0xe7, 0x4b, 0xd7, 0xfc, 0x58,
|
||||
0xba, 0xe6, 0xeb, 0xca, 0x35, 0xe6, 0x2b, 0xd7, 0x78, 0x5f, 0xb9, 0xc6, 0xdd, 0x51, 0xc4, 0x30,
|
||||
0x9e, 0x0c, 0xbd, 0x90, 0x27, 0x04, 0x63, 0x2a, 0x24, 0x93, 0x04, 0x30, 0x06, 0x91, 0xb0, 0x14,
|
||||
0xc9, 0xd3, 0xaf, 0x0b, 0x80, 0xd9, 0x18, 0xe4, 0xb0, 0xa6, 0xfe, 0xf9, 0xc9, 0x57, 0x00, 0x00,
|
||||
0x00, 0xff, 0xff, 0xbe, 0x6b, 0x6e, 0x5b, 0x88, 0x02, 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.Names) > 0 {
|
||||
for iNdEx := len(m.Names) - 1; iNdEx >= 0; iNdEx-- {
|
||||
{
|
||||
size, err := m.Names[iNdEx].MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintGenesis(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
}
|
||||
}
|
||||
if len(m.Authorities) > 0 {
|
||||
for iNdEx := len(m.Authorities) - 1; iNdEx >= 0; iNdEx-- {
|
||||
{
|
||||
size, err := m.Authorities[iNdEx].MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintGenesis(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x1a
|
||||
}
|
||||
}
|
||||
if len(m.Records) > 0 {
|
||||
for iNdEx := len(m.Records) - 1; iNdEx >= 0; iNdEx-- {
|
||||
{
|
||||
size, err := m.Records[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.Records) > 0 {
|
||||
for _, e := range m.Records {
|
||||
l = e.Size()
|
||||
n += 1 + l + sovGenesis(uint64(l))
|
||||
}
|
||||
}
|
||||
if len(m.Authorities) > 0 {
|
||||
for _, e := range m.Authorities {
|
||||
l = e.Size()
|
||||
n += 1 + l + sovGenesis(uint64(l))
|
||||
}
|
||||
}
|
||||
if len(m.Names) > 0 {
|
||||
for _, e := range m.Names {
|
||||
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 Records", 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.Records = append(m.Records, Record{})
|
||||
if err := m.Records[len(m.Records)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 3:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Authorities", 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.Authorities = append(m.Authorities, AuthorityEntry{})
|
||||
if err := m.Authorities[len(m.Authorities)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 4:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Names", 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.Names = append(m.Names, NameEntry{})
|
||||
if err := m.Names[len(m.Names)-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")
|
||||
)
|
21
x/nameservice/types/keys.go
Normal file
21
x/nameservice/types/keys.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
package types
|
||||
|
||||
const (
|
||||
// ModuleName is the name of the staking module
|
||||
ModuleName = "nameservice"
|
||||
|
||||
// RecordRentModuleAccountName is the name of the module account that keeps track of record rents paid.
|
||||
RecordRentModuleAccountName = "record_rent"
|
||||
|
||||
// AuthorityRentModuleAccountName is the name of the module account that keeps track of authority rents paid.
|
||||
AuthorityRentModuleAccountName = "authority_rent"
|
||||
|
||||
// StoreKey is the string store representation
|
||||
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
|
||||
)
|
188
x/nameservice/types/msg.go
Normal file
188
x/nameservice/types/msg.go
Normal file
|
@ -0,0 +1,188 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
var (
|
||||
_ sdk.Msg = &MsgSetName{}
|
||||
_ sdk.Msg = &MsgReserveAuthority{}
|
||||
_ sdk.Msg = &MsgSetAuthorityBond{}
|
||||
_ sdk.Msg = &MsgDeleteNameAuthority{}
|
||||
)
|
||||
|
||||
// NewMsgSetName is the constructor function for MsgSetName.
|
||||
func NewMsgSetName(wrn string, cid string, signer sdk.AccAddress) MsgSetName {
|
||||
return MsgSetName{
|
||||
Wrn: wrn,
|
||||
Cid: cid,
|
||||
Signer: signer.String(),
|
||||
}
|
||||
}
|
||||
|
||||
// Route Implements Msg.
|
||||
func (msg MsgSetName) Route() string { return RouterKey }
|
||||
|
||||
// Type Implements Msg.
|
||||
func (msg MsgSetName) Type() string { return "set-name" }
|
||||
|
||||
// ValidateBasic Implements Msg.
|
||||
func (msg MsgSetName) ValidateBasic() error {
|
||||
|
||||
if msg.Wrn == "" {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "WRN is required.")
|
||||
}
|
||||
|
||||
if msg.Cid == "" {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "CID is required.")
|
||||
}
|
||||
|
||||
if len(msg.Signer) == 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSignBytes gets the sign bytes for the msg MsgSetName
|
||||
func (msg MsgSetName) GetSignBytes() []byte {
|
||||
bz := ModuleCdc.MustMarshalJSON(&msg)
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
||||
// GetSigners Implements Msg.
|
||||
func (msg MsgSetName) GetSigners() []sdk.AccAddress {
|
||||
accAddr, _ := sdk.AccAddressFromBech32(msg.Signer)
|
||||
return []sdk.AccAddress{accAddr}
|
||||
}
|
||||
|
||||
// NewMsgReserveAuthority is the constructor function for MsgReserveName.
|
||||
func NewMsgReserveAuthority(name string, signer sdk.AccAddress, owner sdk.AccAddress) MsgReserveAuthority {
|
||||
return MsgReserveAuthority{
|
||||
Name: name,
|
||||
Owner: owner.String(),
|
||||
Signer: signer.String(),
|
||||
}
|
||||
}
|
||||
|
||||
// Route Implements Msg.
|
||||
func (msg MsgReserveAuthority) Route() string { return RouterKey }
|
||||
|
||||
// Type Implements Msg.
|
||||
func (msg MsgReserveAuthority) Type() string { return "reserve-authority" }
|
||||
|
||||
// ValidateBasic Implements Msg.
|
||||
func (msg MsgReserveAuthority) ValidateBasic() error {
|
||||
|
||||
if len(msg.Name) == 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "name is required.")
|
||||
}
|
||||
|
||||
if len(msg.Signer) == 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSignBytes gets the sign bytes for the msg MsgSetName
|
||||
func (msg MsgReserveAuthority) GetSignBytes() []byte {
|
||||
bz := ModuleCdc.MustMarshalJSON(&msg)
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
||||
// GetSigners Implements Msg.
|
||||
func (msg MsgReserveAuthority) GetSigners() []sdk.AccAddress {
|
||||
accAddr, _ := sdk.AccAddressFromBech32(msg.Signer)
|
||||
return []sdk.AccAddress{accAddr}
|
||||
}
|
||||
|
||||
// NewMsgSetAuthorityBond is the constructor function for MsgSetAuthorityBond.
|
||||
func NewMsgSetAuthorityBond(name string, bondId string, signer sdk.AccAddress) MsgSetAuthorityBond {
|
||||
return MsgSetAuthorityBond{
|
||||
Name: name,
|
||||
Signer: signer.String(),
|
||||
BondId: bondId,
|
||||
}
|
||||
}
|
||||
|
||||
// Route Implements Msg.
|
||||
func (msg MsgSetAuthorityBond) Route() string { return RouterKey }
|
||||
|
||||
// Type Implements Msg.
|
||||
func (msg MsgSetAuthorityBond) Type() string { return "authority-bond" }
|
||||
|
||||
// ValidateBasic Implements Msg.
|
||||
func (msg MsgSetAuthorityBond) ValidateBasic() error {
|
||||
if len(msg.Name) == 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "name is required.")
|
||||
}
|
||||
|
||||
if len(msg.Signer) == 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer.")
|
||||
}
|
||||
|
||||
if len(msg.BondId) == 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "bond id is required.")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSignBytes gets the sign bytes for the msg MsgSetName
|
||||
func (msg MsgSetAuthorityBond) GetSignBytes() []byte {
|
||||
bz := ModuleCdc.MustMarshalJSON(&msg)
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
||||
// GetSigners Implements Msg.
|
||||
func (msg MsgSetAuthorityBond) GetSigners() []sdk.AccAddress {
|
||||
accAddr, _ := sdk.AccAddressFromBech32(msg.Signer)
|
||||
return []sdk.AccAddress{accAddr}
|
||||
}
|
||||
|
||||
// NewMsgDeleteNameAuthority is the constructor function for MsgDeleteNameAuthority.
|
||||
func NewMsgDeleteNameAuthority(wrn string, signer sdk.AccAddress) MsgDeleteNameAuthority {
|
||||
return MsgDeleteNameAuthority{
|
||||
Wrn: wrn,
|
||||
Signer: signer.String(),
|
||||
}
|
||||
}
|
||||
|
||||
// Route Implements Msg.
|
||||
func (msg MsgDeleteNameAuthority) Route() string { return RouterKey }
|
||||
|
||||
// Type Implements Msg.
|
||||
func (msg MsgDeleteNameAuthority) Type() string { return "delete-name" }
|
||||
|
||||
// ValidateBasic Implements Msg.
|
||||
func (msg MsgDeleteNameAuthority) ValidateBasic() error {
|
||||
if len(msg.Wrn) == 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "wrn is required.")
|
||||
}
|
||||
|
||||
if len(msg.Signer) == 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer.")
|
||||
}
|
||||
|
||||
_, err := url.Parse(msg.Wrn)
|
||||
if err != nil {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "invalid wrn.")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSignBytes gets the sign bytes for the msg MsgSetName
|
||||
func (msg MsgDeleteNameAuthority) GetSignBytes() []byte {
|
||||
bz := ModuleCdc.MustMarshalJSON(&msg)
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
||||
// GetSigners Implements Msg.
|
||||
func (msg MsgDeleteNameAuthority) GetSigners() []sdk.AccAddress {
|
||||
accAddr, _ := sdk.AccAddressFromBech32(msg.Signer)
|
||||
return []sdk.AccAddress{accAddr}
|
||||
}
|
3633
x/nameservice/types/nameservice.pb.go
Normal file
3633
x/nameservice/types/nameservice.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
239
x/nameservice/types/params.go
Normal file
239
x/nameservice/types/params.go
Normal file
|
@ -0,0 +1,239 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Default parameter values.
|
||||
var (
|
||||
// DefaultRecordRent is the default record rent for 1 time period (see expiry time).
|
||||
DefaultRecordRent = sdk.NewInt(1000000)
|
||||
|
||||
// DefaultRecordExpiryTime is the default record expiry time (1 year).
|
||||
DefaultRecordExpiryTime = time.Hour * 24 * 365
|
||||
|
||||
DefaultAuthorityRent = sdk.NewInt(1000000)
|
||||
DefaultAuthorityExpiryTime = time.Hour * 24 * 365
|
||||
DefaultAuthorityGracePeriod = time.Hour * 24 * 2
|
||||
|
||||
DefaultAuthorityAuctionEnabled = false
|
||||
DefaultCommitsDuration = time.Hour * 24
|
||||
DefaultRevealsDuration = time.Hour * 24
|
||||
DefaultCommitFee = sdk.NewInt(1000000)
|
||||
DefaultRevealFee = sdk.NewInt(1000000)
|
||||
DefaultMinimumBid = sdk.NewInt(5000000)
|
||||
)
|
||||
|
||||
// Keys for parameter access
|
||||
var (
|
||||
KeyRecordRent = []byte("RecordRent")
|
||||
KeyRecordRentDuration = []byte("RecordRentDuration")
|
||||
|
||||
KeyAuthorityRent = []byte("AuthorityRent")
|
||||
KeyAuthorityRentDuration = []byte("AuthorityRentDuration")
|
||||
KeyAuthorityGracePeriod = []byte("AuthorityGracePeriod")
|
||||
|
||||
KeyAuthorityAuctionEnabled = []byte("AuthorityAuctionEnabled")
|
||||
KeyCommitsDuration = []byte("AuthorityAuctionCommitsDuration")
|
||||
KeyRevealsDuration = []byte("AuthorityAuctionRevealsDuration")
|
||||
KeyCommitFee = []byte("AuthorityAuctionCommitFee")
|
||||
KeyRevealFee = []byte("AuthorityAuctionRevealFee")
|
||||
KeyMinimumBid = []byte("AuthorityAuctionMinimumBid")
|
||||
)
|
||||
|
||||
var _ paramtypes.ParamSet = &Params{}
|
||||
|
||||
// ParamKeyTable ParamTable for staking module
|
||||
func ParamKeyTable() paramtypes.KeyTable {
|
||||
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
|
||||
}
|
||||
|
||||
// ParamSetPairs returns the parameter set pairs.
|
||||
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
|
||||
return paramtypes.ParamSetPairs{
|
||||
paramtypes.NewParamSetPair(KeyRecordRent, &p.RecordRent, validateRecordRent),
|
||||
paramtypes.NewParamSetPair(KeyRecordRentDuration, &p.RecordRentDuration, validateRecordRentDuration),
|
||||
|
||||
paramtypes.NewParamSetPair(KeyAuthorityRent, &p.AuthorityRent, validateAuthorityRent),
|
||||
paramtypes.NewParamSetPair(KeyAuthorityRentDuration, &p.AuthorityRentDuration, validateAuthorityRentDuration),
|
||||
paramtypes.NewParamSetPair(KeyAuthorityGracePeriod, &p.AuthorityGracePeriod, validateAuthorityGracePeriod),
|
||||
|
||||
paramtypes.NewParamSetPair(KeyAuthorityAuctionEnabled, &p.AuthorityAuctionEnabled, validateAuthorityAuctionEnabled),
|
||||
paramtypes.NewParamSetPair(KeyCommitsDuration, &p.AuthorityAuctionCommitsDuration, validateCommitsDuration),
|
||||
paramtypes.NewParamSetPair(KeyRevealsDuration, &p.AuthorityAuctionRevealsDuration, validateRevealsDuration),
|
||||
paramtypes.NewParamSetPair(KeyCommitFee, &p.AuthorityAuctionCommitFee, validateCommitFee),
|
||||
paramtypes.NewParamSetPair(KeyRevealFee, &p.AuthorityAuctionRevealFee, validateRevealFee),
|
||||
paramtypes.NewParamSetPair(KeyMinimumBid, &p.AuthorityAuctionMinimumBid, validateMinimumBid),
|
||||
}
|
||||
}
|
||||
|
||||
// NewParams creates a new Params instance
|
||||
func NewParams(recordRent sdk.Coin, recordRentDuration time.Duration,
|
||||
authorityRent sdk.Coin, authorityRentDuration time.Duration, authorityGracePeriod time.Duration,
|
||||
authorityAuctionEnabled bool, commitsDuration time.Duration, revealsDuration time.Duration,
|
||||
commitFee sdk.Coin, revealFee sdk.Coin, minimumBid sdk.Coin) Params {
|
||||
|
||||
return Params{
|
||||
RecordRent: recordRent,
|
||||
RecordRentDuration: recordRentDuration,
|
||||
|
||||
AuthorityRent: authorityRent,
|
||||
AuthorityRentDuration: authorityRentDuration,
|
||||
AuthorityGracePeriod: authorityGracePeriod,
|
||||
|
||||
AuthorityAuctionEnabled: authorityAuctionEnabled,
|
||||
AuthorityAuctionCommitsDuration: commitsDuration,
|
||||
AuthorityAuctionRevealsDuration: revealsDuration,
|
||||
AuthorityAuctionCommitFee: commitFee,
|
||||
AuthorityAuctionRevealFee: revealFee,
|
||||
AuthorityAuctionMinimumBid: minimumBid,
|
||||
}
|
||||
}
|
||||
|
||||
// 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 NewParams(
|
||||
sdk.NewCoin(sdk.DefaultBondDenom, DefaultRecordRent), DefaultRecordExpiryTime,
|
||||
sdk.NewCoin(sdk.DefaultBondDenom, DefaultAuthorityRent),
|
||||
DefaultAuthorityExpiryTime, DefaultAuthorityGracePeriod, DefaultAuthorityAuctionEnabled, DefaultCommitsDuration,
|
||||
DefaultRevealsDuration,
|
||||
sdk.NewCoin(sdk.DefaultBondDenom, DefaultCommitFee),
|
||||
sdk.NewCoin(sdk.DefaultBondDenom, DefaultRevealFee),
|
||||
sdk.NewCoin(sdk.DefaultBondDenom, DefaultMinimumBid),
|
||||
)
|
||||
}
|
||||
|
||||
func validateAmount(name string, i interface{}) error {
|
||||
v, ok := i.(sdk.Coin)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid parameter type: %T", i)
|
||||
}
|
||||
|
||||
if v.Amount.IsNegative() {
|
||||
return fmt.Errorf("%s can't be negative", name)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateDuration(name string, i interface{}) error {
|
||||
v, ok := i.(time.Duration)
|
||||
if !ok {
|
||||
return fmt.Errorf("%s invalid parameter type: %T", name, i)
|
||||
}
|
||||
|
||||
if v <= 0 {
|
||||
return fmt.Errorf("%s must be a positive integer", name)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateRecordRent(i interface{}) error {
|
||||
return validateAmount("RecordRent", i)
|
||||
}
|
||||
|
||||
func validateRecordRentDuration(i interface{}) error {
|
||||
return validateDuration("RecordRentDuration", i)
|
||||
}
|
||||
|
||||
func validateAuthorityRent(i interface{}) error {
|
||||
return validateAmount("AuthorityRent", i)
|
||||
}
|
||||
|
||||
func validateAuthorityRentDuration(i interface{}) error {
|
||||
return validateDuration("AuthorityRentDuration", i)
|
||||
}
|
||||
|
||||
func validateAuthorityGracePeriod(i interface{}) error {
|
||||
return validateDuration("AuthorityGracePeriod", i)
|
||||
}
|
||||
|
||||
func validateAuthorityAuctionEnabled(i interface{}) error {
|
||||
_, ok := i.(bool)
|
||||
if !ok {
|
||||
return fmt.Errorf("%s invalid parameter type: %T", "AuthorityAuctionEnabled", i)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateCommitsDuration(i interface{}) error {
|
||||
return validateDuration("AuthorityCommitsDuration", i)
|
||||
}
|
||||
|
||||
func validateRevealsDuration(i interface{}) error {
|
||||
return validateDuration("AuthorityRevealsDuration", i)
|
||||
}
|
||||
|
||||
func validateCommitFee(i interface{}) error {
|
||||
return validateAmount("AuthorityCommitFee", i)
|
||||
}
|
||||
|
||||
func validateRevealFee(i interface{}) error {
|
||||
return validateAmount("AuthorityRevealFee", i)
|
||||
}
|
||||
|
||||
func validateMinimumBid(i interface{}) error {
|
||||
return validateAmount("AuthorityMinimumBid", i)
|
||||
}
|
||||
|
||||
// Validate a set of params.
|
||||
func (p Params) Validate() error {
|
||||
if err := validateRecordRent(p.RecordRent); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validateRecordRentDuration(p.RecordRentDuration); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validateAuthorityRent(p.AuthorityRent); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validateAuthorityRentDuration(p.AuthorityRentDuration); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validateAuthorityGracePeriod(p.AuthorityGracePeriod); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validateAuthorityAuctionEnabled(p.AuthorityAuctionEnabled); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validateCommitsDuration(p.AuthorityAuctionCommitsDuration); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validateRevealsDuration(p.AuthorityAuctionRevealsDuration); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validateCommitFee(p.AuthorityAuctionCommitFee); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validateRevealFee(p.AuthorityAuctionRevealFee); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validateMinimumBid(p.AuthorityAuctionMinimumBid); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
5307
x/nameservice/types/query.pb.go
Normal file
5307
x/nameservice/types/query.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
1038
x/nameservice/types/query.pb.gw.go
Normal file
1038
x/nameservice/types/query.pb.gw.go
Normal file
File diff suppressed because it is too large
Load Diff
251
x/nameservice/types/record_msg.go
Normal file
251
x/nameservice/types/record_msg.go
Normal file
|
@ -0,0 +1,251 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
_ sdk.Msg = &MsgSetRecord{}
|
||||
_ sdk.Msg = &MsgRenewRecord{}
|
||||
_ sdk.Msg = &MsgAssociateBond{}
|
||||
_ sdk.Msg = &MsgDissociateBond{}
|
||||
_ sdk.Msg = &MsgDissociateRecords{}
|
||||
_ sdk.Msg = &MsgReAssociateRecords{}
|
||||
)
|
||||
|
||||
// NewMsgSetRecord is the constructor function for MsgSetRecord.
|
||||
func NewMsgSetRecord(payload Payload, bondID string, signer sdk.AccAddress) MsgSetRecord {
|
||||
return MsgSetRecord{
|
||||
Payload: payload,
|
||||
BondId: bondID,
|
||||
Signer: signer.String(),
|
||||
}
|
||||
}
|
||||
|
||||
func (msg MsgSetRecord) ValidateBasic() error {
|
||||
if len(msg.Signer) == 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.Signer)
|
||||
}
|
||||
owners := msg.Payload.Record.Owners
|
||||
for _, owner := range owners {
|
||||
if owner == "" {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Record owner not set.")
|
||||
}
|
||||
}
|
||||
|
||||
if len(msg.BondId) == 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Bond ID is required.")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (msg MsgSetRecord) GetSigners() []sdk.AccAddress {
|
||||
accAddr, _ := sdk.AccAddressFromBech32(msg.Signer)
|
||||
return []sdk.AccAddress{accAddr}
|
||||
}
|
||||
|
||||
// GetSignBytes gets the sign bytes for the msg MsgCreateBond
|
||||
func (msg MsgSetRecord) GetSignBytes() []byte {
|
||||
bz := ModuleCdc.MustMarshalJSON(&msg)
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
||||
// NewMsgRenewRecord is the constructor function for MsgRenewRecord.
|
||||
func NewMsgRenewRecord(recordId string, signer sdk.AccAddress) MsgRenewRecord {
|
||||
return MsgRenewRecord{
|
||||
RecordId: recordId,
|
||||
Signer: signer.String(),
|
||||
}
|
||||
}
|
||||
|
||||
// Route Implements Msg.
|
||||
func (msg MsgRenewRecord) Route() string { return RouterKey }
|
||||
|
||||
// Type Implements Msg.
|
||||
func (msg MsgRenewRecord) Type() string { return "renew-record" }
|
||||
|
||||
// ValidateBasic Implements Msg.
|
||||
func (msg MsgRenewRecord) ValidateBasic() error {
|
||||
if len(msg.RecordId) == 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "record id is required.")
|
||||
}
|
||||
|
||||
if len(msg.Signer) == 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer.")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSignBytes gets the sign bytes for Msg
|
||||
func (msg MsgRenewRecord) GetSignBytes() []byte {
|
||||
bz := ModuleCdc.MustMarshalJSON(&msg)
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
||||
// GetSigners Implements Msg.
|
||||
func (msg MsgRenewRecord) GetSigners() []sdk.AccAddress {
|
||||
accAddr, _ := sdk.AccAddressFromBech32(msg.Signer)
|
||||
return []sdk.AccAddress{accAddr}
|
||||
}
|
||||
|
||||
// NewMsgAssociateBond is the constructor function for MsgAssociateBond.
|
||||
func NewMsgAssociateBond(recordId, bondId string, signer sdk.AccAddress) MsgAssociateBond {
|
||||
return MsgAssociateBond{
|
||||
BondId: bondId,
|
||||
RecordId: recordId,
|
||||
Signer: signer.String(),
|
||||
}
|
||||
}
|
||||
|
||||
// Route Implements Msg.
|
||||
func (msg MsgAssociateBond) Route() string { return RouterKey }
|
||||
|
||||
// Type Implements Msg.
|
||||
func (msg MsgAssociateBond) Type() string { return "associate-bond" }
|
||||
|
||||
// ValidateBasic Implements Msg.
|
||||
func (msg MsgAssociateBond) ValidateBasic() error {
|
||||
if len(msg.RecordId) == 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "record id is required.")
|
||||
}
|
||||
if len(msg.BondId) == 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "bond id is required.")
|
||||
}
|
||||
if len(msg.Signer) == 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer.")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSignBytes gets the sign bytes for Msg
|
||||
func (msg MsgAssociateBond) GetSignBytes() []byte {
|
||||
bz := ModuleCdc.MustMarshalJSON(&msg)
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
||||
// GetSigners Implements Msg.
|
||||
func (msg MsgAssociateBond) GetSigners() []sdk.AccAddress {
|
||||
accAddr, _ := sdk.AccAddressFromBech32(msg.Signer)
|
||||
return []sdk.AccAddress{accAddr}
|
||||
}
|
||||
|
||||
// NewMsgDissociateBond is the constructor function for MsgDissociateBond.
|
||||
func NewMsgDissociateBond(recordId string, signer sdk.AccAddress) MsgDissociateBond {
|
||||
return MsgDissociateBond{
|
||||
RecordId: recordId,
|
||||
Signer: signer.String(),
|
||||
}
|
||||
}
|
||||
|
||||
// Route Implements Msg.
|
||||
func (msg MsgDissociateBond) Route() string { return RouterKey }
|
||||
|
||||
// Type Implements Msg.
|
||||
func (msg MsgDissociateBond) Type() string { return "dissociate-bond" }
|
||||
|
||||
// ValidateBasic Implements Msg.
|
||||
func (msg MsgDissociateBond) ValidateBasic() error {
|
||||
if len(msg.RecordId) == 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "record id is required.")
|
||||
}
|
||||
if len(msg.Signer) == 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer.")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSignBytes gets the sign bytes for Msg
|
||||
func (msg MsgDissociateBond) GetSignBytes() []byte {
|
||||
bz := ModuleCdc.MustMarshalJSON(&msg)
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
||||
// GetSigners Implements Msg.
|
||||
func (msg MsgDissociateBond) GetSigners() []sdk.AccAddress {
|
||||
accAddr, _ := sdk.AccAddressFromBech32(msg.Signer)
|
||||
return []sdk.AccAddress{accAddr}
|
||||
}
|
||||
|
||||
// NewMsgDissociateRecords is the constructor function for MsgDissociateRecords.
|
||||
func NewMsgDissociateRecords(bondId string, signer sdk.AccAddress) MsgDissociateRecords {
|
||||
return MsgDissociateRecords{
|
||||
BondId: bondId,
|
||||
Signer: signer.String(),
|
||||
}
|
||||
}
|
||||
|
||||
// Route Implements Msg.
|
||||
func (msg MsgDissociateRecords) Route() string { return RouterKey }
|
||||
|
||||
// Type Implements Msg.
|
||||
func (msg MsgDissociateRecords) Type() string { return "dissociate-records" }
|
||||
|
||||
// ValidateBasic Implements Msg.
|
||||
func (msg MsgDissociateRecords) ValidateBasic() error {
|
||||
if len(msg.BondId) == 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "bond id is required.")
|
||||
}
|
||||
if len(msg.Signer) == 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer.")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSignBytes gets the sign bytes for Msg
|
||||
func (msg MsgDissociateRecords) GetSignBytes() []byte {
|
||||
bz := ModuleCdc.MustMarshalJSON(&msg)
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
||||
// GetSigners Implements Msg.
|
||||
func (msg MsgDissociateRecords) GetSigners() []sdk.AccAddress {
|
||||
accAddr, _ := sdk.AccAddressFromBech32(msg.Signer)
|
||||
return []sdk.AccAddress{accAddr}
|
||||
}
|
||||
|
||||
// NewMsgReAssociateRecords is the constructor function for MsgReAssociateRecords.
|
||||
func NewMsgReAssociateRecords(oldBondId, newBondId string, signer sdk.AccAddress) MsgReAssociateRecords {
|
||||
return MsgReAssociateRecords{
|
||||
OldBondId: oldBondId,
|
||||
NewBondId: newBondId,
|
||||
Signer: signer.String(),
|
||||
}
|
||||
}
|
||||
|
||||
// Route Implements Msg.
|
||||
func (msg MsgReAssociateRecords) Route() string { return RouterKey }
|
||||
|
||||
// Type Implements Msg.
|
||||
func (msg MsgReAssociateRecords) Type() string { return "reassociate-records" }
|
||||
|
||||
// ValidateBasic Implements Msg.
|
||||
func (msg MsgReAssociateRecords) ValidateBasic() error {
|
||||
if len(msg.OldBondId) == 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "old-bond-id is required.")
|
||||
}
|
||||
if len(msg.NewBondId) == 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "new-bond-id is required.")
|
||||
}
|
||||
if len(msg.Signer) == 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer.")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSignBytes gets the sign bytes for Msg
|
||||
func (msg MsgReAssociateRecords) GetSignBytes() []byte {
|
||||
bz := ModuleCdc.MustMarshalJSON(&msg)
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
||||
// GetSigners Implements Msg.
|
||||
func (msg MsgReAssociateRecords) GetSigners() []sdk.AccAddress {
|
||||
accAddr, _ := sdk.AccAddressFromBech32(msg.Signer)
|
||||
return []sdk.AccAddress{accAddr}
|
||||
}
|
4592
x/nameservice/types/tx.pb.go
Normal file
4592
x/nameservice/types/tx.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
132
x/nameservice/types/types.go
Normal file
132
x/nameservice/types/types.go
Normal file
|
@ -0,0 +1,132 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
canonicalJson "github.com/gibson042/canonicaljson-go"
|
||||
"github.com/tharsis/ethermint/x/nameservice/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
AuthorityActive = "active"
|
||||
AuthorityExpired = "expired"
|
||||
AuthorityUnderAuction = "auction"
|
||||
)
|
||||
|
||||
// PayloadType represents a signed record payload that can be serialized from/to YAML.
|
||||
type PayloadType struct {
|
||||
Record map[string]interface{} `json:"record"`
|
||||
Signatures []Signature `json:"signatures"`
|
||||
}
|
||||
|
||||
// ToPayload converts PayloadType to Payload object.
|
||||
// Why? Because go-amino can't handle maps: https://github.com/tendermint/go-amino/issues/4.
|
||||
func (payloadObj *PayloadType) ToPayload() Payload {
|
||||
var payload = Payload{
|
||||
Record: &Record{
|
||||
CreateTime: time.Time{},
|
||||
ExpiryTime: time.Time{},
|
||||
Deleted: false,
|
||||
Owners: nil,
|
||||
Attributes: helpers.MarshalMapToJSONBytes(payloadObj.Record),
|
||||
},
|
||||
Signatures: payloadObj.Signatures,
|
||||
}
|
||||
return payload
|
||||
}
|
||||
|
||||
// ToReadablePayload converts Payload to PayloadType
|
||||
// It will unmarshal with record attributes
|
||||
func (payload Payload) ToReadablePayload() PayloadType {
|
||||
var payloadType PayloadType
|
||||
|
||||
payloadType.Record = helpers.UnMarshalMapFromJSONBytes(payload.Record.Attributes)
|
||||
|
||||
payloadType.Signatures = payload.Signatures
|
||||
|
||||
return payloadType
|
||||
}
|
||||
|
||||
// Record to Record Type for human-readable attributes
|
||||
|
||||
func (r *Record) ToRecordType() RecordType {
|
||||
var resourceObj RecordType
|
||||
|
||||
resourceObj.Id = r.Id
|
||||
resourceObj.BondId = r.BondId
|
||||
resourceObj.CreateTime = r.CreateTime
|
||||
resourceObj.ExpiryTime = r.ExpiryTime
|
||||
resourceObj.Deleted = r.Deleted
|
||||
resourceObj.Owners = r.Owners
|
||||
resourceObj.Attributes = helpers.UnMarshalMapFromJSONBytes(r.Attributes)
|
||||
|
||||
return resourceObj
|
||||
}
|
||||
|
||||
// RecordType represents a WNS record.
|
||||
type RecordType struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Names []string `json:"names,omitempty"`
|
||||
BondId string `json:"bondId,omitempty"`
|
||||
CreateTime time.Time `json:"createTime,omitempty"`
|
||||
ExpiryTime time.Time `json:"expiryTime,omitempty"`
|
||||
Deleted bool `json:"deleted,omitempty"`
|
||||
Owners []string `json:"owners,omitempty"`
|
||||
Attributes map[string]interface{} `json:"attributes,omitempty"`
|
||||
}
|
||||
|
||||
// ToRecordObj converts Record to RecordObj.
|
||||
// Why? Because go-amino can't handle maps: https://github.com/tendermint/go-amino/issues/4.
|
||||
func (r *RecordType) ToRecordObj() Record {
|
||||
var resourceObj Record
|
||||
|
||||
resourceObj.Id = r.Id
|
||||
resourceObj.BondId = r.BondId
|
||||
resourceObj.CreateTime = r.CreateTime
|
||||
resourceObj.ExpiryTime = r.ExpiryTime
|
||||
resourceObj.Deleted = r.Deleted
|
||||
resourceObj.Owners = r.Owners
|
||||
resourceObj.Attributes = helpers.MarshalMapToJSONBytes(r.Attributes)
|
||||
|
||||
return resourceObj
|
||||
}
|
||||
|
||||
// CanonicalJSON returns the canonical JSON representation of the record.
|
||||
func (r *RecordType) CanonicalJSON() []byte {
|
||||
bytes, err := canonicalJson.Marshal(r.Attributes)
|
||||
if err != nil {
|
||||
panic("Record marshal error.")
|
||||
}
|
||||
|
||||
return bytes
|
||||
}
|
||||
|
||||
// GetSignBytes generates a record hash to be signed.
|
||||
func (r *RecordType) GetSignBytes() ([]byte, []byte) {
|
||||
// Double SHA256 hash.
|
||||
|
||||
// Input to the first round of hashing.
|
||||
bytes := r.CanonicalJSON()
|
||||
|
||||
// First round.
|
||||
first := sha256.New()
|
||||
first.Write(bytes)
|
||||
firstHash := first.Sum(nil)
|
||||
|
||||
// Second round of hashing takes as input the output of the first round.
|
||||
second := sha256.New()
|
||||
second.Write(firstHash)
|
||||
secondHash := second.Sum(nil)
|
||||
|
||||
return secondHash, bytes
|
||||
}
|
||||
|
||||
// GetCID gets the record CID.
|
||||
func (r *RecordType) GetCID() (string, error) {
|
||||
id, err := helpers.GetCid(r.CanonicalJSON())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return id, nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user