Hi @p.s @Nazeeh21 Facing this blocker while calling the function on testnet
contract;
use std::hash::Hash;
pub struct Point {
question_id :u64,
yesnftcount: u64,
nonftcount: u64,
question: u64,
starttime : u64,
endtime : u64
}
storage {
counter: u64 = 0,
question_info: StorageMap<b256, Point> = StorageMap::<b256, Point>{},
used_id: StorageMap<b256, bool> = StorageMap {},
}
abi MyContract {
#[storage(read, write)]
fn add_question(question_id: b256, question_info: Point);
#[storage(read)]
fn get_question(question_id: b256) -> Point;
#[storage(read)]
fn used_id(question_id: b256) -> bool;
#[storage(read)]
fn question_counter() -> u64;
#[storage(read, write)]
fn set_question_time(question_id: b256, start_time: u64, end_time: u64);
#[storage(read, write)]
fn set_question_name(question_id: b256, question: u64);
#[storage(read, write)]
fn set_question_count(question_id: b256, yes_count: u64, no_count: u64);
}
impl MyContract for Contract {
#[storage(read)]
fn question_counter() -> u64 {
storage.counter.read()
}
#[storage(read)]
fn get_question(question_id: b256) -> Point {
storage.question_info.get(question_id).read()
}
#[storage(read)]
fn used_id(question_id: b256) -> bool {
storage.used_id.get(question_id).read()
}
#[storage(read, write)]
fn add_question(question_id: b256, question_info : Point){
require(storage.used_id.get(question_id).read() != true, "Cryptosage: Used question ID");
let incremented : u64 = storage.counter.read() + 1;
storage.counter.write(incremented);
storage.question_info.insert(question_id, question_info);
storage.question_info.get(question_id).write(question_info);
storage.used_id.get(question_id).write(true);
}
#[storage(read, write)]
fn set_question_time(question_id: b256, start_time: u64, end_time: u64) {
require(storage.used_id.get(question_id).read() != false, "Cryptosage: Non existing question");
let mut question_info = storage.question_info.get(question_id).read();
question_info.starttime = start_time;
question_info.endtime = end_time;
}
#[storage(read, write)]
fn set_question_name(question_id: b256, question: u64) {
require(storage.used_id.get(question_id).read() != false, "Cryptosage: Non existing question");
let mut question_info = storage.question_info.get(question_id).read();
question_info.question = question;
}
#[storage(read, write)]
fn set_question_count(question_id: b256, yes_count: u64, no_count: u64) {
require(storage.used_id.get(question_id).read() != false, "Cryptosage: Non existing question");
let mut question_info = storage.question_info.get(question_id).read();
question_info.yesnftcount = yes_count;
question_info.nonftcount = no_count;
}
}
Can you help me to fix this issue ?
Thanks in advance