From 995c2a5bf264acac3d6ed267ed49391eed23ca67 Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Thu, 15 Aug 2024 16:00:25 +0200 Subject: [PATCH] fix modifybid simulation --- docs/static/openapi.yml | 2 +- x/fundraising/keeper/auction.go | 5 ++- x/fundraising/simulation/modify_bid.go | 62 +++++--------------------- 3 files changed, 15 insertions(+), 54 deletions(-) diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 8eccd93..92ff6be 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -1 +1 @@ -{"id":"github.com/tendermint/fundraising","consumes":["application/json"],"produces":["application/json"],"swagger":"2.0","info":{"description":"Chain github.com/tendermint/fundraising REST API","title":"HTTP API Console","contact":{"name":"github.com/tendermint/fundraising"},"version":"version not set"},"paths":{"/fundraising.fundraising.v1.Msg/AddAllowedBidder":{"post":{"tags":["Msg"],"summary":"AddAllowedBidder defines a method sto add a single allowed bidder message.\nThis is for the testing purpose and it must not be used in mainnet.","operationId":"GithubComtendermintfundraisingMsg_AddAllowedBidder","parameters":[{"description":"MsgAddAllowedBidder defines a SDK message for adding an allowed bidder to the\nauction.","name":"body","in":"body","required":true,"schema":{"$ref":"#/definitions/fundraising.fundraising.v1.MsgAddAllowedBidder"}}],"responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/fundraising.fundraising.v1.MsgAddAllowedBidderResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}},"/fundraising.fundraising.v1.Msg/CancelAuction":{"post":{"tags":["Msg"],"summary":"CancelAuction defines a method to cancel the auction message.","operationId":"GithubComtendermintfundraisingMsg_CancelAuction","parameters":[{"description":"MsgCancelAuction defines a SDK message for cancelling the auction.\nCancelling is only allowed when the auction hasn't started yet.","name":"body","in":"body","required":true,"schema":{"$ref":"#/definitions/fundraising.fundraising.v1.MsgCancelAuction"}}],"responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/fundraising.fundraising.v1.MsgCancelAuctionResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}},"/fundraising.fundraising.v1.Msg/CreateBatchAuction":{"post":{"tags":["Msg"],"summary":"CreateBatchAuction submits a create batch auction message.","operationId":"GithubComtendermintfundraisingMsg_CreateBatchAuction","parameters":[{"description":"MsgCreateBatchAuction defines a SDK message for creating an batch\nauction.\n\nSee:\nhttps://github.com/tendermint/fundraising/tree/main/x/fundraising/spec/04_messages.md","name":"body","in":"body","required":true,"schema":{"$ref":"#/definitions/fundraising.fundraising.v1.MsgCreateBatchAuction"}}],"responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/fundraising.fundraising.v1.MsgCreateBatchAuctionResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}},"/fundraising.fundraising.v1.Msg/CreateFixedPriceAuction":{"post":{"tags":["Msg"],"summary":"CreateFixedPriceAuction submits a create fixed price auction message.","operationId":"GithubComtendermintfundraisingMsg_CreateFixedPriceAuction","parameters":[{"description":"MsgCreateFixedPriceAuction defines a SDK message for creating a fixed price\nauction.","name":"body","in":"body","required":true,"schema":{"$ref":"#/definitions/fundraising.fundraising.v1.MsgCreateFixedPriceAuction"}}],"responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/fundraising.fundraising.v1.MsgCreateFixedPriceAuctionResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}},"/fundraising.fundraising.v1.Msg/ModifyBid":{"post":{"tags":["Msg"],"summary":"ModifyBid defines a method to modify the bid message.","operationId":"GithubComtendermintfundraisingMsg_ModifyBid","parameters":[{"description":"MsgModifyBid defines a SDK message for modifying an existing bid for the\nauction.","name":"body","in":"body","required":true,"schema":{"$ref":"#/definitions/fundraising.fundraising.v1.MsgModifyBid"}}],"responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/fundraising.fundraising.v1.MsgModifyBidResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}},"/fundraising.fundraising.v1.Msg/PlaceBid":{"post":{"tags":["Msg"],"summary":"PlaceBid defines a method to place a bid message.","operationId":"GithubComtendermintfundraisingMsg_PlaceBid","parameters":[{"description":"MsgPlaceBid defines a SDK message for placing a bid for the auction.","name":"body","in":"body","required":true,"schema":{"$ref":"#/definitions/fundraising.fundraising.v1.MsgPlaceBid"}}],"responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/fundraising.fundraising.v1.MsgPlaceBidResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}},"/fundraising.fundraising.v1.Msg/UpdateParams":{"post":{"tags":["Msg"],"summary":"UpdateParams defines a (governance) operation for updating the module\nparameters. The authority defaults to the x/gov module account.","operationId":"GithubComtendermintfundraisingMsg_UpdateParams","parameters":[{"description":"MsgUpdateParams is the Msg/UpdateParams request type.","name":"body","in":"body","required":true,"schema":{"$ref":"#/definitions/fundraising.fundraising.v1.MsgUpdateParams"}}],"responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/fundraising.fundraising.v1.MsgUpdateParamsResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}},"/tendermint/fundraising/fundraising/auction":{"get":{"tags":["Query"],"summary":"Queries a list of Auction items.","operationId":"GithubComtendermintfundraisingQuery_ListAuction","parameters":[{"type":"string","name":"status","in":"query"},{"type":"string","name":"type","in":"query"},{"type":"string","format":"byte","description":"key is a value returned in PageResponse.next_key to begin\nquerying the next page most efficiently. Only one of offset or key\nshould be set.","name":"pagination.key","in":"query"},{"type":"string","format":"uint64","description":"offset is a numeric offset that can be used when key is unavailable.\nIt is less efficient than using key. Only one of offset or key should\nbe set.","name":"pagination.offset","in":"query"},{"type":"string","format":"uint64","description":"limit is the total number of results to be returned in the result page.\nIf left empty it will default to a value to be set by each app.","name":"pagination.limit","in":"query"},{"type":"boolean","description":"count_total is set to true to indicate that the result set should include\na count of the total number of items available for pagination in UIs.\ncount_total is only respected when offset is used. It is ignored when key\nis set.","name":"pagination.count_total","in":"query"},{"type":"boolean","description":"reverse is set to true if results are to be returned in the descending order.\n\nSince: cosmos-sdk 0.43","name":"pagination.reverse","in":"query"}],"responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/fundraising.fundraising.v1.QueryAllAuctionResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}},"/tendermint/fundraising/fundraising/auction/{auction_id}":{"get":{"tags":["Query"],"operationId":"GithubComtendermintfundraisingQuery_GetAuction","parameters":[{"type":"string","format":"uint64","name":"auction_id","in":"path","required":true}],"responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/fundraising.fundraising.v1.QueryGetAuctionResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}},"/tendermint/fundraising/fundraising/auction/{auction_id}/allowed_bidder":{"get":{"tags":["Query"],"summary":"Queries a list of AllowedBidder items.","operationId":"GithubComtendermintfundraisingQuery_ListAllowedBidder","parameters":[{"type":"string","format":"uint64","name":"auction_id","in":"path","required":true},{"type":"string","format":"byte","description":"key is a value returned in PageResponse.next_key to begin\nquerying the next page most efficiently. Only one of offset or key\nshould be set.","name":"pagination.key","in":"query"},{"type":"string","format":"uint64","description":"offset is a numeric offset that can be used when key is unavailable.\nIt is less efficient than using key. Only one of offset or key should\nbe set.","name":"pagination.offset","in":"query"},{"type":"string","format":"uint64","description":"limit is the total number of results to be returned in the result page.\nIf left empty it will default to a value to be set by each app.","name":"pagination.limit","in":"query"},{"type":"boolean","description":"count_total is set to true to indicate that the result set should include\na count of the total number of items available for pagination in UIs.\ncount_total is only respected when offset is used. It is ignored when key\nis set.","name":"pagination.count_total","in":"query"},{"type":"boolean","description":"reverse is set to true if results are to be returned in the descending order.\n\nSince: cosmos-sdk 0.43","name":"pagination.reverse","in":"query"}],"responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/fundraising.fundraising.v1.QueryAllAllowedBidderResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}},"/tendermint/fundraising/fundraising/auction/{auction_id}/allowed_bidder/{bidder}":{"get":{"tags":["Query"],"operationId":"GithubComtendermintfundraisingQuery_GetAllowedBidder","parameters":[{"type":"string","format":"uint64","name":"auction_id","in":"path","required":true},{"type":"string","name":"bidder","in":"path","required":true}],"responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/fundraising.fundraising.v1.QueryGetAllowedBidderResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}},"/tendermint/fundraising/fundraising/auction/{auction_id}/bid":{"get":{"tags":["Query"],"summary":"Queries a list of Bid items.","operationId":"GithubComtendermintfundraisingQuery_ListBid","parameters":[{"type":"string","format":"uint64","name":"auction_id","in":"path","required":true},{"type":"string","name":"bidder","in":"query"},{"type":"string","name":"is_matched","in":"query"},{"type":"string","format":"byte","description":"key is a value returned in PageResponse.next_key to begin\nquerying the next page most efficiently. Only one of offset or key\nshould be set.","name":"pagination.key","in":"query"},{"type":"string","format":"uint64","description":"offset is a numeric offset that can be used when key is unavailable.\nIt is less efficient than using key. Only one of offset or key should\nbe set.","name":"pagination.offset","in":"query"},{"type":"string","format":"uint64","description":"limit is the total number of results to be returned in the result page.\nIf left empty it will default to a value to be set by each app.","name":"pagination.limit","in":"query"},{"type":"boolean","description":"count_total is set to true to indicate that the result set should include\na count of the total number of items available for pagination in UIs.\ncount_total is only respected when offset is used. It is ignored when key\nis set.","name":"pagination.count_total","in":"query"},{"type":"boolean","description":"reverse is set to true if results are to be returned in the descending order.\n\nSince: cosmos-sdk 0.43","name":"pagination.reverse","in":"query"}],"responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/fundraising.fundraising.v1.QueryAllBidResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}},"/tendermint/fundraising/fundraising/auction/{auction_id}/bid/{bid_id}":{"get":{"tags":["Query"],"operationId":"GithubComtendermintfundraisingQuery_GetBid","parameters":[{"type":"string","format":"uint64","name":"auction_id","in":"path","required":true},{"type":"string","format":"uint64","name":"bid_id","in":"path","required":true}],"responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/fundraising.fundraising.v1.QueryGetBidResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}},"/tendermint/fundraising/fundraising/auction/{auction_id}/vestings":{"get":{"tags":["Query"],"summary":"Queries a list of VestingQueue items.","operationId":"GithubComtendermintfundraisingQuery_ListVestingQueue","parameters":[{"type":"string","format":"uint64","name":"auction_id","in":"path","required":true},{"type":"string","format":"byte","description":"key is a value returned in PageResponse.next_key to begin\nquerying the next page most efficiently. Only one of offset or key\nshould be set.","name":"pagination.key","in":"query"},{"type":"string","format":"uint64","description":"offset is a numeric offset that can be used when key is unavailable.\nIt is less efficient than using key. Only one of offset or key should\nbe set.","name":"pagination.offset","in":"query"},{"type":"string","format":"uint64","description":"limit is the total number of results to be returned in the result page.\nIf left empty it will default to a value to be set by each app.","name":"pagination.limit","in":"query"},{"type":"boolean","description":"count_total is set to true to indicate that the result set should include\na count of the total number of items available for pagination in UIs.\ncount_total is only respected when offset is used. It is ignored when key\nis set.","name":"pagination.count_total","in":"query"},{"type":"boolean","description":"reverse is set to true if results are to be returned in the descending order.\n\nSince: cosmos-sdk 0.43","name":"pagination.reverse","in":"query"}],"responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/fundraising.fundraising.v1.QueryAllVestingQueueResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}},"/tendermint/fundraising/fundraising/v1/params":{"get":{"tags":["Query"],"summary":"Parameters queries the parameters of the module.","operationId":"GithubComtendermintfundraisingQuery_Params","responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/fundraising.fundraising.v1.QueryParamsResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}}},"definitions":{"cosmos.base.query.v1beta1.PageRequest":{"description":"message SomeRequest {\n Foo some_parameter = 1;\n PageRequest pagination = 2;\n }","type":"object","title":"PageRequest is to be embedded in gRPC request messages for efficient\npagination. Ex:","properties":{"count_total":{"description":"count_total is set to true to indicate that the result set should include\na count of the total number of items available for pagination in UIs.\ncount_total is only respected when offset is used. It is ignored when key\nis set.","type":"boolean"},"key":{"description":"key is a value returned in PageResponse.next_key to begin\nquerying the next page most efficiently. Only one of offset or key\nshould be set.","type":"string","format":"byte"},"limit":{"description":"limit is the total number of results to be returned in the result page.\nIf left empty it will default to a value to be set by each app.","type":"string","format":"uint64"},"offset":{"description":"offset is a numeric offset that can be used when key is unavailable.\nIt is less efficient than using key. Only one of offset or key should\nbe set.","type":"string","format":"uint64"},"reverse":{"description":"reverse is set to true if results are to be returned in the descending order.\n\nSince: cosmos-sdk 0.43","type":"boolean"}}},"cosmos.base.query.v1beta1.PageResponse":{"description":"PageResponse is to be embedded in gRPC response messages where the\ncorresponding request message has used PageRequest.\n\n message SomeResponse {\n repeated Bar results = 1;\n PageResponse page = 2;\n }","type":"object","properties":{"next_key":{"description":"next_key is the key to be passed to PageRequest.key to\nquery the next page most efficiently. It will be empty if\nthere are no more results.","type":"string","format":"byte"},"total":{"type":"string","format":"uint64","title":"total is total number of results available if PageRequest.count_total\nwas set, its value is undefined otherwise"}}},"cosmos.base.v1beta1.Coin":{"description":"Coin defines a token with a denomination and an amount.\n\nNOTE: The amount field is an Int which implements the custom method\nsignatures required by gogoproto.","type":"object","properties":{"amount":{"type":"string"},"denom":{"type":"string"}}},"fundraising.fundraising.v1.AllowedBidder":{"description":"AllowedBidder defines an allowed bidder for the auction.","type":"object","properties":{"auction_id":{"type":"string","format":"uint64","title":"auction_id specifies the id of the auction"},"bidder":{"type":"string","title":"bidder specifies the bech32-encoded address that bids for the auction"},"max_bid_amount":{"type":"string","title":"max_bid_amount specifies the maximum bid amount that the bidder can bid"}}},"fundraising.fundraising.v1.Bid":{"description":"Bid defines a standard bid for an auction.","type":"object","properties":{"auction_id":{"type":"string","format":"uint64","title":"auction_id specifies the id of the auction"},"bidder":{"type":"string","title":"bidder specifies the bech32-encoded address that bids for the auction"},"coin":{"description":"coin specifies the amount of coin that the bidder bids\nfor a fixed price auction, the denom is of the paying coin.\nfor a batch auction of how-much-worth, the denom is of the paying coin.\nfor a batch auction of how-many-coins, the denom is of the selling coin.","$ref":"#/definitions/cosmos.base.v1beta1.Coin"},"id":{"type":"string","format":"uint64","title":"id specifies an index of a bid for the bidder"},"is_matched":{"type":"boolean","title":"is_matched specifies the bid that is a winning bid and enables the bidder\nto purchase the selling coin"},"price":{"type":"string","title":"price specifies the bid price in which price the bidder places the bid"},"type":{"title":"type specifies the bid type; type 1 is fixed price, 2 is how-much-worth, 3\nis how-many-coins","$ref":"#/definitions/fundraising.fundraising.v1.BidType"}}},"fundraising.fundraising.v1.BidType":{"description":"BidType enumerates the valid types of a bid.\n\n - BID_TYPE_UNSPECIFIED: BID_TYPE_UNSPECIFIED defines the default bid type\n - BID_TYPE_FIXED_PRICE: BID_TYPE_FIXED_PRICE defines a bid type for a fixed price auction type\n - BID_TYPE_BATCH_WORTH: BID_TYPE_BATCH_WORTH defines a bid type for How-Much-Worth-to-Buy of a\nbatch auction\n - BID_TYPE_BATCH_MANY: BID_TYPE_BATCH_MANY defines a bid type for How-Many-Coins-to-Buy of a batch\nauction","type":"string","default":"BID_TYPE_UNSPECIFIED","enum":["BID_TYPE_UNSPECIFIED","BID_TYPE_FIXED_PRICE","BID_TYPE_BATCH_WORTH","BID_TYPE_BATCH_MANY"]},"fundraising.fundraising.v1.MsgAddAllowedBidder":{"description":"MsgAddAllowedBidder defines a SDK message for adding an allowed bidder to the\nauction.","type":"object","properties":{"allowed_bidder":{"title":"allowed_bidder specifies the bidder who is allowed to bid and their maximum\nbid amount","$ref":"#/definitions/fundraising.fundraising.v1.AllowedBidder"},"auction_id":{"type":"string","format":"uint64","title":"auction_id specifies the auction id"}}},"fundraising.fundraising.v1.MsgAddAllowedBidderResponse":{"description":"MsgAddAllowedBidderResponse defines the Msg/MsgAddAllowedBidderResponse response type.","type":"object"},"fundraising.fundraising.v1.MsgCancelAuction":{"description":"MsgCancelAuction defines a SDK message for cancelling the auction.\nCancelling is only allowed when the auction hasn't started yet.","type":"object","properties":{"auction_id":{"type":"string","format":"uint64","title":"auction_id specifies the auction id"},"auctioneer":{"type":"string","title":"auctioneer specifies the bech32-encoded address that is in charge of the\nauction"}}},"fundraising.fundraising.v1.MsgCancelAuctionResponse":{"description":"MsgCancelAuctionResponse defines the Msg/MsgCancelAuctionResponse\nresponse type.","type":"object"},"fundraising.fundraising.v1.MsgCreateBatchAuction":{"description":"MsgCreateBatchAuction defines a SDK message for creating an batch\nauction.\n\nSee:\nhttps://github.com/tendermint/fundraising/tree/main/x/fundraising/spec/04_messages.md","type":"object","properties":{"auctioneer":{"type":"string","title":"auctioneer specifies the bech32-encoded address that creates the auction"},"end_time":{"type":"string","format":"date-time","title":"end_time specifies the end time of the plan"},"extended_round_rate":{"type":"string","title":"extended_round_rate specifies the rate that decides if the auction needs\nanother round"},"max_extended_round":{"type":"integer","format":"int64","title":"maximum_extended_round specifies the maximum number of extended rounds for\nthe auction"},"min_bid_price":{"type":"string","title":"min_bid_price specifies the minibum bid price"},"paying_coin_denom":{"type":"string","title":"paying_coin_denom specifies the paying coin denom that bidders use to bid\nfor"},"selling_coin":{"title":"selling_coin specifies the selling coin for the auction","$ref":"#/definitions/cosmos.base.v1beta1.Coin"},"start_price":{"type":"string","title":"start_price specifies the starting price of the auction"},"start_time":{"type":"string","format":"date-time","title":"start_time specifies the start time of the plan"},"vesting_schedules":{"type":"array","title":"vesting_schedules specifies the vesting schedules for the auction","items":{"type":"object","$ref":"#/definitions/fundraising.fundraising.v1.VestingSchedule"}}}},"fundraising.fundraising.v1.MsgCreateBatchAuctionResponse":{"description":"MsgCreateBatchAuctionResponse defines the\nMsg/MsgCreateBatchAuctionResponse response type.","type":"object"},"fundraising.fundraising.v1.MsgCreateFixedPriceAuction":{"description":"MsgCreateFixedPriceAuction defines a SDK message for creating a fixed price\nauction.","type":"object","properties":{"auctioneer":{"type":"string","title":"auctioneer specifies the bech32-encoded address that creates the auction"},"end_time":{"type":"string","format":"date-time","title":"end_time specifies the end time of the plan"},"paying_coin_denom":{"type":"string","title":"paying_coin_denom specifies the paying coin denom that bidders use to bid\nfor"},"selling_coin":{"title":"selling_coin specifies the selling coin for the auction","$ref":"#/definitions/cosmos.base.v1beta1.Coin"},"start_price":{"type":"string","title":"start_price specifies the starting price of the auction"},"start_time":{"type":"string","format":"date-time","title":"start_time specifies the start time of the plan"},"vesting_schedules":{"type":"array","title":"vesting_schedules specifies the vesting schedules for the auction","items":{"type":"object","$ref":"#/definitions/fundraising.fundraising.v1.VestingSchedule"}}}},"fundraising.fundraising.v1.MsgCreateFixedPriceAuctionResponse":{"description":"MsgCreateFixedPriceAuctionResponse defines the\nMsg/MsgCreateFixedPriceAuctionResponse response type.","type":"object"},"fundraising.fundraising.v1.MsgModifyBid":{"description":"MsgModifyBid defines a SDK message for modifying an existing bid for the\nauction.","type":"object","properties":{"auction_id":{"type":"string","format":"uint64","title":"auction_id specifies the auction id"},"bid_id":{"type":"string","format":"uint64","title":"bid_id specifies the bid id"},"bidder":{"type":"string","title":"bidder specifies the bech32-encoded address that bids for the auction"},"coin":{"title":"coin specifies the paying amount of coin or the selling amount that the\nbidder bids","$ref":"#/definitions/cosmos.base.v1beta1.Coin"},"price":{"description":"price specifies the bid price.\nthe bide price must be above or equal to the original value that the bidder\nplaced.","type":"string"}}},"fundraising.fundraising.v1.MsgModifyBidResponse":{"description":"MsgModifyBidResponse defines the Msg/MsgModifyBidResponse response type.","type":"object"},"fundraising.fundraising.v1.MsgPlaceBid":{"description":"MsgPlaceBid defines a SDK message for placing a bid for the auction.","type":"object","properties":{"auction_id":{"type":"string","format":"uint64","title":"auction_id specifies the auction id"},"bid_type":{"title":"type specifies the bid type; type 1 is fixed price, 2 is how-much-worth, 3\nis how-many-coins","$ref":"#/definitions/fundraising.fundraising.v1.BidType"},"bidder":{"type":"string","title":"bidder specifies the bech32-encoded address that bids for the auction"},"coin":{"title":"coin specifies the paying amount of coin or the selling amount that the\nbidder bids","$ref":"#/definitions/cosmos.base.v1beta1.Coin"},"price":{"description":"price specifies the bid price.\nThe bid price must be the start price for fixed price auction whereas\nthe bide price can be any value that the bidder places.","type":"string"}}},"fundraising.fundraising.v1.MsgPlaceBidResponse":{"description":"MsgPlaceBidResponse defines the Msg/MsgPlaceBidResponse response type.","type":"object"},"fundraising.fundraising.v1.MsgUpdateParams":{"description":"MsgUpdateParams is the Msg/UpdateParams request type.","type":"object","properties":{"authority":{"description":"authority is the address that controls the module (defaults to x/gov unless overwritten).","type":"string"},"params":{"description":"NOTE: All parameters must be supplied.","$ref":"#/definitions/fundraising.fundraising.v1.Params"}}},"fundraising.fundraising.v1.MsgUpdateParamsResponse":{"description":"MsgUpdateParamsResponse defines the response structure for executing a\nMsgUpdateParams message.","type":"object"},"fundraising.fundraising.v1.Params":{"description":"Params defines the parameters for the module.","type":"object","properties":{"auction_creation_fee":{"type":"array","title":"auction_creation_fee specifies the fee for auction creation.\nthis prevents from spamming attack and it is collected in the community\npool","items":{"type":"object","$ref":"#/definitions/cosmos.base.v1beta1.Coin"}},"extended_period":{"type":"integer","format":"int64","title":"extended_period specifies the extended period that determines how long\nthe extended auction round lasts"},"place_bid_fee":{"type":"array","title":"place_bid_fee specifies the fee for placing a bid for an auction.\nthis prevents from spamming attack and it is collected in the community\npool","items":{"type":"object","$ref":"#/definitions/cosmos.base.v1beta1.Coin"}}}},"fundraising.fundraising.v1.QueryAllAllowedBidderResponse":{"description":"QueryAllowedBidderResponse is the response type for the Query/AllowedBidder RPC method.","type":"object","properties":{"allowed_bidder":{"type":"array","items":{"type":"object","$ref":"#/definitions/fundraising.fundraising.v1.AllowedBidder"}},"pagination":{"title":"pagination defines the pagination in the response","$ref":"#/definitions/cosmos.base.query.v1beta1.PageResponse"}}},"fundraising.fundraising.v1.QueryAllAuctionResponse":{"description":"QueryAllAuctionResponse is response type for the Query/Auctions RPC method.","type":"object","properties":{"auction":{"type":"array","title":"auctions specifies the existing auctions","items":{"type":"object","$ref":"#/definitions/google.protobuf.Any"}},"pagination":{"title":"pagination defines the pagination in the response","$ref":"#/definitions/cosmos.base.query.v1beta1.PageResponse"}}},"fundraising.fundraising.v1.QueryAllBidResponse":{"description":"QueryBidsResponse is response type for the Query/Bids RPC method.","type":"object","properties":{"bid":{"type":"array","title":"bids specifies the existing bids","items":{"type":"object","$ref":"#/definitions/fundraising.fundraising.v1.Bid"}},"pagination":{"title":"pagination defines the pagination in the response","$ref":"#/definitions/cosmos.base.query.v1beta1.PageResponse"}}},"fundraising.fundraising.v1.QueryAllVestingQueueResponse":{"description":"QueryAllVestingQueueResponse is response type for the Query/Vestings RPC method.","type":"object","properties":{"pagination":{"$ref":"#/definitions/cosmos.base.query.v1beta1.PageResponse"},"vestingQueue":{"type":"array","title":"vestings specifies the existing vestings","items":{"type":"object","$ref":"#/definitions/fundraising.fundraising.v1.VestingQueue"}}}},"fundraising.fundraising.v1.QueryGetAllowedBidderResponse":{"description":"QueryAllowedBidderResponse is the response type for the Query/AllowedBidder\nRPC method.","type":"object","properties":{"allowed_bidder":{"$ref":"#/definitions/fundraising.fundraising.v1.AllowedBidder"}}},"fundraising.fundraising.v1.QueryGetAuctionResponse":{"description":"QueryGetAuctionResponse is the response type for the Query/Auction RPC method.","type":"object","properties":{"auction":{"$ref":"#/definitions/google.protobuf.Any"}}},"fundraising.fundraising.v1.QueryGetBidResponse":{"description":"QueryGetBidResponse is response type for the Query/Sequence RPC method.","type":"object","properties":{"bid":{"title":"bid specifies specific bid","$ref":"#/definitions/fundraising.fundraising.v1.Bid"}}},"fundraising.fundraising.v1.QueryParamsResponse":{"description":"QueryParamsResponse is response type for the Query/Params RPC method.","type":"object","properties":{"params":{"description":"params holds all the parameters of this module.","$ref":"#/definitions/fundraising.fundraising.v1.Params"}}},"fundraising.fundraising.v1.VestingQueue":{"description":"VestingQueue defines the vesting queue.","type":"object","properties":{"auction_id":{"type":"string","format":"uint64","title":"auction_id specifies the id of the auction"},"auctioneer":{"type":"string","title":"auctioneer specifies the bech32-encoded address that creates the auction"},"paying_coin":{"title":"paying_coin specifies the paying amount of coin","$ref":"#/definitions/cosmos.base.v1beta1.Coin"},"release_time":{"type":"string","format":"date-time","title":"release_time specifies the timestamp of the vesting schedule"},"released":{"type":"boolean","title":"released specifies the status of distribution"}}},"fundraising.fundraising.v1.VestingSchedule":{"description":"VestingSchedule defines the vesting schedule for the owner of an auction.","type":"object","properties":{"release_time":{"type":"string","format":"date-time","title":"release_time specifies the time for distribution of the vesting coin"},"weight":{"type":"string","title":"weight specifies the vesting weight for the schedule"}}},"google.protobuf.Any":{"type":"object","properties":{"@type":{"type":"string"}},"additionalProperties":{}},"google.rpc.Status":{"type":"object","properties":{"code":{"type":"integer","format":"int32"},"details":{"type":"array","items":{"type":"object","$ref":"#/definitions/google.protobuf.Any"}},"message":{"type":"string"}}}},"tags":[{"name":"Query"},{"name":"Msg"}]} \ No newline at end of file +{"id":"github.com/tendermint/fundraising","consumes":["application/json"],"produces":["application/json"],"swagger":"2.0","info":{"description":"Chain github.com/tendermint/fundraising REST API","title":"HTTP API Console","contact":{"name":"github.com/tendermint/fundraising"},"version":"version not set"},"paths":{},"definitions":{"google.protobuf.Any":{"type":"object","properties":{"@type":{"type":"string"}},"additionalProperties":{}},"google.rpc.Status":{"type":"object","properties":{"code":{"type":"integer","format":"int32"},"details":{"type":"array","items":{"type":"object","$ref":"#/definitions/google.protobuf.Any"}},"message":{"type":"string"}}}}} \ No newline at end of file diff --git a/x/fundraising/keeper/auction.go b/x/fundraising/keeper/auction.go index c8b8679..6b28fb8 100644 --- a/x/fundraising/keeper/auction.go +++ b/x/fundraising/keeper/auction.go @@ -139,7 +139,10 @@ func (k Keeper) AllocateSellingCoin(ctx context.Context, auction types.AuctionI, continue } allocateCoins := sdk.NewCoins(sdk.NewCoin(sellingCoinDenom, mInfo.AllocationMap[bidder])) - bidderAddr, _ := sdk.AccAddressFromBech32(bidder) + bidderAddr, err := sdk.AccAddressFromBech32(bidder) + if err != nil { + return err + } if _, ok := ioCoins[bidderAddr.String()]; !ok { ioCoins[bidder] = inOutCoins{ diff --git a/x/fundraising/simulation/modify_bid.go b/x/fundraising/simulation/modify_bid.go index 4b70614..d6fed77 100644 --- a/x/fundraising/simulation/modify_bid.go +++ b/x/fundraising/simulation/modify_bid.go @@ -1,10 +1,9 @@ package simulation import ( + "cosmossdk.io/math" "math/rand" - "cosmossdk.io/collections" - "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" sdk "github.com/cosmos/cosmos-sdk/types" @@ -34,75 +33,34 @@ func SimulateMsgModifyBid( // Select a random auction auction := auctions[r.Intn(len(auctions))] - if auction.GetStatus() != types.AuctionStatusStarted { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "auction must be started status"), nil, nil } + if auction.GetType() != types.AuctionTypeBatch || auction.GetStatus() != types.AuctionStatusStarted { + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "incorrect auction type or status"), nil, nil + } bids, err := k.Bids(ctx) if err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "failed to get bids"), nil, nil } + if len(bids) == 0 { + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "no bid modify"), nil, nil + } // Select a random bid bid := bids[r.Intn(len(bids))] - - simAccount, _ := simtypes.RandomAcc(r, accs) + simAccount, _ := FindAccount(accs, bid.Bidder) account := ak.GetAccount(ctx, simAccount.Address) spendable := bk.SpendableCoins(ctx, account.GetAddress()) - bidder := account.GetAddress() - sellingCoinDenom := auction.GetSellingCoin().Denom - payingCoinDenom := auction.GetPayingCoinDenom() - - if _, err := fundBalances(ctx, r, bk, bidder, testCoinDenoms); err != nil { - return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "failed to fund bidder"), nil, err - } - - switch auction.GetType() { - case types.AuctionTypeFixedPrice: - bid.Type = types.BidTypeFixedPrice - bid.Price = auction.GetStartPrice() - if r.Int()%2 == 0 { - bid.Coin = sdk.NewInt64Coin(payingCoinDenom, int64(simtypes.RandIntBetween(r, 100000, 1000000000))) - } else { - bid.Coin = sdk.NewInt64Coin(sellingCoinDenom, int64(simtypes.RandIntBetween(r, 100000, 1000000000))) - } - case types.AuctionTypeBatch: - bid.Price = auction.GetStartPrice().Add(math.LegacyNewDecWithPrec(int64(simtypes.RandIntBetween(r, 1, 5)), 1)) // StartPrice + 0.1 ~ 0.5 - if r.Int()%2 == 0 { - bid.Type = types.BidTypeBatchWorth - bid.Coin = sdk.NewInt64Coin(payingCoinDenom, int64(simtypes.RandIntBetween(r, 100000, 1000000000))) - } else { - bid.Type = types.BidTypeBatchMany - bid.Coin = sdk.NewInt64Coin(sellingCoinDenom, int64(simtypes.RandIntBetween(r, 100000, 1000000000))) - } - } - - bidReserveAmt := bid.ConvertToPayingAmount(payingCoinDenom) - maxBidAmt := bid.ConvertToSellingAmount(payingCoinDenom) - - if !bk.SpendableCoins(ctx, bidder).AmountOf(payingCoinDenom).GT(bidReserveAmt) { - return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "insufficient balance to place a bid"), nil, nil - } - - allowedBidder, err := k.AllowedBidder.Get(ctx, collections.Join(auction.GetId(), bidder)) - if err == nil { - maxBidAmt = maxBidAmt.Add(allowedBidder.MaxBidAmount) - } - - newAllowedBidder := types.NewAllowedBidder(auction.GetId(), bidder, maxBidAmt) - if err := k.AddAllowedBidders(ctx, auction.GetId(), []types.AllowedBidder{newAllowedBidder}); err != nil { - return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "failed to add allowed bidders"), nil, nil - } - msg = types.NewMsgModifyBid( auction.GetId(), - bidder.String(), + account.GetAddress().String(), bid.Id, bid.Price, - bid.Coin, + bid.Coin.AddAmount(math.OneInt()), ) txCtx := simulation.OperationInput{