Missing ABIMessage function signature recognition #159
Description
The ABIMessage
decoding fails for contract transaction execution.
In case we try to decode the smart-contract execution transaction's input
by wrapping it in ABIMessage
and executing any of DecodeABI*
function an overflow error occurs. The bug happens because of additional prefix signature bytes. Example for the transaction:
let transactionHash = BytesFromHexString(
hex: "0x5798fbc45e3b63832abc4984b0f3574a13545f415dd672cd8540cd71f735db56"
)
let network = InfuraNetwork(
chain: "mainnet",
apiKey: "metamask"
)
//Fetching transaction
let basicInfo: JSON = try TransactionProcedure(
network: network,
transactionHash: transactionHash
).call()
// Wrapping `input`
let input = ABIMessage(
message: basicInfo["result"]["input"].stringValue
)
// Get the description string
let description = try DecodedABIString(
abiMessage: input,
index: 2
).value()
An error occures:
Integer with hex representation
612e45a3000000000000000000000000b656b2a9c3b2416437a811e07466ca71
exceeds maximum size 8 by 24
It seems resonable if ABIMessage
will recognize that there is a signature
in the input
and perform all operations by cutting it out.
However, we got same error in case of decoding custom data that was not encoded (padded correctly) by the Web3. Example for the transaction. We got input 0x49206c6f7665205765623353776966742e696f
that represents I love Web3Swift.io
string. An error occures
expected to not throw any error, got <Received bytes of size 19 when 32 was expected>