sov-modules-api 0.3.0

Defines the interface of the Sovereign SDK module system
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use jsonrpsee::types::ErrorObjectOwned;

use crate::{Context, Digest, Spec};

pub fn generate_address<C: Context>(key: &str) -> <C as Spec>::Address {
    let hash: [u8; 32] = <C as Spec>::Hasher::digest(key.as_bytes()).into();
    C::Address::from(hash)
}

pub fn to_jsonrpsee_error_object(err: impl ToString, message: &str) -> ErrorObjectOwned {
    ErrorObjectOwned::owned(
        jsonrpsee::types::error::UNKNOWN_ERROR_CODE,
        message,
        Some(err.to_string()),
    )
}