├── .gitignore ├── Move.toml ├── Move.lock ├── LICENSE └── sources ├── birthday_bot.move └── birthday_bot_test.move /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | storage/ 3 | .idea/ 4 | .aptos/ -------------------------------------------------------------------------------- /Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "birthday_bot" 3 | version = "1.0.0" 4 | 5 | [addresses] 6 | std = "0x1" 7 | overmind = "0x1337" 8 | 9 | [dependencies] 10 | MoveStdlib = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/move-stdlib", rev = "093b497d1267715a222845aad4fd3ca59da90e8d" } 11 | AptosFramework = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-framework", rev = "093b497d1267715a222845aad4fd3ca59da90e8d" } -------------------------------------------------------------------------------- /Move.lock: -------------------------------------------------------------------------------- 1 | # @generated by Move, please check-in and do not edit manually. 2 | 3 | [move] 4 | version = 0 5 | 6 | dependencies = [ 7 | { name = "AptosFramework" }, 8 | { name = "MoveStdlib" }, 9 | ] 10 | 11 | [[move.package]] 12 | name = "AptosFramework" 13 | source = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "093b497d1267715a222845aad4fd3ca59da90e8d", subdir = "aptos-move/framework/aptos-framework" } 14 | 15 | dependencies = [ 16 | { name = "AptosStdlib" }, 17 | { name = "MoveStdlib" }, 18 | ] 19 | 20 | [[move.package]] 21 | name = "AptosStdlib" 22 | source = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "093b497d1267715a222845aad4fd3ca59da90e8d", subdir = "aptos-move/framework/aptos-stdlib" } 23 | 24 | dependencies = [ 25 | { name = "MoveStdlib" }, 26 | ] 27 | 28 | [[move.package]] 29 | name = "MoveStdlib" 30 | source = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "093b497d1267715a222845aad4fd3ca59da90e8d", subdir = "aptos-move/framework/move-stdlib" } 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Overmind 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /sources/birthday_bot.move: -------------------------------------------------------------------------------- 1 | module overmind::birthday_bot { 2 | use aptos_std::table::Table; 3 | use std::signer; 4 | // use std::error; 5 | use aptos_framework::account; 6 | use std::vector; 7 | use aptos_framework::coin; 8 | use aptos_framework::aptos_coin::AptosCoin; 9 | use aptos_std::table; 10 | use aptos_framework::timestamp; 11 | 12 | // 13 | // Errors 14 | // 15 | const ERROR_DISTRIBUTION_STORE_EXIST: u64 = 0; 16 | const ERROR_DISTRIBUTION_STORE_DOES_NOT_EXIST: u64 = 1; 17 | const ERROR_LENGTHS_NOT_EQUAL: u64 = 2; 18 | const ERROR_BIRTHDAY_GIFT_DOES_NOT_EXIST: u64 = 3; 19 | const ERROR_BIRTHDAY_TIMESTAMP_SECONDS_HAS_NOT_PASSED: u64 = 4; 20 | 21 | // 22 | // Data structures 23 | // 24 | struct BirthdayGift has drop, store { 25 | amount: u64, 26 | birthday_timestamp_seconds: u64, 27 | } 28 | 29 | struct DistributionStore has key { 30 | birthday_gifts: Table, 31 | signer_capability: account::SignerCapability, 32 | } 33 | 34 | // 35 | // Assert functions 36 | // 37 | public fun assert_distribution_store_exists( 38 | account_address: address, 39 | ) { 40 | // TODO: assert that `DistributionStore` exists 41 | assert!(exists(account_address), ERROR_DISTRIBUTION_STORE_DOES_NOT_EXIST); 42 | } 43 | 44 | public fun assert_distribution_store_does_not_exist( 45 | account_address: address, 46 | ) { 47 | // TODO: assert that `DistributionStore` does not exist 48 | assert!(!exists(account_address), ERROR_DISTRIBUTION_STORE_EXIST); 49 | } 50 | 51 | public fun assert_lengths_are_equal( 52 | addresses: vector
, 53 | amounts: vector, 54 | timestamps: vector 55 | ) { 56 | // TODO: assert that the lengths of `addresses`, `amounts`, and `timestamps` are all equal 57 | let address_len = vector::length(&addresses); 58 | let amounts_len = vector::length(&amounts); 59 | let timestamp_len = vector::length(×tamps); 60 | 61 | assert!(address_len == amounts_len, ERROR_LENGTHS_NOT_EQUAL); 62 | assert!(address_len == timestamp_len, ERROR_LENGTHS_NOT_EQUAL); 63 | } 64 | 65 | public fun assert_birthday_gift_exists( 66 | distribution_address: address, 67 | _address: address, 68 | ) acquires DistributionStore { 69 | // TODO: assert that `birthday_gifts` exists 70 | let store = borrow_global(distribution_address); 71 | let addr = _address; 72 | assert!(table::contains(&store.birthday_gifts, addr), ERROR_BIRTHDAY_GIFT_DOES_NOT_EXIST); 73 | } 74 | 75 | public fun assert_birthday_timestamp_seconds_has_passed( 76 | distribution_address: address, 77 | address_: address, 78 | ) acquires DistributionStore { 79 | // TODO: assert that the current timestamp is greater than or equal to `birthday_timestamp_seconds` 80 | let store = borrow_global(distribution_address); 81 | // assert_birthday_gift_exists(distribution_address, address_); 82 | let birthdayGift = table::borrow(&store.birthday_gifts, address_); 83 | assert!(timestamp::now_seconds() >= birthdayGift.birthday_timestamp_seconds, ERROR_BIRTHDAY_TIMESTAMP_SECONDS_HAS_NOT_PASSED); 84 | } 85 | 86 | fun get_resource_account_by_cap(addr : address) : signer acquires DistributionStore{ 87 | let store = borrow_global(addr); 88 | account::create_signer_with_capability(&store.signer_capability) 89 | } 90 | 91 | // 92 | // Entry functions 93 | // 94 | /** 95 | * Initializes birthday gift distribution contract 96 | * @param account - account signer executing the function 97 | * @param addresses - list of addresses that can claim their birthday gifts 98 | * @param amounts - list of amounts for birthday gifts 99 | * @param birthday_timestamps - list of birthday timestamps in seconds (only claimable after this timestamp has passed) 100 | **/ 101 | public entry fun initialize_distribution( 102 | account: &signer, 103 | addresses: vector
, 104 | amounts: vector, 105 | birthday_timestamps: vector 106 | ) { 107 | // TODO: check `DistributionStore` does not exist 108 | assert_distribution_store_does_not_exist(signer::address_of(account)); 109 | // TODO: check all lengths of `addresses`, `amounts`, and `birthday_timestamps` are equal 110 | assert_lengths_are_equal(addresses, amounts, birthday_timestamps); 111 | // TODO: create resource account 112 | let (resource_signer, signer_cap) = account::create_resource_account(account, x"01"); 113 | // TODO: register Aptos coin to resource account 114 | coin::register(&resource_signer); 115 | // TODO: loop through the lists and push items to birthday_gifts table 116 | let vlen = vector::length(&addresses); 117 | let idx = 0; 118 | let birthday_gifts = table::new(); 119 | let total = 0; 120 | while (idx < vlen) { 121 | let address_ = vector::borrow(&addresses, idx); 122 | let amount = vector::borrow(&amounts, idx); 123 | let birthday_timestamp = vector::borrow(&birthday_timestamps, idx); 124 | total = total + *amount; 125 | table::add(&mut birthday_gifts, *address_, BirthdayGift { 126 | amount: *amount, 127 | birthday_timestamp_seconds: *birthday_timestamp 128 | }); 129 | idx = idx + 1; 130 | }; 131 | // TODO: transfer the sum of all items in `amounts` from initiator to resource account 132 | coin::transfer(account, signer::address_of(&resource_signer), total); 133 | // TODO: move_to resource `DistributionStore` to account signer 134 | move_to(account, DistributionStore{ 135 | birthday_gifts : birthday_gifts, 136 | signer_capability : signer_cap 137 | }) 138 | } 139 | 140 | /** 141 | * Add birthday gift to `DistributionStore.birthday_gifts` 142 | * @param account - account signer executing the function 143 | * @param address - address that can claim the birthday gift 144 | * @param amount - amount for the birthday gift 145 | * @param birthday_timestamp_seconds - birthday timestamp in seconds (only claimable after this timestamp has passed) 146 | **/ 147 | public entry fun add_birthday_gift( 148 | account: &signer, 149 | address: address, 150 | amount: u64, 151 | birthday_timestamp_seconds: u64 152 | ) acquires DistributionStore { 153 | // TODO: check that the distribution store exists 154 | let account_addr = signer::address_of(account); 155 | assert_distribution_store_exists(account_addr); 156 | // TODO: set new birthday gift to new `amount` and `birthday_timestamp_seconds` (birthday_gift already exists, sum `amounts` and override the `birthday_timestamp_seconds` 157 | let resource_signer = get_resource_account_by_cap(account_addr); 158 | let store = borrow_global_mut(account_addr); 159 | table::add(&mut store.birthday_gifts, address, BirthdayGift { 160 | amount: amount, 161 | birthday_timestamp_seconds: birthday_timestamp_seconds 162 | }); 163 | // TODO: transfer the `amount` from initiator to resource account 164 | coin::transfer(account, signer::address_of(&resource_signer), amount); 165 | } 166 | 167 | /** 168 | * Remove birthday gift from `DistributionStore.birthday_gifts` 169 | * @param account - account signer executing the function 170 | * @param address - `birthday_gifts` address 171 | **/ 172 | public entry fun remove_birthday_gift( 173 | account: &signer, 174 | address: address, 175 | ) acquires DistributionStore { 176 | // TODO: check that the distribution store exists 177 | assert_distribution_store_exists(signer::address_of(account)); 178 | // TODO: if `birthday_gifts` exists, remove `birthday_gift` from table and transfer `amount` from resource account to initiator 179 | assert_birthday_gift_exists(signer::address_of(account), address); 180 | let resource_signer = get_resource_account_by_cap(signer::address_of(account)); 181 | let store = borrow_global_mut(signer::address_of(account)); 182 | let birday_gift = table::borrow(&store.birthday_gifts, address); 183 | coin::transfer(&resource_signer, signer::address_of(account), birday_gift.amount); 184 | table::remove(&mut store.birthday_gifts, address); 185 | 186 | } 187 | 188 | /** 189 | * Claim birthday gift from `DistributionStore.birthday_gifts` 190 | * @param account - account signer executing the function 191 | * @param distribution_address - distribution contract address 192 | **/ 193 | public entry fun claim_birthday_gift( 194 | account: &signer, 195 | distribution_address: address, 196 | ) acquires DistributionStore { 197 | // TODO: check that the distribution store exists 198 | assert_distribution_store_exists(distribution_address); 199 | // TODO: check that the `birthday_gift` exists 200 | assert_birthday_gift_exists(distribution_address, signer::address_of(account)); 201 | // TODO: check that the `birthday_timestamp_seconds` has passed 202 | assert_birthday_timestamp_seconds_has_passed(distribution_address, signer::address_of(account)); 203 | // TODO: remove `birthday_gift` from table and transfer `amount` from resource account to initiator 204 | let resource_signer = get_resource_account_by_cap(distribution_address); 205 | let store = borrow_global_mut(distribution_address); 206 | let birday_gift = table::borrow(&store.birthday_gifts, signer::address_of(account)); 207 | coin::transfer(&resource_signer, signer::address_of(account), birday_gift.amount); 208 | table::remove(&mut store.birthday_gifts, signer::address_of(account)); 209 | } 210 | } 211 | -------------------------------------------------------------------------------- /sources/birthday_bot_test.move: -------------------------------------------------------------------------------- 1 | module overmind::birthday_bot_test { 2 | #[test_only] 3 | use aptos_framework::account; 4 | #[test_only] 5 | use aptos_framework::aptos_coin::{Self, AptosCoin}; 6 | #[test_only] 7 | use aptos_framework::coin; 8 | #[test_only] 9 | use aptos_framework::timestamp; 10 | #[test_only] 11 | use overmind::birthday_bot::{initialize_distribution, assert_distribution_store_exists, add_birthday_gift, remove_birthday_gift, claim_birthday_gift}; 12 | #[test_only] 13 | use std::signer; 14 | #[test_only] 15 | use std::vector; 16 | 17 | // 18 | // Test functions 19 | // Searching == test_[function_name]_[success || failture]_[reason] 20 | // 21 | #[test(aptos_framework = @0x1, account = @0xCAFE, test_one = @0x12, test_two = @0x34)] 22 | fun test_initialize_distribution_success( 23 | aptos_framework: &signer, 24 | account: &signer, 25 | test_one: &signer, 26 | test_two: &signer 27 | ) { 28 | timestamp::set_time_has_started_for_testing(aptos_framework); 29 | let (burn_cap, mint_cap) = aptos_framework::aptos_coin::initialize_for_test(aptos_framework); 30 | 31 | let aptos_framework_address = signer::address_of(aptos_framework); 32 | let account_address = signer::address_of(account); 33 | let test_one_address = signer::address_of(test_one); 34 | let test_two_address = signer::address_of(test_two); 35 | 36 | account::create_account_for_test(aptos_framework_address); 37 | account::create_account_for_test(account_address); 38 | 39 | coin::register(account); 40 | aptos_coin::mint(aptos_framework, account_address, 3000000); 41 | 42 | let addresses: vector
= vector::empty(); 43 | let amounts: vector = vector::empty(); 44 | let birthday_timestamps: vector = vector::empty(); 45 | 46 | vector::push_back(&mut addresses, test_one_address); 47 | vector::push_back(&mut addresses, test_two_address); 48 | 49 | vector::push_back(&mut amounts, 1000000); 50 | vector::push_back(&mut amounts, 2000000); 51 | 52 | vector::push_back(&mut birthday_timestamps, timestamp::now_seconds()); 53 | vector::push_back(&mut birthday_timestamps, timestamp::now_seconds()); 54 | 55 | initialize_distribution( 56 | account, 57 | addresses, 58 | amounts, 59 | birthday_timestamps 60 | ); 61 | 62 | assert_distribution_store_exists(account_address); 63 | assert!(coin::balance(account_address) == 0, 0); 64 | 65 | coin::destroy_burn_cap(burn_cap); 66 | coin::destroy_mint_cap(mint_cap); 67 | } 68 | 69 | #[test(aptos_framework = @0x1, account = @0xCAFE, test_one = @0x12, test_two = @0x34)] 70 | #[expected_failure(abort_code = 0, location = overmind::birthday_bot)] 71 | fun test_initialize_distribution_failure_distribution_store_already_exists( 72 | aptos_framework: &signer, 73 | account: &signer, 74 | test_one: &signer, 75 | test_two: &signer 76 | ) { 77 | timestamp::set_time_has_started_for_testing(aptos_framework); 78 | let (burn_cap, mint_cap) = aptos_framework::aptos_coin::initialize_for_test(aptos_framework); 79 | 80 | let aptos_framework_address = signer::address_of(aptos_framework); 81 | let account_address = signer::address_of(account); 82 | let test_one_address = signer::address_of(test_one); 83 | let test_two_address = signer::address_of(test_two); 84 | 85 | account::create_account_for_test(aptos_framework_address); 86 | account::create_account_for_test(account_address); 87 | 88 | coin::register(account); 89 | aptos_coin::mint(aptos_framework, account_address, 3000000); 90 | 91 | let addresses: vector
= vector::empty(); 92 | let amounts: vector = vector::empty(); 93 | let birthday_timestamps: vector = vector::empty(); 94 | 95 | vector::push_back(&mut addresses, test_one_address); 96 | vector::push_back(&mut addresses, test_two_address); 97 | 98 | vector::push_back(&mut amounts, 1000000); 99 | vector::push_back(&mut amounts, 2000000); 100 | 101 | vector::push_back(&mut birthday_timestamps, timestamp::now_seconds()); 102 | vector::push_back(&mut birthday_timestamps, timestamp::now_seconds()); 103 | 104 | initialize_distribution( 105 | account, 106 | addresses, 107 | amounts, 108 | birthday_timestamps 109 | ); 110 | 111 | initialize_distribution( 112 | account, 113 | addresses, 114 | amounts, 115 | birthday_timestamps 116 | ); 117 | 118 | coin::destroy_burn_cap(burn_cap); 119 | coin::destroy_mint_cap(mint_cap); 120 | } 121 | 122 | #[test(aptos_framework = @0x1, account = @0xCAFE, test_one = @0x12, test_two = @0x34)] 123 | #[expected_failure(abort_code = 2, location = overmind::birthday_bot)] 124 | fun test_initialize_distribution_failure_not_equal_lengths( 125 | aptos_framework: &signer, 126 | account: &signer, 127 | test_one: &signer, 128 | test_two: &signer 129 | ) { 130 | timestamp::set_time_has_started_for_testing(aptos_framework); 131 | let (burn_cap, mint_cap) = aptos_framework::aptos_coin::initialize_for_test(aptos_framework); 132 | 133 | let aptos_framework_address = signer::address_of(aptos_framework); 134 | let account_address = signer::address_of(account); 135 | let test_one_address = signer::address_of(test_one); 136 | let test_two_address = signer::address_of(test_two); 137 | 138 | account::create_account_for_test(aptos_framework_address); 139 | account::create_account_for_test(account_address); 140 | 141 | coin::register(account); 142 | aptos_coin::mint(aptos_framework, account_address, 3000000); 143 | 144 | let addresses: vector
= vector::empty(); 145 | let amounts: vector = vector::empty(); 146 | let birthday_timestamps: vector = vector::empty(); 147 | 148 | vector::push_back(&mut addresses, test_one_address); 149 | vector::push_back(&mut addresses, test_two_address); 150 | 151 | vector::push_back(&mut amounts, 1000000); 152 | vector::push_back(&mut amounts, 2000000); 153 | 154 | vector::push_back(&mut birthday_timestamps, timestamp::now_seconds()); 155 | vector::push_back(&mut birthday_timestamps, timestamp::now_seconds()); 156 | vector::push_back(&mut birthday_timestamps, timestamp::now_seconds()); 157 | 158 | initialize_distribution( 159 | account, 160 | addresses, 161 | amounts, 162 | birthday_timestamps 163 | ); 164 | 165 | coin::destroy_burn_cap(burn_cap); 166 | coin::destroy_mint_cap(mint_cap); 167 | } 168 | 169 | #[test(aptos_framework = @0x1, account = @0xCAFE, test_one = @0x12, test_two = @0x34, test_three = @0x56)] 170 | fun test_add_birthday_gift_success( 171 | aptos_framework: &signer, 172 | account: &signer, 173 | test_one: &signer, 174 | test_two: &signer, 175 | test_three: &signer 176 | ) { 177 | timestamp::set_time_has_started_for_testing(aptos_framework); 178 | let (burn_cap, mint_cap) = aptos_framework::aptos_coin::initialize_for_test(aptos_framework); 179 | 180 | let aptos_framework_address = signer::address_of(aptos_framework); 181 | let account_address = signer::address_of(account); 182 | let test_one_address = signer::address_of(test_one); 183 | let test_two_address = signer::address_of(test_two); 184 | let test_three_address = signer::address_of(test_three); 185 | 186 | account::create_account_for_test(aptos_framework_address); 187 | account::create_account_for_test(account_address); 188 | 189 | coin::register(account); 190 | aptos_coin::mint(aptos_framework, account_address, 4000000); 191 | 192 | let addresses: vector
= vector::empty(); 193 | let amounts: vector = vector::empty(); 194 | let birthday_timestamps: vector = vector::empty(); 195 | 196 | vector::push_back(&mut addresses, test_one_address); 197 | vector::push_back(&mut addresses, test_two_address); 198 | 199 | vector::push_back(&mut amounts, 1000000); 200 | vector::push_back(&mut amounts, 2000000); 201 | 202 | vector::push_back(&mut birthday_timestamps, timestamp::now_seconds()); 203 | vector::push_back(&mut birthday_timestamps, timestamp::now_seconds()); 204 | 205 | initialize_distribution( 206 | account, 207 | addresses, 208 | amounts, 209 | birthday_timestamps 210 | ); 211 | 212 | add_birthday_gift(account, test_three_address, 1000000, timestamp::now_seconds()); 213 | 214 | assert!(coin::balance(account_address) == 0, 0); 215 | 216 | coin::destroy_burn_cap(burn_cap); 217 | coin::destroy_mint_cap(mint_cap); 218 | } 219 | 220 | #[test(aptos_framework = @0x1, account = @0xCAFE, test_one = @0x12, test_two = @0x34)] 221 | fun test_remove_birthday_gift_success( 222 | aptos_framework: &signer, 223 | account: &signer, 224 | test_one: &signer, 225 | test_two: &signer, 226 | ) { 227 | timestamp::set_time_has_started_for_testing(aptos_framework); 228 | let (burn_cap, mint_cap) = aptos_framework::aptos_coin::initialize_for_test(aptos_framework); 229 | 230 | let aptos_framework_address = signer::address_of(aptos_framework); 231 | let account_address = signer::address_of(account); 232 | let test_one_address = signer::address_of(test_one); 233 | let test_two_address = signer::address_of(test_two); 234 | 235 | account::create_account_for_test(aptos_framework_address); 236 | account::create_account_for_test(account_address); 237 | 238 | coin::register(account); 239 | aptos_coin::mint(aptos_framework, account_address, 3000000); 240 | 241 | let addresses: vector
= vector::empty(); 242 | let amounts: vector = vector::empty(); 243 | let birthday_timestamps: vector = vector::empty(); 244 | 245 | vector::push_back(&mut addresses, test_one_address); 246 | vector::push_back(&mut addresses, test_two_address); 247 | 248 | vector::push_back(&mut amounts, 1000000); 249 | vector::push_back(&mut amounts, 2000000); 250 | 251 | vector::push_back(&mut birthday_timestamps, timestamp::now_seconds()); 252 | vector::push_back(&mut birthday_timestamps, timestamp::now_seconds()); 253 | 254 | initialize_distribution( 255 | account, 256 | addresses, 257 | amounts, 258 | birthday_timestamps 259 | ); 260 | 261 | remove_birthday_gift(account, test_two_address); 262 | 263 | assert!(coin::balance(account_address) == 2000000, 0); 264 | 265 | coin::destroy_burn_cap(burn_cap); 266 | coin::destroy_mint_cap(mint_cap); 267 | } 268 | 269 | #[test(aptos_framework = @0x1, account = @0xCAFE, test_one = @0x12, test_two = @0x34)] 270 | fun test_claim_birthday_gift_success( 271 | aptos_framework: &signer, 272 | account: &signer, 273 | test_one: &signer, 274 | test_two: &signer, 275 | ) { 276 | timestamp::set_time_has_started_for_testing(aptos_framework); 277 | let (burn_cap, mint_cap) = aptos_framework::aptos_coin::initialize_for_test(aptos_framework); 278 | 279 | let aptos_framework_address = signer::address_of(aptos_framework); 280 | let account_address = signer::address_of(account); 281 | let test_one_address = signer::address_of(test_one); 282 | let test_two_address = signer::address_of(test_two); 283 | 284 | account::create_account_for_test(aptos_framework_address); 285 | account::create_account_for_test(account_address); 286 | account::create_account_for_test(test_one_address); 287 | 288 | coin::register(account); 289 | coin::register(test_one); 290 | aptos_coin::mint(aptos_framework, account_address, 3000000); 291 | 292 | 293 | let addresses: vector
= vector::empty(); 294 | let amounts: vector = vector::empty(); 295 | let birthday_timestamps: vector = vector::empty(); 296 | 297 | vector::push_back(&mut addresses, test_one_address); 298 | vector::push_back(&mut addresses, test_two_address); 299 | 300 | vector::push_back(&mut amounts, 1000000); 301 | vector::push_back(&mut amounts, 2000000); 302 | 303 | vector::push_back(&mut birthday_timestamps, timestamp::now_seconds()); 304 | vector::push_back(&mut birthday_timestamps, timestamp::now_seconds()); 305 | 306 | initialize_distribution( 307 | account, 308 | addresses, 309 | amounts, 310 | birthday_timestamps 311 | ); 312 | 313 | timestamp::fast_forward_seconds(1); 314 | 315 | claim_birthday_gift(test_one, account_address); 316 | 317 | assert!(coin::balance(test_one_address) == 1000000, 0); 318 | 319 | coin::destroy_burn_cap(burn_cap); 320 | coin::destroy_mint_cap(mint_cap); 321 | } 322 | } --------------------------------------------------------------------------------