fix: warp apply throws if submitter transactionReceipts is undefined (#4501)

### Description
Fix to add conditional for `transactionReceipts` so that the yaml is
only parsed when it is not `undefined`.

### Drive-by changes
E2e tests for warp apply strategy

### Backward compatibility
Yes

### Testing
Manual/Unit Tests
pull/4502/head
Lee 2 months ago committed by GitHub
parent 739af9a34b
commit 509213dcfc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      typescript/cli/examples/submit/strategy/json-rpc-chain-strategy.yaml
  2. 11
      typescript/cli/src/deploy/warp.ts
  3. 25
      typescript/cli/src/tests/commands/helpers.ts
  4. 2
      typescript/cli/src/tests/commands/warp.ts
  5. 60
      typescript/cli/src/tests/warp-apply.e2e-test.ts
  6. 6
      typescript/sdk/src/providers/transactions/submitter/ethersV5/EV5GnosisSafeTxSubmitter.ts

@ -1,3 +1,6 @@
anvil1:
anvil2:
submitter:
type: jsonRpc
anvil3:
submitter:
type: jsonRpc

@ -497,12 +497,10 @@ export async function runWarpRouteApply(
});
const transactionReceipts = await submitter.submit(...transactions);
if (transactionReceipts && transactionReceipts.length > 0) {
return logGreen(
`✅ Warp config update successfully submitted with ${submitter.txSubmitterType} on ${chain}:\n\n`,
indentYamlOrJson(yamlStringify(transactionReceipts, null, 2), 4),
);
}
return logGreen(
`✅ Warp config update successfully submitted with ${submitter.txSubmitterType} on ${chain}:\n\n`,
indentYamlOrJson(yamlStringify(transactionReceipts, null, 2), 4),
);
} catch (e) {
logRed(`Warp config on ${chain} failed to update.`, e);
}
@ -677,7 +675,6 @@ async function enrollRemoteRouters(
strategyUrl,
});
const transactionReceipts = await submitter.submit(...mutatedConfigTxs);
return logGreen(
`✅ Router enrollment update successfully submitted with ${submitter.txSubmitterType} on ${chain}:\n\n`,
indentYamlOrJson(yamlStringify(transactionReceipts, null, 2), 4),

@ -64,13 +64,22 @@ export async function updateOwner(
/**
* Extends the Warp route deployment with a new warp config
*/
export async function extendWarpConfig(
chain: string,
chainToExtend: string,
extendedConfig: TokenRouterConfig,
warpCorePath: string,
warpDeployPath: string,
): Promise<string> {
export async function extendWarpConfig(params: {
chain: string;
chainToExtend: string;
extendedConfig: TokenRouterConfig;
warpCorePath: string;
warpDeployPath: string;
strategyUrl?: string;
}): Promise<string> {
const {
chain,
chainToExtend,
extendedConfig,
warpCorePath,
warpDeployPath,
strategyUrl,
} = params;
const warpDeployConfig = await readWarpConfig(
chain,
warpCorePath,
@ -78,7 +87,7 @@ export async function extendWarpConfig(
);
warpDeployConfig[chainToExtend] = extendedConfig;
writeYamlOrJson(warpDeployPath, warpDeployConfig);
await hyperlaneWarpApply(warpDeployPath, warpCorePath);
await hyperlaneWarpApply(warpDeployPath, warpCorePath, strategyUrl);
return warpDeployPath;
}

@ -26,6 +26,7 @@ export async function hyperlaneWarpDeploy(warpCorePath: string) {
export async function hyperlaneWarpApply(
warpDeployPath: string,
warpCorePath: string,
strategyUrl = '',
) {
return $`yarn workspace @hyperlane-xyz/cli run hyperlane warp apply \
--registry ${REGISTRY_PATH} \
@ -33,6 +34,7 @@ export async function hyperlaneWarpApply(
--warp ${warpCorePath} \
--key ${ANVIL_KEY} \
--verbosity debug \
--strategy ${strategyUrl} \
--yes`;
}

@ -108,14 +108,68 @@ describe('WarpApply e2e tests', async function () {
type: TokenType.native,
};
await extendWarpConfig(
await extendWarpConfig({
chain: CHAIN_NAME_2,
chainToExtend: CHAIN_NAME_3,
extendedConfig: config,
warpCorePath: WARP_CORE_CONFIG_PATH_2,
warpDeployPath: warpConfigPath,
});
const COMBINED_WARP_CORE_CONFIG_PATH = `${REGISTRY_PATH}/deployments/warp_routes/ETH/anvil2-anvil3-config.yaml`;
// Check that chain2 is enrolled in chain1
const updatedWarpDeployConfig1 = await readWarpConfig(
CHAIN_NAME_2,
COMBINED_WARP_CORE_CONFIG_PATH,
warpConfigPath,
);
const chain2Id = await getChainId(CHAIN_NAME_3, ANVIL_KEY);
const remoteRouterKeys1 = Object.keys(
updatedWarpDeployConfig1[CHAIN_NAME_2].remoteRouters!,
);
expect(remoteRouterKeys1).to.include(chain2Id);
// Check that chain1 is enrolled in chain2
const updatedWarpDeployConfig2 = await readWarpConfig(
CHAIN_NAME_3,
config,
WARP_CORE_CONFIG_PATH_2,
COMBINED_WARP_CORE_CONFIG_PATH,
warpConfigPath,
);
const chain1Id = await getChainId(CHAIN_NAME_2, ANVIL_KEY);
const remoteRouterKeys2 = Object.keys(
updatedWarpDeployConfig2[CHAIN_NAME_3].remoteRouters!,
);
expect(remoteRouterKeys2).to.include(chain1Id);
});
it('should extend an existing warp route with json strategy', async () => {
// Read existing config into a file
const warpConfigPath = `${TEMP_PATH}/warp-route-deployment-2.yaml`;
await readWarpConfig(CHAIN_NAME_2, WARP_CORE_CONFIG_PATH_2, warpConfigPath);
// Extend with new config
const config: TokenRouterConfig = {
decimals: 18,
mailbox: chain2Addresses!.mailbox,
name: 'Ether',
owner: new Wallet(ANVIL_KEY).address,
symbol: 'ETH',
totalSupply: 0,
type: TokenType.native,
};
await extendWarpConfig({
chain: CHAIN_NAME_2,
chainToExtend: CHAIN_NAME_3,
extendedConfig: config,
warpCorePath: WARP_CORE_CONFIG_PATH_2,
warpDeployPath: warpConfigPath,
strategyUrl: `${EXAMPLES_PATH}/submit/strategy/json-rpc-chain-strategy.yaml`,
});
const COMBINED_WARP_CORE_CONFIG_PATH = `${REGISTRY_PATH}/deployments/warp_routes/ETH/anvil2-anvil3-config.yaml`;
// Check that chain2 is enrolled in chain1

@ -62,7 +62,7 @@ export class EV5GnosisSafeTxSubmitter implements EV5TxSubmitterInterface {
);
}
public async submit(...txs: PopulatedTransactions): Promise<void> {
public async submit(...txs: PopulatedTransactions): Promise<any[]> {
const nextNonce: number = await this.safeService.getNextNonce(
this.props.safeAddress,
);
@ -94,12 +94,14 @@ export class EV5GnosisSafeTxSubmitter implements EV5TxSubmitterInterface {
`Submitting transaction proposal to ${this.props.safeAddress} on ${this.props.chain}: ${safeTxHash}`,
);
return this.safeService.proposeTransaction({
const transactionReceipts = await this.safeService.proposeTransaction({
safeAddress: this.props.safeAddress,
safeTransactionData,
safeTxHash,
senderAddress,
senderSignature,
});
return transactionReceipts ?? [];
}
}

Loading…
Cancel
Save