1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright 2019-2024 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

mod balance_table;
mod state;

use crate::shim::address::Address;
use crate::shim::deal::DealID;
use crate::shim::econ::TokenAmount;
use ahash::HashMap;
use fil_actor_interface::{market, verifreg::AllocationID};
use fvm_ipld_blockstore::Blockstore;

pub trait MarketStateExt {
    fn get_allocations_for_pending_deals(
        &self,
        store: &impl Blockstore,
    ) -> anyhow::Result<HashMap<DealID, AllocationID>>;

    fn get_allocation_id_for_pending_deal(
        &self,
        store: &impl Blockstore,
        deal_id: &DealID,
    ) -> anyhow::Result<AllocationID>;
}

pub trait BalanceTableExt {
    fn for_each<F>(&self, f: F) -> anyhow::Result<()>
    where
        F: FnMut(&Address, &TokenAmount) -> anyhow::Result<()>;
}