laboratory icon indicating copy to clipboard operation
laboratory copied to clipboard

Feature request: decode symbols and strings into plaintext

Open Shaptic opened this issue 2 years ago • 4 comments

What problem does your feature solve?

When parsing XDR structures using the XDR viewer, it can be annoying to use multiple tools to decode base64-encoded values that you know are human-readable text. It would be better if the Laboratory decoded these as text automatically.

What would you like to see?

ScVals that are encoded as strings (scvString) and symbols (scvSymbol) should be rendered as strings rather than as base64-encoded blobs.

Note that strings don't "have" to be actual strings under the hood (i.e. they're just bytes with a string "hint"), so the error case should be handled. However, symbols MUST be ascii, so there is no error case there.

What alternatives are there?

Copy-pasting to a base64 decoder.

Shaptic avatar Aug 11 '23 17:08 Shaptic

We're bringing this one up in planning this sprint, will keep this updated.

aristidesstaffieri avatar Aug 11 '23 21:08 aristidesstaffieri

However, symbols MUST be ascii, so there is no error case there.

That's actually not necessarily correct in case if we want to also to be able to handle the transaction XDR, which can be arbitrarily broken, including non-valid Symbols.

There are also other potential improvements (in decreasing importance order):

  • Enums are just displayed as [Object object] which makes it impossible to figure out what the value is (at least for strings we have base64 decoder). This is important for the event type field and especially for the SCError type and code.
  • Contract ids within ScAddress and should probably be displayed with C... strkey, similarly to what we do to the account ids.
  • There are also explicit contractId fields outside of the address that can be formatted with strkey as well (e.g. contractId field of the event)

dmkozh avatar Aug 11 '23 21:08 dmkozh

Any update on this?

I still see things like this when decoding Soroban transactions.

contractID and functionName both decoded as base64

invokeHostFunctionOp
hostFunction: [hostFunctionTypeInvokeContract]
invokeContract
contractAddress: [scAddressTypeContract]
contractId: HlVancuzUT+2dtyZdmjFK6bK/Cja9jkHK3Hvv7CTzNs=
functionName: ZGVwb3NpdA==
args: Array[5]

MonsieurNicolas avatar Jan 31 '24 18:01 MonsieurNicolas

Active work is currently underway on Dev X to create a canonical JSON schema which enables XDR <=> JSON in Lab UI. I'm marking this discussion as v1 as it may become obsolete when Lab v2 is shipped.

janewang avatar Mar 12 '24 13:03 janewang

We are decoding XDR strings into JSON, closing.

janewang avatar Aug 21 '24 22:08 janewang