Skip to content

Commit

Permalink
Simpify queries code with object property shorthand
Browse files Browse the repository at this point in the history
  • Loading branch information
twhy committed Mar 1, 2024
1 parent 11ce122 commit c049089
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 69 deletions.
2 changes: 1 addition & 1 deletion packages/stargate/src/modules/auth/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function setupAuthExtension(base: QueryClient): AuthExtension {
return {
auth: {
account: async (address: string) => {
const { account } = await queryService.Account({ address: address });
const { account } = await queryService.Account({ address });
return account ?? null;
},
},
Expand Down
10 changes: 5 additions & 5 deletions packages/stargate/src/modules/authz/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ export function setupAuthzExtension(base: QueryClient): AuthzExtension {
authz: {
grants: async (granter: string, grantee: string, msgTypeUrl: string, paginationKey?: Uint8Array) => {
return await queryService.Grants({
granter: granter,
grantee: grantee,
msgTypeUrl: msgTypeUrl,
granter,
grantee,
msgTypeUrl,
pagination: createPagination(paginationKey),
});
},
granteeGrants: async (grantee: string, paginationKey?: Uint8Array) => {
return await queryService.GranteeGrants({
grantee: grantee,
grantee,
pagination: createPagination(paginationKey),
});
},
granterGrants: async (granter: string, paginationKey?: Uint8Array) => {
return await queryService.GranterGrants({
granter: granter,
granter,
pagination: createPagination(paginationKey),
});
},
Expand Down
8 changes: 3 additions & 5 deletions packages/stargate/src/modules/bank/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ export function setupBankExtension(base: QueryClient): BankExtension {
return {
bank: {
balance: async (address: string, denom: string) => {
const { balance } = await queryService.Balance({ address: address, denom: denom });
const { balance } = await queryService.Balance({ address, denom });
assert(balance);
return balance;
},
allBalances: async (address: string) => {
const { balances } = await queryService.AllBalances(
QueryAllBalancesRequest.fromPartial({ address: address }),
);
const { balances } = await queryService.AllBalances(QueryAllBalancesRequest.fromPartial({ address }));
return balances;
},
totalSupply: async (paginationKey?: Uint8Array) => {
Expand All @@ -48,7 +46,7 @@ export function setupBankExtension(base: QueryClient): BankExtension {
return response;
},
supplyOf: async (denom: string) => {
const { amount } = await queryService.SupplyOf({ denom: denom });
const { amount } = await queryService.SupplyOf({ denom });
assert(amount);
return amount;
},
Expand Down
16 changes: 8 additions & 8 deletions packages/stargate/src/modules/distribution/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,26 @@ export function setupDistributionExtension(base: QueryClient): DistributionExten
},
delegationRewards: async (delegatorAddress: string, validatorAddress: string) => {
const response = await queryService.DelegationRewards({
delegatorAddress: delegatorAddress,
validatorAddress: validatorAddress,
delegatorAddress,
validatorAddress,
});
return response;
},
delegationTotalRewards: async (delegatorAddress: string) => {
const response = await queryService.DelegationTotalRewards({
delegatorAddress: delegatorAddress,
delegatorAddress,
});
return response;
},
delegatorValidators: async (delegatorAddress: string) => {
const response = await queryService.DelegatorValidators({
delegatorAddress: delegatorAddress,
delegatorAddress,
});
return response;
},
delegatorWithdrawAddress: async (delegatorAddress: string) => {
const response = await queryService.DelegatorWithdrawAddress({
delegatorAddress: delegatorAddress,
delegatorAddress,
});
return response;
},
Expand All @@ -81,13 +81,13 @@ export function setupDistributionExtension(base: QueryClient): DistributionExten
},
validatorCommission: async (validatorAddress: string) => {
const response = await queryService.ValidatorCommission({
validatorAddress: validatorAddress,
validatorAddress,
});
return response;
},
validatorOutstandingRewards: async (validatorAddress: string) => {
const response = await queryService.ValidatorOutstandingRewards({
validatorAddress: validatorAddress,
validatorAddress,
});
return response;
},
Expand All @@ -98,7 +98,7 @@ export function setupDistributionExtension(base: QueryClient): DistributionExten
paginationKey?: Uint8Array,
) => {
const response = await queryService.ValidatorSlashes({
validatorAddress: validatorAddress,
validatorAddress,
startingHeight: BigInt(startingHeight),
endingHeight: BigInt(endingHeight),
pagination: createPagination(paginationKey),
Expand Down
6 changes: 3 additions & 3 deletions packages/stargate/src/modules/feegrant/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ export function setupFeegrantExtension(base: QueryClient): FeegrantExtension {
feegrant: {
allowance: async (granter: string, grantee: string) => {
const response = await queryService.Allowance({
granter: granter,
grantee: grantee,
granter,
grantee,
});
return response;
},
allowances: async (grantee: string, paginationKey?: Uint8Array) => {
const response = await queryService.Allowances({
grantee: grantee,
grantee,
pagination: createPagination(paginationKey),
});
return response;
Expand Down
Loading

0 comments on commit c049089

Please sign in to comment.