diff --git a/examples/contracts/aggregator-consumer/src/ocr2/consumer.cairo b/examples/contracts/aggregator-consumer/src/ocr2/consumer.cairo index 6b2222246..5a28ddad1 100644 --- a/examples/contracts/aggregator-consumer/src/ocr2/consumer.cairo +++ b/examples/contracts/aggregator-consumer/src/ocr2/consumer.cairo @@ -1,4 +1,3 @@ - #[contract] mod AggregatorConsumer { use starknet::ContractAddress; @@ -10,7 +9,7 @@ mod AggregatorConsumer { use chainlink::ocr2::aggregator_proxy::IAggregatorDispatcherTrait; struct Storage { - _ocr_address: ContractAddress, + _ocr_address: ContractAddress, } #[constructor] @@ -20,16 +19,11 @@ mod AggregatorConsumer { #[view] fn read_latest_round() -> Round { - IAggregatorDispatcher { - contract_address: _ocr_address::read() - }.latest_round_data() + IAggregatorDispatcher { contract_address: _ocr_address::read() }.latest_round_data() } #[view] fn read_decimals() -> u8 { - IAggregatorDispatcher { - contract_address: _ocr_address::read() - }.decimals() + IAggregatorDispatcher { contract_address: _ocr_address::read() }.decimals() } - } diff --git a/examples/contracts/aggregator-consumer/src/ocr2/price_consumer_with_sequencer.cairo b/examples/contracts/aggregator-consumer/src/ocr2/price_consumer_with_sequencer.cairo index f7d7fa76c..2bd6ac1e3 100644 --- a/examples/contracts/aggregator-consumer/src/ocr2/price_consumer_with_sequencer.cairo +++ b/examples/contracts/aggregator-consumer/src/ocr2/price_consumer_with_sequencer.cairo @@ -1,4 +1,3 @@ - #[contract] mod AggregatorPriceConsumerWithSequencer { use box::BoxTrait; @@ -31,7 +30,7 @@ mod AggregatorPriceConsumerWithSequencer { #[view] fn get_latest_price() -> u128 { assert_sequencer_healthy(); - let round = IAggregatorDispatcher{ + let round = IAggregatorDispatcher { contract_address: _aggregator_address::read() }.latest_round_data(); round.answer @@ -39,7 +38,7 @@ mod AggregatorPriceConsumerWithSequencer { #[external] fn assert_sequencer_healthy() { - let round = IAggregatorDispatcher{ + let round = IAggregatorDispatcher { contract_address: _uptime_feed_address::read() }.latest_round_data(); let timestamp = starknet::info::get_block_info().unbox().block_timestamp; @@ -58,8 +57,5 @@ mod AggregatorPriceConsumerWithSequencer { } } } - - - } diff --git a/examples/contracts/proxy-consumer/src/proxy_consumer.cairo b/examples/contracts/proxy-consumer/src/proxy_consumer.cairo index d3ec3036c..6857628b2 100644 --- a/examples/contracts/proxy-consumer/src/proxy_consumer.cairo +++ b/examples/contracts/proxy-consumer/src/proxy_consumer.cairo @@ -1,4 +1,3 @@ - #[contract] mod ProxyConsumer { use zeroable::Zeroable; @@ -28,25 +27,34 @@ mod ProxyConsumer { )?; let answer = storage_read_syscall( address_domain, storage_address_from_base_and_offset(base, 1_u8) - )?.try_into().unwrap(); + )? + .try_into() + .unwrap(); let block_num = storage_read_syscall( address_domain, storage_address_from_base_and_offset(base, 2_u8) - )?.try_into().unwrap(); + )? + .try_into() + .unwrap(); let started_at = storage_read_syscall( address_domain, storage_address_from_base_and_offset(base, 3_u8) - )?.try_into().unwrap(); + )? + .try_into() + .unwrap(); let updated_at = storage_read_syscall( address_domain, storage_address_from_base_and_offset(base, 4_u8) - )?.try_into().unwrap(); - + )? + .try_into() + .unwrap(); - Result::Ok(Round { - round_id: round_id, - answer: answer, - block_num: block_num, - started_at: started_at, - updated_at: updated_at - }) + Result::Ok( + Round { + round_id: round_id, + answer: answer, + block_num: block_num, + started_at: started_at, + updated_at: updated_at + } + ) } fn write( @@ -56,16 +64,24 @@ mod ProxyConsumer { address_domain, storage_address_from_base_and_offset(base, 0_u8), value.round_id )?; storage_write_syscall( - address_domain, storage_address_from_base_and_offset(base, 1_u8), value.answer.into() + address_domain, + storage_address_from_base_and_offset(base, 1_u8), + value.answer.into() )?; storage_write_syscall( - address_domain, storage_address_from_base_and_offset(base, 2_u8), value.block_num.into() + address_domain, + storage_address_from_base_and_offset(base, 2_u8), + value.block_num.into() )?; storage_write_syscall( - address_domain, storage_address_from_base_and_offset(base, 3_u8), value.started_at.into() + address_domain, + storage_address_from_base_and_offset(base, 3_u8), + value.started_at.into() )?; - storage_write_syscall( - address_domain, storage_address_from_base_and_offset(base, 4_u8), value.updated_at.into() + storage_write_syscall( + address_domain, + storage_address_from_base_and_offset(base, 4_u8), + value.updated_at.into() ) } } @@ -80,11 +96,11 @@ mod ProxyConsumer { assert(!proxy_address.is_zero(), 'proxy address 0'); _proxy_address::write(proxy_address); get_latest_round_data(); - } + } #[external] fn get_latest_round_data() -> Round { - let round = IAggregatorDispatcher{ + let round = IAggregatorDispatcher { contract_address: _proxy_address::read() }.latest_round_data(); _feed_data::write(round);