diff --git a/CHANGELOG.md b/CHANGELOG.md index f19966e8d3..4bae0713a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,9 +36,10 @@ Changes before Tatum release are not documented in this file. - **BREAKING CHANGE:** Type `StreamMetadata` is `Record` (https://github.com/streamr-dev/network/pull/2825, https://github.com/streamr-dev/network/pull/2845) - some new accessors available, see above - no default values are injected (https://github.com/streamr-dev/network/pull/2851) -- **BREAKING CHANGE:** Method `Stream#update()` overwrites metadata instead of merging it (https://github.com/streamr-dev/network/pull/2826) - **BREAKING CHANGE:** Method `Stream#addToStorageNode()` doesn't wait for acknowledgment by default (https://github.com/streamr-dev/network/pull/2810) -- **BREAKING CHANGE:** Parameters and return type of method `StreamrClient#updateStream()` (https://github.com/streamr-dev/network/pull/2859, https://github.com/streamr-dev/network/pull/2855) +- **BREAKING CHANGE:** Replace methods `StreamrClient#updateStream()` and `Stream#update()`: (https://github.com/streamr-dev/network/pull/2826, https://github.com/streamr-dev/network/pull/2855, https://github.com/streamr-dev/network/pull/2859, https://github.com/streamr-dev/network/pull/2862) + - use `StreamrClient#setStreamMetadata()` and `Stream#setMetadata()` instead + - both methods overwrite metadata instead of merging it - Upgrade `StreamRegistry` from v4 to v5 (https://github.com/streamr-dev/network/pull/2780) - Network-level changes: - avoid routing through proxy connections (https://github.com/streamr-dev/network/pull/2801) diff --git a/packages/sdk/src/Stream.ts b/packages/sdk/src/Stream.ts index 55f28f0fdc..4157b309e8 100644 --- a/packages/sdk/src/Stream.ts +++ b/packages/sdk/src/Stream.ts @@ -94,8 +94,8 @@ export class Stream { /** * Updates the metadata of the stream. */ - async update(metadata: StreamMetadata): Promise { - await this.client.updateStream(this.id, metadata) + async setMetadata(metadata: StreamMetadata): Promise { + await this.client.setStreamMetadata(this.id, metadata) this.metadata = metadata } @@ -159,8 +159,8 @@ export class Stream { /** * See {@link StreamrClient.removeStreamFromStorageNode | StreamrClient.removeStreamFromStorageNode}. */ - async removeFromStorageNode(storageNodeAddress: HexString): Promise { - return this.client.removeStreamFromStorageNode(this.id, toEthereumAddress(storageNodeAddress)) + async removeFromStorageNode(nodeAddress: HexString): Promise { + return this.client.removeStreamFromStorageNode(this.id, toEthereumAddress(nodeAddress)) } /** @@ -207,7 +207,7 @@ export class Stream { fields } }) - await this.update(merged) + await this.setMetadata(merged) } /** @@ -231,7 +231,7 @@ export class Stream { } async setDescription(description: string): Promise { - await this.update({ + await this.setMetadata({ ...this.getMetadata(), description }) @@ -253,7 +253,7 @@ export class Stream { * Sets the value of `storageDays` field */ async setStorageDayCount(count: number): Promise { - await this.update({ + await this.setMetadata({ ...this.getMetadata(), storageDays: count }) diff --git a/packages/sdk/src/StreamrClient.ts b/packages/sdk/src/StreamrClient.ts index 8132b38c74..1f1049d126 100644 --- a/packages/sdk/src/StreamrClient.ts +++ b/packages/sdk/src/StreamrClient.ts @@ -402,9 +402,9 @@ export class StreamrClient { /** * Updates the metadata of a stream. */ - async updateStream(streamIdOrPath: string, metadata: StreamMetadata): Promise { + async setStreamMetadata(streamIdOrPath: string, metadata: StreamMetadata): Promise { const streamId = await this.streamIdBuilder.toStreamID(streamIdOrPath) - await this.streamRegistry.updateStreamMetadata(streamId, metadata) + await this.streamRegistry.setStreamMetadata(streamId, metadata) } /** diff --git a/packages/sdk/src/contracts/StreamRegistry.ts b/packages/sdk/src/contracts/StreamRegistry.ts index 111f45951c..990304fefe 100644 --- a/packages/sdk/src/contracts/StreamRegistry.ts +++ b/packages/sdk/src/contracts/StreamRegistry.ts @@ -256,7 +256,7 @@ export class StreamRegistry { } } - async updateStreamMetadata(streamId: StreamID, metadata: StreamMetadata): Promise { + async setStreamMetadata(streamId: StreamID, metadata: StreamMetadata): Promise { await this.connectToContract() const ethersOverrides = await getEthersOverrides(this.rpcProviderSource, this.config) await waitForTx(this.streamRegistryContract!.updateStreamMetadata( diff --git a/packages/sdk/test/end-to-end/StreamRegistry.test.ts b/packages/sdk/test/end-to-end/StreamRegistry.test.ts index 223407306c..ddc2d743aa 100644 --- a/packages/sdk/test/end-to-end/StreamRegistry.test.ts +++ b/packages/sdk/test/end-to-end/StreamRegistry.test.ts @@ -236,10 +236,10 @@ describe('StreamRegistry', () => { }, TIMEOUT) }) - describe('update', () => { + describe('setMetadata', () => { it('happy path', async () => { const description = `description-${Date.now()}` - await createdStream.update({ + await createdStream.setMetadata({ description }) await until(async () => { diff --git a/packages/sdk/test/test-utils/fake/FakeStreamRegistry.ts b/packages/sdk/test/test-utils/fake/FakeStreamRegistry.ts index a8379096cd..c09fd85fcd 100644 --- a/packages/sdk/test/test-utils/fake/FakeStreamRegistry.ts +++ b/packages/sdk/test/test-utils/fake/FakeStreamRegistry.ts @@ -57,7 +57,7 @@ export class FakeStreamRegistry implements Methods { } } - async updateStreamMetadata(streamId: StreamID, metadata: StreamMetadata): Promise { + async setStreamMetadata(streamId: StreamID, metadata: StreamMetadata): Promise { const registryItem = this.chain.getStream(streamId) if (registryItem === undefined) { throw new Error('Stream not found') diff --git a/packages/sdk/test/unit/Stream.test.ts b/packages/sdk/test/unit/Stream.test.ts index 1870d1172e..7818930d28 100644 --- a/packages/sdk/test/unit/Stream.test.ts +++ b/packages/sdk/test/unit/Stream.test.ts @@ -34,10 +34,10 @@ describe('Stream', () => { }) }) - describe('update', () => { + describe('setMetadata', () => { it('fields not updated if transaction fails', async () => { const client: Partial = { - updateStream: jest.fn().mockRejectedValue(new Error('mock-error')), + setStreamMetadata: jest.fn().mockRejectedValue(new Error('mock-error')), } const stream = new Stream(toStreamID('mock-id'), { @@ -45,7 +45,7 @@ describe('Stream', () => { }, client as any) await expect(() => { - return stream.update({ + return stream.setMetadata({ description: 'updated-description' }) }).rejects.toThrow('mock-error')