Caveat: dfx cannot yet produce a request status message in json, so checking request status of an update call is not yet supported.
Code:
It is meant to demonstrate a single-page app can be built without any backend (except asset), and also how raw transaction can be sent using regular http POST.
I also think it is possible to build a 3rd-party mobile wallet as a single-page app that talks to the ICP ledger & NNS, maybe even supporting existing Internet Identity too. But that is a separate topic.
Unfortunately the message execution result (most likely a Candid encoded value) cannot be displayed without a schema. Iām still trying to figure out a solution.
@cryptoschindler Iāve updated the QR code scanner app to decode call results if it is from the ledger or governance canister. Please give it a try and let me know if you notice any problem.
A more general solution depends on whether the app can grab the candid IDL file of the the call target. Iām hoping someday all canisters can start to offer IDL as a standard service.
@cryptoschindler thanks a lot for the nns-command-line-guide article by the way. I feel embarrassed that users have to go through all this pain. Now that the QR scanner app can support displaying results, maybe you can simplify the guide a bit.
Also, Iād suggest you change this line in the article:
(he works for DFINITY so this should be trustworthy).
to something like:
(since the transaction is already signed, the app canāt tamper with it)
Hey Paul, thank you for getting back to me and also for the quick update of the app! Iāll test it tomorrow and get back to you
And thank you for the suggestion regarding the article, I will implement it.
The decoding of principals & accounts doesnāt work yet, it would be nice to have this, otherwise I would need to write another guide on how to decode them
It would also be cool to have a copy button on the response so I donāt need to select the whole thing myself on mobile
Do you have an example call that returns principal or account id?
BTW, the scanner only supports decoding using ledger & governance did file. I think more can be supported if the target canister provides an interface of getting the candid file (motoko canisters by default does this). Or if there is an open service that can return did file to me. Does the canlista canister have such an interface?
dfx canister --network ic call kyhgh-oyaaa-aaaae-qaaha-cai getCandid ā(principal āryjl3-tyaaa-aaaaa-aaaba-caiā)ā
Thatāll get you the candid for rust (or any other) canisters in the listings, if they provided it.
User submitted candid is checked as valid candid by Canlista, but it currently assumes they submitted the candid that matches the canister id, so that base would need covering in the qr-scanner for now.
(Thisāll actually fetch candid for the motoko canisters too.)
Edit: Wrong canister id copied! Weāre all humanā¦ Updated.
Thanks @cryptoschindler and @Ori . Iāve updated the app to print message result as candid instead of JSON. So principal IDs are printed properly, but account is still vec nat8 in candid, which is not pretty printed.
Also it is a lot smarter at figuring out the candid type, so you can use it against almost any canisters. It first tries to use __get_candid_interface_tmp_hack, and if that failed, it will try to use Canlista service.
A copy button is also added. Let me know if you experience any issue. Thanks!
Hey Paul, thanks for upgrades!
Two things I ran into:
I canāt seem to make the JSON input functionality work, thereās no button to submit the message on my end
I tried using a different QR code generator that didnāt really work with the DApp, but works perfectly fine otherwise ( I can read generated QR codes using the built in iPhone QR Code scanner )
I canāt seem to make the JSON input functionality work, thereās no button to submit the message on my end
Just tested, it works in Firefox (on Android) once I paste the json into the text box. But it doesnāt work in Chrome. Will make a fix.
I tried using a different QR code generator that didnāt really work with the DApp, but works perfectly fine otherwise ( I can read generated QR codes using the built in iPhone QR Code scanner )
Are you sure you did the gzip -c|base64 thing before encoding into QR? Which other QR code generator did you use?