You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I was trying to create a way to decode the [String:Any] values that the decode functions return into something a little easier to use by taking the values of the dictionary and casting them to the types, tho it doesn't work nicely on tuples cause they can't be dynamically created, however I stumbled upon a problem and it was that instead of getting an array of 5 values (which is the number of I have) I was getting an array with 10 values out of the dictionary by using dictionary.compactMap { $0.value }, after further inspecting I found that it happened because of this:
/// ABIElement.swift --> ABi.Element extension --> decodeReturnData (_ data: Data) -> [String:Any]?
for output in function.outputs {
let name = "\(i)"
returnArray[name] = values[i]
if output.name != "" {
returnArray[output.name] = values[i]
}
i = i + 1
}
the params are getting added more than once if the output has a name, is this really necessary? why not:
/// ABIElement.swift --> ABi.Element extension --> decodeReturnData (_ data: Data) -> [String:Any]?
for output in function.outputs {
returnArray[output.name ?? "\(i)"] = values[i]
i = i + 1
}
The text was updated successfully, but these errors were encountered:
This part of design was based on the other runtime Web3 libraries. In fact Solidity developers can omit specifying output values names, so way of addressing using just an integer index is necessary as a baseline. Names are there for developers to be able to filter the keys in the dictionary and output the values using some meaningful name.
So I was trying to create a way to decode the [String:Any] values that the decode functions return into something a little easier to use by taking the values of the dictionary and casting them to the types, tho it doesn't work nicely on tuples cause they can't be dynamically created, however I stumbled upon a problem and it was that instead of getting an array of 5 values (which is the number of I have) I was getting an array with 10 values out of the dictionary by using
dictionary.compactMap { $0.value }
, after further inspecting I found that it happened because of this:the params are getting added more than once if the output has a name, is this really necessary? why not:
The text was updated successfully, but these errors were encountered: