anza-xyz / move

Move compiler targeting llvm supported backends
https://discord.gg/wFgfjG9J
Apache License 2.0
107 stars 32 forks source link

Specification of entry functions in solana-move #380

Open ksolana opened 10 months ago

ksolana commented 10 months ago

As per sui doc: https://docs.sui.io/build/move#entry-functions

In general, an entry function must satisfy the following properties:

    Has the entry modifier. The visibility does not matter. The function can be public, public(friend), or internal.
    Has no return value
    (Optional) Has a mutable reference to an instance of the TxContext struct defined in the [TxContext module](https://github.com/MystenLabs/sui/tree/main/crates/sui-framework/packages/sui-framework/sources/tx_context.move) as the last parameter.

More concretely, the transfer function is public, has no return value, and has three parameters:

    c - Represents a gas object whose ownership is to be transferred.
    recipient - The [address](https://github.com/move-language/move/blob/main/language/documentation/book/src/address.md) of the intended recipient
    _ctx - A mutable reference to an instance of the TxContext struct (in this particular case, this parameter is not actually used in the function's body as indicated by its name starting with _). Because it is unused, the parameter could be removed. The mutable reference to the TxContext is optional for entry functions.

We probably will have something similar and we should be able to check it at compile time.