Skip to content

Commit 6295b37

Browse files
committed
chore: restructure to avoid unnecessary RPC calls
1 parent 6b12299 commit 6295b37

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

  • packages/ua-devtools-solana/src/oft

‎packages/ua-devtools-solana/src/oft/sdk.ts‎

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -301,19 +301,14 @@ export class OFT extends OmniSDK implements IOApp {
301301
const ixs: WrappedInstruction[] = []
302302

303303
for (const [eid, optionsByMsgType] of optionsByEidAndMsgType) {
304-
// Fetch current on-chain values to preserve options that aren't being updated
305-
const currentSendOption = await this.getEnforcedOptions(eid, MSG_TYPE_SEND)
306-
const currentSendAndCallOption = await this.getEnforcedOptions(eid, MSG_TYPE_SEND_AND_CALL)
307-
308-
// Use new value if provided, otherwise preserve current on-chain value
309-
const sendOption =
310-
optionsByMsgType.get(MSG_TYPE_SEND) ??
311-
(currentSendOption ? Options.fromOptions(currentSendOption).toBytes() : Options.newOptions().toBytes())
312-
const sendAndCallOption =
313-
optionsByMsgType.get(MSG_TYPE_SEND_AND_CALL) ??
314-
(currentSendAndCallOption
315-
? Options.fromOptions(currentSendAndCallOption).toBytes()
316-
: Options.newOptions().toBytes())
304+
// Use new value if provided, otherwise fetch and preserve current on-chain value
305+
const sendOption = optionsByMsgType.has(MSG_TYPE_SEND)
306+
? optionsByMsgType.get(MSG_TYPE_SEND)!
307+
: Options.fromOptions(await this.getEnforcedOptions(eid, MSG_TYPE_SEND)).toBytes()
308+
309+
const sendAndCallOption = optionsByMsgType.has(MSG_TYPE_SEND_AND_CALL)
310+
? optionsByMsgType.get(MSG_TYPE_SEND_AND_CALL)!
311+
: Options.fromOptions(await this.getEnforcedOptions(eid, MSG_TYPE_SEND_AND_CALL)).toBytes()
317312

318313
ixs.push(await this._setPeerEnforcedOptionsIx(sendOption, sendAndCallOption, eid))
319314
}

0 commit comments

Comments
 (0)