Skip to content

[CONTRACT] Implement Multi-Token Escrow Support #142

@dinahmaccodes

Description

@dinahmaccodes

Description

Extend the escrow system to support multiple token contracts per shipment.
Different shipments can hold escrow in different SAC or custom token contracts.

Tasks

  • Add token_address: Address field to Shipment struct
  • Add token_address parameter to create_shipment() (required)
  • Update escrow storage: key pattern (Symbol("shipment_token"), shipment_id) → Address
  • Update deposit_escrow() to use per-shipment token address
  • Update release_escrow() and refund_escrow() to use per-shipment token
  • Add get_shipment_token(shipment_id) → Result<Address, NavinError> query
  • Emit token_address in: escrow_deposited, escrow_released, escrow_refunded events

Acceptance Criteria

  • Different shipments hold escrow in different token contracts independently
  • Token address stored immutably per shipment, used consistently in all escrow ops
  • Escrow operations reject if token_address doesn't match shipment record
  • Unit tests:
    • Single shipment, single token
    • Two shipments, two different tokens, verify independent balances
    • Cross-token rejection (attempt wrong token on shipment)
    • get_shipment_token() returns correct address per shipment

PR Checklist

  • Shipment struct extended with token_address
  • Storage key pattern documented
  • All escrow functions updated
  • Event signatures updated (all 3 escrow events emit token address)
  • 4+ unit tests passing
  • All CI checks pass

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions