@upcoming/bee-js 0.1.0 → 0.2.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/README.md +8 -2
- package/dist/cjs/bee.js +59 -9
- package/dist/cjs/chunk/soc.js +2 -2
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/manifest/manifest.js +14 -1
- package/dist/cjs/modules/debug/chequebook.js +6 -5
- package/dist/cjs/modules/debug/connectivity.js +1 -1
- package/dist/cjs/modules/debug/settlements.js +7 -6
- package/dist/cjs/modules/debug/stake.js +5 -4
- package/dist/cjs/modules/debug/states.js +3 -2
- package/dist/cjs/modules/gsoc.js +20 -0
- package/dist/cjs/utils/expose.js +2 -3
- package/dist/cjs/utils/pss.js +3 -3
- package/dist/cjs/utils/stamps.js +8 -21
- package/dist/cjs/utils/tokens.js +48 -0
- package/dist/cjs/utils/type.js +10 -11
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee.js +62 -12
- package/dist/mjs/chunk/soc.js +2 -2
- package/dist/mjs/index.js +1 -0
- package/dist/mjs/manifest/manifest.js +14 -1
- package/dist/mjs/modules/debug/chequebook.js +11 -10
- package/dist/mjs/modules/debug/connectivity.js +3 -3
- package/dist/mjs/modules/debug/settlements.js +13 -12
- package/dist/mjs/modules/debug/stake.js +9 -8
- package/dist/mjs/modules/debug/states.js +5 -4
- package/dist/mjs/modules/gsoc.js +12 -0
- package/dist/mjs/utils/expose.js +1 -1
- package/dist/mjs/utils/pss.js +3 -3
- package/dist/mjs/utils/stamps.js +6 -18
- package/dist/mjs/utils/tokens.js +43 -0
- package/dist/mjs/utils/type.js +20 -10
- package/dist/types/bee.d.ts +7 -6
- package/dist/types/chunk/soc.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/manifest/manifest.d.ts +3 -0
- package/dist/types/modules/debug/stake.d.ts +2 -1
- package/dist/types/modules/gsoc.d.ts +7 -0
- package/dist/types/types/debug.d.ts +17 -16
- package/dist/types/types/index.d.ts +8 -0
- package/dist/types/utils/expose.d.ts +1 -1
- package/dist/types/utils/pss.d.ts +2 -1
- package/dist/types/utils/stamps.d.ts +2 -11
- package/dist/types/utils/tokens.d.ts +21 -0
- package/dist/types/utils/type.d.ts +2 -1
- package/package.json +2 -2
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="ws" />
|
|
2
|
+
import WebSocket from 'isomorphic-ws';
|
|
3
|
+
import { BeeRequestOptions, UploadOptions } from '..';
|
|
4
|
+
import { SingleOwnerChunk } from '../chunk/soc';
|
|
5
|
+
import { BatchId, Reference } from '../utils/typed-bytes';
|
|
6
|
+
export declare function send(requestOptions: BeeRequestOptions, soc: SingleOwnerChunk, stamp: BatchId, options?: UploadOptions): Promise<import("..").UploadResult>;
|
|
7
|
+
export declare function subscribe(url: string, reference: Reference, headers?: Record<string, string>): WebSocket;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BZZ, DAI } from '../utils/tokens';
|
|
2
|
+
import { EthAddress, PeerAddress, PublicKey, TransactionId } from '../utils/typed-bytes';
|
|
2
3
|
import { NumberString } from './index';
|
|
3
4
|
export interface Settlements {
|
|
4
5
|
peer: string;
|
|
5
|
-
received:
|
|
6
|
-
sent:
|
|
6
|
+
received: BZZ;
|
|
7
|
+
sent: BZZ;
|
|
7
8
|
}
|
|
8
9
|
export interface AllSettlements {
|
|
9
|
-
totalReceived:
|
|
10
|
-
totalSent:
|
|
10
|
+
totalReceived: BZZ;
|
|
11
|
+
totalSent: BZZ;
|
|
11
12
|
settlements: Settlements[];
|
|
12
13
|
}
|
|
13
14
|
export interface NodeAddresses {
|
|
14
|
-
overlay:
|
|
15
|
+
overlay: PeerAddress;
|
|
15
16
|
underlay: string[];
|
|
16
17
|
ethereum: EthAddress;
|
|
17
18
|
publicKey: PublicKey;
|
|
@@ -25,8 +26,8 @@ export interface ChequebookAddressResponse {
|
|
|
25
26
|
chequebookAddress: string;
|
|
26
27
|
}
|
|
27
28
|
export interface ChequebookBalanceResponse {
|
|
28
|
-
totalBalance:
|
|
29
|
-
availableBalance:
|
|
29
|
+
totalBalance: BZZ;
|
|
30
|
+
availableBalance: BZZ;
|
|
30
31
|
}
|
|
31
32
|
export interface TransactionOptions {
|
|
32
33
|
/**
|
|
@@ -41,12 +42,12 @@ export interface TransactionOptions {
|
|
|
41
42
|
export type CashoutOptions = TransactionOptions;
|
|
42
43
|
export interface CashoutResult {
|
|
43
44
|
recipient: string;
|
|
44
|
-
lastPayout:
|
|
45
|
+
lastPayout: BZZ;
|
|
45
46
|
bounced: boolean;
|
|
46
47
|
}
|
|
47
48
|
export interface LastCashoutActionResponse {
|
|
48
49
|
peer: string;
|
|
49
|
-
uncashedAmount:
|
|
50
|
+
uncashedAmount: BZZ;
|
|
50
51
|
transactionHash: string | null;
|
|
51
52
|
lastCashedCheque: Cheque | null;
|
|
52
53
|
result: CashoutResult | null;
|
|
@@ -57,7 +58,7 @@ export interface TransactionResponse {
|
|
|
57
58
|
export interface Cheque {
|
|
58
59
|
beneficiary: EthAddress;
|
|
59
60
|
chequebook: EthAddress;
|
|
60
|
-
payout:
|
|
61
|
+
payout: BZZ;
|
|
61
62
|
}
|
|
62
63
|
export interface LastChequesForPeerResponse {
|
|
63
64
|
peer: string;
|
|
@@ -113,7 +114,7 @@ export declare enum BeeModes {
|
|
|
113
114
|
}
|
|
114
115
|
export declare function toBeeMode(value: string): BeeModes;
|
|
115
116
|
export interface RedistributionState {
|
|
116
|
-
minimumGasFunds:
|
|
117
|
+
minimumGasFunds: DAI;
|
|
117
118
|
hasSufficientFunds: boolean;
|
|
118
119
|
isFrozen: boolean;
|
|
119
120
|
isFullySynced: boolean;
|
|
@@ -125,8 +126,8 @@ export interface RedistributionState {
|
|
|
125
126
|
lastSelectedRound: number;
|
|
126
127
|
lastSampleDurationSeconds: number;
|
|
127
128
|
block: number;
|
|
128
|
-
reward:
|
|
129
|
-
fees:
|
|
129
|
+
reward: BZZ;
|
|
130
|
+
fees: DAI;
|
|
130
131
|
isHealthy: boolean;
|
|
131
132
|
}
|
|
132
133
|
/**
|
|
@@ -219,8 +220,8 @@ export interface ChainState {
|
|
|
219
220
|
currentPrice: NumberString;
|
|
220
221
|
}
|
|
221
222
|
export interface WalletBalance {
|
|
222
|
-
bzzBalance:
|
|
223
|
-
nativeTokenBalance:
|
|
223
|
+
bzzBalance: BZZ;
|
|
224
|
+
nativeTokenBalance: DAI;
|
|
224
225
|
chainID: number;
|
|
225
226
|
chequebookContractAddress: string;
|
|
226
227
|
walletAddress: string;
|
|
@@ -261,6 +261,14 @@ export interface PssMessageHandler {
|
|
|
261
261
|
onMessage: (message: Bytes, subscription: PssSubscription) => void;
|
|
262
262
|
onError: (error: BeeError, subscription: PssSubscription) => void;
|
|
263
263
|
}
|
|
264
|
+
export interface GsocSubscription {
|
|
265
|
+
readonly address: EthAddress;
|
|
266
|
+
cancel: () => void;
|
|
267
|
+
}
|
|
268
|
+
export interface GsocMessageHandler {
|
|
269
|
+
onMessage: (message: Bytes, subscription: GsocSubscription) => void;
|
|
270
|
+
onError: (error: BeeError, subscription: GsocSubscription) => void;
|
|
271
|
+
}
|
|
264
272
|
export interface ReferenceResponse {
|
|
265
273
|
reference: Reference;
|
|
266
274
|
}
|
|
@@ -2,4 +2,4 @@ export { getCollectionSize } from './collection';
|
|
|
2
2
|
export { getFolderSize } from './collection.node';
|
|
3
3
|
export { makeMaxTarget } from './pss';
|
|
4
4
|
export { approximateOverheadForRedundancyLevel, getRedundancyStat, getRedundancyStats } from './redundancy';
|
|
5
|
-
export { getAmountForTtl, getDepthForCapacity,
|
|
5
|
+
export { getAmountForTtl, getDepthForCapacity, getStampCost, getStampEffectiveBytes, getStampMaximumCapacityBytes, getStampTtlSeconds, getStampUsage, } from './stamps';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PeerAddress } from './typed-bytes';
|
|
1
2
|
/**
|
|
2
3
|
* Utility function that for given strings/reference takes the most specific
|
|
3
4
|
* target that Bee node will except.
|
|
@@ -5,4 +6,4 @@
|
|
|
5
6
|
* @param target is a non-prefixed hex string Bee address
|
|
6
7
|
* @see [Bee docs - PSS](https://docs.ethswarm.org/docs/develop/tools-and-features/pss)
|
|
7
8
|
*/
|
|
8
|
-
export declare function makeMaxTarget(target: string): string;
|
|
9
|
+
export declare function makeMaxTarget(target: PeerAddress | Uint8Array | string): string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EnvelopeWithBatchId, NumberString } from '../types';
|
|
2
2
|
import { Bytes } from './bytes';
|
|
3
|
+
import { BZZ } from './tokens';
|
|
3
4
|
/**
|
|
4
5
|
* Utility function that calculates usage of postage batch based on its utilization, depth and bucket depth.
|
|
5
6
|
*
|
|
@@ -27,18 +28,8 @@ export declare function getStampMaximumCapacityBytes(depth: number): number;
|
|
|
27
28
|
export declare function getStampEffectiveBytes(depth: number): number;
|
|
28
29
|
/**
|
|
29
30
|
* Utility function that calculates the cost of a postage batch based on its depth and amount.
|
|
30
|
-
*
|
|
31
|
-
* @returns {number} The cost of the postage batch in PLUR (10000000000000000 [1e16] PLUR = 1 BZZ)
|
|
32
|
-
*/
|
|
33
|
-
export declare function getStampCostInPlur(depth: number, amount: NumberString | string | bigint): bigint;
|
|
34
|
-
/**
|
|
35
|
-
* Utility function that calculates the cost of a postage batch based on its depth and amount.
|
|
36
|
-
*
|
|
37
|
-
* The returned number is lossy and should be used for display purposes only.
|
|
38
|
-
*
|
|
39
|
-
* @returns {number} The cost of the postage batch in BZZ (1 BZZ = 10000000000000000 [1e16] PLUR)
|
|
40
31
|
*/
|
|
41
|
-
export declare function
|
|
32
|
+
export declare function getStampCost(depth: number, amount: NumberString | string | bigint): BZZ;
|
|
42
33
|
/**
|
|
43
34
|
* Utility function that calculates the TTL of a postage batch based on its amount, price per block and block time.
|
|
44
35
|
*
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { NumberString } from '..';
|
|
2
|
+
export declare class BZZ {
|
|
3
|
+
static readonly DIGITS = 16;
|
|
4
|
+
private state;
|
|
5
|
+
private constructor();
|
|
6
|
+
static fromDecimalString(string: string): BZZ;
|
|
7
|
+
static fromPLUR(plur: NumberString | string | bigint): BZZ;
|
|
8
|
+
toPLURString(): string;
|
|
9
|
+
toPLURBigInt(): bigint;
|
|
10
|
+
toDecimalString(): string;
|
|
11
|
+
}
|
|
12
|
+
export declare class DAI {
|
|
13
|
+
static readonly DIGITS = 18;
|
|
14
|
+
private state;
|
|
15
|
+
private constructor();
|
|
16
|
+
static fromDecimalString(string: string): DAI;
|
|
17
|
+
static fromWei(wei: NumberString | string | bigint): DAI;
|
|
18
|
+
toWeiString(): string;
|
|
19
|
+
toWeiBigInt(): bigint;
|
|
20
|
+
toDecimalString(): string;
|
|
21
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import * as stream from 'stream';
|
|
3
|
-
import { AllTagsOptions, BeeRequestOptions, CashoutOptions, CollectionUploadOptions, FileUploadOptions, NumberString, PostageBatchOptions, PssMessageHandler, Tag, TransactionOptions, UploadOptions } from '../types';
|
|
3
|
+
import { AllTagsOptions, BeeRequestOptions, CashoutOptions, CollectionUploadOptions, FileUploadOptions, GsocMessageHandler, NumberString, PostageBatchOptions, PssMessageHandler, Tag, TransactionOptions, UploadOptions } from '../types';
|
|
4
4
|
export declare function isReadable(obj: unknown): obj is stream.Readable;
|
|
5
5
|
export declare function asNumberString(value: unknown, options?: {
|
|
6
6
|
name?: string;
|
|
@@ -20,6 +20,7 @@ export declare function assertFileUploadOptions(value: unknown): asserts value i
|
|
|
20
20
|
export declare function assertCollectionUploadOptions(value: unknown): asserts value is CollectionUploadOptions;
|
|
21
21
|
export declare function isTag(value: unknown): value is Tag;
|
|
22
22
|
export declare function assertPssMessageHandler(value: unknown): asserts value is PssMessageHandler;
|
|
23
|
+
export declare function assertGsocMessageHandler(value: unknown): asserts value is GsocMessageHandler;
|
|
23
24
|
export declare function assertPostageBatchOptions(value: unknown): asserts value is PostageBatchOptions;
|
|
24
25
|
export declare function assertTransactionOptions(value: unknown, name?: string): asserts value is TransactionOptions;
|
|
25
26
|
export declare function assertCashoutOptions(value: unknown): asserts value is CashoutOptions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@upcoming/bee-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Javascript client for Bee",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bee",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"axios": "^0.28.1",
|
|
66
|
-
"cafe-utility": "^27.
|
|
66
|
+
"cafe-utility": "^27.6.0",
|
|
67
67
|
"isomorphic-ws": "^4.0.1",
|
|
68
68
|
"semver": "^7.3.5",
|
|
69
69
|
"ws": "^8.7.0"
|