From e5afc6b89b5d5eb889c9e976ae7bf32062e32c0c Mon Sep 17 00:00:00 2001 From: Choco Date: Mon, 31 Jul 2023 20:12:08 +1000 Subject: [PATCH] Fix type errors --- .../src/services/grandmaster-manager/index.ts | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/frontend/src/services/grandmaster-manager/index.ts b/frontend/src/services/grandmaster-manager/index.ts index a7f21a5..e4c8254 100644 --- a/frontend/src/services/grandmaster-manager/index.ts +++ b/frontend/src/services/grandmaster-manager/index.ts @@ -1,5 +1,6 @@ -import Web3 from "web3"; -import { ManagerError } from "@/services/grandmaster-manager/errors"; +import Web3 from 'web3'; + +import { ManagerError } from '@/services/grandmaster-manager/errors'; interface AccountDetails { accountAddress: string; @@ -13,17 +14,23 @@ interface CandidateDetails { address: string; delegation: number; rank: number; - status: 'MASTERNODE' | 'PROPOSED' | 'SLASHED' + status: 'MASTERNODE' | 'PROPOSED' | 'SLASHED'; } export class GrandMasterManager { - private web3Client; + private _web3Client: any; + public get web3Client() { + return this._web3Client; + } + public set web3Client(value) { + this._web3Client = value; + } constructor() { const win = window as any; this.web3Client = new Web3(win.xdc ? win.xdc : win.ethereum); } - + /** * * This method will detect XDC-Pay and verify if customer has alraedy loggin. * @returns Account details will be returned if all good, otherwise, relevant error message and type will be returned such as WALLET_NOT_LOGIN @@ -36,37 +43,37 @@ export class GrandMasterManager { networkId: chainId, denom: "hxdc", rpcAddress: "https://devnetstats.apothem.network/subnet" - } + }; } - + /** * Remove a masternode from the manager view list * @param address The master node to be removed * @returns If transaction is successful, return. Otherwise, an error details will be returned */ - async removeMasterNode(address: string): Promise { + async removeMasterNode(_address: string): Promise { return true; } - + /** * Propose to add a new masternode for being a mining candidate from the next epoch * @param address The master node to be added * @returns If transaction is successful, return. Otherwise, an error details will be returned */ - async addNewMasterNode(address: string): Promise { + async addNewMasterNode(_address: string): Promise { return true; } - + /** * Change the voting/ranking power/order of a particular masternode. * @param address The targeted masternode * @param value The xdc value that will be applied to the targeted address. Postive number means increase power, negative means decrease the power * @returns If transaction is successful, return. Otherwise, an error details will be returned */ - async changeVote(address: string, value: number): Promise { + async changeVote(_address: string, _value: number): Promise { return true; } - + /** * A event listener on wallet account. If user switch to a different account, this method will update notify the provided handler * @param changeHandler The handler function to process when the accounts changed. The provided value will be the new wallet address. @@ -76,7 +83,7 @@ export class GrandMasterManager { // TODO: 1. Handle the account change via accountsChanged // TODO: 2. Handle the chain change via chainChanged. This could happen if switch from testnet to mainnet etc. } - + /** * A method to return subnet candidates and its status. * @returns The address and its current status and stake.