This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Channel Terminated Message cross chain command (#7696)
### What was the problem? This PR resolves #7656 ### How was it solved? Created a new `BaseCCChannelTerminatedCommand` inside `base/cc_commands` ### How was it tested? Unit Test Updated accordingly
- Loading branch information
Showing
6 changed files
with
72 additions
and
140 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
framework/src/modules/interoperability/base_cc_commands/channel_terminated.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright © 2022 Lisk Foundation | ||
* | ||
* See the LICENSE file at the top-level directory of this distribution | ||
* for licensing information. | ||
* | ||
* Unless otherwise agreed in a custom licensing agreement with the Lisk Foundation, | ||
* no part of this software, including this file, may be copied, modified, | ||
* propagated, or distributed except according to the terms contained in the | ||
* LICENSE file. | ||
* | ||
* Removal or modification of this copyright notice is prohibited. | ||
*/ | ||
|
||
import { BaseInteroperabilityCCCommand } from '../base_interoperability_cc_commands'; | ||
import { channelTerminatedCCMParamsSchema } from '../schemas'; | ||
import { CROSS_CHAIN_COMMAND_NAME_CHANNEL_TERMINATED } from '../constants'; | ||
import { CCCommandExecuteContext } from '../types'; | ||
|
||
// https://github.com/LiskHQ/lips/blob/main/proposals/lip-0049.md#channel-terminated-message-1 | ||
export abstract class BaseCCChannelTerminatedCommand extends BaseInteroperabilityCCCommand { | ||
public schema = channelTerminatedCCMParamsSchema; | ||
|
||
public get name(): string { | ||
return CROSS_CHAIN_COMMAND_NAME_CHANNEL_TERMINATED; | ||
} | ||
|
||
public async execute(context: CCCommandExecuteContext): Promise<void> { | ||
if (!context.ccm) { | ||
throw new Error( | ||
`CCM to execute cross chain command '${CROSS_CHAIN_COMMAND_NAME_CHANNEL_TERMINATED}' is missing.`, | ||
); | ||
} | ||
const interoperabilityInternalMethod = this.getInteroperabilityInternalMethod(context); | ||
if (await interoperabilityInternalMethod.isLive(context.ccm.sendingChainID, Date.now())) { | ||
await interoperabilityInternalMethod.createTerminatedStateAccount( | ||
context, | ||
context.ccm.sendingChainID, | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 0 additions & 84 deletions
84
...ework/test/unit/modules/interoperability/sidechain/cc_commands/channel_terminated.spec.ts
This file was deleted.
Oops, something went wrong.