-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
Algorand.Unity.Net
this enforces that `Algorand.Unity.Net` can't be used in WebGL BREAKING CHANGE: Removed all explicit/implicit operators to convert Algorand.Unity types to Algorand types. All conversions now can be done with `ToUnity` and `ToDotnet` extension methods by referencing the `Algorand.Unity.Net` assembly.
- Loading branch information
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "Algorand.Unity.Net", | ||
"rootNamespace": "Algorand.Unity.Net", | ||
"references": [ | ||
"GUID:45ab5c0c2cb4a0e4ba897b731349c490", | ||
"GUID:f51ebe6a0ceec4240a699833d6309b23", | ||
"GUID:9f8c967ec86c9324c9b2928ff73b4cf1" | ||
], | ||
"includePlatforms": [], | ||
"excludePlatforms": [ | ||
"WebGL" | ||
], | ||
"allowUnsafeCode": true, | ||
"overrideReferences": true, | ||
"precompiledReferences": [ | ||
"Algorand_1.0.0.14.dll", | ||
"BouncyCastle.Crypto_1.8.8.dll" | ||
], | ||
"autoReferenced": false, | ||
"defineConstraints": [], | ||
"versionDefines": [], | ||
"noEngineReferences": false | ||
} |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace Algorand.Unity.Net | ||
{ | ||
public static class AddressExtensions | ||
{ | ||
public static Algorand.Address ToDotnet(this Address from) | ||
{ | ||
return new Algorand.Address(from); | ||
} | ||
|
||
public static Address ToUnity(this Algorand.Address from) | ||
{ | ||
return from.EncodeAsString(); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
|
||
namespace Algorand.Unity.Net | ||
{ | ||
public static class AlgoApiClientExtensions | ||
{ | ||
public static UnityHttpClient ToHttpClient<T>(this T client) | ||
where T : IAlgoApiClient | ||
{ | ||
var timeout = System.Threading.Timeout.InfiniteTimeSpan; | ||
return client.ToHttpClient(timeout); | ||
} | ||
|
||
public static UnityHttpClient ToHttpClient<T>(this T client, TimeSpan timeout) | ||
where T : IAlgoApiClient | ||
{ | ||
var address = client.Address; | ||
(string headers, string value)[] headers; | ||
if (client.Headers == null) | ||
{ | ||
if (string.IsNullOrEmpty(client.Token)) | ||
{ | ||
return new UnityHttpClient(address, timeout); | ||
} | ||
|
||
headers = new (string headers, string value)[1]; | ||
headers[0] = (client.TokenHeader, client.Token); | ||
return new UnityHttpClient(address, timeout, headers); | ||
} | ||
|
||
if (string.IsNullOrEmpty(client.Token)) | ||
{ | ||
headers = new (string headers, string value)[client.Headers.Length]; | ||
for (var i = 0; i < headers.Length; i++) | ||
headers[i] = client.Headers[i]; | ||
return new UnityHttpClient(address, timeout, headers); | ||
} | ||
|
||
headers = new (string headers, string value)[client.Headers.Length + 1]; | ||
for (var i = 0; i < client.Headers.Length; i++) | ||
headers[i] = client.Headers[i]; | ||
headers[client.Headers.Length] = (client.TokenHeader, client.Token); | ||
return new UnityHttpClient(address, timeout, headers); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Algorand.Algod; | ||
|
||
namespace Algorand.Unity.Net | ||
{ | ||
public static class AlgodClientExtensions | ||
{ | ||
/// <summary> | ||
/// Convert <see cref="AlgodClient"/> to the Algorand2 <see cref="CommonApi"/>. | ||
/// </summary> | ||
/// <param name="algod">The Unity Serializable <see cref="AlgodClient"/>.</param> | ||
/// <returns>An Algorand2 <see cref="CommonApi"/></returns> | ||
public static CommonApi ToCommonApi(this AlgodClient algod) | ||
{ | ||
return new CommonApi(algod.ToHttpClient()); | ||
} | ||
|
||
/// <summary> | ||
/// Convert <see cref="AlgodClient"/> to the Algorand2 <see cref="DefaultApi"/>. | ||
/// </summary> | ||
/// <param name="algod">The Unity Serializable <see cref="AlgodClient"/>.</param> | ||
/// <returns>An Algorand2 <see cref="DefaultApi"/></returns> | ||
public static DefaultApi ToDefaultApi(this AlgodClient algod) | ||
{ | ||
return new DefaultApi(algod.ToHttpClient()); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Algorand.Indexer; | ||
|
||
namespace Algorand.Unity.Net | ||
{ | ||
public static class IndexerClientExtensions | ||
{ | ||
public static CommonApi ToCommonApi(this IndexerClient indexer) | ||
{ | ||
return new CommonApi(indexer.ToHttpClient()); | ||
} | ||
|
||
public static SearchApi ToSearchApi(this IndexerClient indexer) | ||
{ | ||
return new SearchApi(indexer.ToHttpClient()); | ||
} | ||
|
||
public static LookupApi ToLookupApi(this IndexerClient indexer) | ||
{ | ||
return new LookupApi(indexer.ToHttpClient()); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace Algorand.Unity.Net | ||
{ | ||
public static class CompiledTealExtensions | ||
{ | ||
public static TEALProgram ToDotnet(this CompiledTeal from) | ||
{ | ||
return new TEALProgram(from.Bytes); | ||
} | ||
|
||
public static CompiledTeal ToUnity(this TEALProgram from) | ||
{ | ||
return from.Bytes; | ||
} | ||
} | ||
} |
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.