version_control.move 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // SPDX-License-Identifier: Apache 2
  2. /// Note: This module is based on the version_control module in
  3. /// the Sui Wormhole package:
  4. /// https://github.com/wormhole-foundation/wormhole/blob/sui/integration_v2/sui/wormhole/sources/version_control.move
  5. /// This module implements dynamic field keys as empty structs. These keys with
  6. /// `RequiredVersion` are used to determine minimum build requirements for
  7. /// particular Pyth methods and breaking backward compatibility for these
  8. /// methods if an upgrade requires the latest upgrade version for its
  9. /// functionality.
  10. ///
  11. /// See `pyth::required_version` and `pyth::state` for more info.
  12. module pyth::version_control {
  13. /// This value tracks the current Pyth contract version. We are
  14. /// placing this constant value at the top, which goes against Move style
  15. /// guides so that we bring special attention to changing this value when
  16. /// a new implementation is built for a contract upgrade.
  17. const CURRENT_BUILD_VERSION: u64 = 1;
  18. /// Key used to check minimum version requirement for `set_data_sources`
  19. struct SetDataSources {}
  20. /// Key used to check minimum version requirement for `set_governance_data_source`
  21. struct SetGovernanceDataSource {}
  22. /// Key used to check minimum version requirement for `set_stale_price_threshold`
  23. struct SetStalePriceThreshold {}
  24. /// Key used to check minimum version requirement for `set_update_fee`
  25. struct SetUpdateFee {}
  26. /// Key used to check minimum version requirement for `transfer_fee`
  27. struct TransferFee {}
  28. /// Key used to check minimum version requirement for `update_price_feeds`
  29. struct UpdatePriceFeeds {}
  30. /// Key used to check minimum version requirement for `create_price_feeds`
  31. struct CreatePriceFeeds {}
  32. //=======================================================================
  33. /// Return const value `CURRENT_BUILD_VERSION` for this particular build.
  34. /// This value is used to determine whether this implementation meets
  35. /// minimum requirements for various Pyth methods required by `State`.
  36. public fun version(): u64 {
  37. CURRENT_BUILD_VERSION
  38. }
  39. }