Page MenuHomePhabricator

[ecash-agora] Add `historicOffers` function to `Agora`
ClosedPublic

Authored by tobias_ruck on Sep 27 2024, 19:52.

Details

Reviewers
bytesofman
Group Reviewers
Restricted Project
Commits
rABCc97fa359ed0e: [ecash-agora] Add `historicOffers` function to `Agora`
Summary

Allows querying offers made in the past, which were either cancelled or accepted. Unspent offers are ignored.

This reflects what users would expect an "exchange" UX pretty closely: "activeOffers*" is the orderbook, "historicOffers" are the candlesticks (and also the cancelled offers, but those would have to be ignored).

They can also be queried by pubkey, giving users a history of their offers.

This is done by going through the tx history of the token ID/group token ID/pubkey group of the agora plugin, and looking at *inputs* that spend an agora output. We then reconstruct the Utxo, and then we just re-use the _parseOfferUtxo function, which we also gave a status.

Test Plan

npm run integration-tests

Diff Detail

Repository
rABC Bitcoin ABC
Branch
ecash-agora-history
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 30433
Build 60386: Build Diffecash-agora-integration-tests · ecash-agora-tests
Build 60385: arc lint + arc unit

Event Timeline

modules/ecash-agora/src/agora.ts
610 ↗(On Diff #49842)

do we know that all inputscripts we get here will be of the expected agora types?

in theory, anyone could put any input script together and use the agora lokad.

do we need further validation to make sure we aren't trying to parse unexpected scripts?

612 ↗(On Diff #49842)

why == and not ===

modules/ecash-agora/tests/partial.alp.test.ts
601 ↗(On Diff #49842)

why != instead of !== ?

modules/ecash-agora/src/agora.ts
610 ↗(On Diff #49842)

The plugin should already catch it (see the if a few lines above it); but worst case this will just make opIsCanceled undefined and then the == just compares to undefined, giving us isCanceled = false

This revision is now accepted and ready to land.Oct 1 2024, 20:25