@@ -424,6 +424,14 @@ module pyth::pyth {
424424        get_price_no_older_than (price_identifier, state::get_stale_price_threshold_secs ())
425425    }
426426
427+     #[view] 
428+     /// A view function version of get_price(...) that's available in offchain programming environments 
429+     /// including aptos fullnode api, aptos cli, and aptos ts sdk. 
430+     public  fun  get_price_by_feed_id (feed_id: vector <u8 >): Price  {
431+         let  price_identifier = price_identifier::from_byte_vec (feed_id);
432+         get_price (price_identifier)
433+     }
434+ 
427435    /// Get the latest available price cached for the given price identifier, if that price is 
428436    /// no older than the given age. 
429437    public  fun  get_price_no_older_than (price_identifier: PriceIdentifier , max_age_secs: u64 ): Price  {
@@ -433,6 +441,12 @@ module pyth::pyth {
433441        price
434442    }
435443
444+     #[view] 
445+     public  fun  get_price_no_older_than_by_feed_id (feed_id: vector <u8 >, max_age_secs: u64 ): Price  {
446+         let  price_identifier = price_identifier::from_byte_vec (feed_id);
447+         get_price_no_older_than (price_identifier, max_age_secs)
448+     }
449+ 
436450    /// Get the latest available price cached for the given price identifier. 
437451    /// 
438452    /// WARNING: the returned price can be from arbitrarily far in the past. 
@@ -446,6 +460,12 @@ module pyth::pyth {
446460            price_info::get_price_feed (&state::get_latest_price_info (price_identifier)))
447461    }
448462
463+     #[view] 
464+     public  fun  get_price_unsafe_by_feed_id (feed_id: vector <u8 >): Price  {
465+         let  price_identifier = price_identifier::from_byte_vec (feed_id);
466+         get_price_unsafe (price_identifier)
467+     }
468+ 
449469    fun  abs_diff (x: u64 , y: u64 ): u64  {
450470        if  (x > y) {
451471            return  x - y
0 commit comments