Skip to content

SDK fails when Contract returns String in a Struct or Tuple #1385

@pedronauck

Description

@pedronauck

What version of fuels-ts are you using?

0.65.0

Steps to Reproduce

Hey guys, I was trying to run a small project yesterday and got into some issues related to decoding contract calls. What's happening is that it is not possible to return a Struct or a tuple that contains a String or Bytes inside. It seems it worked before 0.58.0, but things started to break since this PR.

Expected Behavior

This is the example of code in Sway

CleanShot 2023-10-27 at 15 24 29
CleanShot 2023-10-27 at 15 24 39

This is the example of usage on the SDK:

  static async getFirstMessage() {
    const contract = await getContract();
    const { value } = await contract.functions.get_first_msg().simulate();
    console.log(value);
  }

Actual Behavior

And that's the error I'm facing right now:

CleanShot 2023-10-27 at 15 24 04@2x

Seems that the problem is related to this part of the code:
https://github.com/FuelLabs/fuels-ts/blob/master/packages/abi-coder/src/coders/stdString.ts#L52-L58

I don't know, but I guess this toNumber() error when tryting to convert from bn will break other decoders as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue is a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions