@@ -17,16 +17,17 @@ module wormhole_transceiver::wormhole_transceiver {
1717 transceiver_message::prefix (&TransceiverAuth {}, ntt_common::bytes4 ::new (x"9945FF10 "))
1818 }
1919
20- public struct State has key , store {
20+ public struct State < phantom ManagerAuth > has key , store {
2121 id: UID ,
2222 peers: Table <u16 , ExternalAddress >,
2323 emitter_cap: EmitterCap ,
2424 }
2525
26- public (package ) fun new (
26+ public (package ) fun new < ManagerAuth > (
2727 wormhole_state: &wormhole::state ::State ,
2828 ctx: &mut TxContext
29- ): State {
29+ ): State <ManagerAuth > {
30+ assert ! (ntt_common::contract_auth ::is_auth_type <ManagerAuth >(b"ManagerAuth "));
3031 State {
3132 id: object::new (ctx),
3233 peers: table::new (ctx),
@@ -45,18 +46,18 @@ module wormhole_transceiver::wormhole_transceiver {
4546 }
4647
4748 #[allow(lint(share_owned))]
48- public fun complete (deployer: DeployerCap , wormhole_state: &wormhole::state ::State , ctx: &mut TxContext ): AdminCap {
49+ public fun complete < ManagerAuth > (deployer: DeployerCap , wormhole_state: &wormhole::state ::State , ctx: &mut TxContext ): AdminCap {
4950 let DeployerCap { id } = deployer;
5051 object::delete (id); // Deletion means that nothing can redeploy this again...
5152
52- let state = new (wormhole_state, ctx);
53+ let state = new < ManagerAuth > (wormhole_state, ctx);
5354 transfer::public_share_object (state);
5455
5556 AdminCap { id: object::new (ctx) }
5657 }
5758
58- public fun release_outbound (
59- state: &mut State ,
59+ public fun release_outbound < ManagerAuth > (
60+ state: &mut State < ManagerAuth > ,
6061 message: OutboundMessage <TransceiverAuth >,
6162 ): MessageTicket {
6263
@@ -81,8 +82,8 @@ module wormhole_transceiver::wormhole_transceiver {
8182 message_ticket
8283 }
8384
84- public fun validate_message (
85- state: &State ,
85+ public fun validate_message < ManagerAuth > (
86+ state: &State < ManagerAuth > ,
8687 vaa: VAA ,
8788 ): ValidatedTransceiverMessage <TransceiverAuth , vector <u8 >> {
8889 let (emitter_chain, emitter_address, payload)
@@ -107,19 +108,7 @@ module wormhole_transceiver::wormhole_transceiver {
107108 id: UID
108109 }
109110
110- // public fun set_peer(
111- // _: &AdminCap,
112- // state: &mut State,
113- // chain: u16,
114- // peer: ExternalAddress
115- // ) {
116- // if (state.peers.contains(chain)) {
117- // state.peers.remove(chain);
118- // };
119- // state.peers.add(chain, peer);
120- // }
121-
122- public fun set_peer (_ : &AdminCap , state: &mut State , chain: u16 , peer: ExternalAddress ): MessageTicket {
111+ public fun set_peer <ManagerAuth >(_ : &AdminCap , state: &mut State <ManagerAuth >, chain: u16 , peer: ExternalAddress ): MessageTicket {
123112
124113 // Cannot replace WH peers because of complexities with the accountant, according to EVM implementation.
125114 assert ! (!state.peers.contains (chain));
@@ -134,7 +123,7 @@ module wormhole_transceiver::wormhole_transceiver {
134123
135124 NTT Accountant must know which transceivers registered each other as peers.
136125 */
137- fun broadcast_peer (chain_id: u16 , peer_address: ExternalAddress , state: &mut State ): MessageTicket {
126+ fun broadcast_peer < ManagerAuth > (chain_id: u16 , peer_address: ExternalAddress , state: &mut State < ManagerAuth > ): MessageTicket {
138127
139128 let transceiver_registration_struct = wormhole_transceiver::wormhole_transceiver_registration ::new (chain_id, peer_address);
140129 let message_ticket = wormhole::publish_message ::prepare_message (
@@ -155,9 +144,9 @@ module wormhole_transceiver::wormhole_transceiver {
155144 the NTT accountant to begin with but does want it in the future.
156145 If wanted in the future, an admin would call this function to allow the NTT accountant to work.
157146 */
158- public fun broadcast_id <CoinType , Auth >(_: &AdminCap , coin_meta: &CoinMetadata <CoinType >, state: &mut State , manager_state: &ManagerState <CoinType >): MessageTicket {
147+ public fun broadcast_id <CoinType , ManagerAuth >(_: &AdminCap , coin_meta: &CoinMetadata <CoinType >, state: &mut State < ManagerAuth > , manager_state: &ManagerState <CoinType >): MessageTicket {
159148
160- let mut manager_address_opt: Option <address > = ntt_common::contract_auth ::get_auth_address <Auth >(b"ManagerAuth ");
149+ let mut manager_address_opt: Option <address > = ntt_common::contract_auth ::get_auth_address <ManagerAuth >(b"ManagerAuth ");
161150 let manager_address = option::extract (&mut manager_address_opt);
162151
163152 let external_address_manager_address = wormhole::external_address ::from_address (manager_address);
0 commit comments