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

Adjustments to send_message() #3401

Closed
deekerno opened this issue Nov 21, 2022 · 1 comment
Closed

Adjustments to send_message() #3401

deekerno opened this issue Nov 21, 2022 · 1 comment
Labels
enhancement New feature or request lib: std Standard library

Comments

@deekerno
Copy link

When using send_message(), Sway allows for message data of arbitrary length to be sent as part of a MessageOut receipt. However, there does not seem to be a way to transform a struct into Vec<u64>, which is the type required for msg_data. I had assumed that send_message() would work in a manner similar to that of log() on non-reference types, where it accepts a generic type and allows for structs to be used. Is it possible for send_message() to be adjusted to allow for this?

Additionally, if the above adjustment is possible, is it also possible for the type used in this new send_message() to be added to loggedTypes in the ABI JSON? In the Fuel indexer, we leverage the logged types field to be able to decode the bytes into the structs found in the Sway contract. This would allow us to decode the data field in MessageOut receipts, and further augment our abilities to index contract events. (FuelLabs/fuel-indexer#300)

@deekerno deekerno added the enhancement New feature or request label Nov 21, 2022
@mohammadfawaz mohammadfawaz added the lib: std Standard library label Nov 22, 2022
@mohammadfawaz
Copy link
Contributor

Is it possible for send_message() to be adjusted to allow for this?

I think this is doable but what may make it challenging is being able to support both Vec<u8> AND non-heap types.

is it also possible for the type used in this new send_message() to be added to loggedTypes in the ABI JSON?

Even if we do this, there is no way to know what type corresponds to what smo instruction. This works for log because register $rB of log is used to store the "log ID" which is stored in the JSON ABI and allows looking up the type. smo does not have a free register that we can use for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lib: std Standard library
Projects
None yet
Development

No branches or pull requests

2 participants