Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arrudagates/substate
100% no-std/wasm compatible Substrate storage key generator
https://github.com/arrudagates/substate
hacktoberfest
Last synced: about 1 month ago
JSON representation
100% no-std/wasm compatible Substrate storage key generator
- Host: GitHub
- URL: https://github.com/arrudagates/substate
- Owner: arrudagates
- License: gpl-3.0
- Created: 2021-10-08T20:58:33.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2021-10-16T16:18:05.000Z (about 3 years ago)
- Last Synced: 2024-01-25T04:52:44.181Z (11 months ago)
- Topics: hacktoberfest
- Language: Rust
- Homepage:
- Size: 23.4 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-substrate - Substate - 100% no-std/wasm compatible Substrate storage key generator library for Rust. (Tools)
README
# Substate
100% no-std/wasm compatible Substrate storage key generatorA simple macro is all you need to generate keys, check usage below.
```rust
// Storage Value
storage_key!("Session", "Validators");
// -> 0xcec5070d609dd3497f72bde07fc96ba088dcde934c658227ee1dfafcd6e16903// Storage Map
storage_key!(
"Staking",
"ErasRewardPoints",
(StorageHasher::Twox64Concat, 10)
);
// -> 0x5f3e4907f716ac89b6347d15ececedca80cc6574281671b299c1727d7ac68cabef8763d79d01484e0c000000// Storage Double Map
storage_key!(
"ImOnline",
"AuthoredBlocks",
(StorageHasher::Twox64Concat, 68),
(StorageHasher::Twox64Concat, address_to_accountid("esqyGXvN7eezFoGtXAiLvXNnai2KFWkt7VfWwywHNBdwb8dUh").unwrap().0)
);
// -> 0x2b06af9719ac64d755623cda8ddd9b94b1c371ded9e9c565e89ba783c4d5f5f94e9f0caa17b4771b4b000000e669931fb1d70de1e63bad33d41d23e049d4f9efea39e4f44426b3f82104800ef6a9f29fbaa18667
```Also comes with a set of string to AccountId and AccountId to string functions in the utils module, because the implementation in sp_core requires std
```rust
let (accountid: AccountId32, format: Ss58AddressFormat) = address_to_accountid("esqyGXvN7eezFoGtXAiLvXNnai2KFWkt7VfWwywHNBdwb8dUh").unwrap();let account: String = accountid_to_address(accountid, format);
```## Credit
The helper functions used in this library were adapted from [Substrate](https://github.com/paritytech/substrate) and [substrate-api-client](https://github.com/scs/substrate-api-client) to work on a no-std/wasm environment and used inside the main macro