-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from dfinance/add-missing-tests
add missing tests for current_time and script docstrings
- Loading branch information
Showing
3 changed files
with
86 additions
and
24 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
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
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,18 @@ | ||
address 0x1 { | ||
module Time { | ||
// A singleton resource holding the current Unix time in seconds | ||
resource struct CurrentTimestamp { | ||
seconds: u64, | ||
} | ||
|
||
// Get the timestamp representing `now` in seconds. | ||
public fun now(): u64 acquires CurrentTimestamp { | ||
borrow_global<CurrentTimestamp>(0x1).seconds | ||
} | ||
|
||
// Helper function to determine if the blockchain is at genesis state. | ||
public fun is_genesis(): bool { | ||
!exists<Self::CurrentTimestamp>(0x1) | ||
} | ||
} | ||
} |