
* Support for CREATE, CLONE and BYTECODE_HASH * Add missing files * Pushed the clone example through the typechecker * CLONE compiles * Fix dependent type in CLONE * Bytecode hash fixes * Refactor * Refactor 2 * move some logic away * Fixed some error messages. Type inference of child contract still does some random shit\n(mistakes arguments with result type) * CREATE sometimes compiles and sometimes not * Fix some scoping/constraint issues * works, needs cleanup * cleanup * Fix some tests. Remove optimization of singleton tuples * Fix default argument for clone * Cleanup * CHANGELOG * Mention void type * Address review, fix some dialyzer errors * Please dialyzer * Fix failing tests * Write negative tests * Docs * TOC * missing 'the' * missing 'the' * missing 'the' * missing 'the' * mention pre-fund * format * pre-fund clarification * format * Grammar in docs
70 lines
1.8 KiB
Plaintext
70 lines
1.8 KiB
Plaintext
|
|
// Testing primitives for accessing the block chain environment
|
|
contract interface Interface =
|
|
entrypoint contract_address : () => address
|
|
entrypoint call_origin : () => address
|
|
entrypoint call_caller : () => address
|
|
entrypoint call_value : () => int
|
|
|
|
contract Environment =
|
|
|
|
record state = {remote : Interface}
|
|
|
|
entrypoint init(remote) = {remote = remote}
|
|
|
|
stateful entrypoint set_remote(remote) = put({remote = remote})
|
|
|
|
// -- Information about the this contract ---
|
|
|
|
// Address
|
|
entrypoint contract_address() : address = Contract.address
|
|
entrypoint nested_address(who) : address =
|
|
who.contract_address(gas = 1000)
|
|
|
|
// Balance
|
|
entrypoint contract_balance() : int = Contract.balance
|
|
|
|
// -- Information about the current call ---
|
|
|
|
// Origin
|
|
entrypoint call_origin() : address = Call.origin
|
|
entrypoint nested_origin() : address =
|
|
state.remote.call_origin()
|
|
|
|
// Caller
|
|
entrypoint call_caller() : address = Call.caller
|
|
entrypoint nested_caller() : address =
|
|
state.remote.call_caller()
|
|
|
|
// Value
|
|
entrypoint call_value() : int = Call.value
|
|
stateful entrypoint nested_value(value : int) : int =
|
|
state.remote.call_value(value = value / 2)
|
|
|
|
// Gas price
|
|
entrypoint call_gas_price() : int = Call.gas_price
|
|
|
|
// -- Information about the chain ---
|
|
|
|
// Account balances
|
|
entrypoint get_balance(acct : address) : int = Chain.balance(acct)
|
|
|
|
// Block hash
|
|
entrypoint block_hash(height : int) : option(hash) = Chain.block_hash(height)
|
|
|
|
// Coinbase
|
|
entrypoint coinbase() : address = Chain.coinbase
|
|
|
|
// Block timestamp
|
|
entrypoint timestamp() : int = Chain.timestamp
|
|
|
|
// Block height
|
|
entrypoint block_height() : int = Chain.block_height
|
|
|
|
// Difficulty
|
|
entrypoint difficulty() : int = Chain.difficulty
|
|
|
|
// Gas limit
|
|
entrypoint gas_limit() : int = Chain.gas_limit
|
|
|