Skip to content

Commit 3034d02

Browse files
author
Maxwell Dulin
committed
Add more comments
1 parent 5a51006 commit 3034d02

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

sui/packages/wormhole_transceiver/sources/wormhole_transceiver.move

+23-16
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,34 @@ module wormhole_transceiver::wormhole_transceiver {
128128
broadcast_peer(chain, peer, state)
129129
}
130130

131+
/*
132+
Broadcast Peer in Solana
133+
Transceiver Registration in EVM
134+
135+
NTT Accountant must know which transceivers registered each other as peers.
136+
*/
137+
fun broadcast_peer(chain_id: u16, peer_address: ExternalAddress, state: &mut State): Option<MessageTicket>{
138+
139+
let transceiver_registration_struct = wormhole_transceiver::wormhole_transceiver_registration::new(chain_id, peer_address);
140+
let message_ticket = wormhole::publish_message::prepare_message(
141+
&mut state.emitter_cap,
142+
0,
143+
transceiver_registration_struct.to_bytes(),
144+
);
145+
option::some(message_ticket)
146+
}
147+
131148
/*
132149
TransceiverInit on EVM
133150
BroadCastId on Solana
151+
152+
Deployment of a new transceiver and notice to the NTT accountant.
153+
Added as a separate function instead of in `init/complete` because
154+
we want to keep these functions simple and dependency free. Additionally, the deployer of NTT may not want
155+
the NTT accountant to begin with but does want it in the future.
156+
If wanted in the future, an admin would call this function to allow the NTT accountant to work.
134157
*/
135158
public fun broadcast_id<CoinType, Auth>(_: &AdminCap, coin_meta: &CoinMetadata<CoinType>, state: &mut State, manager_state: &ManagerState<CoinType>): Option<MessageTicket> {
136-
// MessageTicket cannot be dropped. Means that the WH message is forced to be emitted, since only the `publish_message` call can get rid of it.
137159

138160
let mut manager_address_opt: Option<address> = ntt_common::contract_auth::get_auth_address<Auth>();
139161
let manager_address = option::extract(&mut manager_address_opt);
@@ -150,21 +172,6 @@ module wormhole_transceiver::wormhole_transceiver {
150172
option::some(message_ticket)
151173
}
152174

153-
/*
154-
Broadcast Peer in Solana
155-
Transceiver Registration in EVM
156-
*/
157-
fun broadcast_peer(chain_id: u16, peer_address: ExternalAddress, state: &mut State): Option<MessageTicket>{
158-
159-
let transceiver_registration_struct = wormhole_transceiver::wormhole_transceiver_registration::new(chain_id, peer_address);
160-
let message_ticket = wormhole::publish_message::prepare_message(
161-
&mut state.emitter_cap,
162-
0,
163-
transceiver_registration_struct.to_bytes(),
164-
);
165-
option::some(message_ticket)
166-
}
167-
168175
#[test]
169176
public fun test_auth_type() {
170177
assert!(ntt_common::contract_auth::is_auth_type<wormhole_transceiver::wormhole_transceiver::Auth>(), 0);

0 commit comments

Comments
 (0)