[Ceres]: Add Chain.network_id (#468)
* Add Chain.network_id * Bump aebytecode version
This commit is contained in:
parent
2c8dcf8032
commit
108cb1f948
@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
`Bytes.to_fixed_size`, `Bytes.to_any_size`, `Bytes.size`, `String.to_bytes`,
|
||||
and `Int.to_bytes`; and adjust `Bytes.concat` to allow both fixed and arbitrary
|
||||
sized byte arrays.
|
||||
- `Chain.network_id` - a function to get hold of the Chain's network id.
|
||||
### Changed
|
||||
### Removed
|
||||
- `Bitwise.aes` standard library is removed - the builtin operations are superior.
|
||||
|
@ -734,6 +734,14 @@ Chain.gas_limit : int
|
||||
The gas limit of the current block.
|
||||
|
||||
|
||||
##### network\_id
|
||||
```
|
||||
Chain.network\_id : string
|
||||
```
|
||||
|
||||
The network id of the chain.
|
||||
|
||||
|
||||
##### spend
|
||||
```
|
||||
Chain.spend(to : address, amount : int) : unit
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
{erl_opts, [debug_info]}.
|
||||
|
||||
{deps, [ {aebytecode, {git, "https://github.com/aeternity/aebytecode.git", {tag, "v3.3.0"}}}
|
||||
{deps, [ {aebytecode, {git, "https://github.com/aeternity/aebytecode.git", {tag, "v3.4.0"}}}
|
||||
, {eblake2, "1.0.0"}
|
||||
, {jsx, {git, "https://github.com/talentdeficit/jsx.git", {tag, "2.8.0"}}}
|
||||
]}.
|
||||
|
@ -1,7 +1,7 @@
|
||||
{"1.2.0",
|
||||
[{<<"aebytecode">>,
|
||||
{git,"https://github.com/aeternity/aebytecode.git",
|
||||
{ref,"b38349274fc2bed98d7fe86877e6e1a2df302109"}},
|
||||
{ref,"009e0361922037f978f9c0ef357d4d1be8559928"}},
|
||||
0},
|
||||
{<<"aeserialization">>,
|
||||
{git,"https://github.com/aeternity/aeserialization.git",
|
||||
|
@ -653,6 +653,7 @@ global_env() ->
|
||||
{"block_height", Int},
|
||||
{"difficulty", Int},
|
||||
{"gas_limit", Int},
|
||||
{"network_id", String},
|
||||
{"bytecode_hash",FunC1(bytecode_hash, A, Option(Hash))},
|
||||
{"create", Stateful(
|
||||
FunN([ {named_arg_t, Ann, {id, Ann, "value"}, Int, {typed, Ann, {int, Ann, 0}, Int}}
|
||||
|
@ -274,8 +274,8 @@ builtins() ->
|
||||
end,
|
||||
Scopes = [{[], [{"abort", 1}, {"require", 2}, {"exit", 1}]},
|
||||
{["Chain"], [{"spend", 2}, {"balance", 1}, {"block_hash", 1}, {"coinbase", none},
|
||||
{"timestamp", none}, {"block_height", none}, {"difficulty", none},
|
||||
{"gas_limit", none}, {"bytecode_hash", 1}, {"create", variable}, {"clone", variable}]},
|
||||
{"timestamp", none}, {"block_height", none}, {"difficulty", none}, {"gas_limit", none},
|
||||
{"network_id", none}, {"bytecode_hash", 1}, {"create", variable}, {"clone", variable}]},
|
||||
{["Contract"], [{"address", none}, {"balance", none}, {"creator", none}]},
|
||||
{["Call"], [{"origin", none}, {"caller", none}, {"value", none}, {"gas_price", none}, {"fee", none},
|
||||
{"gas_left", 0}]},
|
||||
|
@ -568,6 +568,8 @@ builtin_to_scode(_Env, chain_difficulty, []) ->
|
||||
[aeb_fate_ops:difficulty(?a)];
|
||||
builtin_to_scode(_Env, chain_gas_limit, []) ->
|
||||
[aeb_fate_ops:gaslimit(?a)];
|
||||
builtin_to_scode(_Env, chain_network_id, []) ->
|
||||
[aeb_fate_ops:network_id(?a)];
|
||||
builtin_to_scode(_Env, contract_balance, []) ->
|
||||
[aeb_fate_ops:balance(?a)];
|
||||
builtin_to_scode(_Env, contract_address, []) ->
|
||||
@ -1090,6 +1092,7 @@ attributes(I) ->
|
||||
{'MICROBLOCK', A} -> Pure(A, []);
|
||||
{'DIFFICULTY', A} -> Pure(A, []);
|
||||
{'GASLIMIT', A} -> Pure(A, []);
|
||||
{'NETWORK_ID', A} -> Pure(A, []);
|
||||
{'GAS', A} -> Pure(A, []);
|
||||
{'LOG0', A} -> Impure(none, [A]);
|
||||
{'LOG1', A, B} -> Impure(none, [A, B]);
|
||||
|
@ -2,7 +2,8 @@
|
||||
|
||||
contract ChainTest =
|
||||
|
||||
record state = { last_bf : address }
|
||||
record state = { last_bf : address
|
||||
, nw_id : string }
|
||||
|
||||
function init() : state =
|
||||
{last_bf = Contract.address}
|
||||
@ -11,3 +12,6 @@ contract ChainTest =
|
||||
|
||||
function save_coinbase() =
|
||||
put(state{last_bf = Chain.coinbase})
|
||||
|
||||
function save_network_id() =
|
||||
put(state{nw_id = Chain.network_id})
|
||||
|
Loading…
x
Reference in New Issue
Block a user