Skip to content

Commit

Permalink
[protocol][feat] add RPC query endpoint for withdrawal gating informa…
Browse files Browse the repository at this point in the history
…tion (#964)
  • Loading branch information
lucas-dydx committed Jan 19, 2024
1 parent 2c5e561 commit 9e091fd
Show file tree
Hide file tree
Showing 13 changed files with 1,076 additions and 70 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { setPaginationParams } from "../../helpers";
import { LCDClient } from "@osmonauts/lcd";
import { QueryGetSubaccountRequest, QuerySubaccountResponseSDKType, QueryAllSubaccountRequest, QuerySubaccountAllResponseSDKType } from "./query";
import { QueryGetSubaccountRequest, QuerySubaccountResponseSDKType, QueryAllSubaccountRequest, QuerySubaccountAllResponseSDKType, QueryGetWithdrawalAndTransfersBlockedInfoRequest, QueryGetWithdrawalAndTransfersBlockedInfoResponseSDKType } from "./query";
export class LCDQueryClient {
req: LCDClient;

Expand All @@ -12,6 +12,7 @@ export class LCDQueryClient {
this.req = requestClient;
this.subaccount = this.subaccount.bind(this);
this.subaccountAll = this.subaccountAll.bind(this);
this.getWithdrawalAndTransfersBlockedInfo = this.getWithdrawalAndTransfersBlockedInfo.bind(this);
}
/* Queries a Subaccount by id */

Expand All @@ -37,5 +38,13 @@ export class LCDQueryClient {
const endpoint = `dydxprotocol/subaccounts/subaccount`;
return await this.req.get<QuerySubaccountAllResponseSDKType>(endpoint, options);
}
/* Queries information about whether withdrawal and transfers are blocked, and
if so which block they are re-enabled on. */


async getWithdrawalAndTransfersBlockedInfo(_params: QueryGetWithdrawalAndTransfersBlockedInfoRequest = {}): Promise<QueryGetWithdrawalAndTransfersBlockedInfoResponseSDKType> {
const endpoint = `dydxprotocol/subaccounts/withdrawals_and_transfers_blocked_info`;
return await this.req.get<QueryGetWithdrawalAndTransfersBlockedInfoResponseSDKType>(endpoint);
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Rpc } from "../../helpers";
import * as _m0 from "protobufjs/minimal";
import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate";
import { QueryGetSubaccountRequest, QuerySubaccountResponse, QueryAllSubaccountRequest, QuerySubaccountAllResponse } from "./query";
import { QueryGetSubaccountRequest, QuerySubaccountResponse, QueryAllSubaccountRequest, QuerySubaccountAllResponse, QueryGetWithdrawalAndTransfersBlockedInfoRequest, QueryGetWithdrawalAndTransfersBlockedInfoResponse } from "./query";
/** Query defines the gRPC querier service. */

export interface Query {
Expand All @@ -10,6 +10,12 @@ export interface Query {
/** Queries a list of Subaccount items. */

subaccountAll(request?: QueryAllSubaccountRequest): Promise<QuerySubaccountAllResponse>;
/**
* Queries information about whether withdrawal and transfers are blocked, and
* if so which block they are re-enabled on.
*/

getWithdrawalAndTransfersBlockedInfo(request?: QueryGetWithdrawalAndTransfersBlockedInfoRequest): Promise<QueryGetWithdrawalAndTransfersBlockedInfoResponse>;
}
export class QueryClientImpl implements Query {
private readonly rpc: Rpc;
Expand All @@ -18,6 +24,7 @@ export class QueryClientImpl implements Query {
this.rpc = rpc;
this.subaccount = this.subaccount.bind(this);
this.subaccountAll = this.subaccountAll.bind(this);
this.getWithdrawalAndTransfersBlockedInfo = this.getWithdrawalAndTransfersBlockedInfo.bind(this);
}

subaccount(request: QueryGetSubaccountRequest): Promise<QuerySubaccountResponse> {
Expand All @@ -34,6 +41,12 @@ export class QueryClientImpl implements Query {
return promise.then(data => QuerySubaccountAllResponse.decode(new _m0.Reader(data)));
}

getWithdrawalAndTransfersBlockedInfo(request: QueryGetWithdrawalAndTransfersBlockedInfoRequest = {}): Promise<QueryGetWithdrawalAndTransfersBlockedInfoResponse> {
const data = QueryGetWithdrawalAndTransfersBlockedInfoRequest.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.subaccounts.Query", "GetWithdrawalAndTransfersBlockedInfo", data);
return promise.then(data => QueryGetWithdrawalAndTransfersBlockedInfoResponse.decode(new _m0.Reader(data)));
}

}
export const createRpcQueryExtension = (base: QueryClient) => {
const rpc = createProtobufRpcClient(base);
Expand All @@ -45,6 +58,10 @@ export const createRpcQueryExtension = (base: QueryClient) => {

subaccountAll(request?: QueryAllSubaccountRequest): Promise<QuerySubaccountAllResponse> {
return queryService.subaccountAll(request);
},

getWithdrawalAndTransfersBlockedInfo(request?: QueryGetWithdrawalAndTransfersBlockedInfoRequest): Promise<QueryGetWithdrawalAndTransfersBlockedInfoResponse> {
return queryService.getWithdrawalAndTransfersBlockedInfo(request);
}

};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,38 @@ export interface QuerySubaccountAllResponseSDKType {
subaccount: SubaccountSDKType[];
pagination?: PageResponseSDKType;
}
/**
* QueryGetWithdrawalAndTransfersBlockedInfoRequest is a request type for
* fetching information about whether withdrawals and transfers are blocked.
*/

export interface QueryGetWithdrawalAndTransfersBlockedInfoRequest {}
/**
* QueryGetWithdrawalAndTransfersBlockedInfoRequest is a request type for
* fetching information about whether withdrawals and transfers are blocked.
*/

export interface QueryGetWithdrawalAndTransfersBlockedInfoRequestSDKType {}
/**
* QueryGetWithdrawalAndTransfersBlockedInfoRequest is a response type for
* fetching information about whether withdrawals and transfers are blocked.
*/

export interface QueryGetWithdrawalAndTransfersBlockedInfoResponse {
negativeTncSubaccountSeenAtBlock: number;
chainOutageSeenAtBlock: number;
withdrawalsAndTransfersUnblockedAtBlock: number;
}
/**
* QueryGetWithdrawalAndTransfersBlockedInfoRequest is a response type for
* fetching information about whether withdrawals and transfers are blocked.
*/

export interface QueryGetWithdrawalAndTransfersBlockedInfoResponseSDKType {
negative_tnc_subaccount_seen_at_block: number;
chain_outage_seen_at_block: number;
withdrawals_and_transfers_unblocked_at_block: number;
}

function createBaseQueryGetSubaccountRequest(): QueryGetSubaccountRequest {
return {
Expand Down Expand Up @@ -245,4 +277,103 @@ export const QuerySubaccountAllResponse = {
return message;
}

};

function createBaseQueryGetWithdrawalAndTransfersBlockedInfoRequest(): QueryGetWithdrawalAndTransfersBlockedInfoRequest {
return {};
}

export const QueryGetWithdrawalAndTransfersBlockedInfoRequest = {
encode(_: QueryGetWithdrawalAndTransfersBlockedInfoRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): QueryGetWithdrawalAndTransfersBlockedInfoRequest {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseQueryGetWithdrawalAndTransfersBlockedInfoRequest();

while (reader.pos < end) {
const tag = reader.uint32();

switch (tag >>> 3) {
default:
reader.skipType(tag & 7);
break;
}
}

return message;
},

fromPartial(_: DeepPartial<QueryGetWithdrawalAndTransfersBlockedInfoRequest>): QueryGetWithdrawalAndTransfersBlockedInfoRequest {
const message = createBaseQueryGetWithdrawalAndTransfersBlockedInfoRequest();
return message;
}

};

function createBaseQueryGetWithdrawalAndTransfersBlockedInfoResponse(): QueryGetWithdrawalAndTransfersBlockedInfoResponse {
return {
negativeTncSubaccountSeenAtBlock: 0,
chainOutageSeenAtBlock: 0,
withdrawalsAndTransfersUnblockedAtBlock: 0
};
}

export const QueryGetWithdrawalAndTransfersBlockedInfoResponse = {
encode(message: QueryGetWithdrawalAndTransfersBlockedInfoResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.negativeTncSubaccountSeenAtBlock !== 0) {
writer.uint32(8).uint32(message.negativeTncSubaccountSeenAtBlock);
}

if (message.chainOutageSeenAtBlock !== 0) {
writer.uint32(16).uint32(message.chainOutageSeenAtBlock);
}

if (message.withdrawalsAndTransfersUnblockedAtBlock !== 0) {
writer.uint32(24).uint32(message.withdrawalsAndTransfersUnblockedAtBlock);
}

return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): QueryGetWithdrawalAndTransfersBlockedInfoResponse {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseQueryGetWithdrawalAndTransfersBlockedInfoResponse();

while (reader.pos < end) {
const tag = reader.uint32();

switch (tag >>> 3) {
case 1:
message.negativeTncSubaccountSeenAtBlock = reader.uint32();
break;

case 2:
message.chainOutageSeenAtBlock = reader.uint32();
break;

case 3:
message.withdrawalsAndTransfersUnblockedAtBlock = reader.uint32();
break;

default:
reader.skipType(tag & 7);
break;
}
}

return message;
},

fromPartial(object: DeepPartial<QueryGetWithdrawalAndTransfersBlockedInfoResponse>): QueryGetWithdrawalAndTransfersBlockedInfoResponse {
const message = createBaseQueryGetWithdrawalAndTransfersBlockedInfoResponse();
message.negativeTncSubaccountSeenAtBlock = object.negativeTncSubaccountSeenAtBlock ?? 0;
message.chainOutageSeenAtBlock = object.chainOutageSeenAtBlock ?? 0;
message.withdrawalsAndTransfersUnblockedAtBlock = object.withdrawalsAndTransfersUnblockedAtBlock ?? 0;
return message;
}

};
21 changes: 21 additions & 0 deletions proto/dydxprotocol/subaccounts/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ service Query {
returns (QuerySubaccountAllResponse) {
option (google.api.http).get = "/dydxprotocol/subaccounts/subaccount";
}

// Queries information about whether withdrawal and transfers are blocked, and
// if so which block they are re-enabled on.
rpc GetWithdrawalAndTransfersBlockedInfo(
QueryGetWithdrawalAndTransfersBlockedInfoRequest)
returns (QueryGetWithdrawalAndTransfersBlockedInfoResponse) {
option (google.api.http).get =
"/dydxprotocol/subaccounts/withdrawals_and_transfers_blocked_info";
}
}

// QueryGetSubaccountRequest is request type for the Query RPC method.
Expand All @@ -45,3 +54,15 @@ message QuerySubaccountAllResponse {
repeated Subaccount subaccount = 1 [ (gogoproto.nullable) = false ];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QueryGetWithdrawalAndTransfersBlockedInfoRequest is a request type for
// fetching information about whether withdrawals and transfers are blocked.
message QueryGetWithdrawalAndTransfersBlockedInfoRequest {}

// QueryGetWithdrawalAndTransfersBlockedInfoRequest is a response type for
// fetching information about whether withdrawals and transfers are blocked.
message QueryGetWithdrawalAndTransfersBlockedInfoResponse {
uint32 negative_tnc_subaccount_seen_at_block = 1;
uint32 chain_outage_seen_at_block = 2;
uint32 withdrawals_and_transfers_unblocked_at_block = 3;
}

0 comments on commit 9e091fd

Please sign in to comment.