-
Notifications
You must be signed in to change notification settings - Fork 169
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
Conversation
|
||
return EthereumTransaction( | ||
from: from, | ||
to: EthereumAddress("0x"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.zero
XCTAssertNoThrow(try encoder.encode("BokkyPooBah Test Token")) | ||
XCTAssertNoThrow(try encoder.encode("BOKKY")) | ||
XCTAssertNoThrow(try encoder.encode(UInt8(18))) |
There was a problem hiding this comment.
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.
XCTAssertNoThrow(try encoder.encode("BokkyPooBah Test Token")) | ||
XCTAssertNoThrow(try encoder.encode("BOKKY")) | ||
XCTAssertNoThrow(try encoder.encode(UInt8(18))) |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
@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"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.zero
@rinat-enikeev are you going to update this? |
See issue.
Basically I want to be able to deploy contracts from Swift code.