Skip to content

Commit

Permalink
Get did from metadata instead with _tmp_hack.
Browse files Browse the repository at this point in the history
  • Loading branch information
q-uint committed Apr 12, 2024
1 parent 9edaeb3 commit 8c67c11
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/goic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
14 changes: 14 additions & 0 deletions ic/ic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8c67c11

Please sign in to comment.