I instantiated a canister inside from canister:
I’m able to call the methods in the dynamically created canister through terminal, but I don’t see any services listed on dashboard: Canister: aijgk-eyaaa-aaaar-qabmq-cai - ICP Dashboard
The canister interface needs to be included in the custom wasm section candid:service
for the dasboard to display it. You can query your canister’s definition with this command: dfx canister --network ic metadata aijgk-eyaaa-aaaar-qabmq-cai candid:service
. As you can see from it, your canister does not have the service definition in there. If you use a custom build script you can use ic-wasm
to add your candid file as a custom section to the wasm
hello @Severin
I’m getting different services.
On the dashboard I can see more methods: Canister: a2prt-iiaaa-aaaar-qabpq-cai - ICP Dashboard
when I ran the command in the terminal, I see fewer methods.
dfx canister --network ic metadata a2prt-iiaaa-aaaar-qabpq-cai candid:service
AFAIK the dashboard does some caching. Is it possible that the dashboard shows an old version? I would consider dfx the source of truth, at least in regards to what is stored in the canister. The WASM is allowed to support more than what is displayed in the candid
hmm, but I able to call the functions through the terminal!
when I tried to call the method from js script, it says ___ is not a function!
how should I fix it?
Is it a runtime error or a compile time error? If it’s a runtime error then I don’t understand what’s happening, if it’s a compile-time error then you ‘just’ don’t have a definition generated for the right function. If you manually add the function to the .did and regenerate the bindings then it should compile
I using a script for generating the did file:
#[query(name = "__get_candid_interface_tmp_hack")]
fn export_candid() -> String {
export_service!();
__export_service()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn save_candid() {
use std::env;
use std::fs::write;
use std::path::PathBuf;
let dir = PathBuf::from(env::current_dir().unwrap());
write(dir.join("wallet.did"), export_candid()).expect("Write failed.");
}
}
it works fine, it renders all the method listed in the did file!
here is the did file, script generated:
type Account = record { owner : principal; subaccount : opt vec nat8 };
type ChunkArgs = record { content : vec nat8; order : nat32 };
type CommitArgs = record {
file_type : text;
chunk_ids : vec nat;
checksum : nat64;
content_encoding : ContentEncoding;
};
type ContentEncoding = variant { GZIP; Identity };
type CreateLegArgs = record {
id : nat;
court : principal;
payment_method : PaymentMethod;
maturity_date : nat64;
currency : text;
leg_type : LegType;
amount : nat64;
receiver : Receiver;
};
type HttpRequest = record {
url : text;
method : text;
body : vec nat8;
headers : vec record { text; text };
};
type HttpResponse = record {
body : vec nat8;
headers : vec record { text; text };
streaming_strategy : opt StreamingStrategy;
status_code : nat16;
};
type Leg = record {
id : nat;
payment_done : bool;
contract : record { principal; nat };
court : principal;
payment_method : PaymentMethod;
maturity_date : nat64;
leg_type : LegType;
ecosytem_type : LegTransctionPlatformType;
leg_status : LegStatus;
amount : nat64;
receiver : Receiver;
leg_account : Account;
};
type LegStatus = variant {
Ended : record { ended_at : nat64 };
InDispute;
Ongoing : record { started_at : nat64 };
};
type LegTransctionPlatformType = variant {
ICP : record { currency : principal; account : Account; decimal : nat8 };
Ethereum : record {
derivation_key : opt vec vec nat8;
currency : text;
address : text;
decimal : nat8;
};
};
type LegType = variant { TokenLeg; ContractLeg };
type PaymentMethod = variant {
Escrow;
Bills : record { prepayment_amount : nat64; payment_date : nat64 };
Direct;
};
type Receiver = variant {
None;
IcrcTokenReceiver : Account;
ContractReceiver : Account;
EthTokenReceiver : text;
};
type StreamingCallbackHttpResponse = record {
token : opt StreamingCallbackToken;
body : vec nat8;
};
type StreamingCallbackToken = record {
chunk_index : nat32;
asset_id : nat;
content_encoding : text;
chunk_size : nat32;
};
type StreamingStrategy = variant {
Callback : record {
token : StreamingCallbackToken;
callback : func () -> ();
};
};
type TransferMoneyArgs = variant {
TokenTransfer : record { id : nat; amount_to_send : opt nat64 };
ContractTransfer : record { id : nat; receiver : opt Account };
};
type UpdateReceiverArgs = record { id : nat; receiver : Receiver };
type WalletInitData = record {
database : principal;
repo_canister : principal;
authority : principal;
};
service : (WalletInitData) -> {
copy_contract_code : () -> (principal);
create_leg : (CreateLegArgs) -> (nat);
get_eth_address : () -> (opt text) query;
get_leg_detail_of : (nat) -> (opt Leg) query;
get_leg_list : () -> (vec record { nat; Leg }) query;
http_request : (HttpRequest) -> (HttpResponse) query;
http_request_streaming_callback : (StreamingCallbackToken) -> (
StreamingCallbackHttpResponse,
) query;
leg_transfer : (TransferMoneyArgs) -> (bool);
mark_payment : (nat) -> (bool);
notify_dispute : (nat) -> (bool);
query_capr_file_url : () -> (opt text) query;
query_expe_file_url : () -> (opt text) query;
query_impe_file_url : () -> (opt text) query;
request_cyles : () -> (bool);
update_eth_address : (text) -> (bool);
update_receiver : (UpdateReceiverArgs) -> (bool);
upload_capr_file : (CommitArgs) -> (text);
upload_chunk : (ChunkArgs) -> (nat);
upload_crpr_fie : (CommitArgs) -> (text);
upload_expe_file : (CommitArgs) -> (text);
upload_impe_file : (CommitArgs) -> (text);
}
also the ic-wasm
commands:
ic-wasm target/wasm32-unknown-unknown/release/wallet.wasm -o wasm_files/wallet.wasm shrink
ic-wasm wasm_files/wallet.wasm -o wasm_files/wallet.wasm metadata candid:service -f src/wallet/wallet.did -v public
I’m able to call the method from terminal using dfx!
the problem is:
I see different services on terminal and dashboard.
On terminal side: I see fewer methods. But I’m able to call hidden methods from terminal.
when I tried calling the method from a js script: it says ___ method is not a function