@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.
@@ -34920,18 +34920,22 @@ class OPPClient {
34920
34920
  };
34921
34921
  }
34922
34922
  async getMessages(address) {
34923
- const oppMessageFilter = this.contract.OPP.filters.OPPMessage();
34924
- const events = await this.contract.OPP.queryFilter(oppMessageFilter, 0, "latest");
34925
- const allAssertions = [];
34926
- for (const event of events) {
34927
- const assertions = await this.extractAssertionsFromEvent(event);
34928
- allAssertions.push(...assertions);
34923
+ try {
34924
+ const oppMessageFilter = this.contract.OPP.filters.OPPMessage();
34925
+ const events = await this.contract.OPP.queryFilter(oppMessageFilter, 0, "latest");
34926
+ const allAssertions = [];
34927
+ for (const event of events) {
34928
+ const assertions = await this.extractAssertionsFromEvent(event);
34929
+ allAssertions.push(...assertions);
34930
+ }
34931
+ const normalized = address ? address.toLowerCase() : null;
34932
+ const filtered = allAssertions.filter(
34933
+ (a) => a.from && a.from.toLowerCase() === normalized || a.to && a.to.toLowerCase() === normalized
34934
+ );
34935
+ return filtered.reverse();
34936
+ } catch (error) {
34937
+ return [];
34929
34938
  }
34930
- const normalized = address ? address.toLowerCase() : null;
34931
- const filtered = allAssertions.filter(
34932
- (a) => a.from && a.from.toLowerCase() === normalized || a.to && a.to.toLowerCase() === normalized
34933
- );
34934
- return filtered.reverse();
34935
34939
  }
34936
34940
  async extractAssertionsFromEvent(event) {
34937
34941
  const header = event.args.header;
@@ -35167,7 +35171,12 @@ class ReceiptClient {
35167
35171
  return this.fetchPreLaunchReceipts(address);
35168
35172
  }
35169
35173
  async stakeReceipts(address) {
35170
- return this.fetchPreLaunchReceipts(address, ReceiptNFTKind.STAKE);
35174
+ try {
35175
+ const receipts = await this.fetchPreLaunchReceipts(address, ReceiptNFTKind.STAKE);
35176
+ return receipts;
35177
+ } catch (err) {
35178
+ return [];
35179
+ }
35171
35180
  }
35172
35181
  async pretokenReceipts(address) {
35173
35182
  return this.fetchPreLaunchReceipts(address, ReceiptNFTKind.PRETOKEN_PURCHASE);
@@ -35301,72 +35310,77 @@ class EthereumStakingClient {
35301
35310
  return result && result.txHash ? result.txHash : "Error - no resulting txHash";
35302
35311
  }
35303
35312
  async getPortfolio() {
35304
- if (!this.signer) return Promise.resolve(null);
35305
- const walletAddress = await this.signer.getAddress();
35306
- const nativeBalance = await this.provider.getBalance(walletAddress);
35307
- const nativeDecimals = this.network?.nativeCurrency?.decimals ?? 18;
35308
- const nativeSymbol = this.network?.nativeCurrency?.symbol ?? "ETH";
35309
- const liqBalance = await this.contract.LiqEthToken.balanceOf(walletAddress);
35310
- const liqSymbol = "Liq" + (this.network?.nativeCurrency?.symbol ?? "ETH");
35311
- let stakeReceipts = await this.receiptClient.stakeReceipts(walletAddress);
35312
- let stakeBalanceBN = BigNumber.from(0);
35313
- for (let r of stakeReceipts) {
35314
- stakeBalanceBN = stakeBalanceBN.add(BigNumber.from(r.receipt.principal.amount));
35315
- }
35316
- let stakeSharesBN = BigNumber.from(0);
35317
- for (let r of stakeReceipts) {
35318
- stakeSharesBN = stakeSharesBN.add(BigNumber.from(r.receipt.shares.amount));
35319
- }
35320
- const wireBalance = await this.contract.Pretoken.balanceOf(walletAddress);
35321
- let currentIndex = BigInt(0);
35322
- let totalShares = BigInt(0);
35323
- let userShares = BigInt(0);
35324
- const indexScale = BigInt(1e27);
35325
35313
  try {
35326
- const [indexBn, totalSharesBn] = await Promise.all([
35327
- this.contract.Depositor.index().catch(() => BigNumber.from(0)),
35328
- this.contract.Depositor.totalShares().catch(() => BigNumber.from(0))
35329
- ]);
35330
- const userSharesBn = stakeSharesBN;
35331
- currentIndex = BigInt(indexBn.toString());
35332
- totalShares = BigInt(totalSharesBn.toString());
35333
- userShares = BigInt(userSharesBn.toString());
35334
- } catch {
35314
+ if (!this.signer) return Promise.resolve(null);
35315
+ const walletAddress = await this.signer.getAddress();
35316
+ const nativeBalance = await this.provider.getBalance(walletAddress);
35317
+ const nativeDecimals = this.network?.nativeCurrency?.decimals ?? 18;
35318
+ const nativeSymbol = this.network?.nativeCurrency?.symbol ?? "ETH";
35319
+ const liqBalance = await this.contract.LiqEthToken.balanceOf(walletAddress);
35320
+ const liqSymbol = "Liq" + (this.network?.nativeCurrency?.symbol ?? "ETH");
35321
+ let stakeReceipts = await this.receiptClient.stakeReceipts(walletAddress);
35322
+ let stakeBalanceBN = BigNumber.from(0);
35323
+ for (let r of stakeReceipts) {
35324
+ stakeBalanceBN = stakeBalanceBN.add(BigNumber.from(r.receipt.principal.amount));
35325
+ }
35326
+ let stakeSharesBN = BigNumber.from(0);
35327
+ for (let r of stakeReceipts) {
35328
+ stakeSharesBN = stakeSharesBN.add(BigNumber.from(r.receipt.shares.amount));
35329
+ }
35330
+ const wireBalance = await this.contract.Pretoken.balanceOf(walletAddress);
35331
+ let currentIndex = BigInt(0);
35332
+ let totalShares = BigInt(0);
35333
+ let userShares = BigInt(0);
35334
+ const indexScale = BigInt(1e27);
35335
+ try {
35336
+ const [indexBn, totalSharesBn] = await Promise.all([
35337
+ this.contract.Depositor.index().catch(() => BigNumber.from(0)),
35338
+ this.contract.Depositor.totalShares().catch(() => BigNumber.from(0))
35339
+ ]);
35340
+ const userSharesBn = stakeSharesBN;
35341
+ currentIndex = BigInt(indexBn.toString());
35342
+ totalShares = BigInt(totalSharesBn.toString());
35343
+ userShares = BigInt(userSharesBn.toString());
35344
+ } catch (error) {
35345
+ console.log("Error fetching staking index/shares:", error);
35346
+ }
35347
+ let estimatedClaim = BigInt(0);
35348
+ let estimatedYield = BigInt(0);
35349
+ const portfolio = {
35350
+ native: {
35351
+ amount: nativeBalance.toBigInt(),
35352
+ decimals: nativeDecimals,
35353
+ symbol: nativeSymbol
35354
+ },
35355
+ liq: {
35356
+ amount: liqBalance.toBigInt(),
35357
+ decimals: nativeDecimals,
35358
+ symbol: liqSymbol
35359
+ },
35360
+ staked: {
35361
+ amount: stakeBalanceBN.toBigInt(),
35362
+ decimals: nativeDecimals,
35363
+ symbol: liqSymbol
35364
+ },
35365
+ wire: {
35366
+ amount: wireBalance.toBigInt(),
35367
+ decimals: 18,
35368
+ symbol: "$WIRE"
35369
+ },
35370
+ yield: {
35371
+ currentIndex,
35372
+ indexScale,
35373
+ totalShares,
35374
+ userShares,
35375
+ estimatedClaim,
35376
+ estimatedYield
35377
+ },
35378
+ chainID: this.network.chainId
35379
+ };
35380
+ return portfolio;
35381
+ } catch (error) {
35382
+ throw error;
35335
35383
  }
35336
- let estimatedClaim = BigInt(0);
35337
- let estimatedYield = BigInt(0);
35338
- const portfolio = {
35339
- native: {
35340
- amount: nativeBalance.toBigInt(),
35341
- decimals: nativeDecimals,
35342
- symbol: nativeSymbol
35343
- },
35344
- liq: {
35345
- amount: liqBalance.toBigInt(),
35346
- decimals: nativeDecimals,
35347
- symbol: liqSymbol
35348
- },
35349
- staked: {
35350
- amount: stakeBalanceBN.toBigInt(),
35351
- decimals: nativeDecimals,
35352
- symbol: liqSymbol
35353
- },
35354
- wire: {
35355
- amount: wireBalance.toBigInt(),
35356
- decimals: 18,
35357
- symbol: "$WIRE"
35358
- },
35359
- yield: {
35360
- currentIndex,
35361
- indexScale,
35362
- totalShares,
35363
- userShares,
35364
- estimatedClaim,
35365
- estimatedYield
35366
- },
35367
- chainID: this.network.chainId
35368
- };
35369
- return portfolio;
35370
35384
  }
35371
35385
  async fetchPrelaunchReceipts(address) {
35372
35386
  this.ensureUser();
@@ -35493,6 +35507,7 @@ class Staker {
35493
35507
  this.clients.set(cfg.network.chainId, new SolanaStakingClient(cfg));
35494
35508
  break;
35495
35509
  case EvmChainID.Ethereum:
35510
+ case EvmChainID.Hoodi:
35496
35511
  this.clients.set(cfg.network.chainId, new EthereumStakingClient(cfg));
35497
35512
  break;
35498
35513
  default: