So, i have reconstructed my smart contract because I have ran into many errors when using the test network. So I followed along with the example code for creating a smart contract and when I use the conversion of Contractimpl I get an error. I tried all sort of ideas to fix it from adding different dependancies to changing code and moving it around, so any helpful advice would be nice.
#Error with using #[contractimpl]
12 messages · Page 1 of 1 (latest)
this is my lib.rs
this is my cargo.toml
the error I get is, error[E0277]: the trait bound EventGuard: TryFromVal<Env, RawVal> is not satisfied
--> src\lib.rs:32:1
|
32 | #[contractimpl]
| ^^^^^^^^^^^^^^^ the trait TryFromVal<Env, RawVal> is not implemented for EventGuard
|
= help: the following other types implement trait TryFromVal<E, V>:
<() as TryFromVal<E, [RawVal; 0]>>
<() as TryFromVal<E, [RawVal; 0]>>
<(T0, T1) as TryFromVal<E, RawVal>>
<(T0, T1) as TryFromVal<E, [RawVal; N]>>
<(T0, T1, T2) as TryFromVal<E, RawVal>>
<(T0, T1, T2) as TryFromVal<E, [RawVal; N]>>
<(T0, T1, T2, T3) as TryFromVal<E, RawVal>>
<(T0, T1, T2, T3) as TryFromVal<E, [RawVal; N]>>
and 304 others
= note: this error originates in the attribute macro soroban_sdk::contractclient (in Nightly builds, run with -Z macro-backtrace for more info)
For more information about this error, try rustc --explain E0277.
so i looked up TryFromVal and it doesn't event seem to exist in contractimpl or i must be changing a prive function in the that dependency, any helpful advice would be nice because I really want to get this going.
I wish this error was clearer, but I don't think we can improve it due to limitations in macros.
The type EventGuard must have a #[contracttype] attribute macro on it, for the type to be usable as an argument, or return value, of a contract function.
I think if you make this change, it should fix it:
@@ -12,6 +12,7 @@ use soroban_sdk::contractclient;
* EventGuard class that holds information pertaining
* to the event.
*/
+#[contracttype]
#[derive(Debug)]
pub struct EventGuard {
/// Name of event
I think that fixed the issue thanks @patent jetty , can I ask why I needed to put that?