@upcoming/bee-js 0.5.0 → 0.5.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.
@@ -1,4 +1,5 @@
1
1
  import { Types } from 'cafe-utility';
2
+ import { prepareRequestHeaders } from "../../utils/headers.js";
2
3
  import { http } from "../../utils/http.js";
3
4
  import { BZZ } from "../../utils/tokens.js";
4
5
  import { asNumberString } from "../../utils/type.js";
@@ -79,18 +80,11 @@ export async function getLastCashoutAction(requestOptions, peer) {
79
80
  * @param options
80
81
  */
81
82
  export async function cashoutLastCheque(requestOptions, peer, options) {
82
- const headers = {};
83
- if (options?.gasPrice) {
84
- headers['gas-price'] = options.gasPrice.toString();
85
- }
86
- if (options?.gasLimit) {
87
- headers['gas-limit'] = options.gasLimit.toString();
88
- }
89
83
  const response = await http(requestOptions, {
90
84
  method: 'post',
91
85
  url: chequebookEndpoint + `/cashout/${peer}`,
92
86
  responseType: 'json',
93
- headers
87
+ headers: prepareRequestHeaders(null, options)
94
88
  });
95
89
  const body = Types.asObject(response.data, {
96
90
  name: 'response.data'
@@ -1,4 +1,5 @@
1
1
  import { Types } from 'cafe-utility';
2
+ import { prepareRequestHeaders } from "../../utils/headers.js";
2
3
  import { http } from "../../utils/http.js";
3
4
  import { BZZ, DAI } from "../../utils/tokens.js";
4
5
  import { asNumberString } from "../../utils/type.js";
@@ -30,18 +31,11 @@ export async function getStake(requestOptions) {
30
31
  * @param options
31
32
  */
32
33
  export async function stake(requestOptions, amount, options) {
33
- const headers = {};
34
- if (options?.gasPrice) {
35
- headers['gas-price'] = options.gasPrice.toString();
36
- }
37
- if (options?.gasLimit) {
38
- headers['gas-limit'] = options.gasLimit.toString();
39
- }
40
34
  await http(requestOptions, {
41
35
  method: 'post',
42
36
  responseType: 'json',
43
37
  url: `${STAKE_ENDPOINT}/${amount}`,
44
- headers
38
+ headers: prepareRequestHeaders(null, options)
45
39
  });
46
40
  }
47
41
  /**
@@ -100,7 +100,7 @@ export async function rebroadcastTransaction(requestOptions, transactionHash) {
100
100
  export async function cancelTransaction(requestOptions, transactionHash, gasPrice) {
101
101
  const headers = {};
102
102
  if (gasPrice) {
103
- headers['gas-price'] = gasPrice;
103
+ headers['gas-price'] = gasPrice.toString();
104
104
  }
105
105
  const response = await http(requestOptions, {
106
106
  method: 'delete',
@@ -93,6 +93,12 @@ export function prepareRequestHeaders(stamp, nullableOptions) {
93
93
  if (options.actPublisher || options.actHistoryAddress || options.actTimestamp) {
94
94
  headers['swarm-act'] = 'true';
95
95
  }
96
+ if (options.gasPrice) {
97
+ headers['gas-price'] = String(options.gasPrice);
98
+ }
99
+ if (options.gasLimit) {
100
+ headers['gas-limit'] = String(options.gasLimit);
101
+ }
96
102
  return headers;
97
103
  }
98
104
  function isEnvelopeWithBatchId(value) {
@@ -1,6 +1,9 @@
1
- import axios, { AxiosError } from 'axios';
1
+ import axios from 'axios';
2
2
  import { Dates, Objects, Strings, System } from 'cafe-utility';
3
3
  import { BeeResponseError } from "../index.js";
4
+ const {
5
+ AxiosError
6
+ } = axios;
4
7
  const MAX_FAILED_ATTEMPTS = 100000;
5
8
  const DELAY_FAST = 200;
6
9
  const DELAY_SLOW = 1000;
@@ -3,8 +3,8 @@ import * as stream from 'stream';
3
3
  import { TAGS_LIMIT_MAX, TAGS_LIMIT_MIN } from "../types/index.js";
4
4
  import { isFile } from "./file.js";
5
5
  import { PublicKey, Reference } from "./typed-bytes.js";
6
- export function isReadable(obj) {
7
- return typeof stream.Readable !== 'undefined' && obj instanceof stream.Readable;
6
+ export function isReadable(value) {
7
+ return typeof stream.Readable !== 'undefined' && value instanceof stream.Readable;
8
8
  }
9
9
  export function asNumberString(value, options) {
10
10
  if (typeof value === 'bigint') {
@@ -48,7 +48,7 @@ export declare function getLastCheques(requestOptions: BeeRequestOptions): Promi
48
48
  * @param gasPrice Gas Price in WEI for the transaction call
49
49
  * @return string Hash of the transaction
50
50
  */
51
- export declare function depositTokens(requestOptions: BeeRequestOptions, amount: number | NumberString, gasPrice?: NumberString): Promise<TransactionId>;
51
+ export declare function depositTokens(requestOptions: BeeRequestOptions, amount: number | NumberString, gasPrice?: NumberString | string | bigint): Promise<TransactionId>;
52
52
  /**
53
53
  * Withdraw tokens from the chequebook to the overlay address
54
54
  *
@@ -57,4 +57,4 @@ export declare function depositTokens(requestOptions: BeeRequestOptions, amount:
57
57
  * @param gasPrice Gas Price in WEI for the transaction call
58
58
  * @return string Hash of the transaction
59
59
  */
60
- export declare function withdrawTokens(requestOptions: BeeRequestOptions, amount: number | NumberString, gasPrice?: NumberString): Promise<TransactionId>;
60
+ export declare function withdrawTokens(requestOptions: BeeRequestOptions, amount: number | NumberString, gasPrice?: NumberString | string | bigint): Promise<TransactionId>;
@@ -27,4 +27,4 @@ export declare function rebroadcastTransaction(requestOptions: BeeRequestOptions
27
27
  * @param transactionHash Hash of the transaction
28
28
  * @param gasPrice Optional gas price
29
29
  */
30
- export declare function cancelTransaction(requestOptions: BeeRequestOptions, transactionHash: TransactionId, gasPrice?: NumberString): Promise<TransactionId>;
30
+ export declare function cancelTransaction(requestOptions: BeeRequestOptions, transactionHash: TransactionId, gasPrice?: NumberString | string | bigint): Promise<TransactionId>;
@@ -33,11 +33,11 @@ export interface TransactionOptions {
33
33
  /**
34
34
  * Gas price for the cashout transaction in WEI
35
35
  */
36
- gasPrice?: NumberString;
36
+ gasPrice?: NumberString | string | bigint;
37
37
  /**
38
38
  * Gas limit for the cashout transaction in WEI
39
39
  */
40
- gasLimit?: NumberString;
40
+ gasLimit?: NumberString | string | bigint;
41
41
  }
42
42
  export interface CashoutResult {
43
43
  recipient: string;
@@ -398,7 +398,10 @@ export interface PostageBatchOptions {
398
398
  /**
399
399
  * Sets gas price in Wei for the transaction that creates the postage batch
400
400
  */
401
- gasPrice?: NumberString;
401
+ gasPrice?: NumberString | string | bigint;
402
+ /**
403
+ * Controls whether data can be overwritten that was uploaded with this postage batch.
404
+ */
402
405
  immutableFlag?: boolean;
403
406
  /**
404
407
  * The returned Promise will await until the purchased Postage Batch is usable.
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import * as stream from 'stream';
3
3
  import { AllTagsOptions, BeeRequestOptions, CollectionUploadOptions, DownloadOptions, FileUploadOptions, GsocMessageHandler, NumberString, PostageBatchOptions, PssMessageHandler, RedundantUploadOptions, Tag, TransactionOptions, UploadOptions } from '../types';
4
- export declare function isReadable(obj: unknown): obj is stream.Readable;
4
+ export declare function isReadable(value: unknown): value is stream.Readable;
5
5
  export declare function asNumberString(value: unknown, options?: {
6
6
  name?: string;
7
7
  min?: bigint;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upcoming/bee-js",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Javascript client for Bee",
5
5
  "keywords": [
6
6
  "bee",