Skip to content

Commit

Permalink
Merge pull request #14 from initia-labs/fix/oracle-view
Browse files Browse the repository at this point in the history
fix: compiler to report error after extended check
  • Loading branch information
beer-1 authored Mar 20, 2024
2 parents 8423863 + f61225c commit 01bd626
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/compiler/src/built_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ impl BuiltPackage {

// Run extended checks as well derive runtime metadata
let model = &model_opt.expect("move model");
let runtime_metadata = extended_checks::run_extended_checks(model);
if model.diag_count(Severity::Warning) > 0 {
let mut error_writer = StandardStream::stderr(ColorChoice::Auto);
model.report_diag(&mut error_writer, Severity::Warning);
Expand All @@ -92,7 +93,6 @@ impl BuiltPackage {
}
}

let runtime_metadata = extended_checks::run_extended_checks(model);
let compiled_pkg_path = package
.compiled_package_info
.build_flags
Expand Down
Binary file modified precompile/binaries/minlib/oracle.mv
Binary file not shown.
8 changes: 4 additions & 4 deletions precompile/modules/minitia_stdlib/sources/oracle.move
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ module minitia_std::oracle {
use minitia_std::string::{Self, String};

#[view]
public fun get_price(pair_id: &String): (u256, u64, u64) {
get_price_internal(*string::bytes(pair_id))
public fun get_price(pair_id: String): (u256, u64, u64) {
get_price_internal(*string::bytes(&pair_id))
}

native fun get_price_internal(pair_id: vector<u8>): (u256, u64, u64);
Expand Down Expand Up @@ -33,12 +33,12 @@ module minitia_std::oracle {
set_price(&btc_usd_pair_id, btc_price, btc_updated_at, btc_decimals);
set_price(&eth_usd_pair_id, eth_price, eth_updated_at, eth_decimals);

let (price, updated_at, decimals) = get_price(&btc_usd_pair_id);
let (price, updated_at, decimals) = get_price(btc_usd_pair_id);
assert!(btc_price == price, 0);
assert!(btc_updated_at == updated_at, 0);
assert!(btc_decimals == decimals, 0);

let (price, updated_at, decimals) = get_price(&eth_usd_pair_id);
let (price, updated_at, decimals) = get_price(eth_usd_pair_id);
assert!(eth_price == price, 0);
assert!(eth_updated_at == updated_at, 0);
assert!(eth_decimals == decimals, 0);
Expand Down

0 comments on commit 01bd626

Please sign in to comment.