This repository has been archived by the owner on Dec 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 76
Auto calculate max_fee #332
Merged
ericnordelo
merged 31 commits into
OpenZeppelin:main
from
andrew-fleming:add-auto-max_fee
Jan 9, 2023
Merged
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
3a01ca9
add estimate_fee_if_zero
andrew-fleming 01e93ed
add tests for estimate_fee_if_zero
andrew-fleming 56c825d
add estimate_fee to run_transaction
andrew-fleming 9a9af6f
src/nile/nre.py
andrew-fleming 1a91cce
formatting
andrew-fleming 8af83d5
remove return
andrew-fleming b0465aa
Apply suggestions from code review
andrew-fleming 01237cc
fix func name
andrew-fleming 7aed394
remove nre tx method
andrew-fleming e74b5fe
add auto_fee param to execute
andrew-fleming e8591d2
Revert "add auto_fee param to execute"
andrew-fleming c22e552
change default max_fee to auto
andrew-fleming 3606bde
add conditional for auto max_fee
andrew-fleming 621acea
fix _process_args
andrew-fleming 819c269
remove import
andrew-fleming de70392
remove estimate_fee func
andrew-fleming dfd2ee4
remove estimate fee test
andrew-fleming c33ac99
adjust tests for auto max_fee
andrew-fleming 26ebcba
Revert "add conditional for auto max_fee"
andrew-fleming f29487c
remove unused param
andrew-fleming 96cc558
add set_estimate_fee_if_auto
andrew-fleming d5035ec
roll back auto fee changes
andrew-fleming 5c0451b
add estimate_fee func to methods
andrew-fleming 8eca7c5
normalize max_fee if None
andrew-fleming e4bbc57
adjust tests for max_fee if None
andrew-fleming c79ea15
fix test
andrew-fleming 0f0918e
Apply suggestions from code review
andrew-fleming 4dd51a1
fix max_fee handling
andrew-fleming 3d115a4
fix tests
andrew-fleming 5a320a4
remove comments
andrew-fleming b4dbb9e
Update src/nile/core/types/account.py
andrew-fleming File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,8 +112,9 @@ async def test_deploy( | |
@patch("nile.core.types.account.get_counterfactual_address", return_value=MOCK_ADDRESS) | ||
@patch("nile.core.types.transactions.get_class_hash", return_value=CLASS_HASH) | ||
@patch("nile.core.deploy.accounts.register") | ||
@patch("nile.core.types.account._set_estimated_fee_if_none") | ||
async def test_deploy_accounts_register( | ||
mock_register, mock_hash, mock_address, mock_deploy | ||
mock_set_fee, mock_register, mock_hash, mock_address, mock_deploy | ||
): | ||
account = await Account(KEY, NETWORK) | ||
|
||
|
@@ -187,9 +188,16 @@ async def test_declare( | |
@patch("nile.core.types.transactions.get_contract_class", return_value="ContractClass") | ||
@patch("nile.core.types.account.DeclareTransaction", return_value="tx") | ||
@patch("nile.core.types.account.DeclareTxWrapper") | ||
@patch("nile.core.types.account._set_estimated_fee_if_none") | ||
async def test_declare_account( | ||
mock_tx_wrapper, mock_tx, mock_contract_class, nile_account, overriding_path | ||
mock_set_fee, | ||
mock_tx_wrapper, | ||
mock_tx, | ||
mock_contract_class, | ||
nile_account, | ||
overriding_path, | ||
): | ||
# mock_tx_wrapper = AsyncMock() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should not! |
||
account = await MockAccount(KEY, NETWORK) | ||
|
||
contract_name = "Account" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think with this we are good to go, just a small suggestion for organization.
Keeping in mind we are calling this for all the account methods returning tx wrappers. Can't we add this logic in the
BaseTxWrapper
__post_init__
method to avoid having to call the_set_estimated_fee_if_none
method repeatedly in account?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.
That was the idea early on, but we'd need
__post_init__
to be async in order to call the underlyingtx.estimate_fee
. It should be possible to do, but I think it's a bit hacky (a la the Account initialization with the asyncself.deploy
)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.
Got it, makes sense.