Skip to content

Commit 76dcbfc

Browse files
authored
Refactor Python withdraw example for clarity (#191)
1 parent 5b297f5 commit 76dcbfc

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

v4-client-py-v2/examples/transfer_example_withdraw_other.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,21 @@ async def test():
1313

1414
wallet = await Wallet.from_mnemonic(node, DYDX_TEST_MNEMONIC, TEST_ADDRESS)
1515

16-
message = partial(withdraw, subaccount(TEST_ADDRESS, 0), TEST_ADDRESS, 0)
16+
withdraw_tx = partial(withdraw, subaccount(TEST_ADDRESS, 0), TEST_ADDRESS, 0)
1717
amount = 100_000_000
1818

19-
simulated = node.builder.build(wallet, message(amount))
20-
21-
simulation = await node.simulate(simulated)
19+
simulated_txs = node.builder.build(wallet, withdraw_tx(amount))
20+
simulation = await node.simulate(simulated_txs)
2221
print("**Simulate**")
2322
print(simulation)
2423

2524
fee = node.calculate_fee(simulation.gas_info.gas_used)
2625
print("**Total Fee**")
2726
print(fee)
2827

29-
response = await node.broadcast(
30-
node.build(wallet, message(amount - fee.amount[0].amount), fee)
31-
)
28+
final_withdraw_tx = withdraw_tx(amount - fee.amount[0].amount)
29+
final_txs = node.build(wallet, final_withdraw_tx, fee)
30+
response = await node.broadcast(final_txs)
3231
print("**Withdraw and Send**")
3332
print(response)
3433

0 commit comments

Comments
 (0)