Skip to content

Commit

Permalink
[DX-3352] feat: experimental orderbook and zkevm api modules (#147)
Browse files Browse the repository at this point in the history
* feat: added experimental module immutable orderbook

* feat: added experimental module immutable zkevm api

* feat: updated uplugin with new modules

* fix: modified defectively generated code

* fix: ignore openapi scheme files during workflow checks
  • Loading branch information
YermekG authored Oct 29, 2024
1 parent 570d0a4 commit 0b44931
Show file tree
Hide file tree
Showing 492 changed files with 47,143 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@
VALIDATE_CPP: false
VALIDATE_CSHARP: false
VALIDATE_CLANG_FORMAT: false
FILTER_REGEX_EXCLUDE: .*/Web/index.js
FILTER_REGEX_EXCLUDE: '.*\/openapi\.json|.*\/Web\/index\.js'
10 changes: 10 additions & 0 deletions Immutable.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
"Name": "ImmutableEditor",
"Type": "Editor",
"LoadingPhase": "Default"
},
{
"Name": "ImmutableOrderbook",
"Type": "Runtime",
"LoadingPhase": "Default"
},
{
"Name": "ImmutablezkEVMAPI",
"Type": "Runtime",
"LoadingPhase": "Default"
}
],
"Plugins": [
Expand Down
31 changes: 31 additions & 0 deletions Source/Experimental/ImmutableOrderbook/ImmutableOrderbook.Build.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* TS SDK API
* running ts sdk as an 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.
*/

using System;
using System.IO;
using UnrealBuildTool;

public class ImmutableOrderbook : ModuleRules
{
public ImmutableOrderbook(ReadOnlyTargetRules Target) : base(Target)
{
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
"HTTP",
"Json",
}
);
PCHUsage = PCHUsageMode.NoPCHs;
}
}
111 changes: 111 additions & 0 deletions Source/Experimental/ImmutableOrderbook/Private/APIAction.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/**
* TS SDK API
* running ts sdk as an 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 "APIAction.h"

#include "ImmutableOrderbookModule.h"
#include "APIHelpers.h"

#include "Templates/SharedPointer.h"

namespace ImmutableOrderbook
{

inline FString ToString(const APIAction::TypeEnum& Value)
{
switch (Value)
{
case APIAction::TypeEnum::Transaction:
return TEXT("TRANSACTION");
case APIAction::TypeEnum::Signable:
return TEXT("SIGNABLE");
}

UE_LOG(LogImmutableOrderbook, Error, TEXT("Invalid APIAction::TypeEnum Value (%d)"), (int)Value);
return TEXT("");
}

FString APIAction::EnumToString(const APIAction::TypeEnum& EnumValue)
{
return ToString(EnumValue);
}

inline bool FromString(const FString& EnumAsString, APIAction::TypeEnum& Value)
{
static TMap<FString, APIAction::TypeEnum> StringToEnum = {
{ TEXT("TRANSACTION"), APIAction::TypeEnum::Transaction },
{ TEXT("SIGNABLE"), APIAction::TypeEnum::Signable }, };

const auto Found = StringToEnum.Find(EnumAsString);
if(Found)
Value = *Found;

return Found != nullptr;
}

bool APIAction::EnumFromString(const FString& EnumAsString, APIAction::TypeEnum& EnumValue)
{
return FromString(EnumAsString, EnumValue);
}

inline void WriteJsonValue(JsonWriter& Writer, const APIAction::TypeEnum& Value)
{
WriteJsonValue(Writer, ToString(Value));
}

inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, APIAction::TypeEnum& Value)
{
FString TmpValue;
if (JsonValue->TryGetString(TmpValue))
{
if(FromString(TmpValue, Value))
return true;
}
return false;
}

void APIAction::WriteJson(JsonWriter& Writer) const
{
Writer->WriteObjectStart();
if (PopulatedTransactions.IsSet())
{
Writer->WriteIdentifierPrefix(TEXT("populatedTransactions")); WriteJsonValue(Writer, PopulatedTransactions.GetValue());
}
if (Purpose.IsSet())
{
Writer->WriteIdentifierPrefix(TEXT("purpose")); WriteJsonValue(Writer, Purpose.GetValue());
}
Writer->WriteIdentifierPrefix(TEXT("type")); WriteJsonValue(Writer, Type);
if (Message.IsSet())
{
Writer->WriteIdentifierPrefix(TEXT("message")); WriteJsonValue(Writer, Message.GetValue());
}
Writer->WriteObjectEnd();
}

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

bool ParseSuccess = true;

ParseSuccess &= TryGetJsonValue(*Object, TEXT("populatedTransactions"), PopulatedTransactions);
ParseSuccess &= TryGetJsonValue(*Object, TEXT("purpose"), Purpose);
ParseSuccess &= TryGetJsonValue(*Object, TEXT("type"), Type);
ParseSuccess &= TryGetJsonValue(*Object, TEXT("message"), Message);

return ParseSuccess;
}

}
47 changes: 47 additions & 0 deletions Source/Experimental/ImmutableOrderbook/Private/APIBaseModel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* TS SDK API
* running ts sdk as an 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 "APIBaseModel.h"

namespace ImmutableOrderbook
{

bool HttpRetryManager::Tick(float DeltaTime)
{
FManager::Update();
return true;
}

HttpRetryParams::HttpRetryParams(const FRetryLimitCountSetting& InRetryLimitCountOverride /*= FRetryLimitCountSetting()*/,
const FRetryTimeoutRelativeSecondsSetting& InRetryTimeoutRelativeSecondsOverride /*= FRetryTimeoutRelativeSecondsSetting()*/,
const FRetryResponseCodes& InRetryResponseCodes /*= FRetryResponseCodes()*/,
const FRetryVerbs& InRetryVerbs /*= FRetryVerbs()*/,
const FRetryDomainsPtr& InRetryDomains /*= FRetryDomainsPtr() */)
: RetryLimitCountOverride(InRetryLimitCountOverride)
, RetryTimeoutRelativeSecondsOverride(InRetryTimeoutRelativeSecondsOverride)
, RetryResponseCodes(InRetryResponseCodes)
, RetryVerbs(InRetryVerbs)
, RetryDomains(InRetryDomains)
{
}

void Response::SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode)
{
ResponseCode = InHttpResponseCode;
SetSuccessful(EHttpResponseCodes::IsOk(InHttpResponseCode));
if(InHttpResponseCode == EHttpResponseCodes::RequestTimeout)
{
SetResponseString(TEXT("Request Timeout"));
}
}

}
41 changes: 41 additions & 0 deletions Source/Experimental/ImmutableOrderbook/Private/APIBigNumberish.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* TS SDK API
* running ts sdk as an 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 "APIBigNumberish.h"

#include "ImmutableOrderbookModule.h"
#include "APIHelpers.h"

#include "Templates/SharedPointer.h"

namespace ImmutableOrderbook
{

void APIBigNumberish::WriteJson(JsonWriter& Writer) const
{
Writer->WriteObjectStart();
Writer->WriteObjectEnd();
}

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

bool ParseSuccess = true;


return ParseSuccess;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* TS SDK API
* running ts sdk as an 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 "APICancelOrders200Response.h"

#include "ImmutableOrderbookModule.h"
#include "APIHelpers.h"

#include "Templates/SharedPointer.h"

namespace ImmutableOrderbook
{

void APICancelOrders200Response::WriteJson(JsonWriter& Writer) const
{
Writer->WriteObjectStart();
if (Result.IsSet())
{
Writer->WriteIdentifierPrefix(TEXT("result")); WriteJsonValue(Writer, Result.GetValue());
}
Writer->WriteObjectEnd();
}

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

bool ParseSuccess = true;

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

return ParseSuccess;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* TS SDK API
* running ts sdk as an 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 "APICancelOrders200ResponseResult.h"

#include "ImmutableOrderbookModule.h"
#include "APIHelpers.h"

#include "Templates/SharedPointer.h"

namespace ImmutableOrderbook
{

void APICancelOrders200ResponseResult::WriteJson(JsonWriter& Writer) const
{
Writer->WriteObjectStart();
if (FailedCancellations.IsSet())
{
Writer->WriteIdentifierPrefix(TEXT("failed_cancellations")); WriteJsonValue(Writer, FailedCancellations.GetValue());
}
if (PendingCancellations.IsSet())
{
Writer->WriteIdentifierPrefix(TEXT("pending_cancellations")); WriteJsonValue(Writer, PendingCancellations.GetValue());
}
if (SuccessfulCancellations.IsSet())
{
Writer->WriteIdentifierPrefix(TEXT("successful_cancellations")); WriteJsonValue(Writer, SuccessfulCancellations.GetValue());
}
Writer->WriteObjectEnd();
}

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

bool ParseSuccess = true;

ParseSuccess &= TryGetJsonValue(*Object, TEXT("failed_cancellations"), FailedCancellations);
ParseSuccess &= TryGetJsonValue(*Object, TEXT("pending_cancellations"), PendingCancellations);
ParseSuccess &= TryGetJsonValue(*Object, TEXT("successful_cancellations"), SuccessfulCancellations);

return ParseSuccess;
}

}
Loading

0 comments on commit 0b44931

Please sign in to comment.