1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
use std::borrow::Cow;
use crate::error::InterpreterError;
use crate::storage::InterpreterStorage;
use fuel_asm::Word;
use fuel_storage::{Mappable, MerkleRoot, MerkleRootStorage, StorageInspect, StorageMutate};
use fuel_types::{Address, Bytes32, ContractId};
#[derive(Debug, Default, Clone, Copy)]
pub struct PredicateStorage;
impl<Type: Mappable> StorageInspect<Type> for PredicateStorage {
type Error = InterpreterError;
fn get(&self, _key: &Type::Key) -> Result<Option<Cow<'_, Type::GetValue>>, InterpreterError> {
Err(InterpreterError::PredicateFailure)
}
fn contains_key(&self, _key: &Type::Key) -> Result<bool, InterpreterError> {
Err(InterpreterError::PredicateFailure)
}
}
impl<Type: Mappable> StorageMutate<Type> for PredicateStorage {
fn insert(
&mut self,
_key: &Type::Key,
_value: &Type::SetValue,
) -> Result<Option<Type::GetValue>, InterpreterError> {
Err(InterpreterError::PredicateFailure)
}
fn remove(&mut self, _key: &Type::Key) -> Result<Option<Type::GetValue>, InterpreterError> {
Err(InterpreterError::PredicateFailure)
}
}
impl<Key, Type: Mappable> MerkleRootStorage<Key, Type> for PredicateStorage {
fn root(&mut self, _parent: &Key) -> Result<MerkleRoot, InterpreterError> {
Err(InterpreterError::PredicateFailure)
}
}
impl InterpreterStorage for PredicateStorage {
type DataError = InterpreterError;
fn block_height(&self) -> Result<u32, InterpreterError> {
Err(InterpreterError::PredicateFailure)
}
fn timestamp(&self, _height: u32) -> Result<Word, Self::DataError> {
Err(InterpreterError::PredicateFailure)
}
fn block_hash(&self, _block_height: u32) -> Result<Bytes32, InterpreterError> {
Err(InterpreterError::PredicateFailure)
}
fn coinbase(&self) -> Result<Address, InterpreterError> {
Err(InterpreterError::PredicateFailure)
}
fn merkle_contract_state_range(
&self,
_id: &ContractId,
_start_key: &Bytes32,
_range: Word,
) -> Result<Vec<Option<Cow<Bytes32>>>, Self::DataError> {
Err(InterpreterError::PredicateFailure)
}
fn merkle_contract_state_insert_range(
&mut self,
_contract: &ContractId,
_start_key: &Bytes32,
_values: &[Bytes32],
) -> Result<Option<()>, Self::DataError> {
Err(InterpreterError::PredicateFailure)
}
fn merkle_contract_state_remove_range(
&mut self,
_contract: &ContractId,
_start_key: &Bytes32,
_range: Word,
) -> Result<Option<()>, Self::DataError> {
Err(InterpreterError::PredicateFailure)
}
}