MCPcopy Create free account
hub / github.com/cowprotocol/services / generate_binding

Function generate_binding

contracts/src/codegen.rs:374–407  ·  view source on GitHub ↗
(instance: &mut SolMacroGen, all_derives: bool)

Source from the content-addressed store, hash-verified

372}
373
374fn generate_binding(instance: &mut SolMacroGen, all_derives: bool) -> Result<()> {
375 let input = instance
376 .get_sol_input()
377 .map_err(|err| anyhow::anyhow!("{:?}", err))?
378 .normalize_json()
379 .map_err(|err| anyhow::anyhow!("{:?}", err))?;
380 let SolInput {
381 attrs: _,
382 path: _,
383 kind,
384 } = input;
385
386 let tokens = match kind {
387 SolInputKind::Sol(mut file) => {
388 let sol_attr: syn::Attribute = if all_derives {
389 syn::parse_quote! {
390 #[sol(rpc, alloy_sol_types = alloy_sol_types, alloy_contract =
391 alloy_contract, all_derives = true)]
392 }
393 } else {
394 syn::parse_quote! {
395 #[sol(rpc, alloy_sol_types = alloy_sol_types, alloy_contract =
396 alloy_contract)]
397 }
398 };
399 file.attrs.push(sol_attr);
400 expand(file)?
401 }
402 _ => unreachable!(),
403 };
404
405 instance.expansion = Some(tokens);
406 Ok(())
407}
408
409struct NetworkArm(u64, (String, Option<u64>));
410

Callers 1

generate_codeMethod · 0.85

Calls 1

get_sol_inputMethod · 0.80

Tested by

no test coverage detected