Chances are you will be ok using a js object instead of a candid string.
Check:
[GitHub - infu/icblast]
[https://jglts-daaaa-aaaai-qnpma-cai.ic0.app/]
Icblast can proxy calls to other canisters. From the examples:
let ic = icblast({ identity }); // can switch identity or go local
// we need to specify "ic" preset because this canister doesn't support downloading IDL spec
let aaa = await ic("aaaaa-aa", "ic");
// each method has also a version with $ suffix. It will not make a call but return the encoded arguments.
// Useful for proxy calls
let encoded = aaa.canister_status$({
canister_id: Principal.fromText("kbzti-laaaa-aaaai-qe2ma-cai"),
});
// we need to specify "wallet" preset for this canister as well
let wallet = await ic("vlgg5-pyaaa-aaaai-qaqba-cai", "wallet");
// now we make a wallet proxy call
let response = await wallet.wallet_call({
args: encoded,
cycles: 0,
method_name: "canister_status",
canister: Principal.fromText("aaaaa-aa"),
});
// each method has also version with $ prefix. It will decode responses
let decoded = aaa.$canister_status(response.Ok.return);
console.log(decoded);
It doesn’t cover the init arguments, however. I personally don’t like using them at all, because I have to provide them every time I upgrade the canister. Instead, I create an init method that sets my initial configuration and stores it in memory.
Anyway if you want to provide Init arguments, you can go to the idl.js file. Here is an example:
export const init = ({ IDL }) => {
const InitArgs = IDL.Record({ ‘ledger_id’ : IDL.Principal });
return [InitArgs];
};
You can take this line out and add it to the end of the file:
export const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });
This also works for types in the idlFactory. It seems init can also return initArgs, so. you can just type:
import {init} from "...mycan.idl.js";
let [InitArgs] = init(IDL);
Then you can do something like
import { IDL } from "@dfinity/candid";
import { Principal } from "@dfinity/principal";
import { InitArgs } from "....mycan.idl.js"
let arg = IDL.encode(InitArgs, {ledger_id:Principal.fromText("aaaaa-aa"));
//you will have the binary you can pass
IC.install({
arg,
...rest_of_arguments
});