Skip to content

Commit

Permalink
sdk: Handle transceiver init edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
nvsriram committed Oct 18, 2024
1 parent 086f117 commit ded3294
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1798,7 +1798,7 @@ async function nttFromManager<N extends Network, C extends Chain>(
ntt: {
manager: nativeManagerAddress,
token: null,
transceiver: { wormhole: null },
transceiver: {},
}
});
const diff = await onlyManager.verifyAddresses();
Expand Down
11 changes: 8 additions & 3 deletions evm/ts/src/ntt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,10 @@ export class EvmNtt<N extends Network, C extends EvmChains>
);

this.xcvrs = [];
if (contracts.ntt.transceiver["wormhole"]) {
if (
"wormhole" in contracts.ntt.transceiver &&
contracts.ntt.transceiver["wormhole"]
) {
const transceiverTypes = [
"wormhole", // wormhole xcvr should be ix 0
...Object.keys(contracts.ntt.transceiver).filter((transceiverType) => {
Expand Down Expand Up @@ -577,7 +580,7 @@ export class EvmNtt<N extends Network, C extends EvmChains>
manager: this.managerAddress,
token: this.tokenAddress,
transceiver: {
wormhole: this.xcvrs[0]!.address,
...(this.xcvrs.length > 0 && { wormhole: this.xcvrs[0]!.address }),
},
// TODO: what about the quoter?
};
Expand All @@ -586,7 +589,9 @@ export class EvmNtt<N extends Network, C extends EvmChains>
manager: this.managerAddress,
token: await this.manager.token(),
transceiver: {
wormhole: (await this.manager.getTransceivers())[0]!, // TODO: make this more generic
...(this.xcvrs.length > 0 && {
wormhole: (await this.manager.getTransceivers())[0]!,
}), // TODO: make this more generic
},
};

Expand Down
5 changes: 4 additions & 1 deletion solana/ts/sdk/ntt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,10 @@ export class SolanaNtt<N extends Network, C extends SolanaChains>
);

this.transceivers = [];
if (contracts.ntt.transceiver["wormhole"]) {
if (
"wormhole" in contracts.ntt.transceiver &&
contracts.ntt.transceiver["wormhole"]
) {
const transceiverTypes = [
"wormhole", // wormhole xcvr should be ix 0
...Object.keys(contracts.ntt.transceiver).filter((transceiverType) => {
Expand Down

0 comments on commit ded3294

Please sign in to comment.