MCPcopy Create free account
hub / github.com/dfinity/orbit / apply

Method apply

core/station/impl/src/models/request_operation.rs:224–252  ·  view source on GitHub ↗
(&self, assets: &mut Vec<AccountAsset>)

Source from the content-addressed store, hash-verified

222
223impl ChangeAssets {
224 pub fn apply(&self, assets: &mut Vec<AccountAsset>) {
225 match self {
226 ChangeAssets::ReplaceWith { assets: new_assets } => {
227 *assets = new_assets
228 .iter()
229 .map(|asset_id| AccountAsset {
230 asset_id: *asset_id,
231 balance: None,
232 })
233 .collect();
234 }
235 ChangeAssets::Change {
236 add_assets,
237 remove_assets,
238 } => {
239 let existing_assets: HashSet<_> = assets.iter().map(|a| a.asset_id).collect();
240 for asset_id in add_assets {
241 if !existing_assets.contains(asset_id) {
242 assets.push(AccountAsset {
243 asset_id: *asset_id,
244 balance: None,
245 });
246 }
247 }
248
249 assets.retain(|a| !remove_assets.contains(&a.asset_id));
250 }
251 }
252 }
253}
254
255#[storable]

Callers 3

edit_accountMethod · 0.45
test_change_assetsFunction · 0.45
throttleFunction · 0.45

Calls 3

mapMethod · 0.80
iterMethod · 0.80
containsMethod · 0.80

Tested by 1

test_change_assetsFunction · 0.36