diff --git a/src/bee.ts b/src/bee.ts index fda7b36b..44d33c1d 100644 --- a/src/bee.ts +++ b/src/bee.ts @@ -10,7 +10,6 @@ import { makeTopic, makeTopicFromString } from './feed/topic' import { DEFAULT_FEED_TYPE, FeedType, assertFeedType } from './feed/type' import * as bytes from './modules/bytes' import * as bzz from './modules/bzz' -import * as grantee from './modules/grantee' import * as chunk from './modules/chunk' import * as balance from './modules/debug/balance' import * as chequebook from './modules/debug/chequebook' @@ -23,6 +22,7 @@ import * as debugStatus from './modules/debug/status' import * as debugTag from './modules/debug/tag' import * as transactions from './modules/debug/transactions' import { createFeedManifest } from './modules/feed' +import * as grantee from './modules/grantee' import * as pinning from './modules/pinning' import * as pss from './modules/pss' import * as status from './modules/status' @@ -49,6 +49,8 @@ import type { FeedWriter, FileData, FileUploadOptions, + GetGranteesResult, + GranteesResult, Health, JsonFeedOptions, LastCashoutActionResponse, @@ -82,8 +84,6 @@ import type { UploadOptions, UploadRedundancyOptions, UploadResultWithCid, - GranteesResult, - GetGranteesResult, WalletBalance, } from './types' import { @@ -325,7 +325,7 @@ export class Bee { * * @param reference - The reference. * @param requestOptions - Optional request options. - * @returns A promise that resolves to a `GetGranteesResult object. + * @returns A promise that resolves to a `GetGranteesResult` object. */ async getGrantees( reference: ReferenceOrEns | string, @@ -345,19 +345,19 @@ export class Bee { * @returns A Promise that resolves to to a `GranteesResult` object. */ async patchGrantees( - reference: Reference | string, - histrory: Reference | string, postageBatchId: string | BatchId, - grantees: string, + reference: Reference | string, + history: Reference | string, + grantees: { add?: string[]; revoke?: string[] }, requestOptions?: BeeRequestOptions, ): Promise { assertBatchId(postageBatchId) return grantee.patchGrantees( - reference, - histrory, postageBatchId, - grantees, + reference, + history, + { add: grantees.add || [], revoke: grantees.revoke || [] }, this.getRequestOptionsForCall(requestOptions), ) } @@ -365,7 +365,7 @@ export class Bee { /** * Upload single file to a Bee node. * - * **To make sure that you won't loose critical data it is highly recommended to also + * **To make sure that you won't lose critical data it is highly recommended to also * locally pin the data with `options.pin = true`** * * @param postageBatchId Postage BatchId to be used to upload the data with diff --git a/src/modules/bytes.ts b/src/modules/bytes.ts index c39f1360..a756c49b 100644 --- a/src/modules/bytes.ts +++ b/src/modules/bytes.ts @@ -44,7 +44,7 @@ export async function upload( return { reference: response.data.reference, tagUid: response.headers['swarm-tag'] ? makeTagUid(response.headers['swarm-tag']) : undefined, - history_address: response.headers['swarm-act-history-address'] || '', + historyAddress: response.headers['swarm-act-history-address'] || '', } } diff --git a/src/modules/bzz.ts b/src/modules/bzz.ts index 1706b563..f54bd72e 100644 --- a/src/modules/bzz.ts +++ b/src/modules/bzz.ts @@ -78,7 +78,7 @@ export async function uploadFile( return { reference: response.data.reference, tagUid: response.headers['swarm-tag'] ? makeTagUid(response.headers['swarm-tag']) : undefined, - history_address: response.headers['swarm-act-history-address'] || '', + historyAddress: response.headers['swarm-act-history-address'] || '', } } @@ -181,6 +181,6 @@ export async function uploadCollection( return { reference: response.data.reference, tagUid: response.headers['swarm-tag'] ? makeTagUid(response.headers['swarm-tag']) : undefined, - history_address: response.headers['swarm-act-history-address'] || '', + historyAddress: response.headers['swarm-act-history-address'] || '', } } diff --git a/src/modules/chunk.ts b/src/modules/chunk.ts index ef2ff11d..725ec139 100644 --- a/src/modules/chunk.ts +++ b/src/modules/chunk.ts @@ -46,7 +46,7 @@ export async function upload( return { reference: response.data.reference, tagUid: response.headers['swarm-tag'] ? makeTagUid(response.headers['swarm-tag']) : undefined, - history_address: response.headers['swarm-act-history-address'] || '', + historyAddress: response.headers['swarm-act-history-address'] || '', } } diff --git a/src/modules/grantee.ts b/src/modules/grantee.ts index 3699692d..37ec1d68 100644 --- a/src/modules/grantee.ts +++ b/src/modules/grantee.ts @@ -42,10 +42,10 @@ export async function createGrantees( } export async function patchGrantees( + postageBatchId: BatchId, reference: string, historyRef: string, - postageBatchId: BatchId, - grantees: string, + grantees: { add?: string[]; revoke?: string[] }, requestOptions: BeeRequestOptions, ): Promise { const response = await http(requestOptions, { diff --git a/src/modules/soc.ts b/src/modules/soc.ts index 2319ef15..2c455071 100644 --- a/src/modules/soc.ts +++ b/src/modules/soc.ts @@ -40,6 +40,6 @@ export async function upload( return { reference: response.data.reference, tagUid: response.headers['swarm-tag'] ? makeTagUid(response.headers['swarm-tag']) : undefined, - history_address: response.headers['swarm-act-history-address'] || '', + historyAddress: response.headers['swarm-act-history-address'] || '', } } diff --git a/src/types/index.ts b/src/types/index.ts index a7f59fd3..17c31ed1 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -141,7 +141,7 @@ export interface UploadResult { /** * History address of the uploaded data with ACT. */ - history_address: string + historyAddress: string } export interface UploadOptions { diff --git a/test/integration/modules/bzz.spec.ts b/test/integration/modules/bzz.spec.ts index dfd8102a..ea8b0dee 100644 --- a/test/integration/modules/bzz.spec.ts +++ b/test/integration/modules/bzz.spec.ts @@ -5,6 +5,7 @@ import * as bzz from '../../../src/modules/bzz' import * as tag from '../../../src/modules/tag' import { BatchId, Collection, ENCRYPTED_REFERENCE_HEX_LENGTH } from '../../../src/types' import { makeCollectionFromFS } from '../../../src/utils/collection.node' +import { http } from '../../../src/utils/http' import { BIG_FILE_TIMEOUT, actBeeKyOptions, @@ -13,7 +14,6 @@ import { invalidReference, randomByteArray, } from '../../utils' -import { http } from '../../../src/utils/http' const BEE_KY_OPTIONS = beeKyOptions() @@ -42,7 +42,7 @@ describe('modules/bzz', () => { it('should upload with act', async function () { const result = await bzz.uploadFile(BEE_KY_OPTIONS, data, batchID, 'act-1.txt', { act: true }) expect(result.reference).to.have.lengthOf(64) - expect(result.history_address).to.have.lengthOf(64) + expect(result.historyAddress).to.have.lengthOf(64) }) it('should not be able to download without ACT header', async function () { @@ -56,7 +56,7 @@ describe('modules/bzz', () => { const result = await bzz.uploadFile(BEE_KY_OPTIONS, data, batchID, 'act-2.txt', { act: true }) const requestOptionsBad = actBeeKyOptions( '0x1234567890123456789012345678901234567890123456789012345678901234', - result.history_address, + result.historyAddress, '1', ) await expect(bzz.downloadFile(requestOptionsBad, result.reference)).rejectedWith( @@ -67,7 +67,7 @@ describe('modules/bzz', () => { it('should download with ACT and valid publicKey', async function () { const filename = 'act-3.txt' const result = await bzz.uploadFile(BEE_KY_OPTIONS, data, batchID, filename, { act: true }) - const requestOptionsOK = actBeeKyOptions(publicKey, result.history_address, '1') + const requestOptionsOK = actBeeKyOptions(publicKey, result.historyAddress, '1') const dFile = await bzz.downloadFile(requestOptionsOK, result.reference, filename) expect(Buffer.from(dFile.data).toString()).to.eql(data) }) diff --git a/test/integration/modules/grantee.spec.ts b/test/integration/modules/grantee.spec.ts index 476f4515..7a0c32bc 100644 --- a/test/integration/modules/grantee.spec.ts +++ b/test/integration/modules/grantee.spec.ts @@ -1,9 +1,9 @@ +import { assert, expect } from 'chai' +import * as bzz from '../../../src/modules/bzz' +import * as grantee from '../../../src/modules/grantee' import { BatchId } from '../../../src/types' import { http } from '../../../src/utils/http' import { actBeeKyOptions, beeKyOptions } from '../../utils' -import * as bzz from '../../../src/modules/bzz' -import * as grantee from '../../../src/modules/grantee' -import { assert, expect } from 'chai' const BEE_KY_OPTIONS = beeKyOptions() @@ -39,7 +39,6 @@ describe('modules/grantee', () => { ], } - const patchGranteesString = JSON.stringify(patchGrantees) it('should create grantee list', async function () { const response = await grantee.createGrantees(BEE_KY_OPTIONS, batchID, grantees) expect(response.ref).to.have.lengthOf(128) @@ -63,10 +62,10 @@ describe('modules/grantee', () => { const createResponse = await grantee.createGrantees(BEE_KY_OPTIONS, batchID, grantees) await new Promise(resolve => setTimeout(resolve, 1000)) const patchResponse = await grantee.patchGrantees( - createResponse.ref, - uploadResult.history_address, batchID, - patchGranteesString, + createResponse.ref, + uploadResult.historyAddress, + patchGrantees, BEE_KY_OPTIONS, ) const list = await grantee.getGrantees(patchResponse.ref, BEE_KY_OPTIONS)