Kaynağa Gözat

Fix store saving/loading procedure (#1244)

yaml file names were based on contract types but they were using the old format
entropy contracts were not serialized
Amin Moghaddam 1 yıl önce
ebeveyn
işleme
17ea0c19e0

+ 6 - 4
contract_manager/src/store.ts

@@ -13,7 +13,7 @@ import {
   EvmPriceFeedContract,
   SuiPriceFeedContract,
 } from "./contracts";
-import { PriceFeedContract } from "./base";
+import { PriceFeedContract, Storable } from "./base";
 import { parse, stringify } from "yaml";
 import { readdirSync, readFileSync, statSync, writeFileSync } from "fs";
 import { Vault } from "./governance";
@@ -30,7 +30,7 @@ export class Store {
     this.loadAllVaults();
   }
 
-  static serialize(obj: PriceFeedContract | Chain | Vault) {
+  static serialize(obj: Storable) {
     return stringify([obj.toJson()]);
   }
 
@@ -75,8 +75,10 @@ export class Store {
   }
 
   saveAllContracts() {
-    const contractsByType: Record<string, PriceFeedContract[]> = {};
-    for (const contract of Object.values(this.contracts)) {
+    const contractsByType: Record<string, Storable[]> = {};
+    const contracts: Storable[] = Object.values(this.contracts);
+    contracts.push(...Object.values(this.entropy_contracts));
+    for (const contract of contracts) {
       if (!contractsByType[contract.getType()]) {
         contractsByType[contract.getType()] = [];
       }

+ 0 - 0
contract_manager/store/contracts/AptosContracts.yaml → contract_manager/store/contracts/AptosPriceFeedContracts.yaml


+ 0 - 0
contract_manager/store/contracts/CosmWasmContracts.yaml → contract_manager/store/contracts/CosmWasmPriceFeedContracts.yaml


+ 3 - 0
contract_manager/store/contracts/EvmEntropyContracts.yaml

@@ -0,0 +1,3 @@
+- chain: base_goerli
+  address: "0x4374e5a8b9C22271E9EB878A2AA31DE97DF15DAF"
+  type: EvmPriceFeedContract

+ 0 - 3
contract_manager/store/contracts/EvmContracts.yaml → contract_manager/store/contracts/EvmPriceFeedContracts.yaml

@@ -250,6 +250,3 @@
 - chain: filecoin
   address: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729"
   type: EvmPriceFeedContract
-- chain: base_goerli
-  address: "0x4374e5a8b9C22271E9EB878A2AA31DE97DF15DAF"
-  type: EvmEntropyContract

+ 0 - 0
contract_manager/store/contracts/SuiContracts.yaml → contract_manager/store/contracts/SuiPriceFeedContracts.yaml