Skip to content

Commit

Permalink
3.0.0 Official Release (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xFirekeeper authored Sep 6, 2023
1 parent 96ed963 commit e64465d
Show file tree
Hide file tree
Showing 482 changed files with 517 additions and 81,428 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ sysinfo.txt

# Builds
*.apk
*.unitypackage

Assets/StreamingAssets/

Expand Down
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"visualstudiotoolsforunity.vstuc"
]
}
10 changes: 10 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Unity",
"type": "vstuc",
"request": "attach",
}
]
}
2 changes: 1 addition & 1 deletion Assets/Plugins/Android.meta

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

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

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

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

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

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

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

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

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static async Task<PMSponsorOperationResponse> PMSponsorUserOperation(stri
private static async Task<RpcResponseMessage> BundlerRequest(string url, string apiKey, object requestId, string method, params object[] args)
{
using HttpClient client = new HttpClient();
// UnityEngine.Debug.Log($"Bundler Request: {method}({string.Join(", ", args)})");
ThirdwebDebug.Log($"Bundler Request: {method}({string.Join(", ", args)})");
var requestMessage = new RpcRequestMessage(requestId, method, args);
string requestMessageJson = JsonConvert.SerializeObject(requestMessage);

Expand All @@ -59,7 +59,7 @@ private static async Task<RpcResponseMessage> BundlerRequest(string url, string
throw new Exception($"Bundler Request Failed. Error: {httpResponse.StatusCode} - {httpResponse.ReasonPhrase} - {await httpResponse.Content.ReadAsStringAsync()}");

var httpResponseJson = await httpResponse.Content.ReadAsStringAsync();
// UnityEngine.Debug.Log($"Bundler Response: {httpResponseJson}");
ThirdwebDebug.Log($"Bundler Response: {httpResponseJson}");

var response = JsonConvert.DeserializeObject<RpcResponseMessage>(httpResponseJson);
if (response.Error != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ internal async Task Initialize()

_initialized = true;

Debug.Log($"Initialized with Factory: {Config.factoryAddress}, AdminSigner: {PersonalAddress}, Predicted Account: {Accounts[0]}, Deployed: {_deployed}");
ThirdwebDebug.Log($"Initialized with Factory: {Config.factoryAddress}, AdminSigner: {PersonalAddress}, Predicted Account: {Accounts[0]}, Deployed: {_deployed}");
}

internal async Task UpdateDeploymentStatus()
Expand Down Expand Up @@ -139,7 +139,7 @@ internal async Task<bool> VerifySignature(byte[] hash, byte[] signature)

internal async Task<RpcResponseMessage> Request(RpcRequestMessage requestMessage)
{
Debug.Log("Requesting: " + requestMessage.Method + "...");
ThirdwebDebug.Log("Requesting: " + requestMessage.Method + "...");

if (requestMessage.Method == "eth_chainId")
{
Expand Down Expand Up @@ -211,10 +211,10 @@ private async Task<RpcResponseMessage> CreateUserOpAndSend(RpcRequestMessage req

// Send the user operation

Debug.Log("Valid UserOp: " + JsonConvert.SerializeObject(partialUserOp));
Debug.Log("Valid Encoded UserOp: " + JsonConvert.SerializeObject(partialUserOpHexified));
ThirdwebDebug.Log("Valid UserOp: " + JsonConvert.SerializeObject(partialUserOp));
ThirdwebDebug.Log("Valid Encoded UserOp: " + JsonConvert.SerializeObject(partialUserOpHexified));
var userOpHash = await BundlerClient.EthSendUserOperation(Config.bundlerUrl, apiKey, requestMessage.Id, partialUserOpHexified, Config.entryPointAddress);
Debug.Log("UserOp Hash: " + userOpHash);
ThirdwebDebug.Log("UserOp Hash: " + userOpHash);

// Wait for the transaction to be mined

Expand All @@ -225,21 +225,21 @@ private async Task<RpcResponseMessage> CreateUserOpAndSend(RpcRequestMessage req
txHash = getUserOpResponse?.transactionHash;
await new WaitForSecondsRealtime(5f);
}
Debug.Log("Tx Hash: " + txHash);
ThirdwebDebug.Log("Tx Hash: " + txHash);

// Check if successful

var receipt = await new Web3(ThirdwebManager.Instance.SDK.session.RPC).Eth.Transactions.GetTransactionReceipt.SendRequestAsync(txHash);
var decodedEvents = receipt.DecodeAllEvents<EntryPointContract.UserOperationEventEventDTO>();
if (decodedEvents[0].Event.Success == false)
{
Debug.Log("Transaction not successful, checking reason...");
ThirdwebDebug.Log("Transaction not successful, checking reason...");
var reason = await new Web3(ThirdwebManager.Instance.SDK.session.RPC).Eth.GetContractTransactionErrorReason.SendRequestAsync(txHash);
throw new Exception($"Transaction {txHash} reverted with reason: {reason}");
}
else
{
Debug.Log("Transaction successful");
ThirdwebDebug.Log("Transaction successful");
_deployed = true;
}

Expand Down
18 changes: 9 additions & 9 deletions Assets/Thirdweb/Core/Scripts/Bridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static void Initialize(string chainOrRPC, ThirdwebSDK.Options options)
{
if (!Utils.IsWebGLBuild())
{
Debug.LogWarning("Initializing the thirdweb SDK is not fully supported in the editor.");
ThirdwebDebug.LogWarning("Initializing the thirdweb SDK is not fully supported in the editor.");
return;
}
#if UNITY_WEBGL
Expand All @@ -84,7 +84,7 @@ public static async Task<string> Connect(WalletConnection walletConnection)
{
if (!Utils.IsWebGLBuild())
{
Debug.LogWarning("Connecting wallets is not fully supported in the editor.");
ThirdwebDebug.LogWarning("Connecting wallets is not fully supported in the editor.");
return Utils.AddressZero;
}
var task = new TaskCompletionSource<string>();
Expand All @@ -109,7 +109,7 @@ public static async Task Disconnect()
{
if (!Utils.IsWebGLBuild())
{
Debug.LogWarning("Disconnecting wallets is not fully supported in the editor.");
ThirdwebDebug.LogWarning("Disconnecting wallets is not fully supported in the editor.");
return;
}
var task = new TaskCompletionSource<string>();
Expand All @@ -125,7 +125,7 @@ public static async Task SwitchNetwork(string chainId)
{
if (!Utils.IsWebGLBuild())
{
Debug.LogWarning("Switching networks is not fully supported in the editor.");
ThirdwebDebug.LogWarning("Switching networks is not fully supported in the editor.");
return;
}
var task = new TaskCompletionSource<string>();
Expand All @@ -141,7 +141,7 @@ public static async Task<T> InvokeRoute<T>(string route, string[] body)
{
if (!Utils.IsWebGLBuild())
{
Debug.LogWarning("Interacting with the thirdweb SDK is not fully supported in the editor.");
ThirdwebDebug.LogWarning("Interacting with the thirdweb SDK is not fully supported in the editor.");
return default;
}
var msg = Utils.ToJson(new RequestMessageBody(body));
Expand All @@ -152,15 +152,15 @@ public static async Task<T> InvokeRoute<T>(string route, string[] body)
ThirdwebInvoke(taskId, route, msg, jsCallback);
#endif
string result = await task.Task;
// Debug.Log($"InvokeRoute Result: {result}");
ThirdwebDebug.Log($"InvokeRoute Result: {result}");
return JsonConvert.DeserializeObject<Result<T>>(result).result;
}

public static string InvokeListener<T>(string route, string[] body, Action<T> action)
{
if (!Utils.IsWebGLBuild())
{
Debug.LogWarning("Interacting with the thirdweb SDK is not fully supported in the editor.");
ThirdwebDebug.LogWarning("Interacting with the thirdweb SDK is not fully supported in the editor.");
return null;
}

Expand All @@ -177,7 +177,7 @@ public static async Task FundWallet(FundWalletOptions payload)
{
if (!Utils.IsWebGLBuild())
{
Debug.LogWarning("Interacting with the thirdweb SDK is not fully supported in the editor.");
ThirdwebDebug.LogWarning("Interacting with the thirdweb SDK is not fully supported in the editor.");
return;
}
var msg = Utils.ToJson(payload);
Expand All @@ -194,7 +194,7 @@ public static async Task<string> ExportWallet(string password)
{
if (!Utils.IsWebGLBuild())
{
Debug.LogWarning("Interacting with the thirdweb SDK is not fully supported in the editor.");
ThirdwebDebug.LogWarning("Interacting with the thirdweb SDK is not fully supported in the editor.");
return null;
}
string taskId = Guid.NewGuid().ToString();
Expand Down
2 changes: 1 addition & 1 deletion Assets/Thirdweb/Core/Scripts/Contract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public async Task<T> Read<T>(string functionName, params object[] args)
else
rawResults.AddRange(result.Select(item => item.Result));

Debug.Log("Raw Result: " + JsonConvert.SerializeObject(rawResults));
ThirdwebDebug.Log("Raw Result: " + JsonConvert.SerializeObject(rawResults));

// Single
if (rawResults.Count == 1)
Expand Down
2 changes: 1 addition & 1 deletion Assets/Thirdweb/Core/Scripts/ERC1155.cs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ public async Task<ClaimConditions> GetActive(string tokenId)
}
catch
{
Debug.Log("Could not fetch currency metadata, proceeding without it.");
ThirdwebDebug.Log("Could not fetch currency metadata, proceeding without it.");
}

return new ClaimConditions()
Expand Down
4 changes: 2 additions & 2 deletions Assets/Thirdweb/Core/Scripts/ERC20.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public async Task<TransactionResult> SetAllowance(string spender, string amount)
var result = new TransactionResult();
if (diff == 0)
{
Debug.LogWarning($"Allowance is already of amount {amount} - Skipping request...");
ThirdwebDebug.LogWarning($"Allowance is already of amount {amount} - Skipping request...");
result = null;
}
else if (diff < 0)
Expand Down Expand Up @@ -392,7 +392,7 @@ public async Task<ClaimConditions> GetActive()
}
catch
{
Debug.Log("Could not fetch currency metadata, proceeding without it.");
ThirdwebDebug.Log("Could not fetch currency metadata, proceeding without it.");
}

return new ClaimConditions()
Expand Down
4 changes: 2 additions & 2 deletions Assets/Thirdweb/Core/Scripts/ERC721.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public async Task<string> OwnerOf(string tokenId)
}
catch (System.Exception)
{
Debug.LogWarning($"Unable to find owner of {tokenId}, return address(0)");
ThirdwebDebug.LogWarning($"Unable to find owner of {tokenId}, return address(0)");
return "0x0000000000000000000000000000000000000000";
}
}
Expand Down Expand Up @@ -506,7 +506,7 @@ public async Task<ClaimConditions> GetActive()
}
catch
{
Debug.Log("Could not fetch currency metadata, proceeding without it.");
ThirdwebDebug.Log("Could not fetch currency metadata, proceeding without it.");
}

return new ClaimConditions()
Expand Down
2 changes: 1 addition & 1 deletion Assets/Thirdweb/Core/Scripts/Hyperplay/Hyperplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal async Task<RpcResponseMessage> Request(RpcRequestMessage message)
await request.SendWebRequest();
if (request.result != UnityWebRequest.Result.Success)
{
Debug.LogError(request.error);
ThirdwebDebug.LogError(request.error);
throw new UnityException("RPC request failed: " + request.error);
}
var hyperplayResult = JsonConvert.DeserializeObject<HyperplayResult>(request.downloadHandler.text);
Expand Down
8 changes: 4 additions & 4 deletions Assets/Thirdweb/Core/Scripts/Storage/StorageDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public async Task<T> DownloadText<T>(string textURI)
{
if (string.IsNullOrEmpty(textURI))
{
Debug.LogWarning($"Unable to download text from empty uri!");
ThirdwebDebug.LogWarning($"Unable to download text from empty uri!");
return default;
}

Expand All @@ -28,7 +28,7 @@ public async Task<T> DownloadText<T>(string textURI)
await req.SendWebRequest();
if (req.result != UnityWebRequest.Result.Success)
{
Debug.LogWarning($"Unable to fetch text uri {textURI} data! {req.error}");
ThirdwebDebug.LogWarning($"Unable to fetch text uri {textURI} data! {req.error}");
return default;
}
string json = req.downloadHandler.text;
Expand All @@ -39,7 +39,7 @@ public async Task<Sprite> DownloadImage(string imageURI)
{
if (string.IsNullOrEmpty(imageURI))
{
Debug.LogWarning($"Unable to download image from empty uri!");
ThirdwebDebug.LogWarning($"Unable to download image from empty uri!");
return null;
}

Expand All @@ -55,7 +55,7 @@ public async Task<Sprite> DownloadImage(string imageURI)
await req.SendWebRequest();
if (req.result != UnityWebRequest.Result.Success)
{
Debug.LogWarning($"Unable to fetch image uri {imageURI} data! {req.error}");
ThirdwebDebug.LogWarning($"Unable to fetch image uri {imageURI} data! {req.error}");
return null;
}
else
Expand Down
34 changes: 34 additions & 0 deletions Assets/Thirdweb/Core/Scripts/ThirdwebDebug.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using UnityEngine;

namespace Thirdweb
{
public static class ThirdwebDebug
{
public static bool IsEnabled => ThirdwebManager.Instance != null && ThirdwebManager.Instance.showDebugLogs;

public static void Log(object message)
{
if (IsEnabled)
Debug.Log(message);
}

public static void LogWarning(object message)
{
if (IsEnabled)
Debug.LogWarning(message);
}

public static void LogError(object message)
{
if (IsEnabled)
Debug.LogError(message);
}

public static void LogException(Exception exception)
{
if (IsEnabled)
Debug.LogException(exception);
}
}
}

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

Loading

0 comments on commit e64465d

Please sign in to comment.