Zilliqa / zq2

Zilliqa 2.0 code base
Apache License 2.0
10 stars 0 forks source link

GetSmartContractCode should return error response for non existing contract address #1702

Open chetan-zilliqa opened 1 month ago

chetan-zilliqa commented 1 month ago

For a non existing address, GetSmartContractCode api should return Address does not exist <address> rather than { "jsonrpc": "2.0", "id": 1, "result": { "code": "", "type": "evm" } }

For eg:

 ZQ2 Output (GetSmartContractCode_output_3_ZQ2.json):
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "code": "",
    "type": "evm"
  }
}

 ZQ1 Output (GetSmartContractCode_output_3_zilliqa.json):
{
  "error": {
    "code": -5,
    "data": null,
    "message": "Address does not exist 0xf66b7ec2dc39feee66434f5a48ebedd1c8bfe3be"
  },
  "id": 1,
  "jsonrpc": "2.0"
}
chetan-zilliqa commented 2 weeks ago

Thanks for fixing the previous issue. maybe a small change we can add in future.

 ZQ2 Output (GetSmartContractCode_e24a6fb4_ZQ2.json):
{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32603,
    "message": "Address does not exist: f66b7ec2dc39feee66434f5a48ebedd1c8bfe3be"
  }
}

 ZQ1 Output (GetSmartContractCode_e24a6fb4_ZQ1.json):
{
  "error": {
    "code": -5,
    "data": null,
    "message": "Address does not exist 0xf66b7ec2dc39feee66434f5a48ebedd1c8bfe3be"
  },
  "id": 1,
  "jsonrpc": "2.0"
}

add data as null and 0x before the contract address.

chetan-zilliqa commented 2 weeks ago

Same applies to GetSmartContractInit api.

 ZQ2 Output (GetSmartContractInit_e24a6fb4_ZQ2.json):
{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32603,
    "message": "Address does not exist"
  }
}

 ZQ1 Output (GetSmartContractInit_e24a6fb4_ZQ1.json):
{
  "error": {
    "code": -5,
    "data": null,
    "message": "Address does not exist"
  },
  "id": 1,
  "jsonrpc": "2.0"
}