diff --git a/crypto/configuration/network.py b/crypto/configuration/network.py index 8aec94a..285fd5d 100644 --- a/crypto/configuration/network.py +++ b/crypto/configuration/network.py @@ -5,13 +5,13 @@ class NetworkType(TypedDict): epoch: datetime - version: int wif: int + chain_id: int network: NetworkType = { 'epoch': Testnet.epoch, - 'version': Testnet.version, 'wif': Testnet.wif, + 'chain_id': Testnet.chain_id, } def set_network(network_object: Union[Type[Mainnet], Type[Testnet]]) -> None: @@ -24,8 +24,8 @@ def set_network(network_object: Union[Type[Mainnet], Type[Testnet]]) -> None: network = { 'epoch': network_object.epoch, - 'version': network_object.version, 'wif': network_object.wif, + 'chain_id': network_object.chain_id, } def get_network() -> NetworkType: @@ -36,18 +36,18 @@ def get_network() -> NetworkType: """ return network -def set_custom_network(epoch: datetime, version: int, wif: int) -> None: +def set_custom_network(epoch: datetime, wif: int, chain_id: int) -> None: """Set custom network Args: epoch (datetime): chains epoch time - version (int): chains version wif (int): chains wif + chain_id (int): chain id """ global network network = { 'epoch': epoch, - 'version': version, 'wif': wif, + 'chain_id': chain_id } diff --git a/crypto/networks/mainnet.py b/crypto/networks/mainnet.py index d352edc..d9a2297 100644 --- a/crypto/networks/mainnet.py +++ b/crypto/networks/mainnet.py @@ -2,5 +2,5 @@ class Mainnet(object): epoch = datetime(2017, 3, 21, 13, 00, 00) - version = 30 wif = 186 + chain_id = 10000 diff --git a/crypto/networks/testnet.py b/crypto/networks/testnet.py index a279eac..d879ab8 100644 --- a/crypto/networks/testnet.py +++ b/crypto/networks/testnet.py @@ -2,5 +2,5 @@ class Testnet(object): epoch = datetime(2017, 3, 21, 13, 00, 00) - version = 30 wif = 186 + chain_id = 10000 diff --git a/crypto/transactions/builder/base.py b/crypto/transactions/builder/base.py index c9f12ee..133dc58 100644 --- a/crypto/transactions/builder/base.py +++ b/crypto/transactions/builder/base.py @@ -11,7 +11,7 @@ def __init__(self, data: dict): 'senderPublicKey': '', 'gasPrice': '5', 'nonce': '1', - 'network': get_network()['version'], + 'network': get_network()['chain_id'], 'gasLimit': 1_000_000, 'data': '', diff --git a/tests/configuration/test_network.py b/tests/configuration/test_network.py index d0a963d..260b1be 100644 --- a/tests/configuration/test_network.py +++ b/tests/configuration/test_network.py @@ -8,31 +8,29 @@ def test_get_network(): result = get_network() - assert result['version'] == 30 - + assert result['chain_id'] == 10000 def test_set_network(): # mainnet set_network(Mainnet) result = get_network() - assert result['version'] == 30 assert result['wif'] == 186 + assert result['chain_id'] == 10000 # testnet set_network(Testnet) result = get_network() - assert result['version'] == 30 assert result['wif'] == 186 + assert result['chain_id'] == 10000 set_network(Testnet) # set back to Testnet so other tests don't fail - def test_set_custom_network(): epoch_time = datetime(2017, 1, 1, 13, 00, 00) - set_custom_network(epoch_time, 11, 130) + set_custom_network(epoch_time, 130, 10000) result = get_network() - assert result['version'] == 11 assert result['wif'] == 130 assert result['epoch'] == epoch_time + assert result['chain_id'] == 10000 set_network(Testnet) # set back to Testnet so other tests don't fail