embarklabs/embark

Change the units and message format of the logs of deployed contracts

richard-ramos opened this issue · 0 comments

Switch the format of the units from this:

Deploying MyContract with 159057 gas at the price of 5000000000 Wei. Estimated cost: 795285000000000 Wei  (txHash: 0x88b6ea6b69c774755d867f5a440888acfbb98aa163fa4a8d805089b657448314)                                                                                                                                                                              

MyContract deployed at 0xe8f0539238e8139B41E0Dc6e0E888f6fF75fa33f using 144826 gas (txHash: 0x0b89eb3088d033964ae40bb4c66a96ed300d0d7b32f2dc2f0ba6cd1d245a27fe)

to this

Deploying MyContract with 159057 gas at the price of 5 Gwei. Estimated cost: 0.000795285 ether  (txHash: 0x88b6ea6b69c774755d867f5a440888acfbb98aa163fa4a8d805089b657448314)                                                                                                                                                                              

MyContract deployed at 0xe8f0539238e8139B41E0Dc6e0E888f6fF75fa33f using 144826 gas. Cost: 0.0007241 ether

Rationale:

  • When you create a transaction in a wallet, you do not specify the gas price in wei, but in gwei, so displaying the price as such makes it easier for the dev to understand the value being used instead of having to convert the price from wei to a more readable unit.
  • Costs are easier to understand if they're shown in ether instead of wei. It makes it easier to see how much did it cost to deploy a contract.
  • With the new gas price units it's important to display a reasonable number of decimals correctly. i.e., display 5.1204 gwei instead of 5.1204000045 gwei, 6.12 gwei instead of 6.12000005 gwei or 6.1200 gwei (not displaying the 0s to the right)
  • If we are already displaying the estimated cost, it wouldnt hurt to display the actual cost after deploy).
  • txHash was already displayed once, so displaying it more than once pollutes the logs.