From b5356375f1185121a4798a0efbf3e91696a9b59f Mon Sep 17 00:00:00 2001 From: robGG1997 Date: Thu, 14 Sep 2023 11:30:11 +0300 Subject: [PATCH 1/9] Revert "automated duplicating imported samples modifications (#595)" This reverts commit a5558941827a91df51e2dd200648dcd13a1231c8. --- .github/workflows/duplicate_sample.yaml | 28 ------------------- duplicate_package_sample.sh | 14 ---------- .../Samples~/Web3.Unity/Prefabs.meta | 8 ------ .../Samples~/Web3.Unity/Scenes.meta | 8 ------ .../Samples~/Web3.Unity/Scripts.meta | 8 ------ .../Samples~/Web3.Unity/Sprites.meta | 8 ------ 6 files changed, 74 deletions(-) delete mode 100644 .github/workflows/duplicate_sample.yaml delete mode 100644 duplicate_package_sample.sh delete mode 100644 src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Prefabs.meta delete mode 100644 src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes.meta delete mode 100644 src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts.meta delete mode 100644 src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Sprites.meta diff --git a/.github/workflows/duplicate_sample.yaml b/.github/workflows/duplicate_sample.yaml deleted file mode 100644 index 793149e56..000000000 --- a/.github/workflows/duplicate_sample.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: Duplicate-Package-Sample - -on: - push: - branches: - - main - -jobs: - duplicate: - name: duplicate package sample - runs-on: ubuntu-latest - - steps: - - name: Checkout Repository - uses: actions/checkout@v2 - - - name: Run duplicate script file - run: bash ${GITHUB_WORKSPACE}/duplicate_package_sample.sh - - - name: Commit and Push - run: | - git config --global user.email $git_email - git config --global user.name "${{ github.actor }}" - git add ./src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/. -f - git diff-index --cached --quiet HEAD || git commit -m "Auto-duplicate Package Samples" - git push - env: - git_email: "${{ github.actor }}@users.noreply.github.com" \ No newline at end of file diff --git a/duplicate_package_sample.sh b/duplicate_package_sample.sh deleted file mode 100644 index f3a677742..000000000 --- a/duplicate_package_sample.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# Specify the source directory and the destination directory -SOURCE_DIRECTORY="src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0-pre001/Web3.Unity Samples/" -DESTINATION_DIRECTORY="src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/" - -# clear destination directory first -rm -r "$DESTINATION_DIRECTORY" - -# Copy source to the destination -cp -r "$SOURCE_DIRECTORY" "$DESTINATION_DIRECTORY" - -#add all modified files -git add "src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/." -f \ No newline at end of file diff --git a/src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Prefabs.meta b/src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Prefabs.meta deleted file mode 100644 index 5b35daff8..000000000 --- a/src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Prefabs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 45a04d2621549e3458049c6c447c3941 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes.meta b/src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes.meta deleted file mode 100644 index 5488a62ed..000000000 --- a/src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f39f8dda9616349489a7803d7e0aff30 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts.meta b/src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts.meta deleted file mode 100644 index 9a1e8b8d4..000000000 --- a/src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: eaef630f284e6e04a88b5939e0eb1cc5 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Sprites.meta b/src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Sprites.meta deleted file mode 100644 index 7175ee89d..000000000 --- a/src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Sprites.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 0c06517aee7843642a091a67c72b1379 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: From bbf532a81a79b1eb982a31a753e10f4c287b8053 Mon Sep 17 00:00:00 2001 From: robGG1997 Date: Thu, 25 Jan 2024 13:59:00 +0300 Subject: [PATCH 2/9] checkpoint --- .../Runtime/Common.meta | 8 ++ .../Runtime/Common/Scripts.meta | 8 ++ .../Runtime/Common/Scripts/ILoginProvider.cs | 106 ++++++++++++++++++ .../Common/Scripts/ILoginProvider.cs.meta | 11 ++ .../Scripts/IWeb3BuilderServiceAdapter.cs | 21 ++++ .../IWeb3BuilderServiceAdapter.cs.meta | 11 ++ .../Common/Scripts/IWeb3InitializedHandler.cs | 7 ++ .../Scripts/IWeb3InitializedHandler.cs.meta | 11 ++ ...3AuthLogin.cs => Web3AuthLoginProvider.cs} | 22 ++-- ....cs.meta => Web3AuthLoginProvider.cs.meta} | 0 .../Scripts/Prefabs/Logout.cs | 4 +- .../Scripts/Scenes/Login.cs | 86 -------------- .../Scripts/Scenes/LoginProvider.cs | 34 ++++++ .../{Login.cs.meta => LoginProvider.cs.meta} | 0 ...aMaskLogin.cs => MetaMaskLoginProvider.cs} | 9 +- ....cs.meta => MetaMaskLoginProvider.cs.meta} | 0 ...Login.cs => WalletConnectLoginProvider.cs} | 13 +-- ...eta => WalletConnectLoginProvider.cs.meta} | 0 18 files changed, 237 insertions(+), 114 deletions(-) create mode 100644 Packages/io.chainsafe.web3-unity/Runtime/Common.meta create mode 100644 Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts.meta create mode 100644 Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ILoginProvider.cs create mode 100644 Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ILoginProvider.cs.meta create mode 100644 Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3BuilderServiceAdapter.cs create mode 100644 Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3BuilderServiceAdapter.cs.meta create mode 100644 Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3InitializedHandler.cs create mode 100644 Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3InitializedHandler.cs.meta rename src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/{Web3AuthLogin.cs => Web3AuthLoginProvider.cs} (85%) rename src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/{Web3AuthLogin.cs.meta => Web3AuthLoginProvider.cs.meta} (100%) delete mode 100644 src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/Login.cs create mode 100644 src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/LoginProvider.cs rename src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/{Login.cs.meta => LoginProvider.cs.meta} (100%) rename src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/{MetaMaskLogin.cs => MetaMaskLoginProvider.cs} (82%) rename src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/{MetaMaskLogin.cs.meta => MetaMaskLoginProvider.cs.meta} (100%) rename src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/{ExistingWalletLogin.cs => WalletConnectLoginProvider.cs} (96%) rename src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/{ExistingWalletLogin.cs.meta => WalletConnectLoginProvider.cs.meta} (100%) diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Common.meta b/Packages/io.chainsafe.web3-unity/Runtime/Common.meta new file mode 100644 index 000000000..737c04e1d --- /dev/null +++ b/Packages/io.chainsafe.web3-unity/Runtime/Common.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ed1ce1c103b01b48a65b4631569502f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts.meta b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts.meta new file mode 100644 index 000000000..ae4d8755e --- /dev/null +++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b3347b82b502e4f4fa3d94b8ae6c144a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ILoginProvider.cs b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ILoginProvider.cs new file mode 100644 index 000000000..fce3d0d2f --- /dev/null +++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ILoginProvider.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Threading.Tasks; +using ChainSafe.Gaming.Evm.Contracts; +using ChainSafe.Gaming.Evm.JsonRpc; +using ChainSafe.Gaming.MultiCall; +using ChainSafe.Gaming.UnityPackage; +using ChainSafe.Gaming.Web3; +using ChainSafe.Gaming.Web3.Build; +using ChainSafe.Gaming.Web3.Unity; +using ChainSafe.GamingSdk.Gelato; +using Scripts.EVM.Token; +using UnityEngine; +using UnityEngine.SceneManagement; + +namespace ChainSafe.Gaming.UnityPackage.Common +{ + /// + /// Builds Instance and Login using a Wallet or a provider. + /// + public interface ILoginProvider + { + public string GelatoApiKey { get; } + + /// + /// All service providers used for configuring instance services. + /// + public IWeb3BuilderServiceAdapter[] Web3BuilderServiceAdapters { get; } + + public IWeb3InitializedHandler[] Web3InitializedHandlers { get; } + + /// + /// Login by Building a Instance. + /// + public async Task Login() + { + Web3.Web3 web3; + + try + { + Web3Builder web3Builder = new Web3Builder(ProjectConfigUtilities.Load()) + .Configure(ConfigureCommonServices); + + web3Builder = ConfigureWeb3Services(web3Builder); + + web3 = await web3Builder.LaunchAsync(); + } + + catch (Exception e) + { + Debug.LogError($"Login failed, please try again\n{e.Message} (see console for more details)"); + + throw; + } + + Web3Accessor.Set(web3); + + OnWeb3Initialized(); + } + + private void OnWeb3Initialized() + { + foreach (var web3InitializedHandler in Web3InitializedHandlers) + { + web3InitializedHandler.OnWeb3Initialized(); + } + } + + /// + /// Configure services to inject based on the type of Login/Provider you want to use. + /// + /// Builder for services to use. + /// Builder with new services added/injected. + private Web3Builder ConfigureWeb3Services(Web3Builder web3Builder) + { + foreach (var adapter in Web3BuilderServiceAdapters) + { + web3Builder = adapter.ConfigureServices(web3Builder); + } + + return web3Builder; + } + + private void ConfigureCommonServices(IWeb3ServiceCollection services) + { + services + .UseUnityEnvironment() + .UseGelato(GelatoApiKey) + .UseMultiCall() + .UseRpcProvider(); + + /* As many contracts as needed may be registered here. + * It is better to register all contracts the application + * will be interacting with at configuration time if they + * are known in advance. We're just registering shiba + * here to show how it's done. You can look at the + * `Scripts/Prefabs/Wallet/RegisteredContract` script + * to see how it's used later on. + */ + services.ConfigureRegisteredContracts(contracts => + contracts.RegisterContract("CsTestErc20", ABI.Erc20, Contracts.Erc20)); + + } + } +} \ No newline at end of file diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ILoginProvider.cs.meta b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ILoginProvider.cs.meta new file mode 100644 index 000000000..f7c5148f3 --- /dev/null +++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ILoginProvider.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5428fb54c62be2747ad58358db433c80 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3BuilderServiceAdapter.cs b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3BuilderServiceAdapter.cs new file mode 100644 index 000000000..b6ec6a644 --- /dev/null +++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3BuilderServiceAdapter.cs @@ -0,0 +1,21 @@ +using ChainSafe.Gaming.Debugging; +using ChainSafe.Gaming.Lootboxes.Chainlink; +using ChainSafe.Gaming.Wallets; +using ChainSafe.Gaming.Web3.Build; +using UnityEngine; + +namespace ChainSafe.Gaming.UnityPackage.Common +{ + /// + /// Provides services for building a instance. + /// + public interface IWeb3BuilderServiceAdapter + { + /// + /// Configures services for building a instance. + /// + /// Builder object for a instance. + /// Builder with services configured to it. + public Web3Builder ConfigureServices(Web3Builder web3Builder); + } +} \ No newline at end of file diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3BuilderServiceAdapter.cs.meta b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3BuilderServiceAdapter.cs.meta new file mode 100644 index 000000000..5f166a5de --- /dev/null +++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3BuilderServiceAdapter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 933b66c7fa977c542a9f852ed967efd0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3InitializedHandler.cs b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3InitializedHandler.cs new file mode 100644 index 000000000..0ed767238 --- /dev/null +++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3InitializedHandler.cs @@ -0,0 +1,7 @@ +namespace ChainSafe.Gaming.UnityPackage.Common +{ + public interface IWeb3InitializedHandler + { + public void OnWeb3Initialized(); + } +} diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3InitializedHandler.cs.meta b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3InitializedHandler.cs.meta new file mode 100644 index 000000000..2dda32482 --- /dev/null +++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3InitializedHandler.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 415bfa3b2643497449b26a9dc2392df3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Web3AuthLogin.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Web3AuthLoginProvider.cs similarity index 85% rename from src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Web3AuthLogin.cs rename to src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Web3AuthLoginProvider.cs index 20d9ace4c..c9db2a0c1 100644 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Web3AuthLogin.cs +++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Web3AuthLoginProvider.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using ChainSafe.Gaming.UnityPackage; +using ChainSafe.Gaming.UnityPackage.Common; using ChainSafe.Gaming.Web3.Analytics; using ChainSafe.Gaming.Web3.Build; using ChainSafe.GamingSdk.Web3Auth; @@ -14,11 +15,11 @@ /// /// Login using Web3Auth. /// -public class Web3AuthLogin : Login +public class Web3AuthLoginProvider : LoginProvider, IWeb3BuilderServiceAdapter { /// /// Struct used for pairing login buttons to Web3 auth providers. - /// Used when adding as listeners to the buttons. + /// Used when adding as listeners to the buttons. /// [Serializable] public struct ProviderAndButtonPair @@ -46,13 +47,11 @@ public void SetRememberMe(bool rememberMe) this.rememberMe = rememberMe; } - protected override IEnumerator Initialize() + protected override async void Initialize() { //Always first add listeners. providerAndButtonPairs.ForEach(p => p.Button.onClick.AddListener(delegate { LoginWithWeb3Auth(p.Provider); })); - - yield return null; #if UNITY_WEBGL && !UNITY_EDITOR Uri uri = new Uri(Application.absoluteURL); @@ -62,9 +61,7 @@ protected override IEnumerator Initialize() { useProvider = false; - Task loginTask = TryLogin(); - - yield return new WaitUntil(() => loginTask.IsCompleted); + await TryLogin(); } #else @@ -72,15 +69,10 @@ protected override IEnumerator Initialize() { useProvider = false; rememberMe = true; - Task loginTask = TryLogin(); + await TryLogin(); Debug.Log("Restoring existing Web3Auth session (Remember Me"); - yield return new WaitUntil(() => loginTask.IsCompleted); } #endif - - // add provider buttons listeners - - } private async void LoginWithWeb3Auth(Provider provider) @@ -104,7 +96,7 @@ private async void LoginWithWeb3Auth(Provider provider) }); } - protected override Web3Builder ConfigureWeb3Services(Web3Builder web3Builder) + public Web3Builder ConfigureServices(Web3Builder web3Builder) { return web3Builder.Configure(services => { diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Web3AuthLogin.cs.meta b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Web3AuthLoginProvider.cs.meta similarity index 100% rename from src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Web3AuthLogin.cs.meta rename to src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Web3AuthLoginProvider.cs.meta diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Prefabs/Logout.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Prefabs/Logout.cs index 88781c9bd..8c4accfe5 100644 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Prefabs/Logout.cs +++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Prefabs/Logout.cs @@ -7,6 +7,8 @@ public class Logout : MonoBehaviour { + public static int LoginSceneIndex; + public async void OnLogout() { // Remove the saved "remember me" data, if any @@ -19,6 +21,6 @@ public async void OnLogout() Web3Accessor.Clear(); // Go back to the first scene to log in again - SceneManager.LoadScene(Login.LoginSceneIndex); + SceneManager.LoadScene(LoginSceneIndex); } } diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/Login.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/Login.cs deleted file mode 100644 index 1eb08eba0..000000000 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/Login.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections; -using System.Threading.Tasks; -using ChainSafe.Gaming.Evm.Contracts; -using ChainSafe.Gaming.Evm.JsonRpc; -using ChainSafe.Gaming.MultiCall; -using ChainSafe.Gaming.UnityPackage; -using ChainSafe.Gaming.Web3; -using ChainSafe.Gaming.Web3.Build; -using ChainSafe.Gaming.Web3.Unity; -using ChainSafe.GamingSdk.Gelato; -using Scripts.EVM.Token; -using UnityEngine; -using UnityEngine.SceneManagement; - -namespace Scenes -{ - public abstract class Login : MonoBehaviour - { - [field:SerializeField] public string SceneToLoad { get; private set; } - - public static int LoginSceneIndex { get; private set; } = 0; - - [SerializeField] private string gelatoApiKey = ""; - - [SerializeField] private ErrorPopup errorPopup; - - private IEnumerator Start() - { - yield return Initialize(); - } - - protected abstract IEnumerator Initialize(); - - protected abstract Web3Builder ConfigureWeb3Services(Web3Builder web3Builder); - - protected async Task TryLogin() - { - Web3 web3; - - try - { - Web3Builder web3Builder = new Web3Builder(ProjectConfigUtilities.Load()) - .Configure(ConfigureCommonServices); - - web3Builder = ConfigureWeb3Services(web3Builder); - - web3 = await web3Builder.LaunchAsync(); - } - - catch (Exception) - { - errorPopup.ShowError("Login failed, please try again\n(see console for more details)"); - throw; - } - - Web3Accessor.Set(web3); - - LoginSceneIndex = SceneManager.GetActiveScene().buildIndex; - - // Attempt scene transition based on the login object sceneToLoad value - SceneManager.LoadScene(SceneToLoad); - } - - private void ConfigureCommonServices(IWeb3ServiceCollection services) - { - services - .UseUnityEnvironment() - .UseGelato(gelatoApiKey) - .UseMultiCall() - .UseRpcProvider(); - - /* As many contracts as needed may be registered here. - * It is better to register all contracts the application - * will be interacting with at configuration time if they - * are known in advance. We're just registering shiba - * here to show how it's done. You can look at the - * `Scripts/Prefabs/Wallet/RegisteredContract` script - * to see how it's used later on. - */ - services.ConfigureRegisteredContracts(contracts => - contracts.RegisterContract("CsTestErc20", ABI.Erc20, Contracts.Erc20)); - - } - } -} \ No newline at end of file diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/LoginProvider.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/LoginProvider.cs new file mode 100644 index 000000000..ce5710fe9 --- /dev/null +++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/LoginProvider.cs @@ -0,0 +1,34 @@ +using System.Threading.Tasks; +using ChainSafe.Gaming.UnityPackage.Common; +using UnityEngine; + +namespace Scenes +{ + public abstract class LoginProvider : MonoBehaviour, ILoginProvider + { + [SerializeField] private string gelatoApiKey = ""; + + [SerializeField] private ErrorPopup errorPopup; + + public string GelatoApiKey => gelatoApiKey; + public IWeb3BuilderServiceAdapter[] Web3BuilderServiceAdapters { get; private set; } + public IWeb3InitializedHandler[] Web3InitializedHandlers { get; private set; } + + private void Start() + { + Initialize(); + } + + protected virtual void Initialize() + { + Web3BuilderServiceAdapters = GetComponents(); + + Web3InitializedHandlers = GetComponents(); + } + + public async Task TryLogin() + { + await (this as ILoginProvider).Login(); + } + } +} \ No newline at end of file diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/Login.cs.meta b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/LoginProvider.cs.meta similarity index 100% rename from src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/Login.cs.meta rename to src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/LoginProvider.cs.meta diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/MetaMaskLogin.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/MetaMaskLoginProvider.cs similarity index 82% rename from src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/MetaMaskLogin.cs rename to src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/MetaMaskLoginProvider.cs index ed96d979f..7558abd95 100644 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/MetaMaskLogin.cs +++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/MetaMaskLoginProvider.cs @@ -1,4 +1,5 @@ using System.Collections; +using ChainSafe.Gaming.UnityPackage.Common; #if UNITY_WEBGL && !UNITY_EDITOR using ChainSafe.Gaming.MetaMask; using ChainSafe.Gaming.MetaMask.Unity; @@ -12,15 +13,13 @@ /// Login using MetaMask. /// Only works for UnityWebGL build (not in editor). /// -public class MetaMaskLogin : Login +public class MetaMaskLoginProvider : LoginProvider, IWeb3BuilderServiceAdapter { [SerializeField] private Button loginButton; - protected override IEnumerator Initialize() + protected override void Initialize() { loginButton.onClick.AddListener(LoginClicked); - - yield return null; } private async void LoginClicked() @@ -28,7 +27,7 @@ private async void LoginClicked() await TryLogin(); } - protected override Web3Builder ConfigureWeb3Services(Web3Builder web3Builder) + public Web3Builder ConfigureServices(Web3Builder web3Builder) { return web3Builder.Configure(services => { diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/MetaMaskLogin.cs.meta b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/MetaMaskLoginProvider.cs.meta similarity index 100% rename from src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/MetaMaskLogin.cs.meta rename to src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/MetaMaskLoginProvider.cs.meta diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ExistingWalletLogin.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/WalletConnectLoginProvider.cs similarity index 96% rename from src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ExistingWalletLogin.cs rename to src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/WalletConnectLoginProvider.cs index 7dd991dc2..e0d46dc9b 100644 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ExistingWalletLogin.cs +++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/WalletConnectLoginProvider.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using ChainSafe.Gaming.Unity; using ChainSafe.Gaming.UnityPackage; +using ChainSafe.Gaming.UnityPackage.Common; using ChainSafe.Gaming.WalletConnect; using ChainSafe.Gaming.WalletConnect.Models; using ChainSafe.Gaming.Web3.Build; @@ -27,7 +28,7 @@ /// /// Login using an existing wallet using Wallet Connect. /// -public class ExistingWalletLogin : Login +public class WalletConnectLoginProvider : LoginProvider, IWeb3BuilderServiceAdapter { [Header("UI")][SerializeField] private TMP_Dropdown supportedWalletsDropdown; @@ -76,7 +77,7 @@ private void OnDestroy() } } - protected override IEnumerator Initialize() + protected override async void Initialize() { Assert.IsNotNull(loginButton); Assert.IsNotNull(rememberMeToggle); @@ -110,13 +111,11 @@ protected override IEnumerator Initialize() if (!isRedirectionWalletAgnostic) { - yield return InitializeWalletSelection(); + await InitializeWalletSelection(); } // try auto login first - var autoLoginTask = TryAutoLogin(); - - yield return new WaitUntil(() => autoLoginTask.IsCompleted); + await TryAutoLogin(); loginButton.onClick.AddListener(LoginClicked); } @@ -126,7 +125,7 @@ private async void LoginClicked() await TryLogin(); } - protected override Web3Builder ConfigureWeb3Services(Web3Builder web3Builder) + public Web3Builder ConfigureServices(Web3Builder web3Builder) { return web3Builder.Configure(services => { diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ExistingWalletLogin.cs.meta b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/WalletConnectLoginProvider.cs.meta similarity index 100% rename from src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ExistingWalletLogin.cs.meta rename to src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/WalletConnectLoginProvider.cs.meta From d521dfb149628cb891a6fef25845836ee6e7ec85 Mon Sep 17 00:00:00 2001 From: robGG1997 Date: Mon, 29 Jan 2024 11:46:30 +0300 Subject: [PATCH 3/9] pushed changes made --- .../Runtime/Common/Scripts}/ErrorPopup.cs | 2 +- .../Common/Scripts}/ErrorPopup.cs.meta | 2 +- .../Runtime/Common/Scripts/ILoginProvider.cs | 17 ++--------- .../Common/Scripts/LoadSceneOnLogin.cs | 20 +++++++++++++ .../Common/Scripts/LoadSceneOnLogin.cs.meta | 11 +++++++ .../Runtime/Common/Scripts}/LoginProvider.cs | 14 +++++++-- .../Common/Scripts}/LoginProvider.cs.meta | 2 +- .../Scripts/ChainlinkLootboxSampleLauncher.cs | 4 +-- .../Scripts/LootboxesServicesAdapter.cs | 29 +++++++++++++++++++ .../Scripts/LootboxesServicesAdapter.cs.meta | 11 +++++++ .../Scenes/SampleLogin - Web3Auth.unity | 17 +++++++++-- .../Scenes/SampleLogin - MetaMask.unity | 17 +++++++++-- ...nity => SampleLogin - WalletConnect.unity} | 17 +++++++++-- ...=> SampleLogin - WalletConnect.unity.meta} | 0 .../Scripts/Prefabs/Logout.cs | 5 ++-- .../ProjectSettings/EditorBuildSettings.asset | 3 +- 16 files changed, 140 insertions(+), 31 deletions(-) rename {src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes => Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts}/ErrorPopup.cs (88%) rename {src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes => Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts}/ErrorPopup.cs.meta (53%) create mode 100644 Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoadSceneOnLogin.cs create mode 100644 Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoadSceneOnLogin.cs.meta rename {src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes => Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts}/LoginProvider.cs (72%) rename {src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes => Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts}/LoginProvider.cs.meta (53%) create mode 100644 src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/LootboxesServicesAdapter.cs create mode 100644 src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/LootboxesServicesAdapter.cs.meta rename src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/{SampleLogin.unity => SampleLogin - WalletConnect.unity} (99%) rename src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/{SampleLogin.unity.meta => SampleLogin - WalletConnect.unity.meta} (100%) diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ErrorPopup.cs b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ErrorPopup.cs similarity index 88% rename from src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ErrorPopup.cs rename to Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ErrorPopup.cs index f8c26431a..0469a39fb 100644 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ErrorPopup.cs +++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ErrorPopup.cs @@ -1,7 +1,7 @@ using UnityEngine; using UnityEngine.UI; -namespace Scenes +namespace ChainSafe.Gaming.UnityPackage.Common { public class ErrorPopup : MonoBehaviour { diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ErrorPopup.cs.meta b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ErrorPopup.cs.meta similarity index 53% rename from src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ErrorPopup.cs.meta rename to Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ErrorPopup.cs.meta index b0a77395c..3c9c65f01 100644 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ErrorPopup.cs.meta +++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ErrorPopup.cs.meta @@ -1,3 +1,3 @@ fileFormatVersion: 2 -guid: c001d0d5433b4215b8abba94194881bd +guid: 9df78976caa7771429cfe2b9b96e1491 timeCreated: 1691581208 \ No newline at end of file diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ILoginProvider.cs b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ILoginProvider.cs index fce3d0d2f..bcc60fd28 100644 --- a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ILoginProvider.cs +++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ILoginProvider.cs @@ -37,22 +37,11 @@ public async Task Login() { Web3.Web3 web3; - try - { - Web3Builder web3Builder = new Web3Builder(ProjectConfigUtilities.Load()) - .Configure(ConfigureCommonServices); - - web3Builder = ConfigureWeb3Services(web3Builder); + Web3Builder web3Builder = new Web3Builder(ProjectConfigUtilities.Load()).Configure(ConfigureCommonServices); - web3 = await web3Builder.LaunchAsync(); - } + web3Builder = ConfigureWeb3Services(web3Builder); - catch (Exception e) - { - Debug.LogError($"Login failed, please try again\n{e.Message} (see console for more details)"); - - throw; - } + web3 = await web3Builder.LaunchAsync(); Web3Accessor.Set(web3); diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoadSceneOnLogin.cs b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoadSceneOnLogin.cs new file mode 100644 index 000000000..d86949fa8 --- /dev/null +++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoadSceneOnLogin.cs @@ -0,0 +1,20 @@ +using ChainSafe.Gaming.UnityPackage.Common; +using UnityEngine; +using UnityEngine.SceneManagement; + +namespace ChainSafe.Gaming.UnityPackage.Common +{ + public class LoadSceneOnLogin : MonoBehaviour, IWeb3InitializedHandler + { + public static int LoginSceneBuildIndex { get; private set; } + + [SerializeField] private string sceneToLoad; + + public void OnWeb3Initialized() + { + LoginSceneBuildIndex = SceneManager.GetActiveScene().buildIndex; + + SceneManager.LoadSceneAsync(sceneToLoad); + } + } +} diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoadSceneOnLogin.cs.meta b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoadSceneOnLogin.cs.meta new file mode 100644 index 000000000..36d62511c --- /dev/null +++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoadSceneOnLogin.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3d2237df0314604419146b916b88d158 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/LoginProvider.cs b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoginProvider.cs similarity index 72% rename from src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/LoginProvider.cs rename to Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoginProvider.cs index ce5710fe9..444480f5d 100644 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/LoginProvider.cs +++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoginProvider.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; using ChainSafe.Gaming.UnityPackage.Common; using UnityEngine; @@ -28,7 +29,16 @@ protected virtual void Initialize() public async Task TryLogin() { - await (this as ILoginProvider).Login(); + try + { + await (this as ILoginProvider).Login(); + } + catch (Exception e) + { + errorPopup.ShowError($"Login failed, please try again\n{e.Message} (see console for more details)"); + + throw; + } } } } \ No newline at end of file diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/LoginProvider.cs.meta b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoginProvider.cs.meta similarity index 53% rename from src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/LoginProvider.cs.meta rename to Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoginProvider.cs.meta index 61485ea02..b19bee141 100644 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/LoginProvider.cs.meta +++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoginProvider.cs.meta @@ -1,3 +1,3 @@ fileFormatVersion: 2 -guid: 9473851428864b439d6561c87053272a +guid: b5a2f51f95094c949a28c71dc8658551 timeCreated: 1691581402 \ No newline at end of file diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/ChainlinkLootboxSampleLauncher.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/ChainlinkLootboxSampleLauncher.cs index a1fe7ff64..1aa12a073 100644 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/ChainlinkLootboxSampleLauncher.cs +++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/ChainlinkLootboxSampleLauncher.cs @@ -3,6 +3,7 @@ using ChainSafe.Gaming.Debugging; using ChainSafe.Gaming.Evm.JsonRpc; using ChainSafe.Gaming.Lootboxes.Chainlink; +using ChainSafe.Gaming.UnityPackage; using ChainSafe.Gaming.Wallets; using ChainSafe.Gaming.Web3; using ChainSafe.Gaming.Web3.Build; @@ -36,8 +37,7 @@ private class Web3Config : ICompleteProjectConfig private async void Awake() { - web3 = await new Web3Builder(new Web3Config()) - .Configure(services => + web3 = Web3Accessor.TryWeb3 ?? await new Web3Builder(new Web3Config()).Configure(services => { services.UseUnityEnvironment(); services.UseRpcProvider(); diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/LootboxesServicesAdapter.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/LootboxesServicesAdapter.cs new file mode 100644 index 000000000..afb404ad4 --- /dev/null +++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/LootboxesServicesAdapter.cs @@ -0,0 +1,29 @@ +using ChainSafe.Gaming.Lootboxes.Chainlink; +using ChainSafe.Gaming.UnityPackage.Common; +using ChainSafe.Gaming.Web3.Build; +using Microsoft.Extensions.DependencyInjection; +using UnityEngine; + +namespace LootBoxes.Chainlink +{ + public class LootboxesServicesAdapter : MonoBehaviour, IWeb3BuilderServiceAdapter + { + // the default values are setup for sepolia. + [SerializeField] private string contractAddress = "0x1993e2dD323B5dcBd8b52dB7d370bC36D280424B"; + + [SerializeField] private string contractAbi = "[ { \"inputs\": [], \"name\": \"AcceptingOnlyLINK\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" } ], \"name\": \"AccessDenied\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"value\", \"type\": \"uint256\" } ], \"name\": \"AmountPerUnitOverflow\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"tokenId\", \"type\": \"uint256\" } ], \"name\": \"DepositStateCorruption\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"EndOfService\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"InsufficientFee\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"InsufficientGas\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"InsufficientPayment\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"supply\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"requested\", \"type\": \"uint256\" } ], \"name\": \"InsufficientSupply\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"InvalidLength\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"int256\", \"name\": \"value\", \"type\": \"int256\" } ], \"name\": \"InvalidLinkPrice\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"InvalidLootboxType\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"requestId\", \"type\": \"uint256\" } ], \"name\": \"InvalidRequestAllocation\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"InvalidTokenAmount\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" } ], \"name\": \"InventoryStateCorruption\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"oldType\", \"type\": \"uint8\" }, { \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"newType\", \"type\": \"uint8\" } ], \"name\": \"ModifiedRewardType\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"NoTokens\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"NothingToClaim\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"NothingToRecover\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"OnlyThis\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"requestId\", \"type\": \"uint256\" } ], \"name\": \"PendingOpenRequest\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" } ], \"name\": \"RewardWithdrawalDenied\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"from\", \"type\": \"address\" } ], \"name\": \"SupplyDenied\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"supply\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"unitsToGet\", \"type\": \"uint256\" } ], \"name\": \"SupplyExceeded\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" } ], \"name\": \"TokenDenied\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"currentPrice\", \"type\": \"uint256\" } ], \"name\": \"UnexpectedPrice\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"rewardType\", \"type\": \"uint8\" } ], \"name\": \"UnexpectedRewardType\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"value\", \"type\": \"uint256\" } ], \"name\": \"UnitsOverflow\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"Unsupported\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"ViewCallFailed\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"ZeroAmount\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" } ], \"name\": \"ZeroSupply\", \"type\": \"error\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"opener\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"tokenId\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" } ], \"name\": \"Allocated\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"tokenId\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"amountPerUnit\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"newSupply\", \"type\": \"uint256\" } ], \"name\": \"AmountPerUnitSet\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"operator\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"bool\", \"name\": \"approved\", \"type\": \"bool\" } ], \"name\": \"ApprovalForAll\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"opener\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"requestId\", \"type\": \"uint256\" } ], \"name\": \"BoxesRecovered\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"caller\", \"type\": \"address\" } ], \"name\": \"EmergencyModeEnabled\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"tokenType\", \"type\": \"uint8\" }, { \"indexed\": false, \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256[]\", \"name\": \"ids\", \"type\": \"uint256[]\" }, { \"indexed\": false, \"internalType\": \"uint256[]\", \"name\": \"amounts\", \"type\": \"uint256[]\" } ], \"name\": \"EmergencyWithdrawal\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"requestId\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"bytes\", \"name\": \"reason\", \"type\": \"bytes\" } ], \"name\": \"OpenRequestFailed\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"requestId\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"randomness\", \"type\": \"uint256\" } ], \"name\": \"OpenRequestFulfilled\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"opener\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"unitsToGet\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"requestId\", \"type\": \"uint256\" } ], \"name\": \"OpenRequested\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"Paused\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"newPrice\", \"type\": \"uint256\" } ], \"name\": \"PriceUpdated\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"opener\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"tokenId\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" } ], \"name\": \"RewardsClaimed\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"indexed\": true, \"internalType\": \"bytes32\", \"name\": \"previousAdminRole\", \"type\": \"bytes32\" }, { \"indexed\": true, \"internalType\": \"bytes32\", \"name\": \"newAdminRole\", \"type\": \"bytes32\" } ], \"name\": \"RoleAdminChanged\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"sender\", \"type\": \"address\" } ], \"name\": \"RoleGranted\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"sender\", \"type\": \"address\" } ], \"name\": \"RoleRevoked\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"buyer\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"payment\", \"type\": \"uint256\" } ], \"name\": \"Sold\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"supplier\", \"type\": \"address\" } ], \"name\": \"SupplierAdded\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"supplier\", \"type\": \"address\" } ], \"name\": \"SupplierRemoved\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" } ], \"name\": \"TokenAdded\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"address\", \"name\": \"operator\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"from\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256[]\", \"name\": \"ids\", \"type\": \"uint256[]\" }, { \"indexed\": false, \"internalType\": \"uint256[]\", \"name\": \"values\", \"type\": \"uint256[]\" } ], \"name\": \"TransferBatch\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"address\", \"name\": \"operator\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"from\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"value\", \"type\": \"uint256\" } ], \"name\": \"TransferSingle\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"string\", \"name\": \"value\", \"type\": \"string\" }, { \"indexed\": true, \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" } ], \"name\": \"URI\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"Unpaused\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" } ], \"name\": \"Withdraw\", \"type\": \"event\" }, { \"inputs\": [], \"name\": \"DEFAULT_ADMIN_ROLE\", \"outputs\": [ { \"internalType\": \"bytes32\", \"name\": \"\", \"type\": \"bytes32\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"FACTORY\", \"outputs\": [ { \"internalType\": \"contract ILootboxFactory\", \"name\": \"\", \"type\": \"address\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"LINK_ETH_FEED\", \"outputs\": [ { \"internalType\": \"contract AggregatorV3Interface\", \"name\": \"\", \"type\": \"address\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"MINTER_ROLE\", \"outputs\": [ { \"internalType\": \"bytes32\", \"name\": \"\", \"type\": \"bytes32\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"PAUSER_ROLE\", \"outputs\": [ { \"internalType\": \"bytes32\", \"name\": \"\", \"type\": \"bytes32\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"_requestId\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"_randomness\", \"type\": \"uint256\" } ], \"name\": \"_allocateRewards\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"_suppliers\", \"type\": \"address[]\" } ], \"name\": \"addSuppliers\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"_tokens\", \"type\": \"address[]\" } ], \"name\": \"addTokens\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" } ], \"name\": \"balanceOf\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"accounts\", \"type\": \"address[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"ids\", \"type\": \"uint256[]\" } ], \"name\": \"balanceOfBatch\", \"outputs\": [ { \"internalType\": \"uint256[]\", \"name\": \"\", \"type\": \"uint256[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"value\", \"type\": \"uint256\" } ], \"name\": \"burn\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"internalType\": \"uint256[]\", \"name\": \"ids\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"values\", \"type\": \"uint256[]\" } ], \"name\": \"burnBatch\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"_amount\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"_maxPrice\", \"type\": \"uint256\" } ], \"name\": \"buy\", \"outputs\": [], \"stateMutability\": \"payable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint32\", \"name\": \"_gas\", \"type\": \"uint32\" }, { \"internalType\": \"uint256\", \"name\": \"_gasPriceInWei\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"_units\", \"type\": \"uint256\" } ], \"name\": \"calculateOpenPrice\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_opener\", \"type\": \"address\" } ], \"name\": \"canClaimRewards\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_opener\", \"type\": \"address\" } ], \"name\": \"claimRewards\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_token\", \"type\": \"address\" }, { \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"_type\", \"type\": \"uint8\" }, { \"internalType\": \"address\", \"name\": \"_to\", \"type\": \"address\" }, { \"internalType\": \"uint256[]\", \"name\": \"_ids\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"_amounts\", \"type\": \"uint256[]\" } ], \"name\": \"emergencyWithdraw\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getAllowedTokenTypes\", \"outputs\": [ { \"internalType\": \"enum LootboxInterface.RewardType[]\", \"name\": \"result\", \"type\": \"uint8[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getAllowedTokens\", \"outputs\": [ { \"internalType\": \"address[]\", \"name\": \"\", \"type\": \"address[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getAvailableSupply\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getInventory\", \"outputs\": [ { \"components\": [ { \"internalType\": \"address\", \"name\": \"rewardToken\", \"type\": \"address\" }, { \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"rewardType\", \"type\": \"uint8\" }, { \"internalType\": \"uint256\", \"name\": \"units\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"amountPerUnit\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"balance\", \"type\": \"uint256\" }, { \"components\": [ { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"units\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"amountPerUnit\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"balance\", \"type\": \"uint256\" } ], \"internalType\": \"struct LootboxInterface.ExtraRewardInfo[]\", \"name\": \"extra\", \"type\": \"tuple[]\" } ], \"internalType\": \"struct LootboxInterface.RewardView[]\", \"name\": \"result\", \"type\": \"tuple[]\" }, { \"components\": [ { \"internalType\": \"address\", \"name\": \"rewardToken\", \"type\": \"address\" }, { \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"rewardType\", \"type\": \"uint8\" }, { \"internalType\": \"uint256\", \"name\": \"units\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"amountPerUnit\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"balance\", \"type\": \"uint256\" }, { \"components\": [ { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"units\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"amountPerUnit\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"balance\", \"type\": \"uint256\" } ], \"internalType\": \"struct LootboxInterface.ExtraRewardInfo[]\", \"name\": \"extra\", \"type\": \"tuple[]\" } ], \"internalType\": \"struct LootboxInterface.RewardView[]\", \"name\": \"leftoversResult\", \"type\": \"tuple[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getLink\", \"outputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getLinkPrice\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getLootboxTypes\", \"outputs\": [ { \"internalType\": \"uint256[]\", \"name\": \"\", \"type\": \"uint256[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_opener\", \"type\": \"address\" } ], \"name\": \"getOpenerRequestDetails\", \"outputs\": [ { \"components\": [ { \"internalType\": \"address\", \"name\": \"opener\", \"type\": \"address\" }, { \"internalType\": \"uint96\", \"name\": \"unitsToGet\", \"type\": \"uint96\" }, { \"internalType\": \"uint256[]\", \"name\": \"lootIds\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"lootAmounts\", \"type\": \"uint256[]\" } ], \"internalType\": \"struct LootboxInterface.Request\", \"name\": \"request\", \"type\": \"tuple\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getPrice\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" } ], \"name\": \"getRoleAdmin\", \"outputs\": [ { \"internalType\": \"bytes32\", \"name\": \"\", \"type\": \"bytes32\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"internalType\": \"uint256\", \"name\": \"index\", \"type\": \"uint256\" } ], \"name\": \"getRoleMember\", \"outputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" } ], \"name\": \"getRoleMemberCount\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getSuppliers\", \"outputs\": [ { \"internalType\": \"address[]\", \"name\": \"\", \"type\": \"address[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getVRFV2Wrapper\", \"outputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"grantRole\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"hasRole\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"operator\", \"type\": \"address\" } ], \"name\": \"isApprovedForAll\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"isEmergencyMode\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" }, { \"internalType\": \"bytes\", \"name\": \"data\", \"type\": \"bytes\" } ], \"name\": \"mint\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"internalType\": \"uint256[]\", \"name\": \"ids\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"amounts\", \"type\": \"uint256[]\" }, { \"internalType\": \"bytes\", \"name\": \"data\", \"type\": \"bytes\" } ], \"name\": \"mintBatch\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"_tos\", \"type\": \"address[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"_lootboxTypes\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"_amounts\", \"type\": \"uint256[]\" } ], \"name\": \"mintToMany\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" }, { \"internalType\": \"uint256[]\", \"name\": \"\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"\", \"type\": \"uint256[]\" }, { \"internalType\": \"bytes\", \"name\": \"\", \"type\": \"bytes\" } ], \"name\": \"onERC1155BatchReceived\", \"outputs\": [ { \"internalType\": \"bytes4\", \"name\": \"\", \"type\": \"bytes4\" } ], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" }, { \"internalType\": \"bytes\", \"name\": \"\", \"type\": \"bytes\" } ], \"name\": \"onERC1155Received\", \"outputs\": [ { \"internalType\": \"bytes4\", \"name\": \"\", \"type\": \"bytes4\" } ], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" }, { \"internalType\": \"bytes\", \"name\": \"\", \"type\": \"bytes\" } ], \"name\": \"onERC721Received\", \"outputs\": [ { \"internalType\": \"bytes4\", \"name\": \"\", \"type\": \"bytes4\" } ], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint32\", \"name\": \"_gas\", \"type\": \"uint32\" }, { \"internalType\": \"uint256[]\", \"name\": \"_lootIds\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"_lootAmounts\", \"type\": \"uint256[]\" } ], \"name\": \"open\", \"outputs\": [], \"stateMutability\": \"payable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" } ], \"name\": \"openerRequests\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"pause\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"paused\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"_requestId\", \"type\": \"uint256\" }, { \"internalType\": \"uint256[]\", \"name\": \"_randomWords\", \"type\": \"uint256[]\" } ], \"name\": \"rawFulfillRandomWords\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_opener\", \"type\": \"address\" } ], \"name\": \"recoverBoxes\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"_suppliers\", \"type\": \"address[]\" } ], \"name\": \"removeSuppliers\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"renounceRole\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"revokeRole\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"from\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"internalType\": \"uint256[]\", \"name\": \"ids\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"amounts\", \"type\": \"uint256[]\" }, { \"internalType\": \"bytes\", \"name\": \"data\", \"type\": \"bytes\" } ], \"name\": \"safeBatchTransferFrom\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"from\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" }, { \"internalType\": \"bytes\", \"name\": \"data\", \"type\": \"bytes\" } ], \"name\": \"safeTransferFrom\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"_tokens\", \"type\": \"address[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"_ids\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"_amountsPerUnit\", \"type\": \"uint256[]\" } ], \"name\": \"setAmountsPerUnit\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"operator\", \"type\": \"address\" }, { \"internalType\": \"bool\", \"name\": \"approved\", \"type\": \"bool\" } ], \"name\": \"setApprovalForAll\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"_newPrice\", \"type\": \"uint256\" } ], \"name\": \"setPrice\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"string\", \"name\": \"_baseURI\", \"type\": \"string\" } ], \"name\": \"setURI\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_from\", \"type\": \"address\" } ], \"name\": \"supplyAllowed\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes4\", \"name\": \"interfaceId\", \"type\": \"bytes4\" } ], \"name\": \"supportsInterface\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_token\", \"type\": \"address\" } ], \"name\": \"tokenAllowed\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"unitsMinted\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"unitsRequested\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"unitsSupply\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"unpause\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"name\": \"uri\", \"outputs\": [ { \"internalType\": \"string\", \"name\": \"\", \"type\": \"string\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"viewCall\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_token\", \"type\": \"address\" }, { \"internalType\": \"address payable\", \"name\": \"_to\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"_amount\", \"type\": \"uint256\" } ], \"name\": \"withdraw\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" } ]"; + + public Web3Builder ConfigureServices(Web3Builder web3Builder) + { + return web3Builder.Configure(services => + { + services.UseChainlinkLootboxService(new LootboxServiceConfig + { + ContractAddress = contractAddress, + ContractAbi = contractAbi + }); + services.AddSingleton(); + }); + } + } +} diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/LootboxesServicesAdapter.cs.meta b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/LootboxesServicesAdapter.cs.meta new file mode 100644 index 000000000..f5a49c735 --- /dev/null +++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/LootboxesServicesAdapter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1601a8846d451cf4fb87a7082da91a7f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scenes/SampleLogin - Web3Auth.unity b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scenes/SampleLogin - Web3Auth.unity index 496e2b6ad..d513b1f8b 100644 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scenes/SampleLogin - Web3Auth.unity +++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scenes/SampleLogin - Web3Auth.unity @@ -574,7 +574,7 @@ MonoBehaviour: m_GameObject: {fileID: 337558419} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: c001d0d5433b4215b8abba94194881bd, type: 3} + m_Script: {fileID: 11500000, guid: 9df78976caa7771429cfe2b9b96e1491, type: 3} m_Name: m_EditorClassIdentifier: MessageLabel: {fileID: 804898217} @@ -1362,6 +1362,7 @@ GameObject: m_Component: - component: {fileID: 1679801099} - component: {fileID: 1679801100} + - component: {fileID: 1679801101} m_Layer: 0 m_Name: Logic - Login - Web3Auth m_TagString: Untagged @@ -1396,7 +1397,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 7b6902e441950fa4bb5cefdd2263164a, type: 3} m_Name: m_EditorClassIdentifier: - k__BackingField: SampleMain gelatoApiKey: 7MFQqyGS1Iui_e_MgmFW1BfbFeJ06g8nnL2oUTlIJug_ errorPopup: {fileID: 337558421} clientId: BCc0wTmuXureEzgawhUSZOWu4bgWo56sZPrxLiHQCpg5OHcNrfa44esdTS8Dm77VtmaIyjhbthdWfbLhSwf7jtU @@ -1415,6 +1415,19 @@ MonoBehaviour: Provider: 3 - Button: {fileID: 7400892925769233044} Provider: 4 +--- !u!114 &1679801101 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1679801098} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3d2237df0314604419146b916b88d158, type: 3} + m_Name: + m_EditorClassIdentifier: + sceneToLoad: SampleMain --- !u!1 &1799608969 GameObject: m_ObjectHideFlags: 0 diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin - MetaMask.unity b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin - MetaMask.unity index 0d17aa009..9635a9189 100644 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin - MetaMask.unity +++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin - MetaMask.unity @@ -249,7 +249,7 @@ MonoBehaviour: m_GameObject: {fileID: 314965759} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: c001d0d5433b4215b8abba94194881bd, type: 3} + m_Script: {fileID: 11500000, guid: 9df78976caa7771429cfe2b9b96e1491, type: 3} m_Name: m_EditorClassIdentifier: MessageLabel: {fileID: 1028782728} @@ -263,6 +263,7 @@ GameObject: m_Component: - component: {fileID: 433476714} - component: {fileID: 433476715} + - component: {fileID: 433476716} m_Layer: 0 m_Name: MetaMaskLogin m_TagString: Untagged @@ -297,10 +298,22 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: b547b7e8ac8d2f442bfefe0c9f59ed1d, type: 3} m_Name: m_EditorClassIdentifier: - k__BackingField: SampleMain gelatoApiKey: 7MFQqyGS1Iui_e_MgmFW1BfbFeJ06g8nnL2oUTlIJug_ errorPopup: {fileID: 314965761} loginButton: {fileID: 2048731599} +--- !u!114 &433476716 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 433476712} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3d2237df0314604419146b916b88d158, type: 3} + m_Name: + m_EditorClassIdentifier: + sceneToLoad: SampleMain --- !u!1 &740974330 GameObject: m_ObjectHideFlags: 0 diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin.unity b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin - WalletConnect.unity similarity index 99% rename from src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin.unity rename to src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin - WalletConnect.unity index b90d9c63a..c560850d3 100644 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin.unity +++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin - WalletConnect.unity @@ -2641,6 +2641,7 @@ GameObject: m_Component: - component: {fileID: 1334079841} - component: {fileID: 1334079842} + - component: {fileID: 1334079843} m_Layer: 0 m_Name: Logic - Login m_TagString: Untagged @@ -2675,7 +2676,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 96894e49d9863ec4db1d93a5e56f19cb, type: 3} m_Name: m_EditorClassIdentifier: - k__BackingField: SampleMain gelatoApiKey: 7MFQqyGS1Iui_e_MgmFW1BfbFeJ06g8nnL2oUTlIJug_ errorPopup: {fileID: 1701305868} supportedWalletsDropdown: {fileID: 540464236} @@ -2701,6 +2701,19 @@ MonoBehaviour: Universal: VerifyUrl: walletConnectModal: {fileID: 395689441} +--- !u!114 &1334079843 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1334079840} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3d2237df0314604419146b916b88d158, type: 3} + m_Name: + m_EditorClassIdentifier: + sceneToLoad: SampleMain --- !u!1 &1491563361 GameObject: m_ObjectHideFlags: 0 @@ -3192,7 +3205,7 @@ MonoBehaviour: m_GameObject: {fileID: 1701305866} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: c001d0d5433b4215b8abba94194881bd, type: 3} + m_Script: {fileID: 11500000, guid: 9df78976caa7771429cfe2b9b96e1491, type: 3} m_Name: m_EditorClassIdentifier: MessageLabel: {fileID: 786896302} diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin.unity.meta b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin - WalletConnect.unity.meta similarity index 100% rename from src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin.unity.meta rename to src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin - WalletConnect.unity.meta diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Prefabs/Logout.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Prefabs/Logout.cs index 8c4accfe5..777b0f582 100644 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Prefabs/Logout.cs +++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Prefabs/Logout.cs @@ -1,14 +1,13 @@ using System.Threading.Tasks; using ChainSafe.Gaming.UnityPackage; using ChainSafe.Gaming.Wallets; +using ChainSafe.Gaming.UnityPackage.Common; using Scenes; using UnityEngine; using UnityEngine.SceneManagement; public class Logout : MonoBehaviour { - public static int LoginSceneIndex; - public async void OnLogout() { // Remove the saved "remember me" data, if any @@ -21,6 +20,6 @@ public async void OnLogout() Web3Accessor.Clear(); // Go back to the first scene to log in again - SceneManager.LoadScene(LoginSceneIndex); + await SceneManager.LoadSceneAsync(LoadSceneOnLogin.LoginSceneBuildIndex); } } diff --git a/src/UnitySampleProject/ProjectSettings/EditorBuildSettings.asset b/src/UnitySampleProject/ProjectSettings/EditorBuildSettings.asset index 4763d64db..48ab02a8d 100644 --- a/src/UnitySampleProject/ProjectSettings/EditorBuildSettings.asset +++ b/src/UnitySampleProject/ProjectSettings/EditorBuildSettings.asset @@ -10,7 +10,8 @@ EditorBuildSettings: - Web3Auth.unity guid: a8a8b501e594874448546e904e2437c5 - enabled: 1 - path: Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin.unity + path: Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin + - WalletConnect.unity guid: 1c1af5c5662d105498b2412267dde0df - enabled: 1 path: Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleMain.unity From 7e26940f2b4a80f1292aeeb3013159db959344c3 Mon Sep 17 00:00:00 2001 From: robGG1997 Date: Mon, 29 Jan 2024 12:11:24 +0300 Subject: [PATCH 4/9] added documentation and removed scene indexers --- .../Runtime/Common/Scripts/ErrorPopup.cs | 7 ++ .../Runtime/Common/Scripts/ILoginProvider.cs | 6 ++ .../Common/Scripts/IWeb3InitializedHandler.cs | 6 ++ .../Common/Scripts/LoadSceneOnLogin.cs | 6 ++ .../Runtime/Common/Scripts/LoginProvider.cs | 9 ++ .../Scripts/LootboxesServicesAdapter.cs | 3 + .../Scripts/Utilities/Web3AuthSceneIndexer.cs | 23 ----- .../Utilities/Web3AuthSceneIndexer.cs.meta | 11 --- .../Scripts/Web3AuthLoginProvider.cs | 2 + .../Scripts/Scenes/MetaMaskLoginProvider.cs | 2 + .../Scenes/WalletConnectLoginProvider.cs | 2 + .../Scripts/Utilities/SceneIndexer.cs | 89 ------------------- .../Scripts/Utilities/SceneIndexer.cs.meta | 11 --- 13 files changed, 43 insertions(+), 134 deletions(-) delete mode 100644 src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Utilities/Web3AuthSceneIndexer.cs delete mode 100644 src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Utilities/Web3AuthSceneIndexer.cs.meta delete mode 100644 src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Utilities/SceneIndexer.cs delete mode 100644 src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Utilities/SceneIndexer.cs.meta diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ErrorPopup.cs b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ErrorPopup.cs index 0469a39fb..2e7134c64 100644 --- a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ErrorPopup.cs +++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ErrorPopup.cs @@ -7,12 +7,19 @@ public class ErrorPopup : MonoBehaviour { public Text MessageLabel; + /// + /// Display error pop up when Login fails. + /// + /// Error message to be displayed. public void ShowError(string message) { gameObject.SetActive(true); MessageLabel.text = message; } + /// + /// Close error popup. + /// public void Close() { gameObject.SetActive(false); diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ILoginProvider.cs b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ILoginProvider.cs index bcc60fd28..df265e476 100644 --- a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ILoginProvider.cs +++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ILoginProvider.cs @@ -21,6 +21,9 @@ namespace ChainSafe.Gaming.UnityPackage.Common /// public interface ILoginProvider { + /// + /// Gelato API key from Gelato's Web Dashboard. + /// public string GelatoApiKey { get; } /// @@ -28,6 +31,9 @@ public interface ILoginProvider /// public IWeb3BuilderServiceAdapter[] Web3BuilderServiceAdapters { get; } + /// + /// All Web3 initialized handlers called when Web3 instance is initialized. + /// public IWeb3InitializedHandler[] Web3InitializedHandlers { get; } /// diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3InitializedHandler.cs b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3InitializedHandler.cs index 0ed767238..177493e43 100644 --- a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3InitializedHandler.cs +++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3InitializedHandler.cs @@ -1,7 +1,13 @@ namespace ChainSafe.Gaming.UnityPackage.Common { + /// + /// Initialized handler used for executing logic when a web3 instance is initialized. + /// public interface IWeb3InitializedHandler { + /// + /// Called when Web3 Instance in is initialized. + /// public void OnWeb3Initialized(); } } diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoadSceneOnLogin.cs b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoadSceneOnLogin.cs index d86949fa8..9bb691590 100644 --- a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoadSceneOnLogin.cs +++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoadSceneOnLogin.cs @@ -4,8 +4,14 @@ namespace ChainSafe.Gaming.UnityPackage.Common { + /// + /// Loads scene when Web3 Instance is initialized. + /// public class LoadSceneOnLogin : MonoBehaviour, IWeb3InitializedHandler { + /// + /// Login scene cached/saved for Logout since we can have more than one Login scene. + /// public static int LoginSceneBuildIndex { get; private set; } [SerializeField] private string sceneToLoad; diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoginProvider.cs b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoginProvider.cs index 444480f5d..baee80c28 100644 --- a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoginProvider.cs +++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoginProvider.cs @@ -5,6 +5,9 @@ namespace Scenes { + /// + /// A concrete implementation of . + /// public abstract class LoginProvider : MonoBehaviour, ILoginProvider { [SerializeField] private string gelatoApiKey = ""; @@ -20,6 +23,9 @@ private void Start() Initialize(); } + /// + /// Initializes Login providers. + /// protected virtual void Initialize() { Web3BuilderServiceAdapters = GetComponents(); @@ -27,6 +33,9 @@ protected virtual void Initialize() Web3InitializedHandlers = GetComponents(); } + /// + /// Try to Login and displays error and throws exception on a failed attempt. + /// public async Task TryLogin() { try diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/LootboxesServicesAdapter.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/LootboxesServicesAdapter.cs index afb404ad4..3c21ce5aa 100644 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/LootboxesServicesAdapter.cs +++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/LootboxesServicesAdapter.cs @@ -6,6 +6,9 @@ namespace LootBoxes.Chainlink { + /// + /// Configures Lootboxes services to work with a . + /// public class LootboxesServicesAdapter : MonoBehaviour, IWeb3BuilderServiceAdapter { // the default values are setup for sepolia. diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Utilities/Web3AuthSceneIndexer.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Utilities/Web3AuthSceneIndexer.cs deleted file mode 100644 index 1b7d7489d..000000000 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Utilities/Web3AuthSceneIndexer.cs +++ /dev/null @@ -1,23 +0,0 @@ -#if UNITY_EDITOR -using UnityEditor; - -/// -/// Add Web3.Unity Web3Auth package sample scenes to Build Settings Scenes -/// -[InitializeOnLoad] -public static class Web3AuthSceneIndexer -{ - private const string ScenesIndexedKey = PackageName + "ScenesIndexed"; - - private const string PackageName = "io.chainsafe.web3-unity.web3auth"; - - static Web3AuthSceneIndexer() - { - SceneIndexer.TryAddEditorBuildSettingsScenes(PackageName, ScenesIndexedKey, new string[] - { - "SampleLogin - Web3Auth.Unity", - }); - } -} - -#endif \ No newline at end of file diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Utilities/Web3AuthSceneIndexer.cs.meta b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Utilities/Web3AuthSceneIndexer.cs.meta deleted file mode 100644 index 50f8761b4..000000000 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Utilities/Web3AuthSceneIndexer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 74c0e58ffe715a448a1d221b425d7352 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Web3AuthLoginProvider.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Web3AuthLoginProvider.cs index c9db2a0c1..492023127 100644 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Web3AuthLoginProvider.cs +++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Web3AuthLoginProvider.cs @@ -49,6 +49,8 @@ public void SetRememberMe(bool rememberMe) protected override async void Initialize() { + base.Initialize(); + //Always first add listeners. providerAndButtonPairs.ForEach(p => p.Button.onClick.AddListener(delegate { LoginWithWeb3Auth(p.Provider); })); diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/MetaMaskLoginProvider.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/MetaMaskLoginProvider.cs index 7558abd95..2cd23b3e4 100644 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/MetaMaskLoginProvider.cs +++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/MetaMaskLoginProvider.cs @@ -19,6 +19,8 @@ public class MetaMaskLoginProvider : LoginProvider, IWeb3BuilderServiceAdapter protected override void Initialize() { + base.Initialize(); + loginButton.onClick.AddListener(LoginClicked); } diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/WalletConnectLoginProvider.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/WalletConnectLoginProvider.cs index e0d46dc9b..0938fd38c 100644 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/WalletConnectLoginProvider.cs +++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/WalletConnectLoginProvider.cs @@ -79,6 +79,8 @@ private void OnDestroy() protected override async void Initialize() { + base.Initialize(); + Assert.IsNotNull(loginButton); Assert.IsNotNull(rememberMeToggle); diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Utilities/SceneIndexer.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Utilities/SceneIndexer.cs deleted file mode 100644 index f95eaea57..000000000 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Utilities/SceneIndexer.cs +++ /dev/null @@ -1,89 +0,0 @@ -#if UNITY_EDITOR - -using System; -using System.IO; -using System.Linq; -using Scenes; -using UnityEditor; -using UnityEditor.PackageManager; -using UnityEditor.PackageManager.UI; -using PackageInfo = UnityEditor.PackageManager.PackageInfo; - -[InitializeOnLoad] -public static class SceneIndexer -{ - private const string ScenesIndexedKey = PackageName + "ScenesIndexed"; - - private const string PackageName = "io.chainsafe.web3-unity"; - - static SceneIndexer() - { - TryAddEditorBuildSettingsScenes(PackageName, ScenesIndexedKey, new string[] - { - "SampleLogin.Unity", - "SampleMain.Unity" - }); - } - - public static void TryAddEditorBuildSettingsScenes(string packageName, string sessionKey, string[] scenes) - { - if (SessionState.GetBool(sessionKey, false)) - { - return; - } - - PackageInfo package = GetPackage(packageName); - - string importPath = GetImportPath(package); - - //Scenes can be deleted. Remove empty scenes from build settings before adding new ones. - EditorBuildSettings.scenes = EditorBuildSettings.scenes.Where(s => !string.IsNullOrEmpty(s.path)).ToArray(); - - //scenes already added to build settings - if (EditorBuildSettings.scenes.Any(s => Path.GetFullPath(s.path).Contains(importPath))) - { - SessionState.SetBool(sessionKey, true); - - return; - } - - // convert and add importPath to scenes path - EditorBuildSettingsScene[] editorBuildSettingsScenes = Array.ConvertAll(scenes, s => new EditorBuildSettingsScene(Path.Combine(importPath, s), true)); - - EditorBuildSettings.scenes = editorBuildSettingsScenes.Concat(EditorBuildSettings.scenes).ToArray(); - - SessionState.SetBool(sessionKey, true); - } - - private static PackageInfo GetPackage(string name) - { - var listRequest = Client.List(); - - while (!listRequest.IsCompleted) - { - //do nothing - } - - PackageInfo[] packages = listRequest.Result.ToArray(); - - PackageInfo package = packages.FirstOrDefault(p => p.name == name); - - if (package == null) - { - throw new Exception($"Installed Package {name} not found"); - } - - return package; - } - - private static string GetImportPath(PackageInfo package) - { - Sample sample = Sample.FindByPackage(package.name, package.version).FirstOrDefault(); - - string importPath = Path.GetRelativePath(Directory.GetCurrentDirectory(), sample.importPath); - - return Path.Combine(importPath, "Scenes"); - } -} - -#endif \ No newline at end of file diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Utilities/SceneIndexer.cs.meta b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Utilities/SceneIndexer.cs.meta deleted file mode 100644 index 90c453b23..000000000 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Utilities/SceneIndexer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 93ae86024927f3f499e488b918531db5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: From c260c310aa7aa1e66a15201ea855dd25f19e0527 Mon Sep 17 00:00:00 2001 From: robGG1997 Date: Mon, 29 Jan 2024 14:54:27 +0000 Subject: [PATCH 5/9] Auto-duplicate Packages Samples --- .../Scripts/ChainlinkLootboxSampleLauncher.cs | 4 +- .../Scripts/LootboxesServicesAdapter.cs | 32 ++++++ .../Scripts/LootboxesServicesAdapter.cs.meta} | 2 +- .../Scripts/Utilities/Web3AuthSceneIndexer.cs | 23 ---- .../Utilities/Web3AuthSceneIndexer.cs.meta | 11 -- ...3AuthLogin.cs => Web3AuthLoginProvider.cs} | 31 ++---- ....cs.meta => Web3AuthLoginProvider.cs.meta} | 0 .../Scenes/SampleLogin - MetaMask.unity | 17 ++- ...nity => SampleLogin - WalletConnect.unity} | 17 ++- ...=> SampleLogin - WalletConnect.unity.meta} | 0 .../Web3.Unity/Scripts/Prefabs/Logout.cs | 3 +- .../Web3.Unity/Scripts/Scenes/ErrorPopup.cs | 21 ---- .../Scripts/Scenes/ErrorPopup.cs.meta | 3 - .../Web3.Unity/Scripts/Scenes/Login.cs | 105 ------------------ .../Web3.Unity/Scripts/Scenes/Login.cs.meta | 3 - ...aMaskLogin.cs => MetaMaskLoginProvider.cs} | 11 +- ....cs.meta => MetaMaskLoginProvider.cs.meta} | 0 ...Login.cs => WalletConnectLoginProvider.cs} | 15 +-- ...eta => WalletConnectLoginProvider.cs.meta} | 0 .../Scripts/Utilities/SceneIndexer.cs | 89 --------------- 20 files changed, 93 insertions(+), 294 deletions(-) create mode 100644 Packages/io.chainsafe.web3-unity.lootboxes/Samples~/Chainlink Lootbox Samples/Scripts/LootboxesServicesAdapter.cs rename Packages/{io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Utilities/SceneIndexer.cs.meta => io.chainsafe.web3-unity.lootboxes/Samples~/Chainlink Lootbox Samples/Scripts/LootboxesServicesAdapter.cs.meta} (83%) delete mode 100644 Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Utilities/Web3AuthSceneIndexer.cs delete mode 100644 Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Utilities/Web3AuthSceneIndexer.cs.meta rename Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/{Web3AuthLogin.cs => Web3AuthLoginProvider.cs} (84%) rename Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/{Web3AuthLogin.cs.meta => Web3AuthLoginProvider.cs.meta} (100%) rename Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/{SampleLogin.unity => SampleLogin - WalletConnect.unity} (99%) rename Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/{SampleLogin.unity.meta => SampleLogin - WalletConnect.unity.meta} (100%) delete mode 100644 Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ErrorPopup.cs delete mode 100644 Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ErrorPopup.cs.meta delete mode 100644 Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/Login.cs delete mode 100644 Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/Login.cs.meta rename Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/{MetaMaskLogin.cs => MetaMaskLoginProvider.cs} (80%) rename Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/{MetaMaskLogin.cs.meta => MetaMaskLoginProvider.cs.meta} (100%) rename Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/{ExistingWalletLogin.cs => WalletConnectLoginProvider.cs} (96%) rename Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/{ExistingWalletLogin.cs.meta => WalletConnectLoginProvider.cs.meta} (100%) delete mode 100644 Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Utilities/SceneIndexer.cs diff --git a/Packages/io.chainsafe.web3-unity.lootboxes/Samples~/Chainlink Lootbox Samples/Scripts/ChainlinkLootboxSampleLauncher.cs b/Packages/io.chainsafe.web3-unity.lootboxes/Samples~/Chainlink Lootbox Samples/Scripts/ChainlinkLootboxSampleLauncher.cs index a1fe7ff64..1aa12a073 100644 --- a/Packages/io.chainsafe.web3-unity.lootboxes/Samples~/Chainlink Lootbox Samples/Scripts/ChainlinkLootboxSampleLauncher.cs +++ b/Packages/io.chainsafe.web3-unity.lootboxes/Samples~/Chainlink Lootbox Samples/Scripts/ChainlinkLootboxSampleLauncher.cs @@ -3,6 +3,7 @@ using ChainSafe.Gaming.Debugging; using ChainSafe.Gaming.Evm.JsonRpc; using ChainSafe.Gaming.Lootboxes.Chainlink; +using ChainSafe.Gaming.UnityPackage; using ChainSafe.Gaming.Wallets; using ChainSafe.Gaming.Web3; using ChainSafe.Gaming.Web3.Build; @@ -36,8 +37,7 @@ private class Web3Config : ICompleteProjectConfig private async void Awake() { - web3 = await new Web3Builder(new Web3Config()) - .Configure(services => + web3 = Web3Accessor.TryWeb3 ?? await new Web3Builder(new Web3Config()).Configure(services => { services.UseUnityEnvironment(); services.UseRpcProvider(); diff --git a/Packages/io.chainsafe.web3-unity.lootboxes/Samples~/Chainlink Lootbox Samples/Scripts/LootboxesServicesAdapter.cs b/Packages/io.chainsafe.web3-unity.lootboxes/Samples~/Chainlink Lootbox Samples/Scripts/LootboxesServicesAdapter.cs new file mode 100644 index 000000000..3c21ce5aa --- /dev/null +++ b/Packages/io.chainsafe.web3-unity.lootboxes/Samples~/Chainlink Lootbox Samples/Scripts/LootboxesServicesAdapter.cs @@ -0,0 +1,32 @@ +using ChainSafe.Gaming.Lootboxes.Chainlink; +using ChainSafe.Gaming.UnityPackage.Common; +using ChainSafe.Gaming.Web3.Build; +using Microsoft.Extensions.DependencyInjection; +using UnityEngine; + +namespace LootBoxes.Chainlink +{ + /// + /// Configures Lootboxes services to work with a . + /// + public class LootboxesServicesAdapter : MonoBehaviour, IWeb3BuilderServiceAdapter + { + // the default values are setup for sepolia. + [SerializeField] private string contractAddress = "0x1993e2dD323B5dcBd8b52dB7d370bC36D280424B"; + + [SerializeField] private string contractAbi = "[ { \"inputs\": [], \"name\": \"AcceptingOnlyLINK\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" } ], \"name\": \"AccessDenied\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"value\", \"type\": \"uint256\" } ], \"name\": \"AmountPerUnitOverflow\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"tokenId\", \"type\": \"uint256\" } ], \"name\": \"DepositStateCorruption\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"EndOfService\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"InsufficientFee\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"InsufficientGas\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"InsufficientPayment\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"supply\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"requested\", \"type\": \"uint256\" } ], \"name\": \"InsufficientSupply\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"InvalidLength\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"int256\", \"name\": \"value\", \"type\": \"int256\" } ], \"name\": \"InvalidLinkPrice\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"InvalidLootboxType\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"requestId\", \"type\": \"uint256\" } ], \"name\": \"InvalidRequestAllocation\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"InvalidTokenAmount\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" } ], \"name\": \"InventoryStateCorruption\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"oldType\", \"type\": \"uint8\" }, { \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"newType\", \"type\": \"uint8\" } ], \"name\": \"ModifiedRewardType\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"NoTokens\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"NothingToClaim\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"NothingToRecover\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"OnlyThis\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"requestId\", \"type\": \"uint256\" } ], \"name\": \"PendingOpenRequest\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" } ], \"name\": \"RewardWithdrawalDenied\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"from\", \"type\": \"address\" } ], \"name\": \"SupplyDenied\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"supply\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"unitsToGet\", \"type\": \"uint256\" } ], \"name\": \"SupplyExceeded\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" } ], \"name\": \"TokenDenied\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"currentPrice\", \"type\": \"uint256\" } ], \"name\": \"UnexpectedPrice\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"rewardType\", \"type\": \"uint8\" } ], \"name\": \"UnexpectedRewardType\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"value\", \"type\": \"uint256\" } ], \"name\": \"UnitsOverflow\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"Unsupported\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"ViewCallFailed\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"ZeroAmount\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" } ], \"name\": \"ZeroSupply\", \"type\": \"error\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"opener\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"tokenId\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" } ], \"name\": \"Allocated\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"tokenId\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"amountPerUnit\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"newSupply\", \"type\": \"uint256\" } ], \"name\": \"AmountPerUnitSet\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"operator\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"bool\", \"name\": \"approved\", \"type\": \"bool\" } ], \"name\": \"ApprovalForAll\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"opener\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"requestId\", \"type\": \"uint256\" } ], \"name\": \"BoxesRecovered\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"caller\", \"type\": \"address\" } ], \"name\": \"EmergencyModeEnabled\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"tokenType\", \"type\": \"uint8\" }, { \"indexed\": false, \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256[]\", \"name\": \"ids\", \"type\": \"uint256[]\" }, { \"indexed\": false, \"internalType\": \"uint256[]\", \"name\": \"amounts\", \"type\": \"uint256[]\" } ], \"name\": \"EmergencyWithdrawal\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"requestId\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"bytes\", \"name\": \"reason\", \"type\": \"bytes\" } ], \"name\": \"OpenRequestFailed\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"requestId\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"randomness\", \"type\": \"uint256\" } ], \"name\": \"OpenRequestFulfilled\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"opener\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"unitsToGet\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"requestId\", \"type\": \"uint256\" } ], \"name\": \"OpenRequested\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"Paused\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"newPrice\", \"type\": \"uint256\" } ], \"name\": \"PriceUpdated\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"opener\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"tokenId\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" } ], \"name\": \"RewardsClaimed\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"indexed\": true, \"internalType\": \"bytes32\", \"name\": \"previousAdminRole\", \"type\": \"bytes32\" }, { \"indexed\": true, \"internalType\": \"bytes32\", \"name\": \"newAdminRole\", \"type\": \"bytes32\" } ], \"name\": \"RoleAdminChanged\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"sender\", \"type\": \"address\" } ], \"name\": \"RoleGranted\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"sender\", \"type\": \"address\" } ], \"name\": \"RoleRevoked\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"buyer\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"payment\", \"type\": \"uint256\" } ], \"name\": \"Sold\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"supplier\", \"type\": \"address\" } ], \"name\": \"SupplierAdded\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"supplier\", \"type\": \"address\" } ], \"name\": \"SupplierRemoved\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" } ], \"name\": \"TokenAdded\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"address\", \"name\": \"operator\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"from\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256[]\", \"name\": \"ids\", \"type\": \"uint256[]\" }, { \"indexed\": false, \"internalType\": \"uint256[]\", \"name\": \"values\", \"type\": \"uint256[]\" } ], \"name\": \"TransferBatch\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"address\", \"name\": \"operator\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"from\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"value\", \"type\": \"uint256\" } ], \"name\": \"TransferSingle\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"string\", \"name\": \"value\", \"type\": \"string\" }, { \"indexed\": true, \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" } ], \"name\": \"URI\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"Unpaused\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" } ], \"name\": \"Withdraw\", \"type\": \"event\" }, { \"inputs\": [], \"name\": \"DEFAULT_ADMIN_ROLE\", \"outputs\": [ { \"internalType\": \"bytes32\", \"name\": \"\", \"type\": \"bytes32\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"FACTORY\", \"outputs\": [ { \"internalType\": \"contract ILootboxFactory\", \"name\": \"\", \"type\": \"address\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"LINK_ETH_FEED\", \"outputs\": [ { \"internalType\": \"contract AggregatorV3Interface\", \"name\": \"\", \"type\": \"address\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"MINTER_ROLE\", \"outputs\": [ { \"internalType\": \"bytes32\", \"name\": \"\", \"type\": \"bytes32\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"PAUSER_ROLE\", \"outputs\": [ { \"internalType\": \"bytes32\", \"name\": \"\", \"type\": \"bytes32\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"_requestId\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"_randomness\", \"type\": \"uint256\" } ], \"name\": \"_allocateRewards\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"_suppliers\", \"type\": \"address[]\" } ], \"name\": \"addSuppliers\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"_tokens\", \"type\": \"address[]\" } ], \"name\": \"addTokens\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" } ], \"name\": \"balanceOf\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"accounts\", \"type\": \"address[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"ids\", \"type\": \"uint256[]\" } ], \"name\": \"balanceOfBatch\", \"outputs\": [ { \"internalType\": \"uint256[]\", \"name\": \"\", \"type\": \"uint256[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"value\", \"type\": \"uint256\" } ], \"name\": \"burn\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"internalType\": \"uint256[]\", \"name\": \"ids\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"values\", \"type\": \"uint256[]\" } ], \"name\": \"burnBatch\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"_amount\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"_maxPrice\", \"type\": \"uint256\" } ], \"name\": \"buy\", \"outputs\": [], \"stateMutability\": \"payable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint32\", \"name\": \"_gas\", \"type\": \"uint32\" }, { \"internalType\": \"uint256\", \"name\": \"_gasPriceInWei\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"_units\", \"type\": \"uint256\" } ], \"name\": \"calculateOpenPrice\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_opener\", \"type\": \"address\" } ], \"name\": \"canClaimRewards\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_opener\", \"type\": \"address\" } ], \"name\": \"claimRewards\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_token\", \"type\": \"address\" }, { \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"_type\", \"type\": \"uint8\" }, { \"internalType\": \"address\", \"name\": \"_to\", \"type\": \"address\" }, { \"internalType\": \"uint256[]\", \"name\": \"_ids\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"_amounts\", \"type\": \"uint256[]\" } ], \"name\": \"emergencyWithdraw\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getAllowedTokenTypes\", \"outputs\": [ { \"internalType\": \"enum LootboxInterface.RewardType[]\", \"name\": \"result\", \"type\": \"uint8[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getAllowedTokens\", \"outputs\": [ { \"internalType\": \"address[]\", \"name\": \"\", \"type\": \"address[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getAvailableSupply\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getInventory\", \"outputs\": [ { \"components\": [ { \"internalType\": \"address\", \"name\": \"rewardToken\", \"type\": \"address\" }, { \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"rewardType\", \"type\": \"uint8\" }, { \"internalType\": \"uint256\", \"name\": \"units\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"amountPerUnit\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"balance\", \"type\": \"uint256\" }, { \"components\": [ { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"units\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"amountPerUnit\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"balance\", \"type\": \"uint256\" } ], \"internalType\": \"struct LootboxInterface.ExtraRewardInfo[]\", \"name\": \"extra\", \"type\": \"tuple[]\" } ], \"internalType\": \"struct LootboxInterface.RewardView[]\", \"name\": \"result\", \"type\": \"tuple[]\" }, { \"components\": [ { \"internalType\": \"address\", \"name\": \"rewardToken\", \"type\": \"address\" }, { \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"rewardType\", \"type\": \"uint8\" }, { \"internalType\": \"uint256\", \"name\": \"units\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"amountPerUnit\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"balance\", \"type\": \"uint256\" }, { \"components\": [ { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"units\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"amountPerUnit\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"balance\", \"type\": \"uint256\" } ], \"internalType\": \"struct LootboxInterface.ExtraRewardInfo[]\", \"name\": \"extra\", \"type\": \"tuple[]\" } ], \"internalType\": \"struct LootboxInterface.RewardView[]\", \"name\": \"leftoversResult\", \"type\": \"tuple[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getLink\", \"outputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getLinkPrice\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getLootboxTypes\", \"outputs\": [ { \"internalType\": \"uint256[]\", \"name\": \"\", \"type\": \"uint256[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_opener\", \"type\": \"address\" } ], \"name\": \"getOpenerRequestDetails\", \"outputs\": [ { \"components\": [ { \"internalType\": \"address\", \"name\": \"opener\", \"type\": \"address\" }, { \"internalType\": \"uint96\", \"name\": \"unitsToGet\", \"type\": \"uint96\" }, { \"internalType\": \"uint256[]\", \"name\": \"lootIds\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"lootAmounts\", \"type\": \"uint256[]\" } ], \"internalType\": \"struct LootboxInterface.Request\", \"name\": \"request\", \"type\": \"tuple\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getPrice\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" } ], \"name\": \"getRoleAdmin\", \"outputs\": [ { \"internalType\": \"bytes32\", \"name\": \"\", \"type\": \"bytes32\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"internalType\": \"uint256\", \"name\": \"index\", \"type\": \"uint256\" } ], \"name\": \"getRoleMember\", \"outputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" } ], \"name\": \"getRoleMemberCount\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getSuppliers\", \"outputs\": [ { \"internalType\": \"address[]\", \"name\": \"\", \"type\": \"address[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getVRFV2Wrapper\", \"outputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"grantRole\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"hasRole\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"operator\", \"type\": \"address\" } ], \"name\": \"isApprovedForAll\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"isEmergencyMode\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" }, { \"internalType\": \"bytes\", \"name\": \"data\", \"type\": \"bytes\" } ], \"name\": \"mint\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"internalType\": \"uint256[]\", \"name\": \"ids\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"amounts\", \"type\": \"uint256[]\" }, { \"internalType\": \"bytes\", \"name\": \"data\", \"type\": \"bytes\" } ], \"name\": \"mintBatch\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"_tos\", \"type\": \"address[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"_lootboxTypes\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"_amounts\", \"type\": \"uint256[]\" } ], \"name\": \"mintToMany\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" }, { \"internalType\": \"uint256[]\", \"name\": \"\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"\", \"type\": \"uint256[]\" }, { \"internalType\": \"bytes\", \"name\": \"\", \"type\": \"bytes\" } ], \"name\": \"onERC1155BatchReceived\", \"outputs\": [ { \"internalType\": \"bytes4\", \"name\": \"\", \"type\": \"bytes4\" } ], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" }, { \"internalType\": \"bytes\", \"name\": \"\", \"type\": \"bytes\" } ], \"name\": \"onERC1155Received\", \"outputs\": [ { \"internalType\": \"bytes4\", \"name\": \"\", \"type\": \"bytes4\" } ], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" }, { \"internalType\": \"bytes\", \"name\": \"\", \"type\": \"bytes\" } ], \"name\": \"onERC721Received\", \"outputs\": [ { \"internalType\": \"bytes4\", \"name\": \"\", \"type\": \"bytes4\" } ], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint32\", \"name\": \"_gas\", \"type\": \"uint32\" }, { \"internalType\": \"uint256[]\", \"name\": \"_lootIds\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"_lootAmounts\", \"type\": \"uint256[]\" } ], \"name\": \"open\", \"outputs\": [], \"stateMutability\": \"payable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" } ], \"name\": \"openerRequests\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"pause\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"paused\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"_requestId\", \"type\": \"uint256\" }, { \"internalType\": \"uint256[]\", \"name\": \"_randomWords\", \"type\": \"uint256[]\" } ], \"name\": \"rawFulfillRandomWords\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_opener\", \"type\": \"address\" } ], \"name\": \"recoverBoxes\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"_suppliers\", \"type\": \"address[]\" } ], \"name\": \"removeSuppliers\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"renounceRole\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"revokeRole\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"from\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"internalType\": \"uint256[]\", \"name\": \"ids\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"amounts\", \"type\": \"uint256[]\" }, { \"internalType\": \"bytes\", \"name\": \"data\", \"type\": \"bytes\" } ], \"name\": \"safeBatchTransferFrom\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"from\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" }, { \"internalType\": \"bytes\", \"name\": \"data\", \"type\": \"bytes\" } ], \"name\": \"safeTransferFrom\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"_tokens\", \"type\": \"address[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"_ids\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"_amountsPerUnit\", \"type\": \"uint256[]\" } ], \"name\": \"setAmountsPerUnit\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"operator\", \"type\": \"address\" }, { \"internalType\": \"bool\", \"name\": \"approved\", \"type\": \"bool\" } ], \"name\": \"setApprovalForAll\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"_newPrice\", \"type\": \"uint256\" } ], \"name\": \"setPrice\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"string\", \"name\": \"_baseURI\", \"type\": \"string\" } ], \"name\": \"setURI\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_from\", \"type\": \"address\" } ], \"name\": \"supplyAllowed\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes4\", \"name\": \"interfaceId\", \"type\": \"bytes4\" } ], \"name\": \"supportsInterface\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_token\", \"type\": \"address\" } ], \"name\": \"tokenAllowed\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"unitsMinted\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"unitsRequested\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"unitsSupply\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"unpause\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"name\": \"uri\", \"outputs\": [ { \"internalType\": \"string\", \"name\": \"\", \"type\": \"string\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"viewCall\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_token\", \"type\": \"address\" }, { \"internalType\": \"address payable\", \"name\": \"_to\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"_amount\", \"type\": \"uint256\" } ], \"name\": \"withdraw\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" } ]"; + + public Web3Builder ConfigureServices(Web3Builder web3Builder) + { + return web3Builder.Configure(services => + { + services.UseChainlinkLootboxService(new LootboxServiceConfig + { + ContractAddress = contractAddress, + ContractAbi = contractAbi + }); + services.AddSingleton(); + }); + } + } +} diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Utilities/SceneIndexer.cs.meta b/Packages/io.chainsafe.web3-unity.lootboxes/Samples~/Chainlink Lootbox Samples/Scripts/LootboxesServicesAdapter.cs.meta similarity index 83% rename from Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Utilities/SceneIndexer.cs.meta rename to Packages/io.chainsafe.web3-unity.lootboxes/Samples~/Chainlink Lootbox Samples/Scripts/LootboxesServicesAdapter.cs.meta index 90c453b23..f5a49c735 100644 --- a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Utilities/SceneIndexer.cs.meta +++ b/Packages/io.chainsafe.web3-unity.lootboxes/Samples~/Chainlink Lootbox Samples/Scripts/LootboxesServicesAdapter.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 93ae86024927f3f499e488b918531db5 +guid: 1601a8846d451cf4fb87a7082da91a7f MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Utilities/Web3AuthSceneIndexer.cs b/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Utilities/Web3AuthSceneIndexer.cs deleted file mode 100644 index 1b7d7489d..000000000 --- a/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Utilities/Web3AuthSceneIndexer.cs +++ /dev/null @@ -1,23 +0,0 @@ -#if UNITY_EDITOR -using UnityEditor; - -/// -/// Add Web3.Unity Web3Auth package sample scenes to Build Settings Scenes -/// -[InitializeOnLoad] -public static class Web3AuthSceneIndexer -{ - private const string ScenesIndexedKey = PackageName + "ScenesIndexed"; - - private const string PackageName = "io.chainsafe.web3-unity.web3auth"; - - static Web3AuthSceneIndexer() - { - SceneIndexer.TryAddEditorBuildSettingsScenes(PackageName, ScenesIndexedKey, new string[] - { - "SampleLogin - Web3Auth.Unity", - }); - } -} - -#endif \ No newline at end of file diff --git a/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Utilities/Web3AuthSceneIndexer.cs.meta b/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Utilities/Web3AuthSceneIndexer.cs.meta deleted file mode 100644 index 50f8761b4..000000000 --- a/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Utilities/Web3AuthSceneIndexer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 74c0e58ffe715a448a1d221b425d7352 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Web3AuthLogin.cs b/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Web3AuthLoginProvider.cs similarity index 84% rename from Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Web3AuthLogin.cs rename to Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Web3AuthLoginProvider.cs index ed1a4a8c9..18d6e62a6 100644 --- a/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Web3AuthLogin.cs +++ b/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Web3AuthLoginProvider.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using ChainSafe.Gaming.Exchangers.Ramp; using ChainSafe.Gaming.UnityPackage; +using ChainSafe.Gaming.UnityPackage.Common; using ChainSafe.Gaming.Web3; using ChainSafe.Gaming.Web3.Analytics; using ChainSafe.Gaming.Web3.Build; @@ -16,11 +17,11 @@ /// /// Login using Web3Auth. /// -public class Web3AuthLogin : Login +public class Web3AuthLoginProvider : LoginProvider, IWeb3BuilderServiceAdapter { /// /// Struct used for pairing login buttons to Web3 auth providers. - /// Used when adding as listeners to the buttons. + /// Used when adding as listeners to the buttons. /// [Serializable] public struct ProviderAndButtonPair @@ -35,7 +36,7 @@ public struct ProviderAndButtonPair [SerializeField] private Network network; [Header("UI")] [SerializeField] private List providerAndButtonPairs; - + private bool useProvider; private Provider selectedProvider; @@ -47,13 +48,13 @@ public void SetRememberMe(bool rememberMe) this.rememberMe = rememberMe; } - protected override IEnumerator Initialize() + protected override async void Initialize() { + base.Initialize(); + //Always first add listeners. providerAndButtonPairs.ForEach(p => p.Button.onClick.AddListener(delegate { LoginWithWeb3Auth(p.Provider); })); - - yield return null; #if UNITY_WEBGL && !UNITY_EDITOR Uri uri = new Uri(Application.absoluteURL); @@ -63,9 +64,7 @@ protected override IEnumerator Initialize() { useProvider = false; - Task loginTask = TryLogin(); - - yield return new WaitUntil(() => loginTask.IsCompleted); + await TryLogin(); } #else @@ -73,15 +72,10 @@ protected override IEnumerator Initialize() { useProvider = false; rememberMe = true; - Task loginTask = TryLogin(); + await TryLogin(); Debug.Log("Restoring existing Web3Auth session (Remember Me"); - yield return new WaitUntil(() => loginTask.IsCompleted); } #endif - - // add provider buttons listeners - - } private async void LoginWithWeb3Auth(Provider provider) @@ -91,8 +85,7 @@ private async void LoginWithWeb3Auth(Provider provider) useProvider = true; } selectedProvider = provider; - - + await TryLogin(); LogAnalytics(provider); } @@ -111,7 +104,7 @@ private void LogAnalytics(Provider provider) }); } - protected override Web3Builder ConfigureWeb3Services(Web3Builder web3Builder) + public Web3Builder ConfigureServices(Web3Builder web3Builder) { return web3Builder.Configure(services => { @@ -140,7 +133,7 @@ protected override Web3Builder ConfigureWeb3Services(Web3Builder web3Builder) }; } - services.UseWeb3AuthWallet(web3AuthConfig); + services.UseWeb3AuthWallet(web3AuthConfig); }); } } diff --git a/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Web3AuthLogin.cs.meta b/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Web3AuthLoginProvider.cs.meta similarity index 100% rename from Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Web3AuthLogin.cs.meta rename to Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Web3AuthLoginProvider.cs.meta diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin - MetaMask.unity b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin - MetaMask.unity index fcd389c92..fd738cc43 100644 --- a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin - MetaMask.unity +++ b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin - MetaMask.unity @@ -249,7 +249,7 @@ MonoBehaviour: m_GameObject: {fileID: 314965759} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: c001d0d5433b4215b8abba94194881bd, type: 3} + m_Script: {fileID: 11500000, guid: 9df78976caa7771429cfe2b9b96e1491, type: 3} m_Name: m_EditorClassIdentifier: MessageLabel: {fileID: 1028782728} @@ -263,6 +263,7 @@ GameObject: m_Component: - component: {fileID: 433476714} - component: {fileID: 433476715} + - component: {fileID: 433476716} m_Layer: 0 m_Name: MetaMaskLogin m_TagString: Untagged @@ -297,11 +298,23 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: b547b7e8ac8d2f442bfefe0c9f59ed1d, type: 3} m_Name: m_EditorClassIdentifier: - k__BackingField: SampleMain gelatoApiKey: 7MFQqyGS1Iui_e_MgmFW1BfbFeJ06g8nnL2oUTlIJug_ errorPopup: {fileID: 314965761} rampConfig: {fileID: 11400000, guid: d1f58846e4fc71d4e90f287a86f328f9, type: 2} loginButton: {fileID: 2048731599} +--- !u!114 &433476716 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 433476712} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3d2237df0314604419146b916b88d158, type: 3} + m_Name: + m_EditorClassIdentifier: + sceneToLoad: SampleMain --- !u!1 &740974330 GameObject: m_ObjectHideFlags: 0 diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin.unity b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin - WalletConnect.unity similarity index 99% rename from Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin.unity rename to Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin - WalletConnect.unity index 3f93cb2db..e7c5b063a 100644 --- a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin.unity +++ b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin - WalletConnect.unity @@ -2641,6 +2641,7 @@ GameObject: m_Component: - component: {fileID: 1334079841} - component: {fileID: 1334079842} + - component: {fileID: 1334079843} m_Layer: 0 m_Name: Logic - Login m_TagString: Untagged @@ -2675,7 +2676,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 96894e49d9863ec4db1d93a5e56f19cb, type: 3} m_Name: m_EditorClassIdentifier: - k__BackingField: SampleMain gelatoApiKey: 7MFQqyGS1Iui_e_MgmFW1BfbFeJ06g8nnL2oUTlIJug_ errorPopup: {fileID: 1701305868} rampConfig: {fileID: 11400000, guid: d1f58846e4fc71d4e90f287a86f328f9, type: 2} @@ -2702,6 +2702,19 @@ MonoBehaviour: Universal: VerifyUrl: walletConnectModal: {fileID: 395689441} +--- !u!114 &1334079843 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1334079840} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3d2237df0314604419146b916b88d158, type: 3} + m_Name: + m_EditorClassIdentifier: + sceneToLoad: SampleMain --- !u!1 &1491563361 GameObject: m_ObjectHideFlags: 0 @@ -3193,7 +3206,7 @@ MonoBehaviour: m_GameObject: {fileID: 1701305866} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: c001d0d5433b4215b8abba94194881bd, type: 3} + m_Script: {fileID: 11500000, guid: 9df78976caa7771429cfe2b9b96e1491, type: 3} m_Name: m_EditorClassIdentifier: MessageLabel: {fileID: 786896302} diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin.unity.meta b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin - WalletConnect.unity.meta similarity index 100% rename from Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin.unity.meta rename to Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin - WalletConnect.unity.meta diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Prefabs/Logout.cs b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Prefabs/Logout.cs index 88781c9bd..777b0f582 100644 --- a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Prefabs/Logout.cs +++ b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Prefabs/Logout.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; using ChainSafe.Gaming.UnityPackage; using ChainSafe.Gaming.Wallets; +using ChainSafe.Gaming.UnityPackage.Common; using Scenes; using UnityEngine; using UnityEngine.SceneManagement; @@ -19,6 +20,6 @@ public async void OnLogout() Web3Accessor.Clear(); // Go back to the first scene to log in again - SceneManager.LoadScene(Login.LoginSceneIndex); + await SceneManager.LoadSceneAsync(LoadSceneOnLogin.LoginSceneBuildIndex); } } diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ErrorPopup.cs b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ErrorPopup.cs deleted file mode 100644 index f8c26431a..000000000 --- a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ErrorPopup.cs +++ /dev/null @@ -1,21 +0,0 @@ -using UnityEngine; -using UnityEngine.UI; - -namespace Scenes -{ - public class ErrorPopup : MonoBehaviour - { - public Text MessageLabel; - - public void ShowError(string message) - { - gameObject.SetActive(true); - MessageLabel.text = message; - } - - public void Close() - { - gameObject.SetActive(false); - } - } -} \ No newline at end of file diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ErrorPopup.cs.meta b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ErrorPopup.cs.meta deleted file mode 100644 index b0a77395c..000000000 --- a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ErrorPopup.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: c001d0d5433b4215b8abba94194881bd -timeCreated: 1691581208 \ No newline at end of file diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/Login.cs b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/Login.cs deleted file mode 100644 index 146dc217b..000000000 --- a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/Login.cs +++ /dev/null @@ -1,105 +0,0 @@ -using System; -using System.Collections; -using System.Threading.Tasks; -using ChainSafe.Gaming.Evm.Contracts; -using ChainSafe.Gaming.Evm.JsonRpc; -using ChainSafe.Gaming.Exchangers.Ramp; -using ChainSafe.Gaming.MultiCall; -using ChainSafe.Gaming.UnityPackage; -using ChainSafe.Gaming.Web3; -using ChainSafe.Gaming.Web3.Build; -using ChainSafe.Gaming.Web3.Unity; -using ChainSafe.GamingSdk.Gelato; -using Scripts.EVM.Token; -using UnityEngine; -using UnityEngine.SceneManagement; - -namespace Scenes -{ - public abstract class Login : MonoBehaviour - { - [field:SerializeField] public string SceneToLoad { get; private set; } - - public static int LoginSceneIndex { get; private set; } = 0; - - [SerializeField] private string gelatoApiKey = ""; - - [SerializeField] private ErrorPopup errorPopup; - - [SerializeField] private RampExchangerConfigSO rampConfig; - - private IEnumerator Start() - { - yield return Initialize(); - } - - protected abstract IEnumerator Initialize(); - - protected abstract Web3Builder ConfigureWeb3Services(Web3Builder web3Builder); - - protected async Task TryLogin() - { - Web3 web3; - - try - { - Web3Builder web3Builder = new Web3Builder(ProjectConfigUtilities.Load()) - .Configure(ConfigureCommonServices); - - web3Builder = ConfigureWeb3Services(web3Builder); - - web3 = await web3Builder.LaunchAsync(); - } - - catch (Exception) - { - - errorPopup.ShowError("Login failed, please try again\n(see console for more details)"); - throw; - } - - Web3Accessor.Set(web3); - - //TODO: REMOVE THIS - if (rampConfig != null) - { - - Web3Accessor.Web3.RampExchanger().OnRampPurchaseCreated += data - => Debug.Log($"On-Ramp purchase created {data.CryptoAmount} {data.Asset.Name}"); - Web3Accessor.Web3.RampExchanger().OffRampSaleCreated += data - => Debug.Log($"Off-Ramp sale created {data.Fiat.Amount:C} {data.Fiat.CurrencySymbol}"); - } - - LoginSceneIndex = SceneManager.GetActiveScene().buildIndex; - - // Attempt scene transition based on the login object sceneToLoad value - SceneManager.LoadScene(SceneToLoad); - } - - private void ConfigureCommonServices(IWeb3ServiceCollection services) - { - services - .UseUnityEnvironment() - .UseGelato(gelatoApiKey) - .UseMultiCall() - .UseRpcProvider(); - - if (rampConfig != null) - services.UseRampExchanger(rampConfig); - else - Debug.LogWarning("Ramp config not provided"); - - /* As many contracts as needed may be registered here. - * It is better to register all contracts the application - * will be interacting with at configuration time if they - * are known in advance. We're just registering shiba - * here to show how it's done. You can look at the - * `Scripts/Prefabs/Wallet/RegisteredContract` script - * to see how it's used later on. - */ - services.ConfigureRegisteredContracts(contracts => - contracts.RegisterContract("CsTestErc20", ABI.Erc20, Contracts.Erc20)); - - } - } -} \ No newline at end of file diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/Login.cs.meta b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/Login.cs.meta deleted file mode 100644 index 61485ea02..000000000 --- a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/Login.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 9473851428864b439d6561c87053272a -timeCreated: 1691581402 \ No newline at end of file diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/MetaMaskLogin.cs b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/MetaMaskLoginProvider.cs similarity index 80% rename from Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/MetaMaskLogin.cs rename to Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/MetaMaskLoginProvider.cs index ed96d979f..2cd23b3e4 100644 --- a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/MetaMaskLogin.cs +++ b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/MetaMaskLoginProvider.cs @@ -1,4 +1,5 @@ using System.Collections; +using ChainSafe.Gaming.UnityPackage.Common; #if UNITY_WEBGL && !UNITY_EDITOR using ChainSafe.Gaming.MetaMask; using ChainSafe.Gaming.MetaMask.Unity; @@ -12,15 +13,15 @@ /// Login using MetaMask. /// Only works for UnityWebGL build (not in editor). /// -public class MetaMaskLogin : Login +public class MetaMaskLoginProvider : LoginProvider, IWeb3BuilderServiceAdapter { [SerializeField] private Button loginButton; - protected override IEnumerator Initialize() + protected override void Initialize() { - loginButton.onClick.AddListener(LoginClicked); + base.Initialize(); - yield return null; + loginButton.onClick.AddListener(LoginClicked); } private async void LoginClicked() @@ -28,7 +29,7 @@ private async void LoginClicked() await TryLogin(); } - protected override Web3Builder ConfigureWeb3Services(Web3Builder web3Builder) + public Web3Builder ConfigureServices(Web3Builder web3Builder) { return web3Builder.Configure(services => { diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/MetaMaskLogin.cs.meta b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/MetaMaskLoginProvider.cs.meta similarity index 100% rename from Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/MetaMaskLogin.cs.meta rename to Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/MetaMaskLoginProvider.cs.meta diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ExistingWalletLogin.cs b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/WalletConnectLoginProvider.cs similarity index 96% rename from Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ExistingWalletLogin.cs rename to Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/WalletConnectLoginProvider.cs index 7dd991dc2..0938fd38c 100644 --- a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ExistingWalletLogin.cs +++ b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/WalletConnectLoginProvider.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using ChainSafe.Gaming.Unity; using ChainSafe.Gaming.UnityPackage; +using ChainSafe.Gaming.UnityPackage.Common; using ChainSafe.Gaming.WalletConnect; using ChainSafe.Gaming.WalletConnect.Models; using ChainSafe.Gaming.Web3.Build; @@ -27,7 +28,7 @@ /// /// Login using an existing wallet using Wallet Connect. /// -public class ExistingWalletLogin : Login +public class WalletConnectLoginProvider : LoginProvider, IWeb3BuilderServiceAdapter { [Header("UI")][SerializeField] private TMP_Dropdown supportedWalletsDropdown; @@ -76,8 +77,10 @@ private void OnDestroy() } } - protected override IEnumerator Initialize() + protected override async void Initialize() { + base.Initialize(); + Assert.IsNotNull(loginButton); Assert.IsNotNull(rememberMeToggle); @@ -110,13 +113,11 @@ protected override IEnumerator Initialize() if (!isRedirectionWalletAgnostic) { - yield return InitializeWalletSelection(); + await InitializeWalletSelection(); } // try auto login first - var autoLoginTask = TryAutoLogin(); - - yield return new WaitUntil(() => autoLoginTask.IsCompleted); + await TryAutoLogin(); loginButton.onClick.AddListener(LoginClicked); } @@ -126,7 +127,7 @@ private async void LoginClicked() await TryLogin(); } - protected override Web3Builder ConfigureWeb3Services(Web3Builder web3Builder) + public Web3Builder ConfigureServices(Web3Builder web3Builder) { return web3Builder.Configure(services => { diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ExistingWalletLogin.cs.meta b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/WalletConnectLoginProvider.cs.meta similarity index 100% rename from Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ExistingWalletLogin.cs.meta rename to Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/WalletConnectLoginProvider.cs.meta diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Utilities/SceneIndexer.cs b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Utilities/SceneIndexer.cs deleted file mode 100644 index c5b9f9cd6..000000000 --- a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Utilities/SceneIndexer.cs +++ /dev/null @@ -1,89 +0,0 @@ -#if UNITY_EDITOR - -using System; -using System.IO; -using System.Linq; -using Scenes; -using UnityEditor; -using UnityEditor.PackageManager; -using UnityEditor.PackageManager.UI; -using PackageInfo = UnityEditor.PackageManager.PackageInfo; - -[InitializeOnLoad] -public static class SceneIndexer -{ - private const string ScenesIndexedKey = PackageName + "ScenesIndexed"; - - private const string PackageName = "io.chainsafe.web3-unity"; - - static SceneIndexer() - { - TryAddEditorBuildSettingsScenes(PackageName, ScenesIndexedKey, new string[] - { - "SampleLogin.Unity", - "SampleMain.Unity" - }); - } - - public static void TryAddEditorBuildSettingsScenes(string packageName, string sessionKey, string[] scenes) - { - if (SessionState.GetBool(sessionKey, false)) - { - return; - } - - PackageInfo package = GetPackage(packageName); - - string importPath = GetImportPath(package); - - //Clear out scenes that do not exist - EditorBuildSettings.scenes = EditorBuildSettings.scenes.Where(s => !string.IsNullOrEmpty(s.path)).ToArray(); - - //scenes already added to build settings - if (EditorBuildSettings.scenes.Any(s => Path.GetFullPath(s.path).Contains(importPath))) - { - SessionState.SetBool(sessionKey, true); - - return; - } - - // convert and add importPath to scenes path - EditorBuildSettingsScene[] editorBuildSettingsScenes = Array.ConvertAll(scenes, s => new EditorBuildSettingsScene(Path.Combine(importPath, s), true)); - - EditorBuildSettings.scenes = editorBuildSettingsScenes.Concat(EditorBuildSettings.scenes).ToArray(); - - SessionState.SetBool(sessionKey, true); - } - - private static PackageInfo GetPackage(string name) - { - var listRequest = Client.List(); - - while (!listRequest.IsCompleted) - { - //do nothing - } - - PackageInfo[] packages = listRequest.Result.ToArray(); - - PackageInfo package = packages.FirstOrDefault(p => p.name == name); - - if (package == null) - { - throw new Exception($"Installed Package {name} not found"); - } - - return package; - } - - private static string GetImportPath(PackageInfo package) - { - Sample sample = Sample.FindByPackage(package.name, package.version).FirstOrDefault(); - - string importPath = Path.GetRelativePath(Directory.GetCurrentDirectory(), sample.importPath); - - return Path.Combine(importPath, "Scenes"); - } -} - -#endif \ No newline at end of file From 1b8db69a7f725da63684e661eb41de37fbf31337 Mon Sep 17 00:00:00 2001 From: robGG1997 Date: Mon, 29 Jan 2024 14:55:43 +0000 Subject: [PATCH 6/9] Published Solution Dependencies to Package Libraries as DLLs --- .../ChainSafe.Gaming.Lootboxes.Chainlink.dll | Bin 32256 -> 32256 bytes .../Libraries/Chainsafe.Gaming.Chainlink.dll | Bin 5632 -> 5632 bytes .../Libraries/ChainSafe.Gaming.Debugging.dll | Bin 16384 -> 16384 bytes .../Libraries/ChainSafe.Gaming.Gelato.dll | Bin 45568 -> 45568 bytes .../ChainSafe.Gaming.InProcessSigner.dll | Bin 8192 -> 8192 bytes ...ing.InProcessTransactionExecutor.Unity.dll | Bin 6656 -> 6656 bytes ...fe.Gaming.InProcessTransactionExecutor.dll | Bin 11264 -> 11264 bytes .../ChainSafe.Gaming.MetaMask.Unity.dll | Bin 14848 -> 14848 bytes .../Libraries/ChainSafe.Gaming.MetaMask.dll | Bin 11264 -> 11264 bytes .../ChainSafe.Gaming.Unity.ThirdParty.dll | Bin 24064 -> 24064 bytes .../Libraries/ChainSafe.Gaming.Unity.dll | Bin 14848 -> 14848 bytes .../ChainSafe.Gaming.WalletConnect.dll | Bin 36352 -> 36352 bytes .../Runtime/Libraries/ChainSafe.Gaming.dll | Bin 216576 -> 216576 bytes 13 files changed, 0 insertions(+), 0 deletions(-) diff --git a/Packages/io.chainsafe.web3-unity.lootboxes/Chainlink/Runtime/Libraries/ChainSafe.Gaming.Lootboxes.Chainlink.dll b/Packages/io.chainsafe.web3-unity.lootboxes/Chainlink/Runtime/Libraries/ChainSafe.Gaming.Lootboxes.Chainlink.dll index 11abfb4e288e9f083376417c49294c941208b043..0b26e94d81ef9e14e7b6a0c6160175c1094213d1 100644 GIT binary patch delta 238 zcmZqp!`SeLaY6^n^0k-lZ0xCs7qDu!oWDt$$7AmW>-*uBLi0C^B)ITsBpaC-BpVwV zBqo|CCK{%inI#&U8W|X-CR&)9rlc5|rWsnM8kicHZ*ItOVPnxd)UaUkiJ|}j1>66h zFRu9QvHL9hzuMhaa+5WR7brjlE3Bb{K-CHBL*`D z1BPS3g8%?&v&Y%CG4%MMRIQ4}B$#?Q09 z>)8>Hnd?4&Ud@?(d$LCH0tKibM;ze=371gC!6f z0igwh8G{KBn*&J`h9n?NWH1Esl7TAHfH)Z_Vhkh=fNDUhLGq?Ro&`|W7$|1QV6fS} HY9})Q3*AnQ diff --git a/Packages/io.chainsafe.web3-unity.lootboxes/Chainlink/Runtime/Libraries/Chainsafe.Gaming.Chainlink.dll b/Packages/io.chainsafe.web3-unity.lootboxes/Chainlink/Runtime/Libraries/Chainsafe.Gaming.Chainlink.dll index 1a5666d7e19f8a6fb934a7fe9b0a0e1c00ff38da..6ac717bdf5018129c0eb1145d658078e8654d8e4 100644 GIT binary patch delta 235 zcmZqBY0#O_!Lqwg=;_8D4NieTj)^bZjqJRqxfdLtx!`xo<|CYvj2g*CW(LW|h6ag= z=81`hsb*%0hNeaahN+1brlu(=My6?omZ=7&M&^@QxuaP`qbGMxPT>v^*z7AlQCIY= zPiG%*e(f!D(aA@+dlaC8XJCRr)tnr6QZJe&Rfq~z&Dp%UfJcSZKbgUZ!HmIxA(_FL z!4OC%0--sWG-OBx%9sJ!h76`aRR%yh709yy@=O_0fY1m?rvXJRf#L>WHRhWi3(B$p E04H@pfB*mh delta 235 zcmZqBY0#O_!Lle+^Z&*k4Nd{^m;20}_1}AU&VK%Jvg<1D%||#T88uQ(ElrJ#EX+*I z%uP&^k`fKglP%LMlaq{-4a|%zk`he~EYgh43=Jl;a!0e=PYSv)IfXkwpyuk*nNP(M z9p=>@E;%#j=Ksk@xO)^}g7=_;Ak}KC8LfXPcy4mEnC7>+fJcSZKb66h!4im#fY5@$ zjKKtm&4Hu|LlO`sG8h7R$v_opK%5K|F$R(bKs6xMAbC?D&jKiG3=}hDFxdQ9P?iM% DI(A8@ diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Debugging.dll b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Debugging.dll index 3f33895c484d8a0b549c4177f1d4b0d05e31e44e..1b9b3aed8c314141ab142b149ce68aa111c6f00c 100644 GIT binary patch delta 252 zcmZo@U~Fh$oY28C?Mv>0jXecA0`{}dDTTa0>b{bH;p>w%S)rSGboE*Fl8wv^l8p@w z5);i66Ae?%%n}VvjSLJ^6D>?lQ&Nmf(+n+B4NQ&985kTG8LTJgXh}>yU@WkCqER#x zi|>_3rzd|f2@tsH_S9|P>>KVY&d+$}uyo8#0&zRT%*3R3Og+$TMX~ Y0YW1nody)O1d1Dg)tGO7Y%R+I0ClTV6#xJL delta 252 zcmZo@U~Fh$oY29dUEcO$V^4vOfVUbWi}Wfkm$lo}9L#Q>&fLtStIw*JYHDd}WMpAx zVrFh)l9ZHaXr64DW|^F1oNQobWRa9;YG9FOY-VV{z~I2hU_CiUOJec?V}Z>RjiQ-Y z#P4leI{AZ1fWR~6N#b)f)g1e35=*DQ;gFjgVA`Vq75vBt6$GkQ-CADqYWAw{8CUgc zc{cwsox$p#%3#W13B*P~Xu)8{U;@PEK+=RE2?!Gz41v64po%mgP6mn?14#p*8jxy` WyeW`p0hBcciWxE(Y<_Gl%K`wDB1k3x diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Gelato.dll b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Gelato.dll index 7557c6b8f32bbae38dea87e3f43e0504766f957d..05fedd1f8604bbd4c18002dd2dea87ba18fdafcc 100644 GIT binary patch delta 242 zcmZp8!qo7DX+j4}+ty2GH}(ij6mV|V_?A1($GP*e%>2jzhMLW5CWi57BpaC-BpVwV zBqo|CCK{%inI#&U8W|X-CR&)9rlc5|rWsnM8kicHPcB%XxjA^=Q7)ES>kj^!EVD8| zKu)xQ1`Npz#teo)IuQuX!K5KWDp1A@$Tnm!1*$Rt(y2h61(0XTkOG88KspU5Y6%oK N0IM}UXlR~nnP!=sWSneZW@M3+Xlh`QW^86SIe&rH=HPipxmXtQIq#b+vob)y zecHY`vn+-DcQ=SX(NPtVpIo!DO#v!6A0`M?ZMW^hM|uA_s=jZlMM^g-t@2{^Ph~J= zumoZwAhcjGV=w_?b0BHLkOYK@42D2nGEhYt5GMmgjDe&9Pz^{mNZu64vjEB(1H}v( L3^wmx@5%%KtpG`G diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.InProcessSigner.dll b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.InProcessSigner.dll index 38dc123956a886f3d7fd671a2fd83a4c45cbad41..6f3115348ab5124ed152e66ad0d90e11dbb552d5 100644 GIT binary patch delta 235 zcmZp0XmFU&!IC1U-n+5qjG#c&<%h3jr1tvlw%TmAs`_fc<_sY{CXHkxGlOJfLxaRb z^Tb5MR5PQ1`Npz z#teo)IuQuX!K5KWDp1A@$Tnm!1*$Rt(y2h61(0XTkOG88KspU5Y6%oK0IMtT*_iQlvWjScK+olRAm69Q-M4SAkUN`1qh9RbQ)095-4r}R%5>TvY0M2 E04sw+&j0`b delta 235 zcmZoLX)u}4!Lq*b_}7g+XLtmH1S${AFS+R4{H}Ly{^yUsH)rs6FlwZlTACUeS(ura znVXm-B_$e~CtIdjCMOvu8<-hcBqf>}Sfm-785&HM;E!Q3Z40a%Us=II)l F%mCP0O^N^j delta 235 zcmZpOXo#55!4j5v?(@c;719E{t;#Q+{=Vup{nv{8qATokH@nF6Gi#)pTACUeS(ura znVXm-B_$e~CtIdjCMOvu8<-hcBqf>}Sfm-785&IfEq|0HOY&O7tJ((u5%i2oo6$fxKj(iZmcj28tL1Ndur7kZO>;DUfFYlr;v588R4bp01I} F3;=HYMcM!W diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.MetaMask.Unity.dll b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.MetaMask.Unity.dll index 031f1f62ae58403e28960e4fa3c2a46d5d771738..77de0bdd85c94509e364691181164c366635735a 100644 GIT binary patch delta 245 zcmZoDX(*Y{!Q%O}_20&x0!@M0&rS#&Ui{v7llcXuODoU++{~lp%%YcUWM+_TY-o^} zXr7p8m}+L0XlQC=V3?X{VQQL^Vq}_TXqjqYYGls9;K9h?JXzjAVe(wP%`7`VO6{K< zq8}izxV+1KBP*Bh@|v=_Y!OG#Ox~hDO#v#%s}2d{Ig29Zz1c=RnqzOY35GFDh0(r?m6=^`63=}a2k_JFEAk`pwQy|X*C~FK9 NGh{H>%x(6S82~NNOaA}> diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.MetaMask.dll b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.MetaMask.dll index 4db43e04c3141ac060f962209053e1d205c5e45e..6e74fe2e3a42561d7440cb9ae882a7567f4a524b 100644 GIT binary patch delta 249 zcmZpOXo#55!6J3K`RK-;5E+5ym*J)>n2miJ^rokL_q>p|`GZUjvtF{1nL)C#p+RDz zd19hrs+n1$p{bF9VQQj#W-tWOi9l!$CJh-xN>046YjQ-$ECr}wG)xevI_LV;mi>Q3-@Fvdd9ZP_Q0P7u|6~Ru1~Uc& zhGYg~216j72!!Tf(vTq)C}Rd>8#0&zRT%*3R3Og+$TMX~0YW1nody)O1d1Dg)tGOV Ik9x=q0D4+XT>t<8 delta 238 zcmZqJ!`QHgaY6^nQU%wu8+&fJ3oJ3yR=zWFqr;*@vu4_BPu{+{#6yHbBh}Q>)X2!f z%*4#x#3U&x(a=2EGR-nM$vD}-%*Y}s(bT{q&DhM)VDp9m7iJcT(;iKee*^~z_|1K3 zyZ5A)~d}sm{1gUoN-gHqbVKaBaq^plM3x)1u@lRziWv~Qd zBOtV3Fk>(QVsjvA!jJ@ni42B7UNTTc8W1M~MT~)@0Z-8Uw`)84Nbd IM?GW)0DX!}ApigX diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Unity.dll b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Unity.dll index 83ae70c1c93b4c61a0459db608663fb3bc6610f2..0ebe969c39f47b9c7d1e80a070579bfe3f8b622f 100644 GIT binary patch delta 235 zcmZoDX(*Y{!IHb7{o%%*DGCA$6tm_g1gd*X-{XAEwq3Povw`9j7L8;hGlOJfLxaRb z^Tb5MR5Pu+RS2f zV9a0$q!WSA984NAqylBkfNVnsQ=lpXAe{>2Spa#a3@Jcp1f8#0&zRT%*3R3Og+$TMX~0YW1nody)O1d1Dg)tGPQ I?)u6M0Ht(Hj{pDw delta 238 zcmZpe!_+W`X+j6fG%LH#jXgIC1@akHK2=H8IIcgxeyUJ(h0*4cqQzVqsiu~uMn)E9 zCT8X)CP_(&hUUqZX_m=J#>oa|MixnlrUn*i#%6{Fo9$~W*;pj~YhFy=(;Oi1GfZsV z%f@tvy$?!_ws#&oHCd)*iUL&dK`m4es5(PS2cR~kCP@4Y6jk!VrD*8_ZDhgDe@@N}#RK@DUPd*%;vwVAt zJM$W5|6~Ru1~Uc&hGYg~216j72!!Tf(vTq)C}Rd>8#0&zRT%*3R3Og+$TMX~0YW1n Vody)O1d1Dg)tGOu_hxQn0sw|zOmYAK delta 258 zcmZpe!`m>2cR~kCx#jX>jXkYBj9Yt{W@HO!Wu~frd>P;|g-6o(O;F#H?It-)j62j) zO)X80j4aGd%*;(pl9Cb)&66$DER&OrlMT#_ERqsU4J^`(&8AP#WtN(QVsjvA!jJ@ni42B7UNTTc8W1M~MT~)@ d0Z-8Uw`)84R}9dowpO0RRigPptp| From 11bc8026d8a59ebb30eec8e8872f20877b828a71 Mon Sep 17 00:00:00 2001 From: robGG1997 Date: Mon, 29 Jan 2024 18:00:19 +0300 Subject: [PATCH 7/9] ramp adapter added and small merge revert --- .../Runtime/Scripts/RampServiceAdapter.cs | 24 +++++++++++++++++++ .../Scripts/RampServiceAdapter.cs.meta | 11 +++++++++ .../Scenes/SampleLogin - Web3Auth.unity | 22 +++++++++++++---- .../Packages/packages-lock.json | 22 ++++++++--------- 4 files changed, 63 insertions(+), 16 deletions(-) create mode 100644 Packages/io.chainsafe.web3-unity.ramp/Runtime/Scripts/RampServiceAdapter.cs create mode 100644 Packages/io.chainsafe.web3-unity.ramp/Runtime/Scripts/RampServiceAdapter.cs.meta diff --git a/Packages/io.chainsafe.web3-unity.ramp/Runtime/Scripts/RampServiceAdapter.cs b/Packages/io.chainsafe.web3-unity.ramp/Runtime/Scripts/RampServiceAdapter.cs new file mode 100644 index 000000000..1bb4ba2d3 --- /dev/null +++ b/Packages/io.chainsafe.web3-unity.ramp/Runtime/Scripts/RampServiceAdapter.cs @@ -0,0 +1,24 @@ +using System.Collections; +using System.Collections.Generic; +using ChainSafe.Gaming.UnityPackage.Common; +using ChainSafe.Gaming.Web3.Build; +using UnityEngine; + +namespace ChainSafe.Gaming.Exchangers.Ramp +{ + /// + /// Add Ramp service when building a Web3 instance. + /// + public class RampServiceAdapter : MonoBehaviour, IWeb3BuilderServiceAdapter + { + [SerializeField] private RampExchangerConfigSO rampConfig; + + public Web3Builder ConfigureServices(Web3Builder web3Builder) + { + return web3Builder.Configure(services => + { + services.UseRampExchanger(rampConfig); + }); + } + } +} diff --git a/Packages/io.chainsafe.web3-unity.ramp/Runtime/Scripts/RampServiceAdapter.cs.meta b/Packages/io.chainsafe.web3-unity.ramp/Runtime/Scripts/RampServiceAdapter.cs.meta new file mode 100644 index 000000000..f2a4207ba --- /dev/null +++ b/Packages/io.chainsafe.web3-unity.ramp/Runtime/Scripts/RampServiceAdapter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d4bbed5530529ea46a1f41b407499dc5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scenes/SampleLogin - Web3Auth.unity b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scenes/SampleLogin - Web3Auth.unity index 23cde91b0..7c013242a 100644 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scenes/SampleLogin - Web3Auth.unity +++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scenes/SampleLogin - Web3Auth.unity @@ -476,7 +476,7 @@ MonoBehaviour: m_OnClick: m_PersistentCalls: m_Calls: - - m_Target: {fileID: 337558421} + - m_Target: {fileID: 0} m_TargetAssemblyTypeName: Scenes.ErrorPopup, Assembly-CSharp m_MethodName: Close m_Mode: 1 @@ -574,7 +574,7 @@ MonoBehaviour: m_GameObject: {fileID: 337558419} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: c001d0d5433b4215b8abba94194881bd, type: 3} + m_Script: {fileID: 11500000, guid: 9df78976caa7771429cfe2b9b96e1491, type: 3} m_Name: m_EditorClassIdentifier: MessageLabel: {fileID: 804898217} @@ -1184,7 +1184,7 @@ MonoBehaviour: m_OnClick: m_PersistentCalls: m_Calls: - - m_Target: {fileID: 337558421} + - m_Target: {fileID: 0} m_TargetAssemblyTypeName: Scenes.ErrorPopup, Assembly-CSharp m_MethodName: Close m_Mode: 1 @@ -1362,6 +1362,7 @@ GameObject: m_Component: - component: {fileID: 1679801099} - component: {fileID: 1679801100} + - component: {fileID: 1679801101} m_Layer: 0 m_Name: Logic - Login - Web3Auth m_TagString: Untagged @@ -1396,10 +1397,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 7b6902e441950fa4bb5cefdd2263164a, type: 3} m_Name: m_EditorClassIdentifier: - k__BackingField: SampleRampIntegration gelatoApiKey: 7MFQqyGS1Iui_e_MgmFW1BfbFeJ06g8nnL2oUTlIJug_ errorPopup: {fileID: 337558421} - rampConfig: {fileID: 11400000, guid: d1f58846e4fc71d4e90f287a86f328f9, type: 2} clientId: BCc0wTmuXureEzgawhUSZOWu4bgWo56sZPrxLiHQCpg5OHcNrfa44esdTS8Dm77VtmaIyjhbthdWfbLhSwf7jtU redirectUri: torusapp://io.chainsafe.gamingsdk.sdkdemoscene/auth network: 1 @@ -1416,6 +1415,19 @@ MonoBehaviour: Provider: 3 - Button: {fileID: 7400892925769233044} Provider: 4 +--- !u!114 &1679801101 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1679801098} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3d2237df0314604419146b916b88d158, type: 3} + m_Name: + m_EditorClassIdentifier: + sceneToLoad: SampleMain --- !u!1 &1799608969 GameObject: m_ObjectHideFlags: 0 diff --git a/src/UnitySampleProject/Packages/packages-lock.json b/src/UnitySampleProject/Packages/packages-lock.json index b53eae5aa..ecce5f024 100644 --- a/src/UnitySampleProject/Packages/packages-lock.json +++ b/src/UnitySampleProject/Packages/packages-lock.json @@ -10,7 +10,7 @@ "hash": "c2f3628a028373afc8c66e443f7ce21bcb613a47" }, "com.unity.2d.animation": { - "version": "7.0.9", + "version": "7.0.10", "depth": 1, "source": "registry", "dependencies": { @@ -48,12 +48,12 @@ "url": "https://packages.unity.com" }, "com.unity.2d.psdimporter": { - "version": "6.0.6", + "version": "6.0.7", "depth": 1, "source": "registry", "dependencies": { - "com.unity.2d.animation": "7.0.8", - "com.unity.2d.common": "6.0.5", + "com.unity.2d.animation": "7.0.9", + "com.unity.2d.common": "6.0.6", "com.unity.2d.sprite": "1.0.0" }, "url": "https://packages.unity.com" @@ -65,12 +65,12 @@ "dependencies": {} }, "com.unity.2d.spriteshape": { - "version": "7.0.6", + "version": "7.0.7", "depth": 1, "source": "registry", "dependencies": { "com.unity.mathematics": "1.1.0", - "com.unity.2d.common": "6.0.4", + "com.unity.2d.common": "6.0.6", "com.unity.2d.path": "5.0.2", "com.unity.modules.physics2d": "1.0.0" }, @@ -83,7 +83,7 @@ "dependencies": {} }, "com.unity.2d.tilemap.extras": { - "version": "2.2.3", + "version": "2.2.5", "depth": 1, "source": "registry", "dependencies": { @@ -122,13 +122,13 @@ "depth": 0, "source": "builtin", "dependencies": { - "com.unity.2d.animation": "7.0.9", + "com.unity.2d.animation": "7.0.10", "com.unity.2d.pixel-perfect": "5.0.3", - "com.unity.2d.psdimporter": "6.0.6", + "com.unity.2d.psdimporter": "6.0.7", "com.unity.2d.sprite": "1.0.0", - "com.unity.2d.spriteshape": "7.0.6", + "com.unity.2d.spriteshape": "7.0.7", "com.unity.2d.tilemap": "1.0.0", - "com.unity.2d.tilemap.extras": "2.2.3" + "com.unity.2d.tilemap.extras": "2.2.5" } }, "com.unity.ide.rider": { From b5ad699a168dd062466a3ff5bca07e890a3a633d Mon Sep 17 00:00:00 2001 From: robGG1997 Date: Mon, 29 Jan 2024 15:01:14 +0000 Subject: [PATCH 8/9] Auto-duplicate Packages Samples --- .../Scenes/SampleLogin - Web3Auth.unity | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scenes/SampleLogin - Web3Auth.unity b/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scenes/SampleLogin - Web3Auth.unity index 23cde91b0..7c013242a 100644 --- a/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scenes/SampleLogin - Web3Auth.unity +++ b/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scenes/SampleLogin - Web3Auth.unity @@ -476,7 +476,7 @@ MonoBehaviour: m_OnClick: m_PersistentCalls: m_Calls: - - m_Target: {fileID: 337558421} + - m_Target: {fileID: 0} m_TargetAssemblyTypeName: Scenes.ErrorPopup, Assembly-CSharp m_MethodName: Close m_Mode: 1 @@ -574,7 +574,7 @@ MonoBehaviour: m_GameObject: {fileID: 337558419} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: c001d0d5433b4215b8abba94194881bd, type: 3} + m_Script: {fileID: 11500000, guid: 9df78976caa7771429cfe2b9b96e1491, type: 3} m_Name: m_EditorClassIdentifier: MessageLabel: {fileID: 804898217} @@ -1184,7 +1184,7 @@ MonoBehaviour: m_OnClick: m_PersistentCalls: m_Calls: - - m_Target: {fileID: 337558421} + - m_Target: {fileID: 0} m_TargetAssemblyTypeName: Scenes.ErrorPopup, Assembly-CSharp m_MethodName: Close m_Mode: 1 @@ -1362,6 +1362,7 @@ GameObject: m_Component: - component: {fileID: 1679801099} - component: {fileID: 1679801100} + - component: {fileID: 1679801101} m_Layer: 0 m_Name: Logic - Login - Web3Auth m_TagString: Untagged @@ -1396,10 +1397,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 7b6902e441950fa4bb5cefdd2263164a, type: 3} m_Name: m_EditorClassIdentifier: - k__BackingField: SampleRampIntegration gelatoApiKey: 7MFQqyGS1Iui_e_MgmFW1BfbFeJ06g8nnL2oUTlIJug_ errorPopup: {fileID: 337558421} - rampConfig: {fileID: 11400000, guid: d1f58846e4fc71d4e90f287a86f328f9, type: 2} clientId: BCc0wTmuXureEzgawhUSZOWu4bgWo56sZPrxLiHQCpg5OHcNrfa44esdTS8Dm77VtmaIyjhbthdWfbLhSwf7jtU redirectUri: torusapp://io.chainsafe.gamingsdk.sdkdemoscene/auth network: 1 @@ -1416,6 +1415,19 @@ MonoBehaviour: Provider: 3 - Button: {fileID: 7400892925769233044} Provider: 4 +--- !u!114 &1679801101 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1679801098} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3d2237df0314604419146b916b88d158, type: 3} + m_Name: + m_EditorClassIdentifier: + sceneToLoad: SampleMain --- !u!1 &1799608969 GameObject: m_ObjectHideFlags: 0 From 57527bb3a90fc5a32231f9ff2a1f40a2073c50e2 Mon Sep 17 00:00:00 2001 From: robGG1997 Date: Mon, 29 Jan 2024 15:02:04 +0000 Subject: [PATCH 9/9] Published Solution Dependencies to Package Libraries as DLLs --- .../ChainSafe.Gaming.Lootboxes.Chainlink.dll | Bin 32256 -> 32256 bytes .../Libraries/Chainsafe.Gaming.Chainlink.dll | Bin 5632 -> 5632 bytes .../Libraries/ChainSafe.Gaming.Debugging.dll | Bin 16384 -> 16384 bytes .../Libraries/ChainSafe.Gaming.Gelato.dll | Bin 45568 -> 45568 bytes .../ChainSafe.Gaming.InProcessSigner.dll | Bin 8192 -> 8192 bytes ...ing.InProcessTransactionExecutor.Unity.dll | Bin 6656 -> 6656 bytes ...fe.Gaming.InProcessTransactionExecutor.dll | Bin 11264 -> 11264 bytes .../ChainSafe.Gaming.MetaMask.Unity.dll | Bin 14848 -> 14848 bytes .../Libraries/ChainSafe.Gaming.MetaMask.dll | Bin 11264 -> 11264 bytes .../ChainSafe.Gaming.Unity.ThirdParty.dll | Bin 24064 -> 24064 bytes .../Libraries/ChainSafe.Gaming.Unity.dll | Bin 14848 -> 14848 bytes .../ChainSafe.Gaming.WalletConnect.dll | Bin 36352 -> 36352 bytes .../Runtime/Libraries/ChainSafe.Gaming.dll | Bin 216576 -> 216576 bytes 13 files changed, 0 insertions(+), 0 deletions(-) diff --git a/Packages/io.chainsafe.web3-unity.lootboxes/Chainlink/Runtime/Libraries/ChainSafe.Gaming.Lootboxes.Chainlink.dll b/Packages/io.chainsafe.web3-unity.lootboxes/Chainlink/Runtime/Libraries/ChainSafe.Gaming.Lootboxes.Chainlink.dll index 0b26e94d81ef9e14e7b6a0c6160175c1094213d1..e4f725aec8cd2806827e81b571912e5e1f4f3e2f 100644 GIT binary patch delta 238 zcmZqp!`SeLaY6@6M|J7XjXf3d0?|VI8GgN#a@usfDA{z0%gxOq2`)SuNv4S@W|o$T zhGrHiDF$XnCT3=d#%XD$Ny&)@=BXBz28qUrX2!-Tn;UXm*jR!t>(8Bhq9{Nh*V@P{ zKIF6S5=Wnh%NgeiP1Y!0pa2t0feHdu%Rbwi_S05RkmVZtHi^wIiUrvGlNd}H5*bn$ z%or?zFp delta 238 zcmZqp!`SeLaY6^n^0k-lZ0xCs7qDu!oWDt$$7AmW>-*uBLi0C^B)ITsBpaC-BpVwV zBqo|CCK{%inI#&U8W|X-CR&)9rlc5|rWsnM8kicHZ*ItOVPnxd)UaUkiJ|}j1>66h zFRu9QvHL9hzuMhaa+5WR7brjlE3Bb{K-CHBL*`D z1BPSn1`{A@1{61DNCQGsh9rh$AkToooFNsc&JxH1$t42S7z1I-=Es7v FEC8^|MKk~a delta 235 zcmZqBY0#O_!Lqwg=;_8D4NieTj)^bZjqJRqxfdLtx!`xo<|CYvj2g*CW(LW|h6ag= z=81`hsb*%0hNeaahN+1brlu(=My6?omZ=7&M&^@QxuaP`qbGMxPT>v^*z7AlQCIY= zPiG%*e(f!D(aA@+dlaC8XJCRr)tnr6QZJe&Rfq~z&Dp%UfJcSZKbgUZ!HmIxA(_FL z!4OC%0--sWG-OBx%9sJ!h76`aRR%yh709yy@=O_0fY1m?rvXJRf#L>WHRhWi3(B$p E04H@pfB*mh diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Debugging.dll b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Debugging.dll index 1b9b3aed8c314141ab142b149ce68aa111c6f00c..68e9fa68ec8ffad73aa81b6eb193f2aa540994af 100644 GIT binary patch delta 252 zcmZo@U~Fh$oY28y^W16i#-0Kl0nQ@V+!vBt+_rCirg)0suj^(WU42%)B-6wcGfT@v zLoq~t^c^Hd8e#pDkr0RpFmk3U^&&*a}at!vZn$&tE~15A4qpn~!+L7-}lyY*LZxci=1f0c)O z{pLTWGg$qT7)%)w8B!R`7%YJ>k--qivH0jXecA0`{}dDTTa0>b{bH;p>w%S)rSGboE*Fl8wv^l8p@w z5);i66Ae?%%n}VvjSLJ^6D>?lQ&Nmf(+n+B4NQ&985kTG8LTJgXh}>yU@WkCqER#x zi|>_3rzd|f2@tsH_S9|P>>KVY&d+$}uyo8#0&zRT%*3R3Og+$TMX~ Y0YW1nody)O1d1Dg)tGO7Y%R+I0ClTV6#xJL diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Gelato.dll b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Gelato.dll index 05fedd1f8604bbd4c18002dd2dea87ba18fdafcc..9a3b240865da41a389284270842b7718c7ab802d 100644 GIT binary patch delta 242 zcmZp8!qo7DX+j6f?%P#&HueZi6nNJ0;_MX`6Yn15i<^1h<*eDfW?~qRMv`e_ikYQl zqM?~ZN{WG*k%^gEqH$W9X;N~cfqANhr9q-`qM5OA%H)Ctnwx{?9pz#Yv15 z%8hMmOvIr RE)l547zk4~?_Tf91OS|vPH_ML delta 242 zcmZp8!qo7DX+j4}+ty2GH}(ij6mV|V_?A1($GP*e%>2jzhMLW5CWi57BpaC-BpVwV zBqo|CCK{%inI#&U8W|X-CR&)9rlc5|rWsnM8kicHPcB%XxjA^=Q7)ES>kj^!EVD8| zKu)xQ1`Npz#teo)IuQuX!K5KWDp1A@$Tnm!1*$Rt(y2h61(0XTkOG88KspU5Y6%oK N0IMuO!%+QqvWjSc!24d4?}A*c z9*bY<2bS@xN=|MOouL2~j7WwGf>g7JHk^5(Zs31PWb*mVHeyp){gW6>84?*%7|a+f zfiRK55XiCs@>3WLfGi^h6Ch~@6gOr_142`VB!*-l&w#<4Ar+|3637C{B?8qL17XT$ Id6|dI0N8XyS^xk5 delta 235 zcmZp0XmFU&!IC1U-n+5qjG#c&<%h3jr1tvlw%TmAs`_fc<_sY{CXHkxGlOJfLxaRb z^Tb5MR5PQ1`Npz z#teo)IuQuX!K5KWDp1A@$Tnm!1*$Rt(y2h61(0XTkOG88KspU5Y6%oK0IM_!qOnoIMK}5IAyW~e+)}9&y7QqEBFHhYB&Y9E_Zz4 zGOe&;-<-+QN+#dn-=_c-WVr?v1gZXXU&JkC@BD~+Vg-epw+WnM^-p3jWk_U5VK8H` z1j0lHLmRAm69Q-M4SAkUN`1qh9RbQ)095-4r}R%5>TvY0M2 E04sw+&j0`b diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.InProcessTransactionExecutor.dll b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.InProcessTransactionExecutor.dll index 859dca2d27ca08ef59d31e37117c9eb05e3507ff..6cb6355255bfa7af15f07d5deee79269d4dc8681 100644 GIT binary patch delta 235 zcmZpOXo#55!NPQL;pB}yE2ITJS2}lJV^#9ozC(X{mHL99%`P(i%o<6ii7955mWhUD z7AYwPW=1AvW{JjWX{JfZi3aAW7M2Ey#))Re#wnA3%O7Pqwk_-0Km+ delta 235 zcmZpOXo#55!E#3M(SeOUE2IUkP5NIvv8c0a%Us=II)l F%mCP0O^N^j diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.MetaMask.Unity.dll b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.MetaMask.Unity.dll index 77de0bdd85c94509e364691181164c366635735a..e3aa3db6f5c9a06f41237f06ad53cffbc6f0a9b8 100644 GIT binary patch delta 245 zcmZoDX(*Y{!Lp`m%ifJW1)2iYQ|2zsF5Ty|aKi&do5V_=%{*GpEP6?%i7955mWhUD z7AYwPW=1AvW{JjWX{JfZi3aAW7M2Ey#))Re#wiR89*hjmljRK*CePK|%<}2Sia(P> z^aBKx-*i8;U|-}q?HbRTvN?WVCU4Q7rT`UWg$V*x*DT>Zrapu3Yu>V537a-&83eKV zCoz~ZBr>Ehm@!xaVIqSekYxenr!W`*Sw;*dK++5-Zp@Gdgr*Eh49P&A0fRY1Do~vz TkOh)U1gbFx!j#S2W?z{BUNBDF delta 245 zcmZoDX(*Y{!Q%O}_20&x0!@M0&rS#&Ui{v7llcXuODoU++{~lp%%YcUWM+_TY-o^} zXr7p8m}+L0XlQC=V3?X{VQQL^Vq}_TXqjqYYGls9;K9h?JXzjAVe(wP%`7`VO6{K< zq8}izxV+1KBP*Bh@|v=_Y!OG#Ox~hDO#v#%s}2H%^zfPnDvrO6I0AAEfWpR zEK*Vo%#2LT%o2^$(oB<*6AjE$Ei4TZjT6m`jZ+vHoERBwCkHAjO@6PyF?ox^2bQ+! zo6b#Mp%@@A_iJ-|n2wjn_Ht)GS)Zch$s9^u3Q)m_?@&RYYQO2rHM7N69M&o>J1Mhy zlhQdB|0D)ehD3%G1~UdrAWUR11hOoE{1gTQAj^os1W1|z#f=%#fY6j7i6I%tGhi@h YNCm311hPPKi9j{RK$x=myt*L^0AFEDyZ`_I delta 249 zcmZpOXo#55!6J3K`RK-;5E+5ym*J)>n2miJ^rokL_q>p|`GZUjvtF{1nL)C#p+RDz zd19hrs+n1$p{bF9VQQj#W-tWOi9l!$CJh-3c7dURYU~962uFIAa>)uV=om{=S#6yHbBgr%|#mv$& z(a_8yCB?wZ$i&Pn(Ks#5G$}dJz&zE$(jd_|(ahL5W%Gsr7iN}(TlH@z{|F8cXiJ^= zM#oLow|AjgH1AyLg_9#fW+^}gb9teHK-Iagr=@p(etShc<=&J%n}tI6vG^x3m@*_X zq%fEhK%N1EIYTN?oh6V3l1l`t NF$Thv&GJzXnE}ATOuzsD delta 238 zcmZqJ!`QHgaY6@+QK8(ijXgKq1*U{Xwk+@BcHQ4;(Jk{onqzZ`hX{v8vXPlVvaz8- zVxoCsqG76;S)!q-k%3`qqJ^nxN{W$bnxSQ?fvJ)C<_!TZ%q*?xN>046YjQ-$ECr}wG)xevI_LV;mi>Q3-@Fvdd9ZP_Q0P7u|6~Ru1~Uc& zhGYg~216j72!!Tf(vTq)C}Rd>8#0&zRT%*3R3Og+$TMX~0YW1nody)O1d1Dg)tGOV Ik9x=q0D4+XT>t<8 diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Unity.dll b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Unity.dll index 0ebe969c39f47b9c7d1e80a070579bfe3f8b622f..f61a407c0109ad116fcdcefd3df764437c5f5df5 100644 GIT binary patch delta 235 zcmZoDX(*Y{!Ln}YyMG&drYHzlN54s(U^vrfeY)UwpF3jpn++7NuxKQiCZ?EKS|%Er zS)`;Gm>HRvnI#&hrI{urCmNWiT38w+8Yh|=8>ej6QM!^A3k--qivHu+RS2f zV9a0$q!WSA984NAqylBkfNVnsQ=lpXAe{>2Spa#a3@Jcp1fkz|^fVrFTX zXlQ1Ul44+HWMXEPXq=X2nv|SqV4iAWX^?1~Xl87jve~}2l8wb)Ida+LJ@&ZOdkfcPg_v%{E_XdBftL#9+#h$dJNd z#$XAAi42B7mIaWX!e9Vo88MguNi(3hF+&;8#0&zRT%*3R3Og+$TMX~0YW1nody)O1d1Dg)tGPQ I?)u6M0Ht(Hj{pDw diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.dll b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.dll index 7260f21fa30c39445a761bd17ba80f882607a8ed..e1bcb73d0661df4d103595a6ae74b1ab07f9ffd4 100644 GIT binary patch delta 250 zcmZpe!`m>2cR~kC)5QhL8hcuM7`OH?&BzuII_%%-pf=BMl5Lr1(CkU<+f8zq7HEn3*LSr=^)DB_|q~r&?GVBpN5085^f;k5ysTR$}=Rll5kL zj~jDJls3=JN68)!p)h-{IXUu9bXM2k~ z^BQLVBnDH4M1~XwGX_f_Ok^+wvMhl76b1tz%ZR}QNSXn~jTzE_(3ByGAsNUsU@&J$ Y1*)?IvOsc)KsCldn6kazo4Jt*00<#Y#sB~S delta 250 zcmZpe!`m>2cR~kCP@4Y6jk!VrD*8_ZDhgDe@@N}#RK@DUPd*%;vwVAt zJM$W5|6~Ru1~Uc&hGYg~216j72!!Tf(vTq)C}Rd>8#0&zRT%*3R3Og+$TMX~0YW1n Vody)O1d1Dg)tGOu_hxQn0sw|zOmYAK