-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Make object directly passable in tx's #7090
Conversation
.all(|types| Self::match_return_type(types.0, types.1, map)) | ||
}, | ||
// For the rest we need to assure the types match | ||
_ => std::mem::discriminant(returned) == std::mem::discriminant(expected), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TyParam(usize)
what if we get this? what is this even? it would seem like a violation
Also these all have Eq / PartialEq -- why not leverage that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a fix for the error propagation problem.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ Forge suite
|
✅ Forge suite
|
✅ Forge suite
|
Description
This PR makes (whitelisted) objects directly passable in non-script tx's. The overall strategy is that each allowed struct is associated with a "constructor" in the module that defines the struct, which will construct the type. The argument will be the BCS encoded parameter values of the constructor call, if the constructor takes the same values in the same order as the struct fields this will be identical.
Overall the flow is that a call to eg.
entry fun my_func(x: std::string::String foo) { ... }
let's say my_func("aptos") will effectively be exectuted as if the user has written a script like
let s = std::string::utf8("aptos")
my_func(s)
The same works for objects
entry fun send(x: Object, to: address);
a call send(0xCAFE, 0xC0FFEE)
will effectively run like
let o = aptos_std::object::address_to_object(0xCAFE)
send(o, 0xC0FFEE)
Notice that I included type inference in the call to address_to_object, from the expected return type. The algorithm works recursively so in principle nested structs etc. will work fine.
Test Plan