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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright 2019-2024 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use super::*;

impl From<DealState> for ApiDealState {
    fn from(s: DealState) -> Self {
        let DealState {
            sector_start_epoch,
            last_updated_epoch,
            slash_epoch,
            verified_claim,
        } = s;
        Self {
            sector_start_epoch,
            last_updated_epoch,
            slash_epoch,
            verified_claim,
        }
    }
}

impl From<DealProposal> for ApiDealProposal {
    fn from(p: DealProposal) -> Self {
        let DealProposal {
            piece_cid,
            piece_size,
            verified_deal,
            client,
            provider,
            label,
            start_epoch,
            end_epoch,
            storage_price_per_epoch,
            provider_collateral,
            client_collateral,
        } = p;
        Self {
            piece_cid,
            piece_size: piece_size.0,
            verified_deal,
            client: client.into(),
            provider: provider.into(),
            label,
            start_epoch,
            end_epoch,
            storage_price_per_epoch: storage_price_per_epoch.into(),
            provider_collateral: provider_collateral.into(),
            client_collateral: client_collateral.into(),
        }
    }
}

impl From<MarketDeal> for ApiMarketDeal {
    fn from(d: MarketDeal) -> Self {
        Self {
            proposal: d.proposal.into(),
            state: d.state.into(),
        }
    }
}