Add methods for creating auctions and add auction tests #28

Merged
nabarun merged 32 commits from deep-stack/registry-sdk:iv-create-auction-test into main 2024-09-25 13:21:05 +00:00
4 changed files with 115 additions and 73 deletions
Showing only changes of commit df804b58f6 - Show all commits

View File

@ -40,7 +40,8 @@ message Params {
(gogoproto.moretags) = "json:\"reveal_fee\" yaml:\"reveal_fee\"" (gogoproto.moretags) = "json:\"reveal_fee\" yaml:\"reveal_fee\""
]; ];
// Minimum acceptable bid amount (for vickrey auctions) // Minimum acceptable bid amount
// Only applicable in vickrey auctions
cosmos.base.v1beta1.Coin minimum_bid = 5 [ cosmos.base.v1beta1.Coin minimum_bid = 5 [
(gogoproto.nullable) = false, (gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"minimum_bid\" yaml:\"minimum_bid\"" (gogoproto.moretags) = "json:\"minimum_bid\" yaml:\"minimum_bid\""
@ -53,7 +54,7 @@ message Auction {
string id = 1; string id = 1;
// Auction's kind (vickrey | provider) // Auction kind (vickrey | provider)
string kind = 2 [ (gogoproto.moretags) = "json:\"kind\" yaml:\"kind\"" ]; string kind = 2 [ (gogoproto.moretags) = "json:\"kind\" yaml:\"kind\"" ];
string status = 3; string status = 3;
@ -93,34 +94,42 @@ message Auction {
(gogoproto.moretags) = "json:\"reveal_fee\" yaml:\"reveal_fee\"" (gogoproto.moretags) = "json:\"reveal_fee\" yaml:\"reveal_fee\""
]; ];
// Minimum acceptable bid amount for a valid commit (for vickrey auctions) // Minimum acceptable bid amount for a valid commit
// Only applicable in vickrey auctions
cosmos.base.v1beta1.Coin minimum_bid = 10 [ cosmos.base.v1beta1.Coin minimum_bid = 10 [
(gogoproto.nullable) = false, (gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"minimum_bid\" yaml:\"minimum_bid\"" (gogoproto.moretags) = "json:\"minimum_bid\" yaml:\"minimum_bid\""
]; ];
// Winner's address for Vickrey auctions, can be multiple for provider auctions // Addresses of the winners
// (single winner for vickrey auction)
// (multiple winners for provider auctions)
repeated string winner_addresses = 11; repeated string winner_addresses = 11;
// Winning bids, i.e., the best bids // Winning bids, i.e. the best bids
repeated cosmos.base.v1beta1.Coin winning_bids = 12 [ repeated cosmos.base.v1beta1.Coin winning_bids = 12 [
(gogoproto.nullable) = false, (gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"winning_bids\" yaml:\"winning_bids\"" (gogoproto.moretags) = "json:\"winning_bids\" yaml:\"winning_bids\""
]; ];
// Amount the winner pays (vickrey auction) or is paid (provider auction) // Auction winning price
// vickrey auction: second highest bid, paid by the winner
// provider auction: higest bid amongst winning_bids, paid by auction creator
// to each winner
cosmos.base.v1beta1.Coin winning_price = 13 [ cosmos.base.v1beta1.Coin winning_price = 13 [
(gogoproto.nullable) = false, (gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"winning_price\" yaml:\"winning_price\"" (gogoproto.moretags) = "json:\"winning_price\" yaml:\"winning_price\""
]; ];
// Maximum acceptable bid amount (for provider auctions) // Maximum acceptable bid amount for a valid commit
// Only applicable in provider auctions
cosmos.base.v1beta1.Coin max_price = 14 [ cosmos.base.v1beta1.Coin max_price = 14 [
(gogoproto.nullable) = false, (gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"max_price\" yaml:\"max_price\"" (gogoproto.moretags) = "json:\"max_price\" yaml:\"max_price\""
]; ];
// Number of providers to be selected // Number of desired providers (num of auction winners)
// Only applicable in provider auctions
int32 num_providers = 15; int32 num_providers = 15;
} }

View File

@ -41,52 +41,55 @@ message MsgCreateAuction {
option (gogoproto.goproto_getters) = false; option (gogoproto.goproto_getters) = false;
option (cosmos.msg.v1.signer) = "signer"; option (cosmos.msg.v1.signer) = "signer";
// Address of the signer
string signer = 1
[ (gogoproto.moretags) = "json:\"signer\" yaml:\"signer\"" ];
// Auction kind (vickrey | provider)
string kind = 2 [ (gogoproto.moretags) = "json:\"kind\" yaml:\"kind\"" ];
// Duration of the commits phase in seconds // Duration of the commits phase in seconds
google.protobuf.Duration commits_duration = 1 [ google.protobuf.Duration commits_duration = 3 [
(gogoproto.nullable) = false, (gogoproto.nullable) = false,
(gogoproto.stdduration) = true, (gogoproto.stdduration) = true,
(gogoproto.moretags) = "json:\"commits_duration\" yaml:\"commits_duration\"" (gogoproto.moretags) = "json:\"commits_duration\" yaml:\"commits_duration\""
]; ];
// Duration of the reveals phase in seconds // Duration of the reveals phase in seconds
google.protobuf.Duration reveals_duration = 2 [ google.protobuf.Duration reveals_duration = 4 [
(gogoproto.nullable) = false, (gogoproto.nullable) = false,
(gogoproto.stdduration) = true, (gogoproto.stdduration) = true,
(gogoproto.moretags) = "json:\"reveals_duration\" yaml:\"reveals_duration\"" (gogoproto.moretags) = "json:\"reveals_duration\" yaml:\"reveals_duration\""
]; ];
// Commit fees // Commit fees
cosmos.base.v1beta1.Coin commit_fee = 3 [ cosmos.base.v1beta1.Coin commit_fee = 5 [
(gogoproto.nullable) = false, (gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"commit_fee\" yaml:\"commit_fee\"" (gogoproto.moretags) = "json:\"commit_fee\" yaml:\"commit_fee\""
]; ];
// Reveal fees // Reveal fees
cosmos.base.v1beta1.Coin reveal_fee = 4 [ cosmos.base.v1beta1.Coin reveal_fee = 6 [
(gogoproto.nullable) = false, (gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"reveal_fee\" yaml:\"reveal_fee\"" (gogoproto.moretags) = "json:\"reveal_fee\" yaml:\"reveal_fee\""
]; ];
// Minimum acceptable bid amount (for vickrey auctions) // Minimum acceptable bid amount
cosmos.base.v1beta1.Coin minimum_bid = 5 [ // Only applicable in vickrey auctions
cosmos.base.v1beta1.Coin minimum_bid = 7 [
(gogoproto.nullable) = false, (gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"minimum_bid\" yaml:\"minimum_bid\"" (gogoproto.moretags) = "json:\"minimum_bid\" yaml:\"minimum_bid\""
]; ];
// Address of the signer // Maximum acceptable bid amount
string signer = 6 // Only applicable in provider auctions
[ (gogoproto.moretags) = "json:\"signer\" yaml:\"signer\"" ];
// Auction's kind (vickrey | provider)
string kind = 7 [ (gogoproto.moretags) = "json:\"kind\" yaml:\"kind\"" ];
// Maximum acceptable bid amount (for provider auctions)
cosmos.base.v1beta1.Coin max_price = 8 [ cosmos.base.v1beta1.Coin max_price = 8 [
(gogoproto.nullable) = false, (gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"max_price\" yaml:\"max_price\"" (gogoproto.moretags) = "json:\"max_price\" yaml:\"max_price\""
]; ];
// Number of providers to be selected // Number of desired providers (num of auction winners)
// Only applicable in provider auctions
int32 num_providers = 9; int32 num_providers = 9;
} }

View File

@ -17,14 +17,17 @@ export interface Params {
commitFee?: Coin; commitFee?: Coin;
/** Reveal fees */ /** Reveal fees */
revealFee?: Coin; revealFee?: Coin;
/** Minimum acceptable bid amount */ /**
* Minimum acceptable bid amount
* Only applicable in vickrey auctions
*/
minimumBid?: Coin; minimumBid?: Coin;
} }
/** Auction represents a sealed-bid on-chain auction */ /** Auction represents a sealed-bid on-chain auction */
export interface Auction { export interface Auction {
id: string; id: string;
/** Auction's kind (vickrey | provider) */ /** Auction kind (vickrey | provider) */
kind: string; kind: string;
status: string; status: string;
/** Address of the creator of the auction */ /** Address of the creator of the auction */
@ -41,17 +44,35 @@ export interface Auction {
*/ */
commitFee?: Coin; commitFee?: Coin;
revealFee?: Coin; revealFee?: Coin;
/** Minimum acceptable bid amount for a valid commit */ /**
* Minimum acceptable bid amount for a valid commit
* Only applicable in vickrey auctions
*/
minimumBid?: Coin; minimumBid?: Coin;
/** Addresses of the winners (one for vickrey auctions and can be multiple for provider auctions) */ /**
* Addresses of the winners
* (single winner for vickrey auction)
* (multiple winners for provider auctions)
*/
winnerAddresses: string[]; winnerAddresses: string[];
/** Winning bids, i.e., the best bids */ /** Winning bids, i.e. the best bids */
winningBids: Coin[]; winningBids: Coin[];
/** Amount the winner pays, i.e. the second best bid */ /**
* Auction winning price
* vickrey auction: second highest bid, paid by the winner
* provider auction: higest bid amongst winning_bids, paid by auction creator
* to each winner
*/
winningPrice?: Coin; winningPrice?: Coin;
/** Maximum acceptable bid amount for a valid commit for service provider auctions */ /**
* Maximum acceptable bid amount for a valid commit
* Only applicable in provider auctions
*/
maxPrice?: Coin; maxPrice?: Coin;
/** Number of providers to be selected */ /**
* Number of desired providers (num of auction winners)
* Only applicable in provider auctions
*/
numProviders: number; numProviders: number;
} }

View File

@ -9,6 +9,10 @@ export const protobufPackage = "cerc.auction.v1";
/** MsgCreateAuction defines a create auction message */ /** MsgCreateAuction defines a create auction message */
export interface MsgCreateAuction { export interface MsgCreateAuction {
/** Address of the signer */
signer: string;
/** Auction kind (vickrey | provider) */
kind: string;
/** Duration of the commits phase in seconds */ /** Duration of the commits phase in seconds */
commitsDuration?: Duration; commitsDuration?: Duration;
/** Duration of the reveals phase in seconds */ /** Duration of the reveals phase in seconds */
@ -17,15 +21,20 @@ export interface MsgCreateAuction {
commitFee?: Coin; commitFee?: Coin;
/** Reveal fees */ /** Reveal fees */
revealFee?: Coin; revealFee?: Coin;
/** Minimum acceptable bid amount */ /**
* Minimum acceptable bid amount
* Only applicable in vickrey auctions
*/
minimumBid?: Coin; minimumBid?: Coin;
/** Address of the signer */ /**
signer: string; * Maximum acceptable bid amount
/** Auction's kind (vickrey | provider) */ * Only applicable in provider auctions
kind: string; */
/** Maximum acceptable bid amount (for service provider auctions) */
maxPrice?: Coin; maxPrice?: Coin;
/** Number of providers to be selected */ /**
* Number of desired providers (num of auction winners)
* Only applicable in provider auctions
*/
numProviders: number; numProviders: number;
} }
@ -90,13 +99,13 @@ export interface MsgUpdateParamsResponse {}
function createBaseMsgCreateAuction(): MsgCreateAuction { function createBaseMsgCreateAuction(): MsgCreateAuction {
return { return {
signer: "",
kind: "",
commitsDuration: undefined, commitsDuration: undefined,
revealsDuration: undefined, revealsDuration: undefined,
commitFee: undefined, commitFee: undefined,
revealFee: undefined, revealFee: undefined,
minimumBid: undefined, minimumBid: undefined,
signer: "",
kind: "",
maxPrice: undefined, maxPrice: undefined,
numProviders: 0, numProviders: 0,
}; };
@ -107,32 +116,32 @@ export const MsgCreateAuction = {
message: MsgCreateAuction, message: MsgCreateAuction,
writer: _m0.Writer = _m0.Writer.create() writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer { ): _m0.Writer {
if (message.signer !== "") {
writer.uint32(10).string(message.signer);
}
if (message.kind !== "") {
writer.uint32(18).string(message.kind);
}
if (message.commitsDuration !== undefined) { if (message.commitsDuration !== undefined) {
Duration.encode( Duration.encode(
message.commitsDuration, message.commitsDuration,
writer.uint32(10).fork() writer.uint32(26).fork()
).ldelim(); ).ldelim();
} }
if (message.revealsDuration !== undefined) { if (message.revealsDuration !== undefined) {
Duration.encode( Duration.encode(
message.revealsDuration, message.revealsDuration,
writer.uint32(18).fork() writer.uint32(34).fork()
).ldelim(); ).ldelim();
} }
if (message.commitFee !== undefined) { if (message.commitFee !== undefined) {
Coin.encode(message.commitFee, writer.uint32(26).fork()).ldelim(); Coin.encode(message.commitFee, writer.uint32(42).fork()).ldelim();
} }
if (message.revealFee !== undefined) { if (message.revealFee !== undefined) {
Coin.encode(message.revealFee, writer.uint32(34).fork()).ldelim(); Coin.encode(message.revealFee, writer.uint32(50).fork()).ldelim();
} }
if (message.minimumBid !== undefined) { if (message.minimumBid !== undefined) {
Coin.encode(message.minimumBid, writer.uint32(42).fork()).ldelim(); Coin.encode(message.minimumBid, writer.uint32(58).fork()).ldelim();
}
if (message.signer !== "") {
writer.uint32(50).string(message.signer);
}
if (message.kind !== "") {
writer.uint32(58).string(message.kind);
} }
if (message.maxPrice !== undefined) { if (message.maxPrice !== undefined) {
Coin.encode(message.maxPrice, writer.uint32(66).fork()).ldelim(); Coin.encode(message.maxPrice, writer.uint32(66).fork()).ldelim();
@ -151,26 +160,26 @@ export const MsgCreateAuction = {
const tag = reader.uint32(); const tag = reader.uint32();
switch (tag >>> 3) { switch (tag >>> 3) {
case 1: case 1:
message.commitsDuration = Duration.decode(reader, reader.uint32());
break;
case 2:
message.revealsDuration = Duration.decode(reader, reader.uint32());
break;
case 3:
message.commitFee = Coin.decode(reader, reader.uint32());
break;
case 4:
message.revealFee = Coin.decode(reader, reader.uint32());
break;
case 5:
message.minimumBid = Coin.decode(reader, reader.uint32());
break;
case 6:
message.signer = reader.string(); message.signer = reader.string();
break; break;
case 7: case 2:
message.kind = reader.string(); message.kind = reader.string();
break; break;
case 3:
message.commitsDuration = Duration.decode(reader, reader.uint32());
break;
case 4:
message.revealsDuration = Duration.decode(reader, reader.uint32());
break;
case 5:
message.commitFee = Coin.decode(reader, reader.uint32());
break;
case 6:
message.revealFee = Coin.decode(reader, reader.uint32());
break;
case 7:
message.minimumBid = Coin.decode(reader, reader.uint32());
break;
case 8: case 8:
message.maxPrice = Coin.decode(reader, reader.uint32()); message.maxPrice = Coin.decode(reader, reader.uint32());
break; break;
@ -187,6 +196,8 @@ export const MsgCreateAuction = {
fromJSON(object: any): MsgCreateAuction { fromJSON(object: any): MsgCreateAuction {
return { return {
signer: isSet(object.signer) ? String(object.signer) : "",
kind: isSet(object.kind) ? String(object.kind) : "",
commitsDuration: isSet(object.commitsDuration) commitsDuration: isSet(object.commitsDuration)
? Duration.fromJSON(object.commitsDuration) ? Duration.fromJSON(object.commitsDuration)
: undefined, : undefined,
@ -202,8 +213,6 @@ export const MsgCreateAuction = {
minimumBid: isSet(object.minimumBid) minimumBid: isSet(object.minimumBid)
? Coin.fromJSON(object.minimumBid) ? Coin.fromJSON(object.minimumBid)
: undefined, : undefined,
signer: isSet(object.signer) ? String(object.signer) : "",
kind: isSet(object.kind) ? String(object.kind) : "",
maxPrice: isSet(object.maxPrice) maxPrice: isSet(object.maxPrice)
? Coin.fromJSON(object.maxPrice) ? Coin.fromJSON(object.maxPrice)
: undefined, : undefined,
@ -215,6 +224,8 @@ export const MsgCreateAuction = {
toJSON(message: MsgCreateAuction): unknown { toJSON(message: MsgCreateAuction): unknown {
const obj: any = {}; const obj: any = {};
message.signer !== undefined && (obj.signer = message.signer);
message.kind !== undefined && (obj.kind = message.kind);
message.commitsDuration !== undefined && message.commitsDuration !== undefined &&
(obj.commitsDuration = message.commitsDuration (obj.commitsDuration = message.commitsDuration
? Duration.toJSON(message.commitsDuration) ? Duration.toJSON(message.commitsDuration)
@ -235,8 +246,6 @@ export const MsgCreateAuction = {
(obj.minimumBid = message.minimumBid (obj.minimumBid = message.minimumBid
? Coin.toJSON(message.minimumBid) ? Coin.toJSON(message.minimumBid)
: undefined); : undefined);
message.signer !== undefined && (obj.signer = message.signer);
message.kind !== undefined && (obj.kind = message.kind);
message.maxPrice !== undefined && message.maxPrice !== undefined &&
(obj.maxPrice = message.maxPrice (obj.maxPrice = message.maxPrice
? Coin.toJSON(message.maxPrice) ? Coin.toJSON(message.maxPrice)
@ -250,6 +259,8 @@ export const MsgCreateAuction = {
object: I object: I
): MsgCreateAuction { ): MsgCreateAuction {
const message = createBaseMsgCreateAuction(); const message = createBaseMsgCreateAuction();
message.signer = object.signer ?? "";
message.kind = object.kind ?? "";
message.commitsDuration = message.commitsDuration =
object.commitsDuration !== undefined && object.commitsDuration !== null object.commitsDuration !== undefined && object.commitsDuration !== null
? Duration.fromPartial(object.commitsDuration) ? Duration.fromPartial(object.commitsDuration)
@ -270,8 +281,6 @@ export const MsgCreateAuction = {
object.minimumBid !== undefined && object.minimumBid !== null object.minimumBid !== undefined && object.minimumBid !== null
? Coin.fromPartial(object.minimumBid) ? Coin.fromPartial(object.minimumBid)
: undefined; : undefined;
message.signer = object.signer ?? "";
message.kind = object.kind ?? "";
message.maxPrice = message.maxPrice =
object.maxPrice !== undefined && object.maxPrice !== null object.maxPrice !== undefined && object.maxPrice !== null
? Coin.fromPartial(object.maxPrice) ? Coin.fromPartial(object.maxPrice)