Entrypoints `parameter_of`: new keyword for obtaining contract's (from module) parameter
Motivation and Context
In some cases it could be useful to have a way of obtaining the parameter from a module (interpreted as a contract because of @entry
attributes).
Description
This MR adds a new keyword parameter_of
for obtaining the parameter of a contract.
Component
-
compiler -
website -
webide -
vscode-plugin -
debugger
Types of changes
-
Bug fix (non-breaking change which fixes an issue) -
New feature (non-breaking change which adds functionality) -
Breaking change (fix or feature that would cause existing functionality to not work as expected) -
Performance improvement (non-breaking change that improves performance) -
None (change with no changelog)
Changelog
A new keyword is introduced: parameter_of
. It can be used to obtain the type of a contract (from a module/namespace):
namespace C {
type storage = int;
// @entry
const increment = (action: int, store: storage) : [list <operation>, storage] => [list([]), store + action];
// @entry
const decrement = (action: int, store: storage) : [list <operation>, storage] => [list([]), store - action];
};
const test_increment = (() => {
let initial_storage = 42;
let [taddr, _, _] = Test.originate_module(contract_of(C), initial_storage, 0 as tez);
let contr : contract<parameter_of C> = Test.to_contract(taddr);
let p : parameter_of C = Increment(1);
let _ = Test.transfer_to_contract_exn(contr, p, 1 as mutez);
return assert(Test.get_storage(taddr) == initial_storage + 1);
}) ();
As in the case of contract_of
, now parameter_of
becomes reserved. To still use parameter_of
as an identifier, @
can be prepended.
Checklist:
-
Changes follow the existing coding style (use dune @fmt
to check). -
Tests for the changes have been added (for bug fixes / feature). -
Documentation has been updated. -
Changelog description has been added (if appropriate). -
Start titles under ## Changelog
section with #### (if appropriate). -
There is no image or uploaded file in changelog -
Examples in changed behaviour have been added to the changelog (for breaking change / feature).
Edited by E. Rivas