Closed Shaptic closed 1 year ago
Thank you for the review, @paulbellamy :pray:
try to do stuff in the dapp example [...] motivating example [...]
I forgot to include the context that motivated this: Slack thread. The idea is for Freighter et al. to have meaningful popups when asking users to authorize invocation trees.
The JSON produces is marginally more human-friendly
Hard disagree, but this isn't obvious without an example. Flattening the structure and leveraging scValToNative
makes a huge difference in readability. Which one is easier to grok (both are JSON.stringify
d)? And which one would be easier for a dapp user (not dev)?
This is a complicated, albeit contrived invocation tree whose pseudo-structure is supposed to represent a high-level contract interaction involving two transfers of native SAC tokens underneath it.
purchase("SomeNft:G...", 7 xlm)
|
+--- swap(xlm, usdc, from, to)
| |
| |- xlm.transfer(from, to, 7)
| |
| |- usdc.transfer(to, from, 1)
|
+--- someNft.transfer(invoker, contract, 1)
While I will admit that the contract IDs don't help you (e.g. what is CDUAR...
?), this could easily be built upon by e.g. block explorers or Freighter itself caching explanations for common contracts.
Putting on my, "non technical user" hat. Both the xdr and json examples you gave look like unintelligible computer-nonsense. Fine, the json outputs contract IDs instead of byte arrays, etc. 🤷
Interestingly, when you actually wanted to explain what the tree structure you were building does you invented a different (more graphical) format to do that. 😉
purchase("SomeNft:G...", 7 xlm)
|
+--- swap(xlm, usdc, from, to)
| |
| |- xlm.transfer(from, to, 7)
| |
| |- usdc.transfer(to, from, 1)
|
+--- someNft.transfer(invoker, contract, 1)
^ This is what I would expect wallets to do. So if xdr -> json -> html
is easier for wallets/dapps than xdr -> html
, then fine, I guess.
We'd vote for xdr -> json -> html, a little more wiggle room and MUCH easier for non-XDR or new devs to understand.
Lou
On Wed, Aug 23, 2023 at 3:45 AM Paul Bellamy @.***> wrote:
Putting on my, "non technical user" hat. Both the xdr and json examples you gave look like unintelligible computer-nonsense. Fine, the json outputs contract IDs instead of byte arrays, etc. 🤷
Interestingly, when you actually wanted to explain what the tree structure you were building does you invented a different (more graphical) format to do that. 😉
purchase("SomeNft:G...", 7 xlm) +--- swap(xlm, usdc, from, to) - xlm.transfer(from, to, 7) - usdc.transfer(to, from, 1) +--- someNft.transfer(invoker, contract, 1)
^ This is what I would expect wallets to do. So if xdr -> json -> html is easier for wallets/dapps than xdr -> html, then fine, I guess.
— Reply to this email directly, view it on GitHub https://github.com/stellar/js-stellar-base/pull/669#issuecomment-1689542779, or unsubscribe https://github.com/notifications/unsubscribe-auth/APB6MJAG5QMUWTC3UNEMNWTXWW7LPANCNFSM6AAAAAA3KUHODY . You are receiving this because you are subscribed to this thread.Message ID: @.***>
-- Regards, Lou Morgan
Chief Technology Officer @.*** www.blocktimefinancial.com 262-716-1201 (M) 262-368-1150 (O)
To clarify, by "xdr" in the above comment, I mean the js classes from stellar-base
, not like base64 strings. But sounds like an intermediate representation might still be helpful. 👍
Size Change: +41.6 kB (+1%)
Total Size: 3.11 MB
dist/stellar-base.js
dist/stellar-base.min.js
compressed-size-action