From 2bc381650e5e9db843e00b536ad4fd0cb63c490c Mon Sep 17 00:00:00 2001 From: Ankush263 Date: Fri, 16 Jun 2023 21:32:44 +0530 Subject: [PATCH 1/3] fix typo --- src.ts/contract/contract.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src.ts/contract/contract.ts b/src.ts/contract/contract.ts index 4157121631..6b224f7536 100644 --- a/src.ts/contract/contract.ts +++ b/src.ts/contract/contract.ts @@ -662,7 +662,7 @@ export class BaseContract implements Addressable, EventEmitterable Date: Sat, 17 Jun 2023 10:22:32 +0530 Subject: [PATCH 2/3] fix types of indexed & result --- src.ts/abi/fragments.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src.ts/abi/fragments.ts b/src.ts/abi/fragments.ts index aa824010da..11fa484337 100644 --- a/src.ts/abi/fragments.ts +++ b/src.ts/abi/fragments.ts @@ -825,7 +825,7 @@ export class ParamType { comps = null; } - let indexed = null; + let indexed: null | boolean = null; const keywords = consumeKeywords(obj, KwModifiers); if (keywords.has("indexed")) { if (!allowIndexed) { throw new Error(""); } @@ -1061,7 +1061,7 @@ export class ErrorFragment extends NamedFragment { }); } - const result = [ ]; + const result: any = [ ]; if (format !== "sighash") { result.push("error"); } result.push(this.name + joinParams(format, this.inputs)); return result.join(" "); @@ -1136,7 +1136,7 @@ export class EventFragment extends NamedFragment { }); } - const result = [ ]; + const result: any = [ ]; if (format !== "sighash") { result.push("event"); } result.push(this.name + joinParams(format, this.inputs)); if (format !== "sighash" && this.anonymous) { result.push("anonymous"); } @@ -1435,7 +1435,7 @@ export class FunctionFragment extends NamedFragment { }); } - const result = []; + const result: any = []; if (format !== "sighash") { result.push("function"); } From 2e60678eeac514764b4d032bb4510fa1ad917216 Mon Sep 17 00:00:00 2001 From: Ankush263 Date: Sat, 17 Jun 2023 22:46:29 +0530 Subject: [PATCH 3/3] Fix typescript types in several files --- src.ts/_admin/test-browser.ts | 2 +- src.ts/_tests/test-contract.ts | 2 +- src.ts/_tests/test-wallet-mnemonic.ts | 2 +- src.ts/abi/coders/abstract-coder.ts | 4 ++-- src.ts/abi/coders/array.ts | 4 ++-- src.ts/abi/interface.ts | 6 +++--- src.ts/providers/abstract-provider.ts | 2 +- src.ts/providers/provider-fallback.ts | 2 +- src.ts/utils/rlp-decode.ts | 2 +- src.ts/utils/rlp-encode.ts | 2 +- src.ts/utils/utf8.ts | 8 ++++---- src.ts/wordlists/lang-ja.ts | 4 ++-- src.ts/wordlists/lang-zh.ts | 2 +- 13 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src.ts/_admin/test-browser.ts b/src.ts/_admin/test-browser.ts index 9828997c1b..69ebcc7a26 100644 --- a/src.ts/_admin/test-browser.ts +++ b/src.ts/_admin/test-browser.ts @@ -201,7 +201,7 @@ const TestData = (function() { return [ String(data.length), zlib.deflateRawSync(data).toString("base64") ].join(","); } - let data = [ ]; + let data: any = [ ]; data.push(`import { ethers } from "/index.js";`); data.push(`import { inflate } from "/static/tiny-inflate.js";`); data.push(`const fs = new Map();`); diff --git a/src.ts/_tests/test-contract.ts b/src.ts/_tests/test-contract.ts index 0e039b47f5..fad5f0fee3 100644 --- a/src.ts/_tests/test-contract.ts +++ b/src.ts/_tests/test-contract.ts @@ -249,7 +249,7 @@ describe("Test Typed Contract Interaction", function() { } ]; - const abi = [ ]; + const abi: any = [ ]; for (let i = 1; i <= 32; i++) { abi.push(`function testTyped(uint${ i * 8 }) public pure returns (string memory)`); abi.push(`function testTyped(int${ i * 8 }) public pure returns (string memory)`); diff --git a/src.ts/_tests/test-wallet-mnemonic.ts b/src.ts/_tests/test-wallet-mnemonic.ts index 8d8e234f11..c0fdbaf09d 100644 --- a/src.ts/_tests/test-wallet-mnemonic.ts +++ b/src.ts/_tests/test-wallet-mnemonic.ts @@ -18,7 +18,7 @@ function fromHex(hex: string): string { } function repeat(text: string, length: number): Array { - const result = [ ]; + const result: any = [ ]; while (result.length < length) { result.push(text); } return result; } diff --git a/src.ts/abi/coders/abstract-coder.ts b/src.ts/abi/coders/abstract-coder.ts index 8a4521a69d..44ec146d3d 100644 --- a/src.ts/abi/coders/abstract-coder.ts +++ b/src.ts/abi/coders/abstract-coder.ts @@ -182,7 +182,7 @@ export class Result extends Array { } if (end > this.length) { end = this.length; } - const result = [ ], names = [ ]; + const result: any = [ ], names: any = [ ]; for (let i = start; i < end; i++) { result.push(this[i]); names.push(this.#names[i]); @@ -195,7 +195,7 @@ export class Result extends Array { * @_ignore */ filter(callback: (el: any, index: number, array: Result) => boolean, thisArg?: any): Result { - const result = [ ], names = [ ]; + const result: any = [ ], names: any = [ ]; for (let i = 0; i < this.length; i++) { const item = this[i]; if (item instanceof Error) { diff --git a/src.ts/abi/coders/array.ts b/src.ts/abi/coders/array.ts index 3270713df8..1f1c9511d4 100644 --- a/src.ts/abi/coders/array.ts +++ b/src.ts/abi/coders/array.ts @@ -171,7 +171,7 @@ export class ArrayCoder extends Coder { assertArgumentCount(value.length, count, "coder array" + (this.localName? (" "+ this.localName): "")); - let coders = []; + let coders: any = []; for (let i = 0; i < value.length; i++) { coders.push(this.coder); } return pack(writer, coders, value); @@ -190,7 +190,7 @@ export class ArrayCoder extends Coder { assert(count * WordSize <= reader.dataLength, "insufficient data length", "BUFFER_OVERRUN", { buffer: reader.bytes, offset: count * WordSize, length: reader.dataLength }); } - let coders = []; + let coders: any = []; for (let i = 0; i < count; i++) { coders.push(new AnonymousCoder(this.coder)); } return unpack(reader, coders); diff --git a/src.ts/abi/interface.ts b/src.ts/abi/interface.ts index e412b49669..47caa560f6 100644 --- a/src.ts/abi/interface.ts +++ b/src.ts/abi/interface.ts @@ -595,7 +595,7 @@ export class Interface { // It is a bare name, look up the function (will return null if ambiguous) if (key.indexOf("(") === -1) { - const matching = [ ]; + const matching: any = [ ]; for (const [ name, fragment ] of this.#events) { if (name.split("("/* fix:) */)[0] === key) { matching.push(fragment); } } @@ -716,7 +716,7 @@ export class Interface { // It is a bare name, look up the function (will return null if ambiguous) if (key.indexOf("(") === -1) { - const matching = [ ]; + const matching: any = [ ]; for (const [ name, fragment ] of this.#errors) { if (name.split("("/* fix:) */)[0] === key) { matching.push(fragment); } } @@ -1154,7 +1154,7 @@ export class Interface { const keys: Array = [ ]; let nonIndexedIndex = 0, indexedIndex = 0; fragment.inputs.forEach((param, index) => { - let value = null; + let value: Indexed | null = null; if (param.indexed) { if (resultIndexed == null) { value = new Indexed(null); diff --git a/src.ts/providers/abstract-provider.ts b/src.ts/providers/abstract-provider.ts index 65f8cb18b7..d05119bd37 100644 --- a/src.ts/providers/abstract-provider.ts +++ b/src.ts/providers/abstract-provider.ts @@ -899,7 +899,7 @@ export class AbstractProvider implements Provider { })()) }); - let maxFeePerGas = null, maxPriorityFeePerGas = null; + let maxFeePerGas: bigint | null = null, maxPriorityFeePerGas: bigint | null = null; if (block && block.baseFeePerGas) { // We may want to compute this more accurately in the future, diff --git a/src.ts/providers/provider-fallback.ts b/src.ts/providers/provider-fallback.ts index 204e744063..40e7d241fe 100644 --- a/src.ts/providers/provider-fallback.ts +++ b/src.ts/providers/provider-fallback.ts @@ -328,7 +328,7 @@ function getFuzzyMode(quorum: number, results: Array): undefined | } let bestWeight = 0; - let bestResult = undefined; + let bestResult: number | undefined = undefined; for (const { weight, result } of tally.values()) { // Use this result, if this result meets quorum and has either: diff --git a/src.ts/utils/rlp-decode.ts b/src.ts/utils/rlp-decode.ts index acb3a21adf..7e0188e5aa 100644 --- a/src.ts/utils/rlp-decode.ts +++ b/src.ts/utils/rlp-decode.ts @@ -27,7 +27,7 @@ type Decoded = { }; function _decodeChildren(data: Uint8Array, offset: number, childOffset: number, length: number): Decoded { - const result = []; + const result: any = []; while (childOffset < offset + 1 + length) { const decoded = _decode(data, childOffset); diff --git a/src.ts/utils/rlp-encode.ts b/src.ts/utils/rlp-encode.ts index 9800e4b2f6..7f516c6bd9 100644 --- a/src.ts/utils/rlp-encode.ts +++ b/src.ts/utils/rlp-encode.ts @@ -6,7 +6,7 @@ import type { RlpStructuredData } from "./rlp.js"; function arrayifyInteger(value: number): Array { - const result = []; + const result: any = []; while (value) { result.unshift(value & 0xff); value >>= 8; diff --git a/src.ts/utils/utf8.ts b/src.ts/utils/utf8.ts index 19cba00e77..e184011837 100644 --- a/src.ts/utils/utf8.ts +++ b/src.ts/utils/utf8.ts @@ -6,7 +6,7 @@ * * @_subsection api/utils:Strings and UTF-8 [about-strings] */ -import { getBytes } from "./data.js"; +import { HexString, getBytes } from "./data.js"; import { assertArgument, assertNormalize } from "./errors.js"; import type { BytesLike } from "./index.js"; @@ -162,8 +162,8 @@ function getUtf8CodePoints(_bytes: BytesLike, onError?: Utf8ErrorFunc): Array): string { function loadWords(): Array { if (_wordlist !== null) { return _wordlist; } - const wordlist = []; + const wordlist: string[] = []; // Transforms for normalizing (sort is a not quite UTF-8) const transform: { [key: string]: string | boolean } = {}; @@ -91,7 +91,7 @@ function loadWords(): Array { for (let length = 3; length <= 9; length++) { const d = data[length - 3]; for (let offset = 0; offset < d.length; offset += length) { - const word = []; + const word: any = []; for (let i = 0; i < length; i++) { const k = mapping.indexOf(d[offset + i]); word.push(227); diff --git a/src.ts/wordlists/lang-zh.ts b/src.ts/wordlists/lang-zh.ts index 048115bce8..5a6b57f65c 100644 --- a/src.ts/wordlists/lang-zh.ts +++ b/src.ts/wordlists/lang-zh.ts @@ -24,7 +24,7 @@ const style = "~!@#$%^&*_-=[]{}|;:,.()<>?" function loadWords(locale: string): Array { if (_wordlist[locale] != null) { return _wordlist[locale] as Array; } - const wordlist = []; + const wordlist: string[] = []; let deltaOffset = 0; for (let i = 0; i < 2048; i++) {