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

#98 - implemented encoding, estimate and deployment for contract creation and call #101

Merged
merged 19 commits into from
May 7, 2018

Conversation

abdulowork
Copy link
Contributor

To implement #98 I separated transaction bytes computation into three separate purposes (contract deployment, contract function call, direct ether transaction). I added separate encoding for contract as EncodedContract and function as EncodedABIFunction. I added computation for contract address as ComputedContractAddress since ganache doesn't report contract address in the eth_getTransactionByHash call.

To solve #100 I added a missing check in SimpleRLP.

@0crat 0crat added the scope label Apr 19, 2018
@0crat
Copy link

0crat commented Apr 19, 2018

Job #101 is now in scope, role is REV

@abdulowork abdulowork requested review from rockfridrich and driver733 and removed request for rockfridrich April 19, 2018 22:51
@@ -105,6 +105,98 @@ final class RLPTests: XCTestCase {
)
}

func test127() {
Copy link
Contributor

Choose a reason for hiding this comment

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

@Biboran Are double expects necessary?


func testContractCallIsEncodedCorrectly() {
expect{
try EthContractCallBytes(
Copy link
Contributor

Choose a reason for hiding this comment

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

@Biboran Seven ctor parameters seems to be too much. What do you think about splitting the tested class into smaller ones?

Copy link
Contributor Author

@abdulowork abdulowork Apr 23, 2018

Choose a reason for hiding this comment

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

@driver733 part of the requirement for the transaction signing is an ability to reproduce it by specifying every dependency. There are 7-8 mathematically independent dependencies for the transaction signing.

Do you see any way to retain that functionality and reduce the number of parameters?

Copy link
Member

Choose a reason for hiding this comment

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

@Biboran @driver733 lets accept that some functions require that number of parameters due to Ethereum architecture. We could code domain wrappers for them later after experimenting with real DApps. If it is ok then let's merge this.

@testable import Web3Swift

final class EthContractCreationBytesTests: XCTestCase {

Copy link
Contributor

Choose a reason for hiding this comment

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

@Biboran Seven ctor parameters seems to be too much. What do you think about splitting the tested class into smaller ones?

import Foundation

//Bytes of a signed contract function call transaction
public final class EthContractCallBytes: BytesScalar {
Copy link
Contributor

Choose a reason for hiding this comment

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

@Biboran Eight ctor parameters seems to be too much. What do you think about splitting the tested class into smaller ones?

import Foundation

//Bytes of a signed contract deployment transaction
public final class EthContractCreationBytes: BytesScalar {
Copy link
Contributor

Choose a reason for hiding this comment

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

@Biboran Seven ctor parameters seems to be too much. What do you think about splitting the class into smaller ones?

import Foundation

//Bytes of a signed transaction to ethereum address
public final class EthDirectTransactionBytes: BytesScalar {
Copy link
Contributor

Choose a reason for hiding this comment

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

@Biboran Seven ctor parameters seems to be too much. What do you think about splitting the class into smaller ones?


//FIXME: This is a temporary workaround to allow throwing errors communicated by network. It is definitely possible to make this check perform only when the "result" was not found by reimplementing JSON.
//Procedure that throws in case JSON RPC responded with an error
public final class VerifiedProcedure: RemoteProcedure {
Copy link
Member

Choose a reason for hiding this comment

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

@Biboran we will need to use verified procedure everywhere. Is it better to create 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 this is a temporary workaround as you can see is mentioned in the above fixme. I described the issue here: #58

weiAmount: NumberScalar,
functionCall: BytesScalar
) {
let senderAddress = CachedBytes(
Copy link
Member

Choose a reason for hiding this comment

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

@Biboran what is the purpose of CachedBytes?

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 makes sure senderAddress is computed only once. Take a look at CachedBytes implementation.

@rockfridrich
Copy link
Member

@Biboran there are a lot of objects like SimpleBytes, BigEndianNumber, CachedNumber and it is not clear how to use them.
We will need to have some wrappers later because it is madness to construct such objects
screen shot 2018-04-24 at 16 02 48

@abdulowork
Copy link
Contributor Author

abdulowork commented Apr 24, 2018

@rockfridrich the point of this ctor is to handle the complexity of signing a transaction. You only need to pass 5 vital parameters and everything else is handled inside. It might be a better idea to take it out and put into another object but I am not sure what it should be and I'll need help with that design.

If you will start with #96 and #99 you will gain an understanding of the design and you will be able tell me how it can be improved and where it's extremely vague.

@0crat
Copy link

0crat commented Apr 24, 2018

This pull request #101 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 Apr 24, 2018

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

@0crat
Copy link

0crat commented Apr 29, 2018

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

@driver733
Copy link
Contributor

@0crat waiting

@0crat
Copy link

0crat commented Apr 30, 2018

@0crat waiting (here)

@driver733 It's a code review job #101, can't put it on hold

@0crat
Copy link

0crat commented May 6, 2018

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

@0crat
Copy link

0crat commented May 6, 2018

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

@0crat
Copy link

0crat commented May 6, 2018

@Biboran/z everybody who has role REV are banned at this job; I won't be able to assign anyone automatically; consider assigning someone manually (as in §19), or invite more people (as in §51), or remove the job from the scope (as in §14)

@abdulowork abdulowork merged commit 882d920 into develop May 7, 2018
@0crat
Copy link

0crat commented May 7, 2018

This pull request #101 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 May 7, 2018

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

@0crat 0crat removed the scope label May 7, 2018
@0crat
Copy link

0crat commented May 7, 2018

Order was finished: +15 point(s) just awarded to @driver733/z

@0crat
Copy link

0crat commented May 7, 2018

The job #101 is now out of scope

@0crat
Copy link

0crat commented May 7, 2018

Payment to ARC for a closed pull request, as in §28: +10 point(s) just awarded to @Biboran/z

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