Skip to content
This repository has been archived by the owner on May 28, 2019. It is now read-only.

Add ENSEncoder #8

Merged
merged 3 commits into from
Apr 26, 2018
Merged

Conversation

hewigovens
Copy link
Contributor

  1. Add ENSEncoder and tests
  2. Add Namehash and tests
  3. Mark TrustCoreTests scheme as shared

@codecov-io
Copy link

codecov-io commented Apr 25, 2018

Codecov Report

Merging #8 into master will increase coverage by 1.52%.
The diff coverage is 98.86%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #8      +/-   ##
==========================================
+ Coverage   82.51%   84.03%   +1.52%     
==========================================
  Files          20       23       +3     
  Lines         858      946      +88     
==========================================
+ Hits          708      795      +87     
- Misses        150      151       +1
Impacted Files Coverage Δ
Tests/Solidity/NamehashTests.swift 100% <100%> (ø)
Tests/Solidity/ENSEncoderTests.swift 100% <100%> (ø)
Sources/Solidity/ENSEncoder.swift 98.03% <98.03%> (ø)

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 acca5f6...99ce82e. Read the comment docs.

Copy link
Contributor

@vikmeup vikmeup left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@alejandro-isaza alejandro-isaza left a comment

Choose a reason for hiding this comment

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

Nice, just a few comments.

@@ -1,3 +1,6 @@
.DS_Store
Copy link
Contributor

Choose a reason for hiding this comment

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

You should add this to your global .gitignore see https://help.github.com/articles/ignoring-files/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can revert this change, but just like we use swiftlint pod version (not global), what if other contributors not set global .gitignore?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's fine to leave it in.


extension Data {
/// sha3 keccak 256
public func sha3() -> Data {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's just use EthereumCrypto.hash(data) I think it is more explicit than data.sha3(). Also we want to have only one way of doing things.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

return data.sha3()
}

public var labelhash: Data {
Copy link
Contributor

Choose a reason for hiding this comment

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

how is this different from sha3? Why do we need a different name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@alejandro-isaza alejandro-isaza Apr 26, 2018

Choose a reason for hiding this comment

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

But then it should be labelHash (capital H) and it should be a static method in the ENSEncoder class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how about a plain public func labelhash / namehash? it may not be used only in ENS contract (other: PublicResolver / ReverseRegistrar)

Copy link
Contributor

Choose a reason for hiding this comment

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

When it's needed somewhere else we can refactor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok👌

node = self.split(separator: ".")
.map { Array($0.utf8).sha3() }
.reversed()
.reduce(node) { return ($0 + $1).sha3() }
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be very specific, it should not be an extension to String as it contaminates the String namespace.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need this scheme

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can revert this but It's convenient for people first time opens the project, otherwise you have to click "Manage Schemes..."

Copy link
Contributor

Choose a reason for hiding this comment

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

Pressing Command-U on the framework target (or any target) should run the tests. No need for a separate scheme.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I know that keyboard shortcuts, I just want to only write and build the tests, then do a full test when everything is done

Copy link
Contributor

Choose a reason for hiding this comment

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

You can also just run some tests. Still not sure why you need a separate scheme.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fine, I will revert this change. (it's not a separate scheme, All the tests are in the same target, I just mark it as shared. We can only run some tests but we still need to build the whole target)

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you can share your screen and show me what you mean :)

@alejandro-isaza alejandro-isaza merged commit 53bb60c into trustwallet:master Apr 26, 2018
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.

4 participants