mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-06-06 22:26:43 +00:00
187 implement rddl claim (#298)
* ignite scaffold map redeem-claim amount issued:bool --module dao --index beneficiary,liquid-tx-hash * revert: remove autogenerated delete redeem claim logic * fix: replace deprecated autogenerated sdkerrors with errorsmod * refactor: rename issued to confirmed on redeem claim * feat: add claim address param * test: add test for restricted msg UpdateRedeemClaim * refactor: update redeem claim key creation and messages * feat: add SendUpdateRedeemCLaim to util * feat: add RedeemClaimDecorator for ante package * ignite scaffold message confirm-redeem-claim id:uint beneficiary:string --module dao * feat: add handleConfirmRedeemClaim to ante handler * feat: add handleUpdateRedeemClaim to ante handler * feat: implement ConfirmRedeemClaim msg handler * test: add redeem claim test and adjust e2e test suite * fix: make use of uint to rddl string util in CreateRedeemClaim * fix: linter and staticcheck errors * ignite scaffold query redeem-claim-by-liquid-tx-hash liquid-tx-hash --response redeem-claim:RedeemClaim --module dao * feat: add RedeemClaimByLiquidTXHash store capabilities * test: add QueryRedeemClaimByLiquidTxHash to e2e test suite * feat: add RedeemClaimDecorator to ante handler chain * fix: remove redundant planetmint-go from service path * fix: linter and staticcheck errors * fix: go vet errors * fix: remove unused autogenerated simulation * fix: broken simulation * fix: openapi.yml * revert: remove autogenerated redundant test file that causes data race on pipeline * feat: burn claim on CreateRedeemClaim * fix: linter error * test: fix mock bankkeeper for msg server test * fix: reissuance test if statement * chore: removed TODO comment * fix: typo in redeem claim error msg * revert: remove autogenerated genesis state * fix: dao module simulation * revert: remove unused function * fix: linter errors * fix: linter error --------- Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
parent
a29f394bc4
commit
a38fe781ba
@ -61,6 +61,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
|
|||||||
NewCheckMachineDecorator(options.MachineKeeper),
|
NewCheckMachineDecorator(options.MachineKeeper),
|
||||||
NewCheckMintAddressDecorator(options.DaoKeeper),
|
NewCheckMintAddressDecorator(options.DaoKeeper),
|
||||||
NewCheckReissuanceDecorator(options.DaoKeeper),
|
NewCheckReissuanceDecorator(options.DaoKeeper),
|
||||||
|
NewRedeemClaimDecorator(options.DaoKeeper, options.BankKeeper),
|
||||||
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
|
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
|
||||||
NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),
|
NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),
|
||||||
ante.NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators
|
ante.NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators
|
||||||
|
@ -31,6 +31,8 @@ func (cv CheckValidatorDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulat
|
|||||||
fallthrough
|
fallthrough
|
||||||
case "/planetmintgo.dao.MsgReissueRDDLResult":
|
case "/planetmintgo.dao.MsgReissueRDDLResult":
|
||||||
fallthrough
|
fallthrough
|
||||||
|
case "/planetmintgo.dao.MsgUpdateRedeemClaim":
|
||||||
|
fallthrough
|
||||||
case "/planetmintgo.machine.MsgNotarizeLiquidAsset":
|
case "/planetmintgo.machine.MsgNotarizeLiquidAsset":
|
||||||
fallthrough
|
fallthrough
|
||||||
case "/planetmintgo.machine.MsgRegisterTrustAnchor":
|
case "/planetmintgo.machine.MsgRegisterTrustAnchor":
|
||||||
|
@ -33,12 +33,16 @@ type BankKeeper interface {
|
|||||||
IsSendEnabledCoins(ctx sdk.Context, coins ...sdk.Coin) error
|
IsSendEnabledCoins(ctx sdk.Context, coins ...sdk.Coin) error
|
||||||
SendCoins(ctx sdk.Context, from, to sdk.AccAddress, amt sdk.Coins) error
|
SendCoins(ctx sdk.Context, from, to sdk.AccAddress, amt sdk.Coins) error
|
||||||
SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
|
SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
|
||||||
|
GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin
|
||||||
}
|
}
|
||||||
|
|
||||||
type DaoKeeper interface {
|
type DaoKeeper interface {
|
||||||
GetMintRequestByHash(ctx sdk.Context, hash string) (val daotypes.MintRequest, found bool)
|
GetMintRequestByHash(ctx sdk.Context, hash string) (val daotypes.MintRequest, found bool)
|
||||||
GetMintAddress(ctx sdk.Context) (mintAddress string)
|
GetMintAddress(ctx sdk.Context) (mintAddress string)
|
||||||
|
GetClaimAddress(ctx sdk.Context) (claimAddress string)
|
||||||
IsValidReissuanceProposal(ctx sdk.Context, msg *daotypes.MsgReissueRDDLProposal) (isValid bool)
|
IsValidReissuanceProposal(ctx sdk.Context, msg *daotypes.MsgReissueRDDLProposal) (isValid bool)
|
||||||
|
GetRedeemClaim(ctx sdk.Context, benficiary string, id uint64) (val daotypes.RedeemClaim, found bool)
|
||||||
|
GetParams(ctx sdk.Context) (params daotypes.Params)
|
||||||
}
|
}
|
||||||
|
|
||||||
type StakingKeeper interface {
|
type StakingKeeper interface {
|
||||||
|
90
app/ante/redeem_claim_decorator.go
Normal file
90
app/ante/redeem_claim_decorator.go
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
package ante
|
||||||
|
|
||||||
|
import (
|
||||||
|
errorsmod "cosmossdk.io/errors"
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||||
|
daotypes "github.com/planetmint/planetmint-go/x/dao/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
type RedeemClaimDecorator struct {
|
||||||
|
dk DaoKeeper
|
||||||
|
bk BankKeeper
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewRedeemClaimDecorator(dk DaoKeeper, bk BankKeeper) RedeemClaimDecorator {
|
||||||
|
return RedeemClaimDecorator{
|
||||||
|
dk: dk,
|
||||||
|
bk: bk,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rcd RedeemClaimDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (_ sdk.Context, err error) {
|
||||||
|
for _, msg := range tx.GetMsgs() {
|
||||||
|
switch sdk.MsgTypeURL(msg) {
|
||||||
|
case "/planetmintgo.dao.MsgCreateRedeemClaim":
|
||||||
|
ctx, err = rcd.handleCreateRedeemClaim(ctx, msg)
|
||||||
|
case "/planetmintgo.dao.MsgUpdateRedeemClaim":
|
||||||
|
ctx, err = rcd.handleUpdateRedeemClaim(ctx, msg)
|
||||||
|
case "/planetmintgo.dao.MsgConfirmRedeemClaim":
|
||||||
|
ctx, err = rcd.handleConfirmRedeemClaim(ctx, msg)
|
||||||
|
default:
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return ctx, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return next(ctx, tx, simulate)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rcd RedeemClaimDecorator) handleCreateRedeemClaim(ctx sdk.Context, msg sdk.Msg) (sdk.Context, error) {
|
||||||
|
createRedeemClaimMsg, ok := msg.(*daotypes.MsgCreateRedeemClaim)
|
||||||
|
if !ok {
|
||||||
|
return ctx, errorsmod.Wrapf(sdkerrors.ErrLogic, "could not cast to MsgCreateRedeemClaim")
|
||||||
|
}
|
||||||
|
|
||||||
|
addr := sdk.MustAccAddressFromBech32(createRedeemClaimMsg.Creator)
|
||||||
|
|
||||||
|
params := rcd.dk.GetParams(ctx)
|
||||||
|
balance := rcd.bk.GetBalance(ctx, addr, params.ClaimDenom)
|
||||||
|
|
||||||
|
if !balance.Amount.GTE(sdk.NewIntFromUint64(createRedeemClaimMsg.Amount)) {
|
||||||
|
return ctx, errorsmod.Wrap(sdkerrors.ErrInsufficientFunds, "error during checkTx or reCheckTx")
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rcd RedeemClaimDecorator) handleUpdateRedeemClaim(ctx sdk.Context, msg sdk.Msg) (sdk.Context, error) {
|
||||||
|
updateClaimMsg, ok := msg.(*daotypes.MsgUpdateRedeemClaim)
|
||||||
|
if !ok {
|
||||||
|
return ctx, errorsmod.Wrapf(sdkerrors.ErrLogic, "could not cast to MsgUpdateRedeemClaim")
|
||||||
|
}
|
||||||
|
|
||||||
|
_, found := rcd.dk.GetRedeemClaim(ctx, updateClaimMsg.Beneficiary, updateClaimMsg.Id)
|
||||||
|
if !found {
|
||||||
|
return ctx, errorsmod.Wrapf(sdkerrors.ErrNotFound, "no redeem claim found for beneficiary: %s; id: %d", updateClaimMsg.Beneficiary, updateClaimMsg.Id)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rcd RedeemClaimDecorator) handleConfirmRedeemClaim(ctx sdk.Context, msg sdk.Msg) (sdk.Context, error) {
|
||||||
|
confirmClaimMsg, ok := msg.(*daotypes.MsgConfirmRedeemClaim)
|
||||||
|
if !ok {
|
||||||
|
return ctx, errorsmod.Wrapf(sdkerrors.ErrLogic, "could not cast to MsgConfirmRedeemClaim")
|
||||||
|
}
|
||||||
|
|
||||||
|
if confirmClaimMsg.Creator != rcd.dk.GetClaimAddress(ctx) {
|
||||||
|
return ctx, errorsmod.Wrapf(daotypes.ErrInvalidClaimAddress, "expected: %s; got: %s", rcd.dk.GetClaimAddress(ctx), confirmClaimMsg.Creator)
|
||||||
|
}
|
||||||
|
_, found := rcd.dk.GetRedeemClaim(ctx, confirmClaimMsg.Beneficiary, confirmClaimMsg.Id)
|
||||||
|
if !found {
|
||||||
|
return ctx, errorsmod.Wrapf(sdkerrors.ErrNotFound, "no redeem claim found for beneficiary: %s; id: %d", confirmClaimMsg.Beneficiary, confirmClaimMsg.Id)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx, nil
|
||||||
|
}
|
359
docs/static/openapi.yml
vendored
359
docs/static/openapi.yml
vendored
@ -47045,6 +47045,8 @@ paths:
|
|||||||
mqtt_response_timeout:
|
mqtt_response_timeout:
|
||||||
type: string
|
type: string
|
||||||
format: int64
|
format: int64
|
||||||
|
claim_address:
|
||||||
|
type: string
|
||||||
description: >-
|
description: >-
|
||||||
QueryParamsResponse is response type for the Query/Params RPC
|
QueryParamsResponse is response type for the Query/Params RPC
|
||||||
method.
|
method.
|
||||||
@ -47068,6 +47070,248 @@ paths:
|
|||||||
additionalProperties: {}
|
additionalProperties: {}
|
||||||
tags:
|
tags:
|
||||||
- Query
|
- Query
|
||||||
|
/planetmint/dao/redeem_claim:
|
||||||
|
get:
|
||||||
|
operationId: PlanetmintgoDaoRedeemClaimAll
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: A successful response.
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
redeemClaim:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
format: uint64
|
||||||
|
beneficiary:
|
||||||
|
type: string
|
||||||
|
liquidTxHash:
|
||||||
|
type: string
|
||||||
|
amount:
|
||||||
|
type: string
|
||||||
|
format: uint64
|
||||||
|
confirmed:
|
||||||
|
type: boolean
|
||||||
|
creator:
|
||||||
|
type: string
|
||||||
|
pagination:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
next_key:
|
||||||
|
type: string
|
||||||
|
format: byte
|
||||||
|
description: |-
|
||||||
|
next_key is the key to be passed to PageRequest.key to
|
||||||
|
query the next page most efficiently. It will be empty if
|
||||||
|
there are no more results.
|
||||||
|
total:
|
||||||
|
type: string
|
||||||
|
format: uint64
|
||||||
|
title: >-
|
||||||
|
total is total number of results available if
|
||||||
|
PageRequest.count_total
|
||||||
|
|
||||||
|
was set, its value is undefined otherwise
|
||||||
|
description: >-
|
||||||
|
PageResponse is to be embedded in gRPC response messages where
|
||||||
|
the
|
||||||
|
|
||||||
|
corresponding request message has used PageRequest.
|
||||||
|
|
||||||
|
message SomeResponse {
|
||||||
|
repeated Bar results = 1;
|
||||||
|
PageResponse page = 2;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
description: An unexpected error response.
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
code:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
message:
|
||||||
|
type: string
|
||||||
|
details:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
'@type':
|
||||||
|
type: string
|
||||||
|
additionalProperties: {}
|
||||||
|
parameters:
|
||||||
|
- name: pagination.key
|
||||||
|
description: |-
|
||||||
|
key is a value returned in PageResponse.next_key to begin
|
||||||
|
querying the next page most efficiently. Only one of offset or key
|
||||||
|
should be set.
|
||||||
|
in: query
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
format: byte
|
||||||
|
- name: pagination.offset
|
||||||
|
description: >-
|
||||||
|
offset is a numeric offset that can be used when key is unavailable.
|
||||||
|
|
||||||
|
It is less efficient than using key. Only one of offset or key
|
||||||
|
should
|
||||||
|
|
||||||
|
be set.
|
||||||
|
in: query
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
format: uint64
|
||||||
|
- name: pagination.limit
|
||||||
|
description: >-
|
||||||
|
limit is the total number of results to be returned in the result
|
||||||
|
page.
|
||||||
|
|
||||||
|
If left empty it will default to a value to be set by each app.
|
||||||
|
in: query
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
format: uint64
|
||||||
|
- name: pagination.count_total
|
||||||
|
description: >-
|
||||||
|
count_total is set to true to indicate that the result set should
|
||||||
|
include
|
||||||
|
|
||||||
|
a count of the total number of items available for pagination in
|
||||||
|
UIs.
|
||||||
|
|
||||||
|
count_total is only respected when offset is used. It is ignored
|
||||||
|
when key
|
||||||
|
|
||||||
|
is set.
|
||||||
|
in: query
|
||||||
|
required: false
|
||||||
|
type: boolean
|
||||||
|
- name: pagination.reverse
|
||||||
|
description: >-
|
||||||
|
reverse is set to true if results are to be returned in the
|
||||||
|
descending order.
|
||||||
|
|
||||||
|
|
||||||
|
Since: cosmos-sdk 0.43
|
||||||
|
in: query
|
||||||
|
required: false
|
||||||
|
type: boolean
|
||||||
|
tags:
|
||||||
|
- Query
|
||||||
|
/planetmint/dao/redeem_claim/{beneficiary}/{id}:
|
||||||
|
get:
|
||||||
|
summary: Queries a list of RedeemClaim items.
|
||||||
|
operationId: PlanetmintgoDaoRedeemClaim
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: A successful response.
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
redeemClaim:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
format: uint64
|
||||||
|
beneficiary:
|
||||||
|
type: string
|
||||||
|
liquidTxHash:
|
||||||
|
type: string
|
||||||
|
amount:
|
||||||
|
type: string
|
||||||
|
format: uint64
|
||||||
|
confirmed:
|
||||||
|
type: boolean
|
||||||
|
creator:
|
||||||
|
type: string
|
||||||
|
default:
|
||||||
|
description: An unexpected error response.
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
code:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
message:
|
||||||
|
type: string
|
||||||
|
details:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
'@type':
|
||||||
|
type: string
|
||||||
|
additionalProperties: {}
|
||||||
|
parameters:
|
||||||
|
- name: beneficiary
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
- name: id
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
format: uint64
|
||||||
|
tags:
|
||||||
|
- Query
|
||||||
|
/planetmint/dao/redeem_claim_by_liquid_tx_hash/{liquidTxHash}:
|
||||||
|
get:
|
||||||
|
summary: Queries a list of RedeemClaimByLiquidTxHash items.
|
||||||
|
operationId: PlanetmintgoDaoRedeemClaimByLiquidTxHash
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: A successful response.
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
redeemClaim:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
format: uint64
|
||||||
|
beneficiary:
|
||||||
|
type: string
|
||||||
|
liquidTxHash:
|
||||||
|
type: string
|
||||||
|
amount:
|
||||||
|
type: string
|
||||||
|
format: uint64
|
||||||
|
confirmed:
|
||||||
|
type: boolean
|
||||||
|
creator:
|
||||||
|
type: string
|
||||||
|
default:
|
||||||
|
description: An unexpected error response.
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
code:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
message:
|
||||||
|
type: string
|
||||||
|
details:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
'@type':
|
||||||
|
type: string
|
||||||
|
additionalProperties: {}
|
||||||
|
parameters:
|
||||||
|
- name: liquidTxHash
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
tags:
|
||||||
|
- Query
|
||||||
/planetmint/dao/reissuance/{blockHeight}:
|
/planetmint/dao/reissuance/{blockHeight}:
|
||||||
get:
|
get:
|
||||||
summary: Queries a list of GetReissuance items.
|
summary: Queries a list of GetReissuance items.
|
||||||
@ -76410,6 +76654,10 @@ definitions:
|
|||||||
format: uint64
|
format: uint64
|
||||||
liquidTxHash:
|
liquidTxHash:
|
||||||
type: string
|
type: string
|
||||||
|
planetmintgo.dao.MsgConfirmRedeemClaimResponse:
|
||||||
|
type: object
|
||||||
|
planetmintgo.dao.MsgCreateRedeemClaimResponse:
|
||||||
|
type: object
|
||||||
planetmintgo.dao.MsgDistributionRequestResponse:
|
planetmintgo.dao.MsgDistributionRequestResponse:
|
||||||
type: object
|
type: object
|
||||||
planetmintgo.dao.MsgDistributionResultResponse:
|
planetmintgo.dao.MsgDistributionResultResponse:
|
||||||
@ -76426,6 +76674,8 @@ definitions:
|
|||||||
type: object
|
type: object
|
||||||
planetmintgo.dao.MsgUpdateParamsResponse:
|
planetmintgo.dao.MsgUpdateParamsResponse:
|
||||||
type: object
|
type: object
|
||||||
|
planetmintgo.dao.MsgUpdateRedeemClaimResponse:
|
||||||
|
type: object
|
||||||
planetmintgo.dao.Params:
|
planetmintgo.dao.Params:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@ -76463,7 +76713,57 @@ definitions:
|
|||||||
mqtt_response_timeout:
|
mqtt_response_timeout:
|
||||||
type: string
|
type: string
|
||||||
format: int64
|
format: int64
|
||||||
|
claim_address:
|
||||||
|
type: string
|
||||||
description: Params defines the parameters for the module.
|
description: Params defines the parameters for the module.
|
||||||
|
planetmintgo.dao.QueryAllRedeemClaimResponse:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
redeemClaim:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
format: uint64
|
||||||
|
beneficiary:
|
||||||
|
type: string
|
||||||
|
liquidTxHash:
|
||||||
|
type: string
|
||||||
|
amount:
|
||||||
|
type: string
|
||||||
|
format: uint64
|
||||||
|
confirmed:
|
||||||
|
type: boolean
|
||||||
|
creator:
|
||||||
|
type: string
|
||||||
|
pagination:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
next_key:
|
||||||
|
type: string
|
||||||
|
format: byte
|
||||||
|
description: |-
|
||||||
|
next_key is the key to be passed to PageRequest.key to
|
||||||
|
query the next page most efficiently. It will be empty if
|
||||||
|
there are no more results.
|
||||||
|
total:
|
||||||
|
type: string
|
||||||
|
format: uint64
|
||||||
|
title: >-
|
||||||
|
total is total number of results available if
|
||||||
|
PageRequest.count_total
|
||||||
|
|
||||||
|
was set, its value is undefined otherwise
|
||||||
|
description: |-
|
||||||
|
PageResponse is to be embedded in gRPC response messages where the
|
||||||
|
corresponding request message has used PageRequest.
|
||||||
|
|
||||||
|
message SomeResponse {
|
||||||
|
repeated Bar results = 1;
|
||||||
|
PageResponse page = 2;
|
||||||
|
}
|
||||||
planetmintgo.dao.QueryChallengesResponse:
|
planetmintgo.dao.QueryChallengesResponse:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@ -76587,6 +76887,26 @@ definitions:
|
|||||||
format: uint64
|
format: uint64
|
||||||
liquidTxHash:
|
liquidTxHash:
|
||||||
type: string
|
type: string
|
||||||
|
planetmintgo.dao.QueryGetRedeemClaimResponse:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
redeemClaim:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
format: uint64
|
||||||
|
beneficiary:
|
||||||
|
type: string
|
||||||
|
liquidTxHash:
|
||||||
|
type: string
|
||||||
|
amount:
|
||||||
|
type: string
|
||||||
|
format: uint64
|
||||||
|
confirmed:
|
||||||
|
type: boolean
|
||||||
|
creator:
|
||||||
|
type: string
|
||||||
planetmintgo.dao.QueryGetReissuanceResponse:
|
planetmintgo.dao.QueryGetReissuanceResponse:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@ -76667,7 +76987,29 @@ definitions:
|
|||||||
mqtt_response_timeout:
|
mqtt_response_timeout:
|
||||||
type: string
|
type: string
|
||||||
format: int64
|
format: int64
|
||||||
|
claim_address:
|
||||||
|
type: string
|
||||||
description: QueryParamsResponse is response type for the Query/Params RPC method.
|
description: QueryParamsResponse is response type for the Query/Params RPC method.
|
||||||
|
planetmintgo.dao.QueryRedeemClaimByLiquidTxHashResponse:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
redeemClaim:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
format: uint64
|
||||||
|
beneficiary:
|
||||||
|
type: string
|
||||||
|
liquidTxHash:
|
||||||
|
type: string
|
||||||
|
amount:
|
||||||
|
type: string
|
||||||
|
format: uint64
|
||||||
|
confirmed:
|
||||||
|
type: boolean
|
||||||
|
creator:
|
||||||
|
type: string
|
||||||
planetmintgo.dao.QueryReissuancesResponse:
|
planetmintgo.dao.QueryReissuancesResponse:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@ -76717,6 +77059,23 @@ definitions:
|
|||||||
repeated Bar results = 1;
|
repeated Bar results = 1;
|
||||||
PageResponse page = 2;
|
PageResponse page = 2;
|
||||||
}
|
}
|
||||||
|
planetmintgo.dao.RedeemClaim:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
format: uint64
|
||||||
|
beneficiary:
|
||||||
|
type: string
|
||||||
|
liquidTxHash:
|
||||||
|
type: string
|
||||||
|
amount:
|
||||||
|
type: string
|
||||||
|
format: uint64
|
||||||
|
confirmed:
|
||||||
|
type: boolean
|
||||||
|
creator:
|
||||||
|
type: string
|
||||||
planetmintgo.dao.Reissuance:
|
planetmintgo.dao.Reissuance:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
1
go.mod
1
go.mod
@ -6,6 +6,7 @@ require (
|
|||||||
cosmossdk.io/api v0.3.1
|
cosmossdk.io/api v0.3.1
|
||||||
cosmossdk.io/errors v1.0.0
|
cosmossdk.io/errors v1.0.0
|
||||||
cosmossdk.io/math v1.1.2
|
cosmossdk.io/math v1.1.2
|
||||||
|
cosmossdk.io/simapp v0.0.0-20230323161446-0af178d721ff
|
||||||
github.com/btcsuite/btcd v0.23.2
|
github.com/btcsuite/btcd v0.23.2
|
||||||
github.com/btcsuite/btcd/btcutil v1.1.2
|
github.com/btcsuite/btcd/btcutil v1.1.2
|
||||||
github.com/cometbft/cometbft v0.37.2
|
github.com/cometbft/cometbft v0.37.2
|
||||||
|
2
go.sum
2
go.sum
@ -199,6 +199,8 @@ cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk=
|
|||||||
cosmossdk.io/log v1.2.1/go.mod h1:GNSCc/6+DhFIj1aLn/j7Id7PaO8DzNylUZoOYBL9+I4=
|
cosmossdk.io/log v1.2.1/go.mod h1:GNSCc/6+DhFIj1aLn/j7Id7PaO8DzNylUZoOYBL9+I4=
|
||||||
cosmossdk.io/math v1.1.2 h1:ORZetZCTyWkI5GlZ6CZS28fMHi83ZYf+A2vVnHNzZBM=
|
cosmossdk.io/math v1.1.2 h1:ORZetZCTyWkI5GlZ6CZS28fMHi83ZYf+A2vVnHNzZBM=
|
||||||
cosmossdk.io/math v1.1.2/go.mod h1:l2Gnda87F0su8a/7FEKJfFdJrM0JZRXQaohlgJeyQh0=
|
cosmossdk.io/math v1.1.2/go.mod h1:l2Gnda87F0su8a/7FEKJfFdJrM0JZRXQaohlgJeyQh0=
|
||||||
|
cosmossdk.io/simapp v0.0.0-20230323161446-0af178d721ff h1:P1ialzTepD1oxdNPYc5N8Eggq3RdejZq3cJs8YYMs9Y=
|
||||||
|
cosmossdk.io/simapp v0.0.0-20230323161446-0af178d721ff/go.mod h1:AKzx6Mb544LjJ9RHmGFHjY9rEOLiUAi8I0F727TR0dY=
|
||||||
cosmossdk.io/tools/rosetta v0.2.1 h1:ddOMatOH+pbxWbrGJKRAawdBkPYLfKXutK9IETnjYxw=
|
cosmossdk.io/tools/rosetta v0.2.1 h1:ddOMatOH+pbxWbrGJKRAawdBkPYLfKXutK9IETnjYxw=
|
||||||
cosmossdk.io/tools/rosetta v0.2.1/go.mod h1:Pqdc1FdvkNV3LcNIkYWt2RQY6IP1ge6YWZk8MhhO9Hw=
|
cosmossdk.io/tools/rosetta v0.2.1/go.mod h1:Pqdc1FdvkNV3LcNIkYWt2RQY6IP1ge6YWZk8MhhO9Hw=
|
||||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
|
|
||||||
package planetmintgo.dao;
|
package planetmintgo.dao;
|
||||||
|
|
||||||
import "gogoproto/gogo.proto";
|
import "gogoproto/gogo.proto";
|
||||||
import "planetmintgo/dao/params.proto";
|
import "planetmintgo/dao/params.proto";
|
||||||
|
import "planetmintgo/dao/redeem_claim.proto";
|
||||||
|
|
||||||
option go_package = "github.com/planetmint/planetmint-go/x/dao/types";
|
option go_package = "github.com/planetmint/planetmint-go/x/dao/types";
|
||||||
|
|
||||||
// GenesisState defines the dao module's genesis state.
|
// GenesisState defines the dao module's genesis state.
|
||||||
message GenesisState {
|
message GenesisState {
|
||||||
Params params = 1 [(gogoproto.nullable) = false];
|
Params params = 1 [(gogoproto.nullable) = false];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,18 +10,19 @@ message Params {
|
|||||||
option (gogoproto.goproto_stringer) = false;
|
option (gogoproto.goproto_stringer) = false;
|
||||||
|
|
||||||
string mint_address = 1;
|
string mint_address = 1;
|
||||||
string token_denom =2;
|
string token_denom = 2;
|
||||||
string fee_denom =3;
|
string fee_denom = 3;
|
||||||
string staged_denom =4;
|
string staged_denom = 4;
|
||||||
string claim_denom =5;
|
string claim_denom = 5;
|
||||||
string reissuance_asset =6;
|
string reissuance_asset = 6;
|
||||||
int64 reissuance_epochs=7;
|
int64 reissuance_epochs = 7;
|
||||||
int64 pop_epochs =8;
|
int64 pop_epochs = 8;
|
||||||
int64 distribution_offset =9;
|
int64 distribution_offset = 9;
|
||||||
string distribution_address_early_inv = 10;
|
string distribution_address_early_inv = 10;
|
||||||
string distribution_address_investor = 11;
|
string distribution_address_investor = 11;
|
||||||
string distribution_address_strategic = 12;
|
string distribution_address_strategic = 12;
|
||||||
string distribution_address_dao = 13;
|
string distribution_address_dao = 13;
|
||||||
string distribution_address_pop = 14;
|
string distribution_address_pop = 14;
|
||||||
int64 mqtt_response_timeout = 15;
|
int64 mqtt_response_timeout = 15;
|
||||||
|
string claim_address = 16;
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import "planetmintgo/dao/reissuance.proto";
|
|||||||
import "planetmintgo/dao/challenge.proto";
|
import "planetmintgo/dao/challenge.proto";
|
||||||
import "amino/amino.proto";
|
import "amino/amino.proto";
|
||||||
import "planetmintgo/dao/distribution_order.proto";
|
import "planetmintgo/dao/distribution_order.proto";
|
||||||
|
import "planetmintgo/dao/redeem_claim.proto";
|
||||||
|
|
||||||
option go_package = "github.com/planetmint/planetmint-go/x/dao/types";
|
option go_package = "github.com/planetmint/planetmint-go/x/dao/types";
|
||||||
|
|
||||||
@ -57,6 +58,7 @@ service Query {
|
|||||||
// Queries a list of Challenges items.
|
// Queries a list of Challenges items.
|
||||||
rpc Challenges (QueryChallengesRequest) returns (QueryChallengesResponse) {
|
rpc Challenges (QueryChallengesRequest) returns (QueryChallengesResponse) {
|
||||||
option (google.api.http).get = "/planetmint/dao/challenges";
|
option (google.api.http).get = "/planetmint/dao/challenges";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Queries a list of GetDistribution items.
|
// Queries a list of GetDistribution items.
|
||||||
@ -64,6 +66,22 @@ service Query {
|
|||||||
option (google.api.http).get = "/planetmint/dao/distribution/{height}";
|
option (google.api.http).get = "/planetmint/dao/distribution/{height}";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Queries a list of RedeemClaim items.
|
||||||
|
rpc RedeemClaim (QueryGetRedeemClaimRequest) returns (QueryGetRedeemClaimResponse) {
|
||||||
|
option (google.api.http).get = "/planetmint/dao/redeem_claim/{beneficiary}/{id}";
|
||||||
|
|
||||||
|
}
|
||||||
|
rpc RedeemClaimAll (QueryAllRedeemClaimRequest) returns (QueryAllRedeemClaimResponse) {
|
||||||
|
option (google.api.http).get = "/planetmint/dao/redeem_claim";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Queries a list of RedeemClaimByLiquidTxHash items.
|
||||||
|
rpc RedeemClaimByLiquidTxHash (QueryRedeemClaimByLiquidTxHashRequest) returns (QueryRedeemClaimByLiquidTxHashResponse) {
|
||||||
|
option (google.api.http).get = "/planetmint/dao/redeem_claim_by_liquid_tx_hash/{liquidTxHash}";
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// QueryParamsRequest is request type for the Query/Params RPC method.
|
// QueryParamsRequest is request type for the Query/Params RPC method.
|
||||||
message QueryParamsRequest {}
|
message QueryParamsRequest {}
|
||||||
@ -104,11 +122,8 @@ message QueryReissuancesRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message QueryReissuancesResponse {
|
message QueryReissuancesResponse {
|
||||||
repeated Reissuance reissuances = 1 [
|
repeated Reissuance reissuances = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
|
||||||
(gogoproto.nullable) = false,
|
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||||
(amino.dont_omitempty) = true
|
|
||||||
];
|
|
||||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message QueryGetChallengeRequest {
|
message QueryGetChallengeRequest {
|
||||||
@ -124,11 +139,8 @@ message QueryChallengesRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message QueryChallengesResponse {
|
message QueryChallengesResponse {
|
||||||
repeated Challenge challenges = 1 [
|
repeated Challenge challenges = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
|
||||||
(gogoproto.nullable) = false,
|
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||||
(amino.dont_omitempty) = true
|
|
||||||
];
|
|
||||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message QueryGetDistributionRequest {
|
message QueryGetDistributionRequest {
|
||||||
@ -139,3 +151,29 @@ message QueryGetDistributionResponse {
|
|||||||
DistributionOrder distribution = 1;
|
DistributionOrder distribution = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message QueryGetRedeemClaimRequest {
|
||||||
|
string beneficiary = 1;
|
||||||
|
uint64 id = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message QueryGetRedeemClaimResponse {
|
||||||
|
RedeemClaim redeemClaim = 1 [(gogoproto.nullable) = false];
|
||||||
|
}
|
||||||
|
|
||||||
|
message QueryAllRedeemClaimRequest {
|
||||||
|
cosmos.base.query.v1beta1.PageRequest pagination = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message QueryAllRedeemClaimResponse {
|
||||||
|
repeated RedeemClaim redeemClaim = 1 [(gogoproto.nullable) = false];
|
||||||
|
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message QueryRedeemClaimByLiquidTxHashRequest {
|
||||||
|
string liquidTxHash = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message QueryRedeemClaimByLiquidTxHashResponse {
|
||||||
|
RedeemClaim redeemClaim = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
14
proto/planetmintgo/dao/redeem_claim.proto
Normal file
14
proto/planetmintgo/dao/redeem_claim.proto
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
package planetmintgo.dao;
|
||||||
|
|
||||||
|
option go_package = "github.com/planetmint/planetmint-go/x/dao/types";
|
||||||
|
|
||||||
|
message RedeemClaim {
|
||||||
|
uint64 id = 1;
|
||||||
|
string beneficiary = 2;
|
||||||
|
string liquidTxHash = 3;
|
||||||
|
uint64 amount = 4;
|
||||||
|
bool confirmed = 5;
|
||||||
|
string creator = 6;
|
||||||
|
}
|
||||||
|
|
@ -10,6 +10,7 @@ import "amino/amino.proto";
|
|||||||
import "gogoproto/gogo.proto";
|
import "gogoproto/gogo.proto";
|
||||||
import "cosmos_proto/cosmos.proto";
|
import "cosmos_proto/cosmos.proto";
|
||||||
import "cosmos/msg/v1/msg.proto";
|
import "cosmos/msg/v1/msg.proto";
|
||||||
|
import "planetmintgo/dao/redeem_claim.proto";
|
||||||
|
|
||||||
option go_package = "github.com/planetmint/planetmint-go/x/dao/types";
|
option go_package = "github.com/planetmint/planetmint-go/x/dao/types";
|
||||||
|
|
||||||
@ -23,6 +24,9 @@ service Msg {
|
|||||||
rpc UpdateParams (MsgUpdateParams ) returns (MsgUpdateParamsResponse );
|
rpc UpdateParams (MsgUpdateParams ) returns (MsgUpdateParamsResponse );
|
||||||
rpc ReportPopResult (MsgReportPopResult ) returns (MsgReportPopResultResponse );
|
rpc ReportPopResult (MsgReportPopResult ) returns (MsgReportPopResultResponse );
|
||||||
rpc InitPop (MsgInitPop ) returns (MsgInitPopResponse );
|
rpc InitPop (MsgInitPop ) returns (MsgInitPopResponse );
|
||||||
|
rpc CreateRedeemClaim (MsgCreateRedeemClaim ) returns (MsgCreateRedeemClaimResponse );
|
||||||
|
rpc UpdateRedeemClaim (MsgUpdateRedeemClaim ) returns (MsgUpdateRedeemClaimResponse );
|
||||||
|
rpc ConfirmRedeemClaim (MsgConfirmRedeemClaim ) returns (MsgConfirmRedeemClaimResponse );
|
||||||
}
|
}
|
||||||
message MsgReportPopResult {
|
message MsgReportPopResult {
|
||||||
string creator = 1;
|
string creator = 1;
|
||||||
@ -101,3 +105,28 @@ message MsgInitPop {
|
|||||||
|
|
||||||
message MsgInitPopResponse {}
|
message MsgInitPopResponse {}
|
||||||
|
|
||||||
|
message MsgCreateRedeemClaim {
|
||||||
|
string creator = 1;
|
||||||
|
string beneficiary = 2;
|
||||||
|
uint64 amount = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message MsgCreateRedeemClaimResponse {}
|
||||||
|
|
||||||
|
message MsgUpdateRedeemClaim {
|
||||||
|
string creator = 1;
|
||||||
|
uint64 id = 2;
|
||||||
|
string beneficiary = 3;
|
||||||
|
string liquidTxHash = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message MsgUpdateRedeemClaimResponse {}
|
||||||
|
|
||||||
|
message MsgConfirmRedeemClaim {
|
||||||
|
string creator = 1;
|
||||||
|
uint64 id = 2;
|
||||||
|
string beneficiary = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message MsgConfirmRedeemClaimResponse {}
|
||||||
|
|
||||||
|
@ -1,12 +1,17 @@
|
|||||||
package dao
|
package dao
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"math"
|
"math"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
bank "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
|
bank "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
|
||||||
|
"github.com/planetmint/planetmint-go/lib"
|
||||||
"github.com/planetmint/planetmint-go/testutil"
|
"github.com/planetmint/planetmint-go/testutil"
|
||||||
clitestutil "github.com/planetmint/planetmint-go/testutil/cli"
|
clitestutil "github.com/planetmint/planetmint-go/testutil/cli"
|
||||||
e2etestutil "github.com/planetmint/planetmint-go/testutil/e2e"
|
e2etestutil "github.com/planetmint/planetmint-go/testutil/e2e"
|
||||||
@ -44,6 +49,7 @@ type PopSelectionE2ETestSuite struct {
|
|||||||
popEpochs int64
|
popEpochs int64
|
||||||
reissuanceEpochs int64
|
reissuanceEpochs int64
|
||||||
distributionOffset int64
|
distributionOffset int64
|
||||||
|
claimDenom string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPopSelectionE2ETestSuite(cfg network.Config) *PopSelectionE2ETestSuite {
|
func NewPopSelectionE2ETestSuite(cfg network.Config) *PopSelectionE2ETestSuite {
|
||||||
@ -56,6 +62,11 @@ func (s *PopSelectionE2ETestSuite) SetupSuite() {
|
|||||||
s.popEpochs = 10
|
s.popEpochs = 10
|
||||||
s.reissuanceEpochs = 60
|
s.reissuanceEpochs = 60
|
||||||
s.distributionOffset = 2
|
s.distributionOffset = 2
|
||||||
|
s.claimDenom = "crddl"
|
||||||
|
|
||||||
|
s.cfg.Mnemonics = []string{sample.Mnemonic}
|
||||||
|
valAddr, err := s.createValAccount(s.cfg)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
var daoGenState daotypes.GenesisState
|
var daoGenState daotypes.GenesisState
|
||||||
s.cfg.Codec.MustUnmarshalJSON(s.cfg.GenesisState[daotypes.ModuleName], &daoGenState)
|
s.cfg.Codec.MustUnmarshalJSON(s.cfg.GenesisState[daotypes.ModuleName], &daoGenState)
|
||||||
@ -64,6 +75,7 @@ func (s *PopSelectionE2ETestSuite) SetupSuite() {
|
|||||||
daoGenState.Params.DistributionOffset = s.distributionOffset
|
daoGenState.Params.DistributionOffset = s.distributionOffset
|
||||||
daoGenState.Params.MqttResponseTimeout = 200
|
daoGenState.Params.MqttResponseTimeout = 200
|
||||||
daoGenState.Params.FeeDenom = sample.FeeDenom
|
daoGenState.Params.FeeDenom = sample.FeeDenom
|
||||||
|
daoGenState.Params.ClaimAddress = valAddr.String()
|
||||||
s.cfg.GenesisState[daotypes.ModuleName] = s.cfg.Codec.MustMarshalJSON(&daoGenState)
|
s.cfg.GenesisState[daotypes.ModuleName] = s.cfg.Codec.MustMarshalJSON(&daoGenState)
|
||||||
|
|
||||||
s.network = network.New(s.T(), s.cfg)
|
s.network = network.New(s.T(), s.cfg)
|
||||||
@ -226,3 +238,90 @@ func (s *PopSelectionE2ETestSuite) TestTokenDistribution1() {
|
|||||||
|
|
||||||
s.VerifyTokens(daoGenState.Params.ClaimDenom)
|
s.VerifyTokens(daoGenState.Params.ClaimDenom)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *PopSelectionE2ETestSuite) TestTokenRedeemClaim() {
|
||||||
|
val := s.network.Validators[0]
|
||||||
|
|
||||||
|
k, err := val.ClientCtx.Keyring.Key(machines[0].name)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
addr, _ := k.GetAddress()
|
||||||
|
|
||||||
|
// Addr sends CreateRedeemClaim => accepted query redeem claim
|
||||||
|
createClaimMsg := daotypes.NewMsgCreateRedeemClaim(addr.String(), "liquidAddress", 10000)
|
||||||
|
out, err := lib.BroadcastTxWithFileLock(addr, createClaimMsg)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
txResponse, err := lib.GetTxResponseFromOut(out)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
s.Require().Equal(int(0), int(txResponse.Code))
|
||||||
|
|
||||||
|
// WaitForBlock => Validator should implicitly send UpdateRedeemClaim
|
||||||
|
s.Require().NoError(s.network.WaitForNextBlock())
|
||||||
|
|
||||||
|
// Claim burned on CreateRedeemClaim
|
||||||
|
balanceOut, err := clitestutil.ExecTestCLICmd(val.ClientCtx, bank.GetBalancesCmd(), []string{
|
||||||
|
addr.String(),
|
||||||
|
fmt.Sprintf("--%s=%s", bank.FlagDenom, s.claimDenom),
|
||||||
|
})
|
||||||
|
s.Require().NoError(err)
|
||||||
|
assert.Equal(s.T(), "amount: \"5993140682\"\ndenom: crddl\n", balanceOut.String()) // 3 * 1997716894 - 10000 = 5993140682
|
||||||
|
|
||||||
|
// Addr sends ConfirmRedeemClaim => rejected not claim address
|
||||||
|
confirmMsg := daotypes.NewMsgConfirmRedeemClaim(addr.String(), 0, "liquidAddress")
|
||||||
|
out, err = lib.BroadcastTxWithFileLock(addr, confirmMsg)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
txResponse, err = lib.GetTxResponseFromOut(out)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
s.Require().Equal(int(21), int(txResponse.Code))
|
||||||
|
|
||||||
|
// Validator with Claim Address sends ConfirmRedeemClaim => accepted
|
||||||
|
valConfirmMsg := daotypes.NewMsgConfirmRedeemClaim(val.Address.String(), 0, "liquidAddress")
|
||||||
|
out, err = lib.BroadcastTxWithFileLock(val.Address, valConfirmMsg)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
txResponse, err = lib.GetTxResponseFromOut(out)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
s.Require().Equal(int(0), int(txResponse.Code))
|
||||||
|
|
||||||
|
// WaitForBlock before query
|
||||||
|
s.Require().NoError(s.network.WaitForNextBlock())
|
||||||
|
|
||||||
|
// QueryRedeemClaim
|
||||||
|
qOut, err := clitestutil.ExecTestCLICmd(val.ClientCtx, daocli.CmdShowRedeemClaim(), []string{"liquidAddress", "0"})
|
||||||
|
s.Require().NoError(err)
|
||||||
|
assert.Equal(s.T(), "redeemClaim:\n amount: \"10000\"\n beneficiary: liquidAddress\n confirmed: true\n creator: plmnt1kp93kns6hs2066d8qw0uz84fw3vlthewt2ck6p\n id: \"0\"\n liquidTxHash: \"0000000000000000000000000000000000000000000000000000000000000000\"\n", qOut.String())
|
||||||
|
|
||||||
|
qOut, err = clitestutil.ExecTestCLICmd(val.ClientCtx, daocli.CmdRedeemClaimByLiquidTxHash(), []string{"0000000000000000000000000000000000000000000000000000000000000000"})
|
||||||
|
s.Require().NoError(err)
|
||||||
|
assert.Equal(s.T(), "redeemClaim:\n amount: \"10000\"\n beneficiary: liquidAddress\n confirmed: true\n creator: plmnt1kp93kns6hs2066d8qw0uz84fw3vlthewt2ck6p\n id: \"0\"\n liquidTxHash: \"0000000000000000000000000000000000000000000000000000000000000000\"\n", qOut.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *PopSelectionE2ETestSuite) createValAccount(cfg network.Config) (address sdk.AccAddress, err error) {
|
||||||
|
buf := bufio.NewReader(os.Stdin)
|
||||||
|
|
||||||
|
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, s.T().TempDir(), buf, cfg.Codec, cfg.KeyringOptions...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
keyringAlgos, _ := kb.SupportedAlgorithms()
|
||||||
|
algo, err := keyring.NewSigningAlgoFromString(cfg.SigningAlgo, keyringAlgos)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
mnemonic := cfg.Mnemonics[0]
|
||||||
|
|
||||||
|
record, err := kb.NewAccount("node0", mnemonic, keyring.DefaultBIP39Passphrase, sdk.GetConfig().GetFullBIP44Path(), algo)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
addr, err := record.GetAddress()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return addr, nil
|
||||||
|
}
|
||||||
|
@ -17,6 +17,7 @@ var msgs = []sdk.Msg{
|
|||||||
&daotypes.MsgDistributionResult{},
|
&daotypes.MsgDistributionResult{},
|
||||||
&daotypes.MsgReissueRDDLProposal{},
|
&daotypes.MsgReissueRDDLProposal{},
|
||||||
&daotypes.MsgReissueRDDLResult{},
|
&daotypes.MsgReissueRDDLResult{},
|
||||||
|
&daotypes.MsgUpdateRedeemClaim{},
|
||||||
&machinetypes.MsgRegisterTrustAnchor{},
|
&machinetypes.MsgRegisterTrustAnchor{},
|
||||||
&machinetypes.MsgNotarizeLiquidAsset{},
|
&machinetypes.MsgNotarizeLiquidAsset{},
|
||||||
}
|
}
|
||||||
@ -109,6 +110,11 @@ func setCreator(msg sdk.Msg, creator string) sdk.Msg {
|
|||||||
if ok {
|
if ok {
|
||||||
msg.Creator = creator
|
msg.Creator = creator
|
||||||
}
|
}
|
||||||
|
case "/planetmintgo.dao.MsgUpdateRedeemClaim":
|
||||||
|
msg, ok := msg.(*daotypes.MsgUpdateRedeemClaim)
|
||||||
|
if ok {
|
||||||
|
msg.Creator = creator
|
||||||
|
}
|
||||||
case "/planetmintgo.machine.MsgNotarizeLiquidAsset":
|
case "/planetmintgo.machine.MsgNotarizeLiquidAsset":
|
||||||
msg, ok := msg.(*machinetypes.MsgNotarizeLiquidAsset)
|
msg, ok := msg.(*machinetypes.MsgNotarizeLiquidAsset)
|
||||||
if ok {
|
if ok {
|
||||||
|
@ -80,6 +80,7 @@ func (s *E2ETestSuite) SetupSuite() {
|
|||||||
daoGenState.Params.DistributionOffset = s.distributionOffset
|
daoGenState.Params.DistributionOffset = s.distributionOffset
|
||||||
daoGenState.Params.ReissuanceEpochs = s.reissuanceEpochs
|
daoGenState.Params.ReissuanceEpochs = s.reissuanceEpochs
|
||||||
daoGenState.Params.MintAddress = valAddr.String()
|
daoGenState.Params.MintAddress = valAddr.String()
|
||||||
|
daoGenState.Params.ClaimAddress = valAddr.String()
|
||||||
s.cfg.GenesisState[daotypes.ModuleName] = s.cfg.Codec.MustMarshalJSON(&daoGenState)
|
s.cfg.GenesisState[daotypes.ModuleName] = s.cfg.Codec.MustMarshalJSON(&daoGenState)
|
||||||
|
|
||||||
bbalances := sdk.NewCoins(
|
bbalances := sdk.NewCoins(
|
||||||
@ -102,6 +103,12 @@ func (s *E2ETestSuite) SetupSuite() {
|
|||||||
|
|
||||||
s.cfg.MinGasPrices = fmt.Sprintf("0.000006%s", daoGenState.Params.FeeDenom)
|
s.cfg.MinGasPrices = fmt.Sprintf("0.000006%s", daoGenState.Params.FeeDenom)
|
||||||
s.network = network.New(s.T(), s.cfg)
|
s.network = network.New(s.T(), s.cfg)
|
||||||
|
|
||||||
|
// create account for redeem claim test case
|
||||||
|
account, err := e2etestutil.CreateAccount(s.network, sample.Name, sample.Mnemonic)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
err = e2etestutil.FundAccount(s.network, account)
|
||||||
|
s.Require().NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TearDownSuite clean up after testing
|
// TearDownSuite clean up after testing
|
||||||
@ -137,11 +144,9 @@ func (s *E2ETestSuite) TestMintToken() {
|
|||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// send mint token request from non mint address
|
// send mint token request from non mint address
|
||||||
account, err := e2etestutil.CreateAccount(s.network, sample.Name, sample.Mnemonic)
|
k, err := val.ClientCtx.Keyring.Key(sample.Name)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
err = e2etestutil.FundAccount(s.network, account)
|
addr, _ := k.GetAddress()
|
||||||
s.Require().NoError(err)
|
|
||||||
addr, _ := account.GetAddress()
|
|
||||||
|
|
||||||
msg1 = daotypes.NewMsgMintToken(addr.String(), &mintRequest)
|
msg1 = daotypes.NewMsgMintToken(addr.String(), &mintRequest)
|
||||||
out, err = lib.BroadcastTxWithFileLock(addr, msg1)
|
out, err = lib.BroadcastTxWithFileLock(addr, msg1)
|
||||||
@ -198,7 +203,7 @@ func (s *E2ETestSuite) TestReissuance() {
|
|||||||
// 1: block 26: sending the reissuance result broadcast tx succeeded
|
// 1: block 26: sending the reissuance result broadcast tx succeeded
|
||||||
// 2: block 27: confirmation
|
// 2: block 27: confirmation
|
||||||
wait = 2
|
wait = 2
|
||||||
if latestHeight%(s.reissuanceEpochs+wait) == 0 {
|
if latestHeight%s.reissuanceEpochs == wait {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ func FundAccount(network *network.Network, account *keyring.Record) (err error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sending funds to account to initialize account on chain
|
// sending funds to account to initialize account on chain
|
||||||
coin := sdk.NewCoins(sdk.NewInt64Coin("stake", 1000)) // TODO: make denom dependent on cfg
|
coin := sdk.NewCoins(sdk.NewInt64Coin("stake", 1000))
|
||||||
msg := banktypes.NewMsgSend(val.Address, addr, coin)
|
msg := banktypes.NewMsgSend(val.Address, addr, coin)
|
||||||
out, err := lib.BroadcastTxWithFileLock(val.Address, msg)
|
out, err := lib.BroadcastTxWithFileLock(val.Address, msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -55,7 +55,9 @@ func DaoKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
|
|||||||
bk := daotestutil.NewMockBankKeeper(ctrl)
|
bk := daotestutil.NewMockBankKeeper(ctrl)
|
||||||
|
|
||||||
bk.EXPECT().MintCoins(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
|
bk.EXPECT().MintCoins(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
|
||||||
|
bk.EXPECT().BurnCoins(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
|
||||||
bk.EXPECT().SendCoinsFromModuleToAccount(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
|
bk.EXPECT().SendCoinsFromModuleToAccount(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
|
||||||
|
bk.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
|
||||||
|
|
||||||
k := keeper.NewKeeper(
|
k := keeper.NewKeeper(
|
||||||
cdc,
|
cdc,
|
||||||
|
@ -91,3 +91,10 @@ func SendInitPoP(goCtx context.Context, proposer string, challenger string, chal
|
|||||||
loggingContext := "PoP"
|
loggingContext := "PoP"
|
||||||
buildSignBroadcastTx(goCtx, loggingContext, sendingValidatorAddress, msg)
|
buildSignBroadcastTx(goCtx, loggingContext, sendingValidatorAddress, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SendUpdateRedeemClaim(goCtx context.Context, beneficiary string, id uint64, txID string) {
|
||||||
|
sendingValidatorAddress := config.GetConfig().ValidatorAddress
|
||||||
|
msg := daotypes.NewMsgUpdateRedeemClaim(sendingValidatorAddress, beneficiary, txID, id)
|
||||||
|
loggingContext := "redeem claim"
|
||||||
|
buildSignBroadcastTx(goCtx, loggingContext, sendingValidatorAddress, msg)
|
||||||
|
}
|
||||||
|
@ -35,6 +35,10 @@ func GetQueryCmd(_ string) *cobra.Command {
|
|||||||
|
|
||||||
cmd.AddCommand(CmdGetDistribution())
|
cmd.AddCommand(CmdGetDistribution())
|
||||||
|
|
||||||
|
cmd.AddCommand(CmdListRedeemClaim())
|
||||||
|
cmd.AddCommand(CmdShowRedeemClaim())
|
||||||
|
cmd.AddCommand(CmdRedeemClaimByLiquidTxHash())
|
||||||
|
|
||||||
// this line is used by starport scaffolding # 1
|
// this line is used by starport scaffolding # 1
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
121
x/dao/client/cli/query_redeem_claim.go
Normal file
121
x/dao/client/cli/query_redeem_claim.go
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
package cli
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"github.com/planetmint/planetmint-go/x/dao/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func CmdListRedeemClaim() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "list-redeem-claim",
|
||||||
|
Short: "list all redeem-claim",
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
pageReq, err := client.ReadPageRequest(cmd.Flags())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
queryClient := types.NewQueryClient(clientCtx)
|
||||||
|
|
||||||
|
params := &types.QueryAllRedeemClaimRequest{
|
||||||
|
Pagination: pageReq,
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := queryClient.RedeemClaimAll(cmd.Context(), params)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return clientCtx.PrintProto(res)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
flags.AddPaginationFlagsToCmd(cmd, cmd.Use)
|
||||||
|
flags.AddQueryFlagsToCmd(cmd)
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func CmdShowRedeemClaim() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "show-redeem-claim [beneficiary] [id]",
|
||||||
|
Short: "shows a redeem-claim",
|
||||||
|
Args: cobra.ExactArgs(2),
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
queryClient := types.NewQueryClient(clientCtx)
|
||||||
|
|
||||||
|
argBeneficiary := args[0]
|
||||||
|
argID, err := strconv.ParseUint(args[1], 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
params := &types.QueryGetRedeemClaimRequest{
|
||||||
|
Beneficiary: argBeneficiary,
|
||||||
|
Id: argID,
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := queryClient.RedeemClaim(cmd.Context(), params)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return clientCtx.PrintProto(res)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
flags.AddQueryFlagsToCmd(cmd)
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ = strconv.Itoa(0)
|
||||||
|
|
||||||
|
func CmdRedeemClaimByLiquidTxHash() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "redeem-claim-by-liquid-tx-hash [liquid-tx-hash]",
|
||||||
|
Short: "Query redeem-claim-by-liquid-tx-hash",
|
||||||
|
Args: cobra.ExactArgs(1),
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
reqLiquidTxHash := args[0]
|
||||||
|
|
||||||
|
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
queryClient := types.NewQueryClient(clientCtx)
|
||||||
|
|
||||||
|
params := &types.QueryRedeemClaimByLiquidTxHashRequest{
|
||||||
|
|
||||||
|
LiquidTxHash: reqLiquidTxHash,
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := queryClient.RedeemClaimByLiquidTxHash(cmd.Context(), params)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return clientCtx.PrintProto(res)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
flags.AddQueryFlagsToCmd(cmd)
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
@ -33,6 +33,9 @@ func GetTxCmd() *cobra.Command {
|
|||||||
cmd.AddCommand(CmdDistributionRequest())
|
cmd.AddCommand(CmdDistributionRequest())
|
||||||
cmd.AddCommand(CmdUpdateParams())
|
cmd.AddCommand(CmdUpdateParams())
|
||||||
cmd.AddCommand(CmdInitPop())
|
cmd.AddCommand(CmdInitPop())
|
||||||
|
cmd.AddCommand(CmdCreateRedeemClaim())
|
||||||
|
cmd.AddCommand(CmdUpdateRedeemClaim())
|
||||||
|
cmd.AddCommand(CmdConfirmRedeemClaim())
|
||||||
// this line is used by starport scaffolding # 1
|
// this line is used by starport scaffolding # 1
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
48
x/dao/client/cli/tx_confirm_redeem_claim.go
Normal file
48
x/dao/client/cli/tx_confirm_redeem_claim.go
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package cli
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
|
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||||
|
"github.com/planetmint/planetmint-go/x/dao/types"
|
||||||
|
"github.com/spf13/cast"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ = strconv.Itoa(0)
|
||||||
|
|
||||||
|
func CmdConfirmRedeemClaim() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "confirm-redeem-claim [id] [beneficiary]",
|
||||||
|
Short: "Broadcast message confirm-redeem-claim",
|
||||||
|
Args: cobra.ExactArgs(2),
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
argID, err := cast.ToUint64E(args[0])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
argBeneficiary := args[1]
|
||||||
|
|
||||||
|
clientCtx, err := client.GetClientTxContext(cmd)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
msg := types.NewMsgConfirmRedeemClaim(
|
||||||
|
clientCtx.GetFromAddress().String(),
|
||||||
|
argID,
|
||||||
|
argBeneficiary,
|
||||||
|
)
|
||||||
|
if err := msg.ValidateBasic(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
flags.AddTxFlagsToCmd(cmd)
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
87
x/dao/client/cli/tx_redeem_claim.go
Normal file
87
x/dao/client/cli/tx_redeem_claim.go
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
package cli
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
|
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||||
|
"github.com/planetmint/planetmint-go/x/dao/types"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
func CmdCreateRedeemClaim() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "create-redeem-claim [beneficiary] [amount]",
|
||||||
|
Short: "Create a new redeem-claim",
|
||||||
|
Args: cobra.ExactArgs(4),
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
// Get indexes
|
||||||
|
indexBeneficiary := args[0]
|
||||||
|
|
||||||
|
// Get value arguments
|
||||||
|
argAmount, err := strconv.ParseUint(args[1], 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
clientCtx, err := client.GetClientTxContext(cmd)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
msg := types.NewMsgCreateRedeemClaim(
|
||||||
|
clientCtx.GetFromAddress().String(),
|
||||||
|
indexBeneficiary,
|
||||||
|
argAmount,
|
||||||
|
)
|
||||||
|
if err := msg.ValidateBasic(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
flags.AddTxFlagsToCmd(cmd)
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func CmdUpdateRedeemClaim() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "update-redeem-claim [beneficiary] [id] [liquid-tx-hash]",
|
||||||
|
Short: "Update a redeem-claim",
|
||||||
|
Args: cobra.ExactArgs(4),
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
// Get indexes
|
||||||
|
indexBeneficiary := args[0]
|
||||||
|
indexID, err := strconv.ParseUint(args[1], 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get value arguments
|
||||||
|
argLiquidTxHash := args[2]
|
||||||
|
|
||||||
|
clientCtx, err := client.GetClientTxContext(cmd)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
msg := types.NewMsgUpdateRedeemClaim(
|
||||||
|
clientCtx.GetFromAddress().String(),
|
||||||
|
indexBeneficiary,
|
||||||
|
argLiquidTxHash,
|
||||||
|
indexID,
|
||||||
|
)
|
||||||
|
if err := msg.ValidateBasic(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
flags.AddTxFlagsToCmd(cmd)
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
@ -14,7 +14,6 @@ func TestGenesis(t *testing.T) {
|
|||||||
t.Parallel()
|
t.Parallel()
|
||||||
genesisState := types.GenesisState{
|
genesisState := types.GenesisState{
|
||||||
Params: types.DefaultParams(),
|
Params: types.DefaultParams(),
|
||||||
|
|
||||||
// this line is used by starport scaffolding # genesis/test/state
|
// this line is used by starport scaffolding # genesis/test/state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
113
x/dao/keeper/msg_server_redeem_claim.go
Normal file
113
x/dao/keeper/msg_server_redeem_claim.go
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
package keeper
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
errorsmod "cosmossdk.io/errors"
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||||
|
"github.com/planetmint/planetmint-go/util"
|
||||||
|
"github.com/planetmint/planetmint-go/x/dao/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
createRedeemClaimTag = "create redeem claim: "
|
||||||
|
)
|
||||||
|
|
||||||
|
func (k msgServer) CreateRedeemClaim(goCtx context.Context, msg *types.MsgCreateRedeemClaim) (*types.MsgCreateRedeemClaimResponse, error) {
|
||||||
|
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||||
|
params := k.GetParams(ctx)
|
||||||
|
|
||||||
|
var redeemClaim = types.RedeemClaim{
|
||||||
|
Creator: msg.Creator,
|
||||||
|
Beneficiary: msg.Beneficiary,
|
||||||
|
Amount: msg.Amount,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := k.burnClaimAmount(ctx, sdk.MustAccAddressFromBech32(msg.Creator), msg.Amount)
|
||||||
|
if err != nil {
|
||||||
|
util.GetAppLogger().Error(ctx, createRedeemClaimTag+"could not burn claim")
|
||||||
|
}
|
||||||
|
|
||||||
|
id := k.CreateNewRedeemClaim(
|
||||||
|
ctx,
|
||||||
|
redeemClaim,
|
||||||
|
)
|
||||||
|
|
||||||
|
if util.IsValidatorBlockProposer(ctx, ctx.BlockHeader().ProposerAddress) {
|
||||||
|
util.GetAppLogger().Info(ctx, fmt.Sprintf("Issuing RDDL claim: %s/%d", msg.Beneficiary, id))
|
||||||
|
txID, err := util.DistributeAsset(msg.Beneficiary, util.UintValueToRDDLTokenString(msg.Amount), params.ReissuanceAsset)
|
||||||
|
if err != nil {
|
||||||
|
util.GetAppLogger().Error(ctx, createRedeemClaimTag+"could not issue claim to beneficiary: "+msg.GetBeneficiary())
|
||||||
|
}
|
||||||
|
util.SendUpdateRedeemClaim(goCtx, msg.Beneficiary, id, txID)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &types.MsgCreateRedeemClaimResponse{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (k msgServer) UpdateRedeemClaim(goCtx context.Context, msg *types.MsgUpdateRedeemClaim) (*types.MsgUpdateRedeemClaimResponse, error) {
|
||||||
|
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||||
|
|
||||||
|
valFound, isFound := k.GetRedeemClaim(
|
||||||
|
ctx,
|
||||||
|
msg.Beneficiary,
|
||||||
|
msg.Id,
|
||||||
|
)
|
||||||
|
if !isFound {
|
||||||
|
return nil, errorsmod.Wrap(sdkerrors.ErrKeyNotFound, "index not set")
|
||||||
|
}
|
||||||
|
|
||||||
|
var redeemClaim = types.RedeemClaim{
|
||||||
|
Creator: valFound.Creator,
|
||||||
|
Beneficiary: msg.Beneficiary,
|
||||||
|
LiquidTxHash: msg.LiquidTxHash,
|
||||||
|
Amount: valFound.Amount,
|
||||||
|
Id: valFound.Id,
|
||||||
|
}
|
||||||
|
|
||||||
|
k.SetRedeemClaim(ctx, redeemClaim)
|
||||||
|
|
||||||
|
return &types.MsgUpdateRedeemClaimResponse{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (k msgServer) ConfirmRedeemClaim(goCtx context.Context, msg *types.MsgConfirmRedeemClaim) (*types.MsgConfirmRedeemClaimResponse, error) {
|
||||||
|
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||||
|
|
||||||
|
valFound, isFound := k.GetRedeemClaim(
|
||||||
|
ctx,
|
||||||
|
msg.Beneficiary,
|
||||||
|
msg.Id,
|
||||||
|
)
|
||||||
|
if !isFound {
|
||||||
|
return nil, errorsmod.Wrap(sdkerrors.ErrKeyNotFound, "index not set")
|
||||||
|
}
|
||||||
|
|
||||||
|
var redeemClaim = types.RedeemClaim{
|
||||||
|
Creator: valFound.Creator,
|
||||||
|
Beneficiary: msg.Beneficiary,
|
||||||
|
LiquidTxHash: valFound.LiquidTxHash,
|
||||||
|
Amount: valFound.Amount,
|
||||||
|
Id: valFound.Id,
|
||||||
|
Confirmed: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
k.SetRedeemClaim(ctx, redeemClaim)
|
||||||
|
|
||||||
|
return &types.MsgConfirmRedeemClaimResponse{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (k msgServer) burnClaimAmount(ctx sdk.Context, addr sdk.AccAddress, amount uint64) (err error) {
|
||||||
|
params := k.GetParams(ctx)
|
||||||
|
burnCoins := sdk.NewCoins(sdk.NewCoin(params.ClaimDenom, sdk.NewIntFromUint64(amount)))
|
||||||
|
err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, addr, types.ModuleName, burnCoins)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = k.bankKeeper.BurnCoins(ctx, types.ModuleName, burnCoins)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
93
x/dao/keeper/msg_server_redeem_claim_test.go
Normal file
93
x/dao/keeper/msg_server_redeem_claim_test.go
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
package keeper_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
keepertest "github.com/planetmint/planetmint-go/testutil/keeper"
|
||||||
|
"github.com/planetmint/planetmint-go/testutil/sample"
|
||||||
|
"github.com/planetmint/planetmint-go/x/dao/keeper"
|
||||||
|
"github.com/planetmint/planetmint-go/x/dao/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Prevent strconv unused error
|
||||||
|
var _ = strconv.IntSize
|
||||||
|
|
||||||
|
func TestRedeemClaimMsgServerCreate(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
k, ctx := keepertest.DaoKeeper(t)
|
||||||
|
srv := keeper.NewMsgServerImpl(*k)
|
||||||
|
wctx := sdk.WrapSDKContext(ctx)
|
||||||
|
creator := sample.ConstBech32Addr
|
||||||
|
for i := 0; i < 5; i++ {
|
||||||
|
expected := &types.MsgCreateRedeemClaim{Creator: creator,
|
||||||
|
Beneficiary: strconv.Itoa(i),
|
||||||
|
}
|
||||||
|
_, err := srv.CreateRedeemClaim(wctx, expected)
|
||||||
|
require.NoError(t, err)
|
||||||
|
rst, found := k.GetRedeemClaim(ctx,
|
||||||
|
expected.Beneficiary,
|
||||||
|
uint64(0),
|
||||||
|
)
|
||||||
|
require.True(t, found)
|
||||||
|
require.Equal(t, expected.Creator, rst.Creator)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRedeemClaimMsgServerUpdate(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
creator := sample.ConstBech32Addr
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
desc string
|
||||||
|
request *types.MsgUpdateRedeemClaim
|
||||||
|
err error
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
desc: "Completed",
|
||||||
|
request: &types.MsgUpdateRedeemClaim{Creator: creator,
|
||||||
|
Beneficiary: strconv.Itoa(0),
|
||||||
|
LiquidTxHash: strconv.Itoa(0),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
desc: "KeyNotFound",
|
||||||
|
request: &types.MsgUpdateRedeemClaim{Creator: creator,
|
||||||
|
Beneficiary: strconv.Itoa(100000),
|
||||||
|
LiquidTxHash: strconv.Itoa(100000),
|
||||||
|
},
|
||||||
|
err: sdkerrors.ErrKeyNotFound,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tc := range tests {
|
||||||
|
tc := tc
|
||||||
|
t.Run(tc.desc, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
k, ctx := keepertest.DaoKeeper(t)
|
||||||
|
srv := keeper.NewMsgServerImpl(*k)
|
||||||
|
wctx := sdk.WrapSDKContext(ctx)
|
||||||
|
expected := &types.MsgCreateRedeemClaim{Creator: creator,
|
||||||
|
Beneficiary: strconv.Itoa(0),
|
||||||
|
}
|
||||||
|
_, err := srv.CreateRedeemClaim(wctx, expected)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
_, err = srv.UpdateRedeemClaim(wctx, tc.request)
|
||||||
|
if tc.err != nil {
|
||||||
|
require.ErrorIs(t, err, tc.err)
|
||||||
|
} else {
|
||||||
|
require.NoError(t, err)
|
||||||
|
rst, found := k.GetRedeemClaim(ctx,
|
||||||
|
expected.Beneficiary,
|
||||||
|
uint64(0),
|
||||||
|
)
|
||||||
|
require.True(t, found)
|
||||||
|
require.Equal(t, expected.Creator, rst.Creator)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
@ -34,3 +34,7 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error {
|
|||||||
func (k Keeper) GetMintAddress(ctx sdk.Context) (mintAddress string) {
|
func (k Keeper) GetMintAddress(ctx sdk.Context) (mintAddress string) {
|
||||||
return k.GetParams(ctx).MintAddress
|
return k.GetParams(ctx).MintAddress
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (k Keeper) GetClaimAddress(ctx sdk.Context) (claimAddress string) {
|
||||||
|
return k.GetParams(ctx).ClaimAddress
|
||||||
|
}
|
||||||
|
76
x/dao/keeper/query_redeem_claim.go
Normal file
76
x/dao/keeper/query_redeem_claim.go
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
package keeper
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
"github.com/cosmos/cosmos-sdk/types/query"
|
||||||
|
"github.com/planetmint/planetmint-go/x/dao/types"
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
"google.golang.org/grpc/status"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (k Keeper) RedeemClaimAll(goCtx context.Context, req *types.QueryAllRedeemClaimRequest) (*types.QueryAllRedeemClaimResponse, error) {
|
||||||
|
if req == nil {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "invalid request")
|
||||||
|
}
|
||||||
|
|
||||||
|
var redeemClaims []types.RedeemClaim
|
||||||
|
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||||
|
|
||||||
|
store := ctx.KVStore(k.storeKey)
|
||||||
|
redeemClaimStore := prefix.NewStore(store, types.KeyPrefix(types.RedeemClaimKeyPrefix))
|
||||||
|
|
||||||
|
pageRes, err := query.Paginate(redeemClaimStore, req.Pagination, func(key []byte, value []byte) error {
|
||||||
|
var redeemClaim types.RedeemClaim
|
||||||
|
if err := k.cdc.Unmarshal(value, &redeemClaim); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
redeemClaims = append(redeemClaims, redeemClaim)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Error(codes.Internal, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return &types.QueryAllRedeemClaimResponse{RedeemClaim: redeemClaims, Pagination: pageRes}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (k Keeper) RedeemClaim(goCtx context.Context, req *types.QueryGetRedeemClaimRequest) (*types.QueryGetRedeemClaimResponse, error) {
|
||||||
|
if req == nil {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "invalid request")
|
||||||
|
}
|
||||||
|
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||||
|
|
||||||
|
val, found := k.GetRedeemClaim(
|
||||||
|
ctx,
|
||||||
|
req.Beneficiary,
|
||||||
|
req.Id,
|
||||||
|
)
|
||||||
|
if !found {
|
||||||
|
return nil, status.Error(codes.NotFound, "not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
return &types.QueryGetRedeemClaimResponse{RedeemClaim: val}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (k Keeper) RedeemClaimByLiquidTxHash(goCtx context.Context, req *types.QueryRedeemClaimByLiquidTxHashRequest) (*types.QueryRedeemClaimByLiquidTxHashResponse, error) {
|
||||||
|
if req == nil {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "invalid request")
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||||
|
|
||||||
|
val, found := k.GetRedeemClaimByLiquidTXHash(
|
||||||
|
ctx,
|
||||||
|
req.LiquidTxHash,
|
||||||
|
)
|
||||||
|
if !found {
|
||||||
|
return nil, status.Error(codes.NotFound, "not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
return &types.QueryRedeemClaimByLiquidTxHashResponse{RedeemClaim: &val}, nil
|
||||||
|
}
|
130
x/dao/keeper/query_redeem_claim_test.go
Normal file
130
x/dao/keeper/query_redeem_claim_test.go
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
package keeper_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
"github.com/cosmos/cosmos-sdk/types/query"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
"google.golang.org/grpc/status"
|
||||||
|
|
||||||
|
keepertest "github.com/planetmint/planetmint-go/testutil/keeper"
|
||||||
|
"github.com/planetmint/planetmint-go/testutil/nullify"
|
||||||
|
"github.com/planetmint/planetmint-go/x/dao/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Prevent strconv unused error
|
||||||
|
var _ = strconv.IntSize
|
||||||
|
|
||||||
|
func TestRedeemClaimQuerySingle(t *testing.T) {
|
||||||
|
keeper, ctx := keepertest.DaoKeeper(t)
|
||||||
|
wctx := sdk.WrapSDKContext(ctx)
|
||||||
|
msgs := createNRedeemClaim(keeper, ctx, 2)
|
||||||
|
tests := []struct {
|
||||||
|
desc string
|
||||||
|
request *types.QueryGetRedeemClaimRequest
|
||||||
|
response *types.QueryGetRedeemClaimResponse
|
||||||
|
err error
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
desc: "First",
|
||||||
|
request: &types.QueryGetRedeemClaimRequest{
|
||||||
|
Beneficiary: msgs[0].Beneficiary,
|
||||||
|
Id: msgs[0].Id,
|
||||||
|
},
|
||||||
|
response: &types.QueryGetRedeemClaimResponse{RedeemClaim: msgs[0]},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
desc: "Second",
|
||||||
|
request: &types.QueryGetRedeemClaimRequest{
|
||||||
|
Beneficiary: msgs[1].Beneficiary,
|
||||||
|
Id: msgs[1].Id,
|
||||||
|
},
|
||||||
|
response: &types.QueryGetRedeemClaimResponse{RedeemClaim: msgs[1]},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
desc: "KeyNotFound",
|
||||||
|
request: &types.QueryGetRedeemClaimRequest{
|
||||||
|
Beneficiary: strconv.Itoa(100000),
|
||||||
|
Id: uint64(100000),
|
||||||
|
},
|
||||||
|
err: status.Error(codes.NotFound, "not found"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
desc: "InvalidRequest",
|
||||||
|
err: status.Error(codes.InvalidArgument, "invalid request"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tc := range tests {
|
||||||
|
t.Run(tc.desc, func(t *testing.T) {
|
||||||
|
response, err := keeper.RedeemClaim(wctx, tc.request)
|
||||||
|
if tc.err != nil {
|
||||||
|
require.ErrorIs(t, err, tc.err)
|
||||||
|
} else {
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t,
|
||||||
|
nullify.Fill(tc.response),
|
||||||
|
nullify.Fill(response),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRedeemClaimQueryPaginated(t *testing.T) {
|
||||||
|
keeper, ctx := keepertest.DaoKeeper(t)
|
||||||
|
wctx := sdk.WrapSDKContext(ctx)
|
||||||
|
msgs := createNRedeemClaim(keeper, ctx, 5)
|
||||||
|
|
||||||
|
request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllRedeemClaimRequest {
|
||||||
|
return &types.QueryAllRedeemClaimRequest{
|
||||||
|
Pagination: &query.PageRequest{
|
||||||
|
Key: next,
|
||||||
|
Offset: offset,
|
||||||
|
Limit: limit,
|
||||||
|
CountTotal: total,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
t.Run("ByOffset", func(t *testing.T) {
|
||||||
|
step := 2
|
||||||
|
for i := 0; i < len(msgs); i += step {
|
||||||
|
resp, err := keeper.RedeemClaimAll(wctx, request(nil, uint64(i), uint64(step), false))
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.LessOrEqual(t, len(resp.RedeemClaim), step)
|
||||||
|
require.Subset(t,
|
||||||
|
nullify.Fill(msgs),
|
||||||
|
nullify.Fill(resp.RedeemClaim),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
t.Run("ByKey", func(t *testing.T) {
|
||||||
|
step := 2
|
||||||
|
var next []byte
|
||||||
|
for i := 0; i < len(msgs); i += step {
|
||||||
|
resp, err := keeper.RedeemClaimAll(wctx, request(next, 0, uint64(step), false))
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.LessOrEqual(t, len(resp.RedeemClaim), step)
|
||||||
|
require.Subset(t,
|
||||||
|
nullify.Fill(msgs),
|
||||||
|
nullify.Fill(resp.RedeemClaim),
|
||||||
|
)
|
||||||
|
next = resp.Pagination.NextKey
|
||||||
|
}
|
||||||
|
})
|
||||||
|
t.Run("Total", func(t *testing.T) {
|
||||||
|
resp, err := keeper.RedeemClaimAll(wctx, request(nil, 0, 0, true))
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, len(msgs), int(resp.Pagination.Total))
|
||||||
|
require.ElementsMatch(t,
|
||||||
|
nullify.Fill(msgs),
|
||||||
|
nullify.Fill(resp.RedeemClaim),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
t.Run("InvalidRequest", func(t *testing.T) {
|
||||||
|
_, err := keeper.RedeemClaimAll(wctx, nil)
|
||||||
|
require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request"))
|
||||||
|
})
|
||||||
|
}
|
118
x/dao/keeper/redeem_claim.go
Normal file
118
x/dao/keeper/redeem_claim.go
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
package keeper
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/binary"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
"github.com/planetmint/planetmint-go/x/dao/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetBeneficiaryRedeemClaimCount get the total number of RedeemClaim for a beneficiary
|
||||||
|
func (k Keeper) GetBeneficiaryRedeemClaimCount(ctx sdk.Context, beneficiary string) uint64 {
|
||||||
|
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RedeemClaimBeneficiaryCountKeyPrefix))
|
||||||
|
byteKey := types.KeyPrefix(beneficiary)
|
||||||
|
bz := store.Get(byteKey)
|
||||||
|
|
||||||
|
// Count doesn't exist: no element
|
||||||
|
if bz == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse bytes
|
||||||
|
return binary.BigEndian.Uint64(bz)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetBeneficiaryRedeemClaimCount set the total number of RedeemClaim for beneficiary
|
||||||
|
func (k Keeper) SetBeneficiaryRedeemClaimCount(ctx sdk.Context, beneficiary string, count uint64) {
|
||||||
|
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RedeemClaimBeneficiaryCountKeyPrefix))
|
||||||
|
byteKey := types.KeyPrefix(beneficiary)
|
||||||
|
bz := make([]byte, 8)
|
||||||
|
binary.BigEndian.PutUint64(bz, count)
|
||||||
|
store.Set(byteKey, bz)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRedeemClaim set a specific redeemClaim in the store from its index
|
||||||
|
func (k Keeper) SetRedeemClaim(ctx sdk.Context, redeemClaim types.RedeemClaim) {
|
||||||
|
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RedeemClaimKeyPrefix))
|
||||||
|
b := k.cdc.MustMarshal(&redeemClaim)
|
||||||
|
|
||||||
|
if redeemClaim.LiquidTxHash != "" {
|
||||||
|
k.SetRedeemClaimByLiquidTXHash(ctx, redeemClaim)
|
||||||
|
}
|
||||||
|
|
||||||
|
store.Set(types.RedeemClaimKey(
|
||||||
|
redeemClaim.Beneficiary,
|
||||||
|
redeemClaim.Id,
|
||||||
|
), b)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRedeemClaimByLiquidTXHash set a specific redeemClaim in the store from its index
|
||||||
|
func (k Keeper) SetRedeemClaimByLiquidTXHash(ctx sdk.Context, redeemClaim types.RedeemClaim) {
|
||||||
|
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RedeemClaimLiquidTXKeyPrefix))
|
||||||
|
b := k.cdc.MustMarshal(&redeemClaim)
|
||||||
|
byteKey := types.KeyPrefix(redeemClaim.LiquidTxHash)
|
||||||
|
store.Set(byteKey, b)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRedeemClaimByLiquidTXHash returns a redeemClaim from its index
|
||||||
|
func (k Keeper) GetRedeemClaimByLiquidTXHash(ctx sdk.Context, liquidTXHash string) (val types.RedeemClaim, found bool) {
|
||||||
|
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RedeemClaimLiquidTXKeyPrefix))
|
||||||
|
b := store.Get(types.KeyPrefix(liquidTXHash))
|
||||||
|
if b == nil {
|
||||||
|
return val, false
|
||||||
|
}
|
||||||
|
|
||||||
|
k.cdc.MustUnmarshal(b, &val)
|
||||||
|
return val, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateNewRedeemClaim creates a specific redeemClaim in the store from its index
|
||||||
|
func (k Keeper) CreateNewRedeemClaim(ctx sdk.Context, redeemClaim types.RedeemClaim) uint64 {
|
||||||
|
count := k.GetBeneficiaryRedeemClaimCount(ctx, redeemClaim.Beneficiary)
|
||||||
|
|
||||||
|
redeemClaim.Id = count
|
||||||
|
k.SetRedeemClaim(ctx, redeemClaim)
|
||||||
|
|
||||||
|
// Update BeneficiaryRedeemCount
|
||||||
|
k.SetBeneficiaryRedeemClaimCount(ctx, redeemClaim.Beneficiary, count+1)
|
||||||
|
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRedeemClaim returns a redeemClaim from its index
|
||||||
|
func (k Keeper) GetRedeemClaim(
|
||||||
|
ctx sdk.Context,
|
||||||
|
beneficiary string,
|
||||||
|
id uint64,
|
||||||
|
|
||||||
|
) (val types.RedeemClaim, found bool) {
|
||||||
|
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RedeemClaimKeyPrefix))
|
||||||
|
|
||||||
|
b := store.Get(types.RedeemClaimKey(
|
||||||
|
beneficiary,
|
||||||
|
id,
|
||||||
|
))
|
||||||
|
if b == nil {
|
||||||
|
return val, false
|
||||||
|
}
|
||||||
|
|
||||||
|
k.cdc.MustUnmarshal(b, &val)
|
||||||
|
return val, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAllRedeemClaim returns all redeemClaim
|
||||||
|
func (k Keeper) GetAllRedeemClaim(ctx sdk.Context) (list []types.RedeemClaim) {
|
||||||
|
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RedeemClaimKeyPrefix))
|
||||||
|
iterator := sdk.KVStorePrefixIterator(store, []byte{})
|
||||||
|
|
||||||
|
defer iterator.Close()
|
||||||
|
|
||||||
|
for ; iterator.Valid(); iterator.Next() {
|
||||||
|
var val types.RedeemClaim
|
||||||
|
k.cdc.MustUnmarshal(iterator.Value(), &val)
|
||||||
|
list = append(list, val)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
66
x/dao/keeper/redeem_claim_test.go
Normal file
66
x/dao/keeper/redeem_claim_test.go
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
package keeper_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
keepertest "github.com/planetmint/planetmint-go/testutil/keeper"
|
||||||
|
"github.com/planetmint/planetmint-go/testutil/nullify"
|
||||||
|
"github.com/planetmint/planetmint-go/x/dao/keeper"
|
||||||
|
"github.com/planetmint/planetmint-go/x/dao/types"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Prevent strconv unused error
|
||||||
|
var _ = strconv.IntSize
|
||||||
|
|
||||||
|
func createNRedeemClaim(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.RedeemClaim {
|
||||||
|
items := make([]types.RedeemClaim, n)
|
||||||
|
for i := range items {
|
||||||
|
items[i].Beneficiary = strconv.Itoa(i)
|
||||||
|
id := keeper.CreateNewRedeemClaim(ctx, items[i])
|
||||||
|
items[i].Id = id
|
||||||
|
}
|
||||||
|
return items
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRedeemClaimGet(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
keeper, ctx := keepertest.DaoKeeper(t)
|
||||||
|
items := createNRedeemClaim(keeper, ctx, 10)
|
||||||
|
for _, item := range items {
|
||||||
|
rst, found := keeper.GetRedeemClaim(ctx,
|
||||||
|
item.Beneficiary,
|
||||||
|
item.Id,
|
||||||
|
)
|
||||||
|
require.True(t, found)
|
||||||
|
require.Equal(t,
|
||||||
|
nullify.Fill(&item),
|
||||||
|
nullify.Fill(&rst),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRedeemClaimGetAll(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
keeper, ctx := keepertest.DaoKeeper(t)
|
||||||
|
items := createNRedeemClaim(keeper, ctx, 10)
|
||||||
|
require.ElementsMatch(t,
|
||||||
|
nullify.Fill(items),
|
||||||
|
nullify.Fill(keeper.GetAllRedeemClaim(ctx)),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRedeemClaimByLiquidTXHash(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
keeper, ctx := keepertest.DaoKeeper(t)
|
||||||
|
items := createNRedeemClaim(keeper, ctx, 10)
|
||||||
|
for i, item := range items {
|
||||||
|
item.LiquidTxHash = strconv.Itoa(i)
|
||||||
|
keeper.SetRedeemClaimByLiquidTXHash(ctx, item)
|
||||||
|
rc, found := keeper.GetRedeemClaimByLiquidTXHash(ctx, strconv.Itoa(i))
|
||||||
|
require.True(t, found)
|
||||||
|
require.Equal(t, item, rc)
|
||||||
|
}
|
||||||
|
}
|
@ -39,6 +39,22 @@ const (
|
|||||||
// TODO: Determine the simulation weight value
|
// TODO: Determine the simulation weight value
|
||||||
defaultWeightMsgInitPop int = 100
|
defaultWeightMsgInitPop int = 100
|
||||||
|
|
||||||
|
opWeightMsgCreateRedeemClaim = "op_weight_msg_redeem_claim"
|
||||||
|
// TODO: Determine the simulation weight value
|
||||||
|
defaultWeightMsgCreateRedeemClaim int = 100
|
||||||
|
|
||||||
|
opWeightMsgUpdateRedeemClaim = "op_weight_msg_redeem_claim"
|
||||||
|
// TODO: Determine the simulation weight value
|
||||||
|
defaultWeightMsgUpdateRedeemClaim int = 100
|
||||||
|
|
||||||
|
opWeightMsgDeleteRedeemClaim = "op_weight_msg_redeem_claim"
|
||||||
|
// TODO: Determine the simulation weight value
|
||||||
|
defaultWeightMsgDeleteRedeemClaim int = 100
|
||||||
|
|
||||||
|
opWeightMsgConfirmRedeemClaim = "op_weight_msg_confirm_redeem_claim"
|
||||||
|
// TODO: Determine the simulation weight value
|
||||||
|
defaultWeightMsgConfirmRedeemClaim int = 100
|
||||||
|
|
||||||
// this line is used by starport scaffolding # simapp/module/const
|
// this line is used by starport scaffolding # simapp/module/const
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -111,6 +127,46 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp
|
|||||||
daosimulation.SimulateMsgInitPop(am.accountKeeper, am.bankKeeper, am.keeper),
|
daosimulation.SimulateMsgInitPop(am.accountKeeper, am.bankKeeper, am.keeper),
|
||||||
))
|
))
|
||||||
|
|
||||||
|
var weightMsgCreateRedeemClaim int
|
||||||
|
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgCreateRedeemClaim, &weightMsgCreateRedeemClaim, nil,
|
||||||
|
func(_ *rand.Rand) {
|
||||||
|
weightMsgCreateRedeemClaim = defaultWeightMsgCreateRedeemClaim
|
||||||
|
},
|
||||||
|
)
|
||||||
|
operations = append(operations, simulation.NewWeightedOperation(
|
||||||
|
weightMsgCreateRedeemClaim,
|
||||||
|
daosimulation.SimulateMsgCreateRedeemClaim(am.accountKeeper, am.bankKeeper, am.keeper),
|
||||||
|
))
|
||||||
|
|
||||||
|
var weightMsgUpdateRedeemClaim int
|
||||||
|
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgUpdateRedeemClaim, &weightMsgUpdateRedeemClaim, nil,
|
||||||
|
func(_ *rand.Rand) {
|
||||||
|
weightMsgUpdateRedeemClaim = defaultWeightMsgUpdateRedeemClaim
|
||||||
|
},
|
||||||
|
)
|
||||||
|
operations = append(operations, simulation.NewWeightedOperation(
|
||||||
|
weightMsgUpdateRedeemClaim,
|
||||||
|
daosimulation.SimulateMsgUpdateRedeemClaim(am.accountKeeper, am.bankKeeper, am.keeper),
|
||||||
|
))
|
||||||
|
|
||||||
|
var weightMsgDeleteRedeemClaim int
|
||||||
|
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgDeleteRedeemClaim, &weightMsgDeleteRedeemClaim, nil,
|
||||||
|
func(_ *rand.Rand) {
|
||||||
|
weightMsgDeleteRedeemClaim = defaultWeightMsgDeleteRedeemClaim
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
var weightMsgConfirmRedeemClaim int
|
||||||
|
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgConfirmRedeemClaim, &weightMsgConfirmRedeemClaim, nil,
|
||||||
|
func(_ *rand.Rand) {
|
||||||
|
weightMsgConfirmRedeemClaim = defaultWeightMsgConfirmRedeemClaim
|
||||||
|
},
|
||||||
|
)
|
||||||
|
operations = append(operations, simulation.NewWeightedOperation(
|
||||||
|
weightMsgConfirmRedeemClaim,
|
||||||
|
daosimulation.SimulateMsgConfirmRedeemClaim(am.accountKeeper, am.bankKeeper, am.keeper),
|
||||||
|
))
|
||||||
|
|
||||||
// this line is used by starport scaffolding # simapp/module/operation
|
// this line is used by starport scaffolding # simapp/module/operation
|
||||||
|
|
||||||
return operations
|
return operations
|
||||||
@ -151,6 +207,30 @@ func (am AppModule) ProposalMsgs(_ module.SimulationState) []simtypes.WeightedPr
|
|||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
simulation.NewWeightedProposalMsg(
|
||||||
|
opWeightMsgCreateRedeemClaim,
|
||||||
|
defaultWeightMsgCreateRedeemClaim,
|
||||||
|
func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg {
|
||||||
|
daosimulation.SimulateMsgCreateRedeemClaim(am.accountKeeper, am.bankKeeper, am.keeper)
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
),
|
||||||
|
simulation.NewWeightedProposalMsg(
|
||||||
|
opWeightMsgUpdateRedeemClaim,
|
||||||
|
defaultWeightMsgUpdateRedeemClaim,
|
||||||
|
func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg {
|
||||||
|
daosimulation.SimulateMsgUpdateRedeemClaim(am.accountKeeper, am.bankKeeper, am.keeper)
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
),
|
||||||
|
simulation.NewWeightedProposalMsg(
|
||||||
|
opWeightMsgConfirmRedeemClaim,
|
||||||
|
defaultWeightMsgConfirmRedeemClaim,
|
||||||
|
func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg {
|
||||||
|
daosimulation.SimulateMsgConfirmRedeemClaim(am.accountKeeper, am.bankKeeper, am.keeper)
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
),
|
||||||
// this line is used by starport scaffolding # simapp/module/OpMsg
|
// this line is used by starport scaffolding # simapp/module/OpMsg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
29
x/dao/simulation/confirm_redeem_claim.go
Normal file
29
x/dao/simulation/confirm_redeem_claim.go
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package simulation
|
||||||
|
|
||||||
|
import (
|
||||||
|
"math/rand"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||||
|
"github.com/planetmint/planetmint-go/x/dao/keeper"
|
||||||
|
"github.com/planetmint/planetmint-go/x/dao/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func SimulateMsgConfirmRedeemClaim(
|
||||||
|
_ types.AccountKeeper,
|
||||||
|
_ types.BankKeeper,
|
||||||
|
_ keeper.Keeper,
|
||||||
|
) simtypes.Operation {
|
||||||
|
return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string,
|
||||||
|
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
|
||||||
|
simAccount, _ := simtypes.RandomAcc(r, accs)
|
||||||
|
msg := &types.MsgConfirmRedeemClaim{
|
||||||
|
Creator: simAccount.Address.String(),
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Handling the ConfirmRedeemClaim simulation
|
||||||
|
|
||||||
|
return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "ConfirmRedeemClaim simulation not implemented"), nil, nil
|
||||||
|
}
|
||||||
|
}
|
102
x/dao/simulation/redeem_claim.go
Normal file
102
x/dao/simulation/redeem_claim.go
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
package simulation
|
||||||
|
|
||||||
|
import (
|
||||||
|
"math/rand"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
simappparams "cosmossdk.io/simapp/params"
|
||||||
|
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/simulation"
|
||||||
|
"github.com/planetmint/planetmint-go/x/dao/keeper"
|
||||||
|
"github.com/planetmint/planetmint-go/x/dao/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Prevent strconv unused error
|
||||||
|
var _ = strconv.IntSize
|
||||||
|
|
||||||
|
func SimulateMsgCreateRedeemClaim(
|
||||||
|
ak types.AccountKeeper,
|
||||||
|
bk types.BankKeeper,
|
||||||
|
k keeper.Keeper,
|
||||||
|
) simtypes.Operation {
|
||||||
|
return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string,
|
||||||
|
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
|
||||||
|
simAccount, _ := simtypes.RandomAcc(r, accs)
|
||||||
|
|
||||||
|
i := r.Int()
|
||||||
|
msg := &types.MsgCreateRedeemClaim{
|
||||||
|
Creator: simAccount.Address.String(),
|
||||||
|
Beneficiary: strconv.Itoa(i),
|
||||||
|
}
|
||||||
|
|
||||||
|
_, found := k.GetRedeemClaim(ctx, msg.Beneficiary, uint64(i))
|
||||||
|
if found {
|
||||||
|
return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "RedeemClaim already exist"), nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
txCtx := simulation.OperationInput{
|
||||||
|
R: r,
|
||||||
|
App: app,
|
||||||
|
TxGen: simappparams.MakeTestEncodingConfig().TxConfig,
|
||||||
|
Cdc: nil,
|
||||||
|
Msg: msg,
|
||||||
|
MsgType: msg.Type(),
|
||||||
|
Context: ctx,
|
||||||
|
SimAccount: simAccount,
|
||||||
|
ModuleName: types.ModuleName,
|
||||||
|
CoinsSpentInMsg: sdk.NewCoins(),
|
||||||
|
AccountKeeper: ak,
|
||||||
|
Bankkeeper: bk,
|
||||||
|
}
|
||||||
|
return simulation.GenAndDeliverTxWithRandFees(txCtx)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func SimulateMsgUpdateRedeemClaim(
|
||||||
|
ak types.AccountKeeper,
|
||||||
|
bk types.BankKeeper,
|
||||||
|
k keeper.Keeper,
|
||||||
|
) simtypes.Operation {
|
||||||
|
return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string,
|
||||||
|
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
|
||||||
|
var (
|
||||||
|
simAccount = simtypes.Account{}
|
||||||
|
redeemClaim = types.RedeemClaim{}
|
||||||
|
msg = &types.MsgUpdateRedeemClaim{}
|
||||||
|
allRedeemClaim = k.GetAllRedeemClaim(ctx)
|
||||||
|
found = false
|
||||||
|
)
|
||||||
|
for _, obj := range allRedeemClaim {
|
||||||
|
simAccount, found = FindAccount(accs, obj.Creator)
|
||||||
|
if found {
|
||||||
|
redeemClaim = obj
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "redeemClaim creator not found"), nil, nil
|
||||||
|
}
|
||||||
|
msg.Creator = simAccount.Address.String()
|
||||||
|
|
||||||
|
msg.Beneficiary = redeemClaim.Beneficiary
|
||||||
|
msg.LiquidTxHash = redeemClaim.LiquidTxHash
|
||||||
|
|
||||||
|
txCtx := simulation.OperationInput{
|
||||||
|
R: r,
|
||||||
|
App: app,
|
||||||
|
TxGen: simappparams.MakeTestEncodingConfig().TxConfig,
|
||||||
|
Cdc: nil,
|
||||||
|
Msg: msg,
|
||||||
|
MsgType: msg.Type(),
|
||||||
|
Context: ctx,
|
||||||
|
SimAccount: simAccount,
|
||||||
|
ModuleName: types.ModuleName,
|
||||||
|
CoinsSpentInMsg: sdk.NewCoins(),
|
||||||
|
AccountKeeper: ak,
|
||||||
|
Bankkeeper: bk,
|
||||||
|
}
|
||||||
|
return simulation.GenAndDeliverTxWithRandFees(txCtx)
|
||||||
|
}
|
||||||
|
}
|
@ -16,6 +16,9 @@ func RegisterCodec(cdc *codec.LegacyAmino) {
|
|||||||
cdc.RegisterConcrete(&MsgDistributionRequest{}, "dao/DistributionRequest", nil)
|
cdc.RegisterConcrete(&MsgDistributionRequest{}, "dao/DistributionRequest", nil)
|
||||||
cdc.RegisterConcrete(&MsgUpdateParams{}, "dao/UpdateParams", nil)
|
cdc.RegisterConcrete(&MsgUpdateParams{}, "dao/UpdateParams", nil)
|
||||||
cdc.RegisterConcrete(&MsgInitPop{}, "dao/InitPop", nil)
|
cdc.RegisterConcrete(&MsgInitPop{}, "dao/InitPop", nil)
|
||||||
|
cdc.RegisterConcrete(&MsgCreateRedeemClaim{}, "dao/CreateRedeemClaim", nil)
|
||||||
|
cdc.RegisterConcrete(&MsgUpdateRedeemClaim{}, "dao/UpdateRedeemClaim", nil)
|
||||||
|
cdc.RegisterConcrete(&MsgConfirmRedeemClaim{}, "dao/ConfirmRedeemClaim", nil)
|
||||||
// this line is used by starport scaffolding # 2
|
// this line is used by starport scaffolding # 2
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,6 +39,13 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
|
|||||||
registry.RegisterImplementations((*sdk.Msg)(nil),
|
registry.RegisterImplementations((*sdk.Msg)(nil),
|
||||||
&MsgInitPop{},
|
&MsgInitPop{},
|
||||||
)
|
)
|
||||||
|
registry.RegisterImplementations((*sdk.Msg)(nil),
|
||||||
|
&MsgCreateRedeemClaim{},
|
||||||
|
&MsgUpdateRedeemClaim{},
|
||||||
|
)
|
||||||
|
registry.RegisterImplementations((*sdk.Msg)(nil),
|
||||||
|
&MsgConfirmRedeemClaim{},
|
||||||
|
)
|
||||||
// this line is used by starport scaffolding # 3
|
// this line is used by starport scaffolding # 3
|
||||||
|
|
||||||
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
|
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
|
||||||
|
@ -27,4 +27,5 @@ var (
|
|||||||
ErrRestrictedMsg = errorsmod.Register(ModuleName, 18, "restricted validator msg")
|
ErrRestrictedMsg = errorsmod.Register(ModuleName, 18, "restricted validator msg")
|
||||||
ErrDistributionWrongHeight = errorsmod.Register(ModuleName, 19, "distribution wrong height")
|
ErrDistributionWrongHeight = errorsmod.Register(ModuleName, 19, "distribution wrong height")
|
||||||
ErrConvertClaims = errorsmod.Register(ModuleName, 20, "convert claim failed")
|
ErrConvertClaims = errorsmod.Register(ModuleName, 20, "convert claim failed")
|
||||||
|
ErrInvalidClaimAddress = errorsmod.Register(ModuleName, 21, "invalid claim address")
|
||||||
)
|
)
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
import (
|
|
||||||
// this line is used by starport scaffolding # genesis/types/import
|
|
||||||
)
|
|
||||||
|
|
||||||
// DefaultIndex is the default global index
|
// DefaultIndex is the default global index
|
||||||
const DefaultIndex uint64 = 1
|
const DefaultIndex uint64 = 1
|
||||||
|
|
||||||
|
@ -75,19 +75,21 @@ func init() {
|
|||||||
func init() { proto.RegisterFile("planetmintgo/dao/genesis.proto", fileDescriptor_cae3132315bdc9f8) }
|
func init() { proto.RegisterFile("planetmintgo/dao/genesis.proto", fileDescriptor_cae3132315bdc9f8) }
|
||||||
|
|
||||||
var fileDescriptor_cae3132315bdc9f8 = []byte{
|
var fileDescriptor_cae3132315bdc9f8 = []byte{
|
||||||
// 192 bytes of a gzipped FileDescriptorProto
|
// 211 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2b, 0xc8, 0x49, 0xcc,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2b, 0xc8, 0x49, 0xcc,
|
||||||
0x4b, 0x2d, 0xc9, 0xcd, 0xcc, 0x2b, 0x49, 0xcf, 0xd7, 0x4f, 0x49, 0xcc, 0xd7, 0x4f, 0x4f, 0xcd,
|
0x4b, 0x2d, 0xc9, 0xcd, 0xcc, 0x2b, 0x49, 0xcf, 0xd7, 0x4f, 0x49, 0xcc, 0xd7, 0x4f, 0x4f, 0xcd,
|
||||||
0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x40, 0x96, 0xd7, 0x4b,
|
0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x40, 0x96, 0xd7, 0x4b,
|
||||||
0x49, 0xcc, 0x97, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x4b, 0xea, 0x83, 0x58, 0x10, 0x75, 0x52,
|
0x49, 0xcc, 0x97, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x4b, 0xea, 0x83, 0x58, 0x10, 0x75, 0x52,
|
||||||
0xb2, 0x18, 0xe6, 0x14, 0x24, 0x16, 0x25, 0xe6, 0x42, 0x8d, 0x51, 0x72, 0xe3, 0xe2, 0x71, 0x87,
|
0xb2, 0x18, 0xe6, 0x14, 0x24, 0x16, 0x25, 0xe6, 0x42, 0x8d, 0x91, 0x52, 0xc6, 0x90, 0x2e, 0x4a,
|
||||||
0x98, 0x1b, 0x5c, 0x92, 0x58, 0x92, 0x2a, 0x64, 0xc6, 0xc5, 0x06, 0x91, 0x97, 0x60, 0x54, 0x60,
|
0x4d, 0x49, 0x4d, 0xcd, 0x8d, 0x4f, 0xce, 0x49, 0xcc, 0xcc, 0x85, 0x28, 0x52, 0x72, 0xe3, 0xe2,
|
||||||
0xd4, 0xe0, 0x36, 0x92, 0xd0, 0x43, 0xb7, 0x47, 0x2f, 0x00, 0x2c, 0xef, 0xc4, 0x72, 0xe2, 0x9e,
|
0x71, 0x87, 0x58, 0x1e, 0x5c, 0x92, 0x58, 0x92, 0x2a, 0x64, 0xc6, 0xc5, 0x06, 0x31, 0x44, 0x82,
|
||||||
0x3c, 0x43, 0x10, 0x54, 0xb5, 0x93, 0xe7, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e,
|
0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x42, 0x0f, 0xdd, 0x31, 0x7a, 0x01, 0x60, 0x79, 0x27, 0x96,
|
||||||
0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31,
|
0x13, 0xf7, 0xe4, 0x19, 0x82, 0xa0, 0xaa, 0x9d, 0x3c, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48,
|
||||||
0x44, 0xe9, 0xa7, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x23, 0xcc, 0x42,
|
0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1,
|
||||||
0x62, 0xea, 0xa6, 0xe7, 0xeb, 0x57, 0x80, 0x5d, 0x56, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06,
|
0x58, 0x8e, 0x21, 0x4a, 0x3f, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f,
|
||||||
0x76, 0x99, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xa8, 0x23, 0x6c, 0x19, 0x02, 0x01, 0x00, 0x00,
|
0x61, 0x16, 0x12, 0x53, 0x37, 0x3d, 0x5f, 0xbf, 0x02, 0xec, 0xbe, 0x92, 0xca, 0x82, 0xd4, 0xe2,
|
||||||
|
0x24, 0x36, 0xb0, 0xcb, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x88, 0xef, 0x33, 0x4d, 0x27,
|
||||||
|
0x01, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
|
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
|
||||||
|
@ -22,7 +22,6 @@ func TestGenesisState_Validate(t *testing.T) {
|
|||||||
{
|
{
|
||||||
desc: "valid genesis state",
|
desc: "valid genesis state",
|
||||||
genState: &types.GenesisState{
|
genState: &types.GenesisState{
|
||||||
|
|
||||||
// this line is used by starport scaffolding # types/genesis/validField
|
// this line is used by starport scaffolding # types/genesis/validField
|
||||||
},
|
},
|
||||||
valid: true,
|
valid: true,
|
||||||
|
45
x/dao/types/key_redeem_claim.go
Normal file
45
x/dao/types/key_redeem_claim.go
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package types
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/binary"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ binary.ByteOrder
|
||||||
|
|
||||||
|
const (
|
||||||
|
// RedeemClaimKeyPrefix is the prefix to retrieve all RedeemClaim
|
||||||
|
RedeemClaimKeyPrefix = "RedeemClaim/value/"
|
||||||
|
RedeemClaimBeneficiaryCountKeyPrefix = "RedeemClaim/beneficiary/count/"
|
||||||
|
RedeemClaimLiquidTXKeyPrefix = "RedeemClaim/liquidTX/value/"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RedeemClaimKey returns the store key to retrieve a RedeemClaim from the index fields
|
||||||
|
func RedeemClaimKey(
|
||||||
|
beneficiary string,
|
||||||
|
id uint64,
|
||||||
|
) []byte {
|
||||||
|
var key []byte
|
||||||
|
|
||||||
|
beneficiaryBytes := []byte(beneficiary)
|
||||||
|
key = append(key, beneficiaryBytes...)
|
||||||
|
key = append(key, []byte("/")...)
|
||||||
|
|
||||||
|
idBytes := SerializeUint64(id)
|
||||||
|
key = append(key, idBytes...)
|
||||||
|
key = append(key, []byte("/")...)
|
||||||
|
|
||||||
|
return key
|
||||||
|
}
|
||||||
|
|
||||||
|
func SerializeUint64(value uint64) []byte {
|
||||||
|
buf := make([]byte, 8)
|
||||||
|
// Adding 1 because 0 will be interpreted as nil, which is an invalid key
|
||||||
|
binary.BigEndian.PutUint64(buf, value+1)
|
||||||
|
return buf
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeserializeUint64(value []byte) uint64 {
|
||||||
|
integer := binary.BigEndian.Uint64(value)
|
||||||
|
// Subtract 1 because addition in serialization
|
||||||
|
return integer - 1
|
||||||
|
}
|
142
x/dao/types/messages_redeem_claim.go
Normal file
142
x/dao/types/messages_redeem_claim.go
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
package types
|
||||||
|
|
||||||
|
import (
|
||||||
|
errorsmod "cosmossdk.io/errors"
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
TypeMsgCreateRedeemClaim = "create_redeem_claim"
|
||||||
|
TypeMsgUpdateRedeemClaim = "update_redeem_claim"
|
||||||
|
TypeMsgConfirmRedeemClaim = "confirm_redeem_claim"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ sdk.Msg = &MsgCreateRedeemClaim{}
|
||||||
|
|
||||||
|
func NewMsgCreateRedeemClaim(
|
||||||
|
creator string,
|
||||||
|
beneficiary string,
|
||||||
|
amount uint64,
|
||||||
|
|
||||||
|
) *MsgCreateRedeemClaim {
|
||||||
|
return &MsgCreateRedeemClaim{
|
||||||
|
Creator: creator,
|
||||||
|
Beneficiary: beneficiary,
|
||||||
|
Amount: amount,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msg *MsgCreateRedeemClaim) Route() string {
|
||||||
|
return RouterKey
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msg *MsgCreateRedeemClaim) Type() string {
|
||||||
|
return TypeMsgCreateRedeemClaim
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msg *MsgCreateRedeemClaim) GetSigners() []sdk.AccAddress {
|
||||||
|
creator, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return []sdk.AccAddress{creator}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msg *MsgCreateRedeemClaim) GetSignBytes() []byte {
|
||||||
|
bz := ModuleCdc.MustMarshalJSON(msg)
|
||||||
|
return sdk.MustSortJSON(bz)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msg *MsgCreateRedeemClaim) ValidateBasic() error {
|
||||||
|
_, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||||
|
if err != nil {
|
||||||
|
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ sdk.Msg = &MsgUpdateRedeemClaim{}
|
||||||
|
|
||||||
|
func NewMsgUpdateRedeemClaim(
|
||||||
|
creator string,
|
||||||
|
beneficiary string,
|
||||||
|
liquidTxHash string,
|
||||||
|
id uint64,
|
||||||
|
|
||||||
|
) *MsgUpdateRedeemClaim {
|
||||||
|
return &MsgUpdateRedeemClaim{
|
||||||
|
Creator: creator,
|
||||||
|
Beneficiary: beneficiary,
|
||||||
|
LiquidTxHash: liquidTxHash,
|
||||||
|
Id: id,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msg *MsgUpdateRedeemClaim) Route() string {
|
||||||
|
return RouterKey
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msg *MsgUpdateRedeemClaim) Type() string {
|
||||||
|
return TypeMsgUpdateRedeemClaim
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msg *MsgUpdateRedeemClaim) GetSigners() []sdk.AccAddress {
|
||||||
|
creator, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return []sdk.AccAddress{creator}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msg *MsgUpdateRedeemClaim) GetSignBytes() []byte {
|
||||||
|
bz := ModuleCdc.MustMarshalJSON(msg)
|
||||||
|
return sdk.MustSortJSON(bz)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msg *MsgUpdateRedeemClaim) ValidateBasic() error {
|
||||||
|
_, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||||
|
if err != nil {
|
||||||
|
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ sdk.Msg = &MsgConfirmRedeemClaim{}
|
||||||
|
|
||||||
|
func NewMsgConfirmRedeemClaim(creator string, id uint64, beneficiary string) *MsgConfirmRedeemClaim {
|
||||||
|
return &MsgConfirmRedeemClaim{
|
||||||
|
Creator: creator,
|
||||||
|
Id: id,
|
||||||
|
Beneficiary: beneficiary,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msg *MsgConfirmRedeemClaim) Route() string {
|
||||||
|
return RouterKey
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msg *MsgConfirmRedeemClaim) Type() string {
|
||||||
|
return TypeMsgConfirmRedeemClaim
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msg *MsgConfirmRedeemClaim) GetSigners() []sdk.AccAddress {
|
||||||
|
creator, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return []sdk.AccAddress{creator}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msg *MsgConfirmRedeemClaim) GetSignBytes() []byte {
|
||||||
|
bz := ModuleCdc.MustMarshalJSON(msg)
|
||||||
|
return sdk.MustSortJSON(bz)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msg *MsgConfirmRedeemClaim) ValidateBasic() error {
|
||||||
|
_, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||||
|
if err != nil {
|
||||||
|
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
95
x/dao/types/messages_redeem_claim_test.go
Normal file
95
x/dao/types/messages_redeem_claim_test.go
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
package types
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestMsgCreateRedeemClaim_ValidateBasic(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
msg MsgCreateRedeemClaim
|
||||||
|
err error
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "invalid address",
|
||||||
|
msg: MsgCreateRedeemClaim{
|
||||||
|
Creator: "invalid_address",
|
||||||
|
},
|
||||||
|
err: sdkerrors.ErrInvalidAddress,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
tt := tt
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
err := tt.msg.ValidateBasic()
|
||||||
|
if tt.err != nil {
|
||||||
|
require.ErrorIs(t, err, tt.err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
require.NoError(t, err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMsgUpdateRedeemClaim_ValidateBasic(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
msg MsgUpdateRedeemClaim
|
||||||
|
err error
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "invalid address",
|
||||||
|
msg: MsgUpdateRedeemClaim{
|
||||||
|
Creator: "invalid_address",
|
||||||
|
},
|
||||||
|
err: sdkerrors.ErrInvalidAddress,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
tt := tt
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
err := tt.msg.ValidateBasic()
|
||||||
|
if tt.err != nil {
|
||||||
|
require.ErrorIs(t, err, tt.err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
require.NoError(t, err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMsgConfirmRedeemClaim_ValidateBasic(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
msg MsgConfirmRedeemClaim
|
||||||
|
err error
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "invalid address",
|
||||||
|
msg: MsgConfirmRedeemClaim{
|
||||||
|
Creator: "invalid_address",
|
||||||
|
},
|
||||||
|
err: sdkerrors.ErrInvalidAddress,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
tt := tt
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
err := tt.msg.ValidateBasic()
|
||||||
|
if tt.err != nil {
|
||||||
|
require.ErrorIs(t, err, tt.err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
require.NoError(t, err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
@ -17,7 +17,7 @@ func NewParams(mintAddress string, tokenDenom string, feeDenom string, stagedDen
|
|||||||
claimDenom string, reissuanceAsset string, reissuanceEpochs int64, popEpochs int64,
|
claimDenom string, reissuanceAsset string, reissuanceEpochs int64, popEpochs int64,
|
||||||
distributionOffset int64, distributionAddressEarlyInv string, distributionAddressInvestor string,
|
distributionOffset int64, distributionAddressEarlyInv string, distributionAddressInvestor string,
|
||||||
distributionAddressStrategic string, distributionAddressDao string, distributionAddressPop string,
|
distributionAddressStrategic string, distributionAddressDao string, distributionAddressPop string,
|
||||||
mqttResponseTimeout int64) Params {
|
mqttResponseTimeout int64, claimAddress string) Params {
|
||||||
return Params{
|
return Params{
|
||||||
MintAddress: mintAddress,
|
MintAddress: mintAddress,
|
||||||
TokenDenom: tokenDenom,
|
TokenDenom: tokenDenom,
|
||||||
@ -41,6 +41,7 @@ func NewParams(mintAddress string, tokenDenom string, feeDenom string, stagedDen
|
|||||||
DistributionAddressDao: distributionAddressDao,
|
DistributionAddressDao: distributionAddressDao,
|
||||||
DistributionAddressPop: distributionAddressPop,
|
DistributionAddressPop: distributionAddressPop,
|
||||||
MqttResponseTimeout: mqttResponseTimeout,
|
MqttResponseTimeout: mqttResponseTimeout,
|
||||||
|
ClaimAddress: claimAddress,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +62,8 @@ func DefaultParams() Params {
|
|||||||
"vjTyRN2G42Yq3T5TJBecHj1dF1xdhKF89hKV4HJN3uXxUbaVGVR76hAfVRQqQCovWaEpar7G5qBBprFG",
|
"vjTyRN2G42Yq3T5TJBecHj1dF1xdhKF89hKV4HJN3uXxUbaVGVR76hAfVRQqQCovWaEpar7G5qBBprFG",
|
||||||
"vjU8eMzU3JbUWZEpVANt2ePJuPWSPixgjiSj2jDMvkVVQQi2DDnZuBRVX4Ygt5YGBf5zvTWCr1ntdqYH",
|
"vjU8eMzU3JbUWZEpVANt2ePJuPWSPixgjiSj2jDMvkVVQQi2DDnZuBRVX4Ygt5YGBf5zvTWCr1ntdqYH",
|
||||||
"vjTvXCFSReRsZ7grdsAreRR12KuKpDw8idueQJK9Yh1BYS7ggAqgvCxCgwh13KGK6M52y37HUmvr4GdD",
|
"vjTvXCFSReRsZ7grdsAreRR12KuKpDw8idueQJK9Yh1BYS7ggAqgvCxCgwh13KGK6M52y37HUmvr4GdD",
|
||||||
2000)
|
2000,
|
||||||
|
"plmnt1dyuhg8ldu3d6nvhrvzzemtc3893dys9v9lvdty")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParamSetPairs get the params.ParamSet
|
// ParamSetPairs get the params.ParamSet
|
||||||
|
@ -40,6 +40,7 @@ type Params struct {
|
|||||||
DistributionAddressDao string `protobuf:"bytes,13,opt,name=distribution_address_dao,json=distributionAddressDao,proto3" json:"distribution_address_dao,omitempty"`
|
DistributionAddressDao string `protobuf:"bytes,13,opt,name=distribution_address_dao,json=distributionAddressDao,proto3" json:"distribution_address_dao,omitempty"`
|
||||||
DistributionAddressPop string `protobuf:"bytes,14,opt,name=distribution_address_pop,json=distributionAddressPop,proto3" json:"distribution_address_pop,omitempty"`
|
DistributionAddressPop string `protobuf:"bytes,14,opt,name=distribution_address_pop,json=distributionAddressPop,proto3" json:"distribution_address_pop,omitempty"`
|
||||||
MqttResponseTimeout int64 `protobuf:"varint,15,opt,name=mqtt_response_timeout,json=mqttResponseTimeout,proto3" json:"mqtt_response_timeout,omitempty"`
|
MqttResponseTimeout int64 `protobuf:"varint,15,opt,name=mqtt_response_timeout,json=mqttResponseTimeout,proto3" json:"mqtt_response_timeout,omitempty"`
|
||||||
|
ClaimAddress string `protobuf:"bytes,16,opt,name=claim_address,json=claimAddress,proto3" json:"claim_address,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Params) Reset() { *m = Params{} }
|
func (m *Params) Reset() { *m = Params{} }
|
||||||
@ -179,6 +180,13 @@ func (m *Params) GetMqttResponseTimeout() int64 {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Params) GetClaimAddress() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.ClaimAddress
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
proto.RegisterType((*Params)(nil), "planetmintgo.dao.Params")
|
proto.RegisterType((*Params)(nil), "planetmintgo.dao.Params")
|
||||||
}
|
}
|
||||||
@ -186,37 +194,38 @@ func init() {
|
|||||||
func init() { proto.RegisterFile("planetmintgo/dao/params.proto", fileDescriptor_a58575036b3ad531) }
|
func init() { proto.RegisterFile("planetmintgo/dao/params.proto", fileDescriptor_a58575036b3ad531) }
|
||||||
|
|
||||||
var fileDescriptor_a58575036b3ad531 = []byte{
|
var fileDescriptor_a58575036b3ad531 = []byte{
|
||||||
// 466 bytes of a gzipped FileDescriptorProto
|
// 483 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x93, 0x31, 0x6f, 0x13, 0x31,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x93, 0xb1, 0x6e, 0x13, 0x4d,
|
||||||
0x14, 0xc7, 0x73, 0xb4, 0x0d, 0xcd, 0x4b, 0xa0, 0xc5, 0x05, 0x64, 0x51, 0x72, 0x69, 0x99, 0x8a,
|
0x14, 0x85, 0xbd, 0x7f, 0x12, 0xff, 0xf1, 0xd8, 0x21, 0x66, 0x02, 0x68, 0x44, 0xf0, 0x3a, 0x81,
|
||||||
0x10, 0x39, 0x09, 0x16, 0xc4, 0xd6, 0x92, 0x0e, 0x99, 0xa8, 0x02, 0x13, 0xcb, 0xc9, 0xc9, 0xbd,
|
0x26, 0x08, 0xe1, 0x95, 0xa0, 0x41, 0x74, 0x09, 0x4e, 0xe1, 0x8a, 0xc8, 0x50, 0xd1, 0xac, 0xc6,
|
||||||
0x5c, 0x2d, 0x72, 0x7e, 0xc6, 0x76, 0x22, 0xfa, 0x2d, 0x18, 0x19, 0xf9, 0x38, 0x8c, 0x15, 0x13,
|
0xbb, 0xd7, 0x9b, 0x11, 0xde, 0xb9, 0xc3, 0xce, 0xd8, 0x22, 0x6f, 0x41, 0x49, 0xc9, 0xe3, 0x50,
|
||||||
0x23, 0x4a, 0xbe, 0x08, 0x3a, 0xfb, 0xaa, 0x5e, 0xa5, 0x64, 0xb3, 0xfe, 0xbf, 0xdf, 0xfb, 0xdb,
|
0xa6, 0xa4, 0x44, 0xf6, 0x43, 0xd0, 0xa2, 0xbd, 0xb3, 0x56, 0x16, 0xc9, 0xee, 0x46, 0xe7, 0x7c,
|
||||||
0xb2, 0xf4, 0xa0, 0xab, 0x67, 0x42, 0xa1, 0x2b, 0xa4, 0x72, 0x39, 0x25, 0x99, 0xa0, 0x44, 0x0b,
|
0xe7, 0xdc, 0xd1, 0x68, 0x2e, 0xeb, 0x99, 0x99, 0xd4, 0xe0, 0x72, 0xa5, 0x5d, 0x86, 0x51, 0x2a,
|
||||||
0x23, 0x0a, 0xdb, 0xd7, 0x86, 0x1c, 0xb1, 0xfd, 0x3a, 0xee, 0x67, 0x82, 0x9e, 0x3d, 0xce, 0x29,
|
0x31, 0x32, 0xb2, 0x90, 0xb9, 0x1d, 0x98, 0x02, 0x1d, 0xf2, 0x6e, 0xdd, 0x1e, 0xa4, 0x12, 0x1f,
|
||||||
0x27, 0x0f, 0x93, 0xf2, 0x14, 0xbc, 0x17, 0x7f, 0x76, 0xa0, 0x79, 0xe1, 0x07, 0xd9, 0x31, 0x74,
|
0x3f, 0xc8, 0x30, 0x43, 0x32, 0xa3, 0xf2, 0xe4, 0xb9, 0xa7, 0x7f, 0xf6, 0x58, 0xf3, 0x8a, 0x82,
|
||||||
0x4a, 0x3d, 0x15, 0x59, 0x66, 0xd0, 0x5a, 0x1e, 0x1d, 0x45, 0x27, 0xad, 0x51, 0xbb, 0xcc, 0x4e,
|
0xfc, 0x94, 0x75, 0x4a, 0x3c, 0x96, 0x69, 0x5a, 0x80, 0xb5, 0x22, 0x38, 0x09, 0xce, 0x5a, 0xe3,
|
||||||
0x43, 0xc4, 0x7a, 0xd0, 0x76, 0xf4, 0x15, 0x55, 0x9a, 0xa1, 0xa2, 0x82, 0xdf, 0xf3, 0x06, 0xf8,
|
0x76, 0xa9, 0x9d, 0x7b, 0x89, 0xf7, 0x59, 0xdb, 0xe1, 0x67, 0xd0, 0x71, 0x0a, 0x1a, 0x73, 0xf1,
|
||||||
0x68, 0x50, 0x26, 0xec, 0x10, 0x5a, 0x53, 0xc4, 0x0a, 0x6f, 0x79, 0xbc, 0x3b, 0x45, 0x0c, 0xf0,
|
0x1f, 0x11, 0x8c, 0xa4, 0x61, 0xa9, 0xf0, 0x63, 0xd6, 0x9a, 0x02, 0x54, 0xf6, 0x0e, 0xd9, 0xfb,
|
||||||
0x18, 0x3a, 0xd6, 0x89, 0x1c, 0xb3, 0x8a, 0x6f, 0x87, 0x0b, 0x42, 0x16, 0x94, 0x1e, 0xb4, 0x27,
|
0x53, 0x00, 0x6f, 0x9e, 0xb2, 0x8e, 0x75, 0x32, 0x83, 0xb4, 0xf2, 0x77, 0xfd, 0x00, 0xaf, 0x79,
|
||||||
0x33, 0x21, 0x8b, 0xca, 0xd8, 0x09, 0x17, 0xf8, 0x28, 0x08, 0x2f, 0x61, 0xdf, 0xa0, 0xb4, 0x76,
|
0xa4, 0xcf, 0xda, 0xc9, 0x4c, 0xaa, 0xbc, 0x22, 0xf6, 0xfc, 0x00, 0x92, 0x3c, 0xf0, 0x9c, 0x75,
|
||||||
0x2e, 0xd4, 0x04, 0x53, 0x61, 0x2d, 0x3a, 0xde, 0xf4, 0xd6, 0xde, 0x6d, 0x7e, 0x5a, 0xc6, 0xec,
|
0x0b, 0x50, 0xd6, 0xce, 0xa5, 0x4e, 0x20, 0x96, 0xd6, 0x82, 0x13, 0x4d, 0xa2, 0x0e, 0xef, 0xf4,
|
||||||
0x15, 0x3c, 0xaa, 0xa9, 0xa8, 0x69, 0x72, 0x69, 0xf9, 0xfd, 0xa3, 0xe8, 0x64, 0x6b, 0x54, 0xeb,
|
0xf3, 0x52, 0xe6, 0x2f, 0xd8, 0xfd, 0x1a, 0x0a, 0x06, 0x93, 0x6b, 0x2b, 0xfe, 0x3f, 0x09, 0xce,
|
||||||
0x38, 0xf7, 0x39, 0xeb, 0x02, 0x68, 0xd2, 0x37, 0xd6, 0xae, 0xb7, 0x5a, 0x9a, 0x74, 0x85, 0x13,
|
0x76, 0xc6, 0xb5, 0x8e, 0x4b, 0xd2, 0x79, 0x8f, 0x31, 0x83, 0x66, 0x4d, 0xed, 0x13, 0xd5, 0x32,
|
||||||
0x38, 0xc8, 0xa4, 0x75, 0x46, 0x8e, 0xe7, 0x4e, 0x92, 0x4a, 0x69, 0x3a, 0x2d, 0x6f, 0x6e, 0x79,
|
0x68, 0x2a, 0x3b, 0x62, 0x47, 0xa9, 0xb2, 0xae, 0x50, 0x93, 0xb9, 0x53, 0xa8, 0x63, 0x9c, 0x4e,
|
||||||
0x8f, 0xd5, 0xd1, 0x47, 0x4f, 0xd8, 0x07, 0x88, 0xef, 0x0c, 0x54, 0x9f, 0x9a, 0xa2, 0x30, 0xb3,
|
0xcb, 0xc9, 0x2d, 0xe2, 0x78, 0xdd, 0x7a, 0x4f, 0x0e, 0x7f, 0xc7, 0xc2, 0x7f, 0x02, 0xd5, 0xa3,
|
||||||
0xab, 0x54, 0xaa, 0x05, 0x07, 0xff, 0xea, 0xc3, 0xba, 0x55, 0x7d, 0xf3, 0x79, 0xe9, 0x0c, 0xd5,
|
0xc6, 0x20, 0x8b, 0xd9, 0x4d, 0xac, 0xf4, 0x42, 0x30, 0xba, 0xf5, 0x71, 0x9d, 0xaa, 0x9e, 0xf9,
|
||||||
0x82, 0x9d, 0x41, 0x77, 0x6d, 0x89, 0x54, 0x0b, 0xb4, 0x8e, 0x0c, 0x6f, 0x6f, 0xec, 0x18, 0x56,
|
0xb2, 0x64, 0x46, 0x7a, 0xc1, 0x2f, 0x58, 0x6f, 0x63, 0x89, 0xd2, 0x0b, 0xb0, 0x0e, 0x0b, 0xd1,
|
||||||
0x0a, 0x1b, 0x6c, 0x78, 0x88, 0x75, 0x46, 0x38, 0xcc, 0xe5, 0x84, 0x77, 0x7c, 0xc9, 0xf3, 0x35,
|
0xde, 0xda, 0x31, 0xaa, 0x10, 0x3e, 0xdc, 0x72, 0x11, 0xeb, 0x0a, 0xe9, 0x20, 0x53, 0x89, 0xe8,
|
||||||
0x25, 0x9f, 0x6e, 0x1c, 0xf6, 0x0e, 0xf8, 0xda, 0x96, 0x4c, 0x10, 0x7f, 0xe0, 0xe7, 0x9f, 0xae,
|
0x50, 0xc9, 0x93, 0x0d, 0x25, 0x1f, 0xd6, 0x0c, 0x7f, 0xc3, 0xc4, 0xc6, 0x96, 0x54, 0xa2, 0x38,
|
||||||
0x99, 0x1f, 0x08, 0xda, 0x38, 0xa9, 0x49, 0xf3, 0x87, 0x1b, 0x27, 0x2f, 0x48, 0xb3, 0x37, 0xf0,
|
0xa0, 0xfc, 0xa3, 0x0d, 0xf9, 0xa1, 0xc4, 0xad, 0x49, 0x83, 0x46, 0xdc, 0xdb, 0x9a, 0xbc, 0x42,
|
||||||
0xa4, 0xf8, 0xe6, 0x5c, 0x6a, 0xd0, 0x6a, 0x52, 0x16, 0x53, 0x27, 0x0b, 0xa4, 0xb9, 0xe3, 0x7b,
|
0xc3, 0x5f, 0xb1, 0x87, 0xf9, 0x17, 0xe7, 0xe2, 0x02, 0xac, 0x41, 0x6d, 0x21, 0x76, 0x2a, 0x07,
|
||||||
0xfe, 0xd7, 0x0f, 0x4a, 0x38, 0xaa, 0xd8, 0xe7, 0x80, 0xde, 0x6f, 0xff, 0xfc, 0xd5, 0x6b, 0x9c,
|
0x9c, 0x3b, 0x71, 0x48, 0xaf, 0x7e, 0x54, 0x9a, 0xe3, 0xca, 0xfb, 0xe8, 0x2d, 0xfe, 0x8c, 0x1d,
|
||||||
0x0d, 0x7f, 0x2f, 0xe3, 0xe8, 0x7a, 0x19, 0x47, 0xff, 0x96, 0x71, 0xf4, 0x63, 0x15, 0x37, 0xae,
|
0xf8, 0xff, 0xb3, 0xfe, 0xc4, 0x5d, 0x1a, 0xd1, 0x21, 0xb1, 0xea, 0x7e, 0xbb, 0xfb, 0xfd, 0x47,
|
||||||
0x57, 0x71, 0xe3, 0xef, 0x2a, 0x6e, 0x7c, 0x49, 0x72, 0xe9, 0x2e, 0xe7, 0xe3, 0xfe, 0x84, 0x8a,
|
0xbf, 0x71, 0x31, 0xfa, 0xb9, 0x0c, 0x83, 0xdb, 0x65, 0x18, 0xfc, 0x5e, 0x86, 0xc1, 0xb7, 0x55,
|
||||||
0xe4, 0x76, 0x43, 0x6a, 0xc7, 0xd7, 0x39, 0x25, 0xdf, 0xfd, 0x3a, 0xb9, 0x2b, 0x8d, 0x76, 0xdc,
|
0xd8, 0xb8, 0x5d, 0x85, 0x8d, 0x5f, 0xab, 0xb0, 0xf1, 0x29, 0xca, 0x94, 0xbb, 0x9e, 0x4f, 0x06,
|
||||||
0xf4, 0x6b, 0xf2, 0xf6, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x69, 0x6a, 0x2e, 0x26, 0x6f, 0x03,
|
0x09, 0xe6, 0xd1, 0xdd, 0x1a, 0xd5, 0x8e, 0x2f, 0x33, 0x8c, 0xbe, 0xd2, 0xce, 0xb9, 0x1b, 0x03,
|
||||||
0x00, 0x00,
|
0x76, 0xd2, 0xa4, 0x5d, 0x7a, 0xfd, 0x37, 0x00, 0x00, 0xff, 0xff, 0x28, 0xe9, 0x84, 0xf9, 0x94,
|
||||||
|
0x03, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Params) Marshal() (dAtA []byte, err error) {
|
func (m *Params) Marshal() (dAtA []byte, err error) {
|
||||||
@ -239,6 +248,15 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||||||
_ = i
|
_ = i
|
||||||
var l int
|
var l int
|
||||||
_ = l
|
_ = l
|
||||||
|
if len(m.ClaimAddress) > 0 {
|
||||||
|
i -= len(m.ClaimAddress)
|
||||||
|
copy(dAtA[i:], m.ClaimAddress)
|
||||||
|
i = encodeVarintParams(dAtA, i, uint64(len(m.ClaimAddress)))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x1
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x82
|
||||||
|
}
|
||||||
if m.MqttResponseTimeout != 0 {
|
if m.MqttResponseTimeout != 0 {
|
||||||
i = encodeVarintParams(dAtA, i, uint64(m.MqttResponseTimeout))
|
i = encodeVarintParams(dAtA, i, uint64(m.MqttResponseTimeout))
|
||||||
i--
|
i--
|
||||||
@ -412,6 +430,10 @@ func (m *Params) Size() (n int) {
|
|||||||
if m.MqttResponseTimeout != 0 {
|
if m.MqttResponseTimeout != 0 {
|
||||||
n += 1 + sovParams(uint64(m.MqttResponseTimeout))
|
n += 1 + sovParams(uint64(m.MqttResponseTimeout))
|
||||||
}
|
}
|
||||||
|
l = len(m.ClaimAddress)
|
||||||
|
if l > 0 {
|
||||||
|
n += 2 + l + sovParams(uint64(l))
|
||||||
|
}
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -878,6 +900,38 @@ func (m *Params) Unmarshal(dAtA []byte) error {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case 16:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field ClaimAddress", wireType)
|
||||||
|
}
|
||||||
|
var stringLen uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowParams
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
stringLen |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
intStringLen := int(stringLen)
|
||||||
|
if intStringLen < 0 {
|
||||||
|
return ErrInvalidLengthParams
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + intStringLen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthParams
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m.ClaimAddress = string(dAtA[iNdEx:postIndex])
|
||||||
|
iNdEx = postIndex
|
||||||
default:
|
default:
|
||||||
iNdEx = preIndex
|
iNdEx = preIndex
|
||||||
skippy, err := skipParams(dAtA[iNdEx:])
|
skippy, err := skipParams(dAtA[iNdEx:])
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -393,6 +393,172 @@ func local_request_Query_GetDistribution_0(ctx context.Context, marshaler runtim
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func request_Query_RedeemClaim_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq QueryGetRedeemClaimRequest
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
var (
|
||||||
|
val string
|
||||||
|
ok bool
|
||||||
|
err error
|
||||||
|
_ = err
|
||||||
|
)
|
||||||
|
|
||||||
|
val, ok = pathParams["beneficiary"]
|
||||||
|
if !ok {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "beneficiary")
|
||||||
|
}
|
||||||
|
|
||||||
|
protoReq.Beneficiary, err = runtime.String(val)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "beneficiary", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
val, ok = pathParams["id"]
|
||||||
|
if !ok {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
|
||||||
|
}
|
||||||
|
|
||||||
|
protoReq.Id, err = runtime.Uint64(val)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := client.RedeemClaim(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func local_request_Query_RedeemClaim_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq QueryGetRedeemClaimRequest
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
var (
|
||||||
|
val string
|
||||||
|
ok bool
|
||||||
|
err error
|
||||||
|
_ = err
|
||||||
|
)
|
||||||
|
|
||||||
|
val, ok = pathParams["beneficiary"]
|
||||||
|
if !ok {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "beneficiary")
|
||||||
|
}
|
||||||
|
|
||||||
|
protoReq.Beneficiary, err = runtime.String(val)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "beneficiary", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
val, ok = pathParams["id"]
|
||||||
|
if !ok {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
|
||||||
|
}
|
||||||
|
|
||||||
|
protoReq.Id, err = runtime.Uint64(val)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := server.RedeemClaim(ctx, &protoReq)
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
filter_Query_RedeemClaimAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||||
|
)
|
||||||
|
|
||||||
|
func request_Query_RedeemClaimAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq QueryAllRedeemClaimRequest
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
if err := req.ParseForm(); err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RedeemClaimAll_0); err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := client.RedeemClaimAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func local_request_Query_RedeemClaimAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq QueryAllRedeemClaimRequest
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
if err := req.ParseForm(); err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RedeemClaimAll_0); err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := server.RedeemClaimAll(ctx, &protoReq)
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func request_Query_RedeemClaimByLiquidTxHash_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq QueryRedeemClaimByLiquidTxHashRequest
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
var (
|
||||||
|
val string
|
||||||
|
ok bool
|
||||||
|
err error
|
||||||
|
_ = err
|
||||||
|
)
|
||||||
|
|
||||||
|
val, ok = pathParams["liquidTxHash"]
|
||||||
|
if !ok {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "liquidTxHash")
|
||||||
|
}
|
||||||
|
|
||||||
|
protoReq.LiquidTxHash, err = runtime.String(val)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "liquidTxHash", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := client.RedeemClaimByLiquidTxHash(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func local_request_Query_RedeemClaimByLiquidTxHash_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq QueryRedeemClaimByLiquidTxHashRequest
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
var (
|
||||||
|
val string
|
||||||
|
ok bool
|
||||||
|
err error
|
||||||
|
_ = err
|
||||||
|
)
|
||||||
|
|
||||||
|
val, ok = pathParams["liquidTxHash"]
|
||||||
|
if !ok {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "liquidTxHash")
|
||||||
|
}
|
||||||
|
|
||||||
|
protoReq.LiquidTxHash, err = runtime.String(val)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "liquidTxHash", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := server.RedeemClaimByLiquidTxHash(ctx, &protoReq)
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
|
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
|
||||||
// UnaryRPC :call QueryServer directly.
|
// UnaryRPC :call QueryServer directly.
|
||||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||||
@ -583,6 +749,75 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
mux.Handle("GET", pattern_Query_RedeemClaim_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
var stream runtime.ServerTransportStream
|
||||||
|
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := local_request_Query_RedeemClaim_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||||
|
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||||
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_Query_RedeemClaim_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
mux.Handle("GET", pattern_Query_RedeemClaimAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
var stream runtime.ServerTransportStream
|
||||||
|
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := local_request_Query_RedeemClaimAll_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||||
|
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||||
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_Query_RedeemClaimAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
mux.Handle("GET", pattern_Query_RedeemClaimByLiquidTxHash_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
var stream runtime.ServerTransportStream
|
||||||
|
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := local_request_Query_RedeemClaimByLiquidTxHash_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||||
|
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||||
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_Query_RedeemClaimByLiquidTxHash_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -784,6 +1019,66 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
mux.Handle("GET", pattern_Query_RedeemClaim_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := request_Query_RedeemClaim_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||||
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_Query_RedeemClaim_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
mux.Handle("GET", pattern_Query_RedeemClaimAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := request_Query_RedeemClaimAll_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||||
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_Query_RedeemClaimAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
mux.Handle("GET", pattern_Query_RedeemClaimByLiquidTxHash_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := request_Query_RedeemClaimByLiquidTxHash_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||||
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_Query_RedeemClaimByLiquidTxHash_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -803,6 +1098,12 @@ var (
|
|||||||
pattern_Query_Challenges_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"planetmint", "dao", "challenges"}, "", runtime.AssumeColonVerbOpt(true)))
|
pattern_Query_Challenges_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"planetmint", "dao", "challenges"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||||
|
|
||||||
pattern_Query_GetDistribution_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"planetmint", "dao", "distribution", "height"}, "", runtime.AssumeColonVerbOpt(true)))
|
pattern_Query_GetDistribution_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"planetmint", "dao", "distribution", "height"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||||
|
|
||||||
|
pattern_Query_RedeemClaim_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"planetmint", "dao", "redeem_claim", "beneficiary", "id"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||||
|
|
||||||
|
pattern_Query_RedeemClaimAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"planetmint", "dao", "redeem_claim"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||||
|
|
||||||
|
pattern_Query_RedeemClaimByLiquidTxHash_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"planetmint", "dao", "redeem_claim_by_liquid_tx_hash", "liquidTxHash"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -821,4 +1122,10 @@ var (
|
|||||||
forward_Query_Challenges_0 = runtime.ForwardResponseMessage
|
forward_Query_Challenges_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
forward_Query_GetDistribution_0 = runtime.ForwardResponseMessage
|
forward_Query_GetDistribution_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
|
forward_Query_RedeemClaim_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
|
forward_Query_RedeemClaimAll_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
|
forward_Query_RedeemClaimByLiquidTxHash_0 = runtime.ForwardResponseMessage
|
||||||
)
|
)
|
||||||
|
535
x/dao/types/redeem_claim.pb.go
Normal file
535
x/dao/types/redeem_claim.pb.go
Normal file
@ -0,0 +1,535 @@
|
|||||||
|
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||||
|
// source: planetmintgo/dao/redeem_claim.proto
|
||||||
|
|
||||||
|
package types
|
||||||
|
|
||||||
|
import (
|
||||||
|
fmt "fmt"
|
||||||
|
proto "github.com/cosmos/gogoproto/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
|
||||||
|
|
||||||
|
type RedeemClaim struct {
|
||||||
|
Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||||
|
Beneficiary string `protobuf:"bytes,2,opt,name=beneficiary,proto3" json:"beneficiary,omitempty"`
|
||||||
|
LiquidTxHash string `protobuf:"bytes,3,opt,name=liquidTxHash,proto3" json:"liquidTxHash,omitempty"`
|
||||||
|
Amount uint64 `protobuf:"varint,4,opt,name=amount,proto3" json:"amount,omitempty"`
|
||||||
|
Confirmed bool `protobuf:"varint,5,opt,name=confirmed,proto3" json:"confirmed,omitempty"`
|
||||||
|
Creator string `protobuf:"bytes,6,opt,name=creator,proto3" json:"creator,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *RedeemClaim) Reset() { *m = RedeemClaim{} }
|
||||||
|
func (m *RedeemClaim) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*RedeemClaim) ProtoMessage() {}
|
||||||
|
func (*RedeemClaim) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_57a8f72ea08c516f, []int{0}
|
||||||
|
}
|
||||||
|
func (m *RedeemClaim) XXX_Unmarshal(b []byte) error {
|
||||||
|
return m.Unmarshal(b)
|
||||||
|
}
|
||||||
|
func (m *RedeemClaim) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
if deterministic {
|
||||||
|
return xxx_messageInfo_RedeemClaim.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 *RedeemClaim) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_RedeemClaim.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *RedeemClaim) XXX_Size() int {
|
||||||
|
return m.Size()
|
||||||
|
}
|
||||||
|
func (m *RedeemClaim) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_RedeemClaim.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_RedeemClaim proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *RedeemClaim) GetId() uint64 {
|
||||||
|
if m != nil {
|
||||||
|
return m.Id
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *RedeemClaim) GetBeneficiary() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.Beneficiary
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *RedeemClaim) GetLiquidTxHash() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.LiquidTxHash
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *RedeemClaim) GetAmount() uint64 {
|
||||||
|
if m != nil {
|
||||||
|
return m.Amount
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *RedeemClaim) GetConfirmed() bool {
|
||||||
|
if m != nil {
|
||||||
|
return m.Confirmed
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *RedeemClaim) GetCreator() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.Creator
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
proto.RegisterType((*RedeemClaim)(nil), "planetmintgo.dao.RedeemClaim")
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
proto.RegisterFile("planetmintgo/dao/redeem_claim.proto", fileDescriptor_57a8f72ea08c516f)
|
||||||
|
}
|
||||||
|
|
||||||
|
var fileDescriptor_57a8f72ea08c516f = []byte{
|
||||||
|
// 256 bytes of a gzipped FileDescriptorProto
|
||||||
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x90, 0x31, 0x4e, 0xc3, 0x30,
|
||||||
|
0x14, 0x86, 0xe3, 0x50, 0x02, 0x75, 0x11, 0x42, 0x1e, 0x90, 0x07, 0x64, 0x45, 0x65, 0xc9, 0x42,
|
||||||
|
0x32, 0x70, 0x03, 0x58, 0x60, 0x8d, 0x98, 0x58, 0x90, 0x13, 0xbb, 0xe9, 0x93, 0x62, 0xbf, 0xe0,
|
||||||
|
0x3a, 0x52, 0x7b, 0x0b, 0xee, 0xc2, 0x25, 0x18, 0x3b, 0x32, 0xa2, 0xe4, 0x22, 0x08, 0x0b, 0xd4,
|
||||||
|
0xb0, 0xbd, 0xff, 0xd3, 0xa7, 0x5f, 0x7a, 0x3f, 0xbd, 0xee, 0x5a, 0x69, 0xb5, 0x37, 0x60, 0x7d,
|
||||||
|
0x83, 0x85, 0x92, 0x58, 0x38, 0xad, 0xb4, 0x36, 0x2f, 0x75, 0x2b, 0xc1, 0xe4, 0x9d, 0x43, 0x8f,
|
||||||
|
0xec, 0x62, 0x2a, 0xe5, 0x4a, 0xe2, 0xf2, 0x9d, 0xd0, 0x45, 0x19, 0xc4, 0xfb, 0x1f, 0x8f, 0x9d,
|
||||||
|
0xd3, 0x18, 0x14, 0x27, 0x29, 0xc9, 0x66, 0x65, 0x0c, 0x8a, 0xa5, 0x74, 0x51, 0x69, 0xab, 0x57,
|
||||||
|
0x50, 0x83, 0x74, 0x3b, 0x1e, 0xa7, 0x24, 0x9b, 0x97, 0x53, 0xc4, 0x96, 0xf4, 0xac, 0x85, 0xd7,
|
||||||
|
0x1e, 0xd4, 0xd3, 0xf6, 0x41, 0x6e, 0xd6, 0xfc, 0x28, 0x28, 0xff, 0x18, 0xbb, 0xa4, 0x89, 0x34,
|
||||||
|
0xd8, 0x5b, 0xcf, 0x67, 0xa1, 0xf9, 0x37, 0xb1, 0x2b, 0x3a, 0xaf, 0xd1, 0xae, 0xc0, 0x19, 0xad,
|
||||||
|
0xf8, 0x71, 0x4a, 0xb2, 0xd3, 0xf2, 0x00, 0x18, 0xa7, 0x27, 0xb5, 0xd3, 0xd2, 0xa3, 0xe3, 0x49,
|
||||||
|
0x28, 0xfd, 0x8b, 0x77, 0x8f, 0x1f, 0x83, 0x20, 0xfb, 0x41, 0x90, 0xaf, 0x41, 0x90, 0xb7, 0x51,
|
||||||
|
0x44, 0xfb, 0x51, 0x44, 0x9f, 0xa3, 0x88, 0x9e, 0x8b, 0x06, 0xfc, 0xba, 0xaf, 0xf2, 0x1a, 0x4d,
|
||||||
|
0x71, 0x78, 0x76, 0x72, 0xde, 0x34, 0x58, 0x6c, 0xc3, 0x3e, 0x7e, 0xd7, 0xe9, 0x4d, 0x95, 0x84,
|
||||||
|
0x65, 0x6e, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x3d, 0x42, 0x49, 0xe4, 0x40, 0x01, 0x00, 0x00,
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *RedeemClaim) 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 *RedeemClaim) MarshalTo(dAtA []byte) (int, error) {
|
||||||
|
size := m.Size()
|
||||||
|
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *RedeemClaim) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||||
|
i := len(dAtA)
|
||||||
|
_ = i
|
||||||
|
var l int
|
||||||
|
_ = l
|
||||||
|
if len(m.Creator) > 0 {
|
||||||
|
i -= len(m.Creator)
|
||||||
|
copy(dAtA[i:], m.Creator)
|
||||||
|
i = encodeVarintRedeemClaim(dAtA, i, uint64(len(m.Creator)))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x32
|
||||||
|
}
|
||||||
|
if m.Confirmed {
|
||||||
|
i--
|
||||||
|
if m.Confirmed {
|
||||||
|
dAtA[i] = 1
|
||||||
|
} else {
|
||||||
|
dAtA[i] = 0
|
||||||
|
}
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x28
|
||||||
|
}
|
||||||
|
if m.Amount != 0 {
|
||||||
|
i = encodeVarintRedeemClaim(dAtA, i, uint64(m.Amount))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x20
|
||||||
|
}
|
||||||
|
if len(m.LiquidTxHash) > 0 {
|
||||||
|
i -= len(m.LiquidTxHash)
|
||||||
|
copy(dAtA[i:], m.LiquidTxHash)
|
||||||
|
i = encodeVarintRedeemClaim(dAtA, i, uint64(len(m.LiquidTxHash)))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x1a
|
||||||
|
}
|
||||||
|
if len(m.Beneficiary) > 0 {
|
||||||
|
i -= len(m.Beneficiary)
|
||||||
|
copy(dAtA[i:], m.Beneficiary)
|
||||||
|
i = encodeVarintRedeemClaim(dAtA, i, uint64(len(m.Beneficiary)))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x12
|
||||||
|
}
|
||||||
|
if m.Id != 0 {
|
||||||
|
i = encodeVarintRedeemClaim(dAtA, i, uint64(m.Id))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x8
|
||||||
|
}
|
||||||
|
return len(dAtA) - i, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func encodeVarintRedeemClaim(dAtA []byte, offset int, v uint64) int {
|
||||||
|
offset -= sovRedeemClaim(v)
|
||||||
|
base := offset
|
||||||
|
for v >= 1<<7 {
|
||||||
|
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||||
|
v >>= 7
|
||||||
|
offset++
|
||||||
|
}
|
||||||
|
dAtA[offset] = uint8(v)
|
||||||
|
return base
|
||||||
|
}
|
||||||
|
func (m *RedeemClaim) Size() (n int) {
|
||||||
|
if m == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
var l int
|
||||||
|
_ = l
|
||||||
|
if m.Id != 0 {
|
||||||
|
n += 1 + sovRedeemClaim(uint64(m.Id))
|
||||||
|
}
|
||||||
|
l = len(m.Beneficiary)
|
||||||
|
if l > 0 {
|
||||||
|
n += 1 + l + sovRedeemClaim(uint64(l))
|
||||||
|
}
|
||||||
|
l = len(m.LiquidTxHash)
|
||||||
|
if l > 0 {
|
||||||
|
n += 1 + l + sovRedeemClaim(uint64(l))
|
||||||
|
}
|
||||||
|
if m.Amount != 0 {
|
||||||
|
n += 1 + sovRedeemClaim(uint64(m.Amount))
|
||||||
|
}
|
||||||
|
if m.Confirmed {
|
||||||
|
n += 2
|
||||||
|
}
|
||||||
|
l = len(m.Creator)
|
||||||
|
if l > 0 {
|
||||||
|
n += 1 + l + sovRedeemClaim(uint64(l))
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
func sovRedeemClaim(x uint64) (n int) {
|
||||||
|
return (math_bits.Len64(x|1) + 6) / 7
|
||||||
|
}
|
||||||
|
func sozRedeemClaim(x uint64) (n int) {
|
||||||
|
return sovRedeemClaim(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||||
|
}
|
||||||
|
func (m *RedeemClaim) 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 ErrIntOverflowRedeemClaim
|
||||||
|
}
|
||||||
|
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: RedeemClaim: wiretype end group for non-group")
|
||||||
|
}
|
||||||
|
if fieldNum <= 0 {
|
||||||
|
return fmt.Errorf("proto: RedeemClaim: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||||
|
}
|
||||||
|
switch fieldNum {
|
||||||
|
case 1:
|
||||||
|
if wireType != 0 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType)
|
||||||
|
}
|
||||||
|
m.Id = 0
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowRedeemClaim
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
m.Id |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Beneficiary", wireType)
|
||||||
|
}
|
||||||
|
var stringLen uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowRedeemClaim
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
stringLen |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
intStringLen := int(stringLen)
|
||||||
|
if intStringLen < 0 {
|
||||||
|
return ErrInvalidLengthRedeemClaim
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + intStringLen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthRedeemClaim
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m.Beneficiary = string(dAtA[iNdEx:postIndex])
|
||||||
|
iNdEx = postIndex
|
||||||
|
case 3:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field LiquidTxHash", wireType)
|
||||||
|
}
|
||||||
|
var stringLen uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowRedeemClaim
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
stringLen |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
intStringLen := int(stringLen)
|
||||||
|
if intStringLen < 0 {
|
||||||
|
return ErrInvalidLengthRedeemClaim
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + intStringLen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthRedeemClaim
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m.LiquidTxHash = string(dAtA[iNdEx:postIndex])
|
||||||
|
iNdEx = postIndex
|
||||||
|
case 4:
|
||||||
|
if wireType != 0 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType)
|
||||||
|
}
|
||||||
|
m.Amount = 0
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowRedeemClaim
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
m.Amount |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 5:
|
||||||
|
if wireType != 0 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Confirmed", wireType)
|
||||||
|
}
|
||||||
|
var v int
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowRedeemClaim
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
v |= int(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m.Confirmed = bool(v != 0)
|
||||||
|
case 6:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType)
|
||||||
|
}
|
||||||
|
var stringLen uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowRedeemClaim
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
stringLen |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
intStringLen := int(stringLen)
|
||||||
|
if intStringLen < 0 {
|
||||||
|
return ErrInvalidLengthRedeemClaim
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + intStringLen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthRedeemClaim
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m.Creator = string(dAtA[iNdEx:postIndex])
|
||||||
|
iNdEx = postIndex
|
||||||
|
default:
|
||||||
|
iNdEx = preIndex
|
||||||
|
skippy, err := skipRedeemClaim(dAtA[iNdEx:])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||||
|
return ErrInvalidLengthRedeemClaim
|
||||||
|
}
|
||||||
|
if (iNdEx + skippy) > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
iNdEx += skippy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if iNdEx > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func skipRedeemClaim(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, ErrIntOverflowRedeemClaim
|
||||||
|
}
|
||||||
|
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, ErrIntOverflowRedeemClaim
|
||||||
|
}
|
||||||
|
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, ErrIntOverflowRedeemClaim
|
||||||
|
}
|
||||||
|
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, ErrInvalidLengthRedeemClaim
|
||||||
|
}
|
||||||
|
iNdEx += length
|
||||||
|
case 3:
|
||||||
|
depth++
|
||||||
|
case 4:
|
||||||
|
if depth == 0 {
|
||||||
|
return 0, ErrUnexpectedEndOfGroupRedeemClaim
|
||||||
|
}
|
||||||
|
depth--
|
||||||
|
case 5:
|
||||||
|
iNdEx += 4
|
||||||
|
default:
|
||||||
|
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||||
|
}
|
||||||
|
if iNdEx < 0 {
|
||||||
|
return 0, ErrInvalidLengthRedeemClaim
|
||||||
|
}
|
||||||
|
if depth == 0 {
|
||||||
|
return iNdEx, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrInvalidLengthRedeemClaim = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||||
|
ErrIntOverflowRedeemClaim = fmt.Errorf("proto: integer overflow")
|
||||||
|
ErrUnexpectedEndOfGroupRedeemClaim = fmt.Errorf("proto: unexpected end of group")
|
||||||
|
)
|
1413
x/dao/types/tx.pb.go
1413
x/dao/types/tx.pb.go
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user