1

Im trying to store a public key in a StorageValue, but when i try to consult it on polkadot-js chain-state, the string gets cut off in the following manner:

KeyStart...KeyEnd

The value being put in storage has the following declaration:

let public_key: Vec< u8> = ToRsaPublicKey::to_pkcs1_pem(&pub_key).unwrap().as_bytes().to_vec();

public_key.len() is 97.

I think the string is being cut-off in JS, maybe due to "text-overflow: ellipsis" ? Is there a way to storage a large string without having to split it?

2
  • Could you please be more descriptive, maybe a github repo link would help a lot? In particular it's difficult to understand what you mean by "I think the string is being cut-off in JS, maybe due to "text-overflow: ellipsis" ?" :)
    – jkhaui
    Commented Mar 25, 2022 at 22:31
  • This sounds like a polkadot-js display issue. I would raise an issue in that repo with a screenshot showing your truncated key.
    – Squirrel
    Commented Mar 26, 2022 at 8:08

1 Answer 1

6

It is not actually a display issue as suggested, it is by design where values > 512 bits are truncated. If you wish to have the actual full value, you can always query via the developer tools.

However...

The trimming actually pre-dates the introduction of text-overflow: ellipsis on the fields (which are quite a nightmare to get right when things start nesting in weird ways) and as a consequence, actually duplicates effort. So basically it ended in a situation where "pretty formatting" was applied in the middle and then again by the rendering engine. Not quite optimal to say the least.

With that in mind, see this PR which actually removes the manual formatting when converting to a hex display, only relying on the builtin browser version.

You would obviously still see ellipsis at the end if it does overflow when something like a hex string is too long, however if you are after the field inspect would work since it is display-only.

For those wanting to scratch an itch: It may actually be quite useful to have a "Copy button" on these output fields, at the very least where Bytes or Hash or anything that is not structured in a toHuman() form is displayed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.