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

#88, #84, #71, #7 - implemented sending value #91

Merged
merged 19 commits into from
Apr 2, 2018
Merged

#88, #84, #71, #7 - implemented sending value #91

merged 19 commits into from
Apr 2, 2018

Conversation

abdulowork
Copy link
Contributor

@driver733 could you please start with a review. I'll complete missing documentation tomorrow.

#7 - To solve #7 I implemented EthGasPrice for the purpose of asking network for a gas price and EthGasEstimate to estimate the gas needed for most basic value transfer. I added relevant tests.
#84 - I added ganache-cli to travis and redesigned FakeEthereumNetwork to GanacheLocalNetwork which also covers #71. I added some tests with the accounts expected on the ganache testnet.
#88 - I added Account interface and EthAutoAccount which works with network estimates and gas price exclusively. I added an array of missing objects needed for signing and sending transaction to the network.

@0crat 0crat added the scope label Mar 20, 2018
@0crat
Copy link

0crat commented Mar 20, 2018

Job #91 is now in scope, role is REV

@codecov-io
Copy link

codecov-io commented Mar 20, 2018

Codecov Report

Merging #91 into develop will increase coverage by 0.21%.
The diff coverage is 98.01%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #91      +/-   ##
===========================================
+ Coverage    96.96%   97.17%   +0.21%     
===========================================
  Files           91      121      +30     
  Lines         2933     3648     +715     
  Branches        26       24       -2     
===========================================
+ Hits          2844     3545     +701     
- Misses          89      103      +14
Impacted Files Coverage Δ
Example/Actors/Bob.swift 100% <ø> (ø)
Web3Swift/RemoteProcedure/ChainIDProcedure.swift 100% <ø> (ø) ⬆️
Example/Actors/Alice.swift 100% <ø> (ø)
Web3Swift/Transactions/EthTransactions.swift 100% <100%> (ø) ⬆️
...e/Tests/TransactionHash/EthTransactionHashIT.swift 100% <100%> (ø)
Web3Swift/Transactions/EthTransactionBytes.swift 100% <100%> (ø)
Example/Tests/Network/InfuraNetworkTests.swift 100% <100%> (ø) ⬆️
Example/Tests/Network/SimpleNetworkTests.swift 100% <100%> (ø) ⬆️
Example/Tests/GasPrice/EthGasPriceTests.swift 100% <100%> (ø)
Web3Swift/Transaction/EthTransaction.swift 100% <100%> (ø)
... and 66 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 8e11c2f...f3fbe86. Read the comment docs.

func testExistingTransactionReceipt() {
expect{
try EthTransactionReceipt(
network: InfuraNetwork(
Copy link
Member

Choose a reason for hiding this comment

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

@Biboran Let's use MainnetTestingNetwork instead of InfuraNetwork with metamask params

Copy link
Contributor Author

Choose a reason for hiding this comment

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

)
),
recipientAddress: BytesFromHexString(
hex: "0xcD8aC90d9cc7e4c03430d58d2f3e87Dae70b807e"
Copy link
Member

Choose a reason for hiding this comment

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

@Biboran Should we use Alice().privateKey() and Bob().address() in tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rockfridrich there are some problems with this approach. Some of our tests work with mutable state on the blockchain (for example EthAutoAccountIT). If we are going to use Alice and Bob our tests will be temporarily coupled to the greater extent that they already are.

In this particular case I think having the data open is better than introducing any alias objects because it tests low level signing maths

Copy link
Member

Choose a reason for hiding this comment

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

@Biboran original idea was to add Alice and Bob private keys into Ganache initialization script. For some tests, we will need the third character who could be Vitalik

- throws:
`DescribedError` if something went wrong.
*/
public func id() throws -> NumberScalar {
Copy link
Member

Choose a reason for hiding this comment

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

@Biboran each procedure depends on network and we use procedure in one of the network implementations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rockfridrich I believe there is nothing wrong with that.

Copy link
Member

Choose a reason for hiding this comment

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

@Biboran ok, but let's think of introducing some sort of Chain object for this purposes later.

public final class EthTransactionBytes: BytesScalar {

private let networkID: NumberScalar
private let transactionsCount: NumberScalar
Copy link
Member

Choose a reason for hiding this comment

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

@Biboran should it be nonce?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rockfridrich lets leave it at transactionsCount as it makes more sense of where the nonce in the transaction is coming from. Transaction has nonce as expected.

@0crat
Copy link

0crat commented Mar 21, 2018

This pull request #91 is assigned to @driver733/z, here is why; the budget is 15 minutes, see §4; please, read §27 and when you decide to accept the changes, inform @Biboran/z (the architect) right in this ticket; if you decide that this PR should not be accepted ever, also inform the architect; this blog post will help you understand what is expected from a code reviewerWe should be aware that driver733 is on vacation; this ticket may be delayed

@0crat
Copy link

0crat commented Mar 21, 2018

Manual assignment of issues is discouraged, see §19: -5 points just awarded to @Biboran/z

return try EthBalance(
network: network,
address: privateKey.address()
)
Copy link
Member

Choose a reason for hiding this comment

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

@Biboran should it be .value() here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rockfridrich no, it is intended to be lazy

}

public func count() throws -> NumberScalar {
let transactionsCountProcedure = self.transactionsCountProcedure
let transactionsCountProcedure = self.procedure
return BigEndianCompactNumber(
hex: SimpleString{
try transactionsCountProcedure.call()["result"].string()
Copy link
Member

Choose a reason for hiding this comment

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

@Biboran how can we remove ["result"] from the code? Could we create something like .value() as a decorator for JSON?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rockfridrich we can get rid of ["result"] duplication; however, we cannot make it just .value(). There are different types that can be represented by JSON (string, int etc) and sometimes there is a need to traverse JSON as a dictionary (eth_getTransactionReceipt call).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rockfridrich if you believe there is an issue with ["result"] duplication make it a separate issue and we will discuss it there

public protocol Account {

/**
TODO: I am not sure whether the Account should promise to return its balance in wei
Copy link
Member

Choose a reason for hiding this comment

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

@Biboran Probably we should create some sort of value object for Wei that can be easily converted to Eth, GWei and other units like here

@0crat
Copy link

0crat commented Mar 26, 2018

@driver733/z this job was assigned to you 5 days ago. It will be taken away from you soon, unless you close it, see §8. Read this and this, please.

@0crat
Copy link

0crat commented Mar 29, 2018

@driver733/z this job was assigned to you 8 days ago. It will be taken away from you soon, unless you close it, see §8. Read this and this, please.

@0crat
Copy link

0crat commented Mar 30, 2018

@driver733/z this job was assigned to you 9days ago. It will be taken away from you soon, unless you close it, see §8. Read this and this, please.

@0crat
Copy link

0crat commented Mar 30, 2018

@driver733/z this job was assigned to you 9days ago. It will be taken away from you soon, unless you close it, see §8. Read this and this, please.

@0crat
Copy link

0crat commented Mar 31, 2018

The user @driver733/z resigned from #91, please stop working. Reason for job resignation: It is older than 10 days, see §8

@0crat
Copy link

0crat commented Mar 31, 2018

Resigned on delay, see §8: -15 point(s) just awarded to @driver733/z

Copy link
Member

@rockfridrich rockfridrich left a comment

Choose a reason for hiding this comment

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

Let's merge

@abdulowork abdulowork merged commit 8f410fb into develop Apr 2, 2018
@0crat 0crat removed the scope label Apr 9, 2018
@0crat
Copy link

0crat commented Apr 9, 2018

The job #91 is now out of scope

@abdulowork abdulowork deleted the 88 branch April 13, 2018 09:02
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.

5 participants