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

Support function in smart contract #1173

Closed
2 tasks done
samuelmanzanera opened this issue Jul 12, 2023 · 1 comment
Closed
2 tasks done

Support function in smart contract #1173

samuelmanzanera opened this issue Jul 12, 2023 · 1 comment
Assignees
Labels
AEIP feature New feature request smart contracts Involve smart contracts

Comments

@samuelmanzanera
Copy link
Member

samuelmanzanera commented Jul 12, 2023

Is your feature request related to a problem?

Sometimes in smart contract we want to extract some part of the code to be reusable for multiple blocks or to structure more your code.
Since the AEIP17, we introduced a way to use function and to expose some through JSON rpc.

Describe the solution you'd like

To support this feature, we should adapt the interpreter parser to support function capability.

  • Private function

We have to support this new syntax

fun myFun do
# Do something
end

Function can have 0 or N arity

They can only be called with the smart contract actions or condition blocks

  • Pubilc function (exported)

We have to support this new syntax

export fun myFun do
  # Do something and return publically
end

Function can have 0 or N arity

They can be called by both private functions, actions or conditions blocks

Their scope should be limited: the parser should prevent :

  • to mutate state
  • use I/O functions
  • contain loops to a certain amount of iterations or complexity

A default allowed complexity has to be defined to be consumed on each instruction (aka gas) limiting the execution of the external functions.

Additional context

No response

Epic

No response

@samuelmanzanera samuelmanzanera added feature New feature request smart contracts Involve smart contracts AEIP labels Jul 12, 2023
@Neylix
Copy link
Member

Neylix commented Aug 10, 2023

First implementations in #1181 #1199 #1202 #1212

Remaining tasks is complexity

@Neylix Neylix closed this as completed Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AEIP feature New feature request smart contracts Involve smart contracts
Projects
Status: Done 🍻
Development

No branches or pull requests

3 participants