|
1 |
| -using System; |
2 |
| -using System.Collections.Generic; |
3 | 1 | using System.Threading.Tasks;
|
4 | 2 | using System.Numerics;
|
5 | 3 | using UnityEngine;
|
6 |
| -using UnityEngine.Networking; |
7 |
| -using Newtonsoft.Json; |
8 | 4 | using Nethereum.Hex.HexTypes;
|
9 | 5 |
|
10 | 6 | namespace Thirdweb
|
@@ -48,8 +44,7 @@ public class Contract : Routable
|
48 | 44 | /// </summary>
|
49 | 45 | public Events events;
|
50 | 46 |
|
51 |
| - public Contract(string chain, string address, string abi = null) |
52 |
| - : base(abi != null ? $"{address}{Routable.subSeparator}{abi}" : address) |
| 47 | + public Contract(string chain, string address, string abi = null) : base(abi != null ? $"{address}{Routable.subSeparator}{abi}" : address) |
53 | 48 | {
|
54 | 49 | this.chain = chain;
|
55 | 50 | this.address = address;
|
@@ -88,10 +83,7 @@ public async Task<T> Read<T>(string functionName, params object[] args)
|
88 | 83 | {
|
89 | 84 | if (Utils.IsWebGLBuild())
|
90 | 85 | {
|
91 |
| - string[] argsEncoded = new string[args.Length + 1]; |
92 |
| - argsEncoded[0] = functionName; |
93 |
| - Utils.ToJsonStringArray(args).CopyTo(argsEncoded, 1); |
94 |
| - return await Bridge.InvokeRoute<T>(getRoute("call"), argsEncoded); |
| 86 | + return await Bridge.InvokeRoute<T>(getRoute("call"), Utils.ToJsonStringArray(functionName, args)); |
95 | 87 | }
|
96 | 88 | else
|
97 | 89 | {
|
@@ -127,15 +119,7 @@ public async Task<TransactionResult> Write(string functionName, TransactionReque
|
127 | 119 | if (Utils.IsWebGLBuild())
|
128 | 120 | {
|
129 | 121 | args = args ?? new object[0];
|
130 |
| - var hasOverrides = transactionOverrides != null; |
131 |
| - string[] argsEncoded = new string[args.Length + (hasOverrides ? 2 : 1)]; |
132 |
| - argsEncoded[0] = functionName; |
133 |
| - Utils.ToJsonStringArray(args).CopyTo(argsEncoded, 1); |
134 |
| - if (hasOverrides) |
135 |
| - { |
136 |
| - argsEncoded[argsEncoded.Length - 1] = Utils.ToJson(transactionOverrides); |
137 |
| - } |
138 |
| - return await Bridge.InvokeRoute<TransactionResult>(getRoute("call"), argsEncoded); |
| 122 | + return await Bridge.InvokeRoute<TransactionResult>(getRoute("call"), Utils.ToJsonStringArray(functionName, args, transactionOverrides)); |
139 | 123 | }
|
140 | 124 | else
|
141 | 125 | {
|
|
0 commit comments