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

Release/1.5.0 #89

Merged
merged 7 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions .github/workflows/build-macos-installer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ jobs:
build:
name: MacOS Intel Installer
runs-on: ${{ matrix.os }}
timeout-minutes: 40
timeout-minutes: 50
strategy:
fail-fast: false
max-parallel: 4
matrix:
python-version: [3.9]
os: [macos-10.15]
os: [macos-11]

steps:
- name: Checkout Code
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,4 @@ There is a known issue where harvesters will not reconnect to the farmer automat

#

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project does not yet adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) for setuptools_scm/PEP 440 reasons.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project does not yet adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) for setuptools_scm/PEP 440 reasons.
2 changes: 1 addition & 1 deletion chinilla-blockchain-gui
11 changes: 5 additions & 6 deletions chinilla/rpc/wallet_rpc_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,8 @@ async def create_offer_for_ids(self, request):
trade_record,
error,
) = await self.service.wallet_state_manager.trade_manager.create_offer_for_ids(
modified_offer, driver_dict, fee=fee, validate_only=validate_only, min_coin_amount=min_coin_amount)
modified_offer, driver_dict, fee=fee, validate_only=validate_only, min_coin_amount=min_coin_amount
)
if success:
return {
"offer": Offer.from_bytes(trade_record.offer).to_bech32(),
Expand Down Expand Up @@ -1098,11 +1099,9 @@ async def take_offer(self, request):
min_coin_amount: uint128 = uint128(request.get("min_coin_amount", 0))

async with self.service.wallet_state_manager.lock:
(
success,
trade_record,
error,
) = await self.service.wallet_state_manager.trade_manager.respond_to_offer(offer, fee=fee, min_coin_amount=min_coin_amount)
(success, trade_record, error,) = await self.service.wallet_state_manager.trade_manager.respond_to_offer(
offer, fee=fee, min_coin_amount=min_coin_amount
)
if not success:
raise ValueError(error)
return {"trade_record": trade_record.to_json_dict_convenience()}
Expand Down
4 changes: 2 additions & 2 deletions chinilla/util/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import shutil

from aiofiles import tempfile # type: ignore
from aiofiles import tempfile
from pathlib import Path
from typing import Union

Expand Down Expand Up @@ -68,7 +68,7 @@ async def write_file_async(file_path: Path, data: Union[str, bytes], *, file_mod

mode: str = "w+" if type(data) == str else "w+b"
temp_file_path: Path
async with tempfile.NamedTemporaryFile(dir=file_path.parent, mode=mode, delete=False) as f:
async with tempfile.NamedTemporaryFile(dir=file_path.parent, mode=mode, delete=False) as f: # type: ignore
temp_file_path = f.name
await f.write(data)
await f.flush()
Expand Down
12 changes: 9 additions & 3 deletions chinilla/wallet/trade_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ async def create_offer_for_ids(
) -> Tuple[bool, Optional[TradeRecord], Optional[str]]:
if driver_dict is None:
driver_dict = {}
success, created_offer, error = await self._create_offer_for_ids(offer, driver_dict, fee=fee, min_coin_amount=min_coin_amount)
success, created_offer, error = await self._create_offer_for_ids(
offer, driver_dict, fee=fee, min_coin_amount=min_coin_amount
)
if not success or created_offer is None:
raise Exception(f"Error creating offer: {error}")
now = uint64(int(time.time()))
Expand Down Expand Up @@ -583,7 +585,9 @@ async def calculate_tx_records_for_offer(self, offer: Offer, validate: bool) ->

return txs

async def respond_to_offer(self, offer: Offer, fee=uint64(0), min_coin_amount: Optional[uint128] = None) -> Tuple[bool, Optional[TradeRecord], Optional[str]]:
async def respond_to_offer(
self, offer: Offer, fee=uint64(0), min_coin_amount: Optional[uint128] = None
) -> Tuple[bool, Optional[TradeRecord], Optional[str]]:
take_offer_dict: Dict[Union[bytes32, int], int] = {}
arbitrage: Dict[Optional[bytes32], int] = offer.arbitrage()

Expand All @@ -606,7 +610,9 @@ async def respond_to_offer(self, offer: Offer, fee=uint64(0), min_coin_amount: O
valid: bool = await self.check_offer_validity(offer)
if not valid:
return False, None, "This offer is no longer valid"
success, take_offer, error = await self._create_offer_for_ids(take_offer_dict, offer.driver_dict, fee=fee, min_coin_amount=min_coin_amount)
success, take_offer, error = await self._create_offer_for_ids(
take_offer_dict, offer.driver_dict, fee=fee, min_coin_amount=min_coin_amount
)
if not success or take_offer is None:
return False, None, error

Expand Down
16 changes: 12 additions & 4 deletions tests/wallet/test_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,9 @@ def test_get_wallet_db_path_v2_r1() -> None:
fingerprint: str = "1234567890"
wallet_db_path: Path = get_wallet_db_path(root_path, config, fingerprint)

assert wallet_db_path == Path("/x/y/z/.chinilla/vanillanet/wallet/db/blockchain_wallet_v2_r1_vanillanet_1234567890.sqlite")
assert wallet_db_path == Path(
"/x/y/z/.chinilla/vanillanet/wallet/db/blockchain_wallet_v2_r1_vanillanet_1234567890.sqlite"
)


def test_get_wallet_db_path_v2() -> None:
Expand All @@ -934,7 +936,9 @@ def test_get_wallet_db_path_v2() -> None:
fingerprint: str = "1234567890"
wallet_db_path: Path = get_wallet_db_path(root_path, config, fingerprint)

assert wallet_db_path == Path("/x/y/z/.chinilla/vanillanet/wallet/db/blockchain_wallet_v2_r1_vanillanet_1234567890.sqlite")
assert wallet_db_path == Path(
"/x/y/z/.chinilla/vanillanet/wallet/db/blockchain_wallet_v2_r1_vanillanet_1234567890.sqlite"
)


def test_get_wallet_db_path_v1() -> None:
Expand All @@ -946,7 +950,9 @@ def test_get_wallet_db_path_v1() -> None:
fingerprint: str = "1234567890"
wallet_db_path: Path = get_wallet_db_path(root_path, config, fingerprint)

assert wallet_db_path == Path("/x/y/z/.chinilla/vanillanet/wallet/db/blockchain_wallet_v2_r1_vanillanet_1234567890.sqlite")
assert wallet_db_path == Path(
"/x/y/z/.chinilla/vanillanet/wallet/db/blockchain_wallet_v2_r1_vanillanet_1234567890.sqlite"
)


def test_get_wallet_db_path_testnet() -> None:
Expand All @@ -958,4 +964,6 @@ def test_get_wallet_db_path_testnet() -> None:
fingerprint: str = "1234567890"
wallet_db_path: Path = get_wallet_db_path(root_path, config, fingerprint)

assert wallet_db_path == Path("/x/y/z/.chinilla/testnet/wallet/db/blockchain_wallet_v2_r1_testnet_1234567890.sqlite")
assert wallet_db_path == Path(
"/x/y/z/.chinilla/testnet/wallet/db/blockchain_wallet_v2_r1_testnet_1234567890.sqlite"
)