Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Missing ABIMessage function signature recognition #159

Open
rockfridrich opened this issue Jun 24, 2018 · 1 comment
Open

Missing ABIMessage function signature recognition #159

rockfridrich opened this issue Jun 24, 2018 · 1 comment

Comments

@rockfridrich
Copy link
Member

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>

@abdulowork
Copy link
Contributor

The message ctor of the ABIMessage was intended to be used without the prepended message signature. How about adding an abiReturn ctor to the ABIMessage which will drop first 3 bytes?

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