Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce ABIConstructor #196

Closed
wants to merge 1 commit into from

Conversation

rinat-enikeev
Copy link
Contributor

See issue.

Basically I want to be able to deploy contracts from Swift code.


return EthereumTransaction(
from: from,
to: EthereumAddress("0x"),
Copy link
Member

Choose a reason for hiding this comment

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

.zero

Comment on lines +16 to +18
XCTAssertNoThrow(try encoder.encode("BokkyPooBah Test Token"))
XCTAssertNoThrow(try encoder.encode("BOKKY"))
XCTAssertNoThrow(try encoder.encode(UInt8(18)))
Copy link
Member

Choose a reason for hiding this comment

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

Tests also serve as examples, can we create a test-only type to conform to ABIConstructor protocol? Also helps testing from API point of view not internal code.

Comment on lines +16 to +18
XCTAssertNoThrow(try encoder.encode("BokkyPooBah Test Token"))
XCTAssertNoThrow(try encoder.encode("BOKKY"))
XCTAssertNoThrow(try encoder.encode(UInt8(18)))
Copy link
Member

Choose a reason for hiding this comment

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

Tests also serve as examples, can we create a test-only type to conform to ABIConstructor protocol? Also helps testing from API point of view not internal code.

import Foundation
import BigInt

public class ABIConstructorEncoder {
Copy link
Member

Choose a reason for hiding this comment

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

Construction could be seen also as a special function call, so it makes sense from the types point of view.

I think we should leverage ABIFunctionEncoder which is already tested instead of duplicating code here.

Can create an enum in ABIFunctionEncoder with two cases:

enum EncodeVariant {
     case call(name: String)
     case construct(bytecode: Data)
}

Then it's just a matter of changing encoded function to support both calls.

To keep API backwards compatible, we can still keep the same initializer with name which would just set the encoding type to call

@DarthMike
Copy link
Member

@rinat-enikeev Thanks for the contribution, please see my comments above. This is a very nice feature to add to the library!


return EthereumTransaction(
from: from,
to: EthereumAddress("0x"),
Copy link
Member

Choose a reason for hiding this comment

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

.zero

@DarthMike
Copy link
Member

@rinat-enikeev are you going to update this?

@DarthMike DarthMike closed this Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants