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 Contracts: Http.request/5 and Http.request_many/2 #1387

Merged
merged 4 commits into from
Apr 23, 2024

Conversation

bchamagne
Copy link
Member

Description

Add a new throw_on_error flag that can be specified to handle the HTTP errors in the contracts.
Fixes #1381

Type of change

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

How Has This Been Tested?

Unit tests & local test with contract such as:

  @version 1

  actions triggered_by: interval, at: "* * * * *" do
    responses = Http.request_many([
      [url: "https://fakerapi.it/api/v1/users?_quantity=1&_gender=male&_seed=cucumber", method: "GET"],
      [url: "https://fakerapi.it/api/v1/users?_quantity=1&_gender=male&_seed=cucumber", method: "GET"],
      [url: "https://fakerapi.it/api/v1/users?_quantity=1&_gender=female&_seed=tomato", method: "GET"],
      [url: "https://fakerapi.it/api/v1/users?_quantity=1&_gender=female&_seed=tomato", method: "GET"],
# should fail (non https)
      [url: "http://fakerapi.it/api/v1/users?_quantity=1&_gender=female&_seed=tomato", method: "GET"],
# should fail (too many urls)
      [url: "https://fakerapi.it/api/v1/users?_quantity=1&_gender=female&_seed=tomato", method: "GET"],
    ], false)

    log(responses)
  end

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 changed the title Smart Contracts: Http.request/5and Http.request_many/2 Smart Contracts: Http.request/5 and Http.request_many/2 Jan 16, 2024
@samuelmanzanera samuelmanzanera added feature New feature request smart contracts Involve smart contracts labels Jan 18, 2024
@bchamagne bchamagne added this to the 1.5.1 milestone Apr 8, 2024
@Neylix Neylix merged commit e428c18 into archethic-foundation:develop Apr 23, 2024
1 check failed
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.

Http.request/request_many flag throw_on_error
3 participants