1
- use std:: { collections:: VecDeque , sync :: Arc } ;
1
+ use std:: collections:: VecDeque ;
2
2
3
- use concurrent_keyring:: { ConcurrentKeyring , KeyringConfig , KeyringEntry } ;
4
3
use ibc_union_spec:: datagram:: { MsgPacketAcknowledgement , MsgPacketRecv } ;
5
4
use jsonrpsee:: {
6
5
core:: { async_trait, JsonValue as Value , RpcResult } ,
@@ -54,7 +53,8 @@ pub struct Module {
54
53
55
54
#[ derive( Clone , Debug , Serialize , Deserialize ) ]
56
55
pub struct ZkgmConfig {
57
- address : SuiAddress ,
56
+ zkgm_address : SuiAddress ,
57
+ vault_object_id : ObjectID ,
58
58
/// ID of the `wrapped_token_to_t` mapping
59
59
wrapped_token_to_t : ObjectID ,
60
60
}
@@ -109,21 +109,8 @@ impl TransactionPluginServer for Module {
109
109
) -> RpcResult < ProgrammableTransaction > {
110
110
let mut ptb = ProgrammableTransactionBuilder :: new ( ) ;
111
111
112
- let store_initial_seq = self
113
- . sui_client
114
- . read_api ( )
115
- . get_object_with_options (
116
- module_info. stores [ 0 ] . into ( ) ,
117
- SuiObjectDataOptions :: new ( ) . with_owner ( ) ,
118
- )
119
- . await
120
- . unwrap ( )
121
- . data
122
- . expect ( "object exists on chain" )
123
- . owner
124
- . expect ( "owner will be present" )
125
- . start_version ( )
126
- . expect ( "object is shared, hence it has a start version" ) ;
112
+ let store_initial_seq = self . get_initial_seq ( module_info. stores [ 0 ] . into ( ) ) . await ;
113
+ let vault_store_initial_seq = self . get_initial_seq ( self . zkgm_config . vault_object_id ) . await ;
127
114
128
115
// If the module is ZKGM, then we register the tokens if needed. Otherwise,
129
116
// the registered tokens are returned.
@@ -151,6 +138,8 @@ impl TransactionPluginServer for Module {
151
138
self ,
152
139
& module_info,
153
140
store_initial_seq,
141
+ self . zkgm_config . vault_object_id ,
142
+ vault_store_initial_seq,
154
143
coin_t,
155
144
fee_recipient,
156
145
data. relayer_msgs . clone ( ) ,
@@ -175,21 +164,8 @@ impl TransactionPluginServer for Module {
175
164
) -> RpcResult < ProgrammableTransaction > {
176
165
let mut ptb = ProgrammableTransactionBuilder :: new ( ) ;
177
166
178
- let store_initial_seq = self
179
- . sui_client
180
- . read_api ( )
181
- . get_object_with_options (
182
- module_info. stores [ 0 ] . into ( ) ,
183
- SuiObjectDataOptions :: new ( ) . with_owner ( ) ,
184
- )
185
- . await
186
- . unwrap ( )
187
- . data
188
- . expect ( "object exists on chain" )
189
- . owner
190
- . expect ( "owner will be present" )
191
- . start_version ( )
192
- . expect ( "object is shared, hence it has a start version" ) ;
167
+ let store_initial_seq = self . get_initial_seq ( module_info. stores [ 0 ] . into ( ) ) . await ;
168
+ let vault_store_initial_seq = self . get_initial_seq ( self . zkgm_config . vault_object_id ) . await ;
193
169
194
170
// If the module is ZKGM, then we register the tokens if needed. Otherwise,
195
171
// the registered tokens are returned.
@@ -206,6 +182,8 @@ impl TransactionPluginServer for Module {
206
182
self ,
207
183
& module_info,
208
184
store_initial_seq,
185
+ self . zkgm_config . vault_object_id ,
186
+ vault_store_initial_seq,
209
187
coin_t,
210
188
fee_recipient,
211
189
session,
@@ -253,6 +231,20 @@ impl Module {
253
231
zkgm_config : config. zkgm_config ,
254
232
} )
255
233
}
234
+
235
+ async fn get_initial_seq ( & self , object : ObjectID ) -> SequenceNumber {
236
+ self . sui_client
237
+ . read_api ( )
238
+ . get_object_with_options ( object, SuiObjectDataOptions :: new ( ) . with_owner ( ) )
239
+ . await
240
+ . unwrap ( )
241
+ . data
242
+ . expect ( "object exists on chain" )
243
+ . owner
244
+ . expect ( "owner will be present" )
245
+ . start_version ( )
246
+ . expect ( "object is shared, hence it has a start version" )
247
+ }
256
248
}
257
249
258
250
#[ async_trait]
0 commit comments