fvm-std 1.0.0

tool for user to write contract which will be run in hyperchain with rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use alloc::string::String;
use crate::types::H256;

pub fn encode_topic(topic: String) -> H256 {
    let mut data: [u8; 32] = [0; 32];
    let mut topic_data = topic.as_bytes();
    if topic_data.len() > 32 {
        topic_data = &topic_data[topic_data.len() - 32..]
    }
    data[32 - topic_data.len()..32].clone_from_slice(topic_data);
    return H256::new(data);
}