bitshares / gwallet

Graphical bitshares wallet
MIT License
4 stars 10 forks source link

create an Execute template function #5

Closed oxarbitrage closed 5 years ago

oxarbitrage commented 5 years ago

For each command that do something in the blockchain(transfer, sell_asset, vote_for_witness, etc) the OnOK method of the command class is called: https://github.com/bitshares/gwallet/blob/master/panels/transfer.cpp#L32

This do some field conversion, validate some data, check if the cli is checked, create the command without broadcasting, present the confirmation dialog and finally executes and get a signed_transaction as response.

In all commands, the same is done. An Execute() function with the number of arguments needed can be created i think in commands.cpp to centralize this code and optimize it in one place.

The tricky part i think is that you need to send wallet method name as argument and call the function, i think it can be done with something like this:

https://stackoverflow.com/a/7558083

oxarbitrage commented 5 years ago

No template function was needed, just a normal one. Function is created here https://github.com/bitshares/gwallet/commit/3aa698284b98fad5648658d340a037005b854350 and then applied to all operations at https://github.com/bitshares/gwallet/commit/fff49e35a9b0a8b91f49ddcfdc0c11ef9591d0af

oxarbitrage commented 5 years ago

sellasset was missing, added at https://github.com/bitshares/gwallet/commit/71d0b32610a17882aea0ed36d68d30b4ae716afc