My Contract content below
#[storage(read)]
fn get_share_bonus_list(_identity: Identity) -> Vec<BonusList>{
let _epoch = storage.epoch.read();
if _epoch < 2{
return Vec::new();
}else{
let mut counter = _epoch;
let mut _bonuslist = Vec::new();
while counter > 1 {
counter -= 1;
let bonuslist = BonusList{epoch_should_bonus: storage.epoch_should_bonus.get(counter).try_read().unwrap(),
epoch_total_share: storage.epoch_total_share.get(counter).try_read(),
my_share_bonus: storage.my_share_bonus.get((_identity, counter)).try_read(),
epoch: counter
};
_bonuslist.push(bonuslist);
}
return _bonuslist;
}
}
The code to obtain the result is as follows
try{
const identityCoder = {
"Address": {
"bits": address
}
};
let result = await myContract.functions.get_share_bonus_list(identityCoder).get();
console.log(result.value);
if(result.value.length > 0){
setData(result.value);
}
}catch(e){
console.log(e);
}
When I use “fuels”: “^0.93.0”, I can get the data correctly.
The data format is as follows
[
{
"epoch_should_bonus": "0x141ced0",
"epoch_total_share": "0x16",
"my_share_bonus": "0x0",
"epoch": "0x1"
}
]
But when I use the latest “fuels”: “^0.94.5”, I can only get
{
"buf": {
"ptr": "0x1",
"cap": "0x141ced0"
},
"len": "0x1"
}
How can I parse to get the correct data?