transfer: a non-container resource can be transferred beyond its on-hand/accounting quantity

Aperta
#86 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
elixir
Ambito
backend, databases

Direzione di ricerca

Start in src/zenflows/vf/economic_event/domain.ex, especially EconomicEvent.Domain.handle_insert/3 for transfer and the cited quantity update sections. Read the existing container checks and related transfer tests, then add coverage for transfers above the held quantity and exactly equal to it, including transferCustody and transferAllRights if their checks belong there. Done when invalid transfers are rejected with clear errors and valid boundary transfers pass.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Problem

A transfer of a resource that is not a container does not check the event's resourceQuantity against the source resource's quantities. A provider can transfer more than they hold. The source resource's onhandQuantity and accountingQuantity then go negative, and the receiver gets the full amount.

In EconomicEvent.Domain.handle_insert/3 for transfer, the quantity checks apply only when res.container?. For a plain resource, the update then decrements both quantities by the event's quantity with no lower bound (L980-L990, L1023-L1029).

Example: a resource with on-hand 1, transfer of 5. The event is accepted, the source goes to -4 and the receiver's new resource holds 5.

Why it matters now

The marketplace (interfacer-medusa) is moving from one-unit listings to N units (interfacerproject/interfacer-gui#962, interfacerproject/interfacer-medusa#7). That PR now re-reads the on-hand quantity before every delivery and refuses an overdraw. But the ledger itself should not accept a quantity that does not exist, whoever the client is.

Proposal

For a non-container source, refuse when resource_quantity > accounting_quantity or resource_quantity > onhand_quantity, with errors in the style of the existing ones. For example: "the transfer events can't transfer more than the resource's accounting-quantity" / "onhand-quantity". The same check probably applies to transferCustody (on-hand) and transferAllRights (accounting). Add tests for 'more than held' and 'exactly what is held'.

Found while working on interfacerproject/interfacer-gui#962. Not reproduced against a running instance; read from the code at 91be858.


Generated by Claude Code

Lingua principale
Elixir
Stelle
18
Fork
4
Merge medio
22g 17h
PR unite (30g)
1

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di interfacerproject/zenflows

Tutte le issue di interfacerproject/zenflows

Issue simili

Altre issue su Elixir

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.