Skip to content

Commit

Permalink
remove some rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Vritra4 committed Jul 30, 2024
1 parent 2d99c9f commit 47a8573
Show file tree
Hide file tree
Showing 17 changed files with 63 additions and 48 deletions.
11 changes: 6 additions & 5 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ export default tseslint.config(
},
rules: {
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/unbound-method': [
"error",
{
"ignoreStatic": true
}
],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/require-await': 'off',
}
},
{
Expand Down
8 changes: 4 additions & 4 deletions src/client/WebSocketClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ export class WebSocketClient extends EventEmitter {

if (
this.callback &&
parsedData.result &&
parsedData.result.query === this.queryParams
parsedData.result && // eslint-disable-line @typescript-eslint/no-unsafe-member-access
parsedData.result.query === this.queryParams // eslint-disable-line @typescript-eslint/no-unsafe-member-access
) {
// this.emit('message', parsedData.result.data);
this.callback(parsedData.result.data)
this.callback(parsedData.result.data) // eslint-disable-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
}
} catch (err) {
this.emit('error', err)
Expand Down Expand Up @@ -248,7 +248,7 @@ export class WebSocketClient extends EventEmitter {

public subscribeTx(query: TendermintQuery, callback: Callback): void {
const newCallback: Callback = (d) => {
d.value.TxResult.txhash = hashToHex(d.value.TxResult.tx)
d.value.TxResult.txhash = hashToHex(d.value.TxResult.tx as string) // eslint-disable-line @typescript-eslint/no-unsafe-member-access
return callback(d)
}

Expand Down
4 changes: 2 additions & 2 deletions src/client/lcd/api/TxAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,11 +479,11 @@ export class TxAPI extends BaseAPI {
}

if (d.code) {
blockResult.code = d.code
blockResult.code = d.code // eslint-disable-line @typescript-eslint/no-unsafe-member-access
}

if (d.codespace) {
blockResult.codespace = d.codespace
blockResult.codespace = d.codespace // eslint-disable-line @typescript-eslint/no-unsafe-member-access
}

return blockResult
Expand Down
2 changes: 1 addition & 1 deletion src/core/authz/msgs/MsgExecAuthorized.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class MsgExecAuthorized extends JSONSerializable<
type: 'cosmos-sdk/MsgExec',
value: {
grantee,
msgs: msgs.map((msg) => {
msgs: msgs.map((msg): Msg.Amino => {
return msg.toAmino()
}),
},
Expand Down
2 changes: 1 addition & 1 deletion src/core/gov/msgs/MsgSubmitProposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class MsgSubmitProposal extends JSONSerializable<
return {
type: 'cosmos-sdk/v1/MsgSubmitProposal',
value: {
messages: messages.map((msg) => msg.toAmino()),
messages: messages.map((msg): Msg.Amino => msg.toAmino()),
initial_deposit: initial_deposit.toAmino(),
proposer,
metadata: metadata && metadata !== '' ? metadata : undefined,
Expand Down
18 changes: 9 additions & 9 deletions src/core/gov/msgs/MsgSubmitProposalLegacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class MsgSubmitProposalLegacy extends JSONSerializable<
* @param proposer proposer's account address
*/
constructor(
public content: Content,
public content: Content | undefined,
initial_deposit: Coins.Input,
public proposer: AccAddress
) {
Expand All @@ -36,7 +36,7 @@ export class MsgSubmitProposalLegacy extends JSONSerializable<
value: { content, initial_deposit, proposer },
} = data
return new MsgSubmitProposalLegacy(
Content.fromAmino(content),
content ? Content.fromAmino(content) : undefined,
Coins.fromAmino(initial_deposit),
proposer
)
Expand All @@ -47,7 +47,7 @@ export class MsgSubmitProposalLegacy extends JSONSerializable<
return {
type: 'cosmos-sdk/MsgSubmitProposal',
value: {
content: content.toAmino(),
content: content?.toAmino(),
initial_deposit: initial_deposit.toAmino(),
proposer,
},
Expand All @@ -59,7 +59,7 @@ export class MsgSubmitProposalLegacy extends JSONSerializable<
): MsgSubmitProposalLegacy {
const { content, initial_deposit, proposer } = data
return new MsgSubmitProposalLegacy(
Content.fromData(content),
content ? Content.fromData(content) : undefined,
Coins.fromData(initial_deposit),
proposer
)
Expand All @@ -69,7 +69,7 @@ export class MsgSubmitProposalLegacy extends JSONSerializable<
const { content, initial_deposit, proposer } = this
return {
'@type': '/cosmos.gov.v1beta1.MsgSubmitProposal',
content: content.toData(),
content: content?.toData(),
initial_deposit: initial_deposit.toData(),
proposer,
}
Expand All @@ -79,7 +79,7 @@ export class MsgSubmitProposalLegacy extends JSONSerializable<
proto: MsgSubmitProposalLegacy.Proto
): MsgSubmitProposalLegacy {
return new MsgSubmitProposalLegacy(
Content.fromProto(proto.content as any),
proto.content ? Content.fromProto(proto.content) : undefined,
Coins.fromProto(proto.initialDeposit),
proto.proposer
)
Expand All @@ -88,7 +88,7 @@ export class MsgSubmitProposalLegacy extends JSONSerializable<
public toProto(): MsgSubmitProposalLegacy.Proto {
const { content, initial_deposit, proposer } = this
return MsgSubmitProposal_pb.fromPartial({
content: content.packAny(),
content: content?.packAny(),
initialDeposit: initial_deposit.toProto(),
proposer,
})
Expand All @@ -112,15 +112,15 @@ export namespace MsgSubmitProposalLegacy {
export interface Amino {
type: 'cosmos-sdk/MsgSubmitProposal'
value: {
content: Content.Amino
content: Content.Amino | undefined
initial_deposit: Coins.Amino
proposer: AccAddress
}
}

export interface Data {
'@type': '/cosmos.gov.v1beta1.MsgSubmitProposal'
content: Content.Data
content: Content.Data | undefined
initial_deposit: Coins.Data
proposer: AccAddress
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/gov/proposals/Proposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class Proposal extends JSONSerializable<

return {
id: id.toString(),
messages: messages.map((msg) => msg.toAmino()),
messages: messages.map((msg): Msg.Amino => msg.toAmino()),
status: proposalStatusToJSON(status),
final_tally_result: {
yes_count: num(final_tally_result.yes_count).toFixed(),
Expand Down
2 changes: 1 addition & 1 deletion src/core/group/GroupProposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export class GroupProposal extends JSONSerializable<
},
voting_period_end: voting_period_end.toISOString(),
executor_result: proposalExecutorResultToJSON(executor_result),
messages: messages.map((msg) => msg.toAmino()),
messages: messages.map((msg): Msg.Amino => msg.toAmino()),
title,
summary,
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/group/msgs/MsgSubmitGroupProposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class MsgSubmitGroupProposal extends JSONSerializable<
group_policy_address,
proposers,
metadata,
messages: messages.map((msg) => msg.toAmino()),
messages: messages.map((msg): Msg.Amino => msg.toAmino()),
exec: execToJSON(exec),
title,
summary,
Expand Down
6 changes: 3 additions & 3 deletions src/core/ibc/core/connection/msgs/MsgConnectionOpenTry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class MsgConnectionOpenTry extends JSONSerializable<
*/
constructor(
public client_id: string,
public client_state: any,
public client_state: Any | undefined,
public counterparty: ConnectionCounterparty | undefined,
public delay_period: number,
public counterparty_versions: IbcVersion[],
Expand Down Expand Up @@ -152,7 +152,7 @@ export class MsgConnectionOpenTry extends JSONSerializable<
} = this
return MsgConnectionOpenTry_pb.fromPartial({
clientId: client_id,
clientState: client_state.toProto(),
clientState: client_state,
counterparty: counterparty?.toProto(),
delayPeriod: Long.fromNumber(delay_period),
counterpartyVersions: counterparty_versions.map((cv) => cv.toProto()),
Expand Down Expand Up @@ -183,7 +183,7 @@ export namespace MsgConnectionOpenTry {
export interface Data {
'@type': '/ibc.core.connection.v1.MsgConnectionOpenTry'
client_id: string
client_state: Any
client_state?: Any
counterparty?: ConnectionCounterparty.Data
delay_period: string
counterparty_versions: IbcVersion.Data[]
Expand Down
26 changes: 17 additions & 9 deletions src/core/intertx/msgs/MsgSubmitTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class MsgSubmitTx extends JSONSerializable<
constructor(
public owner: AccAddress,
public connection_id: string,
public msg: Msg
public msg?: Msg
) {
super()
}
Expand All @@ -27,7 +27,11 @@ export class MsgSubmitTx extends JSONSerializable<
value: { owner, connection_id, msg },
} = data

return new MsgSubmitTx(owner, connection_id, Msg.fromAmino(msg))
return new MsgSubmitTx(
owner,
connection_id,
msg ? Msg.fromAmino(msg) : undefined
)
}

public toAmino(): MsgSubmitTx.Amino {
Expand All @@ -37,14 +41,18 @@ export class MsgSubmitTx extends JSONSerializable<
value: {
owner,
connection_id,
msg: msg.toAmino(),
msg: msg?.toAmino(),
},
}
}

public static fromData(data: MsgSubmitTx.Data): MsgSubmitTx {
const { owner, connection_id, msg } = data
return new MsgSubmitTx(owner, connection_id, Msg.fromData(msg))
return new MsgSubmitTx(
owner,
connection_id,
msg ? Msg.fromData(msg) : undefined
)
}

public toData(): MsgSubmitTx.Data {
Expand All @@ -53,15 +61,15 @@ export class MsgSubmitTx extends JSONSerializable<
'@type': '/initia.intertx.v1.MsgSubmitTx',
owner,
connection_id,
msg: msg.toData(),
msg: msg?.toData(),
}
}

public static fromProto(proto: MsgSubmitTx.Proto): MsgSubmitTx {
return new MsgSubmitTx(
proto.owner,
proto.connectionId,
Msg.fromProto(proto.msg as any)
proto.msg ? Msg.fromProto(proto.msg) : undefined
)
}

Expand All @@ -70,7 +78,7 @@ export class MsgSubmitTx extends JSONSerializable<
return MsgSubmitTx_pb.fromPartial({
owner,
connectionId: connection_id,
msg: msg.packAny(),
msg: msg?.packAny(),
})
}

Expand All @@ -92,15 +100,15 @@ export namespace MsgSubmitTx {
value: {
owner: AccAddress
connection_id: string
msg: Msg.Amino
msg?: Msg.Amino
}
}

export interface Data {
'@type': '/initia.intertx.v1.MsgSubmitTx'
owner: AccAddress
connection_id: string
msg: Msg.Data
msg?: Msg.Data
}

export type Proto = MsgSubmitTx_pb
Expand Down
2 changes: 1 addition & 1 deletion src/core/opchild/msgs/MsgExecuteMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class MsgExecuteMessages extends JSONSerializable<
type: 'opchild/MsgExecuteMessages',
value: {
sender,
messages: messages.map((msg) => msg.toAmino()),
messages: messages.map((msg): Msg.Amino => msg.toAmino()),
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/tx/SignDoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class SignDoc extends JSONSerializable<
? timeout_height.toString()
: undefined,
fee: fee.toAmino(),
msgs: messages.map((m) => m.toAmino()),
msgs: messages.map((m): Msg.Amino => m.toAmino()),
memo: memo ?? '',
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/key/RawKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class RawKey extends Key {
return new RawKey(Buffer.from(hex, 'hex'))
}

// eslint-disable-next-line @typescript-eslint/require-await
public async sign(payload: Buffer): Promise<Buffer> {
const hash = Buffer.from(
SHA256.hash(new Word32Array(payload)).toString(),
Expand All @@ -42,6 +43,7 @@ export class RawKey extends Key {
return Buffer.from(signature)
}

// eslint-disable-next-line @typescript-eslint/require-await
public async signWithKeccak256(payload: Buffer): Promise<Buffer> {
const hash = keccak256(payload)

Expand Down
6 changes: 4 additions & 2 deletions src/key/ledger/LedgerKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,23 @@ export class LedgerKey extends Key {
return this
}

// eslint-disable-next-line @typescript-eslint/require-await
public async sign(message: Buffer): Promise<Buffer> {
if (!this.publicKey) {
await this.loadAccountDetails()
}
const res = await this.app.sign(this.path, message)
checkLedgerErrors(res)

return Buffer.from(signatureImport(Buffer.from(res.signature as any)))
return Buffer.from(signatureImport(Buffer.from(res.signature as any))) // eslint-disable-line @typescript-eslint/no-unsafe-argument
}

// eslint-disable-next-line @typescript-eslint/require-await
public async signWithKeccak256(): Promise<Buffer> {
throw new Error('LedgerKey does not support signWithKeccak256()')
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
// eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/require-await
public async createSignature(_tx: SignDoc): Promise<SignatureV2> {
throw new Error('direct sign mode is not supported')
}
Expand Down
8 changes: 4 additions & 4 deletions src/key/ledger/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ function processErrorResponse(response: any) {
if (isDict(response)) {
if (Object.prototype.hasOwnProperty.call(response, 'statusCode')) {
return {
return_code: response.statusCode,
error_message: errorCodeToString(response.statusCode),
return_code: response.statusCode, // eslint-disable-line @typescript-eslint/no-unsafe-member-access
error_message: errorCodeToString(response.statusCode as number), // eslint-disable-line @typescript-eslint/no-unsafe-member-access
}
}

Expand All @@ -53,13 +53,13 @@ function processErrorResponse(response: any) {

return {
return_code: 0xffff,
error_message: response.toString(),
error_message: response.toString(), // eslint-disable-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
}
}

return {
return_code: 0xffff,
error_message: response.toString(),
error_message: response.toString(), // eslint-disable-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
}
}

Expand Down
Loading

0 comments on commit 47a8573

Please sign in to comment.