Skip to content

Commit d0530ca

Browse files
committed
chore(sui): reflect changes to voyager
Signed-off-by: aeryz <[email protected]>
1 parent f5f7fae commit d0530ca

File tree

3 files changed

+105
-37
lines changed

3 files changed

+105
-37
lines changed

sui/vault/sources/metadata.move

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,63 @@
1+
2+
// License text copyright (c) 2020 MariaDB Corporation Ab, All Rights Reserved.
3+
// "Business Source License" is a trademark of MariaDB Corporation Ab.
4+
5+
// Parameters
6+
7+
// Licensor: Union.fi, Labs Inc.
8+
// Licensed Work: All files under https://github.com/unionlabs/union's sui subdirectory
9+
// The Licensed Work is (c) 2024 Union.fi, Labs Inc.
10+
// Change Date: Four years from the date the Licensed Work is published.
11+
// Change License: Apache-2.0
12+
//
13+
14+
// For information about alternative licensing arrangements for the Licensed Work,
15+
// please contact [email protected].
16+
17+
// Notice
18+
19+
// Business Source License 1.1
20+
21+
// Terms
22+
23+
// The Licensor hereby grants you the right to copy, modify, create derivative
24+
// works, redistribute, and make non-production use of the Licensed Work. The
25+
// Licensor may make an Additional Use Grant, above, permitting limited production use.
26+
27+
// Effective on the Change Date, or the fourth anniversary of the first publicly
28+
// available distribution of a specific version of the Licensed Work under this
29+
// License, whichever comes first, the Licensor hereby grants you rights under
30+
// the terms of the Change License, and the rights granted in the paragraph
31+
// above terminate.
32+
33+
// If your use of the Licensed Work does not comply with the requirements
34+
// currently in effect as described in this License, you must purchase a
35+
// commercial license from the Licensor, its affiliated entities, or authorized
36+
// resellers, or you must refrain from using the Licensed Work.
37+
38+
// All copies of the original and modified Licensed Work, and derivative works
39+
// of the Licensed Work, are subject to this License. This License applies
40+
// separately for each version of the Licensed Work and the Change Date may vary
41+
// for each version of the Licensed Work released by Licensor.
42+
43+
// You must conspicuously display this License on each original or modified copy
44+
// of the Licensed Work. If you receive the Licensed Work in original or
45+
// modified form from a third party, the terms and conditions set forth in this
46+
// License apply to your use of that work.
47+
48+
// Any use of the Licensed Work in violation of this License will automatically
49+
// terminate your rights under this License for the current and all other
50+
// versions of the Licensed Work.
51+
52+
// This License does not grant you any right in any trademark or logo of
53+
// Licensor or its affiliates (provided that you may use a trademark or logo of
54+
// Licensor as expressly required by this License).
55+
56+
// TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
57+
// AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
58+
// EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
59+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
60+
// TITLE.
161
module vault::metadata {
262
use std::string::String;
363

voyager/plugins/sui-ibc-app/src/main.rs

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use std::{collections::VecDeque, sync::Arc};
1+
use std::collections::VecDeque;
22

3-
use concurrent_keyring::{ConcurrentKeyring, KeyringConfig, KeyringEntry};
43
use ibc_union_spec::datagram::{MsgPacketAcknowledgement, MsgPacketRecv};
54
use jsonrpsee::{
65
core::{async_trait, JsonValue as Value, RpcResult},
@@ -54,7 +53,8 @@ pub struct Module {
5453

5554
#[derive(Clone, Debug, Serialize, Deserialize)]
5655
pub struct ZkgmConfig {
57-
address: SuiAddress,
56+
zkgm_address: SuiAddress,
57+
vault_object_id: ObjectID,
5858
/// ID of the `wrapped_token_to_t` mapping
5959
wrapped_token_to_t: ObjectID,
6060
}
@@ -109,21 +109,8 @@ impl TransactionPluginServer for Module {
109109
) -> RpcResult<ProgrammableTransaction> {
110110
let mut ptb = ProgrammableTransactionBuilder::new();
111111

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;
127114

128115
// If the module is ZKGM, then we register the tokens if needed. Otherwise,
129116
// the registered tokens are returned.
@@ -151,6 +138,8 @@ impl TransactionPluginServer for Module {
151138
self,
152139
&module_info,
153140
store_initial_seq,
141+
self.zkgm_config.vault_object_id,
142+
vault_store_initial_seq,
154143
coin_t,
155144
fee_recipient,
156145
data.relayer_msgs.clone(),
@@ -175,21 +164,8 @@ impl TransactionPluginServer for Module {
175164
) -> RpcResult<ProgrammableTransaction> {
176165
let mut ptb = ProgrammableTransactionBuilder::new();
177166

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;
193169

194170
// If the module is ZKGM, then we register the tokens if needed. Otherwise,
195171
// the registered tokens are returned.
@@ -206,6 +182,8 @@ impl TransactionPluginServer for Module {
206182
self,
207183
&module_info,
208184
store_initial_seq,
185+
self.zkgm_config.vault_object_id,
186+
vault_store_initial_seq,
209187
coin_t,
210188
fee_recipient,
211189
session,
@@ -253,6 +231,20 @@ impl Module {
253231
zkgm_config: config.zkgm_config,
254232
})
255233
}
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+
}
256248
}
257249

258250
#[async_trait]

voyager/plugins/sui-ibc-app/src/zkgm.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,14 @@ pub fn begin_recv_call(
8282
))
8383
}
8484

85+
#[allow(clippy::too_many_arguments)]
8586
pub fn recv_packet_call(
8687
ptb: &mut ProgrammableTransactionBuilder,
8788
module: &Module,
8889
module_info: &ModuleInfo,
89-
store_initial_seq: SequenceNumber,
90+
zkgm_store_initial_seq: SequenceNumber,
91+
vault_object_id: ObjectID,
92+
vault_store_initial_seq: SequenceNumber,
9093
coin_t: TypeTag,
9194
fee_recipient: SuiAddress,
9295
relayer_msgs: Vec<Bytes>,
@@ -100,7 +103,12 @@ pub fn recv_packet_call(
100103
}),
101104
CallArg::Object(ObjectArg::SharedObject {
102105
id: module_info.stores[0].into(),
103-
initial_shared_version: store_initial_seq,
106+
initial_shared_version: zkgm_store_initial_seq,
107+
mutable: true,
108+
}),
109+
CallArg::Object(ObjectArg::SharedObject {
110+
id: vault_object_id,
111+
initial_shared_version: vault_store_initial_seq,
104112
mutable: true,
105113
}),
106114
SUI_CALL_ARG_CLOCK,
@@ -196,11 +204,14 @@ pub fn begin_ack_call(
196204
))
197205
}
198206

207+
#[allow(clippy::too_many_arguments)]
199208
pub fn acknowledge_packet_call(
200209
ptb: &mut ProgrammableTransactionBuilder,
201210
module: &Module,
202211
module_info: &ModuleInfo,
203-
store_initial_seq: SequenceNumber,
212+
zkgm_store_initial_seq: SequenceNumber,
213+
vault_object_id: ObjectID,
214+
vault_store_initial_seq: SequenceNumber,
204215
coin_t: TypeTag,
205216
fee_recipient: SuiAddress,
206217
session: Argument,
@@ -213,7 +224,12 @@ pub fn acknowledge_packet_call(
213224
}),
214225
CallArg::Object(ObjectArg::SharedObject {
215226
id: module_info.stores[0].into(),
216-
initial_shared_version: store_initial_seq,
227+
initial_shared_version: zkgm_store_initial_seq,
228+
mutable: true,
229+
}),
230+
CallArg::Object(ObjectArg::SharedObject {
231+
id: vault_object_id,
232+
initial_shared_version: vault_store_initial_seq,
217233
mutable: true,
218234
}),
219235
CallArg::Pure(bcs::to_bytes(&fee_recipient).unwrap()),

0 commit comments

Comments
 (0)