Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

[Feature Request] Any function can be an entry point-- support in forthcoming Solana transaction interface. #161

Open
3 of 5 tasks
nvjle opened this issue May 19, 2023 · 4 comments · Fixed by #251
Open
3 of 5 tasks
Assignees
Labels
enhancement New feature or request

Comments

@nvjle
Copy link

nvjle commented May 19, 2023

Currently for compiler bring-up/debug, we only support a single entry point specified as the script main.

In Move, however, any module function can be an entry point. This is specified via the entry keyword on the function definition, and this is the common way things are done in Move-based chains such as Aptos.

Moreover, client-callable entry functions can take any argument the user wishes, making for a natural programming model. Consider the Aptos coin module:

/// This module provides the foundation for typesafe Coins.
module aptos_framework::coin {
    ...
   /// Transfers `amount` of coins `CoinType` from `from` to `to`.
    public entry fun transfer<CoinType>(
        from: &signer,
        to: address,
        amount: u64,
    ) acquires CoinStore {
        let coin = withdraw<CoinType>(from, amount);
        deposit(to, coin);
    }
 ...

There is no script-- the user client can directly invoke coin::transfer, for example:

let txn_hash = coin_client
    .transfer(&mut alice, bob.address(), 1_000, None)
    .await
    .context("Failed to submit transaction to transfer coins")?; 

The ask is to have a similarly flexible and natural programming model.

See, e.g.,
https://github.com/aptos-labs/aptos-core/tree/main/sdk/src/transaction_builder.rs and
https://github.com/aptos-labs/aptos-core/tree/main/sdk/src/coin_client.rs
for some ideas.

Aptos core: https://github.com/aptos-labs/aptos-core

@nvjle nvjle added the enhancement New feature or request label May 19, 2023
@dmakarov
Copy link
Collaborator

dmakarov commented Jun 1, 2023

I'd like to assign this issue to myself, unless someone is already making progress on this.

@nvjle
Copy link
Author

nvjle commented Jun 1, 2023

I'd like to assign this issue to myself, unless someone is already making progress on this.

Please do 👍

@dmakarov dmakarov self-assigned this Jun 1, 2023
@nvjle nvjle linked a pull request Jul 26, 2023 that will close this issue
@dmakarov
Copy link
Collaborator

Partial implementation is added in #251

@dmakarov
Copy link
Collaborator

#260, #266, and #273 resolve this for now. Updates will be necessary when Solana Runtime support for Move is finalized.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants