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

#176 - Fix dynamic tuple encoding #183

Merged
merged 4 commits into from
Feb 26, 2019
Merged

Conversation

abdulowork
Copy link
Contributor

As per #176

  • Added isDynamic and headsCount properties to the ABIEncodedParameter to address encoding cases where tuple is dynamic
  • Split a part of the tuple encoding functionality into ABITupleEncoding class. I am not sure if it's a good naming
  • Added a sample 0x contract call encoding

As a side effect of this change you no longer have to worry about unwrapping enveloped tuples as is illustrated in the testTwoAddressFixedArraysOfTwo test

@codecov-io
Copy link

codecov-io commented Feb 14, 2019

Codecov Report

Merging #183 into develop will increase coverage by 0.06%.
The diff coverage is 99.32%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #183      +/-   ##
===========================================
+ Coverage    96.64%   96.71%   +0.06%     
===========================================
  Files          303      304       +1     
  Lines        10012    10278     +266     
===========================================
+ Hits          9676     9940     +264     
- Misses         336      338       +2
Impacted Files Coverage Δ
Web3Swift/ABI/Parameters/ABITuple.swift 100% <100%> (ø) ⬆️
Web3Swift/ABI/Parameters/ABIBoolean.swift 95.83% <100%> (+0.83%) ⬆️
Example/Tests/ABI/Parameters/ABITupleTests.swift 62.26% <100%> (ø) ⬆️
Web3Swift/ABI/Parameters/ABITupleEncoding.swift 100% <100%> (ø)
Web3Swift/ABI/Parameters/ABIFixedBytes.swift 100% <100%> (ø) ⬆️
Web3Swift/ABI/Parameters/ABIUnsignedNumber.swift 100% <100%> (ø) ⬆️
Web3Swift/ABI/Parameters/ABIString.swift 100% <100%> (ø) ⬆️
Web3Swift/ABI/EncodedABITuple.swift 100% <100%> (ø) ⬆️
Web3Swift/ABI/Parameters/ABIVariableBytes.swift 100% <100%> (ø) ⬆️
Example/Tests/ABI/EncodedABIFunctionTests.swift 100% <100%> (ø) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ad0b9d2...4264b14. Read the comment docs.

@rockfridrich
Copy link
Member

@Biboran thank you, the new implementation looks excellent!
I will check it later this week.
Maybe we could rename ABITupleEncoding to ABIEncodedTuple. It will make it more readable from my perspective.
Also, I will try to guess if it is possible to get rid of checking isDynamic() in many functions.

Should we try to write tests for such 0x function? It consists of a dynamic collection of dynamic tuples

/// @dev Synchronously executes multiple calls of fillOrder.
/// @param orders Array of order specifications.
/// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders.
/// @param signatures Proofs that orders have been created by makers.
/// @return Amounts filled and fees paid by makers and taker.
///         NOTE: makerAssetFilledAmount and takerAssetFilledAmount may include amounts filled of different assets.
function batchFillOrders(
    Order[] memory orders,
    uint256[] memory takerAssetFillAmounts,
    bytes[] memory signatures
)
    public;
    returns (FillResults memory totalFillResults)

@abdulowork
Copy link
Contributor Author

Maybe we could rename ABITupleEncoding to ABIEncodedTuple. It will make it more readable from my perspective.

I am not sure naming it ABIEncodedTuple will help since we already have EncodedABITuple

@abdulowork
Copy link
Contributor Author

Should we try to write tests for such 0x function? It consists of a dynamic collection of dynamic tuples

We desperately need more unit tests for ABI encoding. The existing unit tests were very helpful in regression testing. We should implement more ABI encoding unit tests and ganache/infura integration tests.
Lets also split ganache/infura test into a separate target

@rockfridrich
Copy link
Member

@Biboran do you have an idea how to make ganache run as a part of the testing pipeline?

return heads + tails
}

//TODO: headsCount should probably be injected
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Biboran in which case we need to inject them? If we want manually construct data?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

headsCount function is not a part of any protocol in this class so it should probably be injected from the outside and removed from this class. For example we could make a separate HeadsCount: IntegerScalar class

@abdulowork
Copy link
Contributor Author

do you have an idea how to make ganache run as a part of the testing pipeline?

I think we can try making a tests runner app for mac os that will spawn ganache and tests Process

@abdulowork
Copy link
Contributor Author

Nvmind I found an easy alternative. Lets discuss it in #173

@rockfridrich
Copy link
Member

@Biboran lets merge it and distribute it to CocoaPods. I will spend some time next week to write additional test cases and verify them with web3.js.
Do we need to update docs in README.md?

@abdulowork
Copy link
Contributor Author

I don't think there is any impact on the README

@abdulowork abdulowork merged commit 0bd85e8 into zeriontech:develop Feb 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants