Skip to content

Commit

Permalink
Updated Demo example sample;
Browse files Browse the repository at this point in the history
  • Loading branch information
k-karuna committed Nov 24, 2023
1 parent 54f58a8 commit 713c4e6
Show file tree
Hide file tree
Showing 79 changed files with 252 additions and 224 deletions.
66 changes: 66 additions & 0 deletions Samples~/Scenes/Demo Example.unity
Original file line number Diff line number Diff line change
Expand Up @@ -2546,6 +2546,71 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1061548245}
m_CullTransparentMesh: 1
--- !u!1001 &1072310480
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 3340385179467995793, guid: 05a6ebf6c729446cc8458943256b9209, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3340385179467995793, guid: 05a6ebf6c729446cc8458943256b9209, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3340385179467995793, guid: 05a6ebf6c729446cc8458943256b9209, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3340385179467995793, guid: 05a6ebf6c729446cc8458943256b9209, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3340385179467995793, guid: 05a6ebf6c729446cc8458943256b9209, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3340385179467995793, guid: 05a6ebf6c729446cc8458943256b9209, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3340385179467995793, guid: 05a6ebf6c729446cc8458943256b9209, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3340385179467995793, guid: 05a6ebf6c729446cc8458943256b9209, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3340385179467995793, guid: 05a6ebf6c729446cc8458943256b9209, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3340385179467995793, guid: 05a6ebf6c729446cc8458943256b9209, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4898021624847171558, guid: 05a6ebf6c729446cc8458943256b9209, type: 3}
propertyPath: m_Name
value: TezosManager
objectReference: {fileID: 0}
- target: {fileID: 7709730176731183433, guid: 05a6ebf6c729446cc8458943256b9209, type: 3}
propertyPath: appName
value: Demo Example Game
objectReference: {fileID: 0}
- target: {fileID: 7709730176731183433, guid: 05a6ebf6c729446cc8458943256b9209, type: 3}
propertyPath: appDescription
value: Demo Example Game Description
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 05a6ebf6c729446cc8458943256b9209, type: 3}
--- !u!1 &1073020256
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -10042,3 +10107,4 @@ SceneRoots:
- {fileID: 519783461}
- {fileID: 1855521413}
- {fileID: 527547397}
- {fileID: 1072310480}
18 changes: 2 additions & 16 deletions Samples~/Scripts/DemoExample/Core/ExampleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,7 @@ public ExampleManager()

public void Init(Action<bool> callback = null)
{
Tezos = TezosSingleton.ConfiguredInstance(
networkType: NetworkType.ghostnet,
rpcUrl: "https://rpc.tzkt.io/ghostnet",
dAppMetadata: new DAppMetadata
{
Name = "Tezos Demo Example Game",
Url = "https://github.com/trilitech/tezos-unity-sdk/tree/main/Samples~",
Icon =
"https://raw.githubusercontent.com/" +
"trilitech/tezos-unity-sdk/main/Samples%7E/Art/UI/Icons/skill_icon_04.png"
});

Tezos = TezosManager.Instance.Tezos;
_networkRPC = TezosConfig.Instance.RpcBaseUrl;
}

Expand Down Expand Up @@ -471,10 +460,7 @@ public void Login(WalletProviderType walletProvider)
Tezos.Wallet.Connect(walletProvider);
}

public WalletMessageReceiver GetWalletMessageReceiver()
{
return Tezos.Wallet.MessageReceiver;
}
public WalletEventManager GetWalletMessageReceiver() => Tezos.Wallet.EventManager;

public void GetOriginatedContracts(Action<IEnumerable<TokenContract>> callback)
{
Expand Down
2 changes: 1 addition & 1 deletion Samples~/Scripts/DemoExample/Core/IExampleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public interface IExampleManager
/// <summary>
/// Return the Tezos wallet MessageReceiver for using callbacks
/// </summary>
public WalletMessageReceiver GetWalletMessageReceiver();
public WalletEventManager GetWalletMessageReceiver();

/// <summary>
/// Checks if item is on the marketplace in the blockchain
Expand Down
2 changes: 1 addition & 1 deletion Samples~/Scripts/DemoExample/ExampleFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class ExampleFactory : MonoBehaviour
public static ExampleFactory Instance;
private IExampleManager _exampleManager = null;

private void Awake()
private void Start()
{
if (Instance == null)
Instance = this;
Expand Down
55 changes: 16 additions & 39 deletions Samples~/Scripts/DemoExample/UIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using TezosSDK.Beacon;
using TezosSDK.Helpers;
using UnityEngine;

Expand Down Expand Up @@ -204,38 +205,27 @@ public void ShowDeployPanel()

#region Tezos Callbacks

private void OnAccountConnected(string account)
private void OnAccountConnected(AccountInfo accountInfo)
{
Debug.Log(account);
if (!string.IsNullOrEmpty(account))
if (!string.IsNullOrEmpty(accountInfo.Address))
OnSignIn(true);
}

private void OnAccountConnectionFailed(string response)
private void OnAccountConnectionFailed(ErrorInfo errorInfo)
{
DisplayPopup("Wallet connection failed!\n \n" +
"Response: \n" + response);
"Response: \n" + errorInfo.Message);
}

private void OnAccountDisconnected(string account)
private void OnAccountDisconnected(AccountInfo accountInfo)
{
AllowUIAccess(false);
ResetWalletData();
}

[Serializable]
private struct Transaction
private void OnContractCallCompleted(OperationResult operationResult)
{
public string transactionHash;
}

private void OnContractCallCompleted(string response)
{
string transactionHash =
JsonSerializer.Deserialize<JsonElement>(response).GetProperty("transactionHash").ToString();
DisplayPopup("Transaction completed!\n \n" +
"Transaction hash:\n" + transactionHash +
"\n \nResponse:\n" + response);
DisplayPopup($"Transaction completed with hash {operationResult.TransactionHash}");
}

public void UpdateContractAddress()
Expand Down Expand Up @@ -275,20 +265,14 @@ public void ChangeContract()
});
}

private void OnContractCallFailed(string response)
private void OnContractCallFailed(ErrorInfo errorInfo)
{
DisplayPopup("Transaction failed!\n \n" +
"Response:\n" + response);
DisplayPopup($"Transaction failed, error: {errorInfo.Message}");
}

private void OnContractCallInjected(string result)
private void OnContractCallInjected(OperationResult operationResult)
{
string successString = JsonSerializer.Deserialize<JsonElement>(result).GetProperty("success").ToString();
string transactionHash =
JsonSerializer.Deserialize<JsonElement>(result).GetProperty("transactionHash").ToString();

bool success = successString != null && bool.Parse(successString);
if (success)
if (!string.IsNullOrEmpty(operationResult.TransactionHash))
{
_manager.FetchMarketItems(PopulateMarket);
_manager.FetchInventoryItems(PopulateInventory);
Expand All @@ -297,21 +281,14 @@ private void OnContractCallInjected(string result)
}

DisplayPopup("Call injected!\n \n" +
"Response:\n" + success +
"\n \nTransaction Hash:\n" + transactionHash);
"\n \nTransaction Hash:\n" + operationResult.TransactionHash);
}

private void OnPayloadSigned(string result)
private void OnPayloadSigned(SignResult signResult)
{
var signature = JsonSerializer
.Deserialize<JsonElement>(result)
.GetProperty("signature")
.ToString();

DisplayPopup($"Signed!\n \n" +
$"Signature: {signature}");
DisplayPopup($"Successfully signed with signature: {signResult.Signature}");
}

#endregion
}
}
}
15 changes: 7 additions & 8 deletions Samples~/Scripts/NftApiSample/DataManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text.Json;
using TezosSDK.Beacon;
using TezosSDK.Helpers;
using TezosSDK.Tezos;
using TezosSDK.Tezos.API.Models.Filters;
Expand All @@ -23,18 +24,16 @@ public class DataManager : MonoBehaviour

void Start()
{
_tezos = TezosSingleton.Instance;
_tezos = TezosManager.Instance.Tezos;
_tezos
.Wallet
.MessageReceiver
.EventManager
.AccountConnected += OnAccountConnected;
}

void OnAccountConnected(string result)
void OnAccountConnected(AccountInfo accountInfo)
{
var json = JsonSerializer.Deserialize<JsonElement>(result);
var account = json.GetProperty("accountInfo");
_connectedAddress = account.GetProperty("address").GetString();
_connectedAddress = accountInfo.Address;
}

public void GetTokensForOwners()
Expand Down Expand Up @@ -92,7 +91,7 @@ public void IsHolderOfContract()
Debug.Log("Enter contract address");
return;
}

CoroutineRunner.Instance.StartCoroutine(_tezos.API.IsHolderOfContract((flag) =>
{
var message = flag
Expand Down Expand Up @@ -122,7 +121,7 @@ public void IsHolderOfToken()
Debug.Log("Enter contract address");
return;
}

CoroutineRunner.Instance.StartCoroutine(_tezos.API.IsHolderOfToken((flag) =>
{
var message = flag
Expand Down
2 changes: 1 addition & 1 deletion Samples~/TextMesh Pro.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file modified Samples~/TextMesh Pro/Documentation.meta
100755 → 100644
Empty file.
Empty file.
Empty file.
Empty file modified Samples~/TextMesh Pro/Fonts.meta
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Fonts/LiberationSans - OFL.txt
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Fonts/LiberationSans - OFL.txt.meta
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Fonts/LiberationSans.ttf
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Fonts/LiberationSans.ttf.meta
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Resources.meta
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Resources/Fonts & Materials.meta
100755 → 100644
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified Samples~/TextMesh Pro/Resources/Sprite Assets.meta
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Resources/Sprite Assets/EmojiOne.asset
100755 → 100644
Empty file.
Empty file.
Empty file modified Samples~/TextMesh Pro/Resources/Style Sheets.meta
100755 → 100644
Empty file.
Empty file.
Empty file.
Empty file modified Samples~/TextMesh Pro/Resources/TMP Settings.asset
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Resources/TMP Settings.asset.meta
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders.meta
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMP_Bitmap-Custom-Atlas.shader
100755 → 100644
Empty file.
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMP_Bitmap-Mobile.shader
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMP_Bitmap-Mobile.shader.meta
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMP_Bitmap.shader
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMP_Bitmap.shader.meta
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMP_SDF Overlay.shader
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMP_SDF Overlay.shader.meta
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMP_SDF SSD.shader
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMP_SDF SSD.shader.meta
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMP_SDF-Mobile Masking.shader
100755 → 100644
Empty file.
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMP_SDF-Mobile Overlay.shader
100755 → 100644
Empty file.
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMP_SDF-Mobile SSD.shader
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMP_SDF-Mobile SSD.shader.meta
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMP_SDF-Mobile.shader
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMP_SDF-Mobile.shader.meta
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMP_SDF-Surface-Mobile.shader
100755 → 100644
Empty file.
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMP_SDF-Surface.shader
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMP_SDF-Surface.shader.meta
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMP_SDF.shader
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMP_SDF.shader.meta
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMP_Sprite.shader
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMP_Sprite.shader.meta
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMPro.cginc
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMPro.cginc.meta
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMPro_Mobile.cginc
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMPro_Mobile.cginc.meta
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMPro_Properties.cginc
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMPro_Properties.cginc.meta
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMPro_Surface.cginc
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Shaders/TMPro_Surface.cginc.meta
100755 → 100644
Empty file.
Empty file modified Samples~/TextMesh Pro/Sprites.meta
100755 → 100644
Empty file.
4 changes: 2 additions & 2 deletions Samples~/TextMesh Pro/Sprites/EmojiOne Attribution.txt
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
This sample of beautiful emojis are provided by EmojiOne https://www.emojione.com/
This sample of beautiful emojis are provided by EmojiOne https://www.emojione.com/

Please visit their website to view the complete set of their emojis and review their licensing terms.
Empty file modified Samples~/TextMesh Pro/Sprites/EmojiOne Attribution.txt.meta
100755 → 100644
Empty file.
Loading

0 comments on commit 713c4e6

Please sign in to comment.