Skip to content

Conversation

@zhangliugang
Copy link
Contributor

Summary of Changes

make Block, TransactionInBlock encodable

Test Data or Screenshots

By submitting this pull request, you are confirming the following:
  • I have reviewed the Contribution Guidelines.
  • I have performed a self-review of my own code.
  • I have updated my repository to match the develop branch.
  • I have included test data or screenshots that prove my fix is effective or that my feature works.
  • I have checked that all tests work and swiftlint is not throwing any errors/warnings.
@zhangliugang zhangliugang changed the title Encodable Block make block encodable Feb 6, 2023
Copy link
Collaborator

@JeneaVranceanu JeneaVranceanu left a comment

Choose a reason for hiding this comment

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

All good, only tests are required.


try container.encode(uncles.map { $0.hexString }, forKey: .uncles)

}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please, write test cases for that feature.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest the following:

  • a test case where you create a Block manually, encode, decode it back and compare it with the original;
  • a test case where you will have a JSON string, decode it and check that the decoding didn't throw. That should be something like XCTAssertNoThrow(try JSONDecoder().decode(jsonString, Block.self)).

To produce a JSON string use the first test and String.init(data: try! JSONEncoder().encode(block), encoding: .utf8)! and print it out to the console.

Copy link
Collaborator

@yaroslavyaroslav yaroslavyaroslav left a comment

Choose a reason for hiding this comment

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

So far so good for me.
@zhangliugang FYI: We have 2 weeks release schedule here, not so much strict thou. So this enhancement will be released somewhere within February. It will be released as patch (e.g. 3.1.2) despite that it's an enhancement (e.g. 3.2.0) actually.

@yaroslavyaroslav
Copy link
Collaborator

@yaroslavyaroslav
Copy link
Collaborator

Well, folks. Depending on a new data as in #772 said. It's actually are not so clear whether this PR are has to be merged or not.

I mean, Block is Decodable only because of there's none request in JSON-RPC where we're sending it to a Node.

So the use case of @zhangliugang is to erase this type and treat it like a dictionary on its JS level implementation.

As for me i wonder the whole stack of your project @zhangliugang.

  1. Like why do you use swift library below the ether.js one? Is it non native UI on React or something?
  2. And anyway, why do you choosing to use this lib for network request, not the ether.js one?

The answers would quite helpful to better understand your flow and to keep it in mind in future lib improvements.

Copy link
Collaborator

@yaroslavyaroslav yaroslavyaroslav left a comment

Choose a reason for hiding this comment

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

#772 PR related questions arisen.

@janndriessen
Copy link
Collaborator

Well, folks. Depending on a new data as in #772 said. It's actually are not so clear whether this PR are has to be merged or not.

I mean, Block is Decodable only because of there's none request in JSON-RPC where we're sending it to a Node.

So the use case of @zhangliugang is to erase this type and treat it like a dictionary on its JS level implementation.

As for me i wonder the whole stack of your project @zhangliugang.

  1. Like why do you use swift library below the ether.js one? Is it non native UI on React or something?
  2. And anyway, why do you choosing to use this lib for network request, not the ether.js one?

The answers would quite helpful to better understand your flow and to keep it in mind in future lib improvements.

My first reaction to reading the PR's title was also why does Block even have to be encodable as well. What are the use cases?

@zhangliugang zhangliugang deleted the block-encodable branch August 22, 2023 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants