diff --git a/package.json b/package.json index eb0135fa..3b0abde2 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "eslint-config-prettier": "^6.10.0", "eslint-plugin-functional": "^3.0.1", "eslint-plugin-import": "^2.20.1", - "eslint-plugin-prettier": "^3.1.2", + "eslint-plugin-prettier": "^3.1.3", "eslint-plugin-simple-import-sort": "^5.0.1", "jasmine": "^3.3.1", "jasmine-spec-reporter": "^4.2.1", @@ -50,7 +50,7 @@ "karma-jasmine": "^3", "karma-jasmine-html-reporter": "^1.4", "lerna": "^3.20.2", - "prettier": "^1.19.1", + "prettier": "^2", "shx": "^0.3.2", "source-map-support": "^0.5.6", "typescript": "~3.7", diff --git a/packages/bcp/karma.conf.js b/packages/bcp/karma.conf.js index ff71fce8..e68db403 100644 --- a/packages/bcp/karma.conf.js +++ b/packages/bcp/karma.conf.js @@ -1,4 +1,4 @@ -module.exports = function(config) { +module.exports = function (config) { config.set({ // base path that will be used to resolve all patterns (eg. files, exclude) basePath: ".", diff --git a/packages/bcp/src/cosmwasmconnection.spec.ts b/packages/bcp/src/cosmwasmconnection.spec.ts index 864f41e5..7c08d49c 100644 --- a/packages/bcp/src/cosmwasmconnection.spec.ts +++ b/packages/bcp/src/cosmwasmconnection.spec.ts @@ -278,7 +278,7 @@ describe("CosmWasmConnection", () => { }); describe("watchAccount", () => { - it("can watch account by address", done => { + it("can watch account by address", (done) => { pendingWithoutWasmd(); const recipient = makeRandomAddress(); const events = new Array(); @@ -286,7 +286,7 @@ describe("CosmWasmConnection", () => { (async () => { const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig); const subscription = connection.watchAccount({ address: recipient }).subscribe({ - next: event => { + next: (event) => { events.push(event); if (events.length === 3) { @@ -335,7 +335,7 @@ describe("CosmWasmConnection", () => { const nonce = await connection.getNonce({ address: senderAddress }); const signedTransaction = await profile.signTransaction(sender, sendTx, connection.codec, nonce); const result = await connection.postTx(connection.codec.bytesToPost(signedTransaction)); - await result.blockInfo.waitFor(info => !isBlockInfoPending(info)); + await result.blockInfo.waitFor((info) => !isBlockInfoPending(info)); } })().catch(done.fail); }); @@ -367,7 +367,7 @@ describe("CosmWasmConnection", () => { const postableBytes = connection.codec.bytesToPost(signed); const response = await connection.postTx(postableBytes); const { transactionId } = response; - await response.blockInfo.waitFor(info => isBlockInfoSucceeded(info)); + await response.blockInfo.waitFor((info) => isBlockInfoSucceeded(info)); const getResponse = await connection.getTx(transactionId); expect(getResponse.transactionId).toEqual(transactionId); @@ -418,7 +418,7 @@ describe("CosmWasmConnection", () => { const postableBytes = connection.codec.bytesToPost(signed); const response = await connection.postTx(postableBytes); const { transactionId } = response; - await response.blockInfo.waitFor(info => isBlockInfoSucceeded(info)); + await response.blockInfo.waitFor((info) => isBlockInfoSucceeded(info)); const getResponse = await connection.getTx(transactionId); expect(getResponse.transactionId).toEqual(transactionId); @@ -491,7 +491,7 @@ describe("CosmWasmConnection", () => { const nonExistentId = "0000000000000000000000000000000000000000000000000000000000000000" as TransactionId; await connection.getTx(nonExistentId).then( () => fail("this must not succeed"), - error => expect(error).toMatch(/transaction does not exist/i), + (error) => expect(error).toMatch(/transaction does not exist/i), ); connection.disconnect(); @@ -524,7 +524,7 @@ describe("CosmWasmConnection", () => { const postableBytes = connection.codec.bytesToPost(signed); const response = await connection.postTx(postableBytes); const { transactionId } = response; - const blockInfo = await response.blockInfo.waitFor(info => !isBlockInfoPending(info)); + const blockInfo = await response.blockInfo.waitFor((info) => !isBlockInfoPending(info)); expect(blockInfo.state).toEqual(TransactionState.Succeeded); // search by id @@ -615,7 +615,7 @@ describe("CosmWasmConnection", () => { const postableBytes = connection.codec.bytesToPost(signed); const response = await connection.postTx(postableBytes); const { transactionId } = response; - const blockInfo = await response.blockInfo.waitFor(info => !isBlockInfoPending(info)); + const blockInfo = await response.blockInfo.waitFor((info) => !isBlockInfoPending(info)); expect(blockInfo.state).toEqual(TransactionState.Succeeded); // search by id @@ -733,7 +733,7 @@ describe("CosmWasmConnection", () => { const postableBytes = connection.codec.bytesToPost(signed); const response = await connection.postTx(postableBytes); const { transactionId } = response; - const blockInfo = await response.blockInfo.waitFor(info => !isBlockInfoPending(info)); + const blockInfo = await response.blockInfo.waitFor((info) => !isBlockInfoPending(info)); assert(isBlockInfoSucceeded(blockInfo)); const { height } = blockInfo; @@ -916,7 +916,7 @@ describe("CosmWasmConnection", () => { }); describe("liveTx", () => { - it("can listen to transactions by recipient address (transactions in history and updates)", done => { + it("can listen to transactions by recipient address (transactions in history and updates)", (done) => { pendingWithoutWasmd(); (async () => { @@ -969,14 +969,14 @@ describe("CosmWasmConnection", () => { // Post A and B. Unfortunately the REST server API does not support sending them in parallel because the sequence check fails. const postResultA = await connection.postTx(bytesToPostA); - await postResultA.blockInfo.waitFor(info => !isBlockInfoPending(info)); + await postResultA.blockInfo.waitFor((info) => !isBlockInfoPending(info)); const postResultB = await connection.postTx(bytesToPostB); - await postResultB.blockInfo.waitFor(info => !isBlockInfoPending(info)); + await postResultB.blockInfo.waitFor((info) => !isBlockInfoPending(info)); // setup listener after A and B are in block const events = new Array>(); const subscription = connection.liveTx({ sentFromOrTo: recipientAddress }).subscribe({ - next: event => { + next: (event) => { assert(isConfirmedTransaction(event), "Confirmed transaction expected"); events.push(event); @@ -999,7 +999,7 @@ describe("CosmWasmConnection", () => { })().catch(done.fail); }); - it("can listen to transactions by ID (transaction in history)", done => { + it("can listen to transactions by ID (transaction in history)", (done) => { pendingWithoutWasmd(); (async () => { @@ -1028,12 +1028,12 @@ describe("CosmWasmConnection", () => { const transactionId = postResult.transactionId; // Wait for a block - await postResult.blockInfo.waitFor(info => !isBlockInfoPending(info)); + await postResult.blockInfo.waitFor((info) => !isBlockInfoPending(info)); // setup listener after transaction is in block const events = new Array>(); const subscription = connection.liveTx({ id: transactionId }).subscribe({ - next: event => { + next: (event) => { assert(isConfirmedTransaction(event), "Confirmed transaction expected"); events.push(event); @@ -1049,7 +1049,7 @@ describe("CosmWasmConnection", () => { })().catch(done.fail); }); - it("can listen to transactions by ID (transaction in updates)", done => { + it("can listen to transactions by ID (transaction in updates)", (done) => { pendingWithoutWasmd(); (async () => { @@ -1082,7 +1082,7 @@ describe("CosmWasmConnection", () => { // setup listener before transaction is in block const events = new Array>(); const subscription = connection.liveTx({ id: transactionId }).subscribe({ - next: event => { + next: (event) => { assert(isConfirmedTransaction(event), "Confirmed transaction expected"); events.push(event); diff --git a/packages/bcp/src/cosmwasmconnection.ts b/packages/bcp/src/cosmwasmconnection.ts index 841143db..ede09af4 100644 --- a/packages/bcp/src/cosmwasmconnection.ts +++ b/packages/bcp/src/cosmwasmconnection.ts @@ -62,7 +62,7 @@ function isDefined(value: X | undefined): value is X { function deduplicate(input: ReadonlyArray, comparator: (a: T, b: T) => number): Array { const out = new Array(); for (const element of input) { - if (!out.find(o => comparator(o, element) === 0)) { + if (!out.find((o) => comparator(o, element) === 0)) { out.push(element); } } @@ -125,7 +125,7 @@ export class CosmWasmConnection implements BlockchainConnection { const erc20Tokens = tokens.erc20Tokens || []; this.erc20Tokens = erc20Tokens; this.supportedTokens = [...tokens.bankTokens, ...erc20Tokens] - .map(info => ({ + .map((info) => ({ tokenTicker: info.ticker as TokenTicker, tokenName: info.name, fractionalDigits: info.fractionalDigits, @@ -164,7 +164,7 @@ export class CosmWasmConnection implements BlockchainConnection { const bankAccount = await this.cosmWasmClient.getAccount(address); const supportedBankCoins = (bankAccount?.balance || []).filter(({ denom }) => - this.bankTokens.find(token => token.denom === denom), + this.bankTokens.find((token) => token.denom === denom), ); const erc20Amounts = await Promise.all( this.erc20Tokens.map( @@ -181,13 +181,13 @@ export class CosmWasmConnection implements BlockchainConnection { }, ), ); - const nonZeroErc20Amounts = erc20Amounts.filter(amount => amount.quantity !== "0"); + const nonZeroErc20Amounts = erc20Amounts.filter((amount) => amount.quantity !== "0"); if (!bankAccount && nonZeroErc20Amounts.length === 0) { return undefined; } else { const balance = [ - ...supportedBankCoins.map(coin => decodeAmount(this.bankTokens, coin)), + ...supportedBankCoins.map((coin) => decodeAmount(this.bankTokens, coin)), ...nonZeroErc20Amounts, ].sort((a, b) => a.tokenTicker.localeCompare(b.tokenTicker)); const pubkey = bankAccount?.pubkey ? decodePubkey(bankAccount.pubkey) : undefined; @@ -203,7 +203,7 @@ export class CosmWasmConnection implements BlockchainConnection { let lastEvent: LastWatchAccountEvent = "no_event_fired_yet"; let pollInternal: NodeJS.Timeout | undefined; const producer: Producer = { - start: async listener => { + start: async (listener) => { const poll = async (): Promise => { try { const event = await this.getAccount(query); @@ -343,7 +343,7 @@ export class CosmWasmConnection implements BlockchainConnection { } else if (sentFromOrTo) { const pendingRequests = new Array>(); pendingRequests.push(this.cosmWasmClient.searchTx({ sentFromOrTo: sentFromOrTo }, filter)); - for (const contract of this.erc20Tokens.map(token => token.contractAddress)) { + for (const contract of this.erc20Tokens.map((token) => token.contractAddress)) { const searchBySender = [ { key: "wasm.contract_address", @@ -374,7 +374,7 @@ export class CosmWasmConnection implements BlockchainConnection { throw new Error("Unsupported query"); } - return txs.map(tx => this.parseAndPopulateTxResponseUnsigned(tx)); + return txs.map((tx) => this.parseAndPopulateTxResponseUnsigned(tx)); } public listenTx( @@ -400,7 +400,7 @@ export class CosmWasmConnection implements BlockchainConnection { } else if (query.sentFromOrTo) { let pollInternal: NodeJS.Timeout | undefined; const producer: Producer | FailedTransaction> = { - start: async listener => { + start: async (listener) => { let minHeight = query.minHeight || 0; const maxHeight = query.maxHeight || Number.MAX_SAFE_INTEGER; @@ -514,7 +514,7 @@ export class CosmWasmConnection implements BlockchainConnection { ): Stream | FailedTransaction> { let pollInternal: NodeJS.Timeout | undefined; const producer: Producer | FailedTransaction> = { - start: listener => { + start: (listener) => { setInterval(async () => { try { const results = await this.searchTx({ id: id }); diff --git a/packages/bcp/src/decode.ts b/packages/bcp/src/decode.ts index 4d4cea12..f293eda6 100644 --- a/packages/bcp/src/decode.ts +++ b/packages/bcp/src/decode.ts @@ -93,7 +93,7 @@ export function parseMsg( }; return send; } else if (types.isMsgExecuteContract(msg)) { - const matchingTokenContract = erc20Tokens.find(t => t.contractAddress === msg.value.contract); + const matchingTokenContract = erc20Tokens.find((t) => t.contractAddress === msg.value.contract); if (!matchingTokenContract) { return { chainId: chainId, @@ -170,7 +170,7 @@ export function parseSignedTx( tokens: BankTokens, erc20Tokens: readonly Erc20Token[], ): SignedTransaction { - const [primarySignature] = txValue.signatures.map(signature => decodeFullSignature(signature, nonce)); + const [primarySignature] = txValue.signatures.map((signature) => decodeFullSignature(signature, nonce)); return { transaction: parseUnsignedTx(txValue, chainId, tokens, erc20Tokens), signatures: [primarySignature], diff --git a/packages/bcp/src/encode.ts b/packages/bcp/src/encode.ts index 85a83e31..8336463e 100644 --- a/packages/bcp/src/encode.ts +++ b/packages/bcp/src/encode.ts @@ -41,7 +41,7 @@ export function toErc20Amount(amount: Amount, erc20Token: Erc20Token): string { } export function toBankCoin(amount: Amount, tokens: BankTokens): types.Coin { - const match = tokens.find(token => token.ticker === amount.tokenTicker); + const match = tokens.find((token) => token.ticker === amount.tokenTicker); if (!match) throw Error(`unknown ticker: ${amount.tokenTicker}`); if (match.fractionalDigits !== amount.fractionalDigits) { throw new Error( @@ -88,8 +88,8 @@ export function buildUnsignedTx( throw new Error("Received transaction of unsupported kind"); } - const matchingBankToken = bankTokens.find(t => t.ticker === tx.amount.tokenTicker); - const matchingErc20Token = erc20Tokens.find(t => t.ticker === tx.amount.tokenTicker); + const matchingBankToken = bankTokens.find((t) => t.ticker === tx.amount.tokenTicker); + const matchingErc20Token = erc20Tokens.find((t) => t.ticker === tx.amount.tokenTicker); if (!tx.fee) throw new Error("Transaction fee must be set"); diff --git a/packages/cli/package.json b/packages/cli/package.json index 741599ff..7f85de75 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -18,6 +18,7 @@ "format": "prettier --write --loglevel warn \"./src/**/*.ts\"", "format-text": "prettier --write --prose-wrap always --print-width 80 \"./*.md\"", "lint": "eslint --max-warnings 0 \"**/*.{js,ts}\"", + "lint-fix": "eslint --max-warnings 0 \"**/*.{js,ts}\" --fix", "build": "tsc", "build-or-skip": "[ -n \"$SKIP_BUILD\" ] || yarn build", "start": "yarn build-or-skip && ./bin/cosmwasm-cli", diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index 6c1e9fc9..dd220fa2 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -163,7 +163,7 @@ export function main(originalArgs: readonly string[]): void { } if (args.init) { - for (const path of args.init.map(arg => arg.toString())) { + for (const path of args.init.map((arg) => arg.toString())) { if (args.debug) console.info(`Adding file: '${path}' ...`); init += fs.readFileSync(path, "utf8") + "\n"; } @@ -171,7 +171,7 @@ export function main(originalArgs: readonly string[]): void { const tsconfigPath = join(__dirname, "..", "tsconfig_repl.json"); const installationDir = join(__dirname, ".."); - new TsRepl(tsconfigPath, init, !!args.debug, installationDir).start().catch(error => { + new TsRepl(tsconfigPath, init, !!args.debug, installationDir).start().catch((error) => { console.error(error); process.exit(1); }); diff --git a/packages/cli/src/helpers.spec.ts b/packages/cli/src/helpers.spec.ts index 5667c9ba..6571d3cf 100644 --- a/packages/cli/src/helpers.spec.ts +++ b/packages/cli/src/helpers.spec.ts @@ -85,13 +85,13 @@ describe("Helpers", () => { const context = createContext({}); await executeJavaScriptAsync("var a", "myfile.js", context) .then(() => fail("must not resolve")) - .catch(e => expect(e).toMatch(/SyntaxError:/)); + .catch((e) => expect(e).toMatch(/SyntaxError:/)); await executeJavaScriptAsync("let b", "myfile.js", context) .then(() => fail("must not resolve")) - .catch(e => expect(e).toMatch(/SyntaxError:/)); + .catch((e) => expect(e).toMatch(/SyntaxError:/)); await executeJavaScriptAsync("const c", "myfile.js", context) .then(() => fail("must not resolve")) - .catch(e => expect(e).toMatch(/SyntaxError:/)); + .catch((e) => expect(e).toMatch(/SyntaxError:/)); }); it("can execute multiple commands in one context", async () => { diff --git a/packages/cli/src/helpers.ts b/packages/cli/src/helpers.ts index d0c59d4d..b6d3e9f7 100644 --- a/packages/cli/src/helpers.ts +++ b/packages/cli/src/helpers.ts @@ -29,5 +29,5 @@ export function isRecoverable(error: TSError): boolean { 2355, // "A function whose declared type is neither 'void' nor 'any' must return a value." ]); - return error.diagnosticCodes.every(code => recoveryCodes.has(code)); + return error.diagnosticCodes.every((code) => recoveryCodes.has(code)); } diff --git a/packages/cli/src/tsrepl.spec.ts b/packages/cli/src/tsrepl.spec.ts index 23540372..e6b488d1 100644 --- a/packages/cli/src/tsrepl.spec.ts +++ b/packages/cli/src/tsrepl.spec.ts @@ -35,12 +35,12 @@ describe("TsRepl", () => { await new TsRepl(tsConfigPath, "const a: string = 123;") .start() .then(() => fail("must not resolve")) - .catch(e => expect(e).toMatch(/is not assignable to type 'string'/)); + .catch((e) => expect(e).toMatch(/is not assignable to type 'string'/)); await new TsRepl(tsConfigPath, "const const const;") .start() .then(() => fail("must not resolve")) - .catch(e => expect(e).toMatch(/Variable declaration expected./)); + .catch((e) => expect(e).toMatch(/Variable declaration expected./)); }); it("can be started with top level await", async () => { diff --git a/packages/cli/src/tsrepl.ts b/packages/cli/src/tsrepl.ts index 4375eca8..274c0468 100644 --- a/packages/cli/src/tsrepl.ts +++ b/packages/cli/src/tsrepl.ts @@ -156,7 +156,7 @@ export class TsRepl { // statement in TypeScript is compiled to no JavaScript until the imported symbol is used // somewhere. This btw. leads to a different execution order of imports than in the TS source. let lastResult: any; - for (const added of changes.filter(change => change.added)) { + for (const added of changes.filter((change) => change.added)) { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion lastResult = await executeJavaScriptAsync(added.value, this.evalFilename, this.context!); } diff --git a/packages/faucet/src/api/webserver.ts b/packages/faucet/src/api/webserver.ts index 5669ada6..e175237b 100644 --- a/packages/faucet/src/api/webserver.ts +++ b/packages/faucet/src/api/webserver.ts @@ -22,7 +22,7 @@ export class Webserver { this.api.use(cors()); this.api.use(bodyParser()); - this.api.use(async context => { + this.api.use(async (context) => { switch (context.path) { case "/": case "/healthz": diff --git a/packages/faucet/src/cli.ts b/packages/faucet/src/cli.ts index ff5d111c..ce90446e 100644 --- a/packages/faucet/src/cli.ts +++ b/packages/faucet/src/cli.ts @@ -11,7 +11,7 @@ export function main(args: ReadonlyArray): void { switch (action) { case "generate": - generate(restArgs).catch(error => { + generate(restArgs).catch((error) => { console.error(error); process.exit(1); }); @@ -20,13 +20,13 @@ export function main(args: ReadonlyArray): void { help(); break; case "version": - version().catch(error => { + version().catch((error) => { console.error(error); process.exit(1); }); break; case "start": - start(restArgs).catch(error => { + start(restArgs).catch((error) => { console.error(error); process.exit(1); }); diff --git a/packages/faucet/src/debugging.ts b/packages/faucet/src/debugging.ts index 97a50f5f..a63932b2 100644 --- a/packages/faucet/src/debugging.ts +++ b/packages/faucet/src/debugging.ts @@ -27,7 +27,7 @@ export function logAccountsState(accounts: ReadonlyArray): void { const holder = accounts[0]; const distributors = accounts.slice(1); console.info("Holder:\n" + ` ${debugAccount(holder)}`); - console.info("Distributors:\n" + distributors.map(r => ` ${debugAccount(r)}`).join("\n")); + console.info("Distributors:\n" + distributors.map((r) => ` ${debugAccount(r)}`).join("\n")); } export function logSendJob(job: SendJob): void { diff --git a/packages/faucet/src/faucet.ts b/packages/faucet/src/faucet.ts index 0aa9cc66..3af0adbc 100644 --- a/packages/faucet/src/faucet.ts +++ b/packages/faucet/src/faucet.ts @@ -66,7 +66,7 @@ export class Faucet { const signed = await this.profile.signTransaction(job.sender, sendWithFee, this.codec, nonce); const post = await this.connection.postTx(this.codec.bytesToPost(signed)); - const blockInfo = await post.blockInfo.waitFor(info => !isBlockInfoPending(info)); + const blockInfo = await post.blockInfo.waitFor((info) => !isBlockInfoPending(info)); if (isBlockInfoFailed(blockInfo)) { throw new Error(`Sending tokens failed. Code: ${blockInfo.code}, message: ${blockInfo.message}`); } @@ -86,11 +86,11 @@ export class Faucet { } public async loadTokenTickers(): Promise> { - return (await this.connection.getAllTokens()).map(token => token.tokenTicker); + return (await this.connection.getAllTokens()).map((token) => token.tokenTicker); } public async loadAccounts(): Promise>> { - const addresses = identitiesOfFirstWallet(this.profile).map(identity => identityToAddress(identity)); + const addresses = identitiesOfFirstWallet(this.profile).map((identity) => identityToAddress(identity)); const out: Account[] = []; for (const address of addresses) { @@ -126,14 +126,16 @@ export class Faucet { const jobs: SendJob[] = []; for (const token of availableTokens) { - const refillDistibutors = distributorAccounts.filter(account => + const refillDistibutors = distributorAccounts.filter((account) => this.tokenManager.needsRefill(account, token), ); if (this.logging) { console.info(`Refilling ${token} of:`); console.info( - refillDistibutors.length ? refillDistibutors.map(r => ` ${debugAccount(r)}`).join("\n") : " none", + refillDistibutors.length + ? refillDistibutors.map((r) => ` ${debugAccount(r)}`).join("\n") + : " none", ); } for (const refillDistibutor of refillDistibutors) { diff --git a/packages/faucet/src/multichainhelpers.ts b/packages/faucet/src/multichainhelpers.ts index 26be6198..d7adcf2e 100644 --- a/packages/faucet/src/multichainhelpers.ts +++ b/packages/faucet/src/multichainhelpers.ts @@ -7,5 +7,5 @@ export function identitiesOfFirstWallet(profile: UserProfile): ReadonlyArray { - return holderAccount.balance.map(coin => coin.tokenTicker); + return holderAccount.balance.map((coin) => coin.tokenTicker); } diff --git a/packages/faucet/src/tokenmanager.ts b/packages/faucet/src/tokenmanager.ts index b91685d9..d2be65da 100644 --- a/packages/faucet/src/tokenmanager.ts +++ b/packages/faucet/src/tokenmanager.ts @@ -43,7 +43,7 @@ export class TokenManager { /** true iff the distributor account needs a refill */ public needsRefill(account: Account, token: TokenTicker): boolean { - const balanceAmount = account.balance.find(b => b.tokenTicker === token); + const balanceAmount = account.balance.find((b) => b.tokenTicker === token); const balance = balanceAmount ? Decimal.fromAtomics(balanceAmount.quantity, balanceAmount.fractionalDigits) @@ -59,7 +59,7 @@ export class TokenManager { private getFractionalDigits(ticker: TokenTicker): number { const match = [...this.config.bankTokens, ...(this.config.erc20Tokens || [])].find( - token => token.ticker === ticker, + (token) => token.ticker === ticker, ); if (!match) throw new Error(`No token found for ticker symbol: ${ticker}`); return match.fractionalDigits; diff --git a/packages/sdk/karma.conf.js b/packages/sdk/karma.conf.js index ff71fce8..e68db403 100644 --- a/packages/sdk/karma.conf.js +++ b/packages/sdk/karma.conf.js @@ -1,4 +1,4 @@ -module.exports = function(config) { +module.exports = function (config) { config.set({ // base path that will be used to resolve all patterns (eg. files, exclude) basePath: ".", diff --git a/packages/sdk/src/cosmwasmclient.searchtx.spec.ts b/packages/sdk/src/cosmwasmclient.searchtx.spec.ts index f5e1d72f..a2daa062 100644 --- a/packages/sdk/src/cosmwasmclient.searchtx.spec.ts +++ b/packages/sdk/src/cosmwasmclient.searchtx.spec.ts @@ -56,7 +56,7 @@ describe("CosmWasmClient.searchTx", () => { beforeAll(async () => { if (wasmdEnabled()) { const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic); - const client = new SigningCosmWasmClient(wasmd.endpoint, faucet.address, signBytes => + const client = new SigningCosmWasmClient(wasmd.endpoint, faucet.address, (signBytes) => pen.sign(signBytes), ); diff --git a/packages/sdk/src/cosmwasmclient.spec.ts b/packages/sdk/src/cosmwasmclient.spec.ts index 9491a6e0..84f016fe 100644 --- a/packages/sdk/src/cosmwasmclient.spec.ts +++ b/packages/sdk/src/cosmwasmclient.spec.ts @@ -124,7 +124,7 @@ describe("CosmWasmClient", () => { const missing = makeRandomAddress(); await client.getNonce(missing).then( () => fail("this must not succeed"), - error => expect(error).toMatch(/account does not exist on chain/i), + (error) => expect(error).toMatch(/account does not exist on chain/i), ); }); }); @@ -373,7 +373,7 @@ describe("CosmWasmClient", () => { if (wasmdEnabled()) { pendingWithoutWasmd(); const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic); - const client = new SigningCosmWasmClient(wasmd.endpoint, faucet.address, signBytes => + const client = new SigningCosmWasmClient(wasmd.endpoint, faucet.address, (signBytes) => pen.sign(signBytes), ); const { codeId } = await client.upload(getHackatom()); @@ -414,7 +414,7 @@ describe("CosmWasmClient", () => { const client = new CosmWasmClient(wasmd.endpoint); await client.queryContractRaw(nonExistentAddress, configKey).then( () => fail("must not succeed"), - error => expect(error).toMatch(`No contract found at address "${nonExistentAddress}"`), + (error) => expect(error).toMatch(`No contract found at address "${nonExistentAddress}"`), ); }); }); @@ -426,7 +426,7 @@ describe("CosmWasmClient", () => { if (wasmdEnabled()) { pendingWithoutWasmd(); const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic); - const client = new SigningCosmWasmClient(wasmd.endpoint, faucet.address, signBytes => + const client = new SigningCosmWasmClient(wasmd.endpoint, faucet.address, (signBytes) => pen.sign(signBytes), ); const { codeId } = await client.upload(getHackatom()); @@ -452,7 +452,7 @@ describe("CosmWasmClient", () => { const client = new CosmWasmClient(wasmd.endpoint); await client.queryContractSmart(contract.address, { broken: {} }).then( () => fail("must not succeed"), - error => expect(error).toMatch(/Error parsing QueryMsg/i), + (error) => expect(error).toMatch(/Error parsing QueryMsg/i), ); }); @@ -463,7 +463,7 @@ describe("CosmWasmClient", () => { const client = new CosmWasmClient(wasmd.endpoint); await client.queryContractSmart(nonExistentAddress, { verifier: {} }).then( () => fail("must not succeed"), - error => expect(error).toMatch(`No contract found at address "${nonExistentAddress}"`), + (error) => expect(error).toMatch(`No contract found at address "${nonExistentAddress}"`), ); }); }); diff --git a/packages/sdk/src/cosmwasmclient.ts b/packages/sdk/src/cosmwasmclient.ts index dc59e127..2d9a05b8 100644 --- a/packages/sdk/src/cosmwasmclient.ts +++ b/packages/sdk/src/cosmwasmclient.ts @@ -252,7 +252,7 @@ export class CosmWasmClient { height: parseInt(response.block.header.height, 10), chainId: response.block.header.chain_id, }, - txs: (response.block.data.txs || []).map(encoded => Encoding.fromBase64(encoded)), + txs: (response.block.data.txs || []).map((encoded) => Encoding.fromBase64(encoded)), }; } @@ -283,17 +283,17 @@ export class CosmWasmClient { const sent = await this.txsQuery(sentQuery); const received = await this.txsQuery(receivedQuery); - const sentHashes = sent.map(t => t.hash); - txs = [...sent, ...received.filter(t => !sentHashes.includes(t.hash))]; + const sentHashes = sent.map((t) => t.hash); + txs = [...sent, ...received.filter((t) => !sentHashes.includes(t.hash))]; } else if (isSearchByTagsQuery(query)) { - const rawQuery = withFilters(query.tags.map(t => `${t.key}=${t.value}`).join("&")); + const rawQuery = withFilters(query.tags.map((t) => `${t.key}=${t.value}`).join("&")); txs = await this.txsQuery(rawQuery); } else { throw new Error("Unknown query type"); } // backend sometimes messes up with min/max height filtering - const filtered = txs.filter(tx => tx.height >= minHeight && tx.height <= maxHeight); + const filtered = txs.filter((tx) => tx.height >= minHeight && tx.height <= maxHeight); return filtered; } diff --git a/packages/sdk/src/logs.ts b/packages/sdk/src/logs.ts index 1db37544..e1eaa1cb 100644 --- a/packages/sdk/src/logs.ts +++ b/packages/sdk/src/logs.ts @@ -75,8 +75,8 @@ export function findAttribute( ): Attribute { const firstLogs = logs.find(() => true); const out = firstLogs?.events - .find(event => event.type === eventType) - ?.attributes.find(attr => attr.key === attrKey); + .find((event) => event.type === eventType) + ?.attributes.find((attr) => attr.key === attrKey); if (!out) { throw new Error( `Could not find attribute '${attrKey}' in first event of type '${eventType}' in first log.`, diff --git a/packages/sdk/src/restclient.spec.ts b/packages/sdk/src/restclient.spec.ts index a1af8fc1..3bd46333 100644 --- a/packages/sdk/src/restclient.spec.ts +++ b/packages/sdk/src/restclient.spec.ts @@ -344,7 +344,7 @@ describe("RestClient", () => { beforeAll(async () => { if (wasmdEnabled()) { const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic); - const client = new SigningCosmWasmClient(wasmd.endpoint, faucet.address, signBytes => + const client = new SigningCosmWasmClient(wasmd.endpoint, faucet.address, (signBytes) => pen.sign(signBytes), ); @@ -482,7 +482,7 @@ describe("RestClient", () => { beforeAll(async () => { if (wasmdEnabled()) { const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic); - const client = new SigningCosmWasmClient(wasmd.endpoint, faucet.address, signBytes => + const client = new SigningCosmWasmClient(wasmd.endpoint, faucet.address, (signBytes) => pen.sign(signBytes), ); @@ -655,7 +655,7 @@ describe("RestClient", () => { expect(parseInt(result.count, 10)).toBeGreaterThanOrEqual(4); // Check first 4 results - const [store, hash, isa, jade] = result.txs.map(tx => fromOneElementArray(tx.tx.value.msg)); + const [store, hash, isa, jade] = result.txs.map((tx) => fromOneElementArray(tx.tx.value.msg)); assert(isMsgStoreCode(store)); assert(isMsgInstantiateContract(hash)); assert(isMsgInstantiateContract(isa)); @@ -719,7 +719,7 @@ describe("RestClient", () => { `message.module=wasm&message.code_id=${deployedErc20.codeId}&message.action=instantiate`, ); expect(parseInt(instantiations.count, 10)).toBeGreaterThanOrEqual(3); - const [hash, isa, jade] = instantiations.txs.map(tx => fromOneElementArray(tx.tx.value.msg)); + const [hash, isa, jade] = instantiations.txs.map((tx) => fromOneElementArray(tx.tx.value.msg)); assert(isMsgInstantiateContract(hash)); assert(isMsgInstantiateContract(isa)); assert(isMsgInstantiateContract(jade)); @@ -861,7 +861,7 @@ describe("RestClient", () => { expect(result.code).toBeFalsy(); // console.log("Raw log:", result.logs); const logs = parseLogs(result.logs); - const wasmEvent = logs.find(() => true)?.events.find(e => e.type === "wasm"); + const wasmEvent = logs.find(() => true)?.events.find((e) => e.type === "wasm"); assert(wasmEvent, "Event of type wasm expected"); expect(wasmEvent.attributes).toContain({ key: "action", value: "release" }); expect(wasmEvent.attributes).toContain({ @@ -1051,13 +1051,13 @@ describe("RestClient", () => { // invalid query syntax throws an error await client.queryContractSmart(contractAddress!, { nosuchkey: {} }).then( () => fail("shouldn't succeed"), - error => expect(error).toMatch("Error parsing QueryMsg"), + (error) => expect(error).toMatch("Error parsing QueryMsg"), ); // invalid address throws an error await client.queryContractSmart(noContract, { verifier: {} }).then( () => fail("shouldn't succeed"), - error => expect(error).toMatch("not found"), + (error) => expect(error).toMatch("not found"), ); }); }); diff --git a/packages/sdk/src/signingcosmwasmclient.spec.ts b/packages/sdk/src/signingcosmwasmclient.spec.ts index 0eaa522c..00bc77da 100644 --- a/packages/sdk/src/signingcosmwasmclient.spec.ts +++ b/packages/sdk/src/signingcosmwasmclient.spec.ts @@ -27,7 +27,7 @@ describe("SigningCosmWasmClient", () => { describe("makeReadOnly", () => { it("can be constructed", async () => { const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic); - const client = new SigningCosmWasmClient(httpUrl, faucet.address, signBytes => pen.sign(signBytes)); + const client = new SigningCosmWasmClient(httpUrl, faucet.address, (signBytes) => pen.sign(signBytes)); expect(client).toBeTruthy(); }); }); @@ -36,7 +36,7 @@ describe("SigningCosmWasmClient", () => { it("always uses authAccount implementation", async () => { pendingWithoutWasmd(); const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic); - const client = new SigningCosmWasmClient(httpUrl, faucet.address, signBytes => pen.sign(signBytes)); + const client = new SigningCosmWasmClient(httpUrl, faucet.address, (signBytes) => pen.sign(signBytes)); const openedClient = (client as unknown) as PrivateCosmWasmClient; const blockLatestSpy = spyOn(openedClient.restClient, "blocksLatest").and.callThrough(); @@ -54,7 +54,7 @@ describe("SigningCosmWasmClient", () => { it("works", async () => { pendingWithoutWasmd(); const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic); - const client = new SigningCosmWasmClient(httpUrl, faucet.address, signBytes => pen.sign(signBytes)); + const client = new SigningCosmWasmClient(httpUrl, faucet.address, (signBytes) => pen.sign(signBytes)); const wasm = getHackatom(); const { codeId, @@ -73,7 +73,7 @@ describe("SigningCosmWasmClient", () => { it("can set builder and source", async () => { pendingWithoutWasmd(); const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic); - const client = new SigningCosmWasmClient(httpUrl, faucet.address, signBytes => pen.sign(signBytes)); + const client = new SigningCosmWasmClient(httpUrl, faucet.address, (signBytes) => pen.sign(signBytes)); const wasm = getHackatom(); const meta: UploadMeta = { @@ -92,7 +92,7 @@ describe("SigningCosmWasmClient", () => { it("works with transfer amount", async () => { pendingWithoutWasmd(); const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic); - const client = new SigningCosmWasmClient(httpUrl, faucet.address, signBytes => pen.sign(signBytes)); + const client = new SigningCosmWasmClient(httpUrl, faucet.address, (signBytes) => pen.sign(signBytes)); const { codeId } = await client.upload(getHackatom()); const transferAmount: readonly Coin[] = [ @@ -125,7 +125,7 @@ describe("SigningCosmWasmClient", () => { it("can instantiate one code multiple times", async () => { pendingWithoutWasmd(); const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic); - const client = new SigningCosmWasmClient(httpUrl, faucet.address, signBytes => pen.sign(signBytes)); + const client = new SigningCosmWasmClient(httpUrl, faucet.address, (signBytes) => pen.sign(signBytes)); const { codeId } = await client.upload(getHackatom()); const contractAddress1 = await client.instantiate( @@ -152,7 +152,7 @@ describe("SigningCosmWasmClient", () => { it("works", async () => { pendingWithoutWasmd(); const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic); - const client = new SigningCosmWasmClient(httpUrl, faucet.address, signBytes => pen.sign(signBytes)); + const client = new SigningCosmWasmClient(httpUrl, faucet.address, (signBytes) => pen.sign(signBytes)); const { codeId } = await client.upload(getHackatom()); // instantiate @@ -180,7 +180,7 @@ describe("SigningCosmWasmClient", () => { // execute const result = await client.execute(contractAddress, { release: {} }, undefined); - const wasmEvent = result.logs.find(() => true)?.events.find(e => e.type === "wasm"); + const wasmEvent = result.logs.find(() => true)?.events.find((e) => e.type === "wasm"); assert(wasmEvent, "Event of type wasm expected"); expect(wasmEvent.attributes).toContain({ key: "action", value: "release" }); expect(wasmEvent.attributes).toContain({ @@ -201,7 +201,7 @@ describe("SigningCosmWasmClient", () => { it("works", async () => { pendingWithoutWasmd(); const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic); - const client = new SigningCosmWasmClient(httpUrl, faucet.address, signBytes => pen.sign(signBytes)); + const client = new SigningCosmWasmClient(httpUrl, faucet.address, (signBytes) => pen.sign(signBytes)); // instantiate const transferAmount: readonly Coin[] = [ diff --git a/yarn.lock b/yarn.lock index 09b6b7fb..805ca19b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3247,10 +3247,10 @@ eslint-plugin-import@^2.20.1: read-pkg-up "^2.0.0" resolve "^1.12.0" -eslint-plugin-prettier@^3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.2.tgz#432e5a667666ab84ce72f945c72f77d996a5c9ba" - integrity sha512-GlolCC9y3XZfv3RQfwGew7NnuFDKsfI4lbvRK+PIIo23SFH+LemGs4cKwzAaRa+Mdb+lQO/STaIayno8T5sJJA== +eslint-plugin-prettier@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.3.tgz#ae116a0fc0e598fdae48743a4430903de5b4e6ca" + integrity sha512-+HG5jmu/dN3ZV3T6eCD7a4BlAySdN7mLIbJYo0z1cFQuI+r2DiTJEFeF68ots93PsnrMxbzIZ2S/ieX+mkrBeQ== dependencies: prettier-linter-helpers "^1.0.0" @@ -6246,10 +6246,10 @@ prettier-linter-helpers@^1.0.0: dependencies: fast-diff "^1.1.2" -prettier@^1.19.1: - version "1.19.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" - integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== +prettier@^2: + version "2.0.4" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.4.tgz#2d1bae173e355996ee355ec9830a7a1ee05457ef" + integrity sha512-SVJIQ51spzFDvh4fIbCLvciiDMCrRhlN3mbZvv/+ycjvmF5E73bKdGfU8QDLNmjYJf+lsGnDBC4UUnvTe5OO0w== private@^0.1.8: version "0.1.8"