Skip to content

Commit

Permalink
chore: updated zkevm api (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
YermekG authored Oct 31, 2024
1 parent 0b44931 commit 5774b10
Show file tree
Hide file tree
Showing 20 changed files with 674 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ void APIChainWithDetails::WriteJson(JsonWriter& Writer) const
{
Writer->WriteIdentifierPrefix(TEXT("rpc_url")); WriteJsonValue(Writer, RpcUrl.GetValue());
}
if (OperatorAllowlistAddress.IsSet())
{
Writer->WriteIdentifierPrefix(TEXT("operator_allowlist_address")); WriteJsonValue(Writer, OperatorAllowlistAddress.GetValue());
}
if (MinterAddress.IsSet())
{
Writer->WriteIdentifierPrefix(TEXT("minter_address")); WriteJsonValue(Writer, MinterAddress.GetValue());
}
Writer->WriteObjectEnd();
}

Expand All @@ -43,6 +51,8 @@ bool APIChainWithDetails::FromJson(const TSharedPtr<FJsonValue>& JsonValue)
ParseSuccess &= TryGetJsonValue(*Object, TEXT("id"), Id);
ParseSuccess &= TryGetJsonValue(*Object, TEXT("name"), Name);
ParseSuccess &= TryGetJsonValue(*Object, TEXT("rpc_url"), RpcUrl);
ParseSuccess &= TryGetJsonValue(*Object, TEXT("operator_allowlist_address"), OperatorAllowlistAddress);
ParseSuccess &= TryGetJsonValue(*Object, TEXT("minter_address"), MinterAddress);

return ParseSuccess;
}
Expand Down
47 changes: 47 additions & 0 deletions Source/Experimental/ImmutablezkEVMAPI/Private/APIFilter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Immutable zkEVM API
* Immutable Multi Rollup API
*
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator
* https://github.com/OpenAPITools/openapi-generator
* Do not edit the class manually.
*/

#include "APIFilter.h"

#include "ImmutablezkEVMAPIModule.h"
#include "APIHelpers.h"

#include "Templates/SharedPointer.h"

namespace ImmutablezkEVMAPI
{

void APIFilter::WriteJson(JsonWriter& Writer) const
{
Writer->WriteObjectStart();
Writer->WriteIdentifierPrefix(TEXT("name")); WriteJsonValue(Writer, Name);
Writer->WriteIdentifierPrefix(TEXT("values")); WriteJsonValue(Writer, Values);
Writer->WriteIdentifierPrefix(TEXT("omitted_values_count")); WriteJsonValue(Writer, OmittedValuesCount);
Writer->WriteObjectEnd();
}

bool APIFilter::FromJson(const TSharedPtr<FJsonValue>& JsonValue)
{
const TSharedPtr<FJsonObject>* Object;
if (!JsonValue->TryGetObject(Object))
return false;

bool ParseSuccess = true;

ParseSuccess &= TryGetJsonValue(*Object, TEXT("name"), Name);
ParseSuccess &= TryGetJsonValue(*Object, TEXT("values"), Values);
ParseSuccess &= TryGetJsonValue(*Object, TEXT("omitted_values_count"), OmittedValuesCount);

return ParseSuccess;
}

}
47 changes: 47 additions & 0 deletions Source/Experimental/ImmutablezkEVMAPI/Private/APIFilterResult.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Immutable zkEVM API
* Immutable Multi Rollup API
*
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator
* https://github.com/OpenAPITools/openapi-generator
* Do not edit the class manually.
*/

#include "APIFilterResult.h"

#include "ImmutablezkEVMAPIModule.h"
#include "APIHelpers.h"

#include "Templates/SharedPointer.h"

namespace ImmutablezkEVMAPI
{

void APIFilterResult::WriteJson(JsonWriter& Writer) const
{
Writer->WriteObjectStart();
Writer->WriteIdentifierPrefix(TEXT("chain")); WriteJsonValue(Writer, Chain);
Writer->WriteIdentifierPrefix(TEXT("contract_address")); WriteJsonValue(Writer, ContractAddress);
Writer->WriteIdentifierPrefix(TEXT("filters")); WriteJsonValue(Writer, Filters);
Writer->WriteObjectEnd();
}

bool APIFilterResult::FromJson(const TSharedPtr<FJsonValue>& JsonValue)
{
const TSharedPtr<FJsonObject>* Object;
if (!JsonValue->TryGetObject(Object))
return false;

bool ParseSuccess = true;

ParseSuccess &= TryGetJsonValue(*Object, TEXT("chain"), Chain);
ParseSuccess &= TryGetJsonValue(*Object, TEXT("contract_address"), ContractAddress);
ParseSuccess &= TryGetJsonValue(*Object, TEXT("filters"), Filters);

return ParseSuccess;
}

}
45 changes: 45 additions & 0 deletions Source/Experimental/ImmutablezkEVMAPI/Private/APIFilterValue.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Immutable zkEVM API
* Immutable Multi Rollup API
*
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator
* https://github.com/OpenAPITools/openapi-generator
* Do not edit the class manually.
*/

#include "APIFilterValue.h"

#include "ImmutablezkEVMAPIModule.h"
#include "APIHelpers.h"

#include "Templates/SharedPointer.h"

namespace ImmutablezkEVMAPI
{

void APIFilterValue::WriteJson(JsonWriter& Writer) const
{
Writer->WriteObjectStart();
Writer->WriteIdentifierPrefix(TEXT("value")); WriteJsonValue(Writer, Value);
Writer->WriteIdentifierPrefix(TEXT("nft_count")); WriteJsonValue(Writer, NftCount);
Writer->WriteObjectEnd();
}

bool APIFilterValue::FromJson(const TSharedPtr<FJsonValue>& JsonValue)
{
const TSharedPtr<FJsonObject>* Object;
if (!JsonValue->TryGetObject(Object))
return false;

bool ParseSuccess = true;

ParseSuccess &= TryGetJsonValue(*Object, TEXT("value"), Value);
ParseSuccess &= TryGetJsonValue(*Object, TEXT("nft_count"), NftCount);

return ParseSuccess;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Immutable zkEVM API
* Immutable Multi Rollup API
*
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator
* https://github.com/OpenAPITools/openapi-generator
* Do not edit the class manually.
*/

#include "APIListFiltersResult.h"

#include "ImmutablezkEVMAPIModule.h"
#include "APIHelpers.h"

#include "Templates/SharedPointer.h"

namespace ImmutablezkEVMAPI
{

void APIListFiltersResult::WriteJson(JsonWriter& Writer) const
{
Writer->WriteObjectStart();
Writer->WriteIdentifierPrefix(TEXT("result")); WriteJsonValue(Writer, Result);
Writer->WriteIdentifierPrefix(TEXT("page")); WriteJsonValue(Writer, Page);
Writer->WriteObjectEnd();
}

bool APIListFiltersResult::FromJson(const TSharedPtr<FJsonValue>& JsonValue)
{
const TSharedPtr<FJsonObject>* Object;
if (!JsonValue->TryGetObject(Object))
return false;

bool ParseSuccess = true;

ParseSuccess &= TryGetJsonValue(*Object, TEXT("result"), Result);
ParseSuccess &= TryGetJsonValue(*Object, TEXT("page"), Page);

return ParseSuccess;
}

}
2 changes: 0 additions & 2 deletions Source/Experimental/ImmutablezkEVMAPI/Private/APIListing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ void APIListing::WriteJson(JsonWriter& Writer) const
Writer->WriteObjectStart();
Writer->WriteIdentifierPrefix(TEXT("listing_id")); WriteJsonValue(Writer, ListingId);
Writer->WriteIdentifierPrefix(TEXT("price_details")); WriteJsonValue(Writer, PriceDetails);
Writer->WriteIdentifierPrefix(TEXT("converted_prices")); WriteJsonValue(Writer, ConvertedPrices);
Writer->WriteIdentifierPrefix(TEXT("token_id")); WriteJsonValue(Writer, TokenId);
Writer->WriteIdentifierPrefix(TEXT("contract_address")); WriteJsonValue(Writer, ContractAddress);
Writer->WriteIdentifierPrefix(TEXT("creator")); WriteJsonValue(Writer, Creator);
Expand All @@ -43,7 +42,6 @@ bool APIListing::FromJson(const TSharedPtr<FJsonValue>& JsonValue)

ParseSuccess &= TryGetJsonValue(*Object, TEXT("listing_id"), ListingId);
ParseSuccess &= TryGetJsonValue(*Object, TEXT("price_details"), PriceDetails);
ParseSuccess &= TryGetJsonValue(*Object, TEXT("converted_prices"), ConvertedPrices);
ParseSuccess &= TryGetJsonValue(*Object, TEXT("token_id"), TokenId);
ParseSuccess &= TryGetJsonValue(*Object, TEXT("contract_address"), ContractAddress);
ParseSuccess &= TryGetJsonValue(*Object, TEXT("creator"), Creator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ void APIMarketPriceDetails::WriteJson(JsonWriter& Writer) const
Writer->WriteIdentifierPrefix(TEXT("amount")); WriteJsonValue(Writer, Amount);
Writer->WriteIdentifierPrefix(TEXT("fee_inclusive_amount")); WriteJsonValue(Writer, FeeInclusiveAmount);
Writer->WriteIdentifierPrefix(TEXT("fees")); WriteJsonValue(Writer, Fees);
if (ConvertedPrices.IsSet())
{
Writer->WriteIdentifierPrefix(TEXT("converted_prices")); WriteJsonValue(Writer, ConvertedPrices.GetValue());
}
Writer->WriteObjectEnd();
}

Expand All @@ -42,6 +46,7 @@ bool APIMarketPriceDetails::FromJson(const TSharedPtr<FJsonValue>& JsonValue)
ParseSuccess &= TryGetJsonValue(*Object, TEXT("amount"), Amount);
ParseSuccess &= TryGetJsonValue(*Object, TEXT("fee_inclusive_amount"), FeeInclusiveAmount);
ParseSuccess &= TryGetJsonValue(*Object, TEXT("fees"), Fees);
ParseSuccess &= TryGetJsonValue(*Object, TEXT("converted_prices"), ConvertedPrices);

return ParseSuccess;
}
Expand Down
27 changes: 27 additions & 0 deletions Source/Experimental/ImmutablezkEVMAPI/Private/APIStacksApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,33 @@ void APIStacksApi::HandleResponse(FHttpResponsePtr HttpResponse, bool bSucceeded
InOutResponse.SetHttpResponseCode(EHttpResponseCodes::RequestTimeout);
}

FHttpRequestPtr APIStacksApi::ListFilters(const ListFiltersRequest& Request, const FListFiltersDelegate& Delegate /*= FListFiltersDelegate()*/) const
{
if (!IsValid())
return nullptr;

FHttpRequestRef HttpRequest = CreateHttpRequest(Request);
HttpRequest->SetURL(*(Url + Request.ComputePath()));

for(const auto& It : AdditionalHeaderParams)
{
HttpRequest->SetHeader(It.Key, It.Value);
}

Request.SetupHttpRequest(HttpRequest);

HttpRequest->OnProcessRequestComplete().BindRaw(this, &APIStacksApi::OnListFiltersResponse, Delegate);
HttpRequest->ProcessRequest();
return HttpRequest;
}

void APIStacksApi::OnListFiltersResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FListFiltersDelegate Delegate) const
{
ListFiltersResponse Response;
HandleResponse(HttpResponse, bSucceeded, Response);
Delegate.ExecuteIfBound(Response);
}

FHttpRequestPtr APIStacksApi::ListStacks(const ListStacksRequest& Request, const FListStacksDelegate& Delegate /*= FListStacksDelegate()*/) const
{
if (!IsValid())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,60 @@
namespace ImmutablezkEVMAPI
{

FString APIStacksApi::ListFiltersRequest::ComputePath() const
{
TMap<FString, FStringFormatArg> PathParams = {
{ TEXT("chain_name"), FStringFormatArg(ToUrlString(ChainName)) },
{ TEXT("contract_address"), FStringFormatArg(ToUrlString(ContractAddress)) } };

FString Path = FString::Format(TEXT("/experimental/chains/{chain_name}/search/filters/{contract_address}"), PathParams);

return Path;
}

void APIStacksApi::ListFiltersRequest::SetupHttpRequest(const FHttpRequestRef& HttpRequest) const
{
static const TArray<FString> Consumes = { };
//static const TArray<FString> Produces = { TEXT("application/json") };

HttpRequest->SetVerb(TEXT("GET"));

}

void APIStacksApi::ListFiltersResponse::SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode)
{
Response::SetHttpResponseCode(InHttpResponseCode);
switch ((int)InHttpResponseCode)
{
case 200:
SetResponseString(TEXT("200 response"));
break;
case 400:
SetResponseString(TEXT("Bad Request (400)"));
break;
case 401:
SetResponseString(TEXT("Unauthorised Request (401)"));
break;
case 403:
SetResponseString(TEXT("Forbidden Request (403)"));
break;
case 404:
SetResponseString(TEXT("The specified resource was not found (404)"));
break;
case 429:
SetResponseString(TEXT("Too Many Requests (429)"));
break;
case 500:
SetResponseString(TEXT("Internal Server Error (500)"));
break;
}
}

bool APIStacksApi::ListFiltersResponse::FromJson(const TSharedPtr<FJsonValue>& JsonValue)
{
return TryGetJsonValue(JsonValue, Content);
}

FString APIStacksApi::ListStacksRequest::ComputePath() const
{
TMap<FString, FStringFormatArg> PathParams = {
Expand Down Expand Up @@ -230,9 +284,9 @@ FString APIStacksApi::SearchStacksRequest::ComputePath() const
{
QueryParams.Add(FString(TEXT("only_if_has_active_listings=")) + ToUrlString(OnlyIfHasActiveListings.GetValue()));
}
if(Trait.IsSet())
if(Traits.IsSet())
{
QueryParams.Add(FString(TEXT("trait=")) + ToUrlString(Trait.GetValue()));
QueryParams.Add(FString(TEXT("traits=")) + ToUrlString(Traits.GetValue()));
}
if(Keyword.IsSet())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class IMMUTABLEZKEVMAPI_API APIChainWithDetails : public Model
FString Name;
/* URL for RPC node */
TOptional<FString> RpcUrl;
/* The address of the Operator Allowlist - https://docs.immutable.com/products/zkevm/minting/royalties/allowlist-spec/ */
TOptional<FString> OperatorAllowlistAddress;
/* The address of the minter used in the Minting API - https://docs.immutable.com/products/zkEVM/minting/minting-api#minting-api-prerequisites */
TOptional<FString> MinterAddress;
};

}
Loading

0 comments on commit 5774b10

Please sign in to comment.