seal: Refactor ext_gas_price (#6478)

* seal: Refactor ext_gas_price

* Remove seals dependency on pallet_transaction_payment
* Add weight as an argument to ext_gas_price

* Fixed documentation nits from review

* Do not use unchecked math even in test code
This commit is contained in:
Alexander Theißen authored and GitHub committed 2020-06-24 10:52:49 +00:00
1 parent f36b78570f
commit a3a42f599a
9 files changed
+51 -51

No files matched your search

@@ -696,12 +696,14 @@ define_env!(Env, <E: Ext>,
Ok(())
},
// Stores the gas price for the current transaction into the scratch buffer.
// Stores the price for the specified amount of gas in scratch buffer.
//
// The data is encoded as T::Balance. The current contents of the scratch buffer are overwritten.
ext_gas_price(ctx) => {
// It is recommended to avoid specifying very small values for `gas` as the prices for a single
// gas can be smaller than one.
ext_gas_price(ctx, gas: u64) => {
ctx.scratch_buf.clear();
ctx.ext.get_weight_price().encode_to(&mut ctx.scratch_buf);
ctx.ext.get_weight_price(gas).encode_to(&mut ctx.scratch_buf);
Ok(())
},