mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 18:11:10 +00:00
6f27489378
* Support custom clients. * Simplify trait bounds. * Plain and double map storage support. * Simplify more trait bounds. * Add proc macro. * Add Call, Event and Store traits. * Update proc-macros. * Add with_system for proc-macro. * proc-macro: test: support signature and extra fields. * proc-macro: test: support sharing state accross steps. * proc-macro: test: fetch state sequentially. * Elide lifetimes. * Add test for plain storage. * Run rustfmt.
80 lines
2.0 KiB
Rust
80 lines
2.0 KiB
Rust
// Copyright 2019 Parity Technologies (UK) Ltd.
|
|
// This file is part of substrate-subxt.
|
|
//
|
|
// subxt is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// subxt is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with substrate-subxt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
//! Implements support for built-in runtime modules.
|
|
|
|
use crate::{
|
|
events::{
|
|
EventsDecoder,
|
|
EventsError,
|
|
},
|
|
metadata::{
|
|
Metadata,
|
|
MetadataError,
|
|
},
|
|
};
|
|
use codec::{
|
|
Decode,
|
|
Encode,
|
|
};
|
|
use sp_core::storage::StorageKey;
|
|
|
|
pub mod balances;
|
|
pub mod contracts;
|
|
pub mod system;
|
|
|
|
/// Store trait.
|
|
pub trait Store<T>: Encode {
|
|
/// Module name.
|
|
const MODULE: &'static str;
|
|
/// Field name.
|
|
const FIELD: &'static str;
|
|
/// Return type.
|
|
type Returns: Decode;
|
|
/// Returns the `StorageKey`.
|
|
fn key(&self, metadata: &Metadata) -> Result<StorageKey, MetadataError>;
|
|
/// Returns the default value.
|
|
fn default(
|
|
&self,
|
|
metadata: &Metadata,
|
|
) -> Result<Option<Self::Returns>, MetadataError> {
|
|
Ok(metadata
|
|
.module(Self::MODULE)?
|
|
.storage(Self::FIELD)?
|
|
.default())
|
|
}
|
|
}
|
|
|
|
/// Call trait.
|
|
pub trait Call<T>: Encode {
|
|
/// Module name.
|
|
const MODULE: &'static str;
|
|
/// Function name.
|
|
const FUNCTION: &'static str;
|
|
/// Load event decoder.
|
|
fn events_decoder(_decoder: &mut EventsDecoder<T>) -> Result<(), EventsError> {
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
/// Event trait.
|
|
pub trait Event<T>: Decode {
|
|
/// Module name.
|
|
const MODULE: &'static str;
|
|
/// Event name.
|
|
const EVENT: &'static str;
|
|
}
|