Expose block random seed and timestamp to contract ABI (#1630)

* Expose block random seed and timestamp to contract ABI

* Add tests

* Bump spec version
This commit is contained in:
Jordan Beauchamp
2019-02-07 22:58:02 +13:00
committed by Sergei Pepyakin
parent eb6dc0394e
commit fb0f4dfb03
12 changed files with 208 additions and 6 deletions
@@ -482,6 +482,19 @@ define_env!(Env, <E: Ext>,
Ok(())
},
// Load the latest block RNG seed into the scratch buffer
ext_random_seed(ctx) => {
ctx.scratch_buf = ctx.ext.random_seed().encode();
Ok(())
},
// Load the latest block timestamp into the scratch buffer
ext_now(ctx) => {
let now: u64 = As::as_(ctx.ext.now().clone());
ctx.scratch_buf = now.encode();
Ok(())
},
// Decodes the given buffer as a `T::Call` and adds it to the list
// of to-be-dispatched calls.
//