-
Notifications
You must be signed in to change notification settings - Fork 10
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
Multiple Dropper v0.2.0 API improvements #299
Conversation
Now the caller can specify `contract_id` or `contract_address` as a query parameter. At least one of those parameters should be provided. `registered_contract_id` in response is now `contract_id`. The response also contains a `contract_address` field.
This allows them to create call requests by contract_id *or* by contract_address. I have added `"contract_id"` and `"contract_address"` keys to `CreateCallRequestsAPIRequest`: ```python class CreateCallRequestsAPIRequest(BaseModel): contract_id: Optional[UUID] = None contract_address: Optional[str] = None specifications: List[CallSpecification] = Field(default_factory=list) ttl_days: Optional[int] = None ``` At least one of those keys must have a non-null value. Resolves #298
7e0b57b
to
28e0c35
Compare
Using Pydantic root validator to ensure that at least one of contract_id or contract_address is provided in the request body (these are optional fields in the JSON).
This makes the API more RESTful. - - - The `POST /contracts/` endpoint also now displays the `contract_type` enum values in API docs. Resolves #276 - - - Also added a PUT `/contracts/<contract_id>` endpoint, which allows users to modify the title, description, and image URI for a contract. These changes only apply to the Moonstream Engine API. Resolves #296
The constraint now includes `moonstream_user_id`. This allows multiple users to register the same contract. Resolves #295
when `call_requests` are created from the API. Also fixed a bug where the `CallRequest` response object did not respect `null` `expired_at` fields.
@bugout-dev check
|
@@ -160,6 +160,7 @@ class RegisteredContract(Base): # type: ignore | |||
__table_args__ = ( | |||
UniqueConstraint( | |||
"blockchain", | |||
"moonstream_user_id", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure if we run migration we will not get error bacause of hitting uniqe constraint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this feature was just launched into production and there are only two rows in production database under this relation currently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lg
Changes
Queries and responses on
/contracts/requests
now showcontract_address
Now the caller can specify
contract_id
orcontract_address
as a query parameter.At least one of those parameters should be provided.
registered_contract_id
in response is nowcontract_id
.The response also contains a
contract_address
field.Resolves #283
Create
call_requests
using contract ID or contract addressThis change allows users to create call requests by posting to
/contracts/requests
with a JSON body which contains a"contract_id"
key or a"contract_address"
key.This change also removes the old
/contracts/<contract_id>/requests
POST endpoint.Resolves #298
Moved
POST /contracts/register
toPOST /contracts/
This makes the API more RESTful.
POST /contracts/
documentation showscontract_type
as an enumPreviously, this parameter of the request body was being displayed as a string.
Resolves #276
Allow users to edit registered contracts
added a PUT
/contracts/<contract_id>
endpoint, which allows users to modify the title, description, and image URI for a contract. These changes only apply to the Moonstream Engine API.Resolves #296
Updated
waggle
to respect new API changes/contracts/requests
call_requests
using contract ID or contract addressUnique constraint on
registered_contracts
modified to includemoonstream_user_id
This allows different users to register the same contract under their respective accounts.
Resolves #295
ttl_days
is not longer directly inserted into raw SQLAlso fixed a bug on how the list call requests endpoint handled call requests with
null
expires_at
fields - it led to a 500 error before.Resolves #300
How to test these changes?
Tested manually.