rename Contract -> ContractInfo

This commit is contained in:
Sunny Aggarwal 2020-01-09 14:53:36 -05:00
parent 57688babf0
commit e9c772845f
7 changed files with 17 additions and 17 deletions

View File

@ -52,7 +52,7 @@ var (
NewCodeInfo = types.NewCodeInfo
NewParams = types.NewParams
NewWasmCoins = types.NewWasmCoins
NewContract = types.NewContract
NewContractInfo = types.NewContractInfo
CosmosResult = types.CosmosResult
// genesis aliases
@ -76,7 +76,7 @@ type (
MsgInstantiateContract = types.MsgInstantiateContract
MsgExecuteContract = types.MsgExecuteContract
CodeInfo = types.CodeInfo
Contract = types.Contract
ContractInfo = types.ContractInfo
GenesisState = types.GenesisState
)

View File

@ -47,7 +47,7 @@ func ExportGenesis(ctx sdk.Context, keeper Keeper) types.GenesisState {
})
}
keeper.ListContractInfo(ctx, func(addr sdk.AccAddress, contract types.Contract) bool {
keeper.ListContractInfo(ctx, func(addr sdk.AccAddress, contract types.ContractInfo) bool {
contractStateIterator := keeper.GetContractState(ctx, addr)
var state []types.Model
for ; contractStateIterator.Valid(); contractStateIterator.Next() {

View File

@ -118,7 +118,7 @@ func (k Keeper) Instantiate(ctx sdk.Context, creator sdk.AccAddress, codeID uint
}
// persist instance
instance := types.NewContract(codeID, creator, string(initMsg))
instance := types.NewContractInfo(codeID, creator, string(initMsg))
// 0x02 | contractAddress (sdk.AccAddress) -> Instance
store.Set(types.GetContractAddressKey(contractAddress), k.cdc.MustMarshalBinaryBare(instance))
@ -129,7 +129,7 @@ func (k Keeper) Instantiate(ctx sdk.Context, creator sdk.AccAddress, codeID uint
func (k Keeper) Execute(ctx sdk.Context, contractAddress sdk.AccAddress, caller sdk.AccAddress, coins sdk.Coins, msgs []byte) (sdk.Result, sdk.Error) {
store := ctx.KVStore(k.storeKey)
var contract types.Contract
var contract types.ContractInfo
contractBz := store.Get(types.GetContractAddressKey(contractAddress))
if contractBz != nil {
k.cdc.MustUnmarshalBinaryBare(contractBz, &contract)
@ -167,9 +167,9 @@ func (k Keeper) Execute(ctx sdk.Context, contractAddress sdk.AccAddress, caller
return types.CosmosResult(*res), nil
}
func (k Keeper) GetContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) *types.Contract {
func (k Keeper) GetContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) *types.ContractInfo {
store := ctx.KVStore(k.storeKey)
var contract types.Contract
var contract types.ContractInfo
contractBz := store.Get(types.GetContractAddressKey(contractAddress))
if contractBz == nil {
return nil
@ -178,16 +178,16 @@ func (k Keeper) GetContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress)
return &contract
}
func (k Keeper) setContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress, contract types.Contract) {
func (k Keeper) setContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress, contract types.ContractInfo) {
store := ctx.KVStore(k.storeKey)
store.Set(types.GetContractAddressKey(contractAddress), k.cdc.MustMarshalBinaryBare(contract))
}
func (k Keeper) ListContractInfo(ctx sdk.Context, cb func(sdk.AccAddress, types.Contract) bool) {
func (k Keeper) ListContractInfo(ctx sdk.Context, cb func(sdk.AccAddress, types.ContractInfo) bool) {
prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.ContractKeyPrefix)
iter := prefixStore.Iterator(nil, nil)
for ; iter.Valid(); iter.Next() {
var contract types.Contract
var contract types.ContractInfo
k.cdc.MustUnmarshalBinaryBare(iter.Value(), &contract)
// cb returns true to stop early
if cb(iter.Key(), contract) {

View File

@ -56,7 +56,7 @@ func queryContractInfo(ctx sdk.Context, bech string, req abci.RequestQuery, keep
func queryContractList(ctx sdk.Context, req abci.RequestQuery, keeper Keeper) ([]byte, sdk.Error) {
var addrs []string
keeper.ListContractInfo(ctx, func(addr sdk.AccAddress, _ types.Contract) bool {
keeper.ListContractInfo(ctx, func(addr sdk.AccAddress, _ types.ContractInfo) bool {
addrs = append(addrs, addr.String())
return false
})

View File

@ -19,7 +19,7 @@ type CodeData struct {
// ContractData struct encompasses ContractAddress, ContractInfo, and ContractState
type ContractData struct {
ContractAddress sdk.AccAddress `json:"contract_address"`
ContractInfo Contract `json:"contract_info"`
ContractInfo ContractInfo `json:"contract_info"`
ContractState []Model `json:"contract_state"`
}

View File

@ -27,7 +27,7 @@ func NewCodeInfo(codeHash []byte, creator sdk.AccAddress) CodeInfo {
}
// Contract stores a WASM contract instance
type Contract struct {
type ContractInfo struct {
CodeID uint64 `json:"code_id"`
Creator sdk.AccAddress `json:"creator"`
InitMsg string `json:"init_msg"`
@ -64,9 +64,9 @@ func NewWasmCoins(cosmosCoins sdk.Coins) (wasmCoins []wasmTypes.Coin) {
return wasmCoins
}
// NewContract creates a new instance of a given WASM contract
func NewContract(codeID uint64, creator sdk.AccAddress, initMsg string) Contract {
return Contract{
// NewContractInfo creates a new instance of a given WASM contract info
func NewContractInfo(codeID uint64, creator sdk.AccAddress, initMsg string) ContractInfo {
return ContractInfo{
CodeID: codeID,
Creator: creator,
InitMsg: initMsg,

View File

@ -417,7 +417,7 @@ func assertContractInfo(t *testing.T, q sdk.Querier, ctx sdk.Context, addr sdk.A
bz, sdkerr := q(ctx, path, abci.RequestQuery{})
require.NoError(t, sdkerr)
var res Contract
var res ContractInfo
err := json.Unmarshal(bz, &res)
require.NoError(t, err)