Skip to content

Commit 6c59d09

Browse files
committed
reset most of main.sw update_price_feeds helper function
1 parent 9a7a1d4 commit 6c59d09

File tree

1 file changed

+15
-12
lines changed
  • target_chains/fuel/contracts/pyth-contract/src

1 file changed

+15
-12
lines changed

target_chains/fuel/contracts/pyth-contract/src/main.sw

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ impl PythCore for Contract {
272272

273273
#[storage(read, write), payable]
274274
fn update_price_feeds(update_data: Vec<Bytes>) {
275-
275+
update_price_feeds(update_data)
276276
}
277277

278278
#[storage(read, write), payable]
@@ -293,6 +293,7 @@ impl PythCore for Contract {
293293
if latest_publish_time(price_feed_ids.get(i).unwrap()) < publish_times.get(i).unwrap()
294294
{
295295
update_price_feeds(update_data);
296+
return;
296297
}
297298

298299
i += 1;
@@ -373,25 +374,23 @@ fn update_fee(update_data: Vec<Bytes>) -> u64 {
373374
total_fee(total_number_of_updates, storage.single_update_fee)
374375
}
375376

376-
#[storage(read, write)]
377+
#[storage(read, write), payable]
377378
fn update_price_feeds(update_data: Vec<Bytes>) {
378379
require(
379380
msg_asset_id() == AssetId::base(),
380381
PythError::FeesCanOnlyBePaidInTheBaseAsset,
381382
);
382383

383-
let required_fee = update_fee(update_data);
384-
require(msg_amount() >= required_fee, PythError::InsufficientFee);
385-
386384
let mut total_number_of_updates = 0;
387385

386+
// let mut updated_price_feeds: Vec<PriceFeedId> = Vec::new(); // TODO: requires append for Vec
388387
let mut i = 0;
389388
while i < update_data.len() {
390389
let data = update_data.get(i).unwrap();
391390

392391
match UpdateType::determine_type(data) {
393392
UpdateType::Accumulator(accumulator_update) => {
394-
let (number_of_updates, updated_ids) = accumulator_update.update_price_feeds(
393+
let (number_of_updates, _updated_ids) = accumulator_update.update_price_feeds(
395394
current_guardian_set_index(),
396395
storage
397396
.wormhole_guardian_sets,
@@ -400,11 +399,11 @@ fn update_price_feeds(update_data: Vec<Bytes>) {
400399
storage
401400
.is_valid_data_source,
402401
);
402+
// updated_price_feeds.append(updated_ids); // TODO: requires append for Vec
403403
total_number_of_updates += number_of_updates;
404-
log(UpdatedPriceFeedsEvent { updated_price_feeds: updated_ids });
405404
},
406405
UpdateType::BatchAttestation(batch_attestation_update) => {
407-
let updated_ids = batch_attestation_update.update_price_feeds(
406+
let _updated_ids = batch_attestation_update.update_price_feeds(
408407
current_guardian_set_index(),
409408
storage
410409
.wormhole_guardian_sets,
@@ -413,16 +412,20 @@ fn update_price_feeds(update_data: Vec<Bytes>) {
413412
storage
414413
.is_valid_data_source,
415414
);
415+
// updated_price_feeds.append(updated_ids); // TODO: requires append for Vec
416416
total_number_of_updates += 1;
417-
log(UpdatedPriceFeedsEvent { updated_price_feeds: updated_ids });
418417
},
419418
}
420419

421420
i += 1;
422421
}
423422

424-
let fee = total_fee(total_number_of_updates, storage.single_update_fee);
425-
require(msg_amount() >= fee, PythError::InsufficientFee);
423+
let required_fee = total_fee(total_number_of_updates, storage.single_update_fee);
424+
require(msg_amount() >= required_fee, PythError::InsufficientFee);
425+
426+
// log(UpdatedPriceFeedsEvent { // TODO: requires append for Vec
427+
// updated_price_feeds,
428+
// })
426429
}
427430

428431
#[storage(read)]
@@ -931,4 +934,4 @@ fn verify_governance_vm(encoded_vm: Bytes) -> WormholeVM {
931934

932935
set_last_executed_governance_sequence(vm.sequence);
933936
vm
934-
}
937+
}

0 commit comments

Comments
 (0)