Skip to content

Commit

Permalink
pending manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
ra0x3 committed Oct 23, 2023
1 parent b25ad2f commit 4f65d8c
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/fuel-indexer-macros/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use fuel_abi_types::abi::program::{
use fuel_indexer_lib::{
constants::*,
graphql::{list_field_type_name, types::IdCol, ParsedGraphQLSchema},
manifest::Predicates,
};
use fuel_indexer_types::{type_id, FUEL_TYPES_NAMESPACE};
use fuels_code_gen::utils::Source;
Expand Down
34 changes: 27 additions & 7 deletions packages/fuel-indexer-macros/src/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,9 +722,8 @@ fn process_fn_items(
let _p = PredicateEntity::from(p.to_owned()).get_or_create();
});

let verifiable_predicates = inputs.iter().filter(|i| {
let verifiable_predicates = inputs.iter().filter_map(|i| {
match i {

fuel::Input::Coin(coin) => {
let fuel::InputCoin {
utxo_id,
Expand All @@ -738,20 +737,41 @@ fn process_fn_items(

// This could potentially be an InputCoin with no predicate data
if predicate.is_empty() || predicate_data.is_empty() {
return false;
return None;
}

signaled_predicates.iter().any(|p| {
let pred = signaled_predicates.iter().find(|p| {
let utxo = p.coin_output();
utxo.to == *owner
})
});

if !pred.is_none() {
return None;
}

let result = match pred {
Some(p) => {
let pid = p.predicate_id();
let ident = predicate_configurable_ident(pid.to_string(), &manifest.predicates());
// convert predicate_data into #identConfigurable
None
}
None => None,
};

result
}
_ => {
warn!("This input type is not handled yet.");
false
None
}
}
});
}).collect::<Vec<_>>();

// let verifiable_predicate_data = verifiable_predicates.iter().map(|p| {

// let name = manifest.predicates().templates().find(|t| t.id == pid).expect("Could not find predicate in manifest").name.clone();
// });

// 1. do the verification

Expand Down
2 changes: 2 additions & 0 deletions packages/fuel-indexer-plugin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ fuel-indexer-types = { workspace = true }
futures = { version = "0.3", optional = true }
getrandom = { version = "0.2", features = ["js"] }
hex = "0.4"
proc-macro2 = "1.0"
quote = "1.0"
serde = { workspace = true }
serde_json = { workspace = true }
sha2 = { version = "0.10" }
Expand Down
23 changes: 23 additions & 0 deletions packages/fuel-indexer-plugin/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ extern crate alloc;
use alloc::vec::Vec;
use fuel_indexer_lib::{
graphql::MAX_FOREIGN_KEY_LIST_FIELDS,
manifest::Predicates,
utils::{deserialize, serialize},
WasmIndexerError,
};
Expand All @@ -11,6 +12,8 @@ use fuel_indexer_schema::{
FtColumn,
};
use fuel_indexer_types::{ffi::*, scalar::UID};
use proc_macro2::Ident;
use quote::format_ident;

pub use bincode;
pub use hex::FromHex;
Expand Down Expand Up @@ -163,3 +166,23 @@ pub fn early_exit(err_code: WasmIndexerError) -> ! {
unsafe { ff_early_exit(err_code as u32) }
unreachable!("Expected termination of WASM exetution after a call to ff_early_exit.")
}

pub fn predicate_configurable_ident(
predicate_id: String,
predicates: &Predicates,
) -> Ident {
match predicates.templates() {
Some(templates) => {
let name = templates
.iter()
.find(|t| t.id == predicate_id)
.expect("No templates matching ID.")
.name
.clone();
format_ident! { "{}Configurables", name }
}
None => {
panic!("No templates found in predicates.")
}
}
}

0 comments on commit 4f65d8c

Please sign in to comment.