Skip to content

Commit 6089313

Browse files
committed
cli: support wh transceiver pauser (evm)
1 parent e439d66 commit 6089313

File tree

4 files changed

+53
-2
lines changed

4 files changed

+53
-2
lines changed

cli/src/index.ts

+30-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export type ChainConfig = {
7171
token: string,
7272
transceivers: {
7373
threshold: number,
74-
wormhole: string,
74+
wormhole: { address: string, pauser?: string },
7575
},
7676
limits: {
7777
outbound: string,
@@ -1312,6 +1312,29 @@ async function pushDeployment<C extends Chain>(deployment: Deployment<C>, signer
13121312
}
13131313
}
13141314
}
1315+
} else if (k === "transceivers") {
1316+
// TODO: refactor this nested loop stuff into separate functions at least
1317+
// alternatively we could first recursively collect all the things
1318+
// to do into a flattened list (with entries like
1319+
// transceivers.wormhole.pauser), and have a top-level mapping of
1320+
// these entries to how they should be handled
1321+
for (const j of Object.keys(diff[k] as object)) {
1322+
if (j === "wormhole") {
1323+
for (const l of Object.keys(diff[k]![j] as object)) {
1324+
if (l === "pauser") {
1325+
const newTransceiverPauser = toUniversal(deployment.manager.chain, diff[k]![j]![l]!.push!);
1326+
txs.push(deployment.whTransceiver.setPauser(newTransceiverPauser, signer.address.address));
1327+
} else {
1328+
console.error(`Unsupported field: ${k}.${j}.${l}`);
1329+
process.exit(1);
1330+
}
1331+
}
1332+
} else {
1333+
console.error(`Unsupported field: ${k}.${j}`);
1334+
process.exit(1);
1335+
1336+
}
1337+
}
13151338
} else {
13161339
console.error(`Unsupported field: ${k}`);
13171340
process.exit(1);
@@ -1404,6 +1427,8 @@ async function pullChainConfig<N extends Network, C extends Chain>(
14041427

14051428
const version = getVersion(manager.chain, ntt);
14061429

1430+
const transceiverPauser = await ntt.getTransceiver(0).then((t) => t?.getPauser() ?? null);
1431+
14071432
const config: ChainConfig = {
14081433
version,
14091434
mode,
@@ -1413,13 +1438,16 @@ async function pullChainConfig<N extends Network, C extends Chain>(
14131438
token: addresses.token!,
14141439
transceivers: {
14151440
threshold,
1416-
wormhole: addresses.transceiver!.wormhole!,
1441+
wormhole: { address: addresses.transceiver!.wormhole! },
14171442
},
14181443
limits: {
14191444
outbound: outboundLimitDecimals,
14201445
inbound: {},
14211446
},
14221447
};
1448+
if (transceiverPauser) {
1449+
config.transceivers.wormhole.pauser = transceiverPauser.toString();
1450+
}
14231451
if (pauser) {
14241452
config.pauser = pauser.toString();
14251453
}

sdk/definitions/src/ntt.ts

+4
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,10 @@ export interface NttTransceiver<
320320

321321
getPeer<C extends Chain>(chain: C): Promise<ChainAddress<C> | null>;
322322

323+
setPauser(newPauser: AccountAddress<C>, payer?: AccountAddress<C>): AsyncGenerator<UnsignedTransaction<N, C>>;
324+
325+
getPauser(): Promise<AccountAddress<C> | null>;
326+
323327
/**
324328
* receive calls the `receive*` method on the transceiver
325329
*

sdk/evm/src/ntt.ts

+11
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,17 @@ export class EvmNttWormholeTranceiver<N extends Network, C extends EvmChains>
6767
yield this.manager.createUnsignedTx(tx, "WormholeTransceiver.registerPeer");
6868
}
6969

70+
async getPauser(): Promise<AccountAddress<C> | null> {
71+
const pauser = await this.transceiver.pauser();
72+
return new EvmAddress(pauser) as AccountAddress<C>;
73+
}
74+
75+
async *setPauser(pauser: AccountAddress<C>) {
76+
const canonicalPauser = canonicalAddress({chain: this.manager.chain, address: pauser});
77+
const tx = await this.transceiver.transferPauserCapability.populateTransaction(canonicalPauser);
78+
yield this.manager.createUnsignedTx(tx, "WormholeTransceiver.setPauser");
79+
}
80+
7081
async getPeer<C extends Chain>(chain: C): Promise<ChainAddress<C> | null> {
7182
const peer = await this.transceiver.getWormholePeer(toChainId(chain));
7283
const peerAddress = Buffer.from(peer.substring(2), 'hex');

solana/ts/sdk/ntt.ts

+8
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ export class SolanaNttWormholeTransceiver<N extends Network, C extends SolanaCha
5353
readonly address: PublicKey
5454
) {}
5555

56+
async getPauser(): Promise<AccountAddress<C> | null> {
57+
return null
58+
}
59+
60+
async *setPauser(_newPauser: AccountAddress<C>, _payer: AccountAddress<C>) {
61+
throw new Error("Method not implemented.");
62+
}
63+
5664
async *receive(_attestation: WormholeNttTransceiver.VAA) {
5765
// TODO: this is implemented below (in the transceiver code). it could get
5866
// tricky in general with multiple transceivers, as they might return an

0 commit comments

Comments
 (0)