File tree Expand file tree Collapse file tree
packages/ua-devtools-solana/src/oft Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ " @layerzerolabs/ua-devtools-solana " : patch
3+ ---
4+
5+ Refactor enforced option setter on Solana to keep existing value rather than reset to null
Original file line number Diff line number Diff line change @@ -294,11 +294,24 @@ export class OFT extends OmniSDK implements IOApp {
294294 this . logger . verbose ( `Setting enforced options to ${ printJson ( enforcedOptions ) } ` )
295295
296296 const optionsByEidAndMsgType = this . reduceEnforcedOptions ( enforcedOptions )
297- const emptyOptions = Options . newOptions ( ) . toBytes ( )
298297 const ixs : WrappedInstruction [ ] = [ ]
298+
299299 for ( const [ eid , optionsByMsgType ] of optionsByEidAndMsgType ) {
300- const sendOption = optionsByMsgType . get ( MSG_TYPE_SEND ) ?? emptyOptions
301- const sendAndCallOption = optionsByMsgType . get ( MSG_TYPE_SEND_AND_CALL ) ?? emptyOptions
300+ // Helper to get option: from update map OR fetch from chain (safely)
301+ const getOption = async ( msgType : MsgType ) => {
302+ if ( optionsByMsgType . has ( msgType ) ) {
303+ return optionsByMsgType . get ( msgType ) !
304+ }
305+ const hex = await this . getEnforcedOptions ( eid , msgType )
306+ return hex && hex !== '0x' ? Options . fromOptions ( hex ) . toBytes ( ) : Options . newOptions ( ) . toBytes ( )
307+ }
308+
309+ // Fetch both in parallel
310+ const [ sendOption , sendAndCallOption ] = await Promise . all ( [
311+ getOption ( MSG_TYPE_SEND ) ,
312+ getOption ( MSG_TYPE_SEND_AND_CALL ) ,
313+ ] )
314+
302315 ixs . push ( await this . _setPeerEnforcedOptionsIx ( sendOption , sendAndCallOption , eid ) )
303316 }
304317
You can’t perform that action at this time.
0 commit comments