LiskArchive / lisk-sdk

🔩 Lisk software development kit
https://lisk.com
Apache License 2.0
2.72k stars 454 forks source link

Implement RecoveryEndpoint class #9182

Open ishantiw opened 9 months ago

ishantiw commented 9 months ago

Description

Implement RecoveryEndpoint class.

class RecoveryEndpoint extends BasePluginEndpoint {
    private _recoveryManager: SidechainRecoveryManager | MainchainRecoveryManager;

    load(recoveryManager) {
        this._recoveryManager = recoveryManager;
    }

    public addQueryKey(chainID, queryKey) {
        const sidechainClient = this._recoveryManager._sidechainClientMap.get(chainID);
        if (sidechainClient) {
            sidechainClient.enableStateRecovery();
            sidechainClient.addQueryKey(queryKey);
        }
    }

    public addChainForRecovery(chainID, connectionURL) {
        const sidechainClient = this._recoveryManager._sidechainClientMap.get(chainID);
        if (!sidechainClient) {
            this._recoveryManager.addSideChainClient(chainID, connectionURL);
        }
    }

      // Delete client for which recovery is no longer needed
      public deleteChainForRecovery(chainID) {}

       // Delete queryKey for which recovery is no longer needed
      public deleteQueryKey(chainID, queryKey) {}

      // User can get moduleName and subStorePrefix from getMetadata endpoint and key is what the user wants to track
      public createQueryKey(moduleName, subStorePrefix, key) {}: returns queryKey string

    public triggerStateRecovery(chainID, queryKey, txFee) {
        this._recoveryManager.triggerStateRecovery(chainID, queryKey);
            // update all the inclusion proofs if the transaction was included successfully
    }
    public triggerMessageRecovery(chainID, txFee): returns { txID, txJSON }
    public triggerInitStateRecovery(chainID, queryKey, txFee): returns { txID, txJSON }

    public triggerInitMessageRecovery(chainID, txFee): returns { txID, txJSON }

      // Enable signing of transaction
      public authorize(password)

      // It will send liveness termination command to mainchain
      public terminateChain(chainID)
}

Acceptance Criteria