@@ -18,15 +18,15 @@ const MAX_LENGTH_HANDLE: usize = 100_000;
18
18
const MAX_LENGTH_MIGRATE : usize = 100_000 ;
19
19
const MAX_LENGTH_QUERY : usize = 100_000 ;
20
20
21
- pub fn call_init < S , A , Q , U > (
22
- instance : & mut Instance < S , A , Q > ,
21
+ pub fn call_init < A , S , Q , U > (
22
+ instance : & mut Instance < A , S , Q > ,
23
23
env : & Env ,
24
24
info : & MessageInfo ,
25
25
msg : & [ u8 ] ,
26
26
) -> VmResult < ContractResult < InitResponse < U > > >
27
27
where
28
- S : Storage + ' static ,
29
28
A : Api + ' static ,
29
+ S : Storage + ' static ,
30
30
Q : Querier + ' static ,
31
31
U : DeserializeOwned + Clone + fmt:: Debug + JsonSchema + PartialEq ,
32
32
{
@@ -37,15 +37,15 @@ where
37
37
Ok ( result)
38
38
}
39
39
40
- pub fn call_handle < S , A , Q , U > (
41
- instance : & mut Instance < S , A , Q > ,
40
+ pub fn call_handle < A , S , Q , U > (
41
+ instance : & mut Instance < A , S , Q > ,
42
42
env : & Env ,
43
43
info : & MessageInfo ,
44
44
msg : & [ u8 ] ,
45
45
) -> VmResult < ContractResult < HandleResponse < U > > >
46
46
where
47
- S : Storage + ' static ,
48
47
A : Api + ' static ,
48
+ S : Storage + ' static ,
49
49
Q : Querier + ' static ,
50
50
U : DeserializeOwned + Clone + fmt:: Debug + JsonSchema + PartialEq ,
51
51
{
@@ -56,15 +56,15 @@ where
56
56
Ok ( result)
57
57
}
58
58
59
- pub fn call_migrate < S , A , Q , U > (
60
- instance : & mut Instance < S , A , Q > ,
59
+ pub fn call_migrate < A , S , Q , U > (
60
+ instance : & mut Instance < A , S , Q > ,
61
61
env : & Env ,
62
62
info : & MessageInfo ,
63
63
msg : & [ u8 ] ,
64
64
) -> VmResult < ContractResult < MigrateResponse < U > > >
65
65
where
66
- S : Storage + ' static ,
67
66
A : Api + ' static ,
67
+ S : Storage + ' static ,
68
68
Q : Querier + ' static ,
69
69
U : DeserializeOwned + Clone + fmt:: Debug + JsonSchema + PartialEq ,
70
70
{
@@ -75,11 +75,16 @@ where
75
75
Ok ( result)
76
76
}
77
77
78
- pub fn call_query < S : Storage + ' static , A : Api + ' static , Q : Querier + ' static > (
79
- instance : & mut Instance < S , A , Q > ,
78
+ pub fn call_query < A , S , Q > (
79
+ instance : & mut Instance < A , S , Q > ,
80
80
env : & Env ,
81
81
msg : & [ u8 ] ,
82
- ) -> VmResult < ContractResult < QueryResponse > > {
82
+ ) -> VmResult < ContractResult < QueryResponse > >
83
+ where
84
+ A : Api + ' static ,
85
+ S : Storage + ' static ,
86
+ Q : Querier + ' static ,
87
+ {
83
88
let env = to_vec ( env) ?;
84
89
let data = call_query_raw ( instance, & env, msg) ?;
85
90
let result: ContractResult < QueryResponse > = from_slice ( & data) ?;
@@ -96,57 +101,82 @@ pub fn call_query<S: Storage + 'static, A: Api + 'static, Q: Querier + 'static>(
96
101
97
102
/// Calls Wasm export "init" and returns raw data from the contract.
98
103
/// The result is length limited to prevent abuse but otherwise unchecked.
99
- pub fn call_init_raw < S : Storage + ' static , A : Api + ' static , Q : Querier + ' static > (
100
- instance : & mut Instance < S , A , Q > ,
104
+ pub fn call_init_raw < A , S , Q > (
105
+ instance : & mut Instance < A , S , Q > ,
101
106
env : & [ u8 ] ,
102
107
info : & [ u8 ] ,
103
108
msg : & [ u8 ] ,
104
- ) -> VmResult < Vec < u8 > > {
109
+ ) -> VmResult < Vec < u8 > >
110
+ where
111
+ A : Api + ' static ,
112
+ S : Storage + ' static ,
113
+ Q : Querier + ' static ,
114
+ {
105
115
instance. set_storage_readonly ( false ) ;
106
116
call_raw ( instance, "init" , & [ env, info, msg] , MAX_LENGTH_INIT )
107
117
}
108
118
109
119
/// Calls Wasm export "handle" and returns raw data from the contract.
110
120
/// The result is length limited to prevent abuse but otherwise unchecked.
111
- pub fn call_handle_raw < S : Storage + ' static , A : Api + ' static , Q : Querier + ' static > (
112
- instance : & mut Instance < S , A , Q > ,
121
+ pub fn call_handle_raw < A , S , Q > (
122
+ instance : & mut Instance < A , S , Q > ,
113
123
env : & [ u8 ] ,
114
124
info : & [ u8 ] ,
115
125
msg : & [ u8 ] ,
116
- ) -> VmResult < Vec < u8 > > {
126
+ ) -> VmResult < Vec < u8 > >
127
+ where
128
+ A : Api + ' static ,
129
+ S : Storage + ' static ,
130
+ Q : Querier + ' static ,
131
+ {
117
132
instance. set_storage_readonly ( false ) ;
118
133
call_raw ( instance, "handle" , & [ env, info, msg] , MAX_LENGTH_HANDLE )
119
134
}
120
135
121
136
/// Calls Wasm export "migrate" and returns raw data from the contract.
122
137
/// The result is length limited to prevent abuse but otherwise unchecked.
123
- pub fn call_migrate_raw < S : Storage + ' static , A : Api + ' static , Q : Querier + ' static > (
124
- instance : & mut Instance < S , A , Q > ,
138
+ pub fn call_migrate_raw < A , S , Q > (
139
+ instance : & mut Instance < A , S , Q > ,
125
140
env : & [ u8 ] ,
126
141
info : & [ u8 ] ,
127
142
msg : & [ u8 ] ,
128
- ) -> VmResult < Vec < u8 > > {
143
+ ) -> VmResult < Vec < u8 > >
144
+ where
145
+ A : Api + ' static ,
146
+ S : Storage + ' static ,
147
+ Q : Querier + ' static ,
148
+ {
129
149
instance. set_storage_readonly ( false ) ;
130
150
call_raw ( instance, "migrate" , & [ env, info, msg] , MAX_LENGTH_MIGRATE )
131
151
}
132
152
133
153
/// Calls Wasm export "query" and returns raw data from the contract.
134
154
/// The result is length limited to prevent abuse but otherwise unchecked.
135
- pub fn call_query_raw < S : Storage + ' static , A : Api + ' static , Q : Querier + ' static > (
136
- instance : & mut Instance < S , A , Q > ,
155
+ pub fn call_query_raw < A , S , Q > (
156
+ instance : & mut Instance < A , S , Q > ,
137
157
env : & [ u8 ] ,
138
158
msg : & [ u8 ] ,
139
- ) -> VmResult < Vec < u8 > > {
159
+ ) -> VmResult < Vec < u8 > >
160
+ where
161
+ A : Api + ' static ,
162
+ S : Storage + ' static ,
163
+ Q : Querier + ' static ,
164
+ {
140
165
instance. set_storage_readonly ( true ) ;
141
166
call_raw ( instance, "query" , & [ env, msg] , MAX_LENGTH_QUERY )
142
167
}
143
168
144
- fn call_raw < S : Storage + ' static , A : Api + ' static , Q : Querier + ' static > (
145
- instance : & mut Instance < S , A , Q > ,
169
+ fn call_raw < A , S , Q > (
170
+ instance : & mut Instance < A , S , Q > ,
146
171
name : & str ,
147
172
args : & [ & [ u8 ] ] ,
148
173
result_max_length : usize ,
149
- ) -> VmResult < Vec < u8 > > {
174
+ ) -> VmResult < Vec < u8 > >
175
+ where
176
+ A : Api + ' static ,
177
+ S : Storage + ' static ,
178
+ Q : Querier + ' static ,
179
+ {
150
180
let mut arg_region_ptrs = Vec :: < Val > :: with_capacity ( args. len ( ) ) ;
151
181
for arg in args {
152
182
let region_ptr = instance. allocate ( arg. len ( ) ) ?;
0 commit comments