Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Would crash when trying to parse my abi data #6

Closed
PandaraWen opened this issue Feb 1, 2018 · 2 comments
Closed

Would crash when trying to parse my abi data #6

PandaraWen opened this issue Feb 1, 2018 · 2 comments

Comments

@PandaraWen
Copy link

I try to use my abi data to create a contract (as shown at the end), but always crash at a same place.

I just simply read json data from my .json file and than parsed it as a string:

self.web3 = Web3.newWeb3(URL(string: "http://localhost:8545")!)!

// ABI
guard let path = Bundle.main.path(forResource: "abi", ofType: "json"),
    let abiString = try? String(contentsOf: URL(fileURLWithPath: path)) else {
    fatalError("Can not get abi data")
}

// Contract
self.contract = self.web3.contract(abiString, at: EthereumAddress(self.contractAddress))!

When I run my program, it would crash at the last line in code snap above, giving an error in console:

parameterTypeInvalid

Am I missing something?

The abi data I used:

[
   {
      "constant":true,
      "inputs":[

      ],
      "name":"getUsers",
      "outputs":[
         {
            "name":"",
            "type":"address[]"
         }
      ],
      "payable":false,
      "stateMutability":"view",
      "type":"function"
   },
   {
      "constant":false,
      "inputs":[
         {
            "name":"handle",
            "type":"string"
         },
         {
            "name":"city",
            "type":"bytes32"
         },
         {
            "name":"state",
            "type":"bytes32"
         },
         {
            "name":"country",
            "type":"bytes32"
         }
      ],
      "name":"registerNewUser",
      "outputs":[
         {
            "name":"success",
            "type":"bool"
         }
      ],
      "payable":false,
      "stateMutability":"nonpayable",
      "type":"function"
   },
   {
      "constant":true,
      "inputs":[
         {
            "name":"SHA256notaryHash",
            "type":"bytes32"
         }
      ],
      "name":"getImage",
      "outputs":[
         {
            "name":"",
            "type":"string"
         },
         {
            "name":"",
            "type":"uint256"
         }
      ],
      "payable":false,
      "stateMutability":"view",
      "type":"function"
   },
   {
      "constant":true,
      "inputs":[
         {
            "name":"userAddress",
            "type":"address"
         }
      ],
      "name":"getUser",
      "outputs":[
         {
            "name":"",
            "type":"string"
         },
         {
            "name":"",
            "type":"bytes32"
         },
         {
            "name":"",
            "type":"bytes32"
         },
         {
            "name":"",
            "type":"bytes32"
         },
         {
            "name":"",
            "type":"bytes32[]"
         }
      ],
      "payable":false,
      "stateMutability":"view",
      "type":"function"
   },
   {
      "constant":true,
      "inputs":[

      ],
      "name":"getAllImages",
      "outputs":[
         {
            "name":"",
            "type":"bytes32[]"
         }
      ],
      "payable":false,
      "stateMutability":"view",
      "type":"function"
   },
   {
      "constant":false,
      "inputs":[
         {
            "name":"imageURL",
            "type":"string"
         },
         {
            "name":"SHA256notaryHash",
            "type":"bytes32"
         }
      ],
      "name":"addImageToUser",
      "outputs":[
         {
            "name":"success",
            "type":"bool"
         }
      ],
      "payable":false,
      "stateMutability":"nonpayable",
      "type":"function"
   },
   {
      "constant":true,
      "inputs":[
         {
            "name":"userAddress",
            "type":"address"
         }
      ],
      "name":"getUserImages",
      "outputs":[
         {
            "name":"",
            "type":"bytes32[]"
         }
      ],
      "payable":false,
      "stateMutability":"view",
      "type":"function"
   }
]
@shamatar
Copy link
Contributor

shamatar commented Feb 1, 2018

Hello @PandaraWen

Thank you for a valuable feedback, it was indeed a bug with "bytes32[]" like parameters parsing. Pushed a fix in 0.2.12.

Sincerely, Alexander

@PandaraWen
Copy link
Author

Oh thanks for your rapidly response, I would test again later on, and close this issue if everything goes 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