File tree Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -6,4 +6,6 @@ edition = "2021"
6
6
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
7
8
8
[dependencies ]
9
- fvm_sdk = { version = " 1.0.0" }
9
+ fvm_ipld_encoding = { version = " 0.2.2" }
10
+ fvm_sdk = { version = " 1.0.0" }
11
+ fvm_shared = { version = " 0.8.0" }
Original file line number Diff line number Diff line change 1
1
pub mod hash;
2
+ pub mod message;
3
+
2
4
#[ cfg( test) ]
3
5
mod tests { }
Original file line number Diff line number Diff line change
1
+ use crate :: hash:: { Hasher , MethodHasher } ;
2
+
3
+ use fvm_ipld_encoding:: RawBytes ;
4
+ use fvm_sdk:: { send, SyscallResult } ;
5
+ use fvm_shared:: { address:: Address , econ:: TokenAmount , receipt:: Receipt } ;
6
+
7
+ #[ derive( Default ) ]
8
+ pub struct MethodDispatcher < T : Hasher > {
9
+ method_hasher : MethodHasher < T > ,
10
+ }
11
+
12
+ impl < T : Hasher > MethodDispatcher < T > {
13
+ pub fn new ( hasher : T ) -> Self {
14
+ Self {
15
+ method_hasher : MethodHasher :: new ( hasher) ,
16
+ }
17
+ }
18
+
19
+ pub fn call_method (
20
+ & self ,
21
+ to : & Address ,
22
+ method : & str ,
23
+ params : RawBytes ,
24
+ value : TokenAmount ,
25
+ ) -> SyscallResult < Receipt > {
26
+ let method = self . method_hasher . method_number ( method) ;
27
+ send:: send ( to, method, params, value)
28
+ }
29
+ }
You can’t perform that action at this time.
0 commit comments