base.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { DataSource } from "xc_admin_common";
  2. import { Chain } from "./chains";
  3. export abstract class Storable {
  4. /**
  5. * Returns the unique identifier for this object
  6. */
  7. abstract getId(): string;
  8. /**
  9. * Returns the type of this object. This is used to reconstruct the object and should match
  10. * the static field type in the class responsible for constructing this object.
  11. */
  12. abstract getType(): string;
  13. /**
  14. * Returns a JSON representation of this object. It should be possible to
  15. * reconstruct the object from the JSON using the fromJson method.
  16. */
  17. abstract toJson(): any;
  18. }
  19. export abstract class Contract extends Storable {
  20. /**
  21. * Returns the time period in seconds that stale data is considered valid for.
  22. */
  23. abstract getValidTimePeriod(): Promise<number>;
  24. /**
  25. * Returns the chain that this contract is deployed on
  26. */
  27. abstract getChain(): Chain;
  28. /**
  29. * Returns an array of data sources that this contract accepts price feed messages from
  30. */
  31. abstract getDataSources(): Promise<DataSource[]>;
  32. /**
  33. * Returns the base update fee for this contract
  34. * This is the required fee for updating the price feeds in the contract
  35. */
  36. abstract getBaseUpdateFee(): Promise<{ amount: string; denom?: string }>;
  37. /**
  38. * Executes the governance instruction contained in the VAA using the sender credentials
  39. * @param sender based on the contract type, this can be a private key, a mnemonic, a wallet, etc.
  40. * @param vaa the VAA to execute
  41. */
  42. abstract executeGovernanceInstruction(sender: any, vaa: Buffer): Promise<any>;
  43. /**
  44. * Returns the single data source that this contract accepts governance messages from
  45. */
  46. abstract getGovernanceDataSource(): Promise<DataSource>;
  47. }