Skip to content

UInt160 type method in smart contract can return String, can be compiled, but can't be executed. #1426

@superboyiii

Description

@superboyiii

We need support this kind of return in compiler or ban it within exception. Compiler and ApplicationEngine are now in different behavior.

    public partial class Test : SmartContract
    {
        public static BigInteger Decimal()
        {
            return (BigInteger)Contract.Call(GetStateContractHash(), "decimals", CallFlags.ReadOnly);
        }

        public static UInt160 GetStateContractHash()
        {
            return "0xd2a4cff31913016155e38e474a2c06d08be276cf";
        }

    }

Compiler build it successfully:

Image

In invokefunction:
Request:

{
  "jsonrpc": "2.0",
  "method": "invokefunction",
  "params": [
    "0x2b6692bc37b1837fd9ff6b4a9496fed6423dd492",
    "decimal",
    [],
    [
      {
        "account": "NdUL5oDPD159KeFpD5A9zw5xNF1xLX6nLT",
        "scopes": "Global"
      }
    ]
  ],
  "id": 3
}

Response:

{
    "jsonrpc": "2.0",
    "id": 3,
    "result": {
        "script": "wh8MB2RlY2ltYWwMFJLUPULW/paUSmv/2X+DsTe8kmYrQWJ9W1I=",
        "state": "FAULT",
        "gasconsumed": "1983480",
        "exception": "Invalid UInt160 length: expected 20 bytes, but got 42 bytes. UInt160 values must be exactly 20 bytes long.",
        "notifications": [],
        "stack": []
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions