Skip to content

Commit 9c18d7c

Browse files
fixes
1 parent f0a369f commit 9c18d7c

File tree

1 file changed

+7
-12
lines changed
  • contracts/price-aggregator/src

1 file changed

+7
-12
lines changed

contracts/price-aggregator/src/lib.rs

+7-12
Original file line numberDiff line numberDiff line change
@@ -130,22 +130,17 @@ pub trait PriceAggregator:
130130
self.require_not_paused();
131131
self.require_is_oracle();
132132

133-
let current_timestamp = self.blockchain().get_block_timestamp();
134-
require!(
135-
submission_timestamp <= current_timestamp,
136-
"Timestamp is from the future"
137-
);
133+
self.require_valid_submission_timestamp(submission_timestamp);
138134

139135
self.check_decimals(&from, &to, decimals);
140136

141-
self.submit_unchecked(from, to, submission_timestamp, price, decimals);
137+
self.submit_unchecked(from, to, price, decimals);
142138
}
143139

144140
fn submit_unchecked(
145141
&self,
146142
from: ManagedBuffer,
147143
to: ManagedBuffer,
148-
submission_timestamp: u64,
149144
price: BigUint,
150145
decimals: u8,
151146
) {
@@ -206,7 +201,7 @@ pub trait PriceAggregator:
206201
self.emit_discard_submission_event(
207202
&token_pair,
208203
round_id,
209-
submission_timestamp,
204+
current_timestamp,
210205
first_submission_timestamp,
211206
has_caller_already_submitted,
212207
);
@@ -220,7 +215,8 @@ pub trait PriceAggregator:
220215
});
221216
}
222217

223-
fn require_valid_submission_timestamp(&self, submission_timestamp: u64, current_timestamp: u64) {
218+
fn require_valid_submission_timestamp(&self, submission_timestamp: u64) {
219+
let current_timestamp = self.blockchain().get_block_timestamp();
224220
require!(
225221
submission_timestamp <= current_timestamp,
226222
"Timestamp is from the future"
@@ -239,16 +235,15 @@ pub trait PriceAggregator:
239235
self.require_not_paused();
240236
self.require_is_oracle();
241237

242-
let current_timestamp = self.blockchain().get_block_timestamp();
243238
for (from, to, submission_timestamp, price, decimals) in submissions
244239
.into_iter()
245240
.map(|submission| submission.into_tuple())
246241
{
247-
self.require_valid_submission_timestamp(submission_timestamp, current_timestamp);
242+
self.require_valid_submission_timestamp(submission_timestamp);
248243

249244
self.check_decimals(&from, &to, decimals);
250245

251-
self.submit_unchecked(from, to, submission_timestamp, price, decimals);
246+
self.submit_unchecked(from, to, price, decimals);
252247
}
253248
}
254249

0 commit comments

Comments
 (0)