The inner block schemas - couldn’t they be Candid as well? Just a binary we can decode later.
Usage will then be:
// Where ICRC_Transfer is a custom type
let ?transfer : ICRC_Transfer = from_candid(block.content) else Debug.trap("err");
let from = transfer.tx.from
Instead of using it like this:
let #Map(m) = block else Debug.trap("err");
let ?tx = Array.find(m, func (k, v) = k == "tx") else Debug.trap("err");
let #Map(txm) = tx else Debug.trap("err");
let ?from = Array.find(m, func (k, v) = k == "from") else Debug.trap("err");
I guess that’s not only a question for icrc-3, but in general a lot of icrc’s are getting these generic variant schemas. By now every CDK should have to_candid and from_candid equivalent. I think in size - they will be equal or Candid version wins. In speed - running multiple Array.find’s to get your values out, will probably be slower too and require libraries that make it usable. @claudio Makes me wonder what’s the problem with the first way of doing it having binary candid sub schemas.