@aptos-labs/ts-sdk 3.1.0 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (518) hide show
  1. package/dist/common/chunk-6MMUUJHX.js.map +1 -1
  2. package/dist/common/cli/index.js.map +1 -1
  3. package/dist/common/index.js +13 -13
  4. package/dist/common/index.js.map +1 -1
  5. package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
  6. package/dist/esm/account/AbstractedAccount.mjs +1 -1
  7. package/dist/esm/account/Account.mjs +1 -1
  8. package/dist/esm/account/AccountUtils.mjs +1 -1
  9. package/dist/esm/account/DerivableAbstractedAccount.mjs +1 -1
  10. package/dist/esm/account/Ed25519Account.mjs +1 -1
  11. package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
  12. package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
  13. package/dist/esm/account/KeylessAccount.mjs +1 -1
  14. package/dist/esm/account/MultiEd25519Account.mjs +1 -1
  15. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  16. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  17. package/dist/esm/account/index.mjs +1 -1
  18. package/dist/esm/account/utils.mjs +1 -1
  19. package/dist/esm/api/account/abstraction.mjs +1 -1
  20. package/dist/esm/api/account.mjs +1 -1
  21. package/dist/esm/api/ans.mjs +1 -1
  22. package/dist/esm/api/aptos.mjs +1 -1
  23. package/dist/esm/api/coin.mjs +1 -1
  24. package/dist/esm/api/digitalAsset.mjs +1 -1
  25. package/dist/esm/api/event.mjs +1 -1
  26. package/dist/esm/api/faucet.mjs +1 -1
  27. package/dist/esm/api/fungibleAsset.mjs +1 -1
  28. package/dist/esm/api/general.mjs +1 -1
  29. package/dist/esm/api/index.mjs +1 -1
  30. package/dist/esm/api/keyless.mjs +1 -1
  31. package/dist/esm/api/object.mjs +1 -1
  32. package/dist/esm/api/staking.mjs +1 -1
  33. package/dist/esm/api/table.mjs +1 -1
  34. package/dist/esm/api/transaction.mjs +1 -1
  35. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  36. package/dist/esm/api/transactionSubmission/helpers.d.mts +22 -9
  37. package/dist/esm/api/transactionSubmission/helpers.mjs +1 -1
  38. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  39. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  40. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  41. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  42. package/dist/esm/api/utils.mjs +1 -1
  43. package/dist/esm/bcs/deserializer.mjs +1 -1
  44. package/dist/esm/bcs/index.mjs +1 -1
  45. package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
  46. package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
  47. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  48. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  49. package/dist/esm/bcs/serializer.mjs +1 -1
  50. package/dist/esm/chunk-4R4AI5RT.mjs +2 -0
  51. package/dist/esm/{chunk-HUWKPKPQ.mjs.map → chunk-4R4AI5RT.mjs.map} +1 -1
  52. package/dist/esm/{chunk-2BOHKN33.mjs → chunk-6MWXV62C.mjs} +2 -2
  53. package/dist/esm/{chunk-FGFLPH5K.mjs → chunk-6PKBXYG3.mjs} +2 -2
  54. package/dist/esm/{chunk-6WDVDEQZ.mjs → chunk-6Y6ZO7TS.mjs} +2 -2
  55. package/dist/esm/{chunk-SLWIGOQL.mjs → chunk-AQQEQB35.mjs} +2 -2
  56. package/dist/esm/{chunk-HNBVYE3N.mjs → chunk-BUUV6B4P.mjs} +2 -2
  57. package/dist/esm/{chunk-WSR5EBJM.mjs → chunk-BYINW7I2.mjs} +2 -2
  58. package/dist/esm/{chunk-ORMOQWWH.mjs → chunk-C6JRJNK3.mjs} +2 -2
  59. package/dist/esm/{chunk-Z5URUE4U.mjs → chunk-DW6WLD2B.mjs} +2 -2
  60. package/dist/esm/{chunk-U3GMNXO4.mjs → chunk-E6IUB35J.mjs} +2 -2
  61. package/dist/esm/{chunk-CO67Y6YE.mjs → chunk-EPMBZCYJ.mjs} +2 -2
  62. package/dist/esm/{chunk-RQX6JOEN.mjs → chunk-FBCXUC7J.mjs} +2 -2
  63. package/dist/esm/{chunk-CFQFFP6N.mjs → chunk-FWGLACJS.mjs} +2 -2
  64. package/dist/esm/{chunk-TYYVB2A6.mjs → chunk-GRB6YSIT.mjs} +2 -2
  65. package/dist/esm/{chunk-RGKRCZ36.mjs → chunk-GYVSI3TS.mjs} +2 -2
  66. package/dist/esm/chunk-HPQMAP7O.mjs +2 -0
  67. package/dist/esm/{chunk-ACNHLCQQ.mjs → chunk-I4NMWLUZ.mjs} +5 -5
  68. package/dist/esm/chunk-I4NMWLUZ.mjs.map +1 -0
  69. package/dist/esm/{chunk-TOBQ5UE6.mjs → chunk-IXYGZ57N.mjs} +2 -2
  70. package/dist/esm/{chunk-MML57K5H.mjs → chunk-NII5Q32W.mjs} +2 -2
  71. package/dist/esm/{chunk-EBMEXURY.mjs → chunk-NJN3EAOM.mjs} +2 -2
  72. package/dist/esm/{chunk-XKUIMGKU.mjs → chunk-OYH2T6V5.mjs} +2 -2
  73. package/dist/esm/chunk-OYUW6ZN2.mjs +2 -0
  74. package/dist/esm/{chunk-5URUYE6H.mjs → chunk-PQS3II2E.mjs} +2 -2
  75. package/dist/esm/{chunk-N6YTF76Q.mjs → chunk-PRUQZNAP.mjs} +2 -2
  76. package/dist/esm/{chunk-UQWF24SS.mjs → chunk-QGFWOGAV.mjs} +2 -2
  77. package/dist/esm/{chunk-4COLMDT3.mjs → chunk-QQEK2GJC.mjs} +2 -2
  78. package/dist/esm/chunk-QREVMGQZ.mjs +2 -0
  79. package/dist/esm/chunk-QREVMGQZ.mjs.map +1 -0
  80. package/dist/esm/{chunk-MNDTFHDB.mjs → chunk-RFQFTIOA.mjs} +2 -2
  81. package/dist/esm/{chunk-XZ75T7Q7.mjs → chunk-THUSLDD6.mjs} +2 -2
  82. package/dist/esm/{chunk-FLZPUYXQ.mjs → chunk-UCBUUH5M.mjs} +2 -2
  83. package/dist/esm/{chunk-MT2RJ7H3.mjs → chunk-WLUXOUZH.mjs} +2 -2
  84. package/dist/esm/{chunk-FYYEPFML.mjs → chunk-XIQFX5FV.mjs} +2 -2
  85. package/dist/esm/{chunk-7DQDJ2SA.mjs → chunk-YFFDF22R.mjs} +2 -2
  86. package/dist/esm/{chunk-WCMW2L3P.mjs → chunk-Z6KQX6VX.mjs} +2 -2
  87. package/dist/esm/{chunk-B563XRSZ.mjs → chunk-ZMT2M6YT.mjs} +2 -2
  88. package/dist/esm/cli/index.mjs +1 -1
  89. package/dist/esm/cli/localNode.mjs +1 -1
  90. package/dist/esm/client/core.mjs +1 -1
  91. package/dist/esm/client/get.mjs +1 -1
  92. package/dist/esm/client/index.mjs +1 -1
  93. package/dist/esm/client/post.mjs +1 -1
  94. package/dist/esm/core/account/index.mjs +1 -1
  95. package/dist/esm/core/account/utils/address.mjs +1 -1
  96. package/dist/esm/core/account/utils/index.mjs +1 -1
  97. package/dist/esm/core/accountAddress.mjs +1 -1
  98. package/dist/esm/core/authenticationKey.mjs +1 -1
  99. package/dist/esm/core/crypto/abstraction.mjs +1 -1
  100. package/dist/esm/core/crypto/deserializationUtils.mjs +1 -1
  101. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  102. package/dist/esm/core/crypto/ephemeral.mjs +1 -1
  103. package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
  104. package/dist/esm/core/crypto/index.mjs +1 -1
  105. package/dist/esm/core/crypto/keyless.mjs +1 -1
  106. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  107. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  108. package/dist/esm/core/crypto/proof.mjs +1 -1
  109. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  110. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  111. package/dist/esm/core/crypto/signature.mjs +1 -1
  112. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  113. package/dist/esm/core/index.mjs +1 -1
  114. package/dist/esm/errors/index.mjs +1 -1
  115. package/dist/esm/index.mjs +1 -1
  116. package/dist/esm/internal/abstraction.mjs +1 -1
  117. package/dist/esm/internal/account.mjs +1 -1
  118. package/dist/esm/internal/ans.mjs +1 -1
  119. package/dist/esm/internal/coin.mjs +1 -1
  120. package/dist/esm/internal/digitalAsset.mjs +1 -1
  121. package/dist/esm/internal/event.mjs +1 -1
  122. package/dist/esm/internal/faucet.mjs +1 -1
  123. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  124. package/dist/esm/internal/general.mjs +1 -1
  125. package/dist/esm/internal/keyless.mjs +1 -1
  126. package/dist/esm/internal/object.mjs +1 -1
  127. package/dist/esm/internal/staking.mjs +1 -1
  128. package/dist/esm/internal/table.mjs +1 -1
  129. package/dist/esm/internal/transaction.mjs +1 -1
  130. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  131. package/dist/esm/internal/utils/index.mjs +1 -1
  132. package/dist/esm/internal/utils/utils.mjs +1 -1
  133. package/dist/esm/internal/view.mjs +1 -1
  134. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  135. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  136. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  137. package/dist/esm/transactions/index.mjs +1 -1
  138. package/dist/esm/transactions/instances/chainId.mjs +1 -1
  139. package/dist/esm/transactions/instances/identifier.mjs +1 -1
  140. package/dist/esm/transactions/instances/index.mjs +1 -1
  141. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  142. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  143. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  144. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  145. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  146. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  147. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  148. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  149. package/dist/esm/transactions/management/index.mjs +1 -1
  150. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  151. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  152. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  153. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  154. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  155. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  156. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  157. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  158. package/dist/esm/utils/helpers.mjs +1 -1
  159. package/dist/esm/utils/index.mjs +1 -1
  160. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  161. package/dist/esm/version.d.mts +1 -1
  162. package/dist/esm/version.mjs +1 -1
  163. package/package.json +1 -1
  164. package/src/api/transactionSubmission/helpers.ts +26 -20
  165. package/src/api/transactionSubmission/submit.ts +3 -3
  166. package/src/transactions/transactionBuilder/remoteAbi.ts +10 -1
  167. package/src/version.ts +1 -1
  168. package/dist/esm/chunk-ACNHLCQQ.mjs.map +0 -1
  169. package/dist/esm/chunk-CW35YAMN.mjs +0 -2
  170. package/dist/esm/chunk-HUWKPKPQ.mjs +0 -2
  171. package/dist/esm/chunk-W4BSN6SK.mjs +0 -2
  172. package/dist/esm/chunk-W4BSN6SK.mjs.map +0 -1
  173. package/dist/esm/chunk-XJJVJOX5.mjs +0 -2
  174. package/src/internal/move/jwks/build/jwk/BuildInfo.yaml +0 -56
  175. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/account.mv +0 -0
  176. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/aggregator.mv +0 -0
  177. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/aggregator_factory.mv +0 -0
  178. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/aggregator_v2.mv +0 -0
  179. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/aptos_account.mv +0 -0
  180. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/aptos_coin.mv +0 -0
  181. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/aptos_governance.mv +0 -0
  182. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/block.mv +0 -0
  183. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/chain_id.mv +0 -0
  184. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/chain_status.mv +0 -0
  185. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/code.mv +0 -0
  186. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/coin.mv +0 -0
  187. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/config_buffer.mv +0 -0
  188. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/consensus_config.mv +0 -0
  189. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/create_signer.mv +0 -0
  190. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/delegation_pool.mv +0 -0
  191. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/dispatchable_fungible_asset.mv +0 -0
  192. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/dkg.mv +0 -0
  193. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/event.mv +0 -0
  194. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/execution_config.mv +0 -0
  195. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/function_info.mv +0 -0
  196. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/fungible_asset.mv +0 -0
  197. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/gas_schedule.mv +0 -0
  198. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/genesis.mv +0 -0
  199. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/governance_proposal.mv +0 -0
  200. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/guid.mv +0 -0
  201. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/jwk_consensus_config.mv +0 -0
  202. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/jwks.mv +0 -0
  203. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/keyless_account.mv +0 -0
  204. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/managed_coin.mv +0 -0
  205. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/multisig_account.mv +0 -0
  206. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/object.mv +0 -0
  207. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/object_code_deployment.mv +0 -0
  208. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/optional_aggregator.mv +0 -0
  209. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/primary_fungible_store.mv +0 -0
  210. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/randomness.mv +0 -0
  211. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/randomness_api_v0_config.mv +0 -0
  212. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/randomness_config.mv +0 -0
  213. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/randomness_config_seqnum.mv +0 -0
  214. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/reconfiguration.mv +0 -0
  215. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/reconfiguration_state.mv +0 -0
  216. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/reconfiguration_with_dkg.mv +0 -0
  217. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/resource_account.mv +0 -0
  218. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/stake.mv +0 -0
  219. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/staking_config.mv +0 -0
  220. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/staking_contract.mv +0 -0
  221. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/staking_proxy.mv +0 -0
  222. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/state_storage.mv +0 -0
  223. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/storage_gas.mv +0 -0
  224. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/system_addresses.mv +0 -0
  225. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/timestamp.mv +0 -0
  226. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/transaction_context.mv +0 -0
  227. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/transaction_fee.mv +0 -0
  228. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/transaction_validation.mv +0 -0
  229. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/util.mv +0 -0
  230. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/validator_consensus_info.mv +0 -0
  231. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/version.mv +0 -0
  232. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/vesting.mv +0 -0
  233. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/voting.mv +0 -0
  234. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/any.mv +0 -0
  235. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/aptos_hash.mv +0 -0
  236. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/big_vector.mv +0 -0
  237. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/bls12381.mv +0 -0
  238. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/bls12381_algebra.mv +0 -0
  239. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/bn254_algebra.mv +0 -0
  240. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/capability.mv +0 -0
  241. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/comparator.mv +0 -0
  242. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/copyable_any.mv +0 -0
  243. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/crypto_algebra.mv +0 -0
  244. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/debug.mv +0 -0
  245. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/ed25519.mv +0 -0
  246. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/fixed_point64.mv +0 -0
  247. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/from_bcs.mv +0 -0
  248. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/math128.mv +0 -0
  249. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/math64.mv +0 -0
  250. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/math_fixed.mv +0 -0
  251. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/math_fixed64.mv +0 -0
  252. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/multi_ed25519.mv +0 -0
  253. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/pool_u64.mv +0 -0
  254. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/pool_u64_unbound.mv +0 -0
  255. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/ristretto255.mv +0 -0
  256. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/ristretto255_bulletproofs.mv +0 -0
  257. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/ristretto255_elgamal.mv +0 -0
  258. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/ristretto255_pedersen.mv +0 -0
  259. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/secp256k1.mv +0 -0
  260. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/simple_map.mv +0 -0
  261. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/smart_table.mv +0 -0
  262. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/smart_vector.mv +0 -0
  263. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/string_utils.mv +0 -0
  264. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/table.mv +0 -0
  265. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/table_with_length.mv +0 -0
  266. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/type_info.mv +0 -0
  267. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/MoveStdlib/acl.mv +0 -0
  268. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/MoveStdlib/bcs.mv +0 -0
  269. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/MoveStdlib/bit_vector.mv +0 -0
  270. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/MoveStdlib/error.mv +0 -0
  271. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/MoveStdlib/features.mv +0 -0
  272. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/MoveStdlib/fixed_point32.mv +0 -0
  273. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/MoveStdlib/hash.mv +0 -0
  274. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/MoveStdlib/option.mv +0 -0
  275. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/MoveStdlib/signer.mv +0 -0
  276. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/MoveStdlib/string.mv +0 -0
  277. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/MoveStdlib/vector.mv +0 -0
  278. package/src/internal/move/jwks/build/jwk/bytecode_scripts/main.mv +0 -0
  279. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/account.mvsm +0 -0
  280. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/aggregator.mvsm +0 -0
  281. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/aggregator_factory.mvsm +0 -0
  282. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/aggregator_v2.mvsm +0 -0
  283. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/aptos_account.mvsm +0 -0
  284. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/aptos_coin.mvsm +0 -0
  285. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/aptos_governance.mvsm +0 -0
  286. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/block.mvsm +0 -0
  287. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/chain_id.mvsm +0 -0
  288. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/chain_status.mvsm +0 -0
  289. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/code.mvsm +0 -0
  290. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/coin.mvsm +0 -0
  291. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/config_buffer.mvsm +0 -0
  292. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/consensus_config.mvsm +0 -0
  293. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/create_signer.mvsm +0 -0
  294. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/delegation_pool.mvsm +0 -0
  295. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/dispatchable_fungible_asset.mvsm +0 -0
  296. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/dkg.mvsm +0 -0
  297. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/event.mvsm +0 -0
  298. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/execution_config.mvsm +0 -0
  299. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/function_info.mvsm +0 -0
  300. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/fungible_asset.mvsm +0 -0
  301. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/gas_schedule.mvsm +0 -0
  302. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/genesis.mvsm +0 -0
  303. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/governance_proposal.mvsm +0 -0
  304. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/guid.mvsm +0 -0
  305. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/jwk_consensus_config.mvsm +0 -0
  306. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/jwks.mvsm +0 -0
  307. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/keyless_account.mvsm +0 -0
  308. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/managed_coin.mvsm +0 -0
  309. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/multisig_account.mvsm +0 -0
  310. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/object.mvsm +0 -0
  311. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/object_code_deployment.mvsm +0 -0
  312. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/optional_aggregator.mvsm +0 -0
  313. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/primary_fungible_store.mvsm +0 -0
  314. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/randomness.mvsm +0 -0
  315. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/randomness_api_v0_config.mvsm +0 -0
  316. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/randomness_config.mvsm +0 -0
  317. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/randomness_config_seqnum.mvsm +0 -0
  318. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/reconfiguration.mvsm +0 -0
  319. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/reconfiguration_state.mvsm +0 -0
  320. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/reconfiguration_with_dkg.mvsm +0 -0
  321. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/resource_account.mvsm +0 -0
  322. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/stake.mvsm +0 -0
  323. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/staking_config.mvsm +0 -0
  324. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/staking_contract.mvsm +0 -0
  325. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/staking_proxy.mvsm +0 -0
  326. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/state_storage.mvsm +0 -0
  327. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/storage_gas.mvsm +0 -0
  328. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/system_addresses.mvsm +0 -0
  329. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/timestamp.mvsm +0 -0
  330. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/transaction_context.mvsm +0 -0
  331. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/transaction_fee.mvsm +0 -0
  332. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/transaction_validation.mvsm +0 -0
  333. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/util.mvsm +0 -0
  334. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/validator_consensus_info.mvsm +0 -0
  335. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/version.mvsm +0 -0
  336. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/vesting.mvsm +0 -0
  337. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/voting.mvsm +0 -0
  338. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/any.mvsm +0 -0
  339. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/aptos_hash.mvsm +0 -0
  340. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/big_vector.mvsm +0 -0
  341. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/bls12381.mvsm +0 -0
  342. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/bls12381_algebra.mvsm +0 -0
  343. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/bn254_algebra.mvsm +0 -0
  344. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/capability.mvsm +0 -0
  345. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/comparator.mvsm +0 -0
  346. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/copyable_any.mvsm +0 -0
  347. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/crypto_algebra.mvsm +0 -0
  348. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/debug.mvsm +0 -0
  349. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/ed25519.mvsm +0 -0
  350. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/fixed_point64.mvsm +0 -0
  351. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/from_bcs.mvsm +0 -0
  352. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/math128.mvsm +0 -0
  353. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/math64.mvsm +0 -0
  354. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/math_fixed.mvsm +0 -0
  355. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/math_fixed64.mvsm +0 -0
  356. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/multi_ed25519.mvsm +0 -0
  357. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/pool_u64.mvsm +0 -0
  358. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/pool_u64_unbound.mvsm +0 -0
  359. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/ristretto255.mvsm +0 -0
  360. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/ristretto255_bulletproofs.mvsm +0 -0
  361. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/ristretto255_elgamal.mvsm +0 -0
  362. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/ristretto255_pedersen.mvsm +0 -0
  363. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/secp256k1.mvsm +0 -0
  364. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/simple_map.mvsm +0 -0
  365. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/smart_table.mvsm +0 -0
  366. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/smart_vector.mvsm +0 -0
  367. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/string_utils.mvsm +0 -0
  368. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/table.mvsm +0 -0
  369. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/table_with_length.mvsm +0 -0
  370. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/type_info.mvsm +0 -0
  371. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/MoveStdlib/acl.mvsm +0 -0
  372. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/MoveStdlib/bcs.mvsm +0 -0
  373. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/MoveStdlib/bit_vector.mvsm +0 -0
  374. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/MoveStdlib/error.mvsm +0 -0
  375. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/MoveStdlib/features.mvsm +0 -0
  376. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/MoveStdlib/fixed_point32.mvsm +0 -0
  377. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/MoveStdlib/hash.mvsm +0 -0
  378. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/MoveStdlib/option.mvsm +0 -0
  379. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/MoveStdlib/signer.mvsm +0 -0
  380. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/MoveStdlib/string.mvsm +0 -0
  381. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/MoveStdlib/vector.mvsm +0 -0
  382. package/src/internal/move/jwks/build/jwk/source_maps/main.mvsm +0 -0
  383. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/account.move +0 -1533
  384. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/aggregator.move +0 -48
  385. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/aggregator_factory.move +0 -66
  386. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/aggregator_v2.move +0 -280
  387. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/aptos_account.move +0 -443
  388. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/aptos_coin.move +0 -204
  389. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/aptos_governance.move +0 -1387
  390. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/block.move +0 -394
  391. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/chain_id.move +0 -41
  392. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/chain_status.move +0 -48
  393. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/code.move +0 -367
  394. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/coin.move +0 -2214
  395. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/config_buffer.move +0 -101
  396. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/consensus_config.move +0 -77
  397. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/create_signer.move +0 -21
  398. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/delegation_pool.move +0 -5568
  399. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/dispatchable_fungible_asset.move +0 -228
  400. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/dkg.move +0 -121
  401. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/event.move +0 -92
  402. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/execution_config.move +0 -66
  403. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/function_info.move +0 -100
  404. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/fungible_asset.move +0 -1566
  405. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/gas_schedule.move +0 -176
  406. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/genesis.move +0 -550
  407. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/governance_proposal.move +0 -23
  408. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/guid.move +0 -68
  409. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/jwk_consensus_config.move +0 -148
  410. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/jwks.move +0 -817
  411. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/keyless_account.move +0 -312
  412. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/managed_coin.move +0 -205
  413. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/multisig_account.move +0 -2477
  414. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/object.move +0 -1073
  415. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/object_code_deployment.move +0 -147
  416. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/optional_aggregator.move +0 -295
  417. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/primary_fungible_store.move +0 -405
  418. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/randomness.move +0 -574
  419. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/randomness_api_v0_config.move +0 -57
  420. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/randomness_config.move +0 -153
  421. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/randomness_config_seqnum.move +0 -49
  422. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/reconfiguration.move +0 -237
  423. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/reconfiguration_state.move +0 -132
  424. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/reconfiguration_with_dkg.move +0 -69
  425. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/resource_account.move +0 -267
  426. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/stake.move +0 -3286
  427. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/staking_config.move +0 -686
  428. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/staking_contract.move +0 -1618
  429. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/staking_proxy.move +0 -228
  430. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/state_storage.move +0 -90
  431. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/storage_gas.move +0 -622
  432. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/system_addresses.move +0 -82
  433. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/timestamp.move +0 -88
  434. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/transaction_context.move +0 -262
  435. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/transaction_fee.move +0 -457
  436. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/transaction_validation.move +0 -501
  437. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/util.move +0 -16
  438. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/validator_consensus_info.move +0 -42
  439. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/version.move +0 -115
  440. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/vesting.move +0 -2183
  441. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/voting.move +0 -1279
  442. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/any.move +0 -57
  443. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/aptos_hash.move +0 -253
  444. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/big_vector.move +0 -469
  445. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/bls12381.move +0 -985
  446. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/bls12381_algebra.move +0 -802
  447. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/bn254_algebra.move +0 -855
  448. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/capability.move +0 -193
  449. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/comparator.move +0 -173
  450. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/copyable_any.move +0 -45
  451. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/crypto_algebra.move +0 -351
  452. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/debug.move +0 -278
  453. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/ed25519.move +0 -262
  454. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/fixed_point64.move +0 -447
  455. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/from_bcs.move +0 -91
  456. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/math128.move +0 -381
  457. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/math64.move +0 -336
  458. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/math_fixed.move +0 -139
  459. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/math_fixed64.move +0 -142
  460. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/multi_ed25519.move +0 -482
  461. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/pool_u64.move +0 -571
  462. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/pool_u64_unbound.move +0 -270
  463. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/ristretto255.move +0 -1310
  464. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/ristretto255_bulletproofs.move +0 -253
  465. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/ristretto255_elgamal.move +0 -234
  466. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/ristretto255_pedersen.move +0 -158
  467. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/secp256k1.move +0 -114
  468. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/simple_map.move +0 -319
  469. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/smart_table.move +0 -769
  470. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/smart_vector.move +0 -766
  471. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/string_utils.move +0 -148
  472. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/table.move +0 -152
  473. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/table_with_length.move +0 -141
  474. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/type_info.move +0 -351
  475. package/src/internal/move/jwks/build/jwk/sources/dependencies/MoveStdlib/acl.move +0 -46
  476. package/src/internal/move/jwks/build/jwk/sources/dependencies/MoveStdlib/bcs.move +0 -27
  477. package/src/internal/move/jwks/build/jwk/sources/dependencies/MoveStdlib/bit_vector.move +0 -239
  478. package/src/internal/move/jwks/build/jwk/sources/dependencies/MoveStdlib/error.move +0 -88
  479. package/src/internal/move/jwks/build/jwk/sources/dependencies/MoveStdlib/features.move +0 -780
  480. package/src/internal/move/jwks/build/jwk/sources/dependencies/MoveStdlib/fixed_point32.move +0 -295
  481. package/src/internal/move/jwks/build/jwk/sources/dependencies/MoveStdlib/hash.move +0 -8
  482. package/src/internal/move/jwks/build/jwk/sources/dependencies/MoveStdlib/option.move +0 -356
  483. package/src/internal/move/jwks/build/jwk/sources/dependencies/MoveStdlib/signer.move +0 -21
  484. package/src/internal/move/jwks/build/jwk/sources/dependencies/MoveStdlib/string.move +0 -93
  485. package/src/internal/move/jwks/build/jwk/sources/dependencies/MoveStdlib/vector.move +0 -669
  486. package/src/internal/move/jwks/build/jwk/sources/main.move +0 -20
  487. /package/dist/esm/{chunk-2BOHKN33.mjs.map → chunk-6MWXV62C.mjs.map} +0 -0
  488. /package/dist/esm/{chunk-FGFLPH5K.mjs.map → chunk-6PKBXYG3.mjs.map} +0 -0
  489. /package/dist/esm/{chunk-6WDVDEQZ.mjs.map → chunk-6Y6ZO7TS.mjs.map} +0 -0
  490. /package/dist/esm/{chunk-SLWIGOQL.mjs.map → chunk-AQQEQB35.mjs.map} +0 -0
  491. /package/dist/esm/{chunk-HNBVYE3N.mjs.map → chunk-BUUV6B4P.mjs.map} +0 -0
  492. /package/dist/esm/{chunk-WSR5EBJM.mjs.map → chunk-BYINW7I2.mjs.map} +0 -0
  493. /package/dist/esm/{chunk-ORMOQWWH.mjs.map → chunk-C6JRJNK3.mjs.map} +0 -0
  494. /package/dist/esm/{chunk-Z5URUE4U.mjs.map → chunk-DW6WLD2B.mjs.map} +0 -0
  495. /package/dist/esm/{chunk-U3GMNXO4.mjs.map → chunk-E6IUB35J.mjs.map} +0 -0
  496. /package/dist/esm/{chunk-CO67Y6YE.mjs.map → chunk-EPMBZCYJ.mjs.map} +0 -0
  497. /package/dist/esm/{chunk-RQX6JOEN.mjs.map → chunk-FBCXUC7J.mjs.map} +0 -0
  498. /package/dist/esm/{chunk-CFQFFP6N.mjs.map → chunk-FWGLACJS.mjs.map} +0 -0
  499. /package/dist/esm/{chunk-TYYVB2A6.mjs.map → chunk-GRB6YSIT.mjs.map} +0 -0
  500. /package/dist/esm/{chunk-RGKRCZ36.mjs.map → chunk-GYVSI3TS.mjs.map} +0 -0
  501. /package/dist/esm/{chunk-CW35YAMN.mjs.map → chunk-HPQMAP7O.mjs.map} +0 -0
  502. /package/dist/esm/{chunk-TOBQ5UE6.mjs.map → chunk-IXYGZ57N.mjs.map} +0 -0
  503. /package/dist/esm/{chunk-MML57K5H.mjs.map → chunk-NII5Q32W.mjs.map} +0 -0
  504. /package/dist/esm/{chunk-EBMEXURY.mjs.map → chunk-NJN3EAOM.mjs.map} +0 -0
  505. /package/dist/esm/{chunk-XKUIMGKU.mjs.map → chunk-OYH2T6V5.mjs.map} +0 -0
  506. /package/dist/esm/{chunk-XJJVJOX5.mjs.map → chunk-OYUW6ZN2.mjs.map} +0 -0
  507. /package/dist/esm/{chunk-5URUYE6H.mjs.map → chunk-PQS3II2E.mjs.map} +0 -0
  508. /package/dist/esm/{chunk-N6YTF76Q.mjs.map → chunk-PRUQZNAP.mjs.map} +0 -0
  509. /package/dist/esm/{chunk-UQWF24SS.mjs.map → chunk-QGFWOGAV.mjs.map} +0 -0
  510. /package/dist/esm/{chunk-4COLMDT3.mjs.map → chunk-QQEK2GJC.mjs.map} +0 -0
  511. /package/dist/esm/{chunk-MNDTFHDB.mjs.map → chunk-RFQFTIOA.mjs.map} +0 -0
  512. /package/dist/esm/{chunk-XZ75T7Q7.mjs.map → chunk-THUSLDD6.mjs.map} +0 -0
  513. /package/dist/esm/{chunk-FLZPUYXQ.mjs.map → chunk-UCBUUH5M.mjs.map} +0 -0
  514. /package/dist/esm/{chunk-MT2RJ7H3.mjs.map → chunk-WLUXOUZH.mjs.map} +0 -0
  515. /package/dist/esm/{chunk-FYYEPFML.mjs.map → chunk-XIQFX5FV.mjs.map} +0 -0
  516. /package/dist/esm/{chunk-7DQDJ2SA.mjs.map → chunk-YFFDF22R.mjs.map} +0 -0
  517. /package/dist/esm/{chunk-WCMW2L3P.mjs.map → chunk-Z6KQX6VX.mjs.map} +0 -0
  518. /package/dist/esm/{chunk-B563XRSZ.mjs.map → chunk-ZMT2M6YT.mjs.map} +0 -0
@@ -1,2183 +0,0 @@
1
- ///
2
- /// Simple vesting contract that allows specifying how much APT coins should be vesting in each fixed-size period. The
3
- /// vesting contract also comes with staking and allows shareholders to withdraw rewards anytime.
4
- ///
5
- /// Vesting schedule is represented as a vector of distributions. For example, a vesting schedule of
6
- /// [3/48, 3/48, 1/48] means that after the vesting starts:
7
- /// 1. The first and second periods will vest 3/48 of the total original grant.
8
- /// 2. The third period will vest 1/48.
9
- /// 3. All subsequent periods will also vest 1/48 (last distribution in the schedule) until the original grant runs out.
10
- ///
11
- /// Shareholder flow:
12
- /// 1. Admin calls create_vesting_contract with a schedule of [3/48, 3/48, 1/48] with a vesting cliff of 1 year and
13
- /// vesting period of 1 month.
14
- /// 2. After a month, a shareholder calls unlock_rewards to request rewards. They can also call vest() which would also
15
- /// unlocks rewards but since the 1 year cliff has not passed (vesting has not started), vest() would not release any of
16
- /// the original grant.
17
- /// 3. After the unlocked rewards become fully withdrawable (as it's subject to staking lockup), shareholders can call
18
- /// distribute() to send all withdrawable funds to all shareholders based on the original grant's shares structure.
19
- /// 4. After 1 year and 1 month, the vesting schedule now starts. Shareholders call vest() to unlock vested coins. vest()
20
- /// checks the schedule and unlocks 3/48 of the original grant in addition to any accumulated rewards since last
21
- /// unlock_rewards(). Once the unlocked coins become withdrawable, shareholders can call distribute().
22
- /// 5. Assuming the shareholders forgot to call vest() for 2 months, when they call vest() again, they will unlock vested
23
- /// tokens for the next period since last vest. This would be for the first month they missed. They can call vest() a
24
- /// second time to unlock for the second month they missed.
25
- ///
26
- /// Admin flow:
27
- /// 1. After creating the vesting contract, admin cannot change the vesting schedule.
28
- /// 2. Admin can call update_voter, update_operator, or reset_lockup at any time to update the underlying staking
29
- /// contract.
30
- /// 3. Admin can also call update_beneficiary for any shareholder. This would send all distributions (rewards, vested
31
- /// coins) of that shareholder to the beneficiary account. By defalt, if a beneficiary is not set, the distributions are
32
- /// send directly to the shareholder account.
33
- /// 4. Admin can call terminate_vesting_contract to terminate the vesting. This would first finish any distribution but
34
- /// will prevent any further rewards or vesting distributions from being created. Once the locked up stake becomes
35
- /// withdrawable, admin can call admin_withdraw to withdraw all funds to the vesting contract's withdrawal address.
36
- module aptos_framework::vesting {
37
- use std::bcs;
38
- use std::error;
39
- use std::fixed_point32::{Self, FixedPoint32};
40
- use std::signer;
41
- use std::string::{utf8, String};
42
- use std::vector;
43
-
44
- use aptos_std::pool_u64::{Self, Pool};
45
- use aptos_std::simple_map::{Self, SimpleMap};
46
-
47
- use aptos_framework::account::{Self, SignerCapability, new_event_handle};
48
- use aptos_framework::aptos_account::{Self, assert_account_is_registered_for_apt};
49
- use aptos_framework::aptos_coin::AptosCoin;
50
- use aptos_framework::coin::{Self, Coin};
51
- use aptos_framework::event::{EventHandle, emit, emit_event};
52
- use aptos_framework::stake;
53
- use aptos_framework::staking_contract;
54
- use aptos_framework::system_addresses;
55
- use aptos_framework::timestamp;
56
-
57
- friend aptos_framework::genesis;
58
-
59
- const VESTING_POOL_SALT: vector<u8> = b"aptos_framework::vesting";
60
-
61
- /// Withdrawal address is invalid.
62
- const EINVALID_WITHDRAWAL_ADDRESS: u64 = 1;
63
- /// Vesting schedule cannot be empty.
64
- const EEMPTY_VESTING_SCHEDULE: u64 = 2;
65
- /// Vesting period cannot be 0.
66
- const EZERO_VESTING_SCHEDULE_PERIOD: u64 = 3;
67
- /// Shareholders list cannot be empty.
68
- const ENO_SHAREHOLDERS: u64 = 4;
69
- /// The length of shareholders and shares lists don't match.
70
- const ESHARES_LENGTH_MISMATCH: u64 = 5;
71
- /// Vesting cannot start before or at the current block timestamp. Has to be in the future.
72
- const EVESTING_START_TOO_SOON: u64 = 6;
73
- /// The signer is not the admin of the vesting contract.
74
- const ENOT_ADMIN: u64 = 7;
75
- /// Vesting contract needs to be in active state.
76
- const EVESTING_CONTRACT_NOT_ACTIVE: u64 = 8;
77
- /// Admin can only withdraw from an inactive (paused or terminated) vesting contract.
78
- const EVESTING_CONTRACT_STILL_ACTIVE: u64 = 9;
79
- /// No vesting contract found at provided address.
80
- const EVESTING_CONTRACT_NOT_FOUND: u64 = 10;
81
- /// Cannot terminate the vesting contract with pending active stake. Need to wait until next epoch.
82
- const EPENDING_STAKE_FOUND: u64 = 11;
83
- /// Grant amount cannot be 0.
84
- const EZERO_GRANT: u64 = 12;
85
- /// Vesting account has no other management roles beside admin.
86
- const EVESTING_ACCOUNT_HAS_NO_ROLES: u64 = 13;
87
- /// The vesting account has no such management role.
88
- const EROLE_NOT_FOUND: u64 = 14;
89
- /// Account is not admin or does not have the required role to take this action.
90
- const EPERMISSION_DENIED: u64 = 15;
91
- /// Zero items were provided to a *_many function.
92
- const EVEC_EMPTY_FOR_MANY_FUNCTION: u64 = 16;
93
-
94
- /// Maximum number of shareholders a vesting pool can support.
95
- const MAXIMUM_SHAREHOLDERS: u64 = 30;
96
-
97
- /// Vesting contract states.
98
- /// Vesting contract is active and distributions can be made.
99
- const VESTING_POOL_ACTIVE: u64 = 1;
100
- /// Vesting contract has been terminated and all funds have been released back to the withdrawal address.
101
- const VESTING_POOL_TERMINATED: u64 = 2;
102
-
103
- /// Roles that can manage certain aspects of the vesting account beyond the main admin.
104
- const ROLE_BENEFICIARY_RESETTER: vector<u8> = b"ROLE_BENEFICIARY_RESETTER";
105
-
106
- struct VestingSchedule has copy, drop, store {
107
- // The vesting schedule as a list of fractions that vest for each period. The last number is repeated until the
108
- // vesting amount runs out.
109
- // For example [1/24, 1/24, 1/48] with a period of 1 month means that after vesting starts, the first two months
110
- // will vest 1/24 of the original total amount. From the third month only, 1/48 will vest until the vesting fund
111
- // runs out.
112
- // u32/u32 should be sufficient to support vesting schedule fractions.
113
- schedule: vector<FixedPoint32>,
114
- // When the vesting should start.
115
- start_timestamp_secs: u64,
116
- // In seconds. How long each vesting period is. For example 1 month.
117
- period_duration: u64,
118
- // Last vesting period, 1-indexed. For example if 2 months have passed, the last vesting period, if distribution
119
- // was requested, would be 2. Default value is 0 which means there have been no vesting periods yet.
120
- last_vested_period: u64,
121
- }
122
-
123
- struct StakingInfo has store {
124
- // Where the vesting's stake pool is located at. Included for convenience.
125
- pool_address: address,
126
- // The currently assigned operator.
127
- operator: address,
128
- // The currently assigned voter.
129
- voter: address,
130
- // Commission paid to the operator of the stake pool.
131
- commission_percentage: u64,
132
- }
133
-
134
- struct VestingContract has key {
135
- state: u64,
136
- admin: address,
137
- grant_pool: Pool,
138
- beneficiaries: SimpleMap<address, address>,
139
- vesting_schedule: VestingSchedule,
140
- // Withdrawal address where all funds would be released back to if the admin ends the vesting for a specific
141
- // account or terminates the entire vesting contract.
142
- withdrawal_address: address,
143
- staking: StakingInfo,
144
- // Remaining amount in the grant. For calculating accumulated rewards.
145
- remaining_grant: u64,
146
- // Used to control staking.
147
- signer_cap: SignerCapability,
148
-
149
- // Events.
150
- update_operator_events: EventHandle<UpdateOperatorEvent>,
151
- update_voter_events: EventHandle<UpdateVoterEvent>,
152
- reset_lockup_events: EventHandle<ResetLockupEvent>,
153
- set_beneficiary_events: EventHandle<SetBeneficiaryEvent>,
154
- unlock_rewards_events: EventHandle<UnlockRewardsEvent>,
155
- vest_events: EventHandle<VestEvent>,
156
- distribute_events: EventHandle<DistributeEvent>,
157
- terminate_events: EventHandle<TerminateEvent>,
158
- admin_withdraw_events: EventHandle<AdminWithdrawEvent>,
159
- }
160
-
161
- struct VestingAccountManagement has key {
162
- roles: SimpleMap<String, address>,
163
- }
164
-
165
- struct AdminStore has key {
166
- vesting_contracts: vector<address>,
167
- // Used to create resource accounts for new vesting contracts so there's no address collision.
168
- nonce: u64,
169
-
170
- create_events: EventHandle<CreateVestingContractEvent>,
171
- }
172
-
173
- #[event]
174
- struct CreateVestingContract has drop, store {
175
- operator: address,
176
- voter: address,
177
- grant_amount: u64,
178
- withdrawal_address: address,
179
- vesting_contract_address: address,
180
- staking_pool_address: address,
181
- commission_percentage: u64,
182
- }
183
-
184
- #[event]
185
- struct UpdateOperator has drop, store {
186
- admin: address,
187
- vesting_contract_address: address,
188
- staking_pool_address: address,
189
- old_operator: address,
190
- new_operator: address,
191
- commission_percentage: u64,
192
- }
193
-
194
- #[event]
195
- struct UpdateVoter has drop, store {
196
- admin: address,
197
- vesting_contract_address: address,
198
- staking_pool_address: address,
199
- old_voter: address,
200
- new_voter: address,
201
- }
202
-
203
- #[event]
204
- struct ResetLockup has drop, store {
205
- admin: address,
206
- vesting_contract_address: address,
207
- staking_pool_address: address,
208
- new_lockup_expiration_secs: u64,
209
- }
210
-
211
- #[event]
212
- struct SetBeneficiary has drop, store {
213
- admin: address,
214
- vesting_contract_address: address,
215
- shareholder: address,
216
- old_beneficiary: address,
217
- new_beneficiary: address,
218
- }
219
-
220
- #[event]
221
- struct UnlockRewards has drop, store {
222
- admin: address,
223
- vesting_contract_address: address,
224
- staking_pool_address: address,
225
- amount: u64,
226
- }
227
-
228
- #[event]
229
- struct Vest has drop, store {
230
- admin: address,
231
- vesting_contract_address: address,
232
- staking_pool_address: address,
233
- period_vested: u64,
234
- amount: u64,
235
- }
236
-
237
- #[event]
238
- struct Distribute has drop, store {
239
- admin: address,
240
- vesting_contract_address: address,
241
- amount: u64,
242
- }
243
-
244
- #[event]
245
- struct Terminate has drop, store {
246
- admin: address,
247
- vesting_contract_address: address,
248
- }
249
-
250
- #[event]
251
- struct AdminWithdraw has drop, store {
252
- admin: address,
253
- vesting_contract_address: address,
254
- amount: u64,
255
- }
256
-
257
- struct CreateVestingContractEvent has drop, store {
258
- operator: address,
259
- voter: address,
260
- grant_amount: u64,
261
- withdrawal_address: address,
262
- vesting_contract_address: address,
263
- staking_pool_address: address,
264
- commission_percentage: u64,
265
- }
266
-
267
- struct UpdateOperatorEvent has drop, store {
268
- admin: address,
269
- vesting_contract_address: address,
270
- staking_pool_address: address,
271
- old_operator: address,
272
- new_operator: address,
273
- commission_percentage: u64,
274
- }
275
-
276
- struct UpdateVoterEvent has drop, store {
277
- admin: address,
278
- vesting_contract_address: address,
279
- staking_pool_address: address,
280
- old_voter: address,
281
- new_voter: address,
282
- }
283
-
284
- struct ResetLockupEvent has drop, store {
285
- admin: address,
286
- vesting_contract_address: address,
287
- staking_pool_address: address,
288
- new_lockup_expiration_secs: u64,
289
- }
290
-
291
- struct SetBeneficiaryEvent has drop, store {
292
- admin: address,
293
- vesting_contract_address: address,
294
- shareholder: address,
295
- old_beneficiary: address,
296
- new_beneficiary: address,
297
- }
298
-
299
- struct UnlockRewardsEvent has drop, store {
300
- admin: address,
301
- vesting_contract_address: address,
302
- staking_pool_address: address,
303
- amount: u64,
304
- }
305
-
306
- struct VestEvent has drop, store {
307
- admin: address,
308
- vesting_contract_address: address,
309
- staking_pool_address: address,
310
- period_vested: u64,
311
- amount: u64,
312
- }
313
-
314
- struct DistributeEvent has drop, store {
315
- admin: address,
316
- vesting_contract_address: address,
317
- amount: u64,
318
- }
319
-
320
- struct TerminateEvent has drop, store {
321
- admin: address,
322
- vesting_contract_address: address,
323
- }
324
-
325
- struct AdminWithdrawEvent has drop, store {
326
- admin: address,
327
- vesting_contract_address: address,
328
- amount: u64,
329
- }
330
-
331
- #[view]
332
- /// Return the address of the underlying stake pool (separate resource account) of the vesting contract.
333
- ///
334
- /// This errors out if the vesting contract with the provided address doesn't exist.
335
- public fun stake_pool_address(vesting_contract_address: address): address acquires VestingContract {
336
- assert_vesting_contract_exists(vesting_contract_address);
337
- borrow_global<VestingContract>(vesting_contract_address).staking.pool_address
338
- }
339
-
340
- #[view]
341
- /// Return the vesting start timestamp (in seconds) of the vesting contract.
342
- /// Vesting will start at this time, and once a full period has passed, the first vest will become unlocked.
343
- ///
344
- /// This errors out if the vesting contract with the provided address doesn't exist.
345
- public fun vesting_start_secs(vesting_contract_address: address): u64 acquires VestingContract {
346
- assert_vesting_contract_exists(vesting_contract_address);
347
- borrow_global<VestingContract>(vesting_contract_address).vesting_schedule.start_timestamp_secs
348
- }
349
-
350
- #[view]
351
- /// Return the duration of one vesting period (in seconds).
352
- /// Each vest is released after one full period has started, starting from the specified start_timestamp_secs.
353
- ///
354
- /// This errors out if the vesting contract with the provided address doesn't exist.
355
- public fun period_duration_secs(vesting_contract_address: address): u64 acquires VestingContract {
356
- assert_vesting_contract_exists(vesting_contract_address);
357
- borrow_global<VestingContract>(vesting_contract_address).vesting_schedule.period_duration
358
- }
359
-
360
- #[view]
361
- /// Return the remaining grant, consisting of unvested coins that have not been distributed to shareholders.
362
- /// Prior to start_timestamp_secs, the remaining grant will always be equal to the original grant.
363
- /// Once vesting has started, and vested tokens are distributed, the remaining grant will decrease over time,
364
- /// according to the vesting schedule.
365
- ///
366
- /// This errors out if the vesting contract with the provided address doesn't exist.
367
- public fun remaining_grant(vesting_contract_address: address): u64 acquires VestingContract {
368
- assert_vesting_contract_exists(vesting_contract_address);
369
- borrow_global<VestingContract>(vesting_contract_address).remaining_grant
370
- }
371
-
372
- #[view]
373
- /// Return the beneficiary account of the specified shareholder in a vesting contract.
374
- /// This is the same as the shareholder address by default and only different if it's been explicitly set.
375
- ///
376
- /// This errors out if the vesting contract with the provided address doesn't exist.
377
- public fun beneficiary(vesting_contract_address: address, shareholder: address): address acquires VestingContract {
378
- assert_vesting_contract_exists(vesting_contract_address);
379
- get_beneficiary(borrow_global<VestingContract>(vesting_contract_address), shareholder)
380
- }
381
-
382
- #[view]
383
- /// Return the percentage of accumulated rewards that is paid to the operator as commission.
384
- ///
385
- /// This errors out if the vesting contract with the provided address doesn't exist.
386
- public fun operator_commission_percentage(vesting_contract_address: address): u64 acquires VestingContract {
387
- assert_vesting_contract_exists(vesting_contract_address);
388
- borrow_global<VestingContract>(vesting_contract_address).staking.commission_percentage
389
- }
390
-
391
- #[view]
392
- /// Return all the vesting contracts a given address is an admin of.
393
- public fun vesting_contracts(admin: address): vector<address> acquires AdminStore {
394
- if (!exists<AdminStore>(admin)) {
395
- vector::empty<address>()
396
- } else {
397
- borrow_global<AdminStore>(admin).vesting_contracts
398
- }
399
- }
400
-
401
- #[view]
402
- /// Return the operator who runs the validator for the vesting contract.
403
- ///
404
- /// This errors out if the vesting contract with the provided address doesn't exist.
405
- public fun operator(vesting_contract_address: address): address acquires VestingContract {
406
- assert_vesting_contract_exists(vesting_contract_address);
407
- borrow_global<VestingContract>(vesting_contract_address).staking.operator
408
- }
409
-
410
- #[view]
411
- /// Return the voter who will be voting on on-chain governance proposals on behalf of the vesting contract's stake
412
- /// pool.
413
- ///
414
- /// This errors out if the vesting contract with the provided address doesn't exist.
415
- public fun voter(vesting_contract_address: address): address acquires VestingContract {
416
- assert_vesting_contract_exists(vesting_contract_address);
417
- borrow_global<VestingContract>(vesting_contract_address).staking.voter
418
- }
419
-
420
- #[view]
421
- /// Return the vesting contract's vesting schedule. The core schedule is represented as a list of u64-based
422
- /// fractions, where the rightmmost 32 bits can be divided by 2^32 to get the fraction, and anything else is the
423
- /// whole number.
424
- ///
425
- /// For example 3/48, or 0.0625, will be represented as 268435456. The fractional portion would be
426
- /// 268435456 / 2^32 = 0.0625. Since there are fewer than 32 bits, the whole number portion is effectively 0.
427
- /// So 268435456 = 0.0625.
428
- ///
429
- /// This errors out if the vesting contract with the provided address doesn't exist.
430
- public fun vesting_schedule(vesting_contract_address: address): VestingSchedule acquires VestingContract {
431
- assert_vesting_contract_exists(vesting_contract_address);
432
- borrow_global<VestingContract>(vesting_contract_address).vesting_schedule
433
- }
434
-
435
- #[view]
436
- /// Return the total accumulated rewards that have not been distributed to shareholders of the vesting contract.
437
- /// This excludes any unpaid commission that the operator has not collected.
438
- ///
439
- /// This errors out if the vesting contract with the provided address doesn't exist.
440
- public fun total_accumulated_rewards(vesting_contract_address: address): u64 acquires VestingContract {
441
- assert_active_vesting_contract(vesting_contract_address);
442
-
443
- let vesting_contract = borrow_global<VestingContract>(vesting_contract_address);
444
- let (total_active_stake, _, commission_amount) =
445
- staking_contract::staking_contract_amounts(vesting_contract_address, vesting_contract.staking.operator);
446
- total_active_stake - vesting_contract.remaining_grant - commission_amount
447
- }
448
-
449
- #[view]
450
- /// Return the accumulated rewards that have not been distributed to the provided shareholder. Caller can also pass
451
- /// the beneficiary address instead of shareholder address.
452
- ///
453
- /// This errors out if the vesting contract with the provided address doesn't exist.
454
- public fun accumulated_rewards(
455
- vesting_contract_address: address, shareholder_or_beneficiary: address): u64 acquires VestingContract {
456
- assert_active_vesting_contract(vesting_contract_address);
457
-
458
- let total_accumulated_rewards = total_accumulated_rewards(vesting_contract_address);
459
- let shareholder = shareholder(vesting_contract_address, shareholder_or_beneficiary);
460
- let vesting_contract = borrow_global<VestingContract>(vesting_contract_address);
461
- let shares = pool_u64::shares(&vesting_contract.grant_pool, shareholder);
462
- pool_u64::shares_to_amount_with_total_coins(&vesting_contract.grant_pool, shares, total_accumulated_rewards)
463
- }
464
-
465
- #[view]
466
- /// Return the list of all shareholders in the vesting contract.
467
- public fun shareholders(vesting_contract_address: address): vector<address> acquires VestingContract {
468
- assert_active_vesting_contract(vesting_contract_address);
469
-
470
- let vesting_contract = borrow_global<VestingContract>(vesting_contract_address);
471
- pool_u64::shareholders(&vesting_contract.grant_pool)
472
- }
473
-
474
- #[view]
475
- /// Return the shareholder address given the beneficiary address in a given vesting contract. If there are multiple
476
- /// shareholders with the same beneficiary address, only the first shareholder is returned. If the given beneficiary
477
- /// address is actually a shareholder address, just return the address back.
478
- ///
479
- /// This returns 0x0 if no shareholder is found for the given beneficiary / the address is not a shareholder itself.
480
- public fun shareholder(
481
- vesting_contract_address: address,
482
- shareholder_or_beneficiary: address
483
- ): address acquires VestingContract {
484
- assert_active_vesting_contract(vesting_contract_address);
485
-
486
- let shareholders = &shareholders(vesting_contract_address);
487
- if (vector::contains(shareholders, &shareholder_or_beneficiary)) {
488
- return shareholder_or_beneficiary
489
- };
490
- let vesting_contract = borrow_global<VestingContract>(vesting_contract_address);
491
- let result = @0x0;
492
- vector::any(shareholders, |shareholder| {
493
- if (shareholder_or_beneficiary == get_beneficiary(vesting_contract, *shareholder)) {
494
- result = *shareholder;
495
- true
496
- } else {
497
- false
498
- }
499
- });
500
-
501
- result
502
- }
503
-
504
- /// Create a vesting schedule with the given schedule of distributions, a vesting start time and period duration.
505
- public fun create_vesting_schedule(
506
- schedule: vector<FixedPoint32>,
507
- start_timestamp_secs: u64,
508
- period_duration: u64,
509
- ): VestingSchedule {
510
- assert!(vector::length(&schedule) > 0, error::invalid_argument(EEMPTY_VESTING_SCHEDULE));
511
- assert!(period_duration > 0, error::invalid_argument(EZERO_VESTING_SCHEDULE_PERIOD));
512
- assert!(
513
- start_timestamp_secs >= timestamp::now_seconds(),
514
- error::invalid_argument(EVESTING_START_TOO_SOON),
515
- );
516
-
517
- VestingSchedule {
518
- schedule,
519
- start_timestamp_secs,
520
- period_duration,
521
- last_vested_period: 0,
522
- }
523
- }
524
-
525
- /// Create a vesting contract with a given configurations.
526
- public fun create_vesting_contract(
527
- admin: &signer,
528
- shareholders: &vector<address>,
529
- buy_ins: SimpleMap<address, Coin<AptosCoin>>,
530
- vesting_schedule: VestingSchedule,
531
- withdrawal_address: address,
532
- operator: address,
533
- voter: address,
534
- commission_percentage: u64,
535
- // Optional seed used when creating the staking contract account.
536
- contract_creation_seed: vector<u8>,
537
- ): address acquires AdminStore {
538
- assert!(
539
- !system_addresses::is_reserved_address(withdrawal_address),
540
- error::invalid_argument(EINVALID_WITHDRAWAL_ADDRESS),
541
- );
542
- assert_account_is_registered_for_apt(withdrawal_address);
543
- assert!(vector::length(shareholders) > 0, error::invalid_argument(ENO_SHAREHOLDERS));
544
- assert!(
545
- simple_map::length(&buy_ins) == vector::length(shareholders),
546
- error::invalid_argument(ESHARES_LENGTH_MISMATCH),
547
- );
548
-
549
- // Create a coins pool to track shareholders and shares of the grant.
550
- let grant = coin::zero<AptosCoin>();
551
- let grant_amount = 0;
552
- let grant_pool = pool_u64::create(MAXIMUM_SHAREHOLDERS);
553
- vector::for_each_ref(shareholders, |shareholder| {
554
- let shareholder: address = *shareholder;
555
- let (_, buy_in) = simple_map::remove(&mut buy_ins, &shareholder);
556
- let buy_in_amount = coin::value(&buy_in);
557
- coin::merge(&mut grant, buy_in);
558
- pool_u64::buy_in(
559
- &mut grant_pool,
560
- shareholder,
561
- buy_in_amount,
562
- );
563
- grant_amount = grant_amount + buy_in_amount;
564
- });
565
- assert!(grant_amount > 0, error::invalid_argument(EZERO_GRANT));
566
-
567
- // If this is the first time this admin account has created a vesting contract, initialize the admin store.
568
- let admin_address = signer::address_of(admin);
569
- if (!exists<AdminStore>(admin_address)) {
570
- move_to(admin, AdminStore {
571
- vesting_contracts: vector::empty<address>(),
572
- nonce: 0,
573
- create_events: new_event_handle<CreateVestingContractEvent>(admin),
574
- });
575
- };
576
-
577
- // Initialize the vesting contract in a new resource account. This allows the same admin to create multiple
578
- // pools.
579
- let (contract_signer, contract_signer_cap) = create_vesting_contract_account(admin, contract_creation_seed);
580
- let pool_address = staking_contract::create_staking_contract_with_coins(
581
- &contract_signer, operator, voter, grant, commission_percentage, contract_creation_seed);
582
-
583
- // Add the newly created vesting contract's address to the admin store.
584
- let contract_address = signer::address_of(&contract_signer);
585
- let admin_store = borrow_global_mut<AdminStore>(admin_address);
586
- vector::push_back(&mut admin_store.vesting_contracts, contract_address);
587
- if (std::features::module_event_migration_enabled()) {
588
- emit(
589
- CreateVestingContract {
590
- operator,
591
- voter,
592
- withdrawal_address,
593
- grant_amount,
594
- vesting_contract_address: contract_address,
595
- staking_pool_address: pool_address,
596
- commission_percentage,
597
- },
598
- );
599
- };
600
- emit_event(
601
- &mut admin_store.create_events,
602
- CreateVestingContractEvent {
603
- operator,
604
- voter,
605
- withdrawal_address,
606
- grant_amount,
607
- vesting_contract_address: contract_address,
608
- staking_pool_address: pool_address,
609
- commission_percentage,
610
- },
611
- );
612
-
613
- move_to(&contract_signer, VestingContract {
614
- state: VESTING_POOL_ACTIVE,
615
- admin: admin_address,
616
- grant_pool,
617
- beneficiaries: simple_map::create<address, address>(),
618
- vesting_schedule,
619
- withdrawal_address,
620
- staking: StakingInfo { pool_address, operator, voter, commission_percentage },
621
- remaining_grant: grant_amount,
622
- signer_cap: contract_signer_cap,
623
- update_operator_events: new_event_handle<UpdateOperatorEvent>(&contract_signer),
624
- update_voter_events: new_event_handle<UpdateVoterEvent>(&contract_signer),
625
- reset_lockup_events: new_event_handle<ResetLockupEvent>(&contract_signer),
626
- set_beneficiary_events: new_event_handle<SetBeneficiaryEvent>(&contract_signer),
627
- unlock_rewards_events: new_event_handle<UnlockRewardsEvent>(&contract_signer),
628
- vest_events: new_event_handle<VestEvent>(&contract_signer),
629
- distribute_events: new_event_handle<DistributeEvent>(&contract_signer),
630
- terminate_events: new_event_handle<TerminateEvent>(&contract_signer),
631
- admin_withdraw_events: new_event_handle<AdminWithdrawEvent>(&contract_signer),
632
- });
633
-
634
- simple_map::destroy_empty(buy_ins);
635
- contract_address
636
- }
637
-
638
- /// Unlock any accumulated rewards.
639
- public entry fun unlock_rewards(contract_address: address) acquires VestingContract {
640
- let accumulated_rewards = total_accumulated_rewards(contract_address);
641
- let vesting_contract = borrow_global<VestingContract>(contract_address);
642
- unlock_stake(vesting_contract, accumulated_rewards);
643
- }
644
-
645
- /// Call `unlock_rewards` for many vesting contracts.
646
- public entry fun unlock_rewards_many(contract_addresses: vector<address>) acquires VestingContract {
647
- let len = vector::length(&contract_addresses);
648
-
649
- assert!(len != 0, error::invalid_argument(EVEC_EMPTY_FOR_MANY_FUNCTION));
650
-
651
- vector::for_each_ref(&contract_addresses, |contract_address| {
652
- let contract_address: address = *contract_address;
653
- unlock_rewards(contract_address);
654
- });
655
- }
656
-
657
- /// Unlock any vested portion of the grant.
658
- public entry fun vest(contract_address: address) acquires VestingContract {
659
- // Unlock all rewards first, if any.
660
- unlock_rewards(contract_address);
661
-
662
- // Unlock the vested amount. This amount will become withdrawable when the underlying stake pool's lockup
663
- // expires.
664
- let vesting_contract = borrow_global_mut<VestingContract>(contract_address);
665
- // Short-circuit if vesting hasn't started yet.
666
- if (vesting_contract.vesting_schedule.start_timestamp_secs > timestamp::now_seconds()) {
667
- return
668
- };
669
-
670
- // Check if the next vested period has already passed. If not, short-circuit since there's nothing to vest.
671
- let vesting_schedule = &mut vesting_contract.vesting_schedule;
672
- let last_vested_period = vesting_schedule.last_vested_period;
673
- let next_period_to_vest = last_vested_period + 1;
674
- let last_completed_period =
675
- (timestamp::now_seconds() - vesting_schedule.start_timestamp_secs) / vesting_schedule.period_duration;
676
- if (last_completed_period < next_period_to_vest) {
677
- return
678
- };
679
-
680
- // Calculate how much has vested, excluding rewards.
681
- // Index is 0-based while period is 1-based so we need to subtract 1.
682
- let schedule = &vesting_schedule.schedule;
683
- let schedule_index = next_period_to_vest - 1;
684
- let vesting_fraction = if (schedule_index < vector::length(schedule)) {
685
- *vector::borrow(schedule, schedule_index)
686
- } else {
687
- // Last vesting schedule fraction will repeat until the grant runs out.
688
- *vector::borrow(schedule, vector::length(schedule) - 1)
689
- };
690
- let total_grant = pool_u64::total_coins(&vesting_contract.grant_pool);
691
- let vested_amount = fixed_point32::multiply_u64(total_grant, vesting_fraction);
692
- // Cap vested amount by the remaining grant amount so we don't try to distribute more than what's remaining.
693
- vested_amount = min(vested_amount, vesting_contract.remaining_grant);
694
- vesting_contract.remaining_grant = vesting_contract.remaining_grant - vested_amount;
695
- vesting_schedule.last_vested_period = next_period_to_vest;
696
- unlock_stake(vesting_contract, vested_amount);
697
-
698
- if (std::features::module_event_migration_enabled()) {
699
- emit(
700
- Vest {
701
- admin: vesting_contract.admin,
702
- vesting_contract_address: contract_address,
703
- staking_pool_address: vesting_contract.staking.pool_address,
704
- period_vested: next_period_to_vest,
705
- amount: vested_amount,
706
- },
707
- );
708
- };
709
- emit_event(
710
- &mut vesting_contract.vest_events,
711
- VestEvent {
712
- admin: vesting_contract.admin,
713
- vesting_contract_address: contract_address,
714
- staking_pool_address: vesting_contract.staking.pool_address,
715
- period_vested: next_period_to_vest,
716
- amount: vested_amount,
717
- },
718
- );
719
- }
720
-
721
- /// Call `vest` for many vesting contracts.
722
- public entry fun vest_many(contract_addresses: vector<address>) acquires VestingContract {
723
- let len = vector::length(&contract_addresses);
724
-
725
- assert!(len != 0, error::invalid_argument(EVEC_EMPTY_FOR_MANY_FUNCTION));
726
-
727
- vector::for_each_ref(&contract_addresses, |contract_address| {
728
- let contract_address = *contract_address;
729
- vest(contract_address);
730
- });
731
- }
732
-
733
- /// Distribute any withdrawable stake from the stake pool.
734
- public entry fun distribute(contract_address: address) acquires VestingContract {
735
- assert_active_vesting_contract(contract_address);
736
-
737
- let vesting_contract = borrow_global_mut<VestingContract>(contract_address);
738
- let coins = withdraw_stake(vesting_contract, contract_address);
739
- let total_distribution_amount = coin::value(&coins);
740
- if (total_distribution_amount == 0) {
741
- coin::destroy_zero(coins);
742
- return
743
- };
744
-
745
- // Distribute coins to all shareholders in the vesting contract.
746
- let grant_pool = &vesting_contract.grant_pool;
747
- let shareholders = &pool_u64::shareholders(grant_pool);
748
- vector::for_each_ref(shareholders, |shareholder| {
749
- let shareholder = *shareholder;
750
- let shares = pool_u64::shares(grant_pool, shareholder);
751
- let amount = pool_u64::shares_to_amount_with_total_coins(grant_pool, shares, total_distribution_amount);
752
- let share_of_coins = coin::extract(&mut coins, amount);
753
- let recipient_address = get_beneficiary(vesting_contract, shareholder);
754
- aptos_account::deposit_coins(recipient_address, share_of_coins);
755
- });
756
-
757
- // Send any remaining "dust" (leftover due to rounding error) to the withdrawal address.
758
- if (coin::value(&coins) > 0) {
759
- aptos_account::deposit_coins(vesting_contract.withdrawal_address, coins);
760
- } else {
761
- coin::destroy_zero(coins);
762
- };
763
-
764
- if (std::features::module_event_migration_enabled()) {
765
- emit(
766
- Distribute {
767
- admin: vesting_contract.admin,
768
- vesting_contract_address: contract_address,
769
- amount: total_distribution_amount,
770
- },
771
- );
772
- };
773
- emit_event(
774
- &mut vesting_contract.distribute_events,
775
- DistributeEvent {
776
- admin: vesting_contract.admin,
777
- vesting_contract_address: contract_address,
778
- amount: total_distribution_amount,
779
- },
780
- );
781
- }
782
-
783
- /// Call `distribute` for many vesting contracts.
784
- public entry fun distribute_many(contract_addresses: vector<address>) acquires VestingContract {
785
- let len = vector::length(&contract_addresses);
786
-
787
- assert!(len != 0, error::invalid_argument(EVEC_EMPTY_FOR_MANY_FUNCTION));
788
-
789
- vector::for_each_ref(&contract_addresses, |contract_address| {
790
- let contract_address = *contract_address;
791
- distribute(contract_address);
792
- });
793
- }
794
-
795
- /// Terminate the vesting contract and send all funds back to the withdrawal address.
796
- public entry fun terminate_vesting_contract(admin: &signer, contract_address: address) acquires VestingContract {
797
- assert_active_vesting_contract(contract_address);
798
-
799
- // Distribute all withdrawable coins, which should have been from previous rewards withdrawal or vest.
800
- distribute(contract_address);
801
-
802
- let vesting_contract = borrow_global_mut<VestingContract>(contract_address);
803
- verify_admin(admin, vesting_contract);
804
- let (active_stake, _, pending_active_stake, _) = stake::get_stake(vesting_contract.staking.pool_address);
805
- assert!(pending_active_stake == 0, error::invalid_state(EPENDING_STAKE_FOUND));
806
-
807
- // Unlock all remaining active stake.
808
- vesting_contract.state = VESTING_POOL_TERMINATED;
809
- vesting_contract.remaining_grant = 0;
810
- unlock_stake(vesting_contract, active_stake);
811
-
812
- if (std::features::module_event_migration_enabled()) {
813
- emit(
814
- Terminate {
815
- admin: vesting_contract.admin,
816
- vesting_contract_address: contract_address,
817
- },
818
- );
819
- };
820
- emit_event(
821
- &mut vesting_contract.terminate_events,
822
- TerminateEvent {
823
- admin: vesting_contract.admin,
824
- vesting_contract_address: contract_address,
825
- },
826
- );
827
- }
828
-
829
- /// Withdraw all funds to the preset vesting contract's withdrawal address. This can only be called if the contract
830
- /// has already been terminated.
831
- public entry fun admin_withdraw(admin: &signer, contract_address: address) acquires VestingContract {
832
- let vesting_contract = borrow_global<VestingContract>(contract_address);
833
- assert!(
834
- vesting_contract.state == VESTING_POOL_TERMINATED,
835
- error::invalid_state(EVESTING_CONTRACT_STILL_ACTIVE)
836
- );
837
-
838
- let vesting_contract = borrow_global_mut<VestingContract>(contract_address);
839
- verify_admin(admin, vesting_contract);
840
- let coins = withdraw_stake(vesting_contract, contract_address);
841
- let amount = coin::value(&coins);
842
- if (amount == 0) {
843
- coin::destroy_zero(coins);
844
- return
845
- };
846
- aptos_account::deposit_coins(vesting_contract.withdrawal_address, coins);
847
-
848
- if (std::features::module_event_migration_enabled()) {
849
- emit(
850
- AdminWithdraw {
851
- admin: vesting_contract.admin,
852
- vesting_contract_address: contract_address,
853
- amount,
854
- },
855
- );
856
- };
857
- emit_event(
858
- &mut vesting_contract.admin_withdraw_events,
859
- AdminWithdrawEvent {
860
- admin: vesting_contract.admin,
861
- vesting_contract_address: contract_address,
862
- amount,
863
- },
864
- );
865
- }
866
-
867
- public entry fun update_operator(
868
- admin: &signer,
869
- contract_address: address,
870
- new_operator: address,
871
- commission_percentage: u64,
872
- ) acquires VestingContract {
873
- let vesting_contract = borrow_global_mut<VestingContract>(contract_address);
874
- verify_admin(admin, vesting_contract);
875
- let contract_signer = &get_vesting_account_signer_internal(vesting_contract);
876
- let old_operator = vesting_contract.staking.operator;
877
- staking_contract::switch_operator(contract_signer, old_operator, new_operator, commission_percentage);
878
- vesting_contract.staking.operator = new_operator;
879
- vesting_contract.staking.commission_percentage = commission_percentage;
880
-
881
- if (std::features::module_event_migration_enabled()) {
882
- emit(
883
- UpdateOperator {
884
- admin: vesting_contract.admin,
885
- vesting_contract_address: contract_address,
886
- staking_pool_address: vesting_contract.staking.pool_address,
887
- old_operator,
888
- new_operator,
889
- commission_percentage,
890
- },
891
- );
892
- };
893
- emit_event(
894
- &mut vesting_contract.update_operator_events,
895
- UpdateOperatorEvent {
896
- admin: vesting_contract.admin,
897
- vesting_contract_address: contract_address,
898
- staking_pool_address: vesting_contract.staking.pool_address,
899
- old_operator,
900
- new_operator,
901
- commission_percentage,
902
- },
903
- );
904
- }
905
-
906
- public entry fun update_operator_with_same_commission(
907
- admin: &signer,
908
- contract_address: address,
909
- new_operator: address,
910
- ) acquires VestingContract {
911
- let commission_percentage = operator_commission_percentage(contract_address);
912
- update_operator(admin, contract_address, new_operator, commission_percentage);
913
- }
914
-
915
- public entry fun update_commission_percentage(
916
- admin: &signer,
917
- contract_address: address,
918
- new_commission_percentage: u64,
919
- ) acquires VestingContract {
920
- let operator = operator(contract_address);
921
- let vesting_contract = borrow_global_mut<VestingContract>(contract_address);
922
- verify_admin(admin, vesting_contract);
923
- let contract_signer = &get_vesting_account_signer_internal(vesting_contract);
924
- staking_contract::update_commision(contract_signer, operator, new_commission_percentage);
925
- vesting_contract.staking.commission_percentage = new_commission_percentage;
926
- // This function does not emit an event. Instead, `staking_contract::update_commission_percentage`
927
- // emits the event for this commission percentage update.
928
- }
929
-
930
- public entry fun update_voter(
931
- admin: &signer,
932
- contract_address: address,
933
- new_voter: address,
934
- ) acquires VestingContract {
935
- let vesting_contract = borrow_global_mut<VestingContract>(contract_address);
936
- verify_admin(admin, vesting_contract);
937
- let contract_signer = &get_vesting_account_signer_internal(vesting_contract);
938
- let old_voter = vesting_contract.staking.voter;
939
- staking_contract::update_voter(contract_signer, vesting_contract.staking.operator, new_voter);
940
- vesting_contract.staking.voter = new_voter;
941
-
942
- if (std::features::module_event_migration_enabled()) {
943
- emit(
944
- UpdateVoter {
945
- admin: vesting_contract.admin,
946
- vesting_contract_address: contract_address,
947
- staking_pool_address: vesting_contract.staking.pool_address,
948
- old_voter,
949
- new_voter,
950
- },
951
- );
952
- };
953
- emit_event(
954
- &mut vesting_contract.update_voter_events,
955
- UpdateVoterEvent {
956
- admin: vesting_contract.admin,
957
- vesting_contract_address: contract_address,
958
- staking_pool_address: vesting_contract.staking.pool_address,
959
- old_voter,
960
- new_voter,
961
- },
962
- );
963
- }
964
-
965
- public entry fun reset_lockup(
966
- admin: &signer,
967
- contract_address: address,
968
- ) acquires VestingContract {
969
- let vesting_contract = borrow_global_mut<VestingContract>(contract_address);
970
- verify_admin(admin, vesting_contract);
971
- let contract_signer = &get_vesting_account_signer_internal(vesting_contract);
972
- staking_contract::reset_lockup(contract_signer, vesting_contract.staking.operator);
973
-
974
- if (std::features::module_event_migration_enabled()) {
975
- emit(
976
- ResetLockup {
977
- admin: vesting_contract.admin,
978
- vesting_contract_address: contract_address,
979
- staking_pool_address: vesting_contract.staking.pool_address,
980
- new_lockup_expiration_secs: stake::get_lockup_secs(vesting_contract.staking.pool_address),
981
- },
982
- );
983
- };
984
- emit_event(
985
- &mut vesting_contract.reset_lockup_events,
986
- ResetLockupEvent {
987
- admin: vesting_contract.admin,
988
- vesting_contract_address: contract_address,
989
- staking_pool_address: vesting_contract.staking.pool_address,
990
- new_lockup_expiration_secs: stake::get_lockup_secs(vesting_contract.staking.pool_address),
991
- },
992
- );
993
- }
994
-
995
- public entry fun set_beneficiary(
996
- admin: &signer,
997
- contract_address: address,
998
- shareholder: address,
999
- new_beneficiary: address,
1000
- ) acquires VestingContract {
1001
- // Verify that the beneficiary account is set up to receive APT. This is a requirement so distribute() wouldn't
1002
- // fail and block all other accounts from receiving APT if one beneficiary is not registered.
1003
- assert_account_is_registered_for_apt(new_beneficiary);
1004
-
1005
- let vesting_contract = borrow_global_mut<VestingContract>(contract_address);
1006
- verify_admin(admin, vesting_contract);
1007
-
1008
- let old_beneficiary = get_beneficiary(vesting_contract, shareholder);
1009
- let beneficiaries = &mut vesting_contract.beneficiaries;
1010
- if (simple_map::contains_key(beneficiaries, &shareholder)) {
1011
- let beneficiary = simple_map::borrow_mut(beneficiaries, &shareholder);
1012
- *beneficiary = new_beneficiary;
1013
- } else {
1014
- simple_map::add(beneficiaries, shareholder, new_beneficiary);
1015
- };
1016
-
1017
- if (std::features::module_event_migration_enabled()) {
1018
- emit(
1019
- SetBeneficiary {
1020
- admin: vesting_contract.admin,
1021
- vesting_contract_address: contract_address,
1022
- shareholder,
1023
- old_beneficiary,
1024
- new_beneficiary,
1025
- },
1026
- );
1027
- };
1028
- emit_event(
1029
- &mut vesting_contract.set_beneficiary_events,
1030
- SetBeneficiaryEvent {
1031
- admin: vesting_contract.admin,
1032
- vesting_contract_address: contract_address,
1033
- shareholder,
1034
- old_beneficiary,
1035
- new_beneficiary,
1036
- },
1037
- );
1038
- }
1039
-
1040
- /// Remove the beneficiary for the given shareholder. All distributions will sent directly to the shareholder
1041
- /// account.
1042
- public entry fun reset_beneficiary(
1043
- account: &signer,
1044
- contract_address: address,
1045
- shareholder: address,
1046
- ) acquires VestingAccountManagement, VestingContract {
1047
- let vesting_contract = borrow_global_mut<VestingContract>(contract_address);
1048
- let addr = signer::address_of(account);
1049
- assert!(
1050
- addr == vesting_contract.admin ||
1051
- addr == get_role_holder(contract_address, utf8(ROLE_BENEFICIARY_RESETTER)),
1052
- error::permission_denied(EPERMISSION_DENIED),
1053
- );
1054
-
1055
- let beneficiaries = &mut vesting_contract.beneficiaries;
1056
- if (simple_map::contains_key(beneficiaries, &shareholder)) {
1057
- simple_map::remove(beneficiaries, &shareholder);
1058
- };
1059
- }
1060
-
1061
- public entry fun set_management_role(
1062
- admin: &signer,
1063
- contract_address: address,
1064
- role: String,
1065
- role_holder: address,
1066
- ) acquires VestingAccountManagement, VestingContract {
1067
- let vesting_contract = borrow_global_mut<VestingContract>(contract_address);
1068
- verify_admin(admin, vesting_contract);
1069
-
1070
- if (!exists<VestingAccountManagement>(contract_address)) {
1071
- let contract_signer = &get_vesting_account_signer_internal(vesting_contract);
1072
- move_to(contract_signer, VestingAccountManagement {
1073
- roles: simple_map::create<String, address>(),
1074
- })
1075
- };
1076
- let roles = &mut borrow_global_mut<VestingAccountManagement>(contract_address).roles;
1077
- if (simple_map::contains_key(roles, &role)) {
1078
- *simple_map::borrow_mut(roles, &role) = role_holder;
1079
- } else {
1080
- simple_map::add(roles, role, role_holder);
1081
- };
1082
- }
1083
-
1084
- public entry fun set_beneficiary_resetter(
1085
- admin: &signer,
1086
- contract_address: address,
1087
- beneficiary_resetter: address,
1088
- ) acquires VestingAccountManagement, VestingContract {
1089
- set_management_role(admin, contract_address, utf8(ROLE_BENEFICIARY_RESETTER), beneficiary_resetter);
1090
- }
1091
-
1092
- /// Set the beneficiary for the operator.
1093
- public entry fun set_beneficiary_for_operator(
1094
- operator: &signer,
1095
- new_beneficiary: address,
1096
- ) {
1097
- staking_contract::set_beneficiary_for_operator(operator, new_beneficiary);
1098
- }
1099
-
1100
- public fun get_role_holder(contract_address: address, role: String): address acquires VestingAccountManagement {
1101
- assert!(exists<VestingAccountManagement>(contract_address), error::not_found(EVESTING_ACCOUNT_HAS_NO_ROLES));
1102
- let roles = &borrow_global<VestingAccountManagement>(contract_address).roles;
1103
- assert!(simple_map::contains_key(roles, &role), error::not_found(EROLE_NOT_FOUND));
1104
- *simple_map::borrow(roles, &role)
1105
- }
1106
-
1107
- /// For emergency use in case the admin needs emergency control of vesting contract account.
1108
- /// This doesn't give the admin total power as the admin would still need to follow the rules set by
1109
- /// staking_contract and stake modules.
1110
- public fun get_vesting_account_signer(admin: &signer, contract_address: address): signer acquires VestingContract {
1111
- let vesting_contract = borrow_global_mut<VestingContract>(contract_address);
1112
- verify_admin(admin, vesting_contract);
1113
- get_vesting_account_signer_internal(vesting_contract)
1114
- }
1115
-
1116
- fun get_vesting_account_signer_internal(vesting_contract: &VestingContract): signer {
1117
- account::create_signer_with_capability(&vesting_contract.signer_cap)
1118
- }
1119
-
1120
- /// Create a salt for generating the resource accounts that will be holding the VestingContract.
1121
- /// This address should be deterministic for the same admin and vesting contract creation nonce.
1122
- fun create_vesting_contract_account(
1123
- admin: &signer,
1124
- contract_creation_seed: vector<u8>,
1125
- ): (signer, SignerCapability) acquires AdminStore {
1126
- let admin_store = borrow_global_mut<AdminStore>(signer::address_of(admin));
1127
- let seed = bcs::to_bytes(&signer::address_of(admin));
1128
- vector::append(&mut seed, bcs::to_bytes(&admin_store.nonce));
1129
- admin_store.nonce = admin_store.nonce + 1;
1130
-
1131
- // Include a salt to avoid conflicts with any other modules out there that might also generate
1132
- // deterministic resource accounts for the same admin address + nonce.
1133
- vector::append(&mut seed, VESTING_POOL_SALT);
1134
- vector::append(&mut seed, contract_creation_seed);
1135
-
1136
- let (account_signer, signer_cap) = account::create_resource_account(admin, seed);
1137
- // Register the vesting contract account to receive APT as it'll be sent to it when claiming unlocked stake from
1138
- // the underlying staking contract.
1139
- coin::register<AptosCoin>(&account_signer);
1140
-
1141
- (account_signer, signer_cap)
1142
- }
1143
-
1144
- fun verify_admin(admin: &signer, vesting_contract: &VestingContract) {
1145
- assert!(signer::address_of(admin) == vesting_contract.admin, error::unauthenticated(ENOT_ADMIN));
1146
- }
1147
-
1148
- fun assert_vesting_contract_exists(contract_address: address) {
1149
- assert!(exists<VestingContract>(contract_address), error::not_found(EVESTING_CONTRACT_NOT_FOUND));
1150
- }
1151
-
1152
- fun assert_active_vesting_contract(contract_address: address) acquires VestingContract {
1153
- assert_vesting_contract_exists(contract_address);
1154
- let vesting_contract = borrow_global<VestingContract>(contract_address);
1155
- assert!(vesting_contract.state == VESTING_POOL_ACTIVE, error::invalid_state(EVESTING_CONTRACT_NOT_ACTIVE));
1156
- }
1157
-
1158
- fun unlock_stake(vesting_contract: &VestingContract, amount: u64) {
1159
- let contract_signer = &get_vesting_account_signer_internal(vesting_contract);
1160
- staking_contract::unlock_stake(contract_signer, vesting_contract.staking.operator, amount);
1161
- }
1162
-
1163
- fun withdraw_stake(vesting_contract: &VestingContract, contract_address: address): Coin<AptosCoin> {
1164
- // Claim any withdrawable distribution from the staking contract. The withdrawn coins will be sent directly to
1165
- // the vesting contract's account.
1166
- staking_contract::distribute(contract_address, vesting_contract.staking.operator);
1167
- let withdrawn_coins = coin::balance<AptosCoin>(contract_address);
1168
- let contract_signer = &get_vesting_account_signer_internal(vesting_contract);
1169
- coin::withdraw<AptosCoin>(contract_signer, withdrawn_coins)
1170
- }
1171
-
1172
- fun get_beneficiary(contract: &VestingContract, shareholder: address): address {
1173
- if (simple_map::contains_key(&contract.beneficiaries, &shareholder)) {
1174
- *simple_map::borrow(&contract.beneficiaries, &shareholder)
1175
- } else {
1176
- shareholder
1177
- }
1178
- }
1179
-
1180
- #[test_only]
1181
- use aptos_framework::stake::with_rewards;
1182
-
1183
- #[test_only]
1184
- use aptos_framework::account::create_account_for_test;
1185
- use aptos_std::math64::min;
1186
-
1187
- #[test_only]
1188
- const MIN_STAKE: u64 = 100000000000000; // 1M APT coins with 8 decimals.
1189
-
1190
- #[test_only]
1191
- const GRANT_AMOUNT: u64 = 20000000000000000; // 200M APT coins with 8 decimals.
1192
-
1193
- #[test_only]
1194
- const VESTING_SCHEDULE_CLIFF: u64 = 31536000; // 1 year
1195
-
1196
- #[test_only]
1197
- const VESTING_PERIOD: u64 = 2592000; // 30 days
1198
-
1199
- #[test_only]
1200
- const VALIDATOR_STATUS_PENDING_ACTIVE: u64 = 1;
1201
- #[test_only]
1202
- const VALIDATOR_STATUS_ACTIVE: u64 = 2;
1203
- #[test_only]
1204
- const VALIDATOR_STATUS_INACTIVE: u64 = 4;
1205
-
1206
- #[test_only]
1207
- const MODULE_EVENT: u64 = 26;
1208
-
1209
- #[test_only]
1210
- const OPERATOR_BENEFICIARY_CHANGE: u64 = 39;
1211
-
1212
- #[test_only]
1213
- public fun setup(aptos_framework: &signer, accounts: &vector<address>) {
1214
- use aptos_framework::aptos_account::create_account;
1215
-
1216
- stake::initialize_for_test_custom(
1217
- aptos_framework,
1218
- MIN_STAKE,
1219
- GRANT_AMOUNT * 10,
1220
- 3600,
1221
- true,
1222
- 10,
1223
- 10000,
1224
- 1000000
1225
- );
1226
-
1227
- vector::for_each_ref(accounts, |addr| {
1228
- let addr: address = *addr;
1229
- if (!account::exists_at(addr)) {
1230
- create_account(addr);
1231
- };
1232
- });
1233
-
1234
- std::features::change_feature_flags_for_testing(aptos_framework, vector[MODULE_EVENT, OPERATOR_BENEFICIARY_CHANGE], vector[]);
1235
- }
1236
-
1237
- #[test_only]
1238
- public fun setup_vesting_contract(
1239
- admin: &signer,
1240
- shareholders: &vector<address>,
1241
- shares: &vector<u64>,
1242
- withdrawal_address: address,
1243
- commission_percentage: u64,
1244
- ): address acquires AdminStore {
1245
- setup_vesting_contract_with_schedule(
1246
- admin,
1247
- shareholders,
1248
- shares,
1249
- withdrawal_address,
1250
- commission_percentage,
1251
- &vector[3, 2, 1],
1252
- 48,
1253
- )
1254
- }
1255
-
1256
- #[test_only]
1257
- public fun setup_vesting_contract_with_schedule(
1258
- admin: &signer,
1259
- shareholders: &vector<address>,
1260
- shares: &vector<u64>,
1261
- withdrawal_address: address,
1262
- commission_percentage: u64,
1263
- vesting_numerators: &vector<u64>,
1264
- vesting_denominator: u64,
1265
- ): address acquires AdminStore {
1266
- let schedule = vector::empty<FixedPoint32>();
1267
- vector::for_each_ref(vesting_numerators, |num| {
1268
- vector::push_back(&mut schedule, fixed_point32::create_from_rational(*num, vesting_denominator));
1269
- });
1270
- let vesting_schedule = create_vesting_schedule(
1271
- schedule,
1272
- timestamp::now_seconds() + VESTING_SCHEDULE_CLIFF,
1273
- VESTING_PERIOD,
1274
- );
1275
-
1276
- let admin_address = signer::address_of(admin);
1277
- let buy_ins = simple_map::create<address, Coin<AptosCoin>>();
1278
- vector::enumerate_ref(shares, |i, share| {
1279
- let shareholder = *vector::borrow(shareholders, i);
1280
- simple_map::add(&mut buy_ins, shareholder, stake::mint_coins(*share));
1281
- });
1282
-
1283
- create_vesting_contract(
1284
- admin,
1285
- shareholders,
1286
- buy_ins,
1287
- vesting_schedule,
1288
- withdrawal_address,
1289
- admin_address,
1290
- admin_address,
1291
- commission_percentage,
1292
- vector[],
1293
- )
1294
- }
1295
-
1296
- #[test(aptos_framework = @0x1, admin = @0x123, shareholder_1 = @0x234, shareholder_2 = @0x345, withdrawal = @111)]
1297
- public entry fun test_end_to_end(
1298
- aptos_framework: &signer,
1299
- admin: &signer,
1300
- shareholder_1: &signer,
1301
- shareholder_2: &signer,
1302
- withdrawal: &signer,
1303
- ) acquires AdminStore, VestingContract {
1304
- let admin_address = signer::address_of(admin);
1305
- let withdrawal_address = signer::address_of(withdrawal);
1306
- let shareholder_1_address = signer::address_of(shareholder_1);
1307
- let shareholder_2_address = signer::address_of(shareholder_2);
1308
- let shareholders = &vector[shareholder_1_address, shareholder_2_address];
1309
- let shareholder_1_share = GRANT_AMOUNT / 4;
1310
- let shareholder_2_share = GRANT_AMOUNT * 3 / 4;
1311
- let shares = &vector[shareholder_1_share, shareholder_2_share];
1312
-
1313
- // Create the vesting contract.
1314
- setup(
1315
- aptos_framework, &vector[admin_address, withdrawal_address, shareholder_1_address, shareholder_2_address]);
1316
- let contract_address = setup_vesting_contract(admin, shareholders, shares, withdrawal_address, 0);
1317
- assert!(vector::length(&borrow_global<AdminStore>(admin_address).vesting_contracts) == 1, 0);
1318
- let stake_pool_address = stake_pool_address(contract_address);
1319
- stake::assert_stake_pool(stake_pool_address, GRANT_AMOUNT, 0, 0, 0);
1320
-
1321
- // The stake pool is still in pending active stake, so unlock_rewards and vest shouldn't do anything.
1322
- let (_sk, pk, pop) = stake::generate_identity();
1323
- stake::join_validator_set_for_test(&pk, &pop, admin, stake_pool_address, false);
1324
- assert!(stake::get_validator_state(stake_pool_address) == VALIDATOR_STATUS_PENDING_ACTIVE, 1);
1325
- unlock_rewards(contract_address);
1326
- vest(contract_address);
1327
- stake::assert_stake_pool(stake_pool_address, GRANT_AMOUNT, 0, 0, 0);
1328
-
1329
- // Wait for the validator to join the validator set. No rewards are earnt yet so unlock_rewards and vest should
1330
- // still do nothing.
1331
- stake::end_epoch();
1332
- assert!(stake::get_validator_state(stake_pool_address) == VALIDATOR_STATUS_ACTIVE, 2);
1333
- unlock_rewards(contract_address);
1334
- vest(contract_address);
1335
- stake::assert_stake_pool(stake_pool_address, GRANT_AMOUNT, 0, 0, 0);
1336
-
1337
- // Stake pool earns some rewards. unlock_rewards should unlock the right amount.
1338
- stake::end_epoch();
1339
- let rewards = get_accumulated_rewards(contract_address);
1340
- unlock_rewards(contract_address);
1341
- stake::assert_stake_pool(stake_pool_address, GRANT_AMOUNT, 0, 0, rewards);
1342
- assert!(remaining_grant(contract_address) == GRANT_AMOUNT, 0);
1343
-
1344
- // Stake pool earns more rewards. vest should unlock the rewards but no vested tokens as vesting hasn't started.
1345
- stake::end_epoch();
1346
- rewards = with_rewards(rewards); // Pending inactive stake still earns rewards.
1347
- rewards = rewards + get_accumulated_rewards(contract_address);
1348
- vest(contract_address);
1349
- stake::assert_stake_pool(stake_pool_address, GRANT_AMOUNT, 0, 0, rewards);
1350
- assert!(remaining_grant(contract_address) == GRANT_AMOUNT, 0);
1351
-
1352
- // Fast forward to stake lockup expiration so rewards are fully unlocked.
1353
- // In the mean time, rewards still earn rewards.
1354
- // Calling distribute() should send rewards to the shareholders.
1355
- stake::fast_forward_to_unlock(stake_pool_address);
1356
- rewards = with_rewards(rewards);
1357
- distribute(contract_address);
1358
- let shareholder_1_bal = coin::balance<AptosCoin>(shareholder_1_address);
1359
- let shareholder_2_bal = coin::balance<AptosCoin>(shareholder_2_address);
1360
- // Distribution goes by the shares of the vesting contract.
1361
- assert!(shareholder_1_bal == rewards / 4, shareholder_1_bal);
1362
- assert!(shareholder_2_bal == rewards * 3 / 4, shareholder_2_bal);
1363
-
1364
- // Fast forward time to the vesting start.
1365
- timestamp::update_global_time_for_test_secs(vesting_start_secs(contract_address));
1366
- // Calling vest only unlocks rewards but not any vested token as the first vesting period hasn't passed yet.
1367
- rewards = get_accumulated_rewards(contract_address);
1368
- vest(contract_address);
1369
- stake::assert_stake_pool(stake_pool_address, GRANT_AMOUNT, 0, 0, rewards);
1370
- assert!(remaining_grant(contract_address) == GRANT_AMOUNT, 0);
1371
-
1372
- // Fast forward to the end of the first period. vest() should now unlock 3/48 of the tokens.
1373
- timestamp::fast_forward_seconds(VESTING_PERIOD);
1374
- vest(contract_address);
1375
- let vested_amount = fraction(GRANT_AMOUNT, 3, 48);
1376
- let remaining_grant = GRANT_AMOUNT - vested_amount;
1377
- let pending_distribution = rewards + vested_amount;
1378
- assert!(remaining_grant(contract_address) == remaining_grant, remaining_grant(contract_address));
1379
- stake::assert_stake_pool(stake_pool_address, remaining_grant, 0, 0, pending_distribution);
1380
-
1381
- // Fast forward to the end of the fourth period. We can call vest() 3 times to vest the last 3 periods.
1382
- timestamp::fast_forward_seconds(VESTING_PERIOD * 3);
1383
- vest(contract_address);
1384
- vested_amount = fraction(GRANT_AMOUNT, 2, 48);
1385
- remaining_grant = remaining_grant - vested_amount;
1386
- pending_distribution = pending_distribution + vested_amount;
1387
- stake::assert_stake_pool(stake_pool_address, remaining_grant, 0, 0, pending_distribution);
1388
- vest(contract_address);
1389
- vested_amount = fraction(GRANT_AMOUNT, 1, 48);
1390
- remaining_grant = remaining_grant - vested_amount;
1391
- pending_distribution = pending_distribution + vested_amount;
1392
- stake::assert_stake_pool(stake_pool_address, remaining_grant, 0, 0, pending_distribution);
1393
- // The last vesting fraction (1/48) is repeated beyond the first 3 periods.
1394
- vest(contract_address);
1395
- remaining_grant = remaining_grant - vested_amount;
1396
- pending_distribution = pending_distribution + vested_amount;
1397
- stake::assert_stake_pool(stake_pool_address, remaining_grant, 0, 0, pending_distribution);
1398
- assert!(remaining_grant(contract_address) == remaining_grant, 0);
1399
-
1400
- stake::end_epoch();
1401
- let total_active = with_rewards(remaining_grant);
1402
- pending_distribution = with_rewards(pending_distribution);
1403
- distribute(contract_address);
1404
- stake::assert_stake_pool(stake_pool_address, total_active, 0, 0, 0);
1405
- assert!(coin::balance<AptosCoin>(shareholder_1_address) == shareholder_1_bal + pending_distribution / 4, 0);
1406
- assert!(coin::balance<AptosCoin>(shareholder_2_address) == shareholder_2_bal + pending_distribution * 3 / 4, 1);
1407
- // Withdrawal address receives the left-over dust of 1 coin due to rounding error.
1408
- assert!(coin::balance<AptosCoin>(withdrawal_address) == 1, 0);
1409
-
1410
- // Admin terminates the vesting contract.
1411
- terminate_vesting_contract(admin, contract_address);
1412
- stake::assert_stake_pool(stake_pool_address, 0, 0, 0, total_active);
1413
- assert!(remaining_grant(contract_address) == 0, 0);
1414
- stake::fast_forward_to_unlock(stake_pool_address);
1415
- let withdrawn_amount = with_rewards(total_active);
1416
- stake::assert_stake_pool(stake_pool_address, 0, withdrawn_amount, 0, 0);
1417
- let previous_bal = coin::balance<AptosCoin>(withdrawal_address);
1418
- admin_withdraw(admin, contract_address);
1419
- assert!(coin::balance<AptosCoin>(withdrawal_address) == previous_bal + withdrawn_amount, 0);
1420
- }
1421
-
1422
- #[test(aptos_framework = @0x1, admin = @0x123)]
1423
- #[expected_failure(abort_code = 0x1000C, location = Self)]
1424
- public entry fun test_create_vesting_contract_with_zero_grant_should_fail(
1425
- aptos_framework: &signer,
1426
- admin: &signer,
1427
- ) acquires AdminStore {
1428
- let admin_address = signer::address_of(admin);
1429
- setup(aptos_framework, &vector[admin_address]);
1430
- setup_vesting_contract(admin, &vector[@1], &vector[0], admin_address, 0);
1431
- }
1432
-
1433
- #[test(aptos_framework = @0x1, admin = @0x123)]
1434
- #[expected_failure(abort_code = 0x10004, location = Self)]
1435
- public entry fun test_create_vesting_contract_with_no_shareholders_should_fail(
1436
- aptos_framework: &signer,
1437
- admin: &signer,
1438
- ) acquires AdminStore {
1439
- let admin_address = signer::address_of(admin);
1440
- setup(aptos_framework, &vector[admin_address]);
1441
- setup_vesting_contract(admin, &vector[], &vector[], admin_address, 0);
1442
- }
1443
-
1444
- #[test(aptos_framework = @0x1, admin = @0x123)]
1445
- #[expected_failure(abort_code = 0x10005, location = Self)]
1446
- public entry fun test_create_vesting_contract_with_mistmaching_shareholders_should_fail(
1447
- aptos_framework: &signer,
1448
- admin: &signer,
1449
- ) acquires AdminStore {
1450
- let admin_address = signer::address_of(admin);
1451
- setup(aptos_framework, &vector[admin_address]);
1452
- setup_vesting_contract(admin, &vector[@1, @2], &vector[1], admin_address, 0);
1453
- }
1454
-
1455
- #[test(aptos_framework = @0x1, admin = @0x123)]
1456
- #[expected_failure(abort_code = 0x60001, location = aptos_framework::aptos_account)]
1457
- public entry fun test_create_vesting_contract_with_invalid_withdrawal_address_should_fail(
1458
- aptos_framework: &signer,
1459
- admin: &signer,
1460
- ) acquires AdminStore {
1461
- let admin_address = signer::address_of(admin);
1462
- setup(aptos_framework, &vector[admin_address]);
1463
- setup_vesting_contract(admin, &vector[@1, @2], &vector[1], @5, 0);
1464
- }
1465
-
1466
- #[test(aptos_framework = @0x1, admin = @0x123)]
1467
- #[expected_failure(abort_code = 0x60001, location = aptos_framework::aptos_account)]
1468
- public entry fun test_create_vesting_contract_with_missing_withdrawal_account_should_fail(
1469
- aptos_framework: &signer,
1470
- admin: &signer,
1471
- ) acquires AdminStore {
1472
- let admin_address = signer::address_of(admin);
1473
- setup(aptos_framework, &vector[admin_address]);
1474
- setup_vesting_contract(admin, &vector[@1, @2], &vector[1], @11, 0);
1475
- }
1476
-
1477
- #[test(aptos_framework = @0x1, admin = @0x123)]
1478
- #[expected_failure(abort_code = 0x60002, location = aptos_framework::aptos_account)]
1479
- public entry fun test_create_vesting_contract_with_unregistered_withdrawal_account_should_fail(
1480
- aptos_framework: &signer,
1481
- admin: &signer,
1482
- ) acquires AdminStore {
1483
- let admin_address = signer::address_of(admin);
1484
- setup(aptos_framework, &vector[admin_address]);
1485
- create_account_for_test(@11);
1486
- setup_vesting_contract(admin, &vector[@1, @2], &vector[1], @11, 0);
1487
- }
1488
-
1489
- #[test(aptos_framework = @0x1)]
1490
- #[expected_failure(abort_code = 0x10002, location = Self)]
1491
- public entry fun test_create_empty_vesting_schedule_should_fail(aptos_framework: &signer) {
1492
- setup(aptos_framework, &vector[]);
1493
- create_vesting_schedule(vector[], 1, 1);
1494
- }
1495
-
1496
- #[test(aptos_framework = @0x1)]
1497
- #[expected_failure(abort_code = 0x10003, location = Self)]
1498
- public entry fun test_create_vesting_schedule_with_zero_period_duration_should_fail(aptos_framework: &signer) {
1499
- setup(aptos_framework, &vector[]);
1500
- create_vesting_schedule(vector[fixed_point32::create_from_rational(1, 1)], 1, 0);
1501
- }
1502
-
1503
- #[test(aptos_framework = @0x1, admin = @0x123)]
1504
- #[expected_failure(abort_code = 0x10006, location = Self)]
1505
- public entry fun test_create_vesting_schedule_with_invalid_vesting_start_should_fail(aptos_framework: &signer) {
1506
- setup(aptos_framework, &vector[]);
1507
- timestamp::update_global_time_for_test_secs(1000);
1508
- create_vesting_schedule(
1509
- vector[fixed_point32::create_from_rational(1, 1)],
1510
- 900,
1511
- 1);
1512
- }
1513
-
1514
- #[test(aptos_framework = @0x1, admin = @0x123, shareholder = @0x234)]
1515
- public entry fun test_vest_twice_should_not_double_count(
1516
- aptos_framework: &signer,
1517
- admin: &signer,
1518
- shareholder: &signer,
1519
- ) acquires AdminStore, VestingContract {
1520
- let admin_address = signer::address_of(admin);
1521
- let shareholder_address = signer::address_of(shareholder);
1522
- setup(aptos_framework, &vector[admin_address, shareholder_address]);
1523
- let contract_address = setup_vesting_contract(
1524
- admin, &vector[shareholder_address], &vector[GRANT_AMOUNT], admin_address, 0);
1525
-
1526
- // Operator needs to join the validator set for the stake pool to earn rewards.
1527
- let stake_pool_address = stake_pool_address(contract_address);
1528
- let (_sk, pk, pop) = stake::generate_identity();
1529
- stake::join_validator_set_for_test(&pk, &pop, admin, stake_pool_address, true);
1530
-
1531
- // Fast forward to the end of the first period. vest() should now unlock 3/48 of the tokens.
1532
- timestamp::update_global_time_for_test_secs(vesting_start_secs(contract_address) + VESTING_PERIOD);
1533
- vest(contract_address);
1534
- let vested_amount = fraction(GRANT_AMOUNT, 3, 48);
1535
- let remaining_grant = GRANT_AMOUNT - vested_amount;
1536
- stake::assert_stake_pool(stake_pool_address, remaining_grant, 0, 0, vested_amount);
1537
- assert!(remaining_grant(contract_address) == remaining_grant, 0);
1538
-
1539
- // Calling vest() a second time shouldn't change anything.
1540
- vest(contract_address);
1541
- stake::assert_stake_pool(stake_pool_address, remaining_grant, 0, 0, vested_amount);
1542
- assert!(remaining_grant(contract_address) == remaining_grant, 0);
1543
- }
1544
-
1545
- #[test(aptos_framework = @0x1, admin = @0x123, shareholder = @0x234)]
1546
- public entry fun test_unlock_rewards_twice_should_not_double_count(
1547
- aptos_framework: &signer,
1548
- admin: &signer,
1549
- shareholder: &signer,
1550
- ) acquires AdminStore, VestingContract {
1551
- let admin_address = signer::address_of(admin);
1552
- let shareholder_address = signer::address_of(shareholder);
1553
- setup(aptos_framework, &vector[admin_address, shareholder_address]);
1554
- let contract_address = setup_vesting_contract(
1555
- admin, &vector[shareholder_address], &vector[GRANT_AMOUNT], admin_address, 0);
1556
-
1557
- // Operator needs to join the validator set for the stake pool to earn rewards.
1558
- let stake_pool_address = stake_pool_address(contract_address);
1559
- let (_sk, pk, pop) = stake::generate_identity();
1560
- stake::join_validator_set_for_test(&pk, &pop, admin, stake_pool_address, true);
1561
-
1562
- // Stake pool earns some rewards. unlock_rewards should unlock the right amount.
1563
- stake::end_epoch();
1564
- let rewards = get_accumulated_rewards(contract_address);
1565
- unlock_rewards(contract_address);
1566
- stake::assert_stake_pool(stake_pool_address, GRANT_AMOUNT, 0, 0, rewards);
1567
- assert!(remaining_grant(contract_address) == GRANT_AMOUNT, 0);
1568
-
1569
- // Calling unlock_rewards a second time shouldn't change anything as no new rewards has accumulated.
1570
- unlock_rewards(contract_address);
1571
- stake::assert_stake_pool(stake_pool_address, GRANT_AMOUNT, 0, 0, rewards);
1572
- }
1573
-
1574
- #[test(aptos_framework = @0x1, admin = @0x123, shareholder = @0x234, operator = @0x345)]
1575
- public entry fun test_unlock_rewards_should_pay_commission_first(
1576
- aptos_framework: &signer,
1577
- admin: &signer,
1578
- shareholder: &signer,
1579
- operator: &signer,
1580
- ) acquires AdminStore, VestingContract {
1581
- let admin_address = signer::address_of(admin);
1582
- let operator_address = signer::address_of(operator);
1583
- let shareholder_address = signer::address_of(shareholder);
1584
- setup(aptos_framework, &vector[admin_address, shareholder_address, operator_address]);
1585
- let contract_address = setup_vesting_contract(
1586
- admin, &vector[shareholder_address], &vector[GRANT_AMOUNT], admin_address, 0);
1587
- assert!(operator_commission_percentage(contract_address) == 0, 0);
1588
-
1589
- // 10% commission will be paid to the operator.
1590
- update_operator(admin, contract_address, operator_address, 10);
1591
- assert!(operator_commission_percentage(contract_address) == 10, 0);
1592
-
1593
- // Operator needs to join the validator set for the stake pool to earn rewards.
1594
- let stake_pool_address = stake_pool_address(contract_address);
1595
- let (_sk, pk, pop) = stake::generate_identity();
1596
- stake::join_validator_set_for_test(&pk, &pop, operator, stake_pool_address, true);
1597
-
1598
- // Stake pool earns some rewards. unlock_rewards should unlock the right amount.
1599
- stake::end_epoch();
1600
- let accumulated_rewards = get_accumulated_rewards(contract_address);
1601
- let commission = accumulated_rewards / 10; // 10%.
1602
- let staker_rewards = accumulated_rewards - commission;
1603
- unlock_rewards(contract_address);
1604
- stake::assert_stake_pool(stake_pool_address, GRANT_AMOUNT, 0, 0, accumulated_rewards);
1605
- assert!(remaining_grant(contract_address) == GRANT_AMOUNT, 0);
1606
-
1607
- // Distribution should pay commission to operator first and remaining amount to shareholders.
1608
- stake::fast_forward_to_unlock(stake_pool_address);
1609
- stake::assert_stake_pool(
1610
- stake_pool_address,
1611
- with_rewards(GRANT_AMOUNT),
1612
- with_rewards(accumulated_rewards),
1613
- 0,
1614
- 0
1615
- );
1616
- // Operator also earns more commission from the rewards earnt on the withdrawn rewards.
1617
- let commission_on_staker_rewards = (with_rewards(staker_rewards) - staker_rewards) / 10;
1618
- staker_rewards = with_rewards(staker_rewards) - commission_on_staker_rewards;
1619
- commission = with_rewards(commission) + commission_on_staker_rewards;
1620
- distribute(contract_address);
1621
- // Rounding error leads to a dust amount of 1 transferred to the staker.
1622
- assert!(coin::balance<AptosCoin>(shareholder_address) == staker_rewards + 1, 0);
1623
- assert!(coin::balance<AptosCoin>(operator_address) == commission - 1, 1);
1624
- }
1625
-
1626
- #[test(aptos_framework = @0x1, admin = @0x123, shareholder = @0x234, operator = @0x345)]
1627
- public entry fun test_request_commission_should_not_lock_rewards_for_shareholders(
1628
- aptos_framework: &signer,
1629
- admin: &signer,
1630
- shareholder: &signer,
1631
- operator: &signer,
1632
- ) acquires AdminStore, VestingContract {
1633
- let admin_address = signer::address_of(admin);
1634
- let operator_address = signer::address_of(operator);
1635
- let shareholder_address = signer::address_of(shareholder);
1636
- setup(aptos_framework, &vector[admin_address, shareholder_address, operator_address]);
1637
- let contract_address = setup_vesting_contract(
1638
- admin, &vector[shareholder_address], &vector[GRANT_AMOUNT], admin_address, 0);
1639
- assert!(operator_commission_percentage(contract_address) == 0, 0);
1640
-
1641
- // 10% commission will be paid to the operator.
1642
- update_operator(admin, contract_address, operator_address, 10);
1643
- assert!(operator_commission_percentage(contract_address) == 10, 0);
1644
-
1645
- // Operator needs to join the validator set for the stake pool to earn rewards.
1646
- let stake_pool_address = stake_pool_address(contract_address);
1647
- let (_sk, pk, pop) = stake::generate_identity();
1648
- stake::join_validator_set_for_test(&pk, &pop, operator, stake_pool_address, true);
1649
-
1650
- // Stake pool earns some rewards.
1651
- stake::end_epoch();
1652
-
1653
- // Operator requests commission directly with staking_contract first.
1654
- let accumulated_rewards = get_accumulated_rewards(contract_address);
1655
- let commission = accumulated_rewards / 10; // 10%.
1656
- let staker_rewards = accumulated_rewards - commission;
1657
- staking_contract::request_commission(operator, contract_address, operator_address);
1658
-
1659
- // Unlock vesting rewards. This should still pay out the accumulated rewards to shareholders.
1660
- unlock_rewards(contract_address);
1661
- stake::assert_stake_pool(stake_pool_address, GRANT_AMOUNT, 0, 0, accumulated_rewards);
1662
- assert!(remaining_grant(contract_address) == GRANT_AMOUNT, 0);
1663
-
1664
- // Distribution should pay commission to operator first and remaining amount to shareholders.
1665
- stake::fast_forward_to_unlock(stake_pool_address);
1666
- stake::assert_stake_pool(
1667
- stake_pool_address,
1668
- with_rewards(GRANT_AMOUNT),
1669
- with_rewards(accumulated_rewards),
1670
- 0,
1671
- 0
1672
- );
1673
- // Operator also earns more commission from the rewards earnt on the withdrawn rewards.
1674
- let commission_on_staker_rewards = (with_rewards(staker_rewards) - staker_rewards) / 10;
1675
- staker_rewards = with_rewards(staker_rewards) - commission_on_staker_rewards;
1676
- commission = with_rewards(commission) + commission_on_staker_rewards;
1677
- distribute(contract_address);
1678
- // Rounding error leads to a dust amount of 1 transferred to the staker.
1679
- assert!(coin::balance<AptosCoin>(shareholder_address) == staker_rewards + 1, 0);
1680
- assert!(coin::balance<AptosCoin>(operator_address) == commission - 1, 1);
1681
- }
1682
-
1683
- #[test(aptos_framework = @0x1, admin = @0x123, operator = @0x345)]
1684
- public entry fun test_update_operator_with_same_commission(
1685
- aptos_framework: &signer,
1686
- admin: &signer,
1687
- operator: &signer,
1688
- ) acquires AdminStore, VestingContract {
1689
- let admin_address = signer::address_of(admin);
1690
- let operator_address = signer::address_of(operator);
1691
- setup(aptos_framework, &vector[admin_address, @11, operator_address]);
1692
- let contract_address = setup_vesting_contract(
1693
- admin, &vector[@11], &vector[GRANT_AMOUNT], admin_address, 10);
1694
-
1695
- update_operator_with_same_commission(admin, contract_address, operator_address);
1696
- assert!(operator_commission_percentage(contract_address) == 10, 0);
1697
- }
1698
-
1699
- #[test(aptos_framework = @0x1, admin = @0x123, shareholder = @0x234, operator = @0x345)]
1700
- public entry fun test_commission_percentage_change(
1701
- aptos_framework: &signer,
1702
- admin: &signer,
1703
- shareholder: &signer,
1704
- operator: &signer,
1705
- ) acquires AdminStore, VestingContract {
1706
- let admin_address = signer::address_of(admin);
1707
- let operator_address = signer::address_of(operator);
1708
- let shareholder_address = signer::address_of(shareholder);
1709
- setup(aptos_framework, &vector[admin_address, shareholder_address, operator_address]);
1710
- let contract_address = setup_vesting_contract(
1711
- admin, &vector[shareholder_address], &vector[GRANT_AMOUNT], admin_address, 0);
1712
- assert!(operator_commission_percentage(contract_address) == 0, 0);
1713
- let stake_pool_address = stake_pool_address(contract_address);
1714
-
1715
- // 10% commission will be paid to the operator.
1716
- update_operator(admin, contract_address, operator_address, 10);
1717
-
1718
- // Operator needs to join the validator set for the stake pool to earn rewards.
1719
- let (_sk, pk, pop) = stake::generate_identity();
1720
- stake::join_validator_set_for_test(&pk, &pop, operator, stake_pool_address, true);
1721
- stake::assert_stake_pool(stake_pool_address, GRANT_AMOUNT, 0, 0, 0);
1722
- assert!(get_accumulated_rewards(contract_address) == 0, 0);
1723
- assert!(remaining_grant(contract_address) == GRANT_AMOUNT, 0);
1724
-
1725
- // Stake pool earns some rewards.
1726
- stake::end_epoch();
1727
- let (_, accumulated_rewards, _) = staking_contract::staking_contract_amounts(
1728
- contract_address,
1729
- operator_address
1730
- );
1731
-
1732
- // Update commission percentage to 20%. This also immediately requests commission.
1733
- update_commission_percentage(admin, contract_address, 20);
1734
- // Assert that the operator is still the same, and the commission percentage is updated to 20%.
1735
- assert!(operator(contract_address) == operator_address, 0);
1736
- assert!(operator_commission_percentage(contract_address) == 20, 0);
1737
-
1738
- // Commission is calculated using the previous commission percentage which is 10%.
1739
- let expected_commission = accumulated_rewards / 10;
1740
-
1741
- // Stake pool earns some more rewards.
1742
- stake::end_epoch();
1743
- let (_, accumulated_rewards, _) = staking_contract::staking_contract_amounts(
1744
- contract_address,
1745
- operator_address
1746
- );
1747
-
1748
- // Request commission again.
1749
- staking_contract::request_commission(operator, contract_address, operator_address);
1750
- // The commission is calculated using the current commission percentage which is 20%.
1751
- expected_commission = with_rewards(expected_commission) + (accumulated_rewards / 5);
1752
-
1753
- // Unlocks the commission.
1754
- stake::fast_forward_to_unlock(stake_pool_address);
1755
- expected_commission = with_rewards(expected_commission);
1756
-
1757
- // Distribute the commission to the operator.
1758
- distribute(contract_address);
1759
-
1760
- // Assert that the operator receives the expected commission.
1761
- assert!(coin::balance<AptosCoin>(operator_address) == expected_commission, 1);
1762
- }
1763
-
1764
- #[test(
1765
- aptos_framework = @0x1,
1766
- admin = @0x123,
1767
- shareholder = @0x234,
1768
- operator1 = @0x345,
1769
- beneficiary = @0x456,
1770
- operator2 = @0x567
1771
- )]
1772
- public entry fun test_set_beneficiary_for_operator(
1773
- aptos_framework: &signer,
1774
- admin: &signer,
1775
- shareholder: &signer,
1776
- operator1: &signer,
1777
- beneficiary: &signer,
1778
- operator2: &signer,
1779
- ) acquires AdminStore, VestingContract {
1780
- let admin_address = signer::address_of(admin);
1781
- let operator_address1 = signer::address_of(operator1);
1782
- let operator_address2 = signer::address_of(operator2);
1783
- let shareholder_address = signer::address_of(shareholder);
1784
- let beneficiary_address = signer::address_of(beneficiary);
1785
- setup(aptos_framework, &vector[admin_address, shareholder_address, operator_address1, beneficiary_address]);
1786
- let contract_address = setup_vesting_contract(
1787
- admin, &vector[shareholder_address], &vector[GRANT_AMOUNT], admin_address, 0);
1788
- assert!(operator_commission_percentage(contract_address) == 0, 0);
1789
- let stake_pool_address = stake_pool_address(contract_address);
1790
- // 10% commission will be paid to the operator.
1791
- update_operator(admin, contract_address, operator_address1, 10);
1792
- assert!(staking_contract::beneficiary_for_operator(operator_address1) == operator_address1, 0);
1793
- set_beneficiary_for_operator(operator1, beneficiary_address);
1794
- assert!(staking_contract::beneficiary_for_operator(operator_address1) == beneficiary_address, 0);
1795
-
1796
- // Operator needs to join the validator set for the stake pool to earn rewards.
1797
- let (_sk, pk, pop) = stake::generate_identity();
1798
- stake::join_validator_set_for_test(&pk, &pop, operator1, stake_pool_address, true);
1799
- stake::assert_stake_pool(stake_pool_address, GRANT_AMOUNT, 0, 0, 0);
1800
- assert!(get_accumulated_rewards(contract_address) == 0, 0);
1801
- assert!(remaining_grant(contract_address) == GRANT_AMOUNT, 0);
1802
-
1803
- // Stake pool earns some rewards.
1804
- stake::end_epoch();
1805
- let (_, accumulated_rewards, _) = staking_contract::staking_contract_amounts(contract_address,
1806
- operator_address1
1807
- );
1808
- // Commission is calculated using the previous commission percentage which is 10%.
1809
- let expected_commission = accumulated_rewards / 10;
1810
-
1811
- // Request commission.
1812
- staking_contract::request_commission(operator1, contract_address, operator_address1);
1813
- // Unlocks the commission.
1814
- stake::fast_forward_to_unlock(stake_pool_address);
1815
- expected_commission = with_rewards(expected_commission);
1816
-
1817
- // Distribute the commission to the operator.
1818
- distribute(contract_address);
1819
-
1820
- // Assert that the beneficiary receives the expected commission.
1821
- assert!(coin::balance<AptosCoin>(operator_address1) == 0, 1);
1822
- assert!(coin::balance<AptosCoin>(beneficiary_address) == expected_commission, 1);
1823
- let old_beneficiay_balance = coin::balance<AptosCoin>(beneficiary_address);
1824
-
1825
- // switch operator to operator2. The rewards should go to operator2 not to the beneficiay of operator1.
1826
- update_operator(admin, contract_address, operator_address2, 10);
1827
-
1828
- stake::end_epoch();
1829
- let (_, accumulated_rewards, _) = staking_contract::staking_contract_amounts(contract_address,
1830
- operator_address2
1831
- );
1832
-
1833
- let expected_commission = accumulated_rewards / 10;
1834
-
1835
- // Request commission.
1836
- staking_contract::request_commission(operator2, contract_address, operator_address2);
1837
- // Unlocks the commission.
1838
- stake::fast_forward_to_unlock(stake_pool_address);
1839
- expected_commission = with_rewards(expected_commission);
1840
-
1841
- // Distribute the commission to the operator.
1842
- distribute(contract_address);
1843
-
1844
- // Assert that the rewards go to operator2, and the balance of the operator1's beneficiay remains the same.
1845
- assert!(coin::balance<AptosCoin>(operator_address2) >= expected_commission, 1);
1846
- assert!(coin::balance<AptosCoin>(beneficiary_address) == old_beneficiay_balance, 1);
1847
- }
1848
-
1849
- #[test(aptos_framework = @0x1, admin = @0x123, shareholder = @0x234)]
1850
- #[expected_failure(abort_code = 0x30008, location = Self)]
1851
- public entry fun test_cannot_unlock_rewards_after_contract_is_terminated(
1852
- aptos_framework: &signer,
1853
- admin: &signer,
1854
- shareholder: &signer,
1855
- ) acquires AdminStore, VestingContract {
1856
- let admin_address = signer::address_of(admin);
1857
- let shareholder_address = signer::address_of(shareholder);
1858
- setup(aptos_framework, &vector[admin_address, shareholder_address]);
1859
- let contract_address = setup_vesting_contract(
1860
- admin, &vector[shareholder_address], &vector[GRANT_AMOUNT], admin_address, 0);
1861
-
1862
- // Immediately terminate. Calling unlock_rewards should now fail.
1863
- terminate_vesting_contract(admin, contract_address);
1864
- unlock_rewards(contract_address);
1865
- }
1866
-
1867
- #[test(aptos_framework = @0x1, admin = @0x123, shareholder = @0x234)]
1868
- public entry fun test_vesting_contract_with_zero_vestings(
1869
- aptos_framework: &signer,
1870
- admin: &signer,
1871
- shareholder: &signer,
1872
- ) acquires AdminStore, VestingContract {
1873
- let admin_address = signer::address_of(admin);
1874
- let shareholder_address = signer::address_of(shareholder);
1875
- setup(aptos_framework, &vector[admin_address, shareholder_address]);
1876
- let contract_address = setup_vesting_contract_with_schedule(
1877
- admin,
1878
- &vector[shareholder_address],
1879
- &vector[GRANT_AMOUNT],
1880
- admin_address,
1881
- 0,
1882
- &vector[0, 3, 0, 2],
1883
- 48,
1884
- );
1885
- let stake_pool_address = stake_pool_address(contract_address);
1886
-
1887
- // First vest() should unlock 0 according to schedule.
1888
- timestamp::update_global_time_for_test_secs(vesting_start_secs(contract_address) + VESTING_PERIOD);
1889
- vest(contract_address);
1890
- stake::assert_stake_pool(stake_pool_address, GRANT_AMOUNT, 0, 0, 0);
1891
- assert!(remaining_grant(contract_address) == GRANT_AMOUNT, 0);
1892
-
1893
- // Next period should vest 3/48.
1894
- timestamp::fast_forward_seconds(VESTING_PERIOD);
1895
- vest(contract_address);
1896
- let vested_amount = fraction(GRANT_AMOUNT, 3, 48);
1897
- let remaining_grant = GRANT_AMOUNT - vested_amount;
1898
- stake::assert_stake_pool(stake_pool_address, remaining_grant, 0, 0, vested_amount);
1899
- assert!(remaining_grant(contract_address) == remaining_grant, 0);
1900
-
1901
- timestamp::fast_forward_seconds(VESTING_PERIOD);
1902
- // Distribute the previous vested amount.
1903
- distribute(contract_address);
1904
- // Next period should vest 0 again.
1905
- vest(contract_address);
1906
- stake::assert_stake_pool(stake_pool_address, remaining_grant, 0, 0, 0);
1907
- assert!(remaining_grant(contract_address) == remaining_grant, 0);
1908
-
1909
- // Next period should vest 2/48.
1910
- timestamp::fast_forward_seconds(VESTING_PERIOD);
1911
- vest(contract_address);
1912
- let vested_amount = fraction(GRANT_AMOUNT, 2, 48);
1913
- remaining_grant = remaining_grant - vested_amount;
1914
- stake::assert_stake_pool(stake_pool_address, remaining_grant, 0, 0, vested_amount);
1915
- assert!(remaining_grant(contract_address) == remaining_grant, 0);
1916
- }
1917
-
1918
- #[test(aptos_framework = @0x1, admin = @0x123, shareholder = @0x234)]
1919
- public entry fun test_last_vest_should_distribute_remaining_amount(
1920
- aptos_framework: &signer,
1921
- admin: &signer,
1922
- shareholder: &signer,
1923
- ) acquires AdminStore, VestingContract {
1924
- let admin_address = signer::address_of(admin);
1925
- let shareholder_address = signer::address_of(shareholder);
1926
- setup(aptos_framework, &vector[admin_address, shareholder_address]);
1927
- let contract_address = setup_vesting_contract_with_schedule(
1928
- admin,
1929
- &vector[shareholder_address],
1930
- &vector[GRANT_AMOUNT],
1931
- admin_address,
1932
- 0,
1933
- // First vest = 3/4 but last vest should only be for the remaining 1/4.
1934
- &vector[3],
1935
- 4,
1936
- );
1937
- let stake_pool_address = stake_pool_address(contract_address);
1938
-
1939
- // First vest is 3/48
1940
- timestamp::update_global_time_for_test_secs(vesting_start_secs(contract_address) + VESTING_PERIOD);
1941
- vest(contract_address);
1942
- let vested_amount = fraction(GRANT_AMOUNT, 3, 4);
1943
- let remaining_grant = GRANT_AMOUNT - vested_amount;
1944
- stake::assert_stake_pool(stake_pool_address, remaining_grant, 0, 0, vested_amount);
1945
- assert!(remaining_grant(contract_address) == remaining_grant, 0);
1946
-
1947
- timestamp::fast_forward_seconds(VESTING_PERIOD);
1948
- // Distribute the previous vested amount.
1949
- distribute(contract_address);
1950
- // Last vest should be the remaining amount (1/4).
1951
- vest(contract_address);
1952
- let vested_amount = remaining_grant;
1953
- remaining_grant = 0;
1954
- stake::assert_stake_pool(stake_pool_address, remaining_grant, 0, 0, vested_amount);
1955
- assert!(remaining_grant(contract_address) == remaining_grant, 0);
1956
- }
1957
-
1958
- #[test(aptos_framework = @0x1, admin = @0x123, shareholder = @0x234)]
1959
- #[expected_failure(abort_code = 0x30008, location = Self)]
1960
- public entry fun test_cannot_vest_after_contract_is_terminated(
1961
- aptos_framework: &signer,
1962
- admin: &signer,
1963
- shareholder: &signer,
1964
- ) acquires AdminStore, VestingContract {
1965
- let admin_address = signer::address_of(admin);
1966
- let shareholder_address = signer::address_of(shareholder);
1967
- setup(aptos_framework, &vector[admin_address, shareholder_address]);
1968
- let contract_address = setup_vesting_contract(
1969
- admin, &vector[shareholder_address], &vector[GRANT_AMOUNT], admin_address, 0);
1970
-
1971
- // Immediately terminate. Calling vest should now fail.
1972
- terminate_vesting_contract(admin, contract_address);
1973
- vest(contract_address);
1974
- }
1975
-
1976
- #[test(aptos_framework = @0x1, admin = @0x123, shareholder = @0x234)]
1977
- #[expected_failure(abort_code = 0x30008, location = Self)]
1978
- public entry fun test_cannot_terminate_twice(
1979
- aptos_framework: &signer,
1980
- admin: &signer,
1981
- shareholder: &signer,
1982
- ) acquires AdminStore, VestingContract {
1983
- let admin_address = signer::address_of(admin);
1984
- let shareholder_address = signer::address_of(shareholder);
1985
- setup(aptos_framework, &vector[admin_address, shareholder_address]);
1986
- let contract_address = setup_vesting_contract(
1987
- admin, &vector[shareholder_address], &vector[GRANT_AMOUNT], admin_address, 0);
1988
-
1989
- // Call terminate_vesting_contract twice should fail.
1990
- terminate_vesting_contract(admin, contract_address);
1991
- terminate_vesting_contract(admin, contract_address);
1992
- }
1993
-
1994
- #[test(aptos_framework = @0x1, admin = @0x123, shareholder = @0x234)]
1995
- #[expected_failure(abort_code = 0x30009, location = Self)]
1996
- public entry fun test_cannot_call_admin_withdraw_if_contract_is_not_terminated(
1997
- aptos_framework: &signer,
1998
- admin: &signer,
1999
- shareholder: &signer,
2000
- ) acquires AdminStore, VestingContract {
2001
- let admin_address = signer::address_of(admin);
2002
- let shareholder_address = signer::address_of(shareholder);
2003
- setup(aptos_framework, &vector[admin_address, shareholder_address]);
2004
- let contract_address = setup_vesting_contract(
2005
- admin, &vector[shareholder_address], &vector[GRANT_AMOUNT], admin_address, 0);
2006
-
2007
- // Calling admin_withdraw should fail as contract has not been terminated.
2008
- admin_withdraw(admin, contract_address);
2009
- }
2010
-
2011
- #[test(aptos_framework = @0x1, admin = @0x123)]
2012
- #[expected_failure(abort_code = 0x60001, location = aptos_framework::aptos_account)]
2013
- public entry fun test_set_beneficiary_with_missing_account_should_fail(
2014
- aptos_framework: &signer,
2015
- admin: &signer,
2016
- ) acquires AdminStore, VestingContract {
2017
- let admin_address = signer::address_of(admin);
2018
- setup(aptos_framework, &vector[admin_address]);
2019
- let contract_address = setup_vesting_contract(
2020
- admin, &vector[@1, @2], &vector[GRANT_AMOUNT, GRANT_AMOUNT], admin_address, 0);
2021
- set_beneficiary(admin, contract_address, @1, @11);
2022
- }
2023
-
2024
- #[test(aptos_framework = @0x1, admin = @0x123)]
2025
- #[expected_failure(abort_code = 0x60002, location = aptos_framework::aptos_account)]
2026
- public entry fun test_set_beneficiary_with_unregistered_account_should_fail(
2027
- aptos_framework: &signer,
2028
- admin: &signer,
2029
- ) acquires AdminStore, VestingContract {
2030
- let admin_address = signer::address_of(admin);
2031
- setup(aptos_framework, &vector[admin_address]);
2032
- let contract_address = setup_vesting_contract(
2033
- admin, &vector[@1, @2], &vector[GRANT_AMOUNT, GRANT_AMOUNT], admin_address, 0);
2034
- create_account_for_test(@11);
2035
- set_beneficiary(admin, contract_address, @1, @11);
2036
- }
2037
-
2038
- #[test(aptos_framework = @0x1, admin = @0x123)]
2039
- public entry fun test_set_beneficiary_should_send_distribution(
2040
- aptos_framework: &signer,
2041
- admin: &signer,
2042
- ) acquires AdminStore, VestingContract {
2043
- let admin_address = signer::address_of(admin);
2044
- setup(aptos_framework, &vector[admin_address, @11]);
2045
- let contract_address = setup_vesting_contract(
2046
- admin, &vector[@1], &vector[GRANT_AMOUNT], admin_address, 0);
2047
- set_beneficiary(admin, contract_address, @1, @11);
2048
- assert!(beneficiary(contract_address, @1) == @11, 0);
2049
-
2050
- // Fast forward to the end of the first period. vest() should now unlock 3/48 of the tokens.
2051
- timestamp::update_global_time_for_test_secs(vesting_start_secs(contract_address) + VESTING_PERIOD);
2052
- vest(contract_address);
2053
-
2054
- // Distribution should go to the beneficiary account.
2055
- stake::end_epoch();
2056
- // No rewards as validator never joined the validator set.
2057
- let vested_amount = fraction(GRANT_AMOUNT, 3, 48);
2058
- distribute(contract_address);
2059
- let balance = coin::balance<AptosCoin>(@11);
2060
- assert!(balance == vested_amount, balance);
2061
- }
2062
-
2063
- #[test(aptos_framework = @0x1, admin = @0x123)]
2064
- public entry fun test_set_management_role(
2065
- aptos_framework: &signer,
2066
- admin: &signer,
2067
- ) acquires AdminStore, VestingAccountManagement, VestingContract {
2068
- let admin_address = signer::address_of(admin);
2069
- setup(aptos_framework, &vector[admin_address]);
2070
- let contract_address = setup_vesting_contract(
2071
- admin, &vector[@11], &vector[GRANT_AMOUNT], admin_address, 0);
2072
- let role = utf8(b"RANDOM");
2073
- set_management_role(admin, contract_address, role, @12);
2074
- assert!(get_role_holder(contract_address, role) == @12, 0);
2075
- set_management_role(admin, contract_address, role, @13);
2076
- assert!(get_role_holder(contract_address, role) == @13, 0);
2077
- }
2078
-
2079
- #[test(aptos_framework = @0x1, admin = @0x123)]
2080
- public entry fun test_reset_beneficiary(
2081
- aptos_framework: &signer,
2082
- admin: &signer,
2083
- ) acquires AdminStore, VestingAccountManagement, VestingContract {
2084
- let admin_address = signer::address_of(admin);
2085
- setup(aptos_framework, &vector[admin_address, @11, @12]);
2086
- let contract_address = setup_vesting_contract(
2087
- admin, &vector[@11], &vector[GRANT_AMOUNT], admin_address, 0);
2088
- set_beneficiary(admin, contract_address, @11, @12);
2089
- assert!(beneficiary(contract_address, @11) == @12, 0);
2090
-
2091
- // Fast forward to the end of the first period. vest() should now unlock 3/48 of the tokens.
2092
- timestamp::update_global_time_for_test_secs(vesting_start_secs(contract_address) + VESTING_PERIOD);
2093
- vest(contract_address);
2094
-
2095
- // Reset the beneficiary.
2096
- reset_beneficiary(admin, contract_address, @11);
2097
-
2098
- // Distribution should go to the original account.
2099
- stake::end_epoch();
2100
- // No rewards as validator never joined the validator set.
2101
- let vested_amount = fraction(GRANT_AMOUNT, 3, 48);
2102
- distribute(contract_address);
2103
- assert!(coin::balance<AptosCoin>(@11) == vested_amount, 0);
2104
- assert!(coin::balance<AptosCoin>(@12) == 0, 1);
2105
- }
2106
-
2107
- #[test(aptos_framework = @0x1, admin = @0x123, resetter = @0x234)]
2108
- public entry fun test_reset_beneficiary_with_resetter_role(
2109
- aptos_framework: &signer,
2110
- admin: &signer,
2111
- resetter: &signer,
2112
- ) acquires AdminStore, VestingAccountManagement, VestingContract {
2113
- let admin_address = signer::address_of(admin);
2114
- setup(aptos_framework, &vector[admin_address, @11, @12]);
2115
- let contract_address = setup_vesting_contract(
2116
- admin, &vector[@11], &vector[GRANT_AMOUNT], admin_address, 0);
2117
- set_beneficiary(admin, contract_address, @11, @12);
2118
- assert!(beneficiary(contract_address, @11) == @12, 0);
2119
-
2120
- // Reset the beneficiary with the resetter role.
2121
- let resetter_address = signer::address_of(resetter);
2122
- set_beneficiary_resetter(admin, contract_address, resetter_address);
2123
- assert!(simple_map::length(&borrow_global<VestingAccountManagement>(contract_address).roles) == 1, 0);
2124
- reset_beneficiary(resetter, contract_address, @11);
2125
- assert!(beneficiary(contract_address, @11) == @11, 0);
2126
- }
2127
-
2128
- #[test(aptos_framework = @0x1, admin = @0x123, resetter = @0x234, random = @0x345)]
2129
- #[expected_failure(abort_code = 0x5000F, location = Self)]
2130
- public entry fun test_reset_beneficiary_with_unauthorized(
2131
- aptos_framework: &signer,
2132
- admin: &signer,
2133
- resetter: &signer,
2134
- random: &signer,
2135
- ) acquires AdminStore, VestingAccountManagement, VestingContract {
2136
- let admin_address = signer::address_of(admin);
2137
- setup(aptos_framework, &vector[admin_address, @11]);
2138
- let contract_address = setup_vesting_contract(
2139
- admin, &vector[@11], &vector[GRANT_AMOUNT], admin_address, 0);
2140
-
2141
- // Reset the beneficiary with a random account. This should failed.
2142
- set_beneficiary_resetter(admin, contract_address, signer::address_of(resetter));
2143
- reset_beneficiary(random, contract_address, @11);
2144
- }
2145
-
2146
- #[test(aptos_framework = @0x1, admin = @0x123, resetter = @0x234, random = @0x345)]
2147
- public entry fun test_shareholder(
2148
- aptos_framework: &signer,
2149
- admin: &signer,
2150
- ) acquires AdminStore, VestingContract {
2151
- let admin_address = signer::address_of(admin);
2152
- setup(aptos_framework, &vector[admin_address, @11, @12]);
2153
- let contract_address = setup_vesting_contract(
2154
- admin, &vector[@11], &vector[GRANT_AMOUNT], admin_address, 0);
2155
-
2156
- // Confirm that the lookup returns the same address when a shareholder is
2157
- // passed for which there is no beneficiary.
2158
- assert!(shareholder(contract_address, @11) == @11, 0);
2159
-
2160
- // Set a beneficiary for @11.
2161
- set_beneficiary(admin, contract_address, @11, @12);
2162
- assert!(beneficiary(contract_address, @11) == @12, 0);
2163
-
2164
- // Confirm that lookup from beneficiary to shareholder works when a beneficiary
2165
- // is set.
2166
- assert!(shareholder(contract_address, @12) == @11, 0);
2167
-
2168
- // Confirm that it returns 0x0 when the address is not in the map.
2169
- assert!(shareholder(contract_address, @33) == @0x0, 0);
2170
- }
2171
-
2172
- #[test_only]
2173
- fun get_accumulated_rewards(contract_address: address): u64 acquires VestingContract {
2174
- let vesting_contract = borrow_global<VestingContract>(contract_address);
2175
- let (active_stake, _, _, _) = stake::get_stake(vesting_contract.staking.pool_address);
2176
- active_stake - vesting_contract.remaining_grant
2177
- }
2178
-
2179
- #[test_only]
2180
- fun fraction(total: u64, numerator: u64, denominator: u64): u64 {
2181
- fixed_point32::multiply_u64(total, fixed_point32::create_from_rational(numerator, denominator))
2182
- }
2183
- }