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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
//! The public value types every dig-offers builder speaks in.
//!
//! These types are deliberately **key-free**: every side of an offer carries its participant's
//! *public* keys (an `IndexMap<Bytes32, PublicKey>` from a coin's p2 puzzle hash to the public
//! key that authorizes it), never a secret. A builder consumes these, appends unsigned
//! `CoinSpend`s to a caller-owned [`SpendContext`](chia_wallet_sdk::driver::SpendContext), and
//! returns the unsigned artifact for the caller to sign.
use PhantomData;
use ;
use ;
use PublicKey;
use IndexMap;
/// A single asset leg, used to describe what an offer offers or requests in a read-only
/// [`OfferSummary`]. Amounts are the asset's base units (mojos for XCH, base units for CATs);
/// an NFT is always quantity one and identified by its launcher id.
/// The maker's side of a make-offer: the coins it spends into the settlement puzzle (its funding
/// XCH, CAT, and NFT coins), the fungible amounts it offers, and where change returns.
///
/// The funding coins fund the offered amounts (plus any network fee); surplus returns to
/// `change_puzzle_hash`. `owner_keys` maps every funding coin's p2 (inner) puzzle hash to the
/// **public** key that authorizes it — the builder never sees a secret. `nfts` are the NFTs to
/// offer (each spent whole into settlement); they must be parsed in the SAME
/// [`SpendContext`](chia_wallet_sdk::driver::SpendContext) passed to `make_build`, since an NFT
/// carries an allocator-relative metadata pointer.
/// The maker's requested side of a make-offer: what the taker must pay, and where it is paid.
///
/// Every requested payment is notarized to the offer's nonce and asserted (never self-funded).
/// A requested NFT needs its [`NftAssetInfo`] (metadata pointer, royalty) so the settlement
/// puzzle hash can be rebuilt correctly.
/// The taker's funding coins for taking an offer: its spendable XCH, CAT, and NFT coins, and
/// where change / received assets return.
///
/// `owner_keys` maps every funding coin's p2 puzzle hash to the **public** key authorizing it;
/// `change_puzzle_hash` receives change, surplus, and the assets the offer delivers to the taker.
/// NFTs the taker gives up (for an NFT-for-NFT take) are supplied in `nfts`, parsed in the SAME
/// context passed to `take_build`.
/// What a taker must fund to take an offer: the requested-over-offered surplus (the offer's
/// arbitrage). NFTs the taker receives are not a cost; NFTs the taker gives up are expressed by
/// the requested-NFT legs, not here.
/// A read-only summary of an `offer1…` string: what it offers, what it requests, the taker's
/// arbitrage cost, and any NFT royalties it carries. Produced by
/// [`summarize`](crate::summarize) without committing to the offer.
/// The unsigned artifact of [`make_build`](crate::make_build): the coin spends the caller must
/// sign, and the requested-payment context to hand back to [`make_assemble`](crate::make_assemble)
/// once signed.
///
/// **The custody boundary.** `coin_spends` are unsigned; the caller computes their required
/// signatures with [`required_signatures`](crate::required_signatures), signs, aggregates into a
/// `SpendBundle`, and passes that plus `requested_payments` + `requested_asset_info` back to
/// `make_assemble`. dig-offers never produces the signature.
/// The unsigned artifact of [`take_build`](crate::take_build): the taker's own coin spends to
/// sign, the maker's already-signed offer, and the cost the take funds.
///
/// **The custody boundary.** `coin_spends` are the TAKER's unsigned spends only; the maker's half
/// is already signed inside `offer`. The caller signs `coin_spends`, wraps them in a `SpendBundle`,
/// and calls [`take_combine`](crate::take_combine) with `offer` to produce the atomic settlement.
/// The unsigned artifact of [`cancel_build`](crate::cancel_build): the reclaim coin spends the
/// maker must sign to invalidate an outstanding offer.