You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 2, 2022. It is now read-only.
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]pubmod flipper {use ink_prelude::string::String;#[ink(storage)]pubstructFlipper{value:String,}implFlipper{/// Creates a new flipper smart contract initialized with the given value.#[ink(constructor)]pubfnnew(init_value:String) -> Self{Self{value: init_value }}/// Creates a new flipper smart contract initialized to `false`.#[ink(constructor)]pubfndefault() -> Self{Self::new(String::from("hello, world!"))}/// Flips the current value of the Flipper's bool.#[ink(message)]pubfnset(&mutself,v:String){self.value = v;}/// Returns the current value of the Flipper's bool.#[ink(message)]pubfnget(&self) -> String{self.value.clone()}}#[cfg(test)]mod tests {usesuper::*;#[test]fndefault_works(){let flipper = Flipper::default();assert_eq!(flipper.get(), String::from("hello, world!"));}#[test]fnit_works(){letmut 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"));}}}
The text was updated successfully, but these errors were encountered:
xhuanlee
changed the title
wrong String value
ink_prelude::string::String problem
Feb 20, 2021
obviously this is a bug in apps, I have proved this by using europa, and I already summited the issue in apps polkadot-js#4621, waiting for jacob to fix it for a long time.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
set value to hello, it returns
u0014hello
;set value to
hello, world!
, it returns4hello, world!
contract source
The text was updated successfully, but these errors were encountered: