Skip to content
This repository has been archived by the owner on Jun 22, 2023. It is now read-only.

Commit

Permalink
[SDK 93] Added JumpNet Bridge mutations (#27)
Browse files Browse the repository at this point in the history
* Added templates for `BridgeAsset`, `BridgeAssets`, and `BridgeClaimAsset` mutation
* Added request classes for `BridgeAsset`, `BridgeAssets`, and `BridgeClaimAsset` mutation
* Added Bridge mutations to `IProjectSchema` and `IPlayerSchema`
  • Loading branch information
BishopJohnson committed Nov 8, 2021
1 parent 09bb09b commit 79058f2
Show file tree
Hide file tree
Showing 34 changed files with 1,847 additions and 0 deletions.
108 changes: 108 additions & 0 deletions include/enjinsdk/player/BridgeAsset.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/* Copyright 2021 Enjin Pte. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef ENJINSDK_PLAYERBRIDGEASSET_HPP
#define ENJINSDK_PLAYERBRIDGEASSET_HPP

#include "enjinsdk_export.h"
#include "enjinsdk/internal/AbstractGraphqlRequest.hpp"
#include "enjinsdk/shared/TransactionFragmentArguments.hpp"
#include <optional>
#include <string>

namespace enjin::sdk::player {

/// \brief Request for bridging an asset.
class ENJINSDK_EXPORT BridgeAsset : public graphql::AbstractGraphqlRequest,
public shared::TransactionFragmentArguments<BridgeAsset> {
public:
/// \brief Sole constructor.
BridgeAsset();

~BridgeAsset() override = default;

[[nodiscard]] std::string serialize() const override;

/// \brief Sets the ID of the asset to bridge.
/// \param asset_id The asset ID.
/// \return This request for chaining.
BridgeAsset& set_asset_id(std::string asset_id);

/// \brief Sets the index of the asset to bridge if the asset is an NFT.
/// \param asset_index The asset index.
/// \return This request for chaining.
BridgeAsset& set_asset_index(std::string asset_index);

/// \brief Sets the amount to bridge.
/// \param value The amount.
/// \return This request for chaining.
BridgeAsset& set_value(std::string value);

bool operator==(const BridgeAsset& rhs) const;

bool operator!=(const BridgeAsset& rhs) const;

private:
std::optional<std::string> asset_id;
std::optional<std::string> asset_index;
std::optional<std::string> value;
};

}

namespace enjin::sdk::shared {

template ENJINSDK_EXPORT player::BridgeAsset&
TransactionFragmentArguments<player::BridgeAsset>::set_asset_id_format(models::AssetIdFormat asset_id_format);

template ENJINSDK_EXPORT player::BridgeAsset&
TransactionFragmentArguments<player::BridgeAsset>::set_with_blockchain_data();

template ENJINSDK_EXPORT player::BridgeAsset&
TransactionFragmentArguments<player::BridgeAsset>::set_with_meta();

template ENJINSDK_EXPORT player::BridgeAsset&
TransactionFragmentArguments<player::BridgeAsset>::set_with_encoded_data();

template ENJINSDK_EXPORT player::BridgeAsset&
TransactionFragmentArguments<player::BridgeAsset>::set_with_asset_data();

template ENJINSDK_EXPORT player::BridgeAsset&
TransactionFragmentArguments<player::BridgeAsset>::set_with_signed_txs();

template ENJINSDK_EXPORT player::BridgeAsset&
TransactionFragmentArguments<player::BridgeAsset>::set_with_error();

template ENJINSDK_EXPORT player::BridgeAsset&
TransactionFragmentArguments<player::BridgeAsset>::set_with_nonce();

template ENJINSDK_EXPORT player::BridgeAsset&
TransactionFragmentArguments<player::BridgeAsset>::set_with_state();

template ENJINSDK_EXPORT player::BridgeAsset&
TransactionFragmentArguments<player::BridgeAsset>::set_with_receipt();

template ENJINSDK_EXPORT player::BridgeAsset&
TransactionFragmentArguments<player::BridgeAsset>::set_with_receipt_logs();

template ENJINSDK_EXPORT player::BridgeAsset&
TransactionFragmentArguments<player::BridgeAsset>::set_with_log_event();

template ENJINSDK_EXPORT player::BridgeAsset&
TransactionFragmentArguments<player::BridgeAsset>::set_with_transaction_project_uuid();

}

#endif //ENJINSDK_PLAYERBRIDGEASSET_HPP
103 changes: 103 additions & 0 deletions include/enjinsdk/player/BridgeAssets.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/* Copyright 2021 Enjin Pte. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef ENJINSDK_PLAYERBRIDGEASSETS_HPP
#define ENJINSDK_PLAYERBRIDGEASSETS_HPP

#include "enjinsdk_export.h"
#include "enjinsdk/internal/AbstractGraphqlRequest.hpp"
#include "enjinsdk/shared/TransactionFragmentArguments.hpp"
#include <optional>
#include <string>
#include <vector>

namespace enjin::sdk::player {

/// \brief Request for bridging multiple indices of an NFT in a single transaction.
class ENJINSDK_EXPORT BridgeAssets : public graphql::AbstractGraphqlRequest,
public shared::TransactionFragmentArguments<BridgeAssets> {
public:
/// \brief Sole constructor.
BridgeAssets();

~BridgeAssets() override = default;

[[nodiscard]] std::string serialize() const override;

/// \brief Sets the ID of the asset to bridge.
/// \param asset_id The asset ID.
/// \return This request for chaining.
BridgeAssets& set_asset_id(std::string asset_id);

/// \brief Sets the indices to bridge.
/// \param asset_indices The asset indices.
/// \return This request for chaining.
BridgeAssets& set_asset_indices(std::vector<std::string> asset_indices);

bool operator==(const BridgeAssets& rhs) const;

bool operator!=(const BridgeAssets& rhs) const;

private:
std::optional<std::string> asset_id;
std::optional<std::vector<std::string>> asset_indices;
};

}

namespace enjin::sdk::shared {

template ENJINSDK_EXPORT player::BridgeAssets&
TransactionFragmentArguments<player::BridgeAssets>::set_asset_id_format(models::AssetIdFormat asset_id_format);

template ENJINSDK_EXPORT player::BridgeAssets&
TransactionFragmentArguments<player::BridgeAssets>::set_with_blockchain_data();

template ENJINSDK_EXPORT player::BridgeAssets&
TransactionFragmentArguments<player::BridgeAssets>::set_with_meta();

template ENJINSDK_EXPORT player::BridgeAssets&
TransactionFragmentArguments<player::BridgeAssets>::set_with_encoded_data();

template ENJINSDK_EXPORT player::BridgeAssets&
TransactionFragmentArguments<player::BridgeAssets>::set_with_asset_data();

template ENJINSDK_EXPORT player::BridgeAssets&
TransactionFragmentArguments<player::BridgeAssets>::set_with_signed_txs();

template ENJINSDK_EXPORT player::BridgeAssets&
TransactionFragmentArguments<player::BridgeAssets>::set_with_error();

template ENJINSDK_EXPORT player::BridgeAssets&
TransactionFragmentArguments<player::BridgeAssets>::set_with_nonce();

template ENJINSDK_EXPORT player::BridgeAssets&
TransactionFragmentArguments<player::BridgeAssets>::set_with_state();

template ENJINSDK_EXPORT player::BridgeAssets&
TransactionFragmentArguments<player::BridgeAssets>::set_with_receipt();

template ENJINSDK_EXPORT player::BridgeAssets&
TransactionFragmentArguments<player::BridgeAssets>::set_with_receipt_logs();

template ENJINSDK_EXPORT player::BridgeAssets&
TransactionFragmentArguments<player::BridgeAssets>::set_with_log_event();

template ENJINSDK_EXPORT player::BridgeAssets&
TransactionFragmentArguments<player::BridgeAssets>::set_with_transaction_project_uuid();

}

#endif //ENJINSDK_PLAYERBRIDGEASSETS_HPP
96 changes: 96 additions & 0 deletions include/enjinsdk/player/BridgeClaimAsset.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/* Copyright 2021 Enjin Pte. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef ENJINSDK_PLAYERBRIDGECLAIMASSET_HPP
#define ENJINSDK_PLAYERBRIDGECLAIMASSET_HPP

#include "enjinsdk_export.h"
#include "enjinsdk/internal/AbstractGraphqlRequest.hpp"
#include "enjinsdk/shared/TransactionFragmentArguments.hpp"
#include <optional>
#include <string>

namespace enjin::sdk::player {

/// \brief Request for claiming assets on the bridge.
class ENJINSDK_EXPORT BridgeClaimAsset : public graphql::AbstractGraphqlRequest,
public shared::TransactionFragmentArguments<BridgeClaimAsset> {
public:
/// \brief Sole constructor.
BridgeClaimAsset();

~BridgeClaimAsset() override = default;

[[nodiscard]] std::string serialize() const override;

/// \brief Sets which assets to filter for by their ID.
/// \param asset_id The asset IDs to filter for.
/// \return This request for chaining.
BridgeClaimAsset& set_asset_id(std::string asset_id);

bool operator==(const BridgeClaimAsset& rhs) const;

bool operator!=(const BridgeClaimAsset& rhs) const;

private:
std::optional<std::string> asset_id;
};

}

namespace enjin::sdk::shared {

template ENJINSDK_EXPORT player::BridgeClaimAsset&
TransactionFragmentArguments<player::BridgeClaimAsset>::set_asset_id_format(models::AssetIdFormat asset_id_format);

template ENJINSDK_EXPORT player::BridgeClaimAsset&
TransactionFragmentArguments<player::BridgeClaimAsset>::set_with_blockchain_data();

template ENJINSDK_EXPORT player::BridgeClaimAsset&
TransactionFragmentArguments<player::BridgeClaimAsset>::set_with_meta();

template ENJINSDK_EXPORT player::BridgeClaimAsset&
TransactionFragmentArguments<player::BridgeClaimAsset>::set_with_encoded_data();

template ENJINSDK_EXPORT player::BridgeClaimAsset&
TransactionFragmentArguments<player::BridgeClaimAsset>::set_with_asset_data();

template ENJINSDK_EXPORT player::BridgeClaimAsset&
TransactionFragmentArguments<player::BridgeClaimAsset>::set_with_signed_txs();

template ENJINSDK_EXPORT player::BridgeClaimAsset&
TransactionFragmentArguments<player::BridgeClaimAsset>::set_with_error();

template ENJINSDK_EXPORT player::BridgeClaimAsset&
TransactionFragmentArguments<player::BridgeClaimAsset>::set_with_nonce();

template ENJINSDK_EXPORT player::BridgeClaimAsset&
TransactionFragmentArguments<player::BridgeClaimAsset>::set_with_state();

template ENJINSDK_EXPORT player::BridgeClaimAsset&
TransactionFragmentArguments<player::BridgeClaimAsset>::set_with_receipt();

template ENJINSDK_EXPORT player::BridgeClaimAsset&
TransactionFragmentArguments<player::BridgeClaimAsset>::set_with_receipt_logs();

template ENJINSDK_EXPORT player::BridgeClaimAsset&
TransactionFragmentArguments<player::BridgeClaimAsset>::set_with_log_event();

template ENJINSDK_EXPORT player::BridgeClaimAsset&
TransactionFragmentArguments<player::BridgeClaimAsset>::set_with_transaction_project_uuid();

}

#endif //ENJINSDK_PLAYERBRIDGECLAIMASSET_HPP
18 changes: 18 additions & 0 deletions include/enjinsdk/player/IPlayerSchema.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#include "enjinsdk/player/AdvancedSendAsset.hpp"
#include "enjinsdk/player/ApproveEnj.hpp"
#include "enjinsdk/player/ApproveMaxEnj.hpp"
#include "enjinsdk/player/BridgeAsset.hpp"
#include "enjinsdk/player/BridgeAssets.hpp"
#include "enjinsdk/player/BridgeClaimAsset.hpp"
#include "enjinsdk/player/GetPlayer.hpp"
#include "enjinsdk/player/GetWallet.hpp"
#include "enjinsdk/player/MeltAsset.hpp"
Expand Down Expand Up @@ -59,6 +62,21 @@ class ENJINSDK_EXPORT IPlayerSchema {
/// \return The future containing the response.
virtual std::future<graphql::GraphqlResponse<models::Request>> approve_enj_max(ApproveMaxEnj& request) = 0;

/// \brief Sends the BridgeAsset request to the platform.
/// \param request The request.
/// \return The future containing the response.
virtual std::future<graphql::GraphqlResponse<models::Request>> bridge_asset(BridgeAsset& request) = 0;

/// \brief Sends the BridgeAssets request to the platform.
/// \param request The request.
/// \return The future containing the response.
virtual std::future<graphql::GraphqlResponse<models::Request>> bridge_assets(BridgeAssets& request) = 0;

/// \brief Sends the BridgeClaimAsset request to the platform.
/// \param request The request.
/// \return The future containing the response.
virtual std::future<graphql::GraphqlResponse<models::Request>> bridge_claim_asset(BridgeClaimAsset& request) = 0;

/// \brief Sends the GetPlayer request to the platform.
/// \param request The request.
/// \return The future containing the response.
Expand Down
6 changes: 6 additions & 0 deletions include/enjinsdk/player/PlayerSchema.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ class ENJINSDK_EXPORT PlayerSchema : public IPlayerSchema,

std::future<graphql::GraphqlResponse<models::Request>> approve_enj_max(ApproveMaxEnj& request) override;

std::future<graphql::GraphqlResponse<models::Request>> bridge_asset(BridgeAsset& request) override;

std::future<graphql::GraphqlResponse<models::Request>> bridge_assets(BridgeAssets& request) override;

std::future<graphql::GraphqlResponse<models::Request>> bridge_claim_asset(BridgeClaimAsset& request) override;

std::future<graphql::GraphqlResponse<models::Player>> get_player(GetPlayer& request) override;

std::future<graphql::GraphqlResponse<models::Wallet>> get_wallet(GetWallet& request) override;
Expand Down
Loading

0 comments on commit 79058f2

Please sign in to comment.