Skip to content

Latest commit

 

History

History
224 lines (149 loc) · 10 KB

File metadata and controls

224 lines (149 loc) · 10 KB
Liquiid logo

Universal Authenticator Library Sharp (UAL)

A native UAL allowing the use of supported SignatureProviders, similar to the js-based UAL allowing developers and users the same interaction flow and UI/UX on all different platforms. The priority of this plugin is for user and developer experience, while building the same base with extension-capabilities allowing to support additional SignatureProviders like Wombat, MetaMask, AIKON, other Wallets or SideChain-Auth in the future.

Installation

Requires Unity 2019.1+ with .NET 4.x+ Runtime

This package can be included into your project by either:

  1. Installing the package via Unity's Package Manager (UPM) in the editor (recommended).
  2. Importing the .unitypackage which you can download here.
  3. Manually add the files in this repo.
  4. Installing it via NuGet.

1. Installing via Unity Package Manager (UPM).

In your Unity project:

  1. Open the Package Manager Window/Tab

    image

  2. Click on + icon and then click on "Add Package From Git URL"

    image

  3. Enter URL: https://github.com/liquiidio/UniversalAuthenticatorLibrarySharp.git#upm


2. Importing the Unity Package.

Download the UnityPackage here.

Then in your Unity project:

  1. Open up the import a custom package window

    image

  2. Navigate to where you downloaded the file and open it.

    image

  3. Check all the relevant files needed (if this is a first time import, just select ALL) and click on import.

    image


3. Install manually.

Download this the latest Release.

Then in your Unity project, copy the sources from UniversalAuthenticatorLibrarySharp into your Unity Assets directory.


Dependencies

None of the dependencies is contained in this Package and no matter which installation method you choose, you have to install it manually in addition to this Package.

EosSharp

EosSharp is a library containing the necessary functionallity to serialize and deserialize Actions, Transactions, Blocks and other Data In addition it contains the necessary functionallity for all kinds of cryptographic operations Lastly it contains the functionallity allowing you and the AnchorLink-Library to access EOSIO or LEAP-based Nodes via their APIs.

EosSharp installation

Follow the Instructions in the EosSharp Repository

Or install the Package directly via UPM Installing via Unity Package Manager (UPM). In your Unity project: Open the Package Manager Window/Tab Click Add Package From Git URL Enter URL: https://github.com/liquiidio/EosSharp.git#upm

AnchorLinkSharp

Allows users and developers to connect and communicate with Anchor Wallet and ESR-based applications. The Anchor & ESR Integration consists of multiple libraries for the ESR-Protocol, the Anchor-integration, Transports among others.

AnchorLinkSharp package installation

Follow the Instructions in the AnchorLinkSharp Repository

Or install the Package directly via UPM Installing via Unity Package Manager (UPM). In your Unity project: Open the Package Manager Window/Tab Click Add Package From Git URL Enter URL: https://github.com/liquiidio/AnchorLinkSharp.git#upm

WaxCloudWallet (WCW)

A combination of local HttpListeners receiving OAuth-Callbacks from WCW-related web-adresses opened through the WebView-Plugin, gathering necessary initial information like OAuth-Tokens, followed by regular non-browser-based (non-WebView required) communication with the WCW-API/Server.

WCW package installation Follow the Instructions in the WCWUnity Repository

Or install the Package directly via UPM Installing via Unity Package Manager (UPM). In your Unity project: Open the Package Manager Window/Tab Click Add Package From Git URL Enter URL: https://github.com/liquiidio/WcwUnity.git#upm

Examples

Canvas

  1. In a Unity scene, add the Canvas authenticator handler prefab i.e. Canvas.

  2. Add the specific authenticators that will be used e.g. AnchorWallet or WAX Cloud Wallet as prefabs to the scene and specify them in the handler that was added in Step 1.

  3. Create a new script inheriting from MonoBehaviour, add a public member of type UnityCanvasUAL and assign it in the editor.

  4. In the Start-method, instantiate/initialize the handler prefab added above and add an action when the user login is successful.

N.B. Ensure that there is an assign event handler/callback for the login to get the User object. Click here for more information.

Canvas

   UnityCanvasUAL.OnUserLogin += UserLogin;
   await UnityCanvasUAL.Init();

UI Toolkit

  1. In a Unity scene, add the authenticator handler prefab i.e. UIToolkit .

  2. Add the specific authenticators that will be used e.g. AnchorWallet or WAX Cloud Wallet as prefabs to the scene and specify them in the handler that was added in Step 1.

  3. Create a new script inheriting from MonoBehaviour, add a public member of type UnityUiToolkitUAL and assign it in the editor.

  4. In the Start-method, instantiate/initialize the respective handler prefab added above and add an action when the user login is successful.

N.B. Ensure that there is an assign event handler/callback for the login to get the User object. Click here for more information.

Canvas

   UnityCanvasUAL.OnUserLogin += UserLogin;
   await UnityCanvasUAL.Init();

User

To get the user that has logged in and to use the data to sign a transaction do the following:

  1. After setting up a scene as explained here, add a memeber of type User

  2. Create a new method (which should match the one called by the action in the getting started section) and pass a User parameter.

  3. Then assign the parameter to the variable of type User.

This is most effective when assigned as an event handler/callback .

UnityXXXUal.OnUserLogin += [UserLoggedInMethod];

Transfer tokens

To perform a transfer action, do the following (ensure that you have a User member assigned as shown here:

   public async Task Transfer(string frmAcc, string toAcc, string qnty, string memo)
        {
            var action = new EosSharp.Core.Api.v1.Action
            {
                account = "eosio.token",
                name = "transfer",
                authorization = new List<PermissionLevel>
                {
                    new PermissionLevel()
                    {
                        actor =
                            "............1", // ............1 will be resolved to the signing accounts permission
                        permission =
                            "............2" // ............2 will be resolved to the signing accounts authority
                    }
                },

                data = new Dictionary<string, object>
                {
                    {"from", frmAcc},
                    {"to", toAcc},
                    {"quantity", qnty},
                    {"memo", memo}
                }
            };
            try
            {
                await user.SignTransaction(new[] {action});
            }
            catch (Exception e)
            {
                Debug.Log(e);
                throw;
            }
        }

Transaction

To perform a generic transaction, do the following (ensure that you have a User member assigned as shown here:

   public async Task Transact(EosSharp.Core.Api.v1.Action action)
        {
            var transactResult = await User.SignTransaction(new []{ action });
        }