Merge pull request #282 from CosmWasm/lint-array-type
Add array-type linter configuration
This commit is contained in:
commit
c7f33f4871
@ -27,10 +27,11 @@ module.exports = {
|
||||
"no-shadow": "warn",
|
||||
"no-unused-vars": "off", // disabled in favour of @typescript-eslint/no-unused-vars, see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md
|
||||
"prefer-const": "warn",
|
||||
"radix": ["warn", "always"],
|
||||
radix: ["warn", "always"],
|
||||
"spaced-comment": ["warn", "always", { line: { markers: ["/ <reference"] } }],
|
||||
"import/no-cycle": "warn",
|
||||
"simple-import-sort/sort": "warn",
|
||||
"@typescript-eslint/array-type": ["warn", { default: "array-simple" }],
|
||||
"@typescript-eslint/await-thenable": "warn",
|
||||
"@typescript-eslint/explicit-function-return-type": ["warn", { allowExpressions: true }],
|
||||
"@typescript-eslint/no-dynamic-delete": "warn",
|
||||
|
||||
@ -23,7 +23,7 @@ export interface GetNonceResult {
|
||||
export interface Account {
|
||||
/** Bech32 account address */
|
||||
readonly address: string;
|
||||
readonly balance: ReadonlyArray<Coin>;
|
||||
readonly balance: readonly Coin[];
|
||||
readonly pubkey: PubKey | undefined;
|
||||
readonly accountNumber: number;
|
||||
readonly sequence: number;
|
||||
@ -68,7 +68,7 @@ export interface SearchBySentFromOrToQuery {
|
||||
* more powerful and slightly lower level than the other search options.
|
||||
*/
|
||||
export interface SearchByTagsQuery {
|
||||
readonly tags: readonly { readonly key: string; readonly value: string }[];
|
||||
readonly tags: ReadonlyArray<{ readonly key: string; readonly value: string }>;
|
||||
}
|
||||
|
||||
export type SearchTxQuery =
|
||||
@ -144,7 +144,7 @@ export interface Block {
|
||||
readonly id: string;
|
||||
readonly header: BlockHeader;
|
||||
/** Array of raw transactions */
|
||||
readonly txs: ReadonlyArray<Uint8Array>;
|
||||
readonly txs: readonly Uint8Array[];
|
||||
}
|
||||
|
||||
/** Use for testing only */
|
||||
|
||||
@ -41,7 +41,7 @@ export interface MsgInstantiateContract extends Msg {
|
||||
readonly label: string;
|
||||
/** Init message as JavaScript object */
|
||||
readonly init_msg: any;
|
||||
readonly init_funds: ReadonlyArray<Coin>;
|
||||
readonly init_funds: readonly Coin[];
|
||||
/** Bech32-encoded admin address */
|
||||
readonly admin?: string;
|
||||
};
|
||||
@ -106,7 +106,7 @@ export interface MsgExecuteContract extends Msg {
|
||||
readonly contract: string;
|
||||
/** Handle message as JavaScript object */
|
||||
readonly msg: any;
|
||||
readonly sent_funds: ReadonlyArray<Coin>;
|
||||
readonly sent_funds: readonly Coin[];
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -55,9 +55,9 @@ interface SmartQueryResponse {
|
||||
}
|
||||
|
||||
/** Unfortunately, Cosmos SDK encodes empty arrays as null */
|
||||
type CosmosSdkArray<T> = ReadonlyArray<T> | null;
|
||||
type CosmosSdkArray<T> = readonly T[] | null;
|
||||
|
||||
function normalizeArray<T>(backend: CosmosSdkArray<T>): ReadonlyArray<T> {
|
||||
function normalizeArray<T>(backend: CosmosSdkArray<T>): readonly T[] {
|
||||
return backend || [];
|
||||
}
|
||||
|
||||
|
||||
8
packages/cosmwasm/types/cosmwasmclient.d.ts
vendored
8
packages/cosmwasm/types/cosmwasmclient.d.ts
vendored
@ -9,7 +9,7 @@ export interface GetNonceResult {
|
||||
export interface Account {
|
||||
/** Bech32 account address */
|
||||
readonly address: string;
|
||||
readonly balance: ReadonlyArray<Coin>;
|
||||
readonly balance: readonly Coin[];
|
||||
readonly pubkey: PubKey | undefined;
|
||||
readonly accountNumber: number;
|
||||
readonly sequence: number;
|
||||
@ -44,10 +44,10 @@ export interface SearchBySentFromOrToQuery {
|
||||
* more powerful and slightly lower level than the other search options.
|
||||
*/
|
||||
export interface SearchByTagsQuery {
|
||||
readonly tags: readonly {
|
||||
readonly tags: ReadonlyArray<{
|
||||
readonly key: string;
|
||||
readonly value: string;
|
||||
}[];
|
||||
}>;
|
||||
}
|
||||
export declare type SearchTxQuery =
|
||||
| SearchByIdQuery
|
||||
@ -99,7 +99,7 @@ export interface Block {
|
||||
readonly id: string;
|
||||
readonly header: BlockHeader;
|
||||
/** Array of raw transactions */
|
||||
readonly txs: ReadonlyArray<Uint8Array>;
|
||||
readonly txs: readonly Uint8Array[];
|
||||
}
|
||||
/** Use for testing only */
|
||||
export interface PrivateCosmWasmClient {
|
||||
|
||||
4
packages/cosmwasm/types/msgs.d.ts
vendored
4
packages/cosmwasm/types/msgs.d.ts
vendored
@ -36,7 +36,7 @@ export interface MsgInstantiateContract extends Msg {
|
||||
readonly label: string;
|
||||
/** Init message as JavaScript object */
|
||||
readonly init_msg: any;
|
||||
readonly init_funds: ReadonlyArray<Coin>;
|
||||
readonly init_funds: readonly Coin[];
|
||||
/** Bech32-encoded admin address */
|
||||
readonly admin?: string;
|
||||
};
|
||||
@ -89,7 +89,7 @@ export interface MsgExecuteContract extends Msg {
|
||||
readonly contract: string;
|
||||
/** Handle message as JavaScript object */
|
||||
readonly msg: any;
|
||||
readonly sent_funds: ReadonlyArray<Coin>;
|
||||
readonly sent_funds: readonly Coin[];
|
||||
};
|
||||
}
|
||||
export declare function isMsgExecuteContract(msg: Msg): msg is MsgExecuteContract;
|
||||
|
||||
@ -194,11 +194,11 @@ describe("Secp256k1", () => {
|
||||
|
||||
it("verifies unnormalized pyca/cryptography signatures", async () => {
|
||||
// signatures are mixed lowS and non-lowS, prehash type is sha256
|
||||
const data: readonly {
|
||||
const data: ReadonlyArray<{
|
||||
readonly message: Uint8Array;
|
||||
readonly privkey: Uint8Array;
|
||||
readonly signature: Uint8Array;
|
||||
}[] = [
|
||||
}> = [
|
||||
{
|
||||
message: fromHex(
|
||||
"5c868fedb8026979ebd26f1ba07c27eedf4ff6d10443505a96ecaf21ba8c4f0937b3cd23ffdc3dd429d4cd1905fb8dbcceeff1350020e18b58d2ba70887baa3a9b783ad30d3fbf210331cdd7df8d77defa398cdacdfc2e359c7ba4cae46bb74401deb417f8b912a1aa966aeeba9c39c7dd22479ae2b30719dca2f2206c5eb4b7",
|
||||
@ -395,11 +395,11 @@ describe("Secp256k1", () => {
|
||||
|
||||
it("matches normalized pyca/cryptography signatures", async () => {
|
||||
// signatures are normalized to lowS, prehash type is sha256
|
||||
const data: readonly {
|
||||
const data: ReadonlyArray<{
|
||||
readonly message: Uint8Array;
|
||||
readonly privkey: Uint8Array;
|
||||
readonly signature: Uint8Array;
|
||||
}[] = [
|
||||
}> = [
|
||||
{
|
||||
message: fromHex(
|
||||
"5c868fedb8026979ebd26f1ba07c27eedf4ff6d10443505a96ecaf21ba8c4f0937b3cd23ffdc3dd429d4cd1905fb8dbcceeff1350020e18b58d2ba70887baa3a9b783ad30d3fbf210331cdd7df8d77defa398cdacdfc2e359c7ba4cae46bb74401deb417f8b912a1aa966aeeba9c39c7dd22479ae2b30719dca2f2206c5eb4b7",
|
||||
|
||||
@ -3,7 +3,7 @@ import { Bip39, Random } from "@cosmjs/crypto";
|
||||
import * as constants from "../constants";
|
||||
import { createPens } from "../profile";
|
||||
|
||||
export async function generate(args: ReadonlyArray<string>): Promise<void> {
|
||||
export async function generate(args: readonly string[]): Promise<void> {
|
||||
if (args.length < 1) {
|
||||
throw Error(
|
||||
`Not enough arguments for action 'generate'. See '${constants.binaryName} help' or README for arguments.`,
|
||||
|
||||
@ -5,7 +5,7 @@ import * as constants from "../../constants";
|
||||
import { logAccountsState } from "../../debugging";
|
||||
import { Faucet } from "../../faucet";
|
||||
|
||||
export async function start(args: ReadonlyArray<string>): Promise<void> {
|
||||
export async function start(args: readonly string[]): Promise<void> {
|
||||
if (args.length < 1) {
|
||||
throw Error(
|
||||
`Not enough arguments for action 'start'. See '${constants.binaryName} help' or README for arguments.`,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { generate, help, start, version } from "./actions";
|
||||
|
||||
export function main(args: ReadonlyArray<string>): void {
|
||||
export function main(args: readonly string[]): void {
|
||||
if (args.length < 1) {
|
||||
help();
|
||||
process.exit(1);
|
||||
|
||||
@ -21,7 +21,7 @@ export function debugAccount(account: MinimalAccount, tokens: TokenConfiguration
|
||||
return `${account.address}: ${debugBalance(account.balance, tokens)}`;
|
||||
}
|
||||
|
||||
export function logAccountsState(accounts: ReadonlyArray<MinimalAccount>, tokens: TokenConfiguration): void {
|
||||
export function logAccountsState(accounts: readonly MinimalAccount[], tokens: TokenConfiguration): void {
|
||||
if (accounts.length < 2) {
|
||||
throw new Error("List of accounts must contain at least one token holder and one distributor");
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ export class Faucet {
|
||||
apiUrl: string,
|
||||
addressPrefix: string,
|
||||
config: TokenConfiguration,
|
||||
pens: readonly [string, Pen][],
|
||||
pens: ReadonlyArray<readonly [string, Pen]>,
|
||||
logging = false,
|
||||
) {
|
||||
this.addressPrefix = addressPrefix;
|
||||
@ -64,7 +64,7 @@ export class Faucet {
|
||||
/**
|
||||
* Returns a list of ticker symbols of tokens owned by the the holder and configured in the faucet
|
||||
*/
|
||||
public async availableTokens(): Promise<ReadonlyArray<string>> {
|
||||
public async availableTokens(): Promise<readonly string[]> {
|
||||
const holderAccount = await this.readOnlyClient.getAccount(this.holderAddress);
|
||||
const balance = holderAccount ? holderAccount.balance : [];
|
||||
|
||||
@ -99,7 +99,7 @@ export class Faucet {
|
||||
return this.tokenConfig.bankTokens.map((token) => token.tickerSymbol);
|
||||
}
|
||||
|
||||
public async loadAccounts(): Promise<ReadonlyArray<MinimalAccount>> {
|
||||
public async loadAccounts(): Promise<readonly MinimalAccount[]> {
|
||||
const addresses = [this.holderAddress, ...this.distributorAddresses];
|
||||
|
||||
return Promise.all(
|
||||
|
||||
@ -6,8 +6,8 @@ export async function createPens(
|
||||
addressPrefix: string,
|
||||
numberOfDistributors: number,
|
||||
logging = false,
|
||||
): Promise<readonly [string, Pen][]> {
|
||||
const pens = new Array<[string, Pen]>();
|
||||
): Promise<ReadonlyArray<readonly [string, Pen]>> {
|
||||
const pens = new Array<readonly [string, Pen]>();
|
||||
|
||||
// first account is the token holder
|
||||
const numberOfIdentities = 1 + numberOfDistributors;
|
||||
|
||||
@ -26,7 +26,7 @@ export interface BankTokenMeta {
|
||||
|
||||
export interface TokenConfiguration {
|
||||
/** Supported tokens of the Cosmos SDK bank module */
|
||||
readonly bankTokens: ReadonlyArray<BankTokenMeta>;
|
||||
readonly bankTokens: readonly BankTokenMeta[];
|
||||
}
|
||||
|
||||
export type MinimalAccount = Pick<Account, "address" | "balance">;
|
||||
|
||||
@ -16,7 +16,7 @@ export interface GetNonceResult {
|
||||
export interface Account {
|
||||
/** Bech32 account address */
|
||||
readonly address: string;
|
||||
readonly balance: ReadonlyArray<Coin>;
|
||||
readonly balance: readonly Coin[];
|
||||
readonly pubkey: PubKey | undefined;
|
||||
readonly accountNumber: number;
|
||||
readonly sequence: number;
|
||||
@ -61,7 +61,7 @@ export interface SearchBySentFromOrToQuery {
|
||||
* more powerful and slightly lower level than the other search options.
|
||||
*/
|
||||
export interface SearchByTagsQuery {
|
||||
readonly tags: readonly { readonly key: string; readonly value: string }[];
|
||||
readonly tags: ReadonlyArray<{ readonly key: string; readonly value: string }>;
|
||||
}
|
||||
|
||||
export type SearchTxQuery =
|
||||
@ -125,7 +125,7 @@ export interface Block {
|
||||
readonly id: string;
|
||||
readonly header: BlockHeader;
|
||||
/** Array of raw transactions */
|
||||
readonly txs: ReadonlyArray<Uint8Array>;
|
||||
readonly txs: readonly Uint8Array[];
|
||||
}
|
||||
|
||||
/** Use for testing only */
|
||||
|
||||
@ -13,7 +13,7 @@ export interface MsgSend extends Msg {
|
||||
readonly from_address: string;
|
||||
/** Bech32 account address */
|
||||
readonly to_address: string;
|
||||
readonly amount: ReadonlyArray<Coin>;
|
||||
readonly amount: readonly Coin[];
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ import { CosmosSdkTx, StdTx } from "./types";
|
||||
export interface CosmosSdkAccount {
|
||||
/** Bech32 account address */
|
||||
readonly address: string;
|
||||
readonly coins: ReadonlyArray<Coin>;
|
||||
readonly coins: readonly Coin[];
|
||||
/** Bech32 encoded pubkey */
|
||||
readonly public_key: string;
|
||||
readonly account_number: number;
|
||||
@ -84,7 +84,7 @@ interface Block {
|
||||
readonly header: BlockHeader;
|
||||
readonly data: {
|
||||
/** Array of base64 encoded transactions */
|
||||
readonly txs: ReadonlyArray<string> | null;
|
||||
readonly txs: readonly string[] | null;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ export interface CosmosSdkTx {
|
||||
}
|
||||
|
||||
export interface StdFee {
|
||||
readonly amount: ReadonlyArray<Coin>;
|
||||
readonly amount: readonly Coin[];
|
||||
readonly gas: string;
|
||||
}
|
||||
|
||||
|
||||
8
packages/sdk38/types/cosmosclient.d.ts
vendored
8
packages/sdk38/types/cosmosclient.d.ts
vendored
@ -9,7 +9,7 @@ export interface GetNonceResult {
|
||||
export interface Account {
|
||||
/** Bech32 account address */
|
||||
readonly address: string;
|
||||
readonly balance: ReadonlyArray<Coin>;
|
||||
readonly balance: readonly Coin[];
|
||||
readonly pubkey: PubKey | undefined;
|
||||
readonly accountNumber: number;
|
||||
readonly sequence: number;
|
||||
@ -44,10 +44,10 @@ export interface SearchBySentFromOrToQuery {
|
||||
* more powerful and slightly lower level than the other search options.
|
||||
*/
|
||||
export interface SearchByTagsQuery {
|
||||
readonly tags: readonly {
|
||||
readonly tags: ReadonlyArray<{
|
||||
readonly key: string;
|
||||
readonly value: string;
|
||||
}[];
|
||||
}>;
|
||||
}
|
||||
export declare type SearchTxQuery =
|
||||
| SearchByIdQuery
|
||||
@ -90,7 +90,7 @@ export interface Block {
|
||||
readonly id: string;
|
||||
readonly header: BlockHeader;
|
||||
/** Array of raw transactions */
|
||||
readonly txs: ReadonlyArray<Uint8Array>;
|
||||
readonly txs: readonly Uint8Array[];
|
||||
}
|
||||
/** Use for testing only */
|
||||
export interface PrivateCosmWasmClient {
|
||||
|
||||
2
packages/sdk38/types/msgs.d.ts
vendored
2
packages/sdk38/types/msgs.d.ts
vendored
@ -11,7 +11,7 @@ export interface MsgSend extends Msg {
|
||||
readonly from_address: string;
|
||||
/** Bech32 account address */
|
||||
readonly to_address: string;
|
||||
readonly amount: ReadonlyArray<Coin>;
|
||||
readonly amount: readonly Coin[];
|
||||
};
|
||||
}
|
||||
export declare function isMsgSend(msg: Msg): msg is MsgSend;
|
||||
|
||||
4
packages/sdk38/types/restclient.d.ts
vendored
4
packages/sdk38/types/restclient.d.ts
vendored
@ -3,7 +3,7 @@ import { CosmosSdkTx, StdTx } from "./types";
|
||||
export interface CosmosSdkAccount {
|
||||
/** Bech32 account address */
|
||||
readonly address: string;
|
||||
readonly coins: ReadonlyArray<Coin>;
|
||||
readonly coins: readonly Coin[];
|
||||
/** Bech32 encoded pubkey */
|
||||
readonly public_key: string;
|
||||
readonly account_number: number;
|
||||
@ -69,7 +69,7 @@ interface Block {
|
||||
readonly header: BlockHeader;
|
||||
readonly data: {
|
||||
/** Array of base64 encoded transactions */
|
||||
readonly txs: ReadonlyArray<string> | null;
|
||||
readonly txs: readonly string[] | null;
|
||||
};
|
||||
}
|
||||
export interface BlockResponse {
|
||||
|
||||
2
packages/sdk38/types/types.d.ts
vendored
2
packages/sdk38/types/types.d.ts
vendored
@ -17,7 +17,7 @@ export interface CosmosSdkTx {
|
||||
readonly value: StdTx;
|
||||
}
|
||||
export interface StdFee {
|
||||
readonly amount: ReadonlyArray<Coin>;
|
||||
readonly amount: readonly Coin[];
|
||||
readonly gas: string;
|
||||
}
|
||||
export interface StdSignature {
|
||||
|
||||
@ -17,7 +17,7 @@ import { Producer, Stream, Subscription } from "xstream";
|
||||
* differently than xstream's concat as discussed in https://github.com/staltz/xstream/issues/170.
|
||||
*
|
||||
*/
|
||||
export function concat<T>(...streams: Stream<T>[]): Stream<T> {
|
||||
export function concat<T>(...streams: Array<Stream<T>>): Stream<T> {
|
||||
const subscriptions = new Array<Subscription>();
|
||||
const queues = new Array<T[]>(); // one queue per stream
|
||||
const completedStreams = new Set<number>();
|
||||
|
||||
2
packages/stream/types/concat.d.ts
vendored
2
packages/stream/types/concat.d.ts
vendored
@ -16,4 +16,4 @@ import { Stream } from "xstream";
|
||||
* differently than xstream's concat as discussed in https://github.com/staltz/xstream/issues/170.
|
||||
*
|
||||
*/
|
||||
export declare function concat<T>(...streams: Stream<T>[]): Stream<T>;
|
||||
export declare function concat<T>(...streams: Array<Stream<T>>): Stream<T>;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user