canvas-ui
canvas-ui copied to clipboard
ink_prelude::string::String problem
set value to hello, it returns u0014hello
;
set value to hello, world!
, it returns 4hello, world!
contract source
// Copyright 2018-2021 Parity Technologies (UK) Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#![cfg_attr(not(feature = "std"), no_std)]
use ink_lang as ink;
#[ink::contract]
pub mod flipper {
use ink_prelude::string::String;
#[ink(storage)]
pub struct Flipper {
value: String,
}
impl Flipper {
/// Creates a new flipper smart contract initialized with the given value.
#[ink(constructor)]
pub fn new(init_value: String) -> Self {
Self { value: init_value }
}
/// Creates a new flipper smart contract initialized to `false`.
#[ink(constructor)]
pub fn default() -> Self {
Self::new(String::from("hello, world!"))
}
/// Flips the current value of the Flipper's bool.
#[ink(message)]
pub fn set(&mut self, v:String) {
self.value = v;
}
/// Returns the current value of the Flipper's bool.
#[ink(message)]
pub fn get(&self) -> String {
self.value.clone()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn default_works() {
let flipper = Flipper::default();
assert_eq!(flipper.get(), String::from("hello, world!"));
}
#[test]
fn it_works() {
let mut flipper = Flipper::new(String::from("Good day"));
assert_eq!(flipper.get(), String::from("Good day"));
flipper.set(String::from("Good morning"));
assert_eq!(flipper.get(), String::from("Good morning"));
}
}
}
I have submmit this issue in https://github.com/polkadot-js/apps, I think this is a bug in apps. more detils refer to this issue https://github.com/polkadot-js/apps/issues/4621
I have submmit this issue in https://github.com/polkadot-js/apps, I think this is a bug in apps. more detils refer to this issue polkadot-js/apps#4621
I'll take a look at it, Thank you~
The issue can be reproduced with the Canvas UI. This is how it looks:
huhu
lala
I've uploaded the .contract
file for the contract posted by @xhuanlee here:
flipper.contract.zip.
obviously this is a bug in apps, I have proved this by using europa, and I already summited the issue in apps https://github.com/polkadot-js/apps/issues/4621, waiting for jacob to fix it for a long time.