Skip to content

Commit

Permalink
Merge branch 'main' into feat/store-events
Browse files Browse the repository at this point in the history
  • Loading branch information
ALPAC-4 committed Dec 5, 2024
2 parents 36dd4a2 + ef23680 commit c0d899f
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 6 deletions.
11 changes: 11 additions & 0 deletions .github/config/.codespellignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cips
pullrequest
keypair
pastTime
hasTables
Nam
EyT
upTo
initia
minitia
expRes
28 changes: 28 additions & 0 deletions .github/workflows/spellcheck.yml
Original file line number Diff line number Diff line change
@@ -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,*.git" --ignore-words=.github/config/.codespellignore
- uses: peter-evans/[email protected]
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.
Empty file added src/chain/index.ts
Empty file.
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import express from 'express'
import { registery } from './lib/metric'
import { registry } from './lib/metric'
import { info } from './lib/logger'

import { config } from './lib/config'
Expand All @@ -18,8 +18,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'))
Expand Down
6 changes: 3 additions & 3 deletions src/lib/metric.ts
Original file line number Diff line number Diff line change
@@ -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(),
Expand Down Expand Up @@ -91,6 +91,6 @@ interface ChainMetric {
}

function register(metric: Counter): Counter {
registery.registerMetric(metric)
registry.registerMetric(metric)
return metric
}
41 changes: 41 additions & 0 deletions src/msgs/recvPacet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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 { Transform } from 'src/lib/transform'
import { getRawProof } from 'src/lib/rawProof'
import { convertProofsToIcs23 } from './ack'

export async function generateMsgRecvPacket(
srcChain: Chain,
destChain: Chain,
packet: Packet,
height: Height
) {
const proof = await getPacketProof(destChain, packet, height)
const msg = new MsgRecvPacket(
packet,
proof,
Transform.height(height),
srcChain.wallet.address()
)

return msg
}

async function getPacketProof(
destChain: Chain,
packet: Packet,
headerHeight: Height
): Promise<string> {
const key = new Uint8Array(
Buffer.from(
`commitments/ports/${packet.source_port}/channels/${packet.source_channel}/sequences/${packet.sequence}`
)
)
const proof = await getRawProof(destChain, key, headerHeight)

const ics23Proof = convertProofsToIcs23(proof)

return Buffer.from(ics23Proof).toString('base64')
}

0 comments on commit c0d899f

Please sign in to comment.