Hello, thanks for the guide. I’m trying to follow it.
Update the Frontend Code
Navigate to the frontend code where the useActorMethod
hook is used. This is typically found in a component file. Change the method from "greet"
to "deposit_principal"
:
const { call, data, error, loading } = useActorMethod("deposit_principal")
more has to be done here than shown - the service has to be updated. I’m trying this:
from the JS service:
import createReActor from "@re-actor/core"
import { canisterId, hello, idlFactory, createActor } from "declarations/hello"
export const {
initialize,
useActorMethod
} = createReActor(() =>
createActor(canisterId, {
agentOptions: {
host: process.env.NEXT_PUBLIC_IC_HOST
}
})
)
and for the rust .did file - this did not regenerate when I ran deploy and the tutorial did not say to update this:
cat hello/hello.did
service : { deposit_principal : (text) -> (text) query }
now when I run the code I get a “method deposit_principal not found” error in the UI, I think because the JS does not have the signature:
grep -nr "greet" ./src/
./src/declarations/hello/hello.did.d.ts:5:export interface _SERVICE { 'greet' : ActorMethod<[string], string> }
./src/declarations/hello/hello.did.js:2: return IDL.Service({ 'greet' : IDL.Func([IDL.Text], [IDL.Text], ['query']) });
./src/components/Greeting.tsx:11: // functionName: "greet",
as here it still has the greet reference, even after doing yarn build and npm run deploy hello.
How do I compile the rust did into JS?