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

SC: add get_calls/0 action #822

Merged
merged 12 commits into from
Jan 26, 2023

Conversation

bchamagne
Copy link
Member

@bchamagne bchamagne commented Jan 12, 2023

Description

This PR aims at adding a get_calls/1 function to the smart contracts' actions.
This function can be used to create aggregator contracts that do not do anything until some threshold.
I found few issues along the way that I will create and fix outside of this PR.

  • Create a get_calls/0 that will automatically add the contract.address
  • Update smart contract documentation

Should the get_calls/1 be available outside the action block?

Fixes #512

Type of change

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

How Has This Been Tested?

I have tested with this contract:

condition inherit: [
	type: true,
	content: true,
	uco_transfers: true
]

condition transaction: [
	uco_transfers: size() > 0
]

actions triggered_by: transaction do
	transactions = get_calls(contract.address)
	set_content size(transactions)
	set_type transfer
	add_uco_transfer to: "000030831178cd6a49fe446778455a7a980729a293bfa16b0a1d2743935db210da76", amount: 1337
end

When I trigger this contract, a new transaction in the contract chain have the content updated to "1".

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

@bchamagne bchamagne marked this pull request as draft January 12, 2023 08:56
@samuelmanzanera
Copy link
Member

Should the get_calls/1 be available outside the action block?

I think for now, we can keep it in the actions block

@bchamagne bchamagne marked this pull request as ready for review January 12, 2023 16:59
@bchamagne bchamagne changed the title Draft: add get_calls/1 SC action add get_calls/1 SC action Jan 13, 2023
@bchamagne bchamagne added feature New feature request smart contracts Involve smart contracts labels Jan 13, 2023
@bchamagne bchamagne changed the title add get_calls/1 SC action add get_calls/0 and get_calls/1 SC actions Jan 13, 2023
@bchamagne
Copy link
Member Author

As discussed with @Neylix , we should remove the get_calls/1 for 2 reasons:

  • 1: no use case yet
  • 2: actual implementation look at calls in local node, which is fine for contract's address, but not for other contract's address. We would have to download the transactions from network. Downloading hundreds of them might not be efficient.

What do you think @samuelmanzanera ?

@samuelmanzanera
Copy link
Member

As discussed with @Neylix , we should remove the get_calls/1 for 2 reasons:

  • 1: no use case yet
  • 2: actual implementation look at calls in local node, which is fine for contract's address, but not for other contract's address. We would have to download the transactions from network. Downloading hundreds of them might not be efficient.

What do you think @samuelmanzanera ?

Indeed, the initial goal of the issue was to get the inputs the current contract .
So the initial intention was to have a get_calls/0.

The get_calls/1 was bonus, but will require indeed I/O by fetching for others chains.

I think you can drop the get_calls/1 .
Nevertheless, the work already done would be ok, just removing the whitelisting

@bchamagne bchamagne changed the title add get_calls/0 and get_calls/1 SC actions SC: add get_calls/0 action Jan 16, 2023
@Neylix Neylix merged commit 5441172 into archethic-foundation:develop Jan 26, 2023
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
None yet
Development

Successfully merging this pull request may close these issues.

Add the possibility to get the inputs in the smart contract
3 participants