@wireio/stake 2.2.1 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/stake.m.js CHANGED
@@ -41366,6 +41366,41 @@ class ReceiptClient {
41366
41366
  }
41367
41367
  }
41368
41368
 
41369
+ class ValidatorClient {
41370
+ get contract() {
41371
+ return this.contractService.contract;
41372
+ }
41373
+ constructor(contract) {
41374
+ this.contractService = contract;
41375
+ }
41376
+ async validatorDepositAndLockBond() {
41377
+ const amountWei = ethers.utils.parseEther("32");
41378
+ try {
41379
+ await this.contract.DepositManager.callStatic.validatorDepositAndLockBond({ value: amountWei });
41380
+ } catch (err) {
41381
+ let errorObj = formatContractErrors(err);
41382
+ throw new Error(errorObj.name ?? errorObj.raw);
41383
+ }
41384
+ const tx = await this.contract.DepositManager.validatorDepositAndLockBond({ value: amountWei });
41385
+ const receipt = await tx.wait(1);
41386
+ let staked;
41387
+ const ev = receipt.events?.find((e) => e.event === "Staked");
41388
+ if (ev && ev.args) {
41389
+ const { sender, amount, shares } = ev.args;
41390
+ staked = {
41391
+ sender,
41392
+ amount: BigNumber.from(amount),
41393
+ shares: BigNumber.from(shares)
41394
+ };
41395
+ }
41396
+ return {
41397
+ txHash: tx.hash,
41398
+ receipt,
41399
+ staked
41400
+ };
41401
+ }
41402
+ }
41403
+
41369
41404
  const INITIAL_TRANCHE_SUPPLY = 35e3;
41370
41405
  class EthereumStakingClient {
41371
41406
  constructor(config) {
@@ -41388,6 +41423,7 @@ class EthereumStakingClient {
41388
41423
  this.stakeClient = new StakeClient(this.contractService);
41389
41424
  this.oppClient = new OPPClient(this.contractService);
41390
41425
  this.receiptClient = new ReceiptClient(this.contractService);
41426
+ this.validatorClient = new ValidatorClient(this.contractService);
41391
41427
  } catch (error) {
41392
41428
  throw error;
41393
41429
  }
@@ -41444,6 +41480,11 @@ class EthereumStakingClient {
41444
41480
  let result = await this.pretokenClient.purchasePretokensWithLiqETH(amount, buyer);
41445
41481
  return result && result.txHash ? result.txHash : "Error - no resulting txHash";
41446
41482
  }
41483
+ async validatorDeposit() {
41484
+ this.ensureUser();
41485
+ let result = await this.validatorClient.validatorDepositAndLockBond();
41486
+ return result && result.txHash ? result.txHash : "Error - no resulting txHash";
41487
+ }
41447
41488
  async getPortfolio() {
41448
41489
  try {
41449
41490
  if (!this.signer) return Promise.resolve(null);