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

Add public function that retrieves RequestContext for a Request #174

Open
Tracked by #49
emizzle opened this issue Sep 17, 2024 · 4 comments
Open
Tracked by #49

Add public function that retrieves RequestContext for a Request #174

emizzle opened this issue Sep 17, 2024 · 4 comments
Assignees
Labels
Marketplace See https://miro.com/app/board/uXjVNZ03E-c=/ for details

Comments

@emizzle
Copy link
Collaborator

emizzle commented Sep 17, 2024

A public view function that retrieves the RequestContext of a StorageRequest should be added to the Marketplace contract. It will replace a few other view functions currently exposed, and add more information. This will allow the Codex client to expose this information in the REST API.

The following fields should be exposed from the RequestContext struct:

  • state
  • slotsFilled
  • startedAt
  • endsAt

This view function will replace the following functions:

  • requestEnd
  • requestState
  • requestExpiry
@emizzle
Copy link
Collaborator Author

emizzle commented Sep 17, 2024

@2-towns from our discussion at the offsite 👍

@2-towns
Copy link

2-towns commented Jan 15, 2025

The current functions requestEnd, requestState and requestExpiry are containing some business logic. Here is an example:

  function requestState(
    RequestId requestId
  ) public view requestIsKnown(requestId) returns (RequestState) {
    RequestContext storage context = _requestContexts[requestId];
    if (
      context.state == RequestState.New &&
      block.timestamp > requestExpiry(requestId)
    ) {
      return RequestState.Cancelled;
    } else if (
      (context.state == RequestState.Started ||
        context.state == RequestState.New) && block.timestamp > context.endsAt
    ) {
      return RequestState.Finished;
    } else {
      return context.state;
    }
  }

So when you say that the new view will replace these functions, it should include that business logic right ?

@emizzle
Copy link
Collaborator Author

emizzle commented Jan 16, 2025

Notes from discussion:
Public view requestContext would call requestState, requestEnd, requestExpiry (which will be made private)

Ice for now as lower priority

@2-towns
Copy link

2-towns commented Jan 16, 2025

Notes from discussion:
Public view requestContext would call requestState, requestEnd, requestExpiry (which will be made private)

Yes, and since those three methods can be called internally by the contract itself, it is better to keep them separate to avoid extra calculations and save gas costs.

@2-towns 2-towns added the Marketplace See https://miro.com/app/board/uXjVNZ03E-c=/ for details label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Marketplace See https://miro.com/app/board/uXjVNZ03E-c=/ for details
Projects
None yet
Development

No branches or pull requests

2 participants