Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
eliasmpw committed Dec 11, 2024
1 parent 9ae2455 commit 8334f53
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 17 deletions.
5 changes: 2 additions & 3 deletions packages/arch3-core/src/archwayclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { CosmWasmClient } from '@cosmjs/cosmwasm-stargate';
import { EncodeObject } from '@cosmjs/proto-signing';
import {
HttpEndpoint,
HttpBatchClient,
HttpBatchClientOptions,
CometClient,
connectComet,
Expand Down Expand Up @@ -47,11 +46,11 @@ export class ArchwayClient extends CosmWasmClient implements IArchwayQueryClient
}

/**
* Creates an instance by connecting to the given Tendermint/CometBFT RPC endpoint using an {@link HttpBatchClient} to batch
* Creates an instance by connecting to the given Tendermint/CometBFT RPC endpoint using an HttpBatchClient to batch
* multiple requests and reduce queries to the server.
*
* @param endpoint - String URL of the RPC endpoint to connect or an {@link HttpEndpoint} object.
* @param options - Optional configuration to control how the {@link HttpBatchClient} will batch requests.
* @param options - Optional configuration to control how the HttpBatchClient will batch requests.
* @returns An {@link ArchwayClient} connected to the endpoint.
*
* @remarks This factory method doesn't support WebSocket endpoints.
Expand Down
2 changes: 1 addition & 1 deletion packages/arch3-core/src/modules/authz/tx.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('Amino converter for /cosmos.authz.v1beta1.MsgGrant', () => {
expect(message).toStrictEqual(result);
});
});
describe('Grants generic authorization with /cosmos.authz.v1beta1.SendAuthorization', () => {
describe('Grants send authorization with /cosmos.authz.v1beta1.SendAuthorization', () => {
it('encodes and decodes back to the same value', () => {
const message = {
granter: granterAddress,
Expand Down
36 changes: 27 additions & 9 deletions packages/arch3-core/src/modules/authz/tx.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AminoConverters } from '@cosmjs/stargate';
import { AminoConverters, Coin } from '@cosmjs/stargate';
import { GenericAuthorization } from 'cosmjs-types/cosmos/authz/v1beta1/authz';
import { MsgGrant, MsgRevoke } from 'cosmjs-types/cosmos/authz/v1beta1/tx';
import { SendAuthorization } from 'cosmjs-types/cosmos/bank/v1beta1/authz';
Expand All @@ -14,11 +14,11 @@ export const createAuthzAminoConverters = (): AminoConverters => {
return {
[MsgGrant.typeUrl]: {
aminoType: 'cosmos-sdk/MsgGrant',
toAmino: ({ granter, grantee, grant }) => {
toAmino: ({ granter, grantee, grant }: MsgGrant) => {
if (!grant || !grant.authorization) {
throw new Error(`Unsupported grant type: '${grant?.authorization?.typeUrl}'`);
}
let authorizationValue;
let authorizationValue: { type: string; value: any };
switch (grant?.authorization?.typeUrl) {
case GenericAuthorization.typeUrl: {
const generic = GenericAuthorization.decode(grant.authorization.value);
Expand All @@ -35,7 +35,10 @@ export const createAuthzAminoConverters = (): AminoConverters => {
authorizationValue = {
type: 'cosmos-sdk/SendAuthorization',
value: {
// eslint-disable-next-line camelcase, @typescript-eslint/naming-convention
spend_limit: spend.spendLimit,
// eslint-disable-next-line camelcase, @typescript-eslint/naming-convention
allow_list: spend.allowList,
},
};
break;
Expand All @@ -57,15 +60,26 @@ export const createAuthzAminoConverters = (): AminoConverters => {
},
};
},
fromAmino: ({ granter, grantee, grant }) => {
fromAmino: ({
granter,
grantee,
grant,
}: {
granter: string;
grantee: string;
grant: {
authorization: { type: string; value: Record<string, unknown> };
expiration: { seconds: any; nanos: any } | undefined;
};
}) => {
const authorizationType = grant?.authorization?.type;
let authorizationValue;
let authorizationValue: { typeUrl: string; value: any };
switch (authorizationType) {
case 'cosmos-sdk/GenericAuthorization': {
authorizationValue = {
typeUrl: GenericAuthorization.typeUrl,
value: GenericAuthorization.encode({
msg: grant.authorization.value.msg,
msg: grant.authorization.value.msg as string,
}).finish(),
};
break;
Expand All @@ -75,7 +89,8 @@ export const createAuthzAminoConverters = (): AminoConverters => {
typeUrl: SendAuthorization.typeUrl,
value: SendAuthorization.encode(
SendAuthorization.fromPartial({
spendLimit: grant.authorization.value.spend_limit,
spendLimit: grant.authorization.value.spend_limit as Coin[],
allowList: grant.authorization.value.allow_list as string[] | undefined,
}),
).finish(),
};
Expand All @@ -96,16 +111,19 @@ export const createAuthzAminoConverters = (): AminoConverters => {
},
[MsgRevoke.typeUrl]: {
aminoType: 'cosmos-sdk/MsgRevoke',
toAmino: ({ granter, grantee, msgTypeUrl }) => {
toAmino: ({ granter, grantee, msgTypeUrl }: MsgRevoke) => {
return {
granter,
grantee,
// eslint-disable-next-line camelcase, @typescript-eslint/naming-convention
msg_type_url: msgTypeUrl,
};
},
fromAmino: ({ granter, grantee, msg_type_url }) => MsgRevoke.fromPartial({
// eslint-disable-next-line camelcase, @typescript-eslint/naming-convention
fromAmino: ({ granter, grantee, msg_type_url }: { granter: string; grantee: string; msg_type_url: string }) => MsgRevoke.fromPartial({
granter,
grantee,
// eslint-disable-next-line camelcase
msgTypeUrl: msg_type_url,
}),
},
Expand Down
8 changes: 4 additions & 4 deletions packages/arch3-core/src/signingarchwayclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
logs,
StdFee,
} from '@cosmjs/stargate';
import { CometClient, HttpBatchClient, HttpBatchClientOptions, connectComet } from '@cosmjs/tendermint-rpc';
import { CometClient, HttpBatchClientOptions, connectComet } from '@cosmjs/tendermint-rpc';
import { assertDefined } from '@cosmjs/utils';
import { SimulateResponse } from 'cosmjs-types/cosmos/tx/v1beta1/service';
import _ from 'lodash';
Expand Down Expand Up @@ -156,7 +156,7 @@ export class SigningArchwayClient extends SigningCosmWasmClient implements IArch
/**
* Creates an instance by connecting to the given Tendermint RPC endpoint.
*
* @param endpoint - String URL of the RPC endpoint to connect or an `HttpEndpoint` object.
* @param endpoint - String URL of the RPC endpoint to connect or an {@link HttpEndpoint} object.
* @param signer - The transaction signer configuration.
* @param options - Options for the signing client.
* @returns A {@link SigningArchwayClient} connected to the endpoint.
Expand All @@ -171,13 +171,13 @@ export class SigningArchwayClient extends SigningCosmWasmClient implements IArch
}

/**
* Creates an instance by connecting to the given Tendermint RPC endpoint using an {@link HttpBatchClient} to batch
* Creates an instance by connecting to the given Tendermint RPC endpoint using an HttpBatchClient to batch
* multiple requests and reduce queries to the server.
*
* @param endpoint - String URL of the RPC endpoint to connect or an {@link HttpEndpoint} object.
* @param signer - The transaction signer configuration.
* @param options - Options for the signing client.
* @param batchClientOptions - Optional configuration to control how the {@link HttpBatchClient} will batch requests.
* @param batchClientOptions - Optional configuration to control how the HttpBatchClient will batch requests.
* @returns A {@link SigningArchwayClient} connected to the endpoint.
*
* @remarks This factory method doesn't support WebSocket endpoints.
Expand Down
2 changes: 2 additions & 0 deletions packages/arch3-core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
*
* @param endpoint - String URL of the RPC endpoint to connect or an {@link HttpEndpoint} object.
* @param options - Optional configuration to control how the {@link HttpBatchClient} will batch requests.
*
* @returns A connected {@link CometClient}
*/
export async function connectCometWithBatchClient(
endpoint: string | HttpEndpoint,
Expand Down

0 comments on commit 8334f53

Please sign in to comment.