|
| 1 | +{- |
| 2 | + This test contract is an upgraded version of PythTest.fc. This is used to test the upgrade functionality of the Pyth contract. |
| 3 | +-} |
| 4 | + |
| 5 | +#include "../imports/stdlib.fc"; |
| 6 | +#include "../Pyth.fc"; |
| 7 | +#include "../Wormhole.fc"; |
| 8 | +#include "../common/op.fc"; |
| 9 | + |
| 10 | +() recv_internal(int balance, int msg_value, cell in_msg_full, slice in_msg_body) impure { |
| 11 | + if (in_msg_body.slice_empty?()) { |
| 12 | + return (); |
| 13 | + } |
| 14 | + |
| 15 | + int op = in_msg_body~load_uint(32); |
| 16 | + cell data = in_msg_body~load_ref(); |
| 17 | + slice data_slice = data.begin_parse(); |
| 18 | + if (op == OP_UPDATE_GUARDIAN_SET) { |
| 19 | + update_guardian_set(data_slice); |
| 20 | + } elseif (op == OP_UPDATE_PRICE_FEEDS) { |
| 21 | + update_price_feeds(msg_value, data_slice); |
| 22 | + } elseif (op == OP_EXECUTE_GOVERNANCE_ACTION) { |
| 23 | + execute_governance_action(data_slice); |
| 24 | + } elseif (op == OP_UPGRADE_CONTRACT) { |
| 25 | + execute_upgrade_contract(data); |
| 26 | + } else { |
| 27 | + throw(0xffff); ;; Throw exception for unknown op |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +(int, int, int, int) test_get_price_unsafe(int price_feed_id) method_id { |
| 32 | + return get_price_unsafe(price_feed_id); |
| 33 | +} |
| 34 | + |
| 35 | +(int, int, int, int) test_get_price_no_older_than(int time_period, int price_feed_id) method_id { |
| 36 | + return get_price_no_older_than(time_period, price_feed_id); |
| 37 | +} |
| 38 | + |
| 39 | +(int, int, int, int) test_get_ema_price_unsafe(int price_feed_id) method_id { |
| 40 | + return get_ema_price_unsafe(price_feed_id); |
| 41 | +} |
| 42 | + |
| 43 | +(int, int, int, int) test_get_ema_price_no_older_than(int time_period, int price_feed_id) method_id { |
| 44 | + return get_ema_price_no_older_than(time_period, price_feed_id); |
| 45 | +} |
| 46 | + |
| 47 | +(int) test_get_update_fee(slice in_msg_body) method_id { |
| 48 | + return get_update_fee(in_msg_body); |
| 49 | +} |
| 50 | + |
| 51 | +(int) test_get_single_update_fee() method_id { |
| 52 | + return get_single_update_fee(); |
| 53 | +} |
| 54 | + |
| 55 | +(int) test_get_chain_id() method_id { |
| 56 | + return get_chain_id(); |
| 57 | +} |
| 58 | + |
| 59 | +(int) test_get_last_executed_governance_sequence() method_id { |
| 60 | + return get_last_executed_governance_sequence(); |
| 61 | +} |
| 62 | + |
| 63 | +(int) test_get_governance_data_source_index() method_id { |
| 64 | + return get_governance_data_source_index(); |
| 65 | +} |
| 66 | + |
| 67 | +(cell) test_get_governance_data_source() method_id { |
| 68 | + return get_governance_data_source(); |
| 69 | +} |
| 70 | + |
| 71 | +(int) test_get_is_valid_data_source(cell data_source) method_id { |
| 72 | + return get_is_valid_data_source(data_source); |
| 73 | +} |
| 74 | + |
| 75 | +;; Add a new function to demonstrate the upgrade |
| 76 | +(int) test_new_function() method_id { |
| 77 | + return 1; |
| 78 | +} |
0 commit comments