Skip to content

Commit 0a11cf8

Browse files
committed
-ran black
-made error new return
1 parent 9668b41 commit 0a11cf8

File tree

5 files changed

+34
-19
lines changed

5 files changed

+34
-19
lines changed

src/wallet/cc_wallet/cc_wallet.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ async def get_confirmed_balance(self) -> uint64:
200200

201201
async def get_unconfirmed_balance(self) -> uint64:
202202
confirmed = await self.get_confirmed_balance()
203-
unconfirmed_tx: List[TransactionRecord] = await self.wallet_state_manager.tx_store.get_unconfirmed_for_wallet(
203+
unconfirmed_tx: List[
204+
TransactionRecord
205+
] = await self.wallet_state_manager.tx_store.get_unconfirmed_for_wallet(
204206
self.wallet_info.id
205207
)
206208
addition_amount = 0
@@ -734,9 +736,7 @@ async def cc_spend(
734736
wallet_id=self.wallet_info.id,
735737
sent_to=[],
736738
)
737-
await self.wallet_state_manager.add_pending_transaction(
738-
tx_record
739-
)
739+
await self.wallet_state_manager.add_pending_transaction(tx_record)
740740

741741
return spend_bundle
742742

@@ -783,7 +783,9 @@ async def generate_new_coloured_coin(self, amount: uint64) -> Optional[SpendBund
783783
cc_puzzle = cc_wallet_puzzles.cc_make_puzzle(cc_inner, cc_core)
784784
cc_puzzle_hash = cc_puzzle.get_tree_hash()
785785

786-
tx_record: Optional[TransactionRecord] = await self.standard_wallet.generate_signed_transaction(
786+
tx_record: Optional[
787+
TransactionRecord
788+
] = await self.standard_wallet.generate_signed_transaction(
787789
amount, cc_puzzle_hash, uint64(0), origin_id, coins
788790
)
789791
self.log.warning(f"cc_puzzle_hash is {cc_puzzle_hash}")

src/wallet/trade_manager.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async def create(
4545

4646
async def create_offer_for_ids(
4747
self, offer: Dict[int, int]
48-
) -> Tuple[bool, Optional[SpendBundle]]:
48+
) -> Tuple[bool, Optional[SpendBundle], Optional[str]]:
4949
"""
5050
Offer is dictionary of wallet ids and amount
5151
"""
@@ -69,7 +69,9 @@ async def create_offer_for_ids(
6969
] = await wallet.generate_zero_val_coin(False, to_exclude)
7070

7171
if zero_spend_bundle is None:
72-
raise Exception("Failed to generate offer. Zero value coin not created.")
72+
raise Exception(
73+
"Failed to generate offer. Zero value coin not created."
74+
)
7375
if spend_bundle is None:
7476
spend_bundle = zero_spend_bundle
7577
else:
@@ -100,7 +102,7 @@ async def create_offer_for_ids(
100102
amount, to_exclude
101103
)
102104
else:
103-
return False, None
105+
return False, None, "unssuported wallet type"
104106
if new_spend_bundle.removals() == [] or new_spend_bundle is None:
105107
raise Exception(f"Wallet {id} was unable to create offer.")
106108
if spend_bundle is None:
@@ -110,9 +112,9 @@ async def create_offer_for_ids(
110112
[spend_bundle, new_spend_bundle]
111113
)
112114

113-
return True, spend_bundle
115+
return True, spend_bundle, None
114116
except Exception as e:
115-
return False, str(e)
117+
return False, None, str(e)
116118

117119
def write_offer_to_disk(self, file_path: Path, offer: SpendBundle):
118120
if offer is not None:
@@ -229,7 +231,8 @@ async def respond_to_offer(self, file_path: Path) -> Tuple[bool, Optional[str]]:
229231
colour
230232
)
231233
unspent = await self.wallet_state_manager.get_spendable_coins_for_wallet(
232-
wallets[colour].wallet_info.id)
234+
wallets[colour].wallet_info.id
235+
)
233236
if coinsol.coin in [record.coin for record in unspent]:
234237
return False, "can't respond to own offer"
235238
innerpuzzlereveal = solution.rest().rest().rest().first()
@@ -271,7 +274,9 @@ async def respond_to_offer(self, file_path: Path) -> Tuple[bool, Optional[str]]:
271274
coinsols.append(coinsol)
272275
else:
273276
# standard chia coin
274-
unspent = await self.wallet_state_manager.get_spendable_coins_for_wallet(1)
277+
unspent = await self.wallet_state_manager.get_spendable_coins_for_wallet(
278+
1
279+
)
275280
if coinsol.coin in [record.coin for record in unspent]:
276281
return False, "can't respond to own offer"
277282
if chia_discrepancy is None:

src/wallet/transaction_record.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,8 @@ class TransactionRecord(Streamable):
3636
def name(self) -> bytes32:
3737
if self.spend_bundle:
3838
return self.spend_bundle.name()
39-
return std_hash(bytes(self.to_puzzle_hash) + bytes(self.created_at_time) + bytes(self.amount))
39+
return std_hash(
40+
bytes(self.to_puzzle_hash)
41+
+ bytes(self.created_at_time)
42+
+ bytes(self.amount)
43+
)

src/wallet/wallet_state_manager.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,9 @@ async def get_unconfirmed_balance(self, wallet_id) -> uint64:
403403
transactions.
404404
"""
405405
confirmed = await self.get_confirmed_balance_for_wallet(wallet_id)
406-
unconfirmed_tx: List[TransactionRecord] = await self.tx_store.get_unconfirmed_for_wallet(wallet_id)
406+
unconfirmed_tx: List[
407+
TransactionRecord
408+
] = await self.tx_store.get_unconfirmed_for_wallet(wallet_id)
407409
removal_amount = 0
408410

409411
for record in unconfirmed_tx:
@@ -453,9 +455,9 @@ async def coin_removed(self, coin: Coin, index: uint32):
453455

454456
await self.wallet_store.set_spent(coin.name(), index)
455457

456-
unconfirmed_record: List[TransactionRecord] = await self.tx_store.unconfirmed_with_removal_coin(
457-
coin.name()
458-
)
458+
unconfirmed_record: List[
459+
TransactionRecord
460+
] = await self.tx_store.unconfirmed_with_removal_coin(coin.name())
459461
for unconfirmed in unconfirmed_record:
460462
await self.tx_store.set_confirmed(unconfirmed.name(), index)
461463

src/wallet/websocket_server.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,12 +455,14 @@ async def get_discrepancies_for_offer(self, websocket, request, response_api):
455455
async def create_offer_for_ids(self, websocket, request, response_api):
456456
offer = request["ids"]
457457
file_name = request["filename"]
458-
success, spend_bundle = await self.trade_manager.create_offer_for_ids(offer)
458+
success, spend_bundle, error = await self.trade_manager.create_offer_for_ids(
459+
offer
460+
)
459461
if success:
460462
self.trade_manager.write_offer_to_disk(Path(file_name), spend_bundle)
461463
response = {"success": success}
462464
else:
463-
response = {"success": success, "reason": spend_bundle}
465+
response = {"success": success, "reason": error}
464466

465467
return await websocket.send(format_response(response_api, response))
466468

0 commit comments

Comments
 (0)