Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pedronauck opened this issue Oct 27, 2023 · 6 comments
Open

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

pedronauck opened this issue Oct 27, 2023 · 6 comments
Labels
bug Issue is a bug

Comments

@pedronauck
Copy link
Contributor

pedronauck commented Oct 27, 2023

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.

@pedronauck pedronauck added the bug Issue is a bug label Oct 27, 2023
@camsjams camsjams self-assigned this Nov 7, 2023
@camsjams
Copy link
Contributor

camsjams commented Nov 7, 2023

Relates to FuelLabs/sway#5044

@camsjams
Copy link
Contributor

camsjams commented Nov 7, 2023

Hey @pedronauck after debugging, this looks to be an issue on Sway with the new String Slice changes that have been added.

Are you able to share more of the contract source code (as text, not image 😅 ). Currently, a storage map like StorageMap<String, u64> = StorageMap {} or similar heap types (Bytes/Strings/Vectors) will not function correctly.

@Torres-ssf
Copy link
Contributor

Torres-ssf commented Nov 29, 2023

This is currently blocked:
ref:

@arboleya arboleya added this to the Cricket milestone Dec 14, 2023
@arboleya arboleya modified the milestones: 4 - Cricket, 3 - Wasp Dec 21, 2023
@arboleya arboleya modified the milestones: 3 - Wasp, 4 - Cricket Jan 31, 2024
@nedsalk nedsalk removed their assignment Feb 22, 2024
@arboleya arboleya changed the title Contracts calls are not working when returning String in a Struct or Tuple SDK fails when Contract returns String in a Struct or Tuple Mar 13, 2024
@danielbate danielbate assigned danielbate and unassigned danielbate Mar 21, 2024
@arboleya arboleya added the epic label May 15, 2024
@danielbate danielbate self-assigned this May 16, 2024
@arboleya arboleya added the p0 label Jun 9, 2024
@arboleya arboleya added this to the 0.x post-launch milestone Jun 12, 2024
@arboleya arboleya added p2 and removed p0 labels Jun 12, 2024
@arboleya arboleya removed the epic label Jun 20, 2024
@arboleya arboleya removed this from the 0.x post-launch milestone Jul 19, 2024
@arboleya arboleya removed the p2 label Jul 20, 2024
@arboleya arboleya added the p1 label Aug 2, 2024
@arboleya arboleya removed the p1 label Aug 2, 2024
@Torres-ssf
Copy link
Contributor

Torres-ssf commented Aug 6, 2024

@danielbate I believe this issue was solved already, right?

@danielbate
Copy link
Member

Encoding wise we support all these types. This is blocked because on Sway side you can't use heap types in storage maps. Once unblocked Sway side, I expect this to just work.

@arboleya arboleya added temp-p2 and removed temp-M labels Sep 7, 2024
@arboleya arboleya added the blocked label Sep 8, 2024 — with Linear
@arboleya arboleya removed the blocked label Sep 8, 2024
@arboleya arboleya added the temp:notion label Sep 8, 2024 — with Linear
@arboleya arboleya added the temp-linear label Sep 8, 2024 — with Linear
@maschad
Copy link
Contributor

maschad commented Nov 19, 2024

Just to add some more context on why this is blocked as per @IGI-111

Using slices in encoding still being worked on as apart of FuelLabs/sway#5110 as @danielbate mentioned

But also there is a need for general support of putting types in storage, which should be solved by implementing the storage v3 RFC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is a bug
Projects
None yet
Development

No branches or pull requests

7 participants