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
I thinks the problem come from the method parseAtomicType on the file Utils/TypedData.swift.
You have line 110:
case .DynamicString, .DynamicBytes:
guard let value = data.stringValue?.web3.keccak256 else {
throw ABIError.invalidValue
}
return try ABIEncoder.encode(value, forType: .FixedBytes(32))
case .FixedAddress, .FixedBytes:
You are considering 0xa21f3c6a68656c6c6f000000000000000000000000000000000000000000000000000000776f726c64202100000000000000000000000000000000000000000000000000" as a String, not as a Hex encoded Data.
I think it should be:
case .DynamicBytes:
guard let stringValue = data.stringValue, let value = Data(hex:stringValue)?.web3.keccak256 else {
throw ABIError.invalidValue
}
return try ABIEncoder.encode(value, forType: .FixedBytes(32))
case .DynamicString:
guard let value = data.stringValue?.web3.keccak256 else {
throw ABIError.invalidValue
}
return try ABIEncoder.encode(value, forType: .FixedBytes(32))
Using this code, I got the expected Hash.
I think you based your code from TrustCore iOS SDK because it has the same logic with the same issues.
Thanks
The text was updated successfully, but these errors were encountered:
I want to encode the following typed message:
Calling :
Returns:
Expected returns:
Fix proposal
I thinks the problem come from the method
parseAtomicType
on the fileUtils/TypedData.swift
.You have line 110:
You are considering
0xa21f3c6a68656c6c6f000000000000000000000000000000000000000000000000000000776f726c64202100000000000000000000000000000000000000000000000000"
as a String, not as a Hex encoded Data.I think it should be:
Using this code, I got the expected Hash.
I think you based your code from TrustCore iOS SDK because it has the same logic with the same issues.
Thanks
The text was updated successfully, but these errors were encountered: