Skip to content

Fix remaining no tx assigns #715

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

Merged
merged 23 commits into from
Jan 13, 2023
Merged

Fix remaining no tx assigns #715

merged 23 commits into from
Jan 13, 2023

Conversation

janndriessen
Copy link
Collaborator

@janndriessen janndriessen commented Dec 22, 2022

Summary of Changes

Fixes #712

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.

yaroslavyaroslav and others added 4 commits December 15, 2022 14:54
…n` never assigns to `Contract.transaction` for any given method that writes on chain.

Obviously it's a bug spreading all over the `Token` implementation. So this fix should be applied to all `ERC*.swift` methods that returns `WriteOperation`.

This is the special case of #712.

Closes #711
@yaroslavyaroslav
Copy link
Collaborator

Just wonder is it all of them? Like do we really using WriteOperation only in ERC+20 and ERC+721 classes and nowhere else?

@janndriessen
Copy link
Collaborator Author

janndriessen commented Dec 22, 2022

Just wonder is it all of them? Like do we really using WriteOperation only in ERC+20 and ERC+721 classes and nowhere else?

ser, this is work progress [WIP] Just created a PR to run the actions cause I'm lazy. 😄

@janndriessen janndriessen changed the title [WIP] Fix remaining no tx assigns Fix remaining no tx assigns Dec 22, 2022
@JeneaVranceanu
Copy link
Collaborator

TL;DR - this PR is fine to merge but in some future PRs, we must remove these public var transaction: CodableTransaction variables as they only create side effects.


@janndriessen What concerns me about this commit (a20b1c4) is that the callOnBlock value can be modified from the outside before any particular call and when we actually execute any of the read operations we can be a wrong value.

Here is a pseudocode example:

let someErc = SomeERC.init(...)
someErc.transaction.callOnBlock = .exact(555_111)
/// This will probably fail due to `callOnBlock` but also trigger setting
/// `someErc.transaction` to `someErc.contract.transaction`
try? await someErc.executeWriteTransaction()
/// Expected to be called on the latest block but instead uses block number 555_111
try? await someErc.readSomeData()

These types of bugs are the primary reason why we should remove all public var transaction: CodableTransaction variables.

@janndriessen
Copy link
Collaborator Author

janndriessen commented Jan 10, 2023

TL;DR - this PR is fine to merge but in some future PRs, we must remove these public var transaction: CodableTransaction variables as they only create side effects.

@janndriessen What concerns me about this commit (a20b1c4) is that the callOnBlock value can be modified from the outside before any particular call and when we actually execute any of the read operations we can be a wrong value.

Here is a pseudocode example:

let someErc = SomeERC.init(...)
someErc.transaction.callOnBlock = .exact(555_111)
/// This will probably fail due to `callOnBlock` but also trigger setting
/// `someErc.transaction` to `someErc.contract.transaction`
try? await someErc.executeWriteTransaction()
/// Expected to be called on the latest block but instead uses block number 555_111
try? await someErc.readSomeData()

These types of bugs are the primary reason why we should remove all public var transaction: CodableTransaction variables.

For sure you don't have to convince me that these classes have bad designs.

Zooming out, I wouldn't even concentrate on adding/maintaining such classes - for me this is convenience/ nice to have.

If the library is built modular enough, an ERC class like this should be easily buildable by anyone themselves.

@janndriessen
Copy link
Collaborator Author

Also, all this kind of things should go on a list for future design choices for 4.x.x or other future versions.

@JeneaVranceanu JeneaVranceanu merged commit deb58f1 into web3swift-team:develop Jan 13, 2023
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.

WriteOperation.transaction ignores ERC*.transaction settings
3 participants