Skip to content

Commit

Permalink
feat: tf denoms from admin (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmorency authored Dec 11, 2024
1 parent 8790e9e commit 3df6d56
Show file tree
Hide file tree
Showing 21 changed files with 325 additions and 15 deletions.
20 changes: 20 additions & 0 deletions proto/osmosis/tokenfactory/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ service Query {
option (google.api.http).get =
"/osmosis/tokenfactory/v1beta1/denoms_from_creator/{creator}";
}

// DenomsFromAdmin defines a gRPC query method for fetching all
// denominations owned by a specific admin.
rpc DenomsFromAdmin(QueryDenomsFromAdminRequest)
returns (QueryDenomsFromAdminResponse) {
option (google.api.http).get =
"/osmosis/tokenfactory/v1beta1/denoms_from_admin/{admin}";
}
}

// QueryParamsRequest is the request type for the Query/Params RPC method.
Expand Down Expand Up @@ -69,3 +77,15 @@ message QueryDenomsFromCreatorRequest {
message QueryDenomsFromCreatorResponse {
repeated string denoms = 1 [ (gogoproto.moretags) = "yaml:\"denoms\"" ];
}

// QueryDenomsFromAdminRequest defines the request structure for the
// DenomsFromAdmin gRPC query.
message QueryDenomsFromAdminRequest {
string admin = 1 [ (gogoproto.moretags) = "yaml:\"admin\"" ];
}

// QueryDenomsFromAdminRequest defines the response structure for the
// DenomsFromAdmin gRPC query.
message QueryDenomsFromAdminResponse {
repeated string denoms = 1 [ (gogoproto.moretags) = "yaml:\"denoms\"" ];
}
2 changes: 1 addition & 1 deletion src/codegen/binary.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].6
* This file and any referenced files were automatically generated by @cosmology/[email protected].8
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/extern.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].6
* This file and any referenced files were automatically generated by @cosmology/[email protected].8
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
6 changes: 5 additions & 1 deletion src/codegen/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].6
* This file and any referenced files were automatically generated by @cosmology/[email protected].8
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down Expand Up @@ -198,6 +198,10 @@ export interface Rpc {
): Promise<Uint8Array>;
}

export function isRpc(rpc: unknown): rpc is Rpc {
return rpc !== null && rpc !== undefined && typeof (rpc as Rpc).request === 'function';
}

interface Timestamp {
/**
* Represents seconds of UTC time since Unix epoch
Expand Down
2 changes: 2 additions & 0 deletions src/codegen/ibc/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export const ibcAminoConverters = {
export const ibcProtoRegistry: ReadonlyArray<[string, GeneratedType]> = [...ibcApplicationsTransferV1TxRegistry.registry, ...ibcCoreChannelV1TxRegistry.registry, ...ibcCoreClientV1TxRegistry.registry, ...ibcCoreConnectionV1TxRegistry.registry];
export const getSigningIbcClientOptions = ({
defaultTypes = defaultRegistryTypes
}: {
defaultTypes?: ReadonlyArray<[string, GeneratedType]>;
} = {}): {
registry: Registry;
aminoTypes: AminoTypes;
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].6
* This file and any referenced files were automatically generated by @cosmology/[email protected].8
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/json-safe.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].6
* This file and any referenced files were automatically generated by @cosmology/[email protected].8
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/codegen/liftedinit/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export const liftedinitAminoConverters = {
export const liftedinitProtoRegistry: ReadonlyArray<[string, GeneratedType]> = [...liftedinitManifestV1TxRegistry.registry];
export const getSigningLiftedinitClientOptions = ({
defaultTypes = defaultRegistryTypes
}: {
defaultTypes?: ReadonlyArray<[string, GeneratedType]>;
} = {}): {
registry: Registry;
aminoTypes: AminoTypes;
Expand Down
2 changes: 2 additions & 0 deletions src/codegen/osmosis/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export const osmosisAminoConverters = {
export const osmosisProtoRegistry: ReadonlyArray<[string, GeneratedType]> = [...osmosisTokenfactoryV1beta1TxRegistry.registry];
export const getSigningOsmosisClientOptions = ({
defaultTypes = defaultRegistryTypes
}: {
defaultTypes?: ReadonlyArray<[string, GeneratedType]>;
} = {}): {
registry: Registry;
aminoTypes: AminoTypes;
Expand Down
8 changes: 7 additions & 1 deletion src/codegen/osmosis/tokenfactory/v1beta1/query.lcd.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LCDClient } from "@cosmology/lcd";
import { QueryParamsRequest, QueryParamsResponseSDKType, QueryDenomAuthorityMetadataRequest, QueryDenomAuthorityMetadataResponseSDKType, QueryDenomsFromCreatorRequest, QueryDenomsFromCreatorResponseSDKType } from "./query";
import { QueryParamsRequest, QueryParamsResponseSDKType, QueryDenomAuthorityMetadataRequest, QueryDenomAuthorityMetadataResponseSDKType, QueryDenomsFromCreatorRequest, QueryDenomsFromCreatorResponseSDKType, QueryDenomsFromAdminRequest, QueryDenomsFromAdminResponseSDKType } from "./query";
export class LCDQueryClient {
req: LCDClient;
constructor({
Expand Down Expand Up @@ -27,4 +27,10 @@ export class LCDQueryClient {
const endpoint = `osmosis/tokenfactory/v1beta1/denoms_from_creator/${params.creator}`;
return await this.req.get<QueryDenomsFromCreatorResponseSDKType>(endpoint);
};
/* DenomsFromAdmin defines a gRPC query method for fetching all
denominations owned by a specific admin. */
denomsFromAdmin = async (params: QueryDenomsFromAdminRequest): Promise<QueryDenomsFromAdminResponseSDKType> => {
const endpoint = `osmosis/tokenfactory/v1beta1/denoms_from_admin/${params.admin}`;
return await this.req.get<QueryDenomsFromAdminResponseSDKType>(endpoint);
};
}
17 changes: 16 additions & 1 deletion src/codegen/osmosis/tokenfactory/v1beta1/query.rpc.Query.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TxRpc } from "../../../types";
import { BinaryReader } from "../../../binary";
import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate";
import { QueryParamsRequest, QueryParamsResponse, QueryDenomAuthorityMetadataRequest, QueryDenomAuthorityMetadataResponse, QueryDenomsFromCreatorRequest, QueryDenomsFromCreatorResponse } from "./query";
import { QueryParamsRequest, QueryParamsResponse, QueryDenomAuthorityMetadataRequest, QueryDenomAuthorityMetadataResponse, QueryDenomsFromCreatorRequest, QueryDenomsFromCreatorResponse, QueryDenomsFromAdminRequest, QueryDenomsFromAdminResponse } from "./query";
/** Query defines the gRPC querier service. */
export interface Query {
/**
Expand All @@ -19,6 +19,11 @@ export interface Query {
* denominations created by a specific admin/creator.
*/
denomsFromCreator(request: QueryDenomsFromCreatorRequest): Promise<QueryDenomsFromCreatorResponse>;
/**
* DenomsFromAdmin defines a gRPC query method for fetching all
* denominations owned by a specific admin.
*/
denomsFromAdmin(request: QueryDenomsFromAdminRequest): Promise<QueryDenomsFromAdminResponse>;
}
export class QueryClientImpl implements Query {
private readonly rpc: TxRpc;
Expand Down Expand Up @@ -46,6 +51,13 @@ export class QueryClientImpl implements Query {
const promise = this.rpc.request("osmosis.tokenfactory.v1beta1.Query", "DenomsFromCreator", data);
return promise.then(data => QueryDenomsFromCreatorResponse.decode(new BinaryReader(data)));
};
/* DenomsFromAdmin defines a gRPC query method for fetching all
denominations owned by a specific admin. */
denomsFromAdmin = async (request: QueryDenomsFromAdminRequest): Promise<QueryDenomsFromAdminResponse> => {
const data = QueryDenomsFromAdminRequest.encode(request).finish();
const promise = this.rpc.request("osmosis.tokenfactory.v1beta1.Query", "DenomsFromAdmin", data);
return promise.then(data => QueryDenomsFromAdminResponse.decode(new BinaryReader(data)));
};
}
export const createRpcQueryExtension = (base: QueryClient) => {
const rpc = createProtobufRpcClient(base);
Expand All @@ -59,6 +71,9 @@ export const createRpcQueryExtension = (base: QueryClient) => {
},
denomsFromCreator(request: QueryDenomsFromCreatorRequest): Promise<QueryDenomsFromCreatorResponse> {
return queryService.denomsFromCreator(request);
},
denomsFromAdmin(request: QueryDenomsFromAdminRequest): Promise<QueryDenomsFromAdminResponse> {
return queryService.denomsFromAdmin(request);
}
};
};
Loading

0 comments on commit 3df6d56

Please sign in to comment.