npm package: @manul.parihar/test-package
Description: Reports updated balance to Balance Report Smart Contract
Latest version: 5.2.2

# @blockswaplab/stakehouse-sdk
Stakehouse SDK is a NPM Package which can be used by ETH2 validators to interact with the Balance Reporter Smart Contract, retreive finalised epoch report from beacon chain, authenticate the finalised epoch report and update their increased ETH balance.  
  
## Installation
To install the package use the comamnd `npm i @manul.parihar/test-package`
  
## Using test-package
Import the package as shown below
```
const { getFinalisedEpochReport, authenticateReport, reportBalanceIncrease } = require("@manul.parihar/test-package");
```  

## getFinalisedEpochReport function
This function accepts a beacon node URL and BLS Public Key to return the most recent finalised epoch report. This report can then be authenticated using the authenticateReport function and the resulting output can be fed to the reportBalanceIncrease to submit updated ETH balance to the Balance Reporter Smart Contract. 

### Input Parameter
beaconNodeURL : URL of the beacon chain node,  
blsPublicKey : Validator's BLS Public key  

### Using getFinalisedEpochReport function
```
getFinalisedEpochReport(beaconNodeURL, blsPublicKey);
```

### Return Parameter
```
// This is what a finalised epoch report looks like
{  
  "blsPublicKey":"a97f0308ffffd1d253f35ef4d8309059b7d89fd53...",  
  "withdrawalCredentials":"010000000000000000000000f847b446...",  
  "slashed":false,  
  "activeBalance":"32042871296",  
  "effectiveBalance":"32000000000",  
  "exitEpoch":"18446744073709551615",  
  "activationEpoch":"63601",  
  "withdrawalEpoch":"18446744073709551615",  
  "currentCheckpointEpoch":66805  
}
```
  
  
## authenticateReport function
This function accepts a finalised beacon chain report from the user and returns Deposit Router response data if the authentication was successful, otherwise an error statement is returned.  

### Input Parameter
finalisedBeaconChainReport : 
```
// This is just a sample Finalised Beacon Chain Report
{  
  "blsPublicKey":"a97f0308ffffd1d253f35ef4d8309059b7d89fd53...",  
  "withdrawalCredentials":"010000000000000000000000f847b446...",  
  "slashed":false,  
  "activeBalance":"32042871296",  
  "effectiveBalance":"32000000000",  
  "exitEpoch":"18446744073709551615",  
  "activationEpoch":"63601",  
  "withdrawalEpoch":"18446744073709551615",  
  "currentCheckpointEpoch":66805  
}
```

### Using authenticateReport function
```
authenticateReport(finalisedBeaconChainReport);
```

### Return Parameter
If the authentication was successful, then a Deposit Router response is returned. Here is how it looks like : 
```
{
  report: {
    blsPublicKey: 'a97f0308ffffd1d253f35ef4d8309059b7d89f...',
    withdrawalCredentials: '010000000000000000000000f847b...',
    slashed: false,
    activeBalance: '32042855400',
    effectiveBalance: '32000000000',
    exitEpoch: '18446744073709551615',
    activationEpoch: '63601',
    withdrawalEpoch: '18446744073709551615',
    currentCheckpointEpoch: 66804
  },
  deadline: 6199503,
  v: 27,
  r: '88bf72df9e2b8e4588e26c4a50f4bfaf3746a57b52f50ee61f61...',
  s: '129474d568b986e7747b46e63438ab181c861d72831b3a674cbb...'
}
```
Otherwise, an error response is returned.
  

## reportBalanceIncrease function
This function allows validators to report their updated ETH balance to the Deposit Router  

### Input Parameters
signer : 
```
const provider = new ethers.providers.InfuraProvider("goerli", {
    projectId: INFURA_PROJECT_ID,
    projectSecret: INFURA_PROJECT_SECRET
});
const signer = new ethers.Wallet(PRIV_KEY, provider);
```
stakeHouseAddr : Address of the Stakehouse  
balanceReport : Deposit Router response obtained from the nodejs-balane-reporter 

### Using reportBalanceIncrease function
```
reportBalanceIncrease(signer, stakeHouseAddr, balanceReport);
```

### Return Parameter
Returns the transaction data