-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TRA-433] Add MarketMapperRevShareDetails state and associated functi…
…ons (#1744) Signed-off-by: Shrenuj Bansal <shrenuj@dydx.exchange>
- Loading branch information
1 parent
a3dea6f
commit 59cb777
Showing
18 changed files
with
1,609 additions
and
174 deletions.
There are no files selected for viewing
298 changes: 151 additions & 147 deletions
298
indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
indexer/packages/v4-protos/src/codegen/dydxprotocol/revshare/query.lcd.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { LCDClient } from "@osmonauts/lcd"; | ||
import { QueryMarketMapperRevShareDetails, QueryMarketMapperRevShareDetailsResponseSDKType } from "./query"; | ||
export class LCDQueryClient { | ||
req: LCDClient; | ||
|
||
constructor({ | ||
requestClient | ||
}: { | ||
requestClient: LCDClient; | ||
}) { | ||
this.req = requestClient; | ||
this.marketMapperRevShareDetails = this.marketMapperRevShareDetails.bind(this); | ||
} | ||
/* Queries market mapper revenue share details for a specific market */ | ||
|
||
|
||
async marketMapperRevShareDetails(params: QueryMarketMapperRevShareDetails): Promise<QueryMarketMapperRevShareDetailsResponseSDKType> { | ||
const endpoint = `dydxprotocol/revshare/market_mapper_rev_share_details/${params.marketId}`; | ||
return await this.req.get<QueryMarketMapperRevShareDetailsResponseSDKType>(endpoint); | ||
} | ||
|
||
} |
21 changes: 19 additions & 2 deletions
21
indexer/packages/v4-protos/src/codegen/dydxprotocol/revshare/query.rpc.Query.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,35 @@ | ||
import { Rpc } from "../../helpers"; | ||
import * as _m0 from "protobufjs/minimal"; | ||
import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; | ||
import { QueryMarketMapperRevShareDetails, QueryMarketMapperRevShareDetailsResponse } from "./query"; | ||
/** Query defines the gRPC querier service. */ | ||
|
||
export interface Query {} | ||
export interface Query { | ||
/** Queries market mapper revenue share details for a specific market */ | ||
marketMapperRevShareDetails(request: QueryMarketMapperRevShareDetails): Promise<QueryMarketMapperRevShareDetailsResponse>; | ||
} | ||
export class QueryClientImpl implements Query { | ||
private readonly rpc: Rpc; | ||
|
||
constructor(rpc: Rpc) { | ||
this.rpc = rpc; | ||
this.marketMapperRevShareDetails = this.marketMapperRevShareDetails.bind(this); | ||
} | ||
|
||
marketMapperRevShareDetails(request: QueryMarketMapperRevShareDetails): Promise<QueryMarketMapperRevShareDetailsResponse> { | ||
const data = QueryMarketMapperRevShareDetails.encode(request).finish(); | ||
const promise = this.rpc.request("dydxprotocol.revshare.Query", "MarketMapperRevShareDetails", data); | ||
return promise.then(data => QueryMarketMapperRevShareDetailsResponse.decode(new _m0.Reader(data))); | ||
} | ||
|
||
} | ||
export const createRpcQueryExtension = (base: QueryClient) => { | ||
const rpc = createProtobufRpcClient(base); | ||
const queryService = new QueryClientImpl(rpc); | ||
return {}; | ||
return { | ||
marketMapperRevShareDetails(request: QueryMarketMapperRevShareDetails): Promise<QueryMarketMapperRevShareDetailsResponse> { | ||
return queryService.marketMapperRevShareDetails(request); | ||
} | ||
|
||
}; | ||
}; |
116 changes: 115 additions & 1 deletion
116
indexer/packages/v4-protos/src/codegen/dydxprotocol/revshare/query.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,115 @@ | ||
export {} | ||
import { MarketMapperRevShareDetails, MarketMapperRevShareDetailsSDKType } from "./revshare"; | ||
import * as _m0 from "protobufjs/minimal"; | ||
import { DeepPartial } from "../../helpers"; | ||
/** Queries market mapper revenue share details for a specific market */ | ||
|
||
export interface QueryMarketMapperRevShareDetails { | ||
/** Queries market mapper revenue share details for a specific market */ | ||
marketId: number; | ||
} | ||
/** Queries market mapper revenue share details for a specific market */ | ||
|
||
export interface QueryMarketMapperRevShareDetailsSDKType { | ||
/** Queries market mapper revenue share details for a specific market */ | ||
market_id: number; | ||
} | ||
/** Response type for QueryMarketMapperRevShareDetails */ | ||
|
||
export interface QueryMarketMapperRevShareDetailsResponse { | ||
details?: MarketMapperRevShareDetails; | ||
} | ||
/** Response type for QueryMarketMapperRevShareDetails */ | ||
|
||
export interface QueryMarketMapperRevShareDetailsResponseSDKType { | ||
details?: MarketMapperRevShareDetailsSDKType; | ||
} | ||
|
||
function createBaseQueryMarketMapperRevShareDetails(): QueryMarketMapperRevShareDetails { | ||
return { | ||
marketId: 0 | ||
}; | ||
} | ||
|
||
export const QueryMarketMapperRevShareDetails = { | ||
encode(message: QueryMarketMapperRevShareDetails, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { | ||
if (message.marketId !== 0) { | ||
writer.uint32(8).uint32(message.marketId); | ||
} | ||
|
||
return writer; | ||
}, | ||
|
||
decode(input: _m0.Reader | Uint8Array, length?: number): QueryMarketMapperRevShareDetails { | ||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); | ||
let end = length === undefined ? reader.len : reader.pos + length; | ||
const message = createBaseQueryMarketMapperRevShareDetails(); | ||
|
||
while (reader.pos < end) { | ||
const tag = reader.uint32(); | ||
|
||
switch (tag >>> 3) { | ||
case 1: | ||
message.marketId = reader.uint32(); | ||
break; | ||
|
||
default: | ||
reader.skipType(tag & 7); | ||
break; | ||
} | ||
} | ||
|
||
return message; | ||
}, | ||
|
||
fromPartial(object: DeepPartial<QueryMarketMapperRevShareDetails>): QueryMarketMapperRevShareDetails { | ||
const message = createBaseQueryMarketMapperRevShareDetails(); | ||
message.marketId = object.marketId ?? 0; | ||
return message; | ||
} | ||
|
||
}; | ||
|
||
function createBaseQueryMarketMapperRevShareDetailsResponse(): QueryMarketMapperRevShareDetailsResponse { | ||
return { | ||
details: undefined | ||
}; | ||
} | ||
|
||
export const QueryMarketMapperRevShareDetailsResponse = { | ||
encode(message: QueryMarketMapperRevShareDetailsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { | ||
if (message.details !== undefined) { | ||
MarketMapperRevShareDetails.encode(message.details, writer.uint32(10).fork()).ldelim(); | ||
} | ||
|
||
return writer; | ||
}, | ||
|
||
decode(input: _m0.Reader | Uint8Array, length?: number): QueryMarketMapperRevShareDetailsResponse { | ||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); | ||
let end = length === undefined ? reader.len : reader.pos + length; | ||
const message = createBaseQueryMarketMapperRevShareDetailsResponse(); | ||
|
||
while (reader.pos < end) { | ||
const tag = reader.uint32(); | ||
|
||
switch (tag >>> 3) { | ||
case 1: | ||
message.details = MarketMapperRevShareDetails.decode(reader, reader.uint32()); | ||
break; | ||
|
||
default: | ||
reader.skipType(tag & 7); | ||
break; | ||
} | ||
} | ||
|
||
return message; | ||
}, | ||
|
||
fromPartial(object: DeepPartial<QueryMarketMapperRevShareDetailsResponse>): QueryMarketMapperRevShareDetailsResponse { | ||
const message = createBaseQueryMarketMapperRevShareDetailsResponse(); | ||
message.details = object.details !== undefined && object.details !== null ? MarketMapperRevShareDetails.fromPartial(object.details) : undefined; | ||
return message; | ||
} | ||
|
||
}; |
65 changes: 65 additions & 0 deletions
65
indexer/packages/v4-protos/src/codegen/dydxprotocol/revshare/revshare.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import * as _m0 from "protobufjs/minimal"; | ||
import { Long, DeepPartial } from "../../helpers"; | ||
/** | ||
* MarketMapperRevShareDetails specifies any details associated with the market | ||
* mapper revenue share | ||
*/ | ||
|
||
export interface MarketMapperRevShareDetails { | ||
/** Unix timestamp recorded when the market revenue share expires */ | ||
expirationTs: Long; | ||
} | ||
/** | ||
* MarketMapperRevShareDetails specifies any details associated with the market | ||
* mapper revenue share | ||
*/ | ||
|
||
export interface MarketMapperRevShareDetailsSDKType { | ||
/** Unix timestamp recorded when the market revenue share expires */ | ||
expiration_ts: Long; | ||
} | ||
|
||
function createBaseMarketMapperRevShareDetails(): MarketMapperRevShareDetails { | ||
return { | ||
expirationTs: Long.UZERO | ||
}; | ||
} | ||
|
||
export const MarketMapperRevShareDetails = { | ||
encode(message: MarketMapperRevShareDetails, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { | ||
if (!message.expirationTs.isZero()) { | ||
writer.uint32(8).uint64(message.expirationTs); | ||
} | ||
|
||
return writer; | ||
}, | ||
|
||
decode(input: _m0.Reader | Uint8Array, length?: number): MarketMapperRevShareDetails { | ||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); | ||
let end = length === undefined ? reader.len : reader.pos + length; | ||
const message = createBaseMarketMapperRevShareDetails(); | ||
|
||
while (reader.pos < end) { | ||
const tag = reader.uint32(); | ||
|
||
switch (tag >>> 3) { | ||
case 1: | ||
message.expirationTs = (reader.uint64() as Long); | ||
break; | ||
|
||
default: | ||
reader.skipType(tag & 7); | ||
break; | ||
} | ||
} | ||
|
||
return message; | ||
}, | ||
|
||
fromPartial(object: DeepPartial<MarketMapperRevShareDetails>): MarketMapperRevShareDetails { | ||
const message = createBaseMarketMapperRevShareDetails(); | ||
message.expirationTs = object.expirationTs !== undefined && object.expirationTs !== null ? Long.fromValue(object.expirationTs) : Long.UZERO; | ||
return message; | ||
} | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import * as _112 from "./gogo"; | ||
export const gogoproto = { ..._112 | ||
import * as _113 from "./gogo"; | ||
export const gogoproto = { ..._113 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
import * as _113 from "./api/annotations"; | ||
import * as _114 from "./api/http"; | ||
import * as _115 from "./protobuf/descriptor"; | ||
import * as _116 from "./protobuf/duration"; | ||
import * as _117 from "./protobuf/timestamp"; | ||
import * as _118 from "./protobuf/any"; | ||
import * as _114 from "./api/annotations"; | ||
import * as _115 from "./api/http"; | ||
import * as _116 from "./protobuf/descriptor"; | ||
import * as _117 from "./protobuf/duration"; | ||
import * as _118 from "./protobuf/timestamp"; | ||
import * as _119 from "./protobuf/any"; | ||
export namespace google { | ||
export const api = { ..._113, | ||
..._114 | ||
export const api = { ..._114, | ||
..._115 | ||
}; | ||
export const protobuf = { ..._115, | ||
..._116, | ||
export const protobuf = { ..._116, | ||
..._117, | ||
..._118 | ||
..._118, | ||
..._119 | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,25 @@ | ||
syntax = "proto3"; | ||
package dydxprotocol.revshare; | ||
|
||
import "google/api/annotations.proto"; | ||
import "dydxprotocol/revshare/revshare.proto"; | ||
|
||
option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/revshare/types"; | ||
|
||
// Query defines the gRPC querier service. | ||
service Query {} | ||
service Query { | ||
// Queries market mapper revenue share details for a specific market | ||
rpc MarketMapperRevShareDetails(QueryMarketMapperRevShareDetails) | ||
returns (QueryMarketMapperRevShareDetailsResponse) { | ||
option (google.api.http).get = | ||
"/dydxprotocol/revshare/market_mapper_rev_share_details/{market_id}"; | ||
} | ||
} | ||
|
||
// Queries market mapper revenue share details for a specific market | ||
message QueryMarketMapperRevShareDetails { uint32 market_id = 1; } | ||
|
||
// Response type for QueryMarketMapperRevShareDetails | ||
message QueryMarketMapperRevShareDetailsResponse { | ||
MarketMapperRevShareDetails details = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
syntax = "proto3"; | ||
package dydxprotocol.revshare; | ||
|
||
option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/revshare/types"; | ||
|
||
// MarketMapperRevShareDetails specifies any details associated with the market | ||
// mapper revenue share | ||
message MarketMapperRevShareDetails { | ||
// Unix timestamp recorded when the market revenue share expires | ||
uint64 expiration_ts = 1; | ||
} |
21 changes: 21 additions & 0 deletions
21
protocol/x/revshare/keeper/grpc_query_marketmapper_revshare_details.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package keeper | ||
|
||
import ( | ||
"context" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/dydxprotocol/v4-chain/protocol/x/revshare/types" | ||
) | ||
|
||
func (k Keeper) MarketMapperRevShareDetails( | ||
ctx context.Context, | ||
req *types.QueryMarketMapperRevShareDetails, | ||
) (*types.QueryMarketMapperRevShareDetailsResponse, error) { | ||
revShareDetails, err := k.GetMarketMapperRevShareDetails(sdk.UnwrapSDKContext(ctx), req.MarketId) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &types.QueryMarketMapperRevShareDetailsResponse{ | ||
Details: &revShareDetails, | ||
}, nil | ||
} |
Oops, something went wrong.