-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[move] account primitives to track abandoned property (#324)
Co-authored-by: 0o-de-lally <[email protected]>
- Loading branch information
1 parent
362ea77
commit ecb415d
Showing
3 changed files
with
33 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
framework/libra-framework/sources/ol_sources/activity.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
/// Maintains the version number for the blockchain. | ||
module ol_framework::activity { | ||
use std::signer; | ||
|
||
friend diem_framework::transaction_validation; | ||
|
||
struct Activity has key { | ||
timestamp: u64, | ||
} | ||
|
||
fun lazy_initialize(user: &signer, timestamp: u64) { | ||
if (!exists<Activity>(signer::address_of(user))) { | ||
move_to<Activity>(user, Activity { | ||
timestamp | ||
}) | ||
} | ||
} | ||
public(friend) fun increment(user: &signer, timestamp: u64) acquires Activity { | ||
lazy_initialize(user, timestamp); | ||
|
||
let state = borrow_global_mut<Activity>(signer::address_of(user)); | ||
state.timestamp = timestamp; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters