Skip to content

TS: Query for DepositRevealed events#457

Merged
lukasz-zimnoch merged 14 commits into
mainfrom
ts-events
Jan 23, 2023
Merged

TS: Query for DepositRevealed events#457
lukasz-zimnoch merged 14 commits into
mainfrom
ts-events

Conversation

@nkuba
Copy link
Copy Markdown
Member

@nkuba nkuba commented Jan 4, 2023

In this PR we add a function to query for DepositRevealed events emitted by the Bridge contract.

Depends on #454

nkuba added 2 commits January 4, 2023 17:20
The Event type will be extended by specific events definition to include
common properties that exist on each chain event.
A common function to query events from contract.
@nkuba nkuba self-assigned this Jan 4, 2023
@nkuba nkuba added the 🔌 typescript TypeScript library label Jan 4, 2023
Base automatically changed from ts-contract-class to main January 5, 2023 09:25
Comment thread typescript/src/chain.ts Outdated
Comment thread typescript/src/chain.ts Outdated
Comment thread typescript/src/chain.ts Outdated
Comment thread typescript/src/deposit.ts Outdated
Comment thread typescript/src/ethereum.ts Outdated
Comment thread typescript/src/ethereum.ts Outdated
nkuba added 4 commits January 23, 2023 15:19
We agreed in #457 (comment)
that this name is better for our usecase.
The generic interface for Bridge contracts should define
getDepositRevealedEvents function.

We added a generic GetEventsFunction that should be used by other events
getting functions.
The TransactionHash type expects to hold a hash in the same order as
block explorers (RPC order). But the Bridge contract expects a hash in
the format that is used by bitcoin natively (internal byte order). The
event emitts the hash in the internal byte order, so we need to reverse
it.
@nkuba nkuba requested a review from lukasz-zimnoch January 23, 2023 14:26
Comment thread typescript/src/ethereum.ts
nkuba added 3 commits January 23, 2023 15:49
The function is required by the interface.
The chain interface expects hexadecimal values to be stores as
un-prefixed strings. The Ethereum handles such values with `0x` prefix
by default. We need to convert the values to conform with the interface.

TODO:
To make dveloment easier and prevent from unexpected runtime errors we
need to handle the properties with Hex type.
@nkuba nkuba requested a review from lukasz-zimnoch January 23, 2023 15:17
@lukasz-zimnoch lukasz-zimnoch merged commit ffeb84c into main Jan 23, 2023
@lukasz-zimnoch lukasz-zimnoch deleted the ts-events branch January 23, 2023 15:27
nkuba added a commit that referenced this pull request Jan 23, 2023
…equestedEvents

This change is made based on the agreements from #457
lukasz-zimnoch added a commit that referenced this pull request Jan 24, 2023
This PR introduces changes necessary for the TBTCv2 Maintainer.

Depends on:
#454
#457
#458
#459
@pdyraga pdyraga added this to the typescript/v1.0.0 milestone Jan 31, 2023
mswilkison added a commit that referenced this pull request May 26, 2026
Codex review on PR #457 caught two P1s that I'm addressing here in PR
#971:

P1 #1: workflows in .github/workflows/ are monorepo-coupled, won't run
in canonical
- ci-formal-verification.yml + nightly-formal-invariants.yml both use:
  - `pnpm install --frozen-lockfile` (canonical has no pnpm-lock.yaml,
    isn't a pnpm workspace)
  - `pnpm --filter @keep-network/tbtc-v2 run test:formal-invariants`
    (canonical isn't a pnpm workspace)
  - `npm run formal:vectors:check` (canonical root package.json has
    no such script)
- Manifest update PR #457 reclassifies these from allowlisted-divergence
  to excluded. Canonical tbtc-v2 already has its own CI matrix
  (contracts.yml, etc.). If formal-verification CI belongs in canonical,
  it can be added as canonical-native workflows in a follow-up — not
  ports of monorepo-coupled YAML.

P1 #2: P2TR script rootDir mis-resolves under solidity/
- Scripts use `path.resolve(scriptDir, "../..")` to compute rootDir
- Under canonical layout (scripts at solidity/scripts/formal/), that
  resolves to `solidity/`, not canonical repo root
- Vector path `docs/test-vectors/p2tr-signature-fraud-v0.json` then
  joins to `solidity/docs/test-vectors/...` which doesn't exist (vectors
  live at canonical root's docs/test-vectors/)
- Fix: change rootDir to `path.resolve(scriptDir, "../../..")` so it
  escapes solidity/ and resolves to canonical root. Contract path
  references (already prefixed solidity/contracts/...) and vector
  path (docs/test-vectors/...) both resolve correctly relative to
  canonical root.

Net change to PR #971
- 2 files modified: rootDir fix in both retained P2TR scripts
- 2 files deleted: ci-formal-verification.yml + nightly-formal-invariants.yml

Source manifest PR #457 is being updated separately:
- ci-formal-verification.yml + nightly-formal-invariants.yml reclassified
  from allowlisted-divergence to excluded
- expectedTargetSha256 for the 2 fixed P2TR scripts recomputed against
  the new content

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
mswilkison added a commit that referenced this pull request May 26, 2026
Codex P1 re-review on PR #457 caught that the path-normalization commit
b0b8841 (rootDir fix) left a stale issue: scripts still reference
vectors under docs/rfc/frost-migration/ which is where my earlier
blanket `docs/frost-migration/` → `docs/rfc/frost-migration/` sed
rewrite put them. But the source manifest maps the actual vector files
to docs/test-vectors/:

- docs/frost-migration/test-vectors/p2tr-signature-fraud-v0.json
  → docs/test-vectors/p2tr-signature-fraud-v0.json
- docs/frost-migration/p2tr-signature-fraud-spend-type-closure.json
  → docs/test-vectors/p2tr-signature-fraud-spend-type-closure.json

So scripts looked for vectors at docs/rfc/frost-migration/test-vectors/
... but vectors actually live at docs/test-vectors/... in canonical.

Fix
- check_p2tr_signature_fraud_vectors.mjs:
  vector path docs/rfc/frost-migration/test-vectors/p2tr-signature-
  fraud-v0.json → docs/test-vectors/p2tr-signature-fraud-v0.json
- check_p2tr_spend_type_closure.mjs (3 references):
  - spend-type closure manifest:
    docs/rfc/frost-migration/p2tr-signature-fraud-spend-type-closure.json
    → docs/test-vectors/p2tr-signature-fraud-spend-type-closure.json
  - vector path (2 occurrences):
    docs/rfc/frost-migration/test-vectors/p2tr-signature-fraud-v0.json
    → docs/test-vectors/p2tr-signature-fraud-v0.json

References to docs/rfc/frost-migration/p2tr-signature-fraud-execution-spec.md
remain (the execution spec IS a doc that lives at docs/rfc/
frost-migration/ in canonical, per the manifest classifier — this
reference is correct).

PR #457 (manifest update) will be updated with the new
expectedTargetSha256 values:
- check_p2tr_signature_fraud_vectors.mjs: 3c21279e43... →
  5b88c84d174c9ddcd27eb3350cb6c5755c4c29db21252bf70fc27693d17fe186
- check_p2tr_spend_type_closure.mjs: 64e41cc057... →
  116d16ebdea93f466a6f0c7b7d34448e5c6440a42254f53b959ceb9affa339e9

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔌 typescript TypeScript library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants