@wireio/stake 1.0.1 → 1.1.0

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.js CHANGED
@@ -35392,18 +35392,22 @@ class OPPClient {
35392
35392
  }
35393
35393
  getMessages(address) {
35394
35394
  return __async$2(this, null, function* () {
35395
- const oppMessageFilter = this.contract.OPP.filters.OPPMessage();
35396
- const events = yield this.contract.OPP.queryFilter(oppMessageFilter, 0, "latest");
35397
- const allAssertions = [];
35398
- for (const event of events) {
35399
- const assertions = yield this.extractAssertionsFromEvent(event);
35400
- allAssertions.push(...assertions);
35395
+ try {
35396
+ const oppMessageFilter = this.contract.OPP.filters.OPPMessage();
35397
+ const events = yield this.contract.OPP.queryFilter(oppMessageFilter, 0, "latest");
35398
+ const allAssertions = [];
35399
+ for (const event of events) {
35400
+ const assertions = yield this.extractAssertionsFromEvent(event);
35401
+ allAssertions.push(...assertions);
35402
+ }
35403
+ const normalized = address ? address.toLowerCase() : null;
35404
+ const filtered = allAssertions.filter(
35405
+ (a) => a.from && a.from.toLowerCase() === normalized || a.to && a.to.toLowerCase() === normalized
35406
+ );
35407
+ return filtered.reverse();
35408
+ } catch (error) {
35409
+ return [];
35401
35410
  }
35402
- const normalized = address ? address.toLowerCase() : null;
35403
- const filtered = allAssertions.filter(
35404
- (a) => a.from && a.from.toLowerCase() === normalized || a.to && a.to.toLowerCase() === normalized
35405
- );
35406
- return filtered.reverse();
35407
35411
  });
35408
35412
  }
35409
35413
  extractAssertionsFromEvent(event) {
@@ -35666,7 +35670,12 @@ class ReceiptClient {
35666
35670
  }
35667
35671
  stakeReceipts(address) {
35668
35672
  return __async$1(this, null, function* () {
35669
- return this.fetchPreLaunchReceipts(address, ReceiptNFTKind.STAKE);
35673
+ try {
35674
+ const receipts = yield this.fetchPreLaunchReceipts(address, ReceiptNFTKind.STAKE);
35675
+ return receipts;
35676
+ } catch (err) {
35677
+ return [];
35678
+ }
35670
35679
  });
35671
35680
  }
35672
35681
  pretokenReceipts(address) {
@@ -35842,72 +35851,77 @@ class EthereumStakingClient {
35842
35851
  getPortfolio() {
35843
35852
  return __async(this, null, function* () {
35844
35853
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
35845
- if (!this.signer) return Promise.resolve(null);
35846
- const walletAddress = yield this.signer.getAddress();
35847
- const nativeBalance = yield this.provider.getBalance(walletAddress);
35848
- const nativeDecimals = (_c = (_b = (_a = this.network) == null ? void 0 : _a.nativeCurrency) == null ? void 0 : _b.decimals) != null ? _c : 18;
35849
- const nativeSymbol = (_f = (_e = (_d = this.network) == null ? void 0 : _d.nativeCurrency) == null ? void 0 : _e.symbol) != null ? _f : "ETH";
35850
- const liqBalance = yield this.contract.LiqEthToken.balanceOf(walletAddress);
35851
- const liqSymbol = "Liq" + ((_i = (_h = (_g = this.network) == null ? void 0 : _g.nativeCurrency) == null ? void 0 : _h.symbol) != null ? _i : "ETH");
35852
- let stakeReceipts = yield this.receiptClient.stakeReceipts(walletAddress);
35853
- let stakeBalanceBN = ethers.BigNumber.from(0);
35854
- for (let r of stakeReceipts) {
35855
- stakeBalanceBN = stakeBalanceBN.add(ethers.BigNumber.from(r.receipt.principal.amount));
35856
- }
35857
- let stakeSharesBN = ethers.BigNumber.from(0);
35858
- for (let r of stakeReceipts) {
35859
- stakeSharesBN = stakeSharesBN.add(ethers.BigNumber.from(r.receipt.shares.amount));
35860
- }
35861
- const wireBalance = yield this.contract.Pretoken.balanceOf(walletAddress);
35862
- let currentIndex = BigInt(0);
35863
- let totalShares = BigInt(0);
35864
- let userShares = BigInt(0);
35865
- const indexScale = BigInt(1e27);
35866
35854
  try {
35867
- const [indexBn, totalSharesBn] = yield Promise.all([
35868
- this.contract.Depositor.index().catch(() => ethers.BigNumber.from(0)),
35869
- this.contract.Depositor.totalShares().catch(() => ethers.BigNumber.from(0))
35870
- ]);
35871
- const userSharesBn = stakeSharesBN;
35872
- currentIndex = BigInt(indexBn.toString());
35873
- totalShares = BigInt(totalSharesBn.toString());
35874
- userShares = BigInt(userSharesBn.toString());
35875
- } catch (e) {
35855
+ if (!this.signer) return Promise.resolve(null);
35856
+ const walletAddress = yield this.signer.getAddress();
35857
+ const nativeBalance = yield this.provider.getBalance(walletAddress);
35858
+ const nativeDecimals = (_c = (_b = (_a = this.network) == null ? void 0 : _a.nativeCurrency) == null ? void 0 : _b.decimals) != null ? _c : 18;
35859
+ const nativeSymbol = (_f = (_e = (_d = this.network) == null ? void 0 : _d.nativeCurrency) == null ? void 0 : _e.symbol) != null ? _f : "ETH";
35860
+ const liqBalance = yield this.contract.LiqEthToken.balanceOf(walletAddress);
35861
+ const liqSymbol = "Liq" + ((_i = (_h = (_g = this.network) == null ? void 0 : _g.nativeCurrency) == null ? void 0 : _h.symbol) != null ? _i : "ETH");
35862
+ let stakeReceipts = yield this.receiptClient.stakeReceipts(walletAddress);
35863
+ let stakeBalanceBN = ethers.BigNumber.from(0);
35864
+ for (let r of stakeReceipts) {
35865
+ stakeBalanceBN = stakeBalanceBN.add(ethers.BigNumber.from(r.receipt.principal.amount));
35866
+ }
35867
+ let stakeSharesBN = ethers.BigNumber.from(0);
35868
+ for (let r of stakeReceipts) {
35869
+ stakeSharesBN = stakeSharesBN.add(ethers.BigNumber.from(r.receipt.shares.amount));
35870
+ }
35871
+ const wireBalance = yield this.contract.Pretoken.balanceOf(walletAddress);
35872
+ let currentIndex = BigInt(0);
35873
+ let totalShares = BigInt(0);
35874
+ let userShares = BigInt(0);
35875
+ const indexScale = BigInt(1e27);
35876
+ try {
35877
+ const [indexBn, totalSharesBn] = yield Promise.all([
35878
+ this.contract.Depositor.index().catch(() => ethers.BigNumber.from(0)),
35879
+ this.contract.Depositor.totalShares().catch(() => ethers.BigNumber.from(0))
35880
+ ]);
35881
+ const userSharesBn = stakeSharesBN;
35882
+ currentIndex = BigInt(indexBn.toString());
35883
+ totalShares = BigInt(totalSharesBn.toString());
35884
+ userShares = BigInt(userSharesBn.toString());
35885
+ } catch (error) {
35886
+ console.log("Error fetching staking index/shares:", error);
35887
+ }
35888
+ let estimatedClaim = BigInt(0);
35889
+ let estimatedYield = BigInt(0);
35890
+ const portfolio = {
35891
+ native: {
35892
+ amount: nativeBalance.toBigInt(),
35893
+ decimals: nativeDecimals,
35894
+ symbol: nativeSymbol
35895
+ },
35896
+ liq: {
35897
+ amount: liqBalance.toBigInt(),
35898
+ decimals: nativeDecimals,
35899
+ symbol: liqSymbol
35900
+ },
35901
+ staked: {
35902
+ amount: stakeBalanceBN.toBigInt(),
35903
+ decimals: nativeDecimals,
35904
+ symbol: liqSymbol
35905
+ },
35906
+ wire: {
35907
+ amount: wireBalance.toBigInt(),
35908
+ decimals: 18,
35909
+ symbol: "$WIRE"
35910
+ },
35911
+ yield: {
35912
+ currentIndex,
35913
+ indexScale,
35914
+ totalShares,
35915
+ userShares,
35916
+ estimatedClaim,
35917
+ estimatedYield
35918
+ },
35919
+ chainID: this.network.chainId
35920
+ };
35921
+ return portfolio;
35922
+ } catch (error) {
35923
+ throw error;
35876
35924
  }
35877
- let estimatedClaim = BigInt(0);
35878
- let estimatedYield = BigInt(0);
35879
- const portfolio = {
35880
- native: {
35881
- amount: nativeBalance.toBigInt(),
35882
- decimals: nativeDecimals,
35883
- symbol: nativeSymbol
35884
- },
35885
- liq: {
35886
- amount: liqBalance.toBigInt(),
35887
- decimals: nativeDecimals,
35888
- symbol: liqSymbol
35889
- },
35890
- staked: {
35891
- amount: stakeBalanceBN.toBigInt(),
35892
- decimals: nativeDecimals,
35893
- symbol: liqSymbol
35894
- },
35895
- wire: {
35896
- amount: wireBalance.toBigInt(),
35897
- decimals: 18,
35898
- symbol: "$WIRE"
35899
- },
35900
- yield: {
35901
- currentIndex,
35902
- indexScale,
35903
- totalShares,
35904
- userShares,
35905
- estimatedClaim,
35906
- estimatedYield
35907
- },
35908
- chainID: this.network.chainId
35909
- };
35910
- return portfolio;
35911
35925
  });
35912
35926
  }
35913
35927
  fetchPrelaunchReceipts(address) {
@@ -36052,6 +36066,7 @@ class Staker {
36052
36066
  this.clients.set(cfg.network.chainId, new SolanaStakingClient(cfg));
36053
36067
  break;
36054
36068
  case core.EvmChainID.Ethereum:
36069
+ case core.EvmChainID.Hoodi:
36055
36070
  this.clients.set(cfg.network.chainId, new EthereumStakingClient(cfg));
36056
36071
  break;
36057
36072
  default: