Closed ecp4224 closed 7 months ago
Unity
Smart contract that returns an array of uint256[], any Unity build target
uint256[]
1.3.1
latest
No response
Contract call is supposed to return an array of BigIntegers but is returning a hex string instead
I have a method on a contract that returns a uint256
The contract backing created by metamask with the contract code generator created this method for it
public Task<BigInteger[]> WalletOfOwner(EvmAddress _owner, CallOptions options = default) { var method = System.Reflection.MethodBase.GetCurrentMethod(); return (Task<BigInteger[]>) InvokeMethod(method, new object[] { _owner, options }); }
When called BigInterger[] result = await contract.WalletOfOwner(MetaMaskUnity.Instance.Wallet.SelectedAddress);
BigInterger[] result = await contract.WalletOfOwner(MetaMaskUnity.Instance.Wallet.SelectedAddress);
Unity throws the error
Error calling WalletOfOwner: Error converting value "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000a" to type 'System.Numerics.BigInteger[]'. Path 'result', line 1, position 825. UnityEngine.Debug:LogError (object) MetaMask.Unity.PhantomGalaxies.Metamask/<NFTWalletOfOwner>d__16:MoveNext () (at Assets/Scripts/Metamask.cs:172) System.Reflection.MethodBase:Invoke (object,object[]) evm.net.Contract/<WaitForTaskCompleted>d__42:MoveNext () System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<System.Numerics.BigInteger[]>:SetException (System.Exception) evm.net.HttpProvider/<RpcRequest>d__14`1<System.Numerics.BigInteger[]>:MoveNext () System.Threading.Tasks.TaskCompletionSource`1<string>:SetResult (string) MetaMask.IO.MetaMaskHttpService/<SendRequestUnity>d__10:MoveNext () (at Assets/MetaMask/Scripts/IO/MetaMaskHttpService.cs:233) UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr) (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/Coroutines.cs:17)
It looks like its returning a hash string instead of a array of big integers.
When I convert the function in ContractBacking.cs to return a string and modify the calling code it doesn't return anything
Contract should properly handle array return types
Contract
BigInteger[]
Fixed with the Unity 2.0 Release.
SDK
Unity
Provide environment information
Smart contract that returns an array of
uint256[]
, any Unity build targetMetaMask SDK Version
1.3.1
MetaMask Mobile app Version
latest
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
Contract call is supposed to return an array of BigIntegers but is returning a hex string instead
I have a method on a contract that returns a uint256
The contract backing created by metamask with the contract code generator created this method for it
When called
BigInterger[] result = await contract.WalletOfOwner(MetaMaskUnity.Instance.Wallet.SelectedAddress);
Unity throws the error
It looks like its returning a hash string instead of a array of big integers.
When I convert the function in ContractBacking.cs to return a string and modify the calling code it doesn't return anything
Expected Behavior
Contract
should properly handle array return typesLink to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster
No response
To Reproduce
BigInteger[]