LiskArchive/lisk-sdk

Implement RecoveryEndpoint class

ishantiw opened this issue · 0 comments

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)
}
  • Make sure all the endpoints return data in JSON format

Acceptance Criteria

  • Should have unit tests for all the endpoints