@ethersphere/bee-js 3.3.2 → 3.4.0-pre.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.
Files changed (48) hide show
  1. package/dist/cjs/utils/data.browser.js +6 -10
  2. package/dist/cjs/utils/data.js +4 -6
  3. package/dist/index.browser.min.js +1 -1
  4. package/dist/index.browser.min.js.map +1 -1
  5. package/dist/mjs/bee-debug.js +294 -189
  6. package/dist/mjs/bee.js +316 -237
  7. package/dist/mjs/chunk/signer.js +46 -12
  8. package/dist/mjs/chunk/soc.js +71 -31
  9. package/dist/mjs/chunk/span.js +1 -1
  10. package/dist/mjs/feed/index.js +86 -42
  11. package/dist/mjs/feed/json.js +46 -10
  12. package/dist/mjs/index.js +2 -1
  13. package/dist/mjs/modules/bytes.js +61 -24
  14. package/dist/mjs/modules/bzz.js +96 -58
  15. package/dist/mjs/modules/chunk.js +51 -16
  16. package/dist/mjs/modules/debug/balance.js +60 -20
  17. package/dist/mjs/modules/debug/chequebook.js +115 -67
  18. package/dist/mjs/modules/debug/chunk.js +47 -11
  19. package/dist/mjs/modules/debug/connectivity.js +76 -32
  20. package/dist/mjs/modules/debug/settlements.js +46 -10
  21. package/dist/mjs/modules/debug/stamps.js +91 -47
  22. package/dist/mjs/modules/debug/states.js +48 -12
  23. package/dist/mjs/modules/debug/status.js +97 -49
  24. package/dist/mjs/modules/debug/tag.js +39 -5
  25. package/dist/mjs/modules/debug/transactions.js +65 -25
  26. package/dist/mjs/modules/feed.js +50 -16
  27. package/dist/mjs/modules/pinning.js +67 -27
  28. package/dist/mjs/modules/pss.js +44 -10
  29. package/dist/mjs/modules/soc.js +47 -14
  30. package/dist/mjs/modules/status.js +37 -3
  31. package/dist/mjs/modules/stewardship.js +46 -10
  32. package/dist/mjs/modules/tag.js +73 -31
  33. package/dist/mjs/utils/collection.browser.js +41 -4
  34. package/dist/mjs/utils/collection.js +45 -11
  35. package/dist/mjs/utils/collection.node.js +137 -42
  36. package/dist/mjs/utils/data.browser.js +88 -53
  37. package/dist/mjs/utils/data.js +57 -22
  38. package/dist/mjs/utils/error.js +0 -9
  39. package/dist/mjs/utils/eth.js +68 -32
  40. package/dist/mjs/utils/file.js +42 -8
  41. package/dist/mjs/utils/headers.js +4 -4
  42. package/dist/mjs/utils/http.js +110 -64
  43. package/dist/mjs/utils/merge.js +2 -2
  44. package/dist/mjs/utils/stream.js +0 -4
  45. package/dist/mjs/utils/type.js +6 -6
  46. package/dist/types/utils/data.browser.d.ts +0 -1
  47. package/dist/types/utils/data.d.ts +2 -2
  48. package/package.json +14 -13
@@ -1,3 +1,35 @@
1
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) {
3
+ return value instanceof P ? value : new P(function (resolve) {
4
+ resolve(value);
5
+ });
6
+ }
7
+
8
+ return new (P || (P = Promise))(function (resolve, reject) {
9
+ function fulfilled(value) {
10
+ try {
11
+ step(generator.next(value));
12
+ } catch (e) {
13
+ reject(e);
14
+ }
15
+ }
16
+
17
+ function rejected(value) {
18
+ try {
19
+ step(generator["throw"](value));
20
+ } catch (e) {
21
+ reject(e);
22
+ }
23
+ }
24
+
25
+ function step(result) {
26
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
27
+ }
28
+
29
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
30
+ });
31
+ };
32
+
1
33
  import { extractUploadHeaders, readFileHeaders } from "../utils/headers.js";
2
34
  import { http } from "../utils/http.js";
3
35
  import { prepareData } from "../utils/data.js";
@@ -10,8 +42,8 @@ const bzzEndpoint = 'bzz';
10
42
 
11
43
  function extractFileUploadHeaders(postageBatchId, options) {
12
44
  const headers = extractUploadHeaders(postageBatchId, options);
13
- if (options?.size) headers['content-length'] = String(options.size);
14
- if (options?.contentType) headers['content-type'] = options.contentType;
45
+ if (options === null || options === void 0 ? void 0 : options.size) headers['content-length'] = String(options.size);
46
+ if (options === null || options === void 0 ? void 0 : options.contentType) headers['content-type'] = options.contentType;
15
47
  return headers;
16
48
  }
17
49
  /**
@@ -25,27 +57,28 @@ function extractFileUploadHeaders(postageBatchId, options) {
25
57
  */
26
58
 
27
59
 
28
- export async function uploadFile(ky, data, postageBatchId, name, options) {
29
- if (isReadable(data) && !options?.contentType) {
30
- if (!options) options = {};
31
- options.contentType = 'application/octet-stream';
32
- }
60
+ export function uploadFile(ky, data, postageBatchId, name, options) {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ if (isReadable(data) && !(options === null || options === void 0 ? void 0 : options.contentType)) {
63
+ if (!options) options = {};
64
+ options.contentType = 'application/octet-stream';
65
+ }
33
66
 
34
- const response = await http(ky, {
35
- method: 'post',
36
- path: bzzEndpoint,
37
- body: await prepareData(data),
38
- headers: { ...extractFileUploadHeaders(postageBatchId, options)
39
- },
40
- searchParams: {
41
- name
42
- },
43
- responseType: 'json'
67
+ const response = yield http(ky, {
68
+ method: 'post',
69
+ path: bzzEndpoint,
70
+ body: yield prepareData(data),
71
+ headers: Object.assign({}, extractFileUploadHeaders(postageBatchId, options)),
72
+ searchParams: {
73
+ name
74
+ },
75
+ responseType: 'json'
76
+ });
77
+ return {
78
+ reference: response.data.reference,
79
+ tagUid: makeTagUid(response.headers.get('swarm-tag'))
80
+ };
44
81
  });
45
- return {
46
- reference: response.data.reference,
47
- tagUid: makeTagUid(response.headers.get('swarm-tag'))
48
- };
49
82
  }
50
83
  /**
51
84
  * Download single file as a buffer
@@ -55,16 +88,18 @@ export async function uploadFile(ky, data, postageBatchId, name, options) {
55
88
  * @param path If hash is collection then this defines path to a single file in the collection
56
89
  */
57
90
 
58
- export async function downloadFile(ky, hash, path = '') {
59
- const response = await http(ky, {
60
- method: 'GET',
61
- responseType: 'arraybuffer',
62
- path: `${bzzEndpoint}/${hash}/${path}`
91
+ export function downloadFile(ky, hash, path = '') {
92
+ return __awaiter(this, void 0, void 0, function* () {
93
+ const response = yield http(ky, {
94
+ method: 'GET',
95
+ responseType: 'arraybuffer',
96
+ path: `${bzzEndpoint}/${hash}/${path}`
97
+ });
98
+ const file = Object.assign(Object.assign({}, readFileHeaders(response.headers)), {
99
+ data: wrapBytesWithHelpers(new Uint8Array(response.data))
100
+ });
101
+ return file;
63
102
  });
64
- const file = { ...readFileHeaders(response.headers),
65
- data: wrapBytesWithHelpers(new Uint8Array(response.data))
66
- };
67
- return file;
68
103
  }
69
104
  /**
70
105
  * Download single file as a readable stream
@@ -74,22 +109,24 @@ export async function downloadFile(ky, hash, path = '') {
74
109
  * @param path If hash is collection then this defines path to a single file in the collection
75
110
  */
76
111
 
77
- export async function downloadFileReadable(ky, hash, path = '') {
78
- const response = await http(ky, {
79
- method: 'GET',
80
- responseType: 'stream',
81
- path: `${bzzEndpoint}/${hash}/${path}`
112
+ export function downloadFileReadable(ky, hash, path = '') {
113
+ return __awaiter(this, void 0, void 0, function* () {
114
+ const response = yield http(ky, {
115
+ method: 'GET',
116
+ responseType: 'stream',
117
+ path: `${bzzEndpoint}/${hash}/${path}`
118
+ });
119
+ const file = Object.assign(Object.assign({}, readFileHeaders(response.headers)), {
120
+ data: response.data
121
+ });
122
+ return file;
82
123
  });
83
- const file = { ...readFileHeaders(response.headers),
84
- data: response.data
85
- };
86
- return file;
87
124
  }
88
125
 
89
126
  function extractCollectionUploadHeaders(postageBatchId, options) {
90
127
  const headers = extractUploadHeaders(postageBatchId, options);
91
- if (options?.indexDocument) headers['swarm-index-document'] = options.indexDocument;
92
- if (options?.errorDocument) headers['swarm-error-document'] = options.errorDocument;
128
+ if (options === null || options === void 0 ? void 0 : options.indexDocument) headers['swarm-index-document'] = options.indexDocument;
129
+ if (options === null || options === void 0 ? void 0 : options.errorDocument) headers['swarm-error-document'] = options.errorDocument;
93
130
  return headers;
94
131
  }
95
132
  /**
@@ -101,22 +138,23 @@ function extractCollectionUploadHeaders(postageBatchId, options) {
101
138
  */
102
139
 
103
140
 
104
- export async function uploadCollection(ky, collection, postageBatchId, options) {
105
- assertCollection(collection);
106
- const tarData = makeTar(collection);
107
- const response = await http(ky, {
108
- method: 'post',
109
- path: bzzEndpoint,
110
- body: tarData,
111
- responseType: 'json',
112
- headers: {
113
- 'content-type': 'application/x-tar',
114
- 'swarm-collection': 'true',
115
- ...extractCollectionUploadHeaders(postageBatchId, options)
116
- }
141
+ export function uploadCollection(ky, collection, postageBatchId, options) {
142
+ return __awaiter(this, void 0, void 0, function* () {
143
+ assertCollection(collection);
144
+ const tarData = makeTar(collection);
145
+ const response = yield http(ky, {
146
+ method: 'post',
147
+ path: bzzEndpoint,
148
+ body: tarData,
149
+ responseType: 'json',
150
+ headers: Object.assign({
151
+ 'content-type': 'application/x-tar',
152
+ 'swarm-collection': 'true'
153
+ }, extractCollectionUploadHeaders(postageBatchId, options))
154
+ });
155
+ return {
156
+ reference: response.data.reference,
157
+ tagUid: makeTagUid(response.headers.get('swarm-tag'))
158
+ };
117
159
  });
118
- return {
119
- reference: response.data.reference,
120
- tagUid: makeTagUid(response.headers.get('swarm-tag'))
121
- };
122
160
  }
@@ -1,3 +1,35 @@
1
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) {
3
+ return value instanceof P ? value : new P(function (resolve) {
4
+ resolve(value);
5
+ });
6
+ }
7
+
8
+ return new (P || (P = Promise))(function (resolve, reject) {
9
+ function fulfilled(value) {
10
+ try {
11
+ step(generator.next(value));
12
+ } catch (e) {
13
+ reject(e);
14
+ }
15
+ }
16
+
17
+ function rejected(value) {
18
+ try {
19
+ step(generator["throw"](value));
20
+ } catch (e) {
21
+ reject(e);
22
+ }
23
+ }
24
+
25
+ function step(result) {
26
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
27
+ }
28
+
29
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
30
+ });
31
+ };
32
+
1
33
  import { extractUploadHeaders } from "../utils/headers.js";
2
34
  import { http } from "../utils/http.js";
3
35
  import { wrapBytesWithHelpers } from "../utils/bytes.js";
@@ -15,18 +47,19 @@ const endpoint = 'chunks';
15
47
  * @param options Additional options like tag, encryption, pinning
16
48
  */
17
49
 
18
- export async function upload(ky, data, postageBatchId, options) {
19
- const response = await http(ky, {
20
- method: 'post',
21
- path: `${endpoint}`,
22
- body: data,
23
- headers: {
24
- 'content-type': 'application/octet-stream',
25
- ...extractUploadHeaders(postageBatchId, options)
26
- },
27
- responseType: 'json'
50
+ export function upload(ky, data, postageBatchId, options) {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ const response = yield http(ky, {
53
+ method: 'post',
54
+ path: `${endpoint}`,
55
+ body: data,
56
+ headers: Object.assign({
57
+ 'content-type': 'application/octet-stream'
58
+ }, extractUploadHeaders(postageBatchId, options)),
59
+ responseType: 'json'
60
+ });
61
+ return response.data.reference;
28
62
  });
29
- return response.data.reference;
30
63
  }
31
64
  /**
32
65
  * Download chunk data as a byte array
@@ -36,10 +69,12 @@ export async function upload(ky, data, postageBatchId, options) {
36
69
  *
37
70
  */
38
71
 
39
- export async function download(ky, hash) {
40
- const response = await http(ky, {
41
- responseType: 'arraybuffer',
42
- path: `${endpoint}/${hash}`
72
+ export function download(ky, hash) {
73
+ return __awaiter(this, void 0, void 0, function* () {
74
+ const response = yield http(ky, {
75
+ responseType: 'arraybuffer',
76
+ path: `${endpoint}/${hash}`
77
+ });
78
+ return wrapBytesWithHelpers(new Uint8Array(response.data));
43
79
  });
44
- return wrapBytesWithHelpers(new Uint8Array(response.data));
45
80
  }
@@ -1,3 +1,35 @@
1
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) {
3
+ return value instanceof P ? value : new P(function (resolve) {
4
+ resolve(value);
5
+ });
6
+ }
7
+
8
+ return new (P || (P = Promise))(function (resolve, reject) {
9
+ function fulfilled(value) {
10
+ try {
11
+ step(generator.next(value));
12
+ } catch (e) {
13
+ reject(e);
14
+ }
15
+ }
16
+
17
+ function rejected(value) {
18
+ try {
19
+ step(generator["throw"](value));
20
+ } catch (e) {
21
+ reject(e);
22
+ }
23
+ }
24
+
25
+ function step(result) {
26
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
27
+ }
28
+
29
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
30
+ });
31
+ };
32
+
1
33
  import { http } from "../../utils/http.js";
2
34
  const balancesEndpoint = 'balances';
3
35
  const consumedEndpoint = 'consumed';
@@ -7,12 +39,14 @@ const consumedEndpoint = 'consumed';
7
39
  * @param ky Ky debug instance
8
40
  */
9
41
 
10
- export async function getAllBalances(ky) {
11
- const response = await http(ky, {
12
- path: balancesEndpoint,
13
- responseType: 'json'
42
+ export function getAllBalances(ky) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ const response = yield http(ky, {
45
+ path: balancesEndpoint,
46
+ responseType: 'json'
47
+ });
48
+ return response.data;
14
49
  });
15
- return response.data;
16
50
  }
17
51
  /**
18
52
  * Get the balances with a specific peer including prepaid services
@@ -21,12 +55,14 @@ export async function getAllBalances(ky) {
21
55
  * @param address Swarm address of peer
22
56
  */
23
57
 
24
- export async function getPeerBalance(ky, address) {
25
- const response = await http(ky, {
26
- path: `${balancesEndpoint}/${address}`,
27
- responseType: 'json'
58
+ export function getPeerBalance(ky, address) {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ const response = yield http(ky, {
61
+ path: `${balancesEndpoint}/${address}`,
62
+ responseType: 'json'
63
+ });
64
+ return response.data;
28
65
  });
29
- return response.data;
30
66
  }
31
67
  /**
32
68
  * Get the past due consumption balances with all known peers
@@ -34,12 +70,14 @@ export async function getPeerBalance(ky, address) {
34
70
  * @param ky Ky debug instance
35
71
  */
36
72
 
37
- export async function getPastDueConsumptionBalances(ky) {
38
- const response = await http(ky, {
39
- path: consumedEndpoint,
40
- responseType: 'json'
73
+ export function getPastDueConsumptionBalances(ky) {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ const response = yield http(ky, {
76
+ path: consumedEndpoint,
77
+ responseType: 'json'
78
+ });
79
+ return response.data;
41
80
  });
42
- return response.data;
43
81
  }
44
82
  /**
45
83
  * Get the past due consumption balance with a specific peer
@@ -48,10 +86,12 @@ export async function getPastDueConsumptionBalances(ky) {
48
86
  * @param address Swarm address of peer
49
87
  */
50
88
 
51
- export async function getPastDueConsumptionPeerBalance(ky, address) {
52
- const response = await http(ky, {
53
- path: `${consumedEndpoint}/${address}`,
54
- responseType: 'json'
89
+ export function getPastDueConsumptionPeerBalance(ky, address) {
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ const response = yield http(ky, {
92
+ path: `${consumedEndpoint}/${address}`,
93
+ responseType: 'json'
94
+ });
95
+ return response.data;
55
96
  });
56
- return response.data;
57
97
  }
@@ -1,3 +1,35 @@
1
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) {
3
+ return value instanceof P ? value : new P(function (resolve) {
4
+ resolve(value);
5
+ });
6
+ }
7
+
8
+ return new (P || (P = Promise))(function (resolve, reject) {
9
+ function fulfilled(value) {
10
+ try {
11
+ step(generator.next(value));
12
+ } catch (e) {
13
+ reject(e);
14
+ }
15
+ }
16
+
17
+ function rejected(value) {
18
+ try {
19
+ step(generator["throw"](value));
20
+ } catch (e) {
21
+ reject(e);
22
+ }
23
+ }
24
+
25
+ function step(result) {
26
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
27
+ }
28
+
29
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
30
+ });
31
+ };
32
+
1
33
  import { http } from "../../utils/http.js";
2
34
  const chequebookEndpoint = 'chequebook';
3
35
  /**
@@ -6,12 +38,14 @@ const chequebookEndpoint = 'chequebook';
6
38
  * @param ky Ky debug instance
7
39
  */
8
40
 
9
- export async function getChequebookAddress(ky) {
10
- const response = await http(ky, {
11
- path: chequebookEndpoint + '/address',
12
- responseType: 'json'
41
+ export function getChequebookAddress(ky) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const response = yield http(ky, {
44
+ path: chequebookEndpoint + '/address',
45
+ responseType: 'json'
46
+ });
47
+ return response.data;
13
48
  });
14
- return response.data;
15
49
  }
16
50
  /**
17
51
  * Get the balance of the chequebook
@@ -19,12 +53,14 @@ export async function getChequebookAddress(ky) {
19
53
  * @param ky Ky debug instance
20
54
  */
21
55
 
22
- export async function getChequebookBalance(ky) {
23
- const response = await http(ky, {
24
- path: chequebookEndpoint + '/balance',
25
- responseType: 'json'
56
+ export function getChequebookBalance(ky) {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ const response = yield http(ky, {
59
+ path: chequebookEndpoint + '/balance',
60
+ responseType: 'json'
61
+ });
62
+ return response.data;
26
63
  });
27
- return response.data;
28
64
  }
29
65
  /**
30
66
  * Get last cashout action for the peer
@@ -33,12 +69,14 @@ export async function getChequebookBalance(ky) {
33
69
  * @param peer Swarm address of peer
34
70
  */
35
71
 
36
- export async function getLastCashoutAction(ky, peer) {
37
- const response = await http(ky, {
38
- path: chequebookEndpoint + `/cashout/${peer}`,
39
- responseType: 'json'
72
+ export function getLastCashoutAction(ky, peer) {
73
+ return __awaiter(this, void 0, void 0, function* () {
74
+ const response = yield http(ky, {
75
+ path: chequebookEndpoint + `/cashout/${peer}`,
76
+ responseType: 'json'
77
+ });
78
+ return response.data;
40
79
  });
41
- return response.data;
42
80
  }
43
81
  /**
44
82
  * Cashout the last cheque for the peer
@@ -48,24 +86,26 @@ export async function getLastCashoutAction(ky, peer) {
48
86
  * @param options
49
87
  */
50
88
 
51
- export async function cashoutLastCheque(ky, peer, options) {
52
- const headers = {};
89
+ export function cashoutLastCheque(ky, peer, options) {
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ const headers = {};
53
92
 
54
- if (options?.gasPrice) {
55
- headers['gas-price'] = options.gasPrice.toString();
56
- }
93
+ if (options === null || options === void 0 ? void 0 : options.gasPrice) {
94
+ headers['gas-price'] = options.gasPrice.toString();
95
+ }
57
96
 
58
- if (options?.gasLimit) {
59
- headers['gas-limit'] = options.gasLimit.toString();
60
- }
97
+ if (options === null || options === void 0 ? void 0 : options.gasLimit) {
98
+ headers['gas-limit'] = options.gasLimit.toString();
99
+ }
61
100
 
62
- const response = await http(ky, {
63
- method: 'post',
64
- path: chequebookEndpoint + `/cashout/${peer}`,
65
- responseType: 'json',
66
- headers
101
+ const response = yield http(ky, {
102
+ method: 'post',
103
+ path: chequebookEndpoint + `/cashout/${peer}`,
104
+ responseType: 'json',
105
+ headers
106
+ });
107
+ return response.data.transactionHash;
67
108
  });
68
- return response.data.transactionHash;
69
109
  }
70
110
  /**
71
111
  * Get last cheques for the peer
@@ -74,12 +114,14 @@ export async function cashoutLastCheque(ky, peer, options) {
74
114
  * @param peer Swarm address of peer
75
115
  */
76
116
 
77
- export async function getLastChequesForPeer(ky, peer) {
78
- const response = await http(ky, {
79
- path: chequebookEndpoint + `/cheque/${peer}`,
80
- responseType: 'json'
117
+ export function getLastChequesForPeer(ky, peer) {
118
+ return __awaiter(this, void 0, void 0, function* () {
119
+ const response = yield http(ky, {
120
+ path: chequebookEndpoint + `/cheque/${peer}`,
121
+ responseType: 'json'
122
+ });
123
+ return response.data;
81
124
  });
82
- return response.data;
83
125
  }
84
126
  /**
85
127
  * Get last cheques for all peers
@@ -87,12 +129,14 @@ export async function getLastChequesForPeer(ky, peer) {
87
129
  * @param ky Ky debug instance
88
130
  */
89
131
 
90
- export async function getLastCheques(ky) {
91
- const response = await http(ky, {
92
- path: chequebookEndpoint + '/cheque',
93
- responseType: 'json'
132
+ export function getLastCheques(ky) {
133
+ return __awaiter(this, void 0, void 0, function* () {
134
+ const response = yield http(ky, {
135
+ path: chequebookEndpoint + '/cheque',
136
+ responseType: 'json'
137
+ });
138
+ return response.data;
94
139
  });
95
- return response.data;
96
140
  }
97
141
  /**
98
142
  * Deposit tokens from overlay address into chequebook
@@ -103,23 +147,25 @@ export async function getLastCheques(ky) {
103
147
  * @return string Hash of the transaction
104
148
  */
105
149
 
106
- export async function depositTokens(ky, amount, gasPrice) {
107
- const headers = {};
150
+ export function depositTokens(ky, amount, gasPrice) {
151
+ return __awaiter(this, void 0, void 0, function* () {
152
+ const headers = {};
108
153
 
109
- if (gasPrice) {
110
- headers['gas-price'] = gasPrice.toString();
111
- }
154
+ if (gasPrice) {
155
+ headers['gas-price'] = gasPrice.toString();
156
+ }
112
157
 
113
- const response = await http(ky, {
114
- method: 'post',
115
- path: chequebookEndpoint + '/deposit',
116
- responseType: 'json',
117
- searchParams: {
118
- amount: amount.toString(10)
119
- },
120
- headers
158
+ const response = yield http(ky, {
159
+ method: 'post',
160
+ path: chequebookEndpoint + '/deposit',
161
+ responseType: 'json',
162
+ searchParams: {
163
+ amount: amount.toString(10)
164
+ },
165
+ headers
166
+ });
167
+ return response.data.transactionHash;
121
168
  });
122
- return response.data.transactionHash;
123
169
  }
124
170
  /**
125
171
  * Withdraw tokens from the chequebook to the overlay address
@@ -130,21 +176,23 @@ export async function depositTokens(ky, amount, gasPrice) {
130
176
  * @return string Hash of the transaction
131
177
  */
132
178
 
133
- export async function withdrawTokens(ky, amount, gasPrice) {
134
- const headers = {};
179
+ export function withdrawTokens(ky, amount, gasPrice) {
180
+ return __awaiter(this, void 0, void 0, function* () {
181
+ const headers = {};
135
182
 
136
- if (gasPrice) {
137
- headers['gas-price'] = gasPrice.toString();
138
- }
183
+ if (gasPrice) {
184
+ headers['gas-price'] = gasPrice.toString();
185
+ }
139
186
 
140
- const response = await http(ky, {
141
- method: 'post',
142
- path: chequebookEndpoint + '/withdraw',
143
- responseType: 'json',
144
- searchParams: {
145
- amount: amount.toString(10)
146
- },
147
- headers
187
+ const response = yield http(ky, {
188
+ method: 'post',
189
+ path: chequebookEndpoint + '/withdraw',
190
+ responseType: 'json',
191
+ searchParams: {
192
+ amount: amount.toString(10)
193
+ },
194
+ headers
195
+ });
196
+ return response.data.transactionHash;
148
197
  });
149
- return response.data.transactionHash;
150
198
  }