version_control.move 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // SPDX-License-Identifier: Apache 2
  2. /// This module implements dynamic field keys as empty structs. These keys are
  3. /// used to determine the latest version for this build. If the current version
  4. /// is not this build's, then paths through the `state` module will abort.
  5. ///
  6. /// See `token_bridge::state` and `wormhole::package_utils` for more info.
  7. module token_bridge::version_control {
  8. ////////////////////////////////////////////////////////////////////////////
  9. //
  10. // Hard-coded Version Control
  11. //
  12. // Before upgrading, please set the types for `current_version` and
  13. // `previous_version` to match the correct types (current being the latest
  14. // version reflecting this build).
  15. //
  16. ////////////////////////////////////////////////////////////////////////////
  17. public(friend) fun current_version(): V__0_2_0 {
  18. V__0_2_0 {}
  19. }
  20. #[test_only]
  21. public fun current_version_test_only(): V__0_2_0 {
  22. current_version()
  23. }
  24. public(friend) fun previous_version(): V__DUMMY {
  25. V__DUMMY {}
  26. }
  27. #[test_only]
  28. public fun previous_version_test_only(): V__DUMMY {
  29. previous_version()
  30. }
  31. ////////////////////////////////////////////////////////////////////////////
  32. //
  33. // Change Log
  34. //
  35. // Please write release notes as doc strings for each version struct. These
  36. // notes will be our attempt at tracking upgrades. Wish us luck.
  37. //
  38. ////////////////////////////////////////////////////////////////////////////
  39. /// First published package on Sui mainnet.
  40. struct V__0_2_0 has store, drop, copy {}
  41. // Dummy.
  42. struct V__DUMMY has store, drop, copy {}
  43. ////////////////////////////////////////////////////////////////////////////
  44. //
  45. // Implementation and Test-Only Methods
  46. //
  47. ////////////////////////////////////////////////////////////////////////////
  48. friend token_bridge::state;
  49. #[test_only]
  50. public fun dummy(): V__DUMMY {
  51. V__DUMMY {}
  52. }
  53. #[test_only]
  54. struct V__MIGRATED has store, drop, copy {}
  55. #[test_only]
  56. public fun next_version(): V__MIGRATED {
  57. V__MIGRATED {}
  58. }
  59. }