use-ink / contracts-ui

Web application for deploying wasm smart contracts on Substrate chains that include the FRAME contracts pallet
https://contracts-ui.substrate.io/
GNU General Public License v3.0
61 stars 45 forks source link

Better Input for Fixed-Length Arrays (`[T, N]`) #416

Closed ashutoshvarma closed 1 year ago

ashutoshvarma commented 1 year ago

Is your feature request related to a problem? Please describe. When inputting a fixed length array like a [u8;20] (an EVM Address), it is frustrating and not practical enough to input each u8 separately.

Describe the solution you'd like For fixed length bytes array, input should also provide option to input hex-encoded strings, like polkadot-js provides.

Additional context image

PierreOssun commented 1 year ago

Any update on it ? @statictype

statictype commented 1 year ago

can you please provide a contract to test against?

ashutoshvarma commented 1 year ago

@statictype Any contract with array as input will reproduce. Below is the modified flipper where flip() take an EVM address ([u8;20]) who

#![cfg_attr(not(feature = "std"), no_std)]

#[ink::contract]
mod flipper {
    #[ink(storage)]
    pub struct Flipper {
        value: bool,
    }

    impl Flipper {
        #[ink(constructor)]
        pub fn new(init_value: bool) -> Self {
            Self { value: init_value }
        }
        #[ink(message)]
        pub fn flip(&mut self, who: [u8; 20]) {
            if who != [0; 20] {}
            self.value = !self.value;
        }

        #[ink(message)]
        pub fn get(&self) -> bool {
            self.value
        }
    }
}

Link to ink playground - https://ink-playground.substrate.io/?id=9e28483fb567b26972b7ce624c349cf9

statictype commented 1 year ago

@peetzweg maybe you can take care of this next week? i have no bandwidth until May

peetzweg commented 1 year ago

For sure this is nice ux improvement. IMHO not too sure to completely drop the the current ux to enter array elements.

I'm not available this week but could try to fit it in next weeks. However, how do you @ashutoshvarma or @PierreOssun work on a PR for this? Shouldn't be too complex for what I know.

Maar-io commented 1 year ago

Hi there, any update on this? This makes it almost impossible to use eth_addresses as input. We use ethereum addresses on Astar's cross VM feature.

peetzweg commented 1 year ago

Hi there, any update on this? This makes it almost impossible to use eth_addresses as input. We use ethereum addresses on Astar's cross VM feature.

@Maar-io Isn't this just a user experience issue? Because it's cumbersome to click the + button for new array elements? Or can you describe in other words what your issue is?

Maar-io commented 1 year ago

@Maar-io Isn't this just a user experience issue? Because it's cumbersome to click the + button for new array elements? Or can you describe in other words what your issue is?

You can call it bad UX but it is really not usable. Instead of copy and paste EVM user/contract address, you need to manually enter 20 bytes, one by one. This is how it looks on Polkadot.js

Screenshot 2023-05-04 at 10 35 52
statictype commented 1 year ago

I can pick this up next week

Maar-io commented 1 year ago

Hello friends, any update on this? I see you implemented hash input (64 chars) The H160 should be similar as feature