[Ceres] Add Chain.network_id #959
@ -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`,
|
`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
|
and `Int.to_bytes`; and adjust `Bytes.concat` to allow both fixed and arbitrary
|
||||||
sized byte arrays.
|
sized byte arrays.
|
||||||
|
- `Chain.network_id` - a function to get hold of the Chain's network id.
|
||||||
### Changed
|
### Changed
|
||||||
### Removed
|
### Removed
|
||||||
- `Bitwise.aes` standard library is removed - the builtin operations are superior.
|
- `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.
|
The gas limit of the current block.
|
||||||
|
|
||||||
|
|
||||||
|
##### network\_id
|
||||||
|
```
|
||||||
|
Chain.network\_id : string
|
||||||
|
```
|
||||||
|
|
||||||
|
The network id of the chain.
|
||||||
|
|
||||||
|
|
||||||
##### spend
|
##### spend
|
||||||
```
|
```
|
||||||
Chain.spend(to : address, amount : int) : unit
|
Chain.spend(to : address, amount : int) : unit
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
{erl_opts, [debug_info]}.
|
{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"}
|
, {eblake2, "1.0.0"}
|
||||||
, {jsx, {git, "https://github.com/talentdeficit/jsx.git", {tag, "2.8.0"}}}
|
, {jsx, {git, "https://github.com/talentdeficit/jsx.git", {tag, "2.8.0"}}}
|
||||||
]}.
|
]}.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{"1.2.0",
|
{"1.2.0",
|
||||||
[{<<"aebytecode">>,
|
[{<<"aebytecode">>,
|
||||||
{git,"https://github.com/aeternity/aebytecode.git",
|
{git,"https://github.com/aeternity/aebytecode.git",
|
||||||
{ref,"b38349274fc2bed98d7fe86877e6e1a2df302109"}},
|
{ref,"009e0361922037f978f9c0ef357d4d1be8559928"}},
|
||||||
0},
|
0},
|
||||||
{<<"aeserialization">>,
|
{<<"aeserialization">>,
|
||||||
{git,"https://github.com/aeternity/aeserialization.git",
|
{git,"https://github.com/aeternity/aeserialization.git",
|
||||||
|
@ -654,6 +654,7 @@ global_env() ->
|
|||||||
{"block_height", Int},
|
{"block_height", Int},
|
||||||
{"difficulty", Int},
|
{"difficulty", Int},
|
||||||
{"gas_limit", Int},
|
{"gas_limit", Int},
|
||||||
|
{"network_id", String},
|
||||||
{"bytecode_hash",FunC1(bytecode_hash, A, Option(Hash))},
|
{"bytecode_hash",FunC1(bytecode_hash, A, Option(Hash))},
|
||||||
{"create", Stateful(
|
{"create", Stateful(
|
||||||
FunN([ {named_arg_t, Ann, {id, Ann, "value"}, Int, {typed, Ann, {int, Ann, 0}, Int}}
|
FunN([ {named_arg_t, Ann, {id, Ann, "value"}, Int, {typed, Ann, {int, Ann, 0}, Int}}
|
||||||
|
@ -271,8 +271,8 @@ builtins() ->
|
|||||||
end,
|
end,
|
||||||
Scopes = [{[], [{"abort", 1}, {"require", 2}, {"exit", 1}]},
|
Scopes = [{[], [{"abort", 1}, {"require", 2}, {"exit", 1}]},
|
||||||
{["Chain"], [{"spend", 2}, {"balance", 1}, {"block_hash", 1}, {"coinbase", none},
|
{["Chain"], [{"spend", 2}, {"balance", 1}, {"block_hash", 1}, {"coinbase", none},
|
||||||
{"timestamp", none}, {"block_height", none}, {"difficulty", none},
|
{"timestamp", none}, {"block_height", none}, {"difficulty", none}, {"gas_limit", none},
|
||||||
{"gas_limit", none}, {"bytecode_hash", 1}, {"create", variable}, {"clone", variable}]},
|
{"network_id", none}, {"bytecode_hash", 1}, {"create", variable}, {"clone", variable}]},
|
||||||
{["Contract"], [{"address", none}, {"balance", none}, {"creator", none}]},
|
{["Contract"], [{"address", none}, {"balance", none}, {"creator", none}]},
|
||||||
{["Call"], [{"origin", none}, {"caller", none}, {"value", none}, {"gas_price", none}, {"fee", none},
|
{["Call"], [{"origin", none}, {"caller", none}, {"value", none}, {"gas_price", none}, {"fee", none},
|
||||||
{"gas_left", 0}]},
|
{"gas_left", 0}]},
|
||||||
|
@ -568,6 +568,8 @@ builtin_to_scode(_Env, chain_difficulty, []) ->
|
|||||||
[aeb_fate_ops:difficulty(?a)];
|
[aeb_fate_ops:difficulty(?a)];
|
||||||
builtin_to_scode(_Env, chain_gas_limit, []) ->
|
builtin_to_scode(_Env, chain_gas_limit, []) ->
|
||||||
[aeb_fate_ops:gaslimit(?a)];
|
[aeb_fate_ops:gaslimit(?a)];
|
||||||
|
builtin_to_scode(_Env, chain_network_id, []) ->
|
||||||
|
[aeb_fate_ops:network_id(?a)];
|
||||||
builtin_to_scode(_Env, contract_balance, []) ->
|
builtin_to_scode(_Env, contract_balance, []) ->
|
||||||
[aeb_fate_ops:balance(?a)];
|
[aeb_fate_ops:balance(?a)];
|
||||||
builtin_to_scode(_Env, contract_address, []) ->
|
builtin_to_scode(_Env, contract_address, []) ->
|
||||||
@ -1090,6 +1092,7 @@ attributes(I) ->
|
|||||||
{'MICROBLOCK', A} -> Pure(A, []);
|
{'MICROBLOCK', A} -> Pure(A, []);
|
||||||
{'DIFFICULTY', A} -> Pure(A, []);
|
{'DIFFICULTY', A} -> Pure(A, []);
|
||||||
{'GASLIMIT', A} -> Pure(A, []);
|
{'GASLIMIT', A} -> Pure(A, []);
|
||||||
|
{'NETWORK_ID', A} -> Pure(A, []);
|
||||||
{'GAS', A} -> Pure(A, []);
|
{'GAS', A} -> Pure(A, []);
|
||||||
{'LOG0', A} -> Impure(none, [A]);
|
{'LOG0', A} -> Impure(none, [A]);
|
||||||
{'LOG1', A, B} -> Impure(none, [A, B]);
|
{'LOG1', A, B} -> Impure(none, [A, B]);
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
contract ChainTest =
|
contract ChainTest =
|
||||||
|
|
||||||
record state = { last_bf : address }
|
record state = { last_bf : address
|
||||||
|
, nw_id : string }
|
||||||
|
|
||||||
function init() : state =
|
function init() : state =
|
||||||
{last_bf = Contract.address}
|
{last_bf = Contract.address}
|
||||||
@ -11,3 +12,6 @@ contract ChainTest =
|
|||||||
|
|
||||||
function save_coinbase() =
|
function save_coinbase() =
|
||||||
put(state{last_bf = Chain.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