@wireio/stake 0.4.1 → 0.4.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.
@@ -8291,7 +8291,7 @@ class SolanaStakingClient {
8291
8291
  return this.config.network;
8292
8292
  }
8293
8293
  async deposit(amountLamports) {
8294
- this.ensureWriteAccess();
8294
+ this.ensureUser();
8295
8295
  if (amountLamports <= BigInt(0)) {
8296
8296
  throw new Error("Deposit amount must be greater than zero.");
8297
8297
  }
@@ -8304,7 +8304,7 @@ class SolanaStakingClient {
8304
8304
  });
8305
8305
  }
8306
8306
  async withdraw(amountLamports) {
8307
- this.ensureWriteAccess();
8307
+ this.ensureUser();
8308
8308
  if (amountLamports <= BigInt(0)) {
8309
8309
  throw new Error("Withdraw amount must be greater than zero.");
8310
8310
  }
@@ -8317,7 +8317,7 @@ class SolanaStakingClient {
8317
8317
  });
8318
8318
  }
8319
8319
  async stake(amountLamports) {
8320
- this.ensureWriteAccess();
8320
+ this.ensureUser();
8321
8321
  if (!amountLamports || amountLamports <= BigInt(0)) {
8322
8322
  throw new Error("Stake amount must be greater than zero.");
8323
8323
  }
@@ -8329,7 +8329,7 @@ class SolanaStakingClient {
8329
8329
  return this.sendAndConfirmHttp(signed, prepared);
8330
8330
  }
8331
8331
  async unstake(amountLamports) {
8332
- this.ensureWriteAccess();
8332
+ this.ensureUser();
8333
8333
  if (!amountLamports || amountLamports <= BigInt(0)) {
8334
8334
  throw new Error("Unstake amount must be greater than zero.");
8335
8335
  }
@@ -8341,7 +8341,7 @@ class SolanaStakingClient {
8341
8341
  return this.sendAndConfirmHttp(signed, prepared);
8342
8342
  }
8343
8343
  async buy(amountLamports) {
8344
- this.ensureWriteAccess();
8344
+ this.ensureUser();
8345
8345
  if (!amountLamports || amountLamports <= BigInt(0)) {
8346
8346
  throw new Error("liqSOL pretoken purchase requires a positive amount.");
8347
8347
  }
@@ -8439,6 +8439,16 @@ class SolanaStakingClient {
8439
8439
  chainID: this.network.chainId
8440
8440
  };
8441
8441
  }
8442
+ async getUserRecord() {
8443
+ if (!this.pubKey) throw new Error("User pubKey is undefined");
8444
+ return this.distributionClient.getUserRecord(this.solPubKey);
8445
+ }
8446
+ getSystemAPY() {
8447
+ return Promise.resolve(0);
8448
+ }
8449
+ getDepositFee(amount) {
8450
+ return Promise.resolve(BigInt(0));
8451
+ }
8442
8452
  async getTrancheSnapshot(options) {
8443
8453
  const {
8444
8454
  chainID = SolChainID.WireTestnet,
@@ -8460,12 +8470,8 @@ class SolanaStakingClient {
8460
8470
  ladderWindowAfter: windowAfter
8461
8471
  });
8462
8472
  }
8463
- async getUserRecord() {
8464
- if (!this.pubKey) throw new Error("User pubKey is undefined");
8465
- return this.distributionClient.getUserRecord(this.solPubKey);
8466
- }
8467
8473
  async sendAndConfirmHttp(signed, ctx) {
8468
- this.ensureWriteAccess();
8474
+ this.ensureUser();
8469
8475
  const signature = await this.connection.sendRawTransaction(
8470
8476
  signed.serialize(),
8471
8477
  {
@@ -8490,11 +8496,11 @@ class SolanaStakingClient {
8490
8496
  return signature;
8491
8497
  }
8492
8498
  async signTransaction(tx) {
8493
- this.ensureWriteAccess();
8499
+ this.ensureUser();
8494
8500
  return this.anchor.wallet.signTransaction(tx);
8495
8501
  }
8496
8502
  async sendTransaction(signed) {
8497
- this.ensureWriteAccess();
8503
+ this.ensureUser();
8498
8504
  return this.anchor.sendAndConfirm(signed);
8499
8505
  }
8500
8506
  async prepareTx(tx) {
@@ -8503,7 +8509,7 @@ class SolanaStakingClient {
8503
8509
  tx.feePayer = this.solPubKey;
8504
8510
  return { tx, blockhash, lastValidBlockHeight };
8505
8511
  }
8506
- ensureWriteAccess() {
8512
+ ensureUser() {
8507
8513
  if (!this.pubKey || !this.anchor.wallet.publicKey) {
8508
8514
  throw new Error("User Authorization required: pubKey is undefined");
8509
8515
  }
@@ -29135,8 +29141,12 @@ class EthereumStakingClient {
29135
29141
  constructor(config) {
29136
29142
  this.config = config;
29137
29143
  try {
29138
- this.provider = config.provider;
29139
- this.signer = this.provider.getSigner();
29144
+ if (config.provider) {
29145
+ this.provider = config.provider;
29146
+ this.signer = this.provider.getSigner();
29147
+ } else {
29148
+ this.provider = new ethers.providers.JsonRpcProvider(config.network.rpcUrls[0]);
29149
+ }
29140
29150
  this.pubKey = config.pubKey;
29141
29151
  this.contractService = new EthereumContractService({
29142
29152
  provider: this.provider,
@@ -29158,17 +29168,20 @@ class EthereumStakingClient {
29158
29168
  return this.config.network;
29159
29169
  }
29160
29170
  async deposit(amount) {
29171
+ this.ensureUser();
29161
29172
  const amountWei = BigNumber.isBigNumber(amount) ? amount : BigNumber.from(amount);
29162
29173
  const result = await this.convertClient.performDeposit(amountWei);
29163
29174
  return result.txHash;
29164
29175
  }
29165
29176
  async withdraw(amount) {
29177
+ this.ensureUser();
29166
29178
  const address = await this.signer.getAddress();
29167
29179
  const amountWei = BigNumber.from(amount);
29168
29180
  const result = await this.convertClient.performWithdraw(address, amountWei);
29169
29181
  return result.txHash;
29170
29182
  }
29171
29183
  async stake(amount) {
29184
+ this.ensureUser();
29172
29185
  const walletAddress = await this.signer.getAddress();
29173
29186
  const amountWei = BigNumber.from(amount);
29174
29187
  const result = await this.stakeClient.performStake(amountWei, walletAddress);
@@ -29178,38 +29191,20 @@ class EthereumStakingClient {
29178
29191
  throw new Error("Method not yet implemented.");
29179
29192
  }
29180
29193
  async unstakePrelaunch(tokenId, recipient) {
29194
+ this.ensureUser();
29181
29195
  const tokenIdBigNum = BigNumber.from(tokenId);
29182
29196
  const result = await this.stakeClient.performWithdrawStake(tokenIdBigNum, recipient);
29183
29197
  return result.txHash;
29184
29198
  }
29185
29199
  async buy(amount) {
29200
+ this.ensureUser();
29186
29201
  const buyer = await this.signer.getAddress();
29187
29202
  await this.updateMockAggregatorPrice();
29188
29203
  let result = await this.pretokenClient.purchasePretokensWithLiqETH(amount, buyer);
29189
29204
  return result && result.txHash ? result.txHash : "Error - no resulting txHash";
29190
29205
  }
29191
- async getOPPMessages(address) {
29192
- if (!address) address = await this.signer.getAddress();
29193
- return await this.oppClient.getMessages(address);
29194
- }
29195
- async getOPPStatus() {
29196
- return await this.oppClient.getStatus();
29197
- }
29198
- async fetchPrelaunchReceipts(address) {
29199
- if (address === void 0) address = await this.signer.getAddress();
29200
- return await this.receiptClient.stakeReceipts(address);
29201
- }
29202
- async getEthStats() {
29203
- let withdrawDelay = await this.contract.DepositManager.withdrawDelay();
29204
- let minDeposit = await this.contract.DepositManager.minDeposit();
29205
- let rewardCooldown = await this.contract.DepositManager.rewardCooldown();
29206
- return {
29207
- withdrawDelay,
29208
- minDeposit,
29209
- rewardCooldown
29210
- };
29211
- }
29212
29206
  async getPortfolio() {
29207
+ this.ensureUser();
29213
29208
  const walletAddress = await this.signer.getAddress();
29214
29209
  const nativeBalance = await this.provider.getBalance(walletAddress);
29215
29210
  const nativeDecimals = this.network?.nativeCurrency?.decimals ?? 18;
@@ -29247,6 +29242,42 @@ class EthereumStakingClient {
29247
29242
  };
29248
29243
  return portfolio;
29249
29244
  }
29245
+ async fetchPrelaunchReceipts(address) {
29246
+ this.ensureUser();
29247
+ if (address === void 0) address = await this.signer.getAddress();
29248
+ return await this.receiptClient.stakeReceipts(address);
29249
+ }
29250
+ async getOPPMessages(address) {
29251
+ this.ensureUser();
29252
+ if (!address) address = await this.signer.getAddress();
29253
+ return await this.oppClient.getMessages(address);
29254
+ }
29255
+ ensureUser() {
29256
+ if (!this.signer) {
29257
+ throw new Error(
29258
+ "EthereumStakingClient: write operation requires a wallet-connected Web3 provider"
29259
+ );
29260
+ }
29261
+ }
29262
+ getSystemAPY() {
29263
+ return Promise.resolve(0);
29264
+ }
29265
+ getDepositFee(amount) {
29266
+ return Promise.resolve(BigInt(0));
29267
+ }
29268
+ async getOPPStatus() {
29269
+ return await this.oppClient.getStatus();
29270
+ }
29271
+ async getEthStats() {
29272
+ let withdrawDelay = await this.contract.DepositManager.withdrawDelay();
29273
+ let minDeposit = await this.contract.DepositManager.minDeposit();
29274
+ let rewardCooldown = await this.contract.DepositManager.rewardCooldown();
29275
+ return {
29276
+ withdrawDelay,
29277
+ minDeposit,
29278
+ rewardCooldown
29279
+ };
29280
+ }
29250
29281
  async getTrancheSnapshot(options) {
29251
29282
  const {
29252
29283
  chainID = EvmChainID.Hoodi,