Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add consts for near, yocto, and tgas #640

Merged
merged 5 commits into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified examples/callback-results/res/callback_results.wasm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified examples/fungible-token/res/defi.wasm
Binary file not shown.
Binary file modified examples/fungible-token/res/fungible_token.wasm
Binary file not shown.
Binary file modified examples/non-fungible-token/res/approval_receiver.wasm
Binary file not shown.
Binary file modified examples/non-fungible-token/res/non_fungible_token.wasm
Binary file not shown.
Binary file modified examples/non-fungible-token/res/token_receiver.wasm
Binary file not shown.
5 changes: 5 additions & 0 deletions near-sdk/src/types/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
#[repr(transparent)]
pub struct Gas(pub u64);

impl Gas {
/// One Tera gas, which is 10^12 gas units.
pub const ONE_TERA: Gas = Gas(1_000_000_000_000);
}

impl Serialize for Gas {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
Expand Down
6 changes: 6 additions & 0 deletions near-sdk/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ pub type Timestamp = u64;

/// Raw type for 32 bytes of the hash.
pub type CryptoHash = [u8; 32];

/// Balance of one Yocto NEAR, which is the smallest denomination. This value is 10^-24 of one NEAR.
pub const ONE_YOCTO: u128 = 1;

/// Balance of one NEAR, which is 10^24 Yocto NEAR.
pub const ONE_NEAR: u128 = 1_000_000_000_000_000_000_000_000;