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

Implement msg.data #277

Open
cburgdorf opened this issue Mar 1, 2021 · 7 comments
Open

Implement msg.data #277

cburgdorf opened this issue Mar 1, 2021 · 7 comments

Comments

@cburgdorf
Copy link
Collaborator

What is wrong?

We do not yet implement reading msg.data

Ok(MsgField::Data) => todo!(),

How can it be fixed

Start here:

Ok(MsgField::Data) => todo!(),

Background:

https://docs.soliditylang.org/en/develop/units-and-global-variables.html#block-and-transaction-properties

@georgeroman
Copy link
Contributor

I can take this.

@cburgdorf
Copy link
Collaborator Author

Happy to review a PR!

@g-r-a-n-t
Copy link
Member

Hi @georgeroman, thank you very much for volunteering.

There's a bit of a holdup with this issue right now, since we do not support dynamically sized bytes (see #280). Without support for dynamically sized bytes, I'm not quite sure how this will be implemented.

There's some open discussion about bytes support, which you'll see if you follow the linked issue, but I think we can get away with handling bytes the same way we handle strings for the time being.

If you're still interested in taking this on, let me know. Otherwise, we could find something else for you.

@georgeroman
Copy link
Contributor

Thank you for letting me know! In this case, I'll take #278 as it seems easier to start with. However, I would still be interested in helping out with this one.

@g-r-a-n-t
Copy link
Member

Great! That one is alright.

@cburgdorf
Copy link
Collaborator Author

cburgdorf commented Mar 16, 2021

Just citing from #280 (comment) that there might be a better way to read msg.data using a special cbytes type that could have read or slice APIs to read slices of the calldata into a fixed size array.

@cburgdorf cburgdorf removed the good first issue Good for newcomers label Mar 19, 2021
@sbillig
Copy link
Collaborator

sbillig commented May 28, 2021

How about something like a decode_calldata function, which is generic in its return type?

impl Msg:
  pub fn decode_calldata<T>(offset: u256 = 0) -> T:
    // magic
(x, y, z): (Array<u8, 10>, u256, address) = Msg::decode_calldata(offset: 32)
// x is Array<u8, 10, Location=Calldata> or Calldata<Array<u8, 10>>

// Get a pointer to some raw bytes (This is a bit weird, I admit. Maybe getting a pointer to raw bytes should be a different fn)
x: Array<u8, 128, Encoding=Static> = Msg::decode_calldata()

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

No branches or pull requests

4 participants