-
Notifications
You must be signed in to change notification settings - Fork 14
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
Universal token receiver #93
Conversation
Params already come in as `RawBytes` so we don't need to do anything special to them. Fixes deserialisation panics in the example receiver actor
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.
LGTM
@@ -71,8 +71,7 @@ impl Messaging for FvmMessenger { | |||
params: &RawBytes, | |||
value: &TokenAmount, | |||
) -> Result<Receipt> { | |||
let params = RawBytes::new(fvm_ipld_encoding::to_vec(¶ms)?); | |||
Ok(send::send(to, method, params, value.clone())?) | |||
Ok(send::send(to, method, params.clone(), value.clone())?) |
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.
👍 thanks
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.
I want to have a further look at this later. I think every time we call this, we're creating a RawBytes
at the call site to serialise some params struct. Might be better to just move ownership (of the RawBytes
) in that case to avoid the clone and save a little gas.
@@ -12,11 +13,14 @@ pub trait FRC46TokenReceiver { | |||
/// the receiving actor can immediately utilise the received funds. If the receiver wishes to | |||
/// reject the incoming transfer, this function should abort which will cause the token actor | |||
/// to rollback the transaction. | |||
fn tokens_received(params: TokensReceivedParams); | |||
fn receive(token_type: TokenType, params: FRC46TokenReceived); |
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.
Perhaps generalise this to be a UniversalReceiver trait, and with the params argument here being raw bytes. We're going to want essentially the same thing for NFT (so perhaps this will move out of this crate to a new fil_universal_receiver crate too).
But you could convince me that being generic for all receivers is out of scope here.
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.
Moving things around can wait for a follow-up of course
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.
Updated to this:
fn receive(params: UniversalReceiverParams);
I've also added more comments on it and the UniversalReceiverParams
which hopefully explain things clearly.
Moving things around can wait for a follow-up of course
Added issue #94 for this
Implements the universal receiver hook as detailed in FRC-0046
Also makes a change to our
FvmMessenger
which fixes an issue I had with actor-to-actor messaging. The receiver actor example can now deserialise and inspect details of incoming transfers