@ethersphere/bee-js 13.1.1-upcoming.gc4973c3 → 13.2.0-upcoming.g65e5d19

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.
@@ -18,7 +18,7 @@ async function getStake(requestOptions) {
18
18
  responseType: 'json',
19
19
  url: STAKE_ENDPOINT,
20
20
  });
21
- return stake_1.GetStakeResponse.parse(response.data).stakedAmount;
21
+ return stake_1.GetStakeResponse.parse(response.data);
22
22
  }
23
23
  async function getWithdrawableStake(requestOptions) {
24
24
  const response = await (0, http_1.http)(requestOptions, {
@@ -71,7 +71,7 @@ class Chequebook {
71
71
  */
72
72
  async deposit(amount, gasPrice, requestOptions) {
73
73
  const amountString = amount instanceof tokens_1.BZZ ? amount.toPLURString() : (0, type_1.asNumberString)(amount, { min: 1n, name: 'amount' });
74
- const gasPriceString = gasPrice ? (0, type_1.asNumberString)(amount, { min: 0n, name: 'gasPrice' }) : undefined;
74
+ const gasPriceString = gasPrice ? (0, type_1.asNumberString)(gasPrice, { min: 0n, name: 'gasPrice' }) : undefined;
75
75
  return api.depositTokens(this.context.getRequestOptionsForCall(requestOptions), amountString, gasPriceString);
76
76
  }
77
77
  /**
@@ -83,7 +83,7 @@ class Chequebook {
83
83
  */
84
84
  async withdraw(amount, gasPrice, requestOptions) {
85
85
  const amountString = amount instanceof tokens_1.BZZ ? amount.toPLURString() : (0, type_1.asNumberString)(amount, { min: 1n, name: 'amount' });
86
- const gasPriceString = gasPrice ? (0, type_1.asNumberString)(amount, { min: 0n, name: 'gasPrice' }) : undefined;
86
+ const gasPriceString = gasPrice ? (0, type_1.asNumberString)(gasPrice, { min: 0n, name: 'gasPrice' }) : undefined;
87
87
  return api.withdrawTokens(this.context.getRequestOptionsForCall(requestOptions), amountString, gasPriceString);
88
88
  }
89
89
  }
@@ -54,7 +54,13 @@ class Stake {
54
54
  * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
55
55
  */
56
56
  async get(requestOptions) {
57
- return stakeApi.getStake(this.context.getRequestOptionsForCall(requestOptions));
57
+ const { stakedAmount } = await stakeApi.getStake(this.context.getRequestOptionsForCall(requestOptions));
58
+ return stakedAmount;
59
+ }
60
+ /** Gets the minimum next deposit, or `null` when Bee cannot determine it (e.g. the price oracle is unavailable). */
61
+ async getMinimumDeposit(requestOptions) {
62
+ const { minimumDeposit } = await stakeApi.getStake(this.context.getRequestOptionsForCall(requestOptions));
63
+ return minimumDeposit;
58
64
  }
59
65
  /**
60
66
  * Gets the amount of withdrawable staked BZZ.
@@ -65,7 +71,7 @@ class Stake {
65
71
  return stakeApi.getWithdrawableStake(this.context.getRequestOptionsForCall(requestOptions));
66
72
  }
67
73
  /**
68
- * Stakes the given amount of BZZ. Initial deposit must be at least 10 BZZ.
74
+ * Stakes the given amount of BZZ. Must be at least {@link getMinimumDeposit}, otherwise Bee rejects it with 400.
69
75
  *
70
76
  * Be aware that staked BZZ tokens can **not** be withdrawn.
71
77
  *
@@ -7,6 +7,10 @@ const tokens_1 = require("../../utils/tokens");
7
7
  const type_1 = require("../../utils/type");
8
8
  exports.GetStakeResponse = zod_1.z.object({
9
9
  stakedAmount: zod_1.z.string().transform(s => tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(s, { name: 'stakedAmount' }))),
10
+ minimumDeposit: zod_1.z
11
+ .string()
12
+ .nullish()
13
+ .transform(s => (s ? tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(s, { name: 'minimumDeposit' })) : null)),
10
14
  });
11
15
  exports.GetWithdrawableStakeResponse = zod_1.z.object({
12
16
  withdrawableAmount: zod_1.z.string().transform(s => tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(s, { name: 'withdrawableAmount' }))),