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

Smart contract functions without args #1181

Merged

Conversation

herissondev
Copy link
Contributor

Description

Add possibility to create and use custom functions in Smart contracts.
However, I have a failing test which is not concerned by anything i changed:

doctest Archethic.Crypto.sign/2 (28) (CryptoTest)
     test/archethic/crypto_test.exs:15

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Multiple tests on :

  • FunctionInterpreter
  • ActionInterpreter
  • ConditionInterpreter
  • Interpreter

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@Neylix Neylix added feature New feature request smart contracts Involve smart contracts labels Jul 21, 2023
@Neylix Neylix requested review from bchamagne and Neylix July 21, 2023 08:06
lib/archethic/contracts.ex Outdated Show resolved Hide resolved
lib/archethic/contracts/contract.ex Show resolved Hide resolved
lib/archethic/contracts/interpreter/action_interpreter.ex Outdated Show resolved Hide resolved
lib/archethic/contracts/interpreter/common_interpreter.ex Outdated Show resolved Hide resolved
lib/archethic/contracts/interpreter/common_interpreter.ex Outdated Show resolved Hide resolved
lib/archethic/contracts/interpreter/scope.ex Outdated Show resolved Hide resolved
lib/archethic/contracts/interpreter/scope.ex Show resolved Hide resolved
test/archethic/contracts/interpreter_test.exs Show resolved Hide resolved
@herissondev herissondev requested a review from Neylix July 24, 2023 10:00
@Neylix Neylix merged commit c5952b5 into archethic-foundation:develop Jul 25, 2023
1 check passed
Neylix added a commit to Neylix/archethic-node that referenced this pull request Aug 1, 2023
* function parsing

* function parsing tests

* interpreter parse functions

* contract add functions to struct

* function_interpreter check if function exist

* get available functions and pass them to parsers

* add functions to scope

* add functions contract struct

* allow call to functions

* postwalk functions common_interpreter.ex

* remove functions postwalk function_interpreter.ex

* allow custom function call in action_interpreter.ex

* function call return value common_interpreter.ex

* function_interpreter.ex add constants in scope

* remove add_function as not used

* add possibility to pass existing custom functions to sanitize_parse_execute

* pass functions to action interpreter scope's

* move function prewalk to not catch "for var..."

* function_interpreter test parsing and execute

* create execute_function_ast for scope

* custom function matches check_types

* test function parsing in action_interpreter

* test function execution in action_interpreter

* format

* allow function calls in condition block

* fix function test

* test function in conditions

* add functions to condition constatns

* add functions test in interpreter

* fucntions key to string

* function_key function

* format

* case to if

* function_key to tuple

* add get_function_ast doc

* merge public_functions and private_functions into functions

* remove default functions_keys

* remove unused function

* move test to interpreter_test.exs

* format

* pass function_keys in condition_interpreter.ex's postwalk

* add function_key type

* fix spec and doc

* scope test

* Wrap single line function in ast block

* Fix @SPEC

* Rename get_functions to get_functions_keys

* Use String interpolation

---------

Co-authored-by: Neylix <[email protected]>
@Neylix Neylix mentioned this pull request Aug 10, 2023
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request smart contracts Involve smart contracts
Projects
Status: Done 🍻
Development

Successfully merging this pull request may close these issues.

3 participants