Skip to content

Commit 5647049

Browse files
slapec93Gergely Békési
andauthored
chore: update core, use Bytes.concat (#1242)
* chore: update core, use Bytes.concat * chore: update rc wf bee version --------- Co-authored-by: Gergely Békési <gergely.bekesi@ethswarm.org>
1 parent c013bdf commit 5647049

8 files changed

Lines changed: 17 additions & 19 deletions

File tree

.github/workflows/tests-rc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
run: bee-dev --port 16337 &
3535

3636
- name: Start bee-factory
37-
run: bee-factory start
37+
run: bee-factory start --tag v2.8.2-rc1
3838

3939
- name: Create managed postage batch
4040
run: echo "JEST_MANAGED_BATCH_ID=$(swarm-cli stamp buy --depth 20 --amount 1b --quiet)" >> $GITHUB_ENV

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"debug": "^4.4.3",
7272
"isomorphic-ws": "^5.0.0",
7373
"semver": "^7.3.5",
74-
"swarm-core": "npm:@upcoming/swarm-core@0.0.8",
74+
"swarm-core": "npm:@upcoming/swarm-core@0.0.9",
7575
"ws": "^8.21.0",
7676
"zod": "^4.4.3"
7777
},

src/chunk/soc.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
Reference,
99
SingleOwnerChunk,
1010
Span,
11-
concatBytes,
1211
makeContentAddressedChunk,
1312
makeSOCAddress,
1413
makeSingleOwnerChunk as coreMakeSingleOwnerChunk,
@@ -58,7 +57,7 @@ export function makeSingleOwnerChunk(
5857
): SingleOwnerChunk {
5958
identifier = new Identifier(identifier)
6059
signer = new PrivateKey(signer)
61-
const wrappedChunk = { data: concatBytes(span.toUint8Array(), payload.toUint8Array()), span, payload, address }
60+
const wrappedChunk = { data: Bytes.concat(span.toUint8Array(), payload.toUint8Array()), span, payload, address }
6261

6362
return coreMakeSingleOwnerChunk(wrappedChunk, identifier, signer.toBigInt())
6463
}
@@ -79,7 +78,7 @@ export async function uploadSingleOwnerChunk(
7978
stamp: BatchId | Uint8Array | string,
8079
options?: UploadOptions,
8180
): Promise<UploadResult> {
82-
const data = concatBytes(chunk.span.toUint8Array(), chunk.payload.toUint8Array())
81+
const data = Bytes.concat(chunk.span.toUint8Array(), chunk.payload.toUint8Array())
8382

8483
return socAPI.upload(requestOptions, chunk.owner, chunk.identifier, chunk.signature, data, stamp, options)
8584
}

src/feed/identifier.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { FeedIndex, Identifier, Topic, concatBytes, keccak256 } from 'swarm-core'
1+
import { Bytes, FeedIndex, Identifier, Topic, keccak256 } from 'swarm-core'
22

33
export function makeFeedIdentifier(topic: Topic, index: FeedIndex | number): Identifier {
44
index = typeof index === 'number' ? FeedIndex.fromBigInt(BigInt(index)) : index
55

6-
return new Identifier(keccak256(concatBytes(topic.toUint8Array(), index.toUint8Array())))
6+
return new Identifier(keccak256(Bytes.concat(topic.toUint8Array(), index.toUint8Array())))
77
}

src/feed/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
PrivateKey,
1010
Reference,
1111
Topic,
12-
concatBytes,
1312
keccak256,
1413
makeContentAddressedChunk,
1514
numberToUint64,
@@ -86,7 +85,7 @@ export async function updateFeedWithReference(
8685
const identifier = makeFeedIdentifier(topic, nextIndex)
8786
const at = options?.at ?? Date.now() / 1000.0
8887
const timestamp = numberToUint64(BigInt(Math.floor(at)), 'BE')
89-
const payloadBytes = concatBytes(timestamp, reference.toUint8Array())
88+
const payloadBytes = Bytes.concat(timestamp, reference.toUint8Array())
9089

9190
return uploadSingleOwnerChunkData(requestOptions, signer, postageBatchId, identifier, payloadBytes, options)
9291
}
@@ -132,7 +131,7 @@ export async function updateFeedWithPayload(
132131
export function getFeedUpdateChunkReference(owner: EthAddress, topic: Topic, index: FeedIndex): Reference {
133132
const identifier = makeFeedIdentifier(topic, index)
134133

135-
return new Reference(keccak256(concatBytes(identifier.toUint8Array(), owner.toUint8Array())))
134+
return new Reference(keccak256(Bytes.concat(identifier.toUint8Array(), owner.toUint8Array())))
136135
}
137136

138137
export async function downloadFeedUpdate(

test/integration/download-ens.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ReadStream } from 'fs'
2-
import { concatBytes } from 'swarm-core'
2+
import { Bytes } from 'swarm-core'
33
import { MantarayNode, NULL_ADDRESS } from '../../src'
44
import { makeBee } from '../utils'
55

@@ -36,7 +36,7 @@ test.skip('GET readable bytes (ENS)', async () => {
3636
parts.push(part)
3737
}
3838

39-
const data = concatBytes(...parts)
39+
const data = Bytes.concat(...parts)
4040

4141
const manifest = MantarayNode.unmarshalFromData(data, NULL_ADDRESS)
4242
await manifest.loadRecursively(bee)

test/integration/upload.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Types } from 'cafe-utility'
22
import { ReadStream } from 'fs'
3-
import { ChunkSplitter, PrivateKey, Span, concatBytes, makeContentAddressedChunk } from 'swarm-core'
3+
import { Bytes, ChunkSplitter, PrivateKey, Span, makeContentAddressedChunk } from 'swarm-core'
44
import { BeeRequest, BeeRequestOptions, MantarayNode, NULL_ADDRESS } from '../../src'
55
import { makeCollectionFromFileList } from '../../src/utils/collection'
66
import { batch, makeBee } from '../utils'
@@ -21,7 +21,7 @@ test('POST encrypted data', async () => {
2121
for await (const chunk of stream) {
2222
chunks.push(chunk)
2323
}
24-
const concatenated = concatBytes(...chunks)
24+
const concatenated = Bytes.concat(...chunks)
2525
expect(decoder.decode(concatenated)).toBe(data)
2626
})
2727

@@ -37,7 +37,7 @@ test('POST encrypted file', async () => {
3737
for await (const chunk of stream) {
3838
chunks.push(chunk)
3939
}
40-
const concatenated = concatBytes(...chunks)
40+
const concatenated = Bytes.concat(...chunks)
4141
expect(decoder.decode(concatenated)).toBe(await file.text())
4242
})
4343

0 commit comments

Comments
 (0)