Skip to content
This repository has been archived by the owner on Jun 11, 2019. It is now read-only.

uint256[] error in Tron Studio #9

Open
gvitali opened this issue Oct 29, 2018 · 1 comment
Open

uint256[] error in Tron Studio #9

gvitali opened this issue Oct 29, 2018 · 1 comment

Comments

@gvitali
Copy link

gvitali commented Oct 29, 2018

When I add this function into contract code and try to deploy, studio stops to work with errors in console.

Function:

function funcName(address _userAddress) public view returns(uint256[]) {
     uint256[] memory itemsTotal = new uint256[](totalItems);
     for(uint8 i = 0; i < totalItems; i++) {
        itemsTotal[i] = someOtherFunction(i, _userAddress);
     }
     return itemsTotal;
  }

Errors in console:

ERROR [JavaFX Application Thread] [DefaultConfig](DefaultConfig.java:28) Uncaught exception     Thread[JavaFX Application Thread,5,main],java.lang.RuntimeException:    java.lang.reflect.InvocationTargetException
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1774)

and

Caused by: java.lang.UnsupportedOperationException: Unsupported type encountered: uint256[]
    at org.tron.abi.datatypes.generated.AbiTypes.getTypeReference(AbiTypes.java:742)
    at org.tron.studio.ui.RightTabRunController.getContractRunPanel(RightTabRunController.java:403)
    at org.tron.studio.ui.RightTabRunController.onClickDeploy(RightTabRunController.java:318)

This function works well in Ethereum.

How to work with arrays like uint256[] in Tron?

Thank you

@UnforgivenZZZ
Copy link
Contributor

I think the syntax for uint256 array is same as in ethurem, could it be the version? i use pragma solidity ^0.4.23; and add

uint256[] memory itemsTotal = new uint256[](7);
for(uint8 i = 0; i < 7; i++) {
    itemsTotal[i] = i;
 }

with no problem, or can I see whats your code in someOtherFunction(i, _userAddress); as well?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants