diff --git a/cmd/goic/main.go b/cmd/goic/main.go index b18ac59..203cd81 100644 --- a/cmd/goic/main.go +++ b/cmd/goic/main.go @@ -140,8 +140,11 @@ func fetchDID(canisterId principal.Principal) ([]byte, error) { return nil, err } var did string + // This endpoint has been deprecated and removed starting with moc v0.11.0. if err := a.Query(canisterId, "__get_candid_interface_tmp_hack", nil, []any{&did}); err != nil { - return nil, err + // It is recommended for the canister to have a custom section called "icp:public candid:service", which + // contains the UTF-8 encoding of the Candid interface for the canister. + return a.GetCanisterMetadata(canisterId, "candid:service") } return []byte(did), nil } diff --git a/ic/ic_test.go b/ic/ic_test.go index fe33066..3b03b67 100644 --- a/ic/ic_test.go +++ b/ic/ic_test.go @@ -81,6 +81,20 @@ func TestModules(t *testing.T) { if err := a.Authorize(principal.AnonymousID); err != nil { t.Fatal(err) } + + { + a, err := agent.New(config) + if err != nil { + t.Fatal(err) + } + did, err := a.GetCanisterMetadata(cId, "candid:service") + if err != nil { + t.Fatal(err) + } + if len(did) == 0 { + t.Error("empty did") + } + } }) t.Run("management canister", func(t *testing.T) {