This repository has been archived by the owner on Oct 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rashad Alston
authored and
Rashad Alston
committed
Aug 15, 2023
1 parent
76429ab
commit 83a25cd
Showing
8 changed files
with
93 additions
and
225 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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 |
---|---|---|
@@ -1,8 +1,17 @@ | ||
/// Utility functions for Fuel indexers. | ||
use fuel_indexer_plugin::prelude::sha256_digest; | ||
use fuel_indexer_plugin::types::SizedAsciiString; | ||
use fuel_indexer_plugin::types::{Bytes32, SizedAsciiString}; | ||
|
||
/// Returns the SHA256 hex digest of the input as a `SizedAsciiString`. | ||
pub fn id(data: impl AsRef<[u8]>) -> SizedAsciiString<64> { | ||
SizedAsciiString::<64>::new(sha256_digest(&data)).unwrap() | ||
} | ||
|
||
/// Converts a given input into a `Bytes32` object by taking the first 32 bytes | ||
/// of the input's SHA256 hex digest. | ||
pub fn bytes32(data: impl AsRef<[u8]>) -> Bytes32 { | ||
let digest = sha256_digest(&data); | ||
let mut result = [0u8; 32]; | ||
result.copy_from_slice(&digest.as_bytes()[0..32]); | ||
Bytes32::from(result) | ||
} |