Skip to content

Commit

Permalink
sanity test: implement all queries
Browse files Browse the repository at this point in the history
  • Loading branch information
quaisx committed Jun 20, 2024
1 parent c78cd2a commit 3b7f521
Show file tree
Hide file tree
Showing 22 changed files with 906 additions and 45 deletions.
21 changes: 21 additions & 0 deletions src/query/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {
Query,
QueryConfigRequest,
QueryConfigResponse
} from "../grpc_gateway/cosmos/app/v1alpha1/query.pb"


export class AppQuerier {
constructor(private url: string) {}

config(
req: QueryConfigRequest,
headers?: HeadersInit,
): Promise<QueryConfigResponse> {
return Query.Config(req, {
headers,
pathPrefix: this.url,
});
}

}
88 changes: 86 additions & 2 deletions src/query/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,24 @@ import {
} from "../grpc_gateway/cosmos/auth/v1beta1/auth.pb";
import {
Query,
QueryAccountRequest,
QueryAccountsRequest,
QueryAccountsResponse,
QueryAccountRequest,
QueryAccountResponse,
QueryModuleAccountsRequest,
QueryModuleAccountsResponse,
QueryModuleAccountByNameRequest,
QueryModuleAccountByNameResponse,
Bech32PrefixRequest,
Bech32PrefixResponse,
AddressBytesToStringRequest,
AddressBytesToStringResponse,
AddressStringToBytesRequest,
AddressStringToBytesResponse,
QueryAccountAddressByIDRequest,
QueryAccountAddressByIDResponse,
QueryAccountInfoRequest,
QueryAccountInfoResponse,
QueryParamsRequest,
QueryParamsResponse,
} from "../grpc_gateway/cosmos/auth/v1beta1/query.pb";
Expand All @@ -19,7 +35,6 @@ import {
ContinuousVestingAccount,
DelayedVestingAccount,
} from "../grpc_gateway/cosmos/vesting/v1beta1/vesting.pb";
import { QueryModuleAccountByNameRequest } from "../protobuf/cosmos/auth/v1beta1/query";

export type Account = {
"@type":
Expand All @@ -34,6 +49,7 @@ export type Account = {
| DelayedVestingAccount
);


/** AuthQuerier is the query interface for the x/auth module */
export class AuthQuerier {
constructor(private url: string) {}
Expand Down Expand Up @@ -73,6 +89,17 @@ export class AuthQuerier {
});
}

async moduleAccounts(
req: QueryModuleAccountsRequest,
headers?: HeadersInit,
): Promise<QueryModuleAccountsResponse> {
//@ts-ignore
return Query.ModuleAccounts(req, {
headers,
pathPrefix: this.url,
});
}

async moduleAccountByName(
req: QueryModuleAccountByNameRequest,
headers?: HeadersInit,
Expand All @@ -83,4 +110,61 @@ export class AuthQuerier {
pathPrefix: this.url,
});
}


async bech32Prefix(
req: Bech32PrefixRequest,
headers?: HeadersInit,
): Promise<Bech32PrefixResponse> {
//@ts-ignore
return Query.Bech32Prefix(req, {
headers,
pathPrefix: this.url,
});
}

async addressBytesToString(
req: AddressBytesToStringRequest,
headers?: HeadersInit,
): Promise<AddressBytesToStringResponse> {
//@ts-ignore
return Query.AddressBytesToString(req, {
headers,
pathPrefix: this.url,
});
}

async addressStringToBytes(
req: AddressStringToBytesRequest,
headers?: HeadersInit,
): Promise<AddressStringToBytesResponse> {
//@ts-ignore
return Query.AddressStringToBytes(req, {
headers,
pathPrefix: this.url,
});
}

async accountAddressByID(
req: QueryAccountAddressByIDRequest,
headers?: HeadersInit,
): Promise<QueryAccountAddressByIDResponse> {
//@ts-ignore
return Query.AccountAddressByID(req, {
headers,
pathPrefix: this.url,
});
}

async accountInfo(
req: QueryAccountInfoRequest,
headers?: HeadersInit,
): Promise<QueryAccountInfoResponse> {
//@ts-ignore
return Query.AccountInfo(req, {
headers,
pathPrefix: this.url,
});
}

}
19 changes: 19 additions & 0 deletions src/query/autocli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {
Query,
AppOptionsRequest,
AppOptionsResponse,
} from "../grpc_gateway/cosmos/autocli/v1/query.pb";

export class AutoCliQuerier {
constructor(private url: string) {}

appOptions(
req: AppOptionsRequest,
headers?: HeadersInit,
): Promise<AppOptionsResponse> {
return Query.AppOptions(req, {
headers,
pathPrefix: this.url,
});
}
}
61 changes: 61 additions & 0 deletions src/query/bank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,72 @@ import {
QuerySupplyOfResponse,
QueryTotalSupplyRequest,
QueryTotalSupplyResponse,
QuerySpendableBalanceByDenomRequest,
QuerySpendableBalanceByDenomResponse,
QueryDenomMetadataByQueryStringRequest,
QueryDenomMetadataByQueryStringResponse,
QueryDenomOwnersRequest,
QueryDenomOwnersResponse,
QueryDenomOwnersByQueryRequest,
QueryDenomOwnersByQueryResponse,
QuerySendEnabledRequest,
QuerySendEnabledResponse,
} from "../grpc_gateway/cosmos/bank/v1beta1/query.pb";


export class BankQuerier {
constructor(private url: string) {}

spendableBalanceByDenom(
req: QuerySpendableBalanceByDenomRequest,
headers?: HeadersInit,
): Promise<QuerySpendableBalanceByDenomResponse> {
return Query.SpendableBalanceByDenom(req, {
headers,
pathPrefix: this.url,
});
}

denomMetadataByQueryString(
req: QueryDenomMetadataByQueryStringRequest,
headers?: HeadersInit,
): Promise<QueryDenomMetadataByQueryStringResponse> {
return Query.DenomMetadataByQueryString(req, {
headers,
pathPrefix: this.url,
});
}

denomOwners(
req: QueryDenomOwnersRequest,
headers?: HeadersInit,
): Promise<QueryDenomOwnersResponse> {
return Query.DenomOwners(req, {
headers,
pathPrefix: this.url,
});
}

sendEnabled(
req: QuerySendEnabledRequest,
headers?: HeadersInit,
): Promise<QuerySendEnabledResponse> {
return Query.SendEnabled(req, {
headers,
pathPrefix: this.url,
});
}

denomOwnersByQuery(
req: QueryDenomOwnersByQueryRequest,
headers?: HeadersInit,
): Promise<QueryDenomOwnersByQueryResponse> {
return Query.DenomOwnersByQuery(req, {
headers,
pathPrefix: this.url,
});
}

balance(
req: QueryBalanceRequest,
headers?: HeadersInit,
Expand Down
44 changes: 44 additions & 0 deletions src/query/circuit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import {
Query,
QueryAccountRequest,
AccountResponse,
QueryAccountsRequest,
AccountsResponse,
QueryDisabledListRequest,
DisabledListResponse,

} from "../grpc_gateway/cosmos/circuit/v1/query.pb";

export class CircuitQuerier {
constructor(private url: string) {}

account(
req: QueryAccountRequest,
headers?: HeadersInit,
): Promise<AccountResponse> {
return Query.Account(req, {
headers,
pathPrefix: this.url,
});
}

accounts(
req: QueryAccountsRequest,
headers?: HeadersInit,
): Promise<AccountsResponse> {
return Query.Accounts(req, {
headers,
pathPrefix: this.url,
});
}

disabledList(
req: QueryDisabledListRequest,
headers?: HeadersInit,
): Promise<DisabledListResponse> {
return Query.DisabledList(req, {
headers,
pathPrefix: this.url,
});
}
}
12 changes: 12 additions & 0 deletions src/query/distribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {
QueryValidatorOutstandingRewardsResponse,
QueryValidatorSlashesRequest,
QueryValidatorSlashesResponse,
QueryValidatorDistributionInfoRequest,
QueryValidatorDistributionInfoResponse,
} from "../grpc_gateway/cosmos/distribution/v1beta1/query.pb";

export class DistributionQuerier {
Expand Down Expand Up @@ -148,4 +150,14 @@ export class DistributionQuerier {
pathPrefix: this.url,
});
}

validatorDistributionInfo(
req: QueryValidatorDistributionInfoRequest,
headers?: HeadersInit,
): Promise<QueryValidatorDistributionInfoResponse> {
return Query.ValidatorDistributionInfo(req, {
headers,
pathPrefix: this.url,
});
}
}
16 changes: 16 additions & 0 deletions src/query/gov.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,25 @@ import {
QueryVotesResponse,
} from "../grpc_gateway/cosmos/gov/v1beta1/query.pb";

// import {
// Query as QueryV1,
// QueryConstitutionRequest,
// QueryConstitutionResponse
// } from "../grpc_gateway/cosmos/gov/v1/query.pb"

export class GovQuerier {
constructor(private url: string) {}

// constitution(
// req: QueryConstitutionRequest,
// headers?: HeadersInit,
// ): Promise<QueryConstitutionResponse> {
// return QueryV1.Constitution(req, {
// headers,
// pathPrefix: this.url,
// });
// }

proposal(
req: QueryProposalRequest,
headers?: HeadersInit,
Expand Down
Loading

0 comments on commit 3b7f521

Please sign in to comment.