Skip to content

Commit e700a88

Browse files
committed
feat: utilize metadata key selector in KeyValueAddress reader
Signed-off-by: quacumque <[email protected]>
1 parent 1740745 commit e700a88

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

trigger/src/lib.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,18 +207,17 @@ impl<T> KeyValueAddress<T> {
207207

208208
impl<T: DeserializeOwned> KeyValueAddress<T> {
209209
fn read(&self, host: &Iroha) -> Result<Option<T>> {
210-
let meta = match &self.entity {
210+
let maybe_json = match &self.entity {
211211
KeyValueAddressEntity::Trigger(id) => host
212212
.query(FindTriggers)
213213
.filter_with(|x| x.id.eq(id.to_owned()))
214-
.select_with(|x| x.action.metadata)
215-
.execute_single(),
214+
.select_with(|x| x.action.metadata.key(self.key.to_owned()))
215+
.execute_single_opt(),
216216
_ => todo!(),
217217
}
218218
.map_err(|err| anyhow!("failed query: {err}"))?;
219219

220-
let maybe_value = meta
221-
.get(&self.key)
220+
let maybe_value = maybe_json
222221
.map(|json| json.try_into_any().with_context(|| "cannot deserialize"))
223222
.transpose()?;
224223

0 commit comments

Comments
 (0)