Ver código fonte

Make chain id configurable

Tom Pointon 3 anos atrás
pai
commit
4e43c910c6

+ 1 - 1
aptos/contracts/sources/governance/governance_instruction.move

@@ -17,7 +17,7 @@ module pyth::governance_instruction {
     fun validate(instruction: &GovernanceInstruction) {
         assert!(instruction.module_ == MODULE, error::invalid_governance_module());
         let target_chain_id = instruction.target_chain_id;
-        assert!(target_chain_id == TARGET_CHAIN_ID || target_chain_id == 0, error::invalid_governance_target_chain_id());
+        assert!(target_chain_id == state::get_chain_id() || target_chain_id == 0, error::invalid_governance_target_chain_id());
     }
  
     public fun from_byte_vec(bytes: vector<u8>): GovernanceInstruction {

+ 4 - 0
aptos/contracts/sources/state.move

@@ -137,6 +137,10 @@ module pyth::state {
         hash
     }
 
+    public fun get_chain_id(): u64 acquires ChainID {
+        borrow_global<ChainID>(@pyth).chain_id
+    }
+
     // Setters
     public(friend) fun set_data_sources(new_sources: vector<DataSource>) acquires DataSources {
         let sources = &mut borrow_global_mut<DataSources>(@pyth).sources;