@ethersphere/bee-js 8.3.1 → 9.0.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.
- package/README.md +192 -50
- package/dist/cjs/bee-dev.js +78 -0
- package/dist/cjs/bee.js +341 -417
- package/dist/cjs/chunk/bmt.js +15 -32
- package/dist/cjs/chunk/cac.js +26 -36
- package/dist/cjs/chunk/soc.js +56 -51
- package/dist/cjs/feed/identifier.js +3 -28
- package/dist/cjs/feed/index.js +95 -44
- package/dist/cjs/feed/retrievable.js +11 -22
- package/dist/cjs/index.js +17 -1
- package/dist/cjs/manifest/manifest.js +369 -0
- package/dist/cjs/modules/bytes.js +24 -12
- package/dist/cjs/modules/bzz.js +24 -34
- package/dist/cjs/modules/chunk.js +13 -7
- package/dist/cjs/modules/debug/balance.js +29 -4
- package/dist/cjs/modules/debug/chequebook.js +60 -16
- package/dist/cjs/modules/debug/connectivity.js +82 -4
- package/dist/cjs/modules/debug/settlements.js +22 -2
- package/dist/cjs/modules/debug/stake.js +29 -11
- package/dist/cjs/modules/debug/stamps.js +88 -7
- package/dist/cjs/modules/debug/states.js +25 -3
- package/dist/cjs/modules/debug/status.js +45 -47
- package/dist/cjs/modules/debug/transactions.js +27 -5
- package/dist/cjs/modules/envelope.js +8 -6
- package/dist/cjs/modules/feed.js +25 -10
- package/dist/cjs/modules/grantee.js +18 -12
- package/dist/cjs/modules/gsoc.js +24 -0
- package/dist/cjs/modules/pinning.js +13 -2
- package/dist/cjs/modules/pss.js +9 -3
- package/dist/cjs/modules/soc.js +9 -4
- package/dist/cjs/modules/stewardship.js +7 -3
- package/dist/cjs/modules/tag.js +35 -3
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/stamper/stamper.js +43 -0
- package/dist/cjs/types/debug.js +16 -1
- package/dist/cjs/types/index.js +2 -24
- package/dist/cjs/utils/bytes.js +67 -115
- package/dist/cjs/utils/chunk-size.js +17 -0
- package/dist/cjs/utils/chunk-stream.browser.js +85 -0
- package/dist/cjs/utils/chunk-stream.js +84 -0
- package/dist/cjs/utils/cid.js +5 -6
- package/dist/cjs/utils/collection.browser.js +2 -2
- package/dist/cjs/utils/collection.js +3 -2
- package/dist/cjs/utils/collection.node.js +0 -2
- package/dist/cjs/utils/constants.js +7 -3
- package/dist/cjs/utils/data.browser.js +6 -3
- package/dist/cjs/utils/data.js +8 -4
- package/dist/cjs/utils/duration.js +51 -0
- package/dist/cjs/utils/expose.js +11 -40
- package/dist/cjs/utils/headers.js +79 -52
- package/dist/cjs/utils/http.js +34 -10
- package/dist/cjs/utils/mime.js +78 -0
- package/dist/cjs/utils/pss.js +3 -4
- package/dist/cjs/utils/redundancy.js +18 -14
- package/dist/cjs/utils/resource-locator.js +17 -0
- package/dist/cjs/utils/size.js +35 -0
- package/dist/cjs/utils/stamps.js +67 -51
- package/dist/cjs/utils/tar-uploader.browser.js +2 -2
- package/dist/cjs/utils/tar-uploader.js +2 -2
- package/dist/cjs/utils/tokens.js +144 -0
- package/dist/cjs/utils/type.js +142 -350
- package/dist/cjs/utils/typed-bytes.js +179 -0
- package/dist/cjs/utils/upload-progress.js +2 -0
- package/dist/cjs/utils/url.js +0 -4
- package/dist/cjs/utils/workaround.js +27 -0
- package/dist/index.browser.min.js +1 -2
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee-dev.js +98 -0
- package/dist/mjs/bee.js +367 -411
- package/dist/mjs/chunk/bmt.js +13 -29
- package/dist/mjs/chunk/cac.js +26 -34
- package/dist/mjs/chunk/soc.js +57 -53
- package/dist/mjs/feed/identifier.js +3 -26
- package/dist/mjs/feed/index.js +98 -51
- package/dist/mjs/feed/retrievable.js +12 -23
- package/dist/mjs/index.js +10 -1
- package/dist/mjs/manifest/manifest.js +371 -0
- package/dist/mjs/modules/bytes.js +27 -15
- package/dist/mjs/modules/bzz.js +25 -32
- package/dist/mjs/modules/chunk.js +16 -8
- package/dist/mjs/modules/debug/balance.js +61 -4
- package/dist/mjs/modules/debug/chequebook.js +116 -16
- package/dist/mjs/modules/debug/connectivity.js +144 -3
- package/dist/mjs/modules/debug/settlements.js +46 -2
- package/dist/mjs/modules/debug/stake.js +69 -11
- package/dist/mjs/modules/debug/stamps.js +184 -7
- package/dist/mjs/modules/debug/states.js +55 -3
- package/dist/mjs/modules/debug/status.js +97 -45
- package/dist/mjs/modules/debug/transactions.js +61 -5
- package/dist/mjs/modules/envelope.js +11 -9
- package/dist/mjs/modules/feed.js +26 -10
- package/dist/mjs/modules/grantee.js +35 -13
- package/dist/mjs/modules/gsoc.js +16 -0
- package/dist/mjs/modules/pinning.js +23 -2
- package/dist/mjs/modules/pss.js +10 -4
- package/dist/mjs/modules/soc.js +10 -5
- package/dist/mjs/modules/stewardship.js +14 -4
- package/dist/mjs/modules/tag.js +93 -3
- package/dist/mjs/package.json +2 -1
- package/dist/mjs/stamper/stamper.js +39 -0
- package/dist/mjs/types/debug.js +15 -1
- package/dist/mjs/types/index.js +2 -24
- package/dist/mjs/utils/bytes.js +63 -104
- package/dist/mjs/utils/chunk-size.js +13 -0
- package/dist/mjs/utils/chunk-stream.browser.js +85 -0
- package/dist/mjs/utils/chunk-stream.js +87 -0
- package/dist/mjs/utils/cid.js +5 -6
- package/dist/mjs/utils/collection.browser.js +2 -2
- package/dist/mjs/utils/collection.js +2 -2
- package/dist/mjs/utils/collection.node.js +0 -2
- package/dist/mjs/utils/constants.js +6 -2
- package/dist/mjs/utils/data.browser.js +9 -3
- package/dist/mjs/utils/data.js +12 -4
- package/dist/mjs/utils/duration.js +47 -0
- package/dist/mjs/utils/expose.js +2 -7
- package/dist/mjs/utils/headers.js +73 -48
- package/dist/mjs/utils/http.js +33 -11
- package/dist/mjs/utils/mime.js +75 -0
- package/dist/mjs/utils/pss.js +3 -4
- package/dist/mjs/utils/redundancy.js +18 -8
- package/dist/mjs/utils/resource-locator.js +13 -0
- package/dist/mjs/utils/size.js +31 -0
- package/dist/mjs/utils/stamps.js +47 -44
- package/dist/mjs/utils/tar-uploader.browser.js +2 -2
- package/dist/mjs/utils/tar-uploader.js +2 -2
- package/dist/mjs/utils/tokens.js +139 -0
- package/dist/mjs/utils/type.js +216 -310
- package/dist/mjs/utils/typed-bytes.js +160 -0
- package/dist/mjs/utils/upload-progress.js +1 -0
- package/dist/mjs/utils/url.js +0 -4
- package/dist/mjs/utils/workaround.js +22 -0
- package/dist/types/bee-dev.d.ts +5 -0
- package/dist/types/bee.d.ts +88 -165
- package/dist/types/chunk/bmt.d.ts +2 -2
- package/dist/types/chunk/cac.d.ts +7 -24
- package/dist/types/chunk/soc.d.ts +15 -15
- package/dist/types/feed/identifier.d.ts +2 -4
- package/dist/types/feed/index.d.ts +14 -18
- package/dist/types/feed/retrievable.d.ts +3 -4
- package/dist/types/index.d.ts +28 -1
- package/dist/types/manifest/manifest.d.ts +106 -0
- package/dist/types/modules/bytes.d.ts +8 -5
- package/dist/types/modules/bzz.d.ts +8 -10
- package/dist/types/modules/chunk.d.ts +4 -3
- package/dist/types/modules/debug/balance.d.ts +3 -2
- package/dist/types/modules/debug/chequebook.d.ts +7 -6
- package/dist/types/modules/debug/connectivity.d.ts +5 -3
- package/dist/types/modules/debug/settlements.d.ts +2 -1
- package/dist/types/modules/debug/stake.d.ts +4 -2
- package/dist/types/modules/debug/stamps.d.ts +5 -4
- package/dist/types/modules/debug/status.d.ts +6 -25
- package/dist/types/modules/debug/transactions.d.ts +5 -4
- package/dist/types/modules/envelope.d.ts +3 -2
- package/dist/types/modules/feed.d.ts +20 -16
- package/dist/types/modules/grantee.d.ts +7 -6
- package/dist/types/modules/gsoc.d.ts +7 -0
- package/dist/types/modules/pinning.d.ts +2 -4
- package/dist/types/modules/pss.d.ts +4 -3
- package/dist/types/modules/soc.d.ts +3 -2
- package/dist/types/modules/stewardship.d.ts +4 -4
- package/dist/types/modules/tag.d.ts +2 -1
- package/dist/types/stamper/stamper.d.ts +15 -0
- package/dist/types/types/debug.d.ts +63 -115
- package/dist/types/types/index.d.ts +103 -204
- package/dist/types/utils/bytes.d.ts +16 -90
- package/dist/types/utils/chunk-size.d.ts +1 -0
- package/dist/types/utils/chunk-stream.browser.d.ts +6 -0
- package/dist/types/utils/chunk-stream.d.ts +6 -0
- package/dist/types/utils/cid.d.ts +3 -2
- package/dist/types/utils/collection.browser.d.ts +2 -2
- package/dist/types/utils/collection.d.ts +2 -1
- package/dist/types/utils/collection.node.d.ts +0 -1
- package/dist/types/utils/constants.d.ts +4 -1
- package/dist/types/utils/duration.d.ts +17 -0
- package/dist/types/utils/error.d.ts +2 -2
- package/dist/types/utils/expose.d.ts +2 -7
- package/dist/types/utils/headers.d.ts +3 -4
- package/dist/types/utils/mime.d.ts +1 -0
- package/dist/types/utils/pss.d.ts +2 -2
- package/dist/types/utils/resource-locator.d.ts +6 -0
- package/dist/types/utils/size.d.ts +16 -0
- package/dist/types/utils/stamps.d.ts +27 -33
- package/dist/types/utils/tar-uploader.browser.d.ts +3 -4
- package/dist/types/utils/tar-uploader.d.ts +3 -4
- package/dist/types/utils/tokens.d.ts +77 -0
- package/dist/types/utils/type.d.ts +20 -52
- package/dist/types/utils/typed-bytes.d.ts +68 -0
- package/dist/types/utils/upload-progress.d.ts +4 -0
- package/dist/types/utils/workaround.d.ts +2 -0
- package/package.json +11 -17
- package/dist/cjs/chunk/signer.js +0 -126
- package/dist/cjs/chunk/span.js +0 -25
- package/dist/cjs/feed/json.js +0 -28
- package/dist/cjs/feed/topic.js +0 -25
- package/dist/cjs/feed/type.js +0 -15
- package/dist/cjs/modules/debug/chunk.js +0 -21
- package/dist/cjs/modules/debug/tag.js +0 -19
- package/dist/cjs/utils/eth.js +0 -216
- package/dist/cjs/utils/hash.js +0 -21
- package/dist/cjs/utils/hex.js +0 -150
- package/dist/cjs/utils/reference.js +0 -36
- package/dist/index.browser.min.js.LICENSE.txt +0 -8
- package/dist/mjs/chunk/signer.js +0 -114
- package/dist/mjs/chunk/span.js +0 -21
- package/dist/mjs/feed/json.js +0 -26
- package/dist/mjs/feed/topic.js +0 -19
- package/dist/mjs/feed/type.js +0 -10
- package/dist/mjs/modules/debug/chunk.js +0 -17
- package/dist/mjs/modules/debug/tag.js +0 -15
- package/dist/mjs/utils/eth.js +0 -192
- package/dist/mjs/utils/hash.js +0 -16
- package/dist/mjs/utils/hex.js +0 -135
- package/dist/mjs/utils/reference.js +0 -29
- package/dist/types/chunk/signer.d.ts +0 -31
- package/dist/types/chunk/span.d.ts +0 -10
- package/dist/types/feed/json.d.ts +0 -4
- package/dist/types/feed/topic.d.ts +0 -3
- package/dist/types/feed/type.d.ts +0 -6
- package/dist/types/modules/debug/chunk.d.ts +0 -10
- package/dist/types/modules/debug/tag.d.ts +0 -8
- package/dist/types/utils/eth.d.ts +0 -67
- package/dist/types/utils/hash.d.ts +0 -9
- package/dist/types/utils/hex.d.ts +0 -86
- package/dist/types/utils/reference.d.ts +0 -2
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { FixedPointNumber } from 'cafe-utility';
|
|
2
|
+
export class BZZ {
|
|
3
|
+
constructor(state) {
|
|
4
|
+
this.state = state;
|
|
5
|
+
}
|
|
6
|
+
static fromDecimalString(string) {
|
|
7
|
+
return new BZZ(FixedPointNumber.fromDecimalString(string, BZZ.DIGITS));
|
|
8
|
+
}
|
|
9
|
+
static fromPLUR(plur) {
|
|
10
|
+
return new BZZ(new FixedPointNumber(plur, BZZ.DIGITS));
|
|
11
|
+
}
|
|
12
|
+
toPLURString() {
|
|
13
|
+
return this.state.toString();
|
|
14
|
+
}
|
|
15
|
+
toPLURBigInt() {
|
|
16
|
+
return this.state.value;
|
|
17
|
+
}
|
|
18
|
+
toDecimalString() {
|
|
19
|
+
return this.state.toDecimalString();
|
|
20
|
+
}
|
|
21
|
+
toSignificantDigits(digits) {
|
|
22
|
+
return this.toDecimalString().slice(0, this.toDecimalString().indexOf('.') + digits + 1);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Does not mutate the current BZZ instance.
|
|
26
|
+
*
|
|
27
|
+
* @param other BZZ instance, or amount in PLUR
|
|
28
|
+
* @returns New BZZ instance
|
|
29
|
+
*/
|
|
30
|
+
plus(other) {
|
|
31
|
+
return new BZZ(this.state.add(other instanceof BZZ ? other.state : new FixedPointNumber(other, BZZ.DIGITS)));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Does not mutate the current BZZ instance.
|
|
35
|
+
*
|
|
36
|
+
* @param other BZZ instance, or amount in PLUR
|
|
37
|
+
* @returns New BZZ instance
|
|
38
|
+
*/
|
|
39
|
+
minus(other) {
|
|
40
|
+
return new BZZ(this.state.subtract(other instanceof BZZ ? other.state : new FixedPointNumber(other, BZZ.DIGITS)));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Does not mutate the current BZZ instance.
|
|
44
|
+
*
|
|
45
|
+
* @param other Divisor
|
|
46
|
+
* @returns New BZZ instance
|
|
47
|
+
*/
|
|
48
|
+
divide(other) {
|
|
49
|
+
return new BZZ(this.state.divmod(other)[0]);
|
|
50
|
+
}
|
|
51
|
+
gt(other) {
|
|
52
|
+
return this.state.compare(other.state) === 1;
|
|
53
|
+
}
|
|
54
|
+
gte(other) {
|
|
55
|
+
return this.state.compare(other.state) !== -1;
|
|
56
|
+
}
|
|
57
|
+
lt(other) {
|
|
58
|
+
return this.state.compare(other.state) === -1;
|
|
59
|
+
}
|
|
60
|
+
lte(other) {
|
|
61
|
+
return this.state.compare(other.state) !== 1;
|
|
62
|
+
}
|
|
63
|
+
eq(other) {
|
|
64
|
+
return this.state.compare(other.state) === 0;
|
|
65
|
+
}
|
|
66
|
+
exchangeToDAI(daiPerBzz) {
|
|
67
|
+
return DAI.fromWei(this.state.exchange('*', new FixedPointNumber(daiPerBzz.toWeiBigInt(), DAI.DIGITS), DAI.DIGITS).value);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
BZZ.DIGITS = 16;
|
|
71
|
+
export class DAI {
|
|
72
|
+
constructor(state) {
|
|
73
|
+
this.state = state;
|
|
74
|
+
}
|
|
75
|
+
static fromDecimalString(string) {
|
|
76
|
+
return new DAI(FixedPointNumber.fromDecimalString(string, DAI.DIGITS));
|
|
77
|
+
}
|
|
78
|
+
static fromWei(wei) {
|
|
79
|
+
return new DAI(new FixedPointNumber(wei, DAI.DIGITS));
|
|
80
|
+
}
|
|
81
|
+
toWeiString() {
|
|
82
|
+
return this.state.toString();
|
|
83
|
+
}
|
|
84
|
+
toWeiBigInt() {
|
|
85
|
+
return this.state.value;
|
|
86
|
+
}
|
|
87
|
+
toDecimalString() {
|
|
88
|
+
return this.state.toDecimalString();
|
|
89
|
+
}
|
|
90
|
+
toSignificantDigits(digits) {
|
|
91
|
+
return this.toDecimalString().slice(0, this.toDecimalString().indexOf('.') + digits + 1);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Does not mutate the current DAI instance.
|
|
95
|
+
*
|
|
96
|
+
* @param other DAI instance, or amount in PLUR
|
|
97
|
+
* @returns New DAI instance
|
|
98
|
+
*/
|
|
99
|
+
plus(other) {
|
|
100
|
+
return new DAI(this.state.add(other instanceof DAI ? other.state : new FixedPointNumber(other, DAI.DIGITS)));
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Does not mutate the current DAI instance.
|
|
104
|
+
*
|
|
105
|
+
* @param other DAI instance, or amount in PLUR
|
|
106
|
+
* @returns New DAI instance
|
|
107
|
+
*/
|
|
108
|
+
minus(other) {
|
|
109
|
+
return new DAI(this.state.subtract(other instanceof DAI ? other.state : new FixedPointNumber(other, DAI.DIGITS)));
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Does not mutate the current DAI instance.
|
|
113
|
+
*
|
|
114
|
+
* @param other Divisor
|
|
115
|
+
* @returns New DAI instance
|
|
116
|
+
*/
|
|
117
|
+
divide(other) {
|
|
118
|
+
return new DAI(this.state.divmod(other)[0]);
|
|
119
|
+
}
|
|
120
|
+
gt(other) {
|
|
121
|
+
return this.state.compare(other.state) === 1;
|
|
122
|
+
}
|
|
123
|
+
gte(other) {
|
|
124
|
+
return this.state.compare(other.state) !== -1;
|
|
125
|
+
}
|
|
126
|
+
lt(other) {
|
|
127
|
+
return this.state.compare(other.state) === -1;
|
|
128
|
+
}
|
|
129
|
+
lte(other) {
|
|
130
|
+
return this.state.compare(other.state) !== 1;
|
|
131
|
+
}
|
|
132
|
+
eq(other) {
|
|
133
|
+
return this.state.compare(other.state) === 0;
|
|
134
|
+
}
|
|
135
|
+
exchangeToBZZ(daiPerBzz) {
|
|
136
|
+
return BZZ.fromPLUR(this.state.exchange('/', new FixedPointNumber(daiPerBzz.toWeiBigInt(), DAI.DIGITS), BZZ.DIGITS).value);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
DAI.DIGITS = 18;
|