#include "imports/stdlib.fc"; #include "common/errors.fc"; #include "common/storage.fc"; #include "common/op.fc"; #include "Wormhole.fc"; #include "Pyth.fc"; ;; Internal message handler () recv_internal(int my_balance, int msg_value, cell in_msg_full, slice in_msg_body) impure { if (in_msg_body.slice_empty?()) { ;; ignore empty messages return (); } ;; * A 32-bit (big-endian) unsigned integer `op`, identifying the `operation` to be performed, or the `method` of the smart contract to be invoked. int op = in_msg_body~load_uint(32); cell data = in_msg_body~load_ref(); slice data_slice = data.begin_parse(); ;; Get sender address from message slice cs = in_msg_full.begin_parse(); int flags = cs~load_uint(4); if (flags & 1) { ;; ignore all bounced messages return (); } slice sender_address = cs~load_msg_addr(); ;; load sender address ;; * The remainder of the message body is specific for each supported value of `op`. if (op == OP_UPDATE_GUARDIAN_SET) { update_guardian_set(data_slice); } elseif (op == OP_UPDATE_PRICE_FEEDS) { update_price_feeds(msg_value, data_slice); } elseif (op == OP_EXECUTE_GOVERNANCE_ACTION) { execute_governance_action(data_slice); } elseif (op == OP_UPGRADE_CONTRACT) { execute_upgrade_contract(data); } elseif (op == OP_PARSE_PRICE_FEED_UPDATES) { cell price_ids_cell = in_msg_body~load_ref(); slice price_ids_slice = price_ids_cell.begin_parse(); int min_publish_time = in_msg_body~load_uint(64); int max_publish_time = in_msg_body~load_uint(64); slice target_address = in_msg_body~load_msg_addr(); cell custom_payload_cell = in_msg_body~load_ref(); slice custom_payload = custom_payload_cell.begin_parse(); parse_price_feed_updates(msg_value, data_slice, price_ids_slice, min_publish_time, max_publish_time, sender_address, target_address, custom_payload); } elseif (op == OP_PARSE_UNIQUE_PRICE_FEED_UPDATES) { cell price_ids_cell = in_msg_body~load_ref(); slice price_ids_slice = price_ids_cell.begin_parse(); int publish_time = in_msg_body~load_uint(64); int max_staleness = in_msg_body~load_uint(64); slice target_address = in_msg_body~load_msg_addr(); cell custom_payload_cell = in_msg_body~load_ref(); slice custom_payload = custom_payload_cell.begin_parse(); parse_unique_price_feed_updates(msg_value, data_slice, price_ids_slice, publish_time, max_staleness, sender_address, target_address, custom_payload); } else { throw(0xffff); ;; Throw exception for unknown op } }