concordium-rust-smart-contracts icon indicating copy to clipboard operation
concordium-rust-smart-contracts copied to clipboard

Make the `invoke_contract` public in `cis2client` so that custom methods can be called from cis2 contract.

Open dhruvja opened this issue 1 year ago • 3 comments

Description With cis2client, we can only call a handful of methods like transfer, balanceOf etc. But ideally we would wanna call burn, mint and many more. This would help users call any method from the token contract which implements cis2. Users can use the invoke_contract implemented by Host but the error handling is better in cis2client which is customized for it.

Solution Make the invoke_contract found in cis2client as public. Here: https://github.com/Concordium/concordium-rust-smart-contracts/blob/4acf34e31e419059cd91941cf4fdef1c433f4b8d/concordium-cis2/src/cis2_client.rs#L367

The similar can be done for invoke_contract_read_only method as well.

dhruvja avatar Mar 03 '24 18:03 dhruvja

Well we can always implement the conversion by ourselves, but its a feature thats good to have.

dhruvja avatar Mar 03 '24 18:03 dhruvja

I don't think it's right to make this public since invoking other methods does not have anything to do with cis2.

However if I read your feedback more broadly, it would make sense to add a method to HasHost that automatically parses the response into a type you provide instead of returning the raw return value.

This seems like it would accomplish what you want, right?

abizjak avatar Mar 04 '24 07:03 abizjak

oh yes indeed. Yes thats what i would love to achieve. Looking at cis2 invoke contract, i was able to do the same. But having it done by invoke_contract would be ideal. Thanks

dhruvja avatar Mar 04 '24 16:03 dhruvja