Skip to content

Commit

Permalink
cli: set up special relaying EVM->Solana (#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
kcsongor authored Oct 22, 2024
1 parent 5d6ca4d commit 4148bae
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 14 deletions.
47 changes: 33 additions & 14 deletions cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,8 +682,12 @@ yargs(hideBin(process.argv))
const tx = (await ntt.getTransceiver(0) as EvmNttWormholeTranceiver<Network, EvmChains>).setIsEvmChain(evmChain, true)
await signSendWait(ctx, tx, signer.signer)
}
for (const relaying of missingConfig.standardRelaying) {
const tx = (await ntt.getTransceiver(0) as EvmNttWormholeTranceiver<Network, EvmChains>).setIsWormholeRelayingEnabled(relaying, true)
for (const relayingTarget of missingConfig.standardRelaying) {
const tx = (await ntt.getTransceiver(0) as EvmNttWormholeTranceiver<Network, EvmChains>).setIsWormholeRelayingEnabled(relayingTarget, true)
await signSendWait(ctx, tx, signer.signer)
}
for (const relayingTarget of missingConfig.specialRelaying) {
const tx = (await ntt.getTransceiver(0) as EvmNttWormholeTranceiver<Network, EvmChains>).setIsSpecialRelayingEnabled(relayingTarget, true)
await signSendWait(ctx, tx, signer.signer)
}
if (missingConfig.solanaWormholeTransceiver) {
Expand Down Expand Up @@ -800,8 +804,11 @@ yargs(hideBin(process.argv))
for (const evmChain of missingConfig.evmChains) {
console.error(` ${evmChain} needs to be configured as an EVM chain`);
}
for (const relaying of missingConfig.standardRelaying) {
console.warn(` No standard relaying: ${relaying}`);
for (const relayingTarget of missingConfig.standardRelaying) {
console.warn(` No standard relaying to ${relayingTarget}`);
}
for (const relayingTarget of missingConfig.specialRelaying) {
console.warn(` No special relaying to ${relayingTarget}`);
}
if (missingConfig.solanaWormholeTransceiver) {
console.error(" Missing Solana wormhole transceiver");
Expand Down Expand Up @@ -896,6 +903,7 @@ type MissingImplicitConfig = {
transceiverPeers: ChainAddress<Chain>[];
evmChains: Chain[];
standardRelaying: Chain[];
specialRelaying: Chain[];
solanaWormholeTransceiver: boolean;
solanaUpdateLUT: boolean;
}
Expand Down Expand Up @@ -1436,6 +1444,7 @@ async function missingConfigs(
transceiverPeers: [],
evmChains: [],
standardRelaying: [],
specialRelaying: [],
solanaWormholeTransceiver: false,
solanaUpdateLUT: false,
};
Expand Down Expand Up @@ -1490,17 +1499,27 @@ async function missingConfigs(

if (chainToPlatform(fromChain) === "Evm") {
const toIsEvm = chainToPlatform(toChain) === "Evm";
const toIsSolana = chainToPlatform(toChain) === "Solana";
const whTransceiver = await from.ntt.getTransceiver(0) as EvmNttWormholeTranceiver<Network, EvmChains>;

if (toIsEvm) {
const remoteToEvm = await whTransceiver.isEvmChain(toChain);
if (!remoteToEvm) {
count++;
missing.evmChains.push(toChain);
}

const remoteToEvm = await (await from.ntt.getTransceiver(0) as EvmNttWormholeTranceiver<Network, EvmChains>).isEvmChain(toChain);
if (toIsEvm && !remoteToEvm) {
count++;
missing.evmChains.push(toChain);
}

const standardRelaying = await (await from.ntt.getTransceiver(0) as EvmNttWormholeTranceiver<Network, EvmChains>).isWormholeRelayingEnabled(toChain);
if (toIsEvm && !standardRelaying) {
count++;
missing.standardRelaying.push(toChain);
const standardRelaying = await whTransceiver.isWormholeRelayingEnabled(toChain);
if (!standardRelaying) {
count++;
missing.standardRelaying.push(toChain);
}
} else if (toIsSolana) {
const specialRelaying = await whTransceiver.isSpecialRelayingEnabled(toChain);
if (!specialRelaying) {
count++;
missing.specialRelaying.push(toChain);
}
}
}

Expand Down
11 changes: 11 additions & 0 deletions evm/ts/src/ntt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ export class EvmNttWormholeTranceiver<N extends Network, C extends EvmChains>
toChainId(destChain)
);
}

async *setIsSpecialRelayingEnabled(destChain: Chain, enabled: boolean) {
const tx = await this.transceiver.setIsSpecialRelayingEnabled.populateTransaction(
toChainId(destChain),
enabled
);
yield this.manager.createUnsignedTx(
tx,
"WormholeTransceiver.setSpecialRelayingEnabled"
);
}
}

export class EvmNtt<N extends Network, C extends EvmChains>
Expand Down

0 comments on commit 4148bae

Please sign in to comment.