Calling another canister from backend

So I used __get_candid_interface_tmp_hack to get the canidid file of a canister that I can query here:
https://a4gq6-oaaaa-aaaab-qaa4q-cai.raw.ic0.app/?id=tskpj-aiaaa-aaaag-qaxsq-cai

The candid service definition contains the definition of a function I would like to query:
image

When I query the availableCycles() function in the canister I get the expected result:
image

But when I query getRegistry() I get an empty array.

It makes me think that I am not converting the registry correctly from a linked list to an array:

image

The type I’m trying to cast to has the same structure as the candidid getRegistry function:
image

But ultimately the array I get is empty.

Any help will be appreciated.

2 Likes

Have you tried using an array instead of a list? Like:

... 
getRegistry: () -> async [T.NFT];
... 
2 Likes

Thanks mate I figured it out from your reply, I changed to an array and got a more descriptive message:

Just define the type record like this:

    getRegistry: () -> async [(Nat32, Text)];

Map that to type:
let registry = Array.map<(Nat32, Text), T.NFT>(registryRecords, updateFn);

and build the using indexes:

let updateFn = func(nft: (Nat32, Text)): T.NFT {
  return {
        tokenIndex = nft.0;
        accountIdentifier = nft.1;
      };
  };
2 Likes