Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fine-tune act namings #946

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/bee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
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'
Expand All @@ -23,6 +22,7 @@
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'
Expand All @@ -49,6 +49,8 @@
FeedWriter,
FileData,
FileUploadOptions,
GetGranteesResult,
GranteesResult,
Health,
JsonFeedOptions,
LastCashoutActionResponse,
Expand Down Expand Up @@ -82,8 +84,6 @@
UploadOptions,
UploadRedundancyOptions,
UploadResultWithCid,
GranteesResult,
GetGranteesResult,
WalletBalance,
} from './types'
import {
Expand Down Expand Up @@ -325,7 +325,7 @@
*
* @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,
Expand All @@ -345,27 +345,27 @@
* @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<GranteesResult> {
assertBatchId(postageBatchId)

return grantee.patchGrantees(
reference,
histrory,
postageBatchId,
grantees,
reference,
history,
{ add: grantees.add || [], revoke: grantees.revoke || [] },
this.getRequestOptionsForCall(requestOptions),
)
}

/**
* 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
Expand Down Expand Up @@ -411,7 +411,7 @@
ReferenceType.MANIFEST,
)
} else if (isReadable(data) && options?.tag && !options.size) {
// TODO: Needed until https://github.com/ethersphere/bee/issues/2317 is resolved

Check warning on line 414 in src/bee.ts

View workflow job for this annotation

GitHub Actions / check (16.x)

Unexpected 'todo' comment: 'TODO: Needed until...'
const result = await bzz.uploadFile(
this.getRequestOptionsForCall(requestOptions),
data,
Expand Down Expand Up @@ -789,7 +789,7 @@
await this.makeFeedReader(type, canonicalTopic, canonicalOwner).download()

return true
} catch (e: any) {

Check warning on line 792 in src/bee.ts

View workflow job for this annotation

GitHub Actions / check (16.x)

Unexpected any. Specify a different type
if (e?.response?.status === 404) {
return false
}
Expand Down Expand Up @@ -1883,7 +1883,7 @@
if (stamp.usable) {
return
}
} catch (error: any) {}

Check warning on line 1886 in src/bee.ts

View workflow job for this annotation

GitHub Actions / check (16.x)

Unexpected any. Specify a different type

Check warning on line 1886 in src/bee.ts

View workflow job for this annotation

GitHub Actions / check (16.x)

Empty block statement

await System.sleepMillis(TIME_STEP)
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/bytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'] || '',
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/modules/bzz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'] || '',
}
}

Expand Down Expand Up @@ -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'] || '',
}
}
2 changes: 1 addition & 1 deletion src/modules/chunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'] || '',
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/modules/grantee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<GranteesResult> {
const response = await http<GranteesResult>(requestOptions, {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/soc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'] || '',
}
}
2 changes: 1 addition & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export interface UploadResult {
/**
* History address of the uploaded data with ACT.
*/
history_address: string
historyAddress: string
}

export interface UploadOptions {
Expand Down
8 changes: 4 additions & 4 deletions test/integration/modules/bzz.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -13,7 +14,6 @@ import {
invalidReference,
randomByteArray,
} from '../../utils'
import { http } from '../../../src/utils/http'

const BEE_KY_OPTIONS = beeKyOptions()

Expand Down Expand Up @@ -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 () {
Expand All @@ -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(
Expand All @@ -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)
})
Expand Down
13 changes: 6 additions & 7 deletions test/integration/modules/grantee.spec.ts
Original file line number Diff line number Diff line change
@@ -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()

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Loading