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

[IND-416] Add default fee for v4 python client #54

Merged
merged 5 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions v4-client-py/v4_client_py/chain/aerial/client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from datetime import timedelta
from typing import Any, Callable, List, Optional, Union
from v4_client_py.clients.constants import BroadcastMode, DEFAULT_TOKEN
from v4_client_py.clients.constants import BroadcastMode

from v4_proto.cosmos.base.query.v1beta1.pagination_pb2 import PageRequest

Expand All @@ -18,7 +18,7 @@ def prepare_and_broadcast_basic_transaction(
gas_limit: Optional[int] = None,
memo: Optional[str] = None,
broadcast_mode: BroadcastMode = None,
fee: Optional[int] = 5000,
fee: int = 5000,
) -> SubmittedTx:
"""Prepare and broadcast basic transaction.

Expand All @@ -28,6 +28,8 @@ def prepare_and_broadcast_basic_transaction(
:param account: The account
:param gas_limit: The gas limit
:param memo: Transaction memo, defaults to None
:param broadcast_mode: Broadcast mode, defaults to None
:param fee: Transaction fee, defaults to 5000
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Note that the denomination is from the network config.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


:return: broadcast transaction
"""
Expand All @@ -53,7 +55,7 @@ def prepare_and_broadcast_basic_transaction(
# finally, build the final transaction that will be executed with the correct gas and fee values
tx.seal(
SigningCfg.direct(sender.public_key(), account.sequence),
fee=f"{fee}{DEFAULT_TOKEN}",
fee=f"{fee}{client.network_config.fee_denomination}",
gas_limit=gas_limit,
memo=memo,
)
Expand Down
17 changes: 16 additions & 1 deletion v4-client-py/v4_client_py/chain/aerial/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@ def fetchai_dorado_testnet(cls) -> "NetworkConfig":
faucet_url="https://faucet-dorado.fetch.ai",
)

@classmethod
def fetch_dydx_testnet(cls) -> "NetworkConfig":
"""Dydx testnet.

:return: Network configuration
"""
return NetworkConfig(
chain_id="dydx",
url="grpc+https://v4.testnet.dydx.exchange",
fee_minimum_gas_price=5000000000,
fee_denomination="dv4tnt",
staking_denomination="dv4tnt",
faucet_url="http://faucet.v4testnet.dydx.exchange",
)

@classmethod
def fetchai_alpha_testnet(cls):
"""Get the fetchai alpha testnet.
Expand All @@ -93,7 +108,7 @@ def fetchai_stable_testnet(cls):

:return: fetchai stable testnet. For now dorado is fetchai stable testnet.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Update this comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

"""
return cls.fetchai_dorado_testnet()
return cls.fetch_dydx_testnet()

@classmethod
def fetchai_mainnet(cls) -> "NetworkConfig":
Expand Down
3 changes: 0 additions & 3 deletions v4-client-py/v4_client_py/clients/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@

BECH32_PREFIX = 'dydx'

# ------------ DEFAULT TOKEN ------------
DEFAULT_TOKEN = "dv4tnt"

class BroadcastMode(Enum):
BroadcastTxSync = 0
BroadcastTxCommit = 1
Expand Down