1717 const Actor &actor, Runtime &runtime, const MethodParams ¶ms)
1818
1919namespace fc::vm::actor {
20+
21+ using common::Buffer;
2022 using runtime::InvocationOutput;
2123 using runtime::Runtime;
2224
@@ -33,12 +35,6 @@ namespace fc::vm::actor {
3335 // / Actor methods exported by number
3436 using ActorExports = std::map<MethodNumber, ActorMethod>;
3537
36- // / Reserved method number for send operation
37- constexpr MethodNumber kSendMethodNumber {0 };
38-
39- // / Reserved method number for constructor
40- constexpr MethodNumber kConstructorMethodNumber {1 };
41-
4238 // / Decode actor params, raises appropriate error
4339 template <typename T>
4440 outcome::result<T> decodeActorParams (MethodParams params_bytes) {
@@ -50,6 +46,20 @@ namespace fc::vm::actor {
5046 }
5147
5248 using runtime::encodeActorParams;
49+
50+ template <typename T>
51+ outcome::result<T> decodeActorReturn (const InvocationOutput &result) {
52+ OUTCOME_TRY (decoded,
53+ codec::cbor::decode<T>(result.return_value .toVector ()));
54+ return std::move (decoded);
55+ }
56+
57+ template <typename T>
58+ outcome::result<InvocationOutput> encodeActorReturn (const T &result) {
59+ OUTCOME_TRY (encoded, codec::cbor::encode (result));
60+ return InvocationOutput{Buffer{encoded}};
61+ }
62+
5363} // namespace fc::vm::actor
5464
5565#endif // CPP_FILECOIN_CORE_VM_ACTOR_ACTOR_METHOD_HPP
0 commit comments