Skip to content

Commit 825b7ec

Browse files
authored
Remove as conversions from rust_oracle.rs (#282)
1 parent 6f53073 commit 825b7ec

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

program/rust/src/rust_oracle.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,14 @@ pub fn upd_price(
228228
let price_data = load_checked::<PriceAccount>(price_account, cmd_args.header.version)?;
229229

230230
// Verify that publisher is authorized
231-
while publisher_index < price_data.num_ as usize {
231+
while publisher_index < try_convert::<u32, usize>(price_data.num_)? {
232232
if price_data.comp_[publisher_index].pub_ == *funding_account.key {
233233
break;
234234
}
235235
publisher_index += 1;
236236
}
237237
pyth_assert(
238-
publisher_index < price_data.num_ as usize,
238+
publisher_index < try_convert::<u32, usize>(price_data.num_)?,
239239
ProgramError::InvalidArgument,
240240
)?;
241241

@@ -445,7 +445,7 @@ pub fn init_price(
445445
0,
446446
size_of::<PriceInfo>(),
447447
);
448-
for i in 0..(price_data.comp_.len() as usize) {
448+
for i in 0..price_data.comp_.len() {
449449
sol_memset(
450450
bytes_of_mut(&mut price_data.comp_[i].agg_),
451451
0,
@@ -491,7 +491,7 @@ pub fn add_publisher(
491491
return Err(ProgramError::InvalidArgument);
492492
}
493493

494-
for i in 0..(price_data.num_ as usize) {
494+
for i in 0..(try_convert::<u32, usize>(price_data.num_)?) {
495495
if cmd_args.publisher == price_data.comp_[i].pub_ {
496496
return Err(ProgramError::InvalidArgument);
497497
}
@@ -537,9 +537,9 @@ pub fn del_publisher(
537537

538538
let mut price_data = load_checked::<PriceAccount>(price_account, cmd_args.header.version)?;
539539

540-
for i in 0..(price_data.num_ as usize) {
540+
for i in 0..(try_convert::<u32, usize>(price_data.num_)?) {
541541
if cmd_args.publisher == price_data.comp_[i].pub_ {
542-
for j in i + 1..(price_data.num_ as usize) {
542+
for j in i + 1..(try_convert::<u32, usize>(price_data.num_)?) {
543543
price_data.comp_[j - 1] = price_data.comp_[j];
544544
}
545545
price_data.num_ -= 1;

0 commit comments

Comments
 (0)