@upcoming/bee-js 9.4.1 → 9.7.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/dist/cjs/bee.js +94 -22
- package/dist/cjs/manifest/manifest.js +3 -3
- package/dist/cjs/modules/debug/stake.js +37 -3
- package/dist/cjs/modules/debug/states.js +24 -1
- package/dist/cjs/modules/debug/status.js +3 -2
- package/dist/cjs/modules/status.js +15 -1
- package/dist/cjs/types/index.js +277 -1
- package/dist/cjs/utils/bytes.js +19 -1
- package/dist/cjs/utils/http.js +2 -2
- package/dist/cjs/utils/stamps.js +36 -13
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee.js +95 -23
- package/dist/mjs/manifest/manifest.js +3 -3
- package/dist/mjs/modules/debug/stake.js +45 -2
- package/dist/mjs/modules/debug/states.js +35 -0
- package/dist/mjs/modules/debug/status.js +5 -2
- package/dist/mjs/modules/status.js +12 -0
- package/dist/mjs/types/index.js +1267 -1
- package/dist/mjs/utils/bytes.js +17 -0
- package/dist/mjs/utils/http.js +2 -2
- package/dist/mjs/utils/stamps.js +35 -14
- package/dist/types/bee.d.ts +69 -18
- package/dist/types/manifest/manifest.d.ts +1 -1
- package/dist/types/modules/debug/stake.d.ts +9 -2
- package/dist/types/modules/debug/states.d.ts +4 -0
- package/dist/types/modules/debug/status.d.ts +2 -2
- package/dist/types/modules/status.d.ts +1 -0
- package/dist/types/types/debug.d.ts +1 -0
- package/dist/types/types/index.d.ts +66 -0
- package/dist/types/utils/bytes.d.ts +1 -0
- package/dist/types/utils/stamps.d.ts +4 -4
- package/package.json +3 -3
package/dist/mjs/utils/bytes.js
CHANGED
|
@@ -67,4 +67,21 @@ export class Bytes {
|
|
|
67
67
|
represent() {
|
|
68
68
|
return this.toHex();
|
|
69
69
|
}
|
|
70
|
+
}
|
|
71
|
+
export function parseSizeToBytes(sizeStr) {
|
|
72
|
+
const units = {
|
|
73
|
+
B: 1,
|
|
74
|
+
kB: 1000,
|
|
75
|
+
MB: 1000 ** 2,
|
|
76
|
+
GB: 1000 ** 3,
|
|
77
|
+
TB: 1000 ** 4,
|
|
78
|
+
PB: 1000 ** 5
|
|
79
|
+
};
|
|
80
|
+
const match = sizeStr.match(/^([\d.]+)\s*(B|kB|MB|GB|TB|PB)$/);
|
|
81
|
+
if (!match) {
|
|
82
|
+
throw new Error(`Invalid size format: ${sizeStr}`);
|
|
83
|
+
}
|
|
84
|
+
const value = parseFloat(match[1]);
|
|
85
|
+
const unit = match[2];
|
|
86
|
+
return Math.ceil(value * units[unit]);
|
|
70
87
|
}
|
package/dist/mjs/utils/http.js
CHANGED
|
@@ -23,7 +23,7 @@ export const DEFAULT_HTTP_CONFIG = {
|
|
|
23
23
|
export async function http(options, config) {
|
|
24
24
|
const requestConfig = Objects.deepMerge3(DEFAULT_HTTP_CONFIG, config, options);
|
|
25
25
|
if (requestConfig.data && typeof Buffer !== 'undefined' && Buffer.isBuffer(requestConfig.data)) {
|
|
26
|
-
requestConfig.data = requestConfig.data.buffer;
|
|
26
|
+
requestConfig.data = requestConfig.data.buffer.slice(requestConfig.data.byteOffset, requestConfig.data.byteOffset + requestConfig.data.byteLength);
|
|
27
27
|
}
|
|
28
28
|
if (requestConfig.params) {
|
|
29
29
|
const keys = Object.keys(requestConfig.params);
|
|
@@ -59,7 +59,7 @@ function maybeRunOnRequestHook(options, requestConfig) {
|
|
|
59
59
|
if (options.onRequest) {
|
|
60
60
|
options.onRequest({
|
|
61
61
|
method: requestConfig.method || 'GET',
|
|
62
|
-
url: Strings.joinUrl(requestConfig.baseURL, requestConfig.url),
|
|
62
|
+
url: Strings.joinUrl([requestConfig.baseURL, requestConfig.url]),
|
|
63
63
|
headers: {
|
|
64
64
|
...requestConfig.headers
|
|
65
65
|
},
|
package/dist/mjs/utils/stamps.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Binary } from 'cafe-utility';
|
|
2
|
-
import {
|
|
2
|
+
import { capacityBreakpoints } from "../types/index.js";
|
|
3
|
+
import { Bytes, parseSizeToBytes } from "./bytes.js";
|
|
3
4
|
import { Duration } from "./duration.js";
|
|
4
5
|
import { BZZ } from "./tokens.js";
|
|
5
6
|
import { asNumberString } from "./type.js";
|
|
@@ -37,24 +38,33 @@ const effectiveSizeBreakpoints = [[17, 0.00004089], [18, 0.00609], [19, 0.10249]
|
|
|
37
38
|
*
|
|
38
39
|
* @returns {number} The effective size of the postage batch in bytes.
|
|
39
40
|
*/
|
|
40
|
-
export function getStampEffectiveBytes(depth) {
|
|
41
|
+
export function getStampEffectiveBytes(depth, encryption, erasureCodeLevel) {
|
|
41
42
|
if (depth < 17) {
|
|
42
43
|
return 0;
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
if (encryption !== undefined && erasureCodeLevel !== undefined) {
|
|
46
|
+
const encryptionKey = encryption ? 'ENCRYPTION_ON' : 'ENCRYPTION_OFF';
|
|
47
|
+
const breakpoints = capacityBreakpoints[encryptionKey][erasureCodeLevel];
|
|
48
|
+
const entry = breakpoints.find(item => item.batchDepth === depth);
|
|
49
|
+
if (entry?.effectiveVolume) {
|
|
50
|
+
return parseSizeToBytes(entry.effectiveVolume);
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
const breakpoint = effectiveSizeBreakpoints.find(([d, size]) => {
|
|
54
|
+
if (depth === d) {
|
|
55
|
+
return size;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
if (breakpoint) {
|
|
59
|
+
return breakpoint[1] * 1000 * 1000 * 1000;
|
|
47
60
|
}
|
|
48
|
-
});
|
|
49
|
-
if (breakpoint) {
|
|
50
|
-
return breakpoint[1] * 1000 * 1000 * 1000;
|
|
51
61
|
}
|
|
52
62
|
return Math.ceil(getStampTheoreticalBytes(depth) * MAX_UTILIZATION);
|
|
53
63
|
}
|
|
54
|
-
export function getStampEffectiveBytesBreakpoints() {
|
|
64
|
+
export function getStampEffectiveBytesBreakpoints(encryption, erasureCodeLevel) {
|
|
55
65
|
const map = new Map();
|
|
56
66
|
for (let i = 17; i < 35; i++) {
|
|
57
|
-
map.set(i, getStampEffectiveBytes(i));
|
|
67
|
+
map.set(i, getStampEffectiveBytes(i, encryption, erasureCodeLevel));
|
|
58
68
|
}
|
|
59
69
|
return map;
|
|
60
70
|
}
|
|
@@ -91,10 +101,21 @@ export function getAmountForDuration(duration, pricePerBlock, blockTime) {
|
|
|
91
101
|
* @param size The effective size of the postage batch
|
|
92
102
|
* @returns
|
|
93
103
|
*/
|
|
94
|
-
export function getDepthForSize(size) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
104
|
+
export function getDepthForSize(size, encryption, erasureCodeLevel) {
|
|
105
|
+
if (encryption !== undefined && erasureCodeLevel !== undefined) {
|
|
106
|
+
const encryptionKey = encryption ? 'ENCRYPTION_ON' : 'ENCRYPTION_OFF';
|
|
107
|
+
const breakpoints = capacityBreakpoints[encryptionKey][erasureCodeLevel];
|
|
108
|
+
const entry = breakpoints.find(item => {
|
|
109
|
+
return size.toBytes() <= parseSizeToBytes(item.effectiveVolume);
|
|
110
|
+
});
|
|
111
|
+
if (entry?.effectiveVolume) {
|
|
112
|
+
return entry.batchDepth;
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
for (const [depth, sizeBreakpoint] of effectiveSizeBreakpoints) {
|
|
116
|
+
if (size.toBytes() <= sizeBreakpoint * 1000 * 1000 * 1000) {
|
|
117
|
+
return depth;
|
|
118
|
+
}
|
|
98
119
|
}
|
|
99
120
|
}
|
|
100
121
|
return 35;
|
package/dist/types/bee.d.ts
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
import { Readable } from 'stream';
|
|
3
3
|
import { Chunk } from './chunk/cac';
|
|
4
4
|
import { FeedPayloadResult } from './modules/feed';
|
|
5
|
-
import type { AllSettlements, BalanceResponse, BeeOptions, BeeRequestOptions, BeeVersions, ChainState, ChequebookAddressResponse, ChequebookBalanceResponse, CollectionUploadOptions, DebugStatus, DownloadOptions, EnvelopeWithBatchId, FeedReader, FeedWriter, FileData, FileUploadOptions, GetGranteesResult, GlobalPostageBatch, GranteesResult, GsocMessageHandler, GsocSubscription, Health, LastCashoutActionResponse, LastChequesForPeerResponse, LastChequesResponse, NodeAddresses, NodeInfo, NumberString, Peer, PeerBalance, Pin, PingResponse, PostageBatch, PostageBatchBuckets, PssMessageHandler, PssSubscription, Readiness, RedistributionState, RedundantUploadOptions, ReferenceInformation, RemovePeerResponse, ReserveState, SOCReader, SOCWriter, Settlements, Tag, Topology, TransactionInfo, UploadOptions, WalletBalance } from './types';
|
|
5
|
+
import type { AllSettlements, BalanceResponse, BeeOptions, BeeRequestOptions, BeeVersions, ChainState, ChequebookAddressResponse, ChequebookBalanceResponse, CollectionUploadOptions, DebugStatus, DownloadOptions, EnvelopeWithBatchId, FeedReader, FeedWriter, FileData, FileUploadOptions, GetGranteesResult, GlobalPostageBatch, GranteesResult, GsocMessageHandler, GsocSubscription, Health, LastCashoutActionResponse, LastChequesForPeerResponse, LastChequesResponse, NodeAddresses, NodeInfo, NumberString, Peer, PeerBalance, Pin, PingResponse, PostageBatch, PostageBatchBuckets, PssMessageHandler, PssSubscription, Readiness, RedistributionState, RedundancyLevel, RedundantUploadOptions, ReferenceInformation, RemovePeerResponse, ReserveState, SOCReader, SOCWriter, Settlements, Tag, Topology, TransactionInfo, UploadOptions, WalletBalance } from './types';
|
|
6
6
|
import { AllTagsOptions, Collection, PostageBatchOptions, TransactionOptions, UploadResult } from './types';
|
|
7
7
|
import { Bytes } from './utils/bytes';
|
|
8
8
|
import { Duration } from './utils/duration';
|
|
9
9
|
import { Size } from './utils/size';
|
|
10
|
-
import { BZZ } from './utils/tokens';
|
|
10
|
+
import { BZZ, DAI } from './utils/tokens';
|
|
11
11
|
import { BatchId, EthAddress, FeedIndex, Identifier, PeerAddress, PrivateKey, PublicKey, Reference, Topic, TransactionId } from './utils/typed-bytes';
|
|
12
12
|
import { UploadProgress } from './utils/upload-progress';
|
|
13
13
|
/**
|
|
@@ -497,6 +497,15 @@ export declare class Bee {
|
|
|
497
497
|
* @returns true if successful, false on error
|
|
498
498
|
*/
|
|
499
499
|
isConnected(options?: BeeRequestOptions): Promise<boolean>;
|
|
500
|
+
/**
|
|
501
|
+
* Checks the `/gateway` endpoint to see if the remote API is a gateway.
|
|
502
|
+
*
|
|
503
|
+
* Do note that this is not a standard way to check for gateway nodes,
|
|
504
|
+
* but some of the gateway tooling expose this endpoint.
|
|
505
|
+
*
|
|
506
|
+
* @param options
|
|
507
|
+
*/
|
|
508
|
+
isGateway(options?: BeeRequestOptions): Promise<boolean>;
|
|
500
509
|
getNodeAddresses(options?: BeeRequestOptions): Promise<NodeAddresses>;
|
|
501
510
|
getBlocklist(options?: BeeRequestOptions): Promise<Peer[]>;
|
|
502
511
|
/**
|
|
@@ -563,21 +572,41 @@ export declare class Bee {
|
|
|
563
572
|
*/
|
|
564
573
|
cashoutLastCheque(address: PeerAddress | string, options?: TransactionOptions, requestOptions?: BeeRequestOptions): Promise<TransactionId>;
|
|
565
574
|
/**
|
|
566
|
-
* Deposit tokens from
|
|
575
|
+
* Deposit tokens from node wallet into chequebook
|
|
567
576
|
*
|
|
568
577
|
* @param amount Amount of tokens to deposit (must be positive integer)
|
|
569
578
|
* @param gasPrice Gas Price in WEI for the transaction call
|
|
570
579
|
* @return string Hash of the transaction
|
|
580
|
+
* @deprecated Use `depositBZZToChequebook` instead.
|
|
571
581
|
*/
|
|
572
582
|
depositTokens(amount: BZZ | NumberString | string | bigint, gasPrice?: NumberString | string | bigint, options?: BeeRequestOptions): Promise<TransactionId>;
|
|
573
583
|
/**
|
|
574
|
-
*
|
|
584
|
+
* Deposit tokens from node wallet into chequebook
|
|
585
|
+
*
|
|
586
|
+
* @param amount Amount of tokens to deposit (must be positive integer)
|
|
587
|
+
* @param gasPrice Gas Price in WEI for the transaction call
|
|
588
|
+
* @return string Hash of the transaction
|
|
589
|
+
*/
|
|
590
|
+
depositBZZToChequebook(amount: BZZ | NumberString | string | bigint, gasPrice?: NumberString | string | bigint, options?: BeeRequestOptions): Promise<TransactionId>;
|
|
591
|
+
/**
|
|
592
|
+
* Withdraw tokens from the chequebook to the node wallet
|
|
575
593
|
*
|
|
576
594
|
* @param amount Amount of tokens to withdraw (must be positive integer)
|
|
577
595
|
* @param gasPrice Gas Price in WEI for the transaction call
|
|
578
596
|
* @return string Hash of the transaction
|
|
597
|
+
* @deprecated Use `withdrawBZZFromChequebook` instead.
|
|
579
598
|
*/
|
|
580
599
|
withdrawTokens(amount: BZZ | NumberString | string | bigint, gasPrice?: NumberString | string | bigint, options?: BeeRequestOptions): Promise<TransactionId>;
|
|
600
|
+
/**
|
|
601
|
+
* Withdraw tokens from the chequebook to the node wallet
|
|
602
|
+
*
|
|
603
|
+
* @param amount Amount of tokens to withdraw (must be positive integer)
|
|
604
|
+
* @param gasPrice Gas Price in WEI for the transaction call
|
|
605
|
+
* @return string Hash of the transaction
|
|
606
|
+
*/
|
|
607
|
+
withdrawBZZFromChequebook(amount: BZZ | NumberString | string | bigint, gasPrice?: NumberString | string | bigint, options?: BeeRequestOptions): Promise<TransactionId>;
|
|
608
|
+
withdrawBZZToExternalWallet(amount: BZZ | NumberString | string | bigint, address: EthAddress | Uint8Array | string, options?: BeeRequestOptions): Promise<TransactionId>;
|
|
609
|
+
withdrawDAIToExternalWallet(amount: DAI | NumberString | string | bigint, address: EthAddress | Uint8Array | string, options?: BeeRequestOptions): Promise<TransactionId>;
|
|
581
610
|
/**
|
|
582
611
|
* Get amount of sent and received from settlements with a peer
|
|
583
612
|
*
|
|
@@ -635,7 +664,7 @@ export declare class Bee {
|
|
|
635
664
|
*/
|
|
636
665
|
getChainState(options?: BeeRequestOptions): Promise<ChainState>;
|
|
637
666
|
/**
|
|
638
|
-
* Get wallet balances for
|
|
667
|
+
* Get wallet balances for DAI and BZZ of the Bee node
|
|
639
668
|
*
|
|
640
669
|
* @param options
|
|
641
670
|
*/
|
|
@@ -658,12 +687,12 @@ export declare class Bee {
|
|
|
658
687
|
* @see [Bee Debug API reference - `POST /stamps`](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps~1{amount}~1{depth}/post)
|
|
659
688
|
*/
|
|
660
689
|
createPostageBatch(amount: NumberString | string | bigint, depth: number, options?: PostageBatchOptions, requestOptions?: BeeRequestOptions): Promise<BatchId>;
|
|
661
|
-
buyStorage(size: Size, duration: Duration, options?: PostageBatchOptions, requestOptions?: BeeRequestOptions): Promise<BatchId>;
|
|
662
|
-
getStorageCost(size: Size, duration: Duration, options?: BeeRequestOptions): Promise<BZZ>;
|
|
663
|
-
extendStorageSize(postageBatchId: BatchId | Uint8Array | string, size: Size, options?: BeeRequestOptions): Promise<BatchId>;
|
|
690
|
+
buyStorage(size: Size, duration: Duration, options?: PostageBatchOptions, requestOptions?: BeeRequestOptions, encryption?: boolean, erasureCodeLevel?: RedundancyLevel): Promise<BatchId>;
|
|
691
|
+
getStorageCost(size: Size, duration: Duration, options?: BeeRequestOptions, encryption?: boolean, erasureCodeLevel?: RedundancyLevel): Promise<BZZ>;
|
|
692
|
+
extendStorageSize(postageBatchId: BatchId | Uint8Array | string, size: Size, options?: BeeRequestOptions, encryption?: boolean, erasureCodeLevel?: RedundancyLevel): Promise<BatchId>;
|
|
664
693
|
extendStorageDuration(postageBatchId: BatchId | Uint8Array | string, duration: Duration, options?: BeeRequestOptions): Promise<BatchId>;
|
|
665
|
-
getExtensionCost(postageBatchId: BatchId | Uint8Array | string, size: Size, duration: Duration, options?: BeeRequestOptions): Promise<BZZ>;
|
|
666
|
-
getSizeExtensionCost(postageBatchId: BatchId | Uint8Array | string, size: Size, options?: BeeRequestOptions): Promise<BZZ>;
|
|
694
|
+
getExtensionCost(postageBatchId: BatchId | Uint8Array | string, size: Size, duration: Duration, options?: BeeRequestOptions, encryption?: boolean, erasureCodeLevel?: RedundancyLevel): Promise<BZZ>;
|
|
695
|
+
getSizeExtensionCost(postageBatchId: BatchId | Uint8Array | string, size: Size, options?: BeeRequestOptions, encryption?: boolean, erasureCodeLevel?: RedundancyLevel): Promise<BZZ>;
|
|
667
696
|
getDurationExtensionCost(postageBatchId: BatchId | Uint8Array | string, duration: Duration, options?: BeeRequestOptions): Promise<BZZ>;
|
|
668
697
|
/**
|
|
669
698
|
* Topup a fresh amount of BZZ to given Postage Batch.
|
|
@@ -753,30 +782,52 @@ export declare class Bee {
|
|
|
753
782
|
*/
|
|
754
783
|
rebroadcastPendingTransaction(transactionHash: TransactionId | Uint8Array | string, options?: BeeRequestOptions): Promise<TransactionId>;
|
|
755
784
|
/**
|
|
756
|
-
*
|
|
785
|
+
* Cancels a currently pending transaction
|
|
757
786
|
* @param transactionHash
|
|
758
787
|
* @param gasPrice
|
|
759
788
|
*/
|
|
760
789
|
cancelPendingTransaction(transactionHash: TransactionId | Uint8Array | string, gasPrice?: NumberString | string | bigint, options?: BeeRequestOptions): Promise<TransactionId>;
|
|
761
790
|
/**
|
|
762
|
-
* Gets the
|
|
791
|
+
* Gets the amount of staked BZZ
|
|
763
792
|
*
|
|
764
|
-
* @param options
|
|
793
|
+
* @param options HTTP request options, such as `headers` or `timeout`
|
|
765
794
|
*/
|
|
766
795
|
getStake(options?: BeeRequestOptions): Promise<BZZ>;
|
|
767
796
|
/**
|
|
768
|
-
*
|
|
797
|
+
* Gets the amount of withdrawable staked BZZ.
|
|
798
|
+
*
|
|
799
|
+
* @param options HTTP request options, such as `headers` or `timeout`
|
|
800
|
+
*/
|
|
801
|
+
getWithdrawableStake(options?: BeeRequestOptions): Promise<BZZ>;
|
|
802
|
+
/**
|
|
803
|
+
* Withdraws ALL surplus staked BZZ to the node wallet.
|
|
804
|
+
*
|
|
805
|
+
* Use the `getWithdrawableStake` method to check how much surplus stake is available.
|
|
806
|
+
*
|
|
807
|
+
* @param options HTTP request options, such as `headers` or `timeout`
|
|
808
|
+
*/
|
|
809
|
+
withdrawSurplusStake(options?: BeeRequestOptions): Promise<TransactionId>;
|
|
810
|
+
/**
|
|
811
|
+
* Withdraws all staked BZZ to the node wallet.
|
|
812
|
+
*
|
|
813
|
+
* **Only available when the staking contract is paused and is in the process of being migrated to a new contract!**
|
|
814
|
+
*
|
|
815
|
+
* @param options HTTP request options, such as `headers` or `timeout`
|
|
816
|
+
*/
|
|
817
|
+
migrateStake(options?: BeeRequestOptions): Promise<TransactionId>;
|
|
818
|
+
/**
|
|
819
|
+
* Stakes the given amount of BZZ. Initial deposit must be at least 10 BZZ.
|
|
769
820
|
*
|
|
770
821
|
* Be aware that staked BZZ tokens can **not** be withdrawn.
|
|
771
822
|
*
|
|
772
|
-
* @param amount Amount of BZZ
|
|
773
|
-
* @param options
|
|
823
|
+
* @param amount Amount of BZZ tokens to be staked. If not providing a `BZZ` instance, the amount is denoted in PLUR.
|
|
824
|
+
* @param options HTTP request options, such as `headers` or `timeout`
|
|
774
825
|
*/
|
|
775
826
|
depositStake(amount: BZZ | NumberString | string | bigint, options?: TransactionOptions, requestOptions?: BeeRequestOptions): Promise<TransactionId>;
|
|
776
827
|
/**
|
|
777
|
-
*
|
|
828
|
+
* Gets current status of node in redistribution game
|
|
778
829
|
*
|
|
779
|
-
* @param options
|
|
830
|
+
* @param options HTTP request options, such as `headers` or `timeout`
|
|
780
831
|
*/
|
|
781
832
|
getRedistributionState(options?: BeeRequestOptions): Promise<RedistributionState>;
|
|
782
833
|
private waitForUsablePostageStamp;
|
|
@@ -9,7 +9,7 @@ export declare class Fork {
|
|
|
9
9
|
constructor(prefix: Uint8Array, node: MantarayNode);
|
|
10
10
|
static split(a: Fork, b: Fork): Fork;
|
|
11
11
|
marshal(): Uint8Array;
|
|
12
|
-
static unmarshal(reader: Uint8ArrayReader): Fork;
|
|
12
|
+
static unmarshal(reader: Uint8ArrayReader, addressLength: number): Fork;
|
|
13
13
|
}
|
|
14
14
|
interface MantarayNodeOptions {
|
|
15
15
|
selfAddress?: Uint8Array;
|
|
@@ -2,17 +2,24 @@ import { BeeRequestOptions, NumberString, RedistributionState, TransactionOption
|
|
|
2
2
|
import { BZZ } from '../../utils/tokens';
|
|
3
3
|
import { TransactionId } from '../../utils/typed-bytes';
|
|
4
4
|
/**
|
|
5
|
-
* Gets the staked
|
|
5
|
+
* Gets the amount of staked BZZ
|
|
6
6
|
*
|
|
7
7
|
* @param requestOptions Options for making requests
|
|
8
8
|
*/
|
|
9
9
|
export declare function getStake(requestOptions: BeeRequestOptions): Promise<BZZ>;
|
|
10
|
+
/**
|
|
11
|
+
* Gets the amount of withdrawable staked BZZ
|
|
12
|
+
*
|
|
13
|
+
* @param requestOptions Options for making requests
|
|
14
|
+
*/
|
|
15
|
+
export declare function getWithdrawableStake(requestOptions: BeeRequestOptions): Promise<BZZ>;
|
|
16
|
+
export declare function withdrawSurplusStake(requestOptions: BeeRequestOptions): Promise<TransactionId>;
|
|
17
|
+
export declare function migrateStake(requestOptions: BeeRequestOptions): Promise<TransactionId>;
|
|
10
18
|
/**
|
|
11
19
|
* Stake given amount of tokens.
|
|
12
20
|
*
|
|
13
21
|
* @param requestOptions Options for making requests
|
|
14
22
|
* @param amount
|
|
15
|
-
* @param options
|
|
16
23
|
*/
|
|
17
24
|
export declare function stake(requestOptions: BeeRequestOptions, amount: NumberString | string | bigint, options?: TransactionOptions): Promise<TransactionId>;
|
|
18
25
|
/**
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { BeeRequestOptions, ChainState, ReserveState, WalletBalance } from '../../types';
|
|
2
|
+
import { BZZ, DAI } from '../../utils/tokens';
|
|
3
|
+
import { EthAddress, TransactionId } from '../../utils/typed-bytes';
|
|
2
4
|
/**
|
|
3
5
|
* Get state of reserve
|
|
4
6
|
*
|
|
@@ -17,3 +19,5 @@ export declare function getChainState(requestOptions: BeeRequestOptions): Promis
|
|
|
17
19
|
* @param requestOptions Options for making requests
|
|
18
20
|
*/
|
|
19
21
|
export declare function getWalletBalance(requestOptions: BeeRequestOptions): Promise<WalletBalance>;
|
|
22
|
+
export declare function withdrawBZZ(requestOptions: BeeRequestOptions, amount: BZZ, address: EthAddress): Promise<TransactionId>;
|
|
23
|
+
export declare function withdrawDAI(requestOptions: BeeRequestOptions, amount: DAI, address: EthAddress): Promise<TransactionId>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BeeRequestOptions } from '../../index';
|
|
2
2
|
import type { DebugStatus, Health, NodeInfo, Readiness } from '../../types/debug';
|
|
3
3
|
import { BeeVersions } from '../../types/debug';
|
|
4
|
-
export declare const SUPPORTED_BEE_VERSION_EXACT = "2.
|
|
4
|
+
export declare const SUPPORTED_BEE_VERSION_EXACT = "2.6.0-d0aa8b93";
|
|
5
5
|
export declare const SUPPORTED_BEE_VERSION: string;
|
|
6
|
-
export declare const SUPPORTED_API_VERSION = "7.
|
|
6
|
+
export declare const SUPPORTED_API_VERSION = "7.3.0";
|
|
7
7
|
export declare function getDebugStatus(requestOptions: BeeRequestOptions): Promise<DebugStatus>;
|
|
8
8
|
/**
|
|
9
9
|
* Get health of node
|
|
@@ -5,3 +5,4 @@ import { BeeRequestOptions } from '../index';
|
|
|
5
5
|
* @param requestOptions Options for making requests
|
|
6
6
|
*/
|
|
7
7
|
export declare function checkConnection(requestOptions: BeeRequestOptions): Promise<void> | never;
|
|
8
|
+
export declare function isGateway(requestOptions: BeeRequestOptions): Promise<boolean>;
|
|
@@ -484,3 +484,69 @@ export interface EnvelopeWithBatchId extends Envelope {
|
|
|
484
484
|
export type NumberString = string & {
|
|
485
485
|
__numberString: never;
|
|
486
486
|
};
|
|
487
|
+
export declare const capacityBreakpoints: {
|
|
488
|
+
ENCRYPTION_OFF: {
|
|
489
|
+
0: {
|
|
490
|
+
theoreticalVolume: string;
|
|
491
|
+
effectiveVolume: string;
|
|
492
|
+
batchDepth: number;
|
|
493
|
+
utilizationRate: string;
|
|
494
|
+
}[];
|
|
495
|
+
1: {
|
|
496
|
+
theoreticalVolume: string;
|
|
497
|
+
effectiveVolume: string;
|
|
498
|
+
batchDepth: number;
|
|
499
|
+
utilizationRate: string;
|
|
500
|
+
}[];
|
|
501
|
+
2: {
|
|
502
|
+
theoreticalVolume: string;
|
|
503
|
+
effectiveVolume: string;
|
|
504
|
+
batchDepth: number;
|
|
505
|
+
utilizationRate: string;
|
|
506
|
+
}[];
|
|
507
|
+
3: {
|
|
508
|
+
theoreticalVolume: string;
|
|
509
|
+
effectiveVolume: string;
|
|
510
|
+
batchDepth: number;
|
|
511
|
+
utilizationRate: string;
|
|
512
|
+
}[];
|
|
513
|
+
4: {
|
|
514
|
+
theoreticalVolume: string;
|
|
515
|
+
effectiveVolume: string;
|
|
516
|
+
batchDepth: number;
|
|
517
|
+
utilizationRate: string;
|
|
518
|
+
}[];
|
|
519
|
+
};
|
|
520
|
+
ENCRYPTION_ON: {
|
|
521
|
+
0: {
|
|
522
|
+
theoreticalVolume: string;
|
|
523
|
+
effectiveVolume: string;
|
|
524
|
+
batchDepth: number;
|
|
525
|
+
utilizationRate: string;
|
|
526
|
+
}[];
|
|
527
|
+
1: {
|
|
528
|
+
theoreticalVolume: string;
|
|
529
|
+
effectiveVolume: string;
|
|
530
|
+
batchDepth: number;
|
|
531
|
+
utilizationRate: string;
|
|
532
|
+
}[];
|
|
533
|
+
2: {
|
|
534
|
+
theoreticalVolume: string;
|
|
535
|
+
effectiveVolume: string;
|
|
536
|
+
batchDepth: number;
|
|
537
|
+
utilizationRate: string;
|
|
538
|
+
}[];
|
|
539
|
+
3: {
|
|
540
|
+
theoreticalVolume: string;
|
|
541
|
+
effectiveVolume: string;
|
|
542
|
+
batchDepth: number;
|
|
543
|
+
utilizationRate: string;
|
|
544
|
+
}[];
|
|
545
|
+
4: {
|
|
546
|
+
theoreticalVolume: string;
|
|
547
|
+
effectiveVolume: string;
|
|
548
|
+
batchDepth: number;
|
|
549
|
+
utilizationRate: string;
|
|
550
|
+
}[];
|
|
551
|
+
};
|
|
552
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EnvelopeWithBatchId, NumberString } from '../types';
|
|
1
|
+
import { EnvelopeWithBatchId, NumberString, RedundancyLevel } from '../types';
|
|
2
2
|
import { Bytes } from './bytes';
|
|
3
3
|
import { Duration } from './duration';
|
|
4
4
|
import { Size } from './size';
|
|
@@ -27,8 +27,8 @@ export declare function getStampTheoreticalBytes(depth: number): number;
|
|
|
27
27
|
*
|
|
28
28
|
* @returns {number} The effective size of the postage batch in bytes.
|
|
29
29
|
*/
|
|
30
|
-
export declare function getStampEffectiveBytes(depth: number): number;
|
|
31
|
-
export declare function getStampEffectiveBytesBreakpoints(): Map<number, number>;
|
|
30
|
+
export declare function getStampEffectiveBytes(depth: number, encryption?: boolean, erasureCodeLevel?: RedundancyLevel): number;
|
|
31
|
+
export declare function getStampEffectiveBytesBreakpoints(encryption: boolean, erasureCodeLevel?: RedundancyLevel): Map<number, number>;
|
|
32
32
|
/**
|
|
33
33
|
* Utility function that calculates the cost of a postage batch based on its depth and amount.
|
|
34
34
|
*/
|
|
@@ -55,6 +55,6 @@ export declare function getAmountForDuration(duration: Duration, pricePerBlock:
|
|
|
55
55
|
* @param size The effective size of the postage batch
|
|
56
56
|
* @returns
|
|
57
57
|
*/
|
|
58
|
-
export declare function getDepthForSize(size: Size): number;
|
|
58
|
+
export declare function getDepthForSize(size: Size, encryption?: boolean, erasureCodeLevel?: RedundancyLevel): number;
|
|
59
59
|
export declare function convertEnvelopeToMarshaledStamp(envelope: EnvelopeWithBatchId): Bytes;
|
|
60
60
|
export declare function marshalStamp(signature: Uint8Array, batchId: Uint8Array, timestamp: Uint8Array, index: Uint8Array): Bytes;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@upcoming/bee-js",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.7.0",
|
|
4
4
|
"description": "Javascript client for Bee",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bee",
|
|
@@ -55,14 +55,14 @@
|
|
|
55
55
|
"build:node": "tsc -p tsconfig.json && tsc -p tsconfig-mjs.json && ./build-fixup && babel --plugins \"babel-plugin-add-import-extension\" --out-dir dist/mjs/ dist/mjs/",
|
|
56
56
|
"build:types": "tsc --emitDeclarationOnly --declaration --outDir dist/types",
|
|
57
57
|
"build:browser": "webpack --progress",
|
|
58
|
-
"test": "jest --config=jest.config.ts --runInBand --verbose",
|
|
58
|
+
"test": "jest --config=jest.config.ts --runInBand --verbose --forceExit",
|
|
59
59
|
"check": "tsc --project tsconfig.test.json",
|
|
60
60
|
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\" && prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
61
61
|
"depcheck": "depcheck ."
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"axios": "^0.30.0",
|
|
65
|
-
"cafe-utility": "^
|
|
65
|
+
"cafe-utility": "^31.0.0",
|
|
66
66
|
"isomorphic-ws": "^4.0.1",
|
|
67
67
|
"semver": "^7.3.5",
|
|
68
68
|
"ws": "^8.7.0"
|