From 4488e3757c76e23a2b39932bdb6e40ac0417e102 Mon Sep 17 00:00:00 2001 From: Vritra4 Date: Fri, 15 Nov 2024 17:00:40 +0900 Subject: [PATCH 1/3] add spellchecker and run --- .github/config/.codespellignore | 11 +++++++++++ .github/workflows/spellcheck.yml | 28 ++++++++++++++++++++++++++++ src/chain/index.ts | 4 ++-- src/index.ts | 6 +++--- src/lib/metric.ts | 6 +++--- src/lib/transform.ts | 2 +- src/msgs/ack.ts | 4 ++-- src/msgs/recvPacet.ts | 4 ++-- src/msgs/timeout.ts | 4 ++-- 9 files changed, 54 insertions(+), 15 deletions(-) create mode 100644 .github/config/.codespellignore create mode 100644 .github/workflows/spellcheck.yml diff --git a/.github/config/.codespellignore b/.github/config/.codespellignore new file mode 100644 index 0000000..a08537a --- /dev/null +++ b/.github/config/.codespellignore @@ -0,0 +1,11 @@ +cips +pullrequest +keypair +pastTime +hasTables +Nam +EyT +upTo +initia +minitia +expRes diff --git a/.github/workflows/spellcheck.yml b/.github/workflows/spellcheck.yml new file mode 100644 index 0000000..15fe10f --- /dev/null +++ b/.github/workflows/spellcheck.yml @@ -0,0 +1,28 @@ +name: Spell Check + +on: + pull_request: + +jobs: + spellcheck: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Run codespell + continue-on-error: true + run: | + sudo apt-get install codespell -y + codespell -w --skip="*.json,*.mjs" --ignore-words=.github/config/.codespellignore + - uses: peter-evans/create-pull-request@v7.0.5 + if: github.event_name != 'pull_request' + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "chore: fix typos" + title: "chore: fix typos" + branch: "chore/fix-typos" + delete-branch: true + body: | + This PR fixes typos in the codebase. + Please review it, and merge if everything is fine. + If there are proto changes, run `make proto-gen` and commit the changes. diff --git a/src/chain/index.ts b/src/chain/index.ts index 2b56cbc..ce6e133 100644 --- a/src/chain/index.ts +++ b/src/chain/index.ts @@ -207,7 +207,7 @@ export class Chain { this.packetsToHandle = this.packetsToHandle.slice(packets.length) } } catch (e) { - this.error(`Fail to handle packet. resonse - ${e}`) + this.error(`Fail to handle packet. response - ${e}`) } finally { this.workers['packet_handler'] = new Date().valueOf() await delay(1000) @@ -255,7 +255,7 @@ export class Chain { this.packetsToHandle.push(...results) this.fedHeight = heights[heights.length - 1] } catch (e) { - this.error(`Fail to fetch block result. resonse - ${e}`) + this.error(`Fail to fetch block result. response - ${e}`) } finally { this.workers['event_feeder'] = new Date().valueOf() await delay(100) diff --git a/src/index.ts b/src/index.ts index 6febb20..a799385 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,7 +3,7 @@ import express from 'express' import { runPair } from './lib/chainPair' import { config } from './lib/config' import { ChainStatus } from './chain/types' -import { registery } from './lib/metric' +import { registry } from './lib/metric' import { info } from './lib/logger' async function main() { @@ -33,8 +33,8 @@ async function main() { const metricApp = express() metricApp.get('/metrics', (req, res) => { - res.setHeader('content-type', registery.contentType) - registery + res.setHeader('content-type', registry.contentType) + registry .metrics() .then((response) => res.send(response)) .catch(() => res.status(500).send('Fail to get metrics')) diff --git a/src/lib/metric.ts b/src/lib/metric.ts index 3108c3e..d4498cb 100644 --- a/src/lib/metric.ts +++ b/src/lib/metric.ts @@ -1,8 +1,8 @@ import { Registry, Counter, collectDefaultMetrics } from 'prom-client' -export const registery = new Registry() +export const registry = new Registry() -collectDefaultMetrics({ register: registery }) +collectDefaultMetrics({ register: registry }) export const metrics = { chain: createChainMetric(), @@ -91,6 +91,6 @@ interface ChainMetric { } function register(metric: Counter): Counter { - registery.registerMetric(metric) + registry.registerMetric(metric) return metric } diff --git a/src/lib/transform.ts b/src/lib/transform.ts index 360d381..31030a6 100644 --- a/src/lib/transform.ts +++ b/src/lib/transform.ts @@ -1,7 +1,7 @@ import { Height as CosmjsHeight } from 'cosmjs-types/ibc/core/client/v1/client' import { Height as InitiajsHeight } from '@initia/initia.js' -export class Transfrom { +export class Transform { static height(height: CosmjsHeight): InitiajsHeight static height(height: InitiajsHeight): CosmjsHeight diff --git a/src/msgs/ack.ts b/src/msgs/ack.ts index 2b24509..f70db42 100644 --- a/src/msgs/ack.ts +++ b/src/msgs/ack.ts @@ -5,7 +5,7 @@ import { ProofOps } from 'cosmjs-types/tendermint/crypto/proof' import { CommitmentProof } from 'cosmjs-types/cosmos/ics23/v1/proofs' import { MerkleProof } from 'cosmjs-types/ibc/core/commitment/v1/commitment' import { Chain } from 'src/chain' -import { Transfrom } from 'src/lib/transform' +import { Transform } from 'src/lib/transform' import { getRawProof } from 'src/lib/rawProof' export async function generateMsgAck( @@ -19,7 +19,7 @@ export async function generateMsgAck( ack.packet, ack.acknowledgement, proof, - Transfrom.height(height), + Transform.height(height), srcChain.wallet.address() ) diff --git a/src/msgs/recvPacet.ts b/src/msgs/recvPacet.ts index 8f8c858..7bba2e5 100644 --- a/src/msgs/recvPacet.ts +++ b/src/msgs/recvPacet.ts @@ -2,7 +2,7 @@ import { Packet } from '@initia/initia.js' import { MsgRecvPacket } from '@initia/initia.js/dist/core/ibc/core/channel/msgs' import { Height } from 'cosmjs-types/ibc/core/client/v1/client' import { Chain } from 'src/chain' -import { Transfrom } from 'src/lib/transform' +import { Transform } from 'src/lib/transform' import { getRawProof } from 'src/lib/rawProof' import { convertProofsToIcs23 } from './ack' @@ -16,7 +16,7 @@ export async function generateMsgRecvPacket( const msg = new MsgRecvPacket( packet, proof, - Transfrom.height(height), + Transform.height(height), srcChain.wallet.address() ) diff --git a/src/msgs/timeout.ts b/src/msgs/timeout.ts index dab6f63..fa804b4 100644 --- a/src/msgs/timeout.ts +++ b/src/msgs/timeout.ts @@ -2,7 +2,7 @@ import { MsgTimeout } from '@initia/initia.js/dist/core/ibc/core/channel/msgs' import { Height } from 'cosmjs-types/ibc/core/client/v1/client' import { Uint64 } from '@cosmjs/math' import { Chain } from 'src/chain' -import { Transfrom } from 'src/lib/transform' +import { Transform } from 'src/lib/transform' import { Packet } from '@initia/initia.js' import { getRawProof } from 'src/lib/rawProof' import { convertProofsToIcs23 } from './ack' @@ -20,7 +20,7 @@ export async function generateMsgTimeout( return new MsgTimeout( packet, proof, - Transfrom.height(proofHeight), + Transform.height(proofHeight), sequence, srcChain.wallet.address() ) From 85743907d47654ae9f4ed97b253861ddad7f8e11 Mon Sep 17 00:00:00 2001 From: Vritra4 Date: Fri, 15 Nov 2024 17:01:59 +0900 Subject: [PATCH 2/3] chore --- .github/workflows/spellcheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/spellcheck.yml b/.github/workflows/spellcheck.yml index 15fe10f..dcdf533 100644 --- a/.github/workflows/spellcheck.yml +++ b/.github/workflows/spellcheck.yml @@ -13,7 +13,7 @@ jobs: continue-on-error: true run: | sudo apt-get install codespell -y - codespell -w --skip="*.json,*.mjs" --ignore-words=.github/config/.codespellignore + codespell -w --skip="*.json,*.mjs,*.git" --ignore-words=.github/config/.codespellignore - uses: peter-evans/create-pull-request@v7.0.5 if: github.event_name != 'pull_request' with: From 4b3a024b7a3e701bb65a451dac1439e70f363cae Mon Sep 17 00:00:00 2001 From: Vritra4 Date: Fri, 15 Nov 2024 17:05:41 +0900 Subject: [PATCH 3/3] manual fix --- src/chain/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/chain/index.ts b/src/chain/index.ts index ce6e133..089f9f1 100644 --- a/src/chain/index.ts +++ b/src/chain/index.ts @@ -266,13 +266,13 @@ export class Chain { private async latestHeightWorker() { // to prevent rerun if ( - (this.workers['latest_height_worekr'] ?? 0) > + (this.workers['latest_height_worker'] ?? 0) > new Date().valueOf() - 5 * 60 * 1000 ) { return } - this.debug('Activate latest height worekr') + this.debug('Activate latest height worker') // TODO add websocket options const MAX_RETRY = 10 @@ -308,7 +308,7 @@ export class Chain { ) } } finally { - this.workers['latest_height_worekr'] = new Date().valueOf() + this.workers['latest_height_worker'] = new Date().valueOf() await delay(1000) } }