agent-rs icon indicating copy to clipboard operation
agent-rs copied to clipboard

I can’t add rust agent to my wasn?

Open aliscie opened this issue 2 years ago • 2 comments

When I add

[dependencies]
ic-agent = "0.20.0"

To Cargo.toml I got this error

Consider changing their names to be unique or compiling them separately.
This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.

error[E0583]: file not found for module `sys`
   --> /Users/apple/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.7/src/lib.rs:124:1
    |
124 | mod sys;
    | ^^^^^^^^
    |
    = help: to create the module `sys`, create file "/Users/apple/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.7/src/sys.rs" or "/Users/apple/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.7/src/sys/mod.rs"

I tride older versions but nothing

aliscie avatar Sep 27 '22 20:09 aliscie

Correct. The agent is for client-side code (and for browsers, js-sys support has not been added yet). For canisters you would use ic_cdk::call, and for browsers you would use agent-js.

adamspofford-dfinity avatar Sep 28 '22 18:09 adamspofford-dfinity

I tried using it but what is the ArgumentEncoder??

async move {
        let greeting = call(principal, "greet", ("Ali")).await.unwrap();
    };

error

27  |         let greeting = call(principal, "greet", ("Ali")).await.unwrap();
    |                        ----                     ^^^^^^^ the trait `ArgumentEncoder` is not implemented for `&str`

aliscie avatar Oct 02 '22 07:10 aliscie

Add a comma: ("Ali",)

Otherwise ("Ali") is the same thing as writing "Ali".

adamspofford-dfinity avatar Dec 01 '22 23:12 adamspofford-dfinity

Wanted to clarify, does this mean that agent-rs won't work for a Rust application that's compiled to WASM and runs in the browser?

hafezrouzati avatar Mar 08 '23 23:03 hafezrouzati

Correct. This is a feature in our backlog, but for now, if you wanted to interact with the IC from browser wasm, your best bet is agent-js through wasm_bindgen.

adamspofford-dfinity avatar Mar 09 '23 22:03 adamspofford-dfinity

Closing as the stated issue is intended behavior.

adamspofford-dfinity avatar Mar 09 '23 22:03 adamspofford-dfinity