feat: new external function call interface#18274
Conversation
| @@ -51,68 +51,10 @@ where | |||
| } | |||
| } | |||
|
|
|||
There was a problem hiding this comment.
The docs from this file were moved over to ContractSelf and I marked the functions as deprecated to point devs to the new API.
| /// # Returns | ||
| /// * `T` - Whatever data the called function has returned. | ||
| /// | ||
| /// TODO(F-130): Drop this function. This should be present only on PrivateStaticCallInterface. |
There was a problem hiding this comment.
Will drop this function in a followup PR. It shouldn't exist.
| { | ||
| emit_event_in_private(event, self.context, recipient, delivery_mode); | ||
| } | ||
|
|
There was a problem hiding this comment.
The docs here are mostly a copy-paster from call_interfaces.nr. I just:
- updated the arguments as they are different here,
- added the Example section which I thought is important because devs might not know how tho get the CallInterface arg.
| * General Opcodes | ||
| ************************************************************************/ | ||
| #[external("public")] | ||
| #[view] |
There was a problem hiding this comment.
Needed to do this because where it's called it's called statically and the new API doesn't support calling of non-view function statically because self.view(...) expects PublicStaticCallInterface on the input and not PublicCallInterface.
| #[external("private")] | ||
| fn enqueue_public_from_private() { | ||
| AvmTest::at(self.address).set_opcode_u8().enqueue_view(self.context); | ||
| self.enqueue_self_static.set_opcode_u8(); |
There was a problem hiding this comment.
The naming here is inconsistent. Somewhere we use "static" and somewhere we use "view". Noted that in the final renaming task.
548002b to
baf4cef
Compare
5c45a7f to
e9e3a26
Compare
|
|
||
| #[external("public")] | ||
| #[view] | ||
| fn set_opcode_u8_view() -> u8 { |
There was a problem hiding this comment.
The new API doesn't allow me to call non-view function statically but we also need the set_opcode_u8 to be non-static for typescript test so I just created this copy here.
1448ef8 to
9f627cf
Compare
e9e3a26 to
dc586db
Compare
9f627cf to
22ad496
Compare
5843610 to
ffe6c15
Compare
4645315 to
1b0eb6f
Compare
6eedab5 to
cc4088d
Compare
1b0eb6f to
50e1222
Compare
Flakey Tests🤖 says: This CI run detected 1 tests that failed, but were tolerated due to a .test_patterns.yml entry. |
8bb0e31 to
4463791
Compare
cc4088d to
09bfcdb
Compare
09bfcdb to
afc0612
Compare
4463791 to
39a98d3
Compare
afc0612 to
e82cde7
Compare
39a98d3 to
26b8165
Compare
Fixes F-135
In this PR I implement the following API:
```rust
self.{call, view, enqueue, enqueue_view, enqueue_view_incognito, set_as_teardown, set_as_teardown_incognito}(MyContract::at(address).my_function(...args))
```
that can now be used instead of:
```rust
MyContract::at(address).my_function(...args).{call, view, enqueue, enqueue_view, enqueue_view_incognito, set_as_teardown, set_as_teardown_incognito}(self.context)
```
I've also updated all the places to use the new API.
Now `self.context` is used in contracts fairly rarely.
26b8165 to
7de49f6
Compare
Pull Request is not mergeable

Fixes F-135
In this PR I implement the following API:
that can now be used instead of:
I've also updated all the places to use the new API.
Now
self.contextis used in contracts fairly rarely.