#[ink(storage)]
pub struct Variables {
a: u128,
b: u128,
multiplier: u128
}
impl Variables {
#[ink(constructor)]
pub fn new(a: u128, b: u128) -> Self {
Variables {
a: a,
b: b,
multiplier: 1_000_000_000_000
}
}
#[ink(constructor)]
pub fn default() -> Self {
Variables {
a: Default::default(),
b: Default::default(),
multiplier: 1_000_000_000_000
}
}
#[ink(message)]
pub fn initializer(&mut self, a: u128, b: u128) -> bool{
self.a = a;
self.b = b;
true
}
#[ink(message)]
pub fn div(&self) -> u128 {
(self.a*self.multiplier/self.b) as u128
}
}
}
when I try to build above contract i'm getting this error -
ERROR: Validation of the Wasm failed
.
ERROR: An unexpected panic function import was found in the contract Wasm.
This typically goes back to a known bug in the Rust compiler:
https://github.com/rust-lang/rust/issues/78744
As a workaround try to insert overflow-checks = false
into your Cargo.toml
.
This will disable safe math operations, but unfortunately we are currently not
aware of a better workaround until the bug in the compiler is fixed.
ERROR: An unexpected import function was found in the contract Wasm: _ZN4core9panicking5panic17h8d2687444d110f05E.
Import funtions must either be prefixed with 'memory', or part of a module prefixed with 'seal'
Ignore with --skip-wasm-validation