mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 00:41:08 +00:00
use externalities for chain_id
This commit is contained in:
@@ -137,7 +137,7 @@ impl_function_executor!(this: FunctionExecutor<'e, E>,
|
||||
} else { 0 }
|
||||
},
|
||||
ext_chain_id() -> u64 => {
|
||||
42u64
|
||||
this.ext.chain_id()
|
||||
}
|
||||
=> <'e, E: Externalities + 'e>
|
||||
);
|
||||
|
||||
@@ -70,8 +70,9 @@ pub fn set_storage(_key: &[u8], _value: &[u8]) {
|
||||
|
||||
/// The current relay chain identifier.
|
||||
pub fn chain_id() -> u64 {
|
||||
// TODO: fetch from Externalities.
|
||||
42u64
|
||||
ext::with(|holder|
|
||||
holder.ext.chain_id()
|
||||
).unwrap_or(0)
|
||||
}
|
||||
|
||||
/// Execute the given closure with global function available whose functionality routes into the
|
||||
@@ -105,6 +106,8 @@ mod tests {
|
||||
fn set_storage(&mut self, key: Vec<u8>, value: Vec<u8>) {
|
||||
self.storage.insert(key, value);
|
||||
}
|
||||
|
||||
fn chain_id(&self) -> u64 { 42 }
|
||||
}
|
||||
|
||||
macro_rules! map {
|
||||
|
||||
@@ -73,4 +73,8 @@ impl<'a, B: 'a> Externalities for Ext<'a, B>
|
||||
fn set_storage(&mut self, key: Vec<u8>, value: Vec<u8>) {
|
||||
self.overlay.set_storage(key, value);
|
||||
}
|
||||
|
||||
fn chain_id(&self) -> u64 {
|
||||
42
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +130,10 @@ pub trait Externalities {
|
||||
/// Set storage of current contract being called (effective immediately).
|
||||
fn set_storage(&mut self, key: Vec<u8>, value: Vec<u8>);
|
||||
|
||||
/// Get the current set of authorities.
|
||||
/// Get the identity of the chain.
|
||||
fn chain_id(&self) -> u64 { 42 } // TODO: remove implementation and fix resulting errors.
|
||||
|
||||
/// Get the current set of authorities from storage.
|
||||
fn authorities(&self) -> Result<Vec<&[u8]>, Self::Error> {
|
||||
(0..self.storage(b"con\0aut\0len")?.into_iter()
|
||||
.rev()
|
||||
|
||||
Reference in New Issue
Block a user