Unable to parse array data by using latest TS SDK

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?

Hey @Clara :wave:

Could you share the output of fuelup show?

Are you getting this on localhost or Testnet? If testing on Testnet, can you tell me how and when you deployed your contract?

Hello, @p.s
Do you mean the json content of abi? I didn’t use fuelup.
I used https://www.sway-playground.org/ directly to compile and deploy the code.

Hi @anderson
I used https://www.sway-playground.org/ directly to compile and deploy the code on Testnet.
The contract has been running smoothly on the Testnet for more than 20 days.

There were changes to forc and the underlying ABI contract structure which could be causing the issue you’re experiencing.

Have you tried recompiling and redeploying the contract?

No, there are already some users playing on it, so we generally will not redeploy casually, and the method of updating the contract is waiting for further official information. In this case, let’s try updating together when our new features are developed.

You could try developing locally, or even using our testing utility for developing new features. If this avenue appeals to you, then to get setup quickly you could use create-fuels.

@Clara please could you share the complete contract code?

Thanks @p.s
We have deployed the latest contract to the test network and found that the latest TS SDK must be combined with the latest ABI JSON to be used correctly.
Due to the large number of features, it may take a few days to know whether the code and data are correct.

Hey @danielbate
We are still developing and testing contracts and systems. There are many additions and modifications to contract functions. We need to take time to sort them out before uploading them to our github. Currently, github does not have the latest version of the code.

Okay no problem, let us know when you can share the full contract and we can run some tests.

This is a good point tho, if you rebuild the contract and the ABI changes, you should redeploy the contract.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.