and is the latency the same as calling an update function?
I’m asking this because i dont want to implement certified variables for my big map
and is the latency the same as calling an update function?
I’m asking this because i dont want to implement certified variables for my big map
In frontend js, how to call a query function as an update?
Assuming you’re referring to calling a function with AgentJS, you have to manually (or via a script) edit the JavaScript declaration files to remove the keyword 'query'.
// IDL file with query support
return IDL.Service({
count_assets: IDL.Func([IDL.Text, ListParams], [IDL.Nat64], ['query']),
// => IDL file for update
return IDL.Service({
count_assets: IDL.Func([IDL.Text, ListParams], [IDL.Nat64], []),
In other words, you have to duplicate the factory declarations: one for query, one for update.
Then use the modified factory for your actor.
For example:
import { idlFactory as idlFactoryUpdate } from '$declarations/factory.update.did';
import { idlFactory as idlFactoryQuery } from '$declarations/factory.query.did';
Actor.createActor(idlFactory, { // here either Update or Query
agent,
canisterId,
});
That’s what I do in Juno (https://github.com/junobuild/juno) and what we do in ic-js (https://github.com/dfinity/icp-js-canisters).
Hope that helps.