From 5dd5eceedf52858aeefa29fb510f2f86cc19f05d Mon Sep 17 00:00:00 2001 From: George Kudrayvtsev Date: Mon, 27 Nov 2023 14:22:39 -0800 Subject: [PATCH] Update deprecation message with a specific version --- .github/workflows/npm_publish.yml | 2 +- CHANGELOG.md | 4 +- test/unit/server/get_events_test.js | 178 ++++++++++++++-------------- 3 files changed, 92 insertions(+), 92 deletions(-) diff --git a/.github/workflows/npm_publish.yml b/.github/workflows/npm_publish.yml index 232bde0b..6ee7469e 100644 --- a/.github/workflows/npm_publish.yml +++ b/.github/workflows/npm_publish.yml @@ -27,6 +27,6 @@ jobs: run: | yarn publish npm deprecate soroban-client@latest \ - "⚠️ This package is now deprecated: use the stellar-sdk library! 🚚 All future updates and bug fixes will happen there. Please refer to the migration guide for details on porting your codebase: https://github.com/stellar/js-soroban-client/tree/main/docs/migration.md" + "⚠️ This package is now deprecated: transition to `stellar-sdk@beta`, instead! 🚚 All future updates and bug fixes will happen there. Please refer to the migration guide for details on porting your codebase: https://github.com/stellar/js-soroban-client/tree/main/docs/migration.md" env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index d99c16d4..1d6b8369 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,8 @@ A breaking change should be clearly marked in this log. ## Unreleased ### Fixed -* The `Server.getEvents` method now correctly parses responses without a `contractId` field set: the `events[i].contractId` field on an event will be omitted if there was no ID in the event (e.g. for system events; ([#TODO](https://github.com/stellar/js-stellar-sdk/pull/TODO))). -* The `Server.getEvents()` method will correctly parse the event value as an `xdr.ScVal` rather than an `xdr.DiagnosticEvent` ([#TODO](https://github.com/stellar/js-stellar-sdk/pull/TODO)). +* The `Server.getEvents` method now correctly parses responses without a `contractId` field set: the `events[i].contractId` field on an event will be omitted if there was no ID in the event (e.g. for system events; ([#172](https://github.com/stellar/js-soroban-client/pull/172))). +* The `Server.getEvents()` method will correctly parse the event value as an `xdr.ScVal` rather than an `xdr.DiagnosticEvent` ([#172](https://github.com/stellar/js-soroban-client/pull/172)). ## v1.0.0-beta.4 diff --git a/test/unit/server/get_events_test.js b/test/unit/server/get_events_test.js index 85bc65b5..8beee190 100644 --- a/test/unit/server/get_events_test.js +++ b/test/unit/server/get_events_test.js @@ -1,6 +1,6 @@ const { Server, AxiosClient, nativeToScVal } = SorobanClient; -describe("Server#getEvents", function () { +describe('Server#getEvents', function () { beforeEach(function () { this.server = new Server(serverUrl); this.axiosMock = sinon.mock(AxiosClient); @@ -11,16 +11,16 @@ describe("Server#getEvents", function () { this.axiosMock.restore(); }); - it("requests the correct endpoint", function (done) { + it('requests the correct endpoint', function (done) { let result = { latestLedger: 0, events: [] }; setupMock( this.axiosMock, { filters: [], pagination: {}, - startLedger: "1", + startLedger: '1' }, - result, + result ); this.server @@ -34,25 +34,25 @@ describe("Server#getEvents", function () { }); }); - it("can build wildcard filters", function (done) { + it('can build wildcard filters', function (done) { let result = { latestLedger: 1, - events: filterEvents(getEventsResponseFixture, "*/*"), + events: filterEvents(getEventsResponseFixture, '*/*') }; expect(result.events).to.not.have.lengthOf(0, JSON.stringify(result)); setupMock( this.axiosMock, { - startLedger: "1", + startLedger: '1', filters: [ { - topics: [["*", "*"]], - }, + topics: [['*', '*']] + } ], - pagination: {}, + pagination: {} }, - result, + result ); this.server @@ -60,9 +60,9 @@ describe("Server#getEvents", function () { startLedger: 1, filters: [ { - topics: [["*", "*"]], - }, - ], + topics: [['*', '*']] + } + ] }) .then(function (response) { expect(response).to.be.deep.equal(parseEvents(result)); @@ -71,28 +71,28 @@ describe("Server#getEvents", function () { .catch(done); }); - it("can build matching filters", function (done) { + it('can build matching filters', function (done) { let result = { latestLedger: 1, events: filterEvents( getEventsResponseFixture, - `${topicVals[0]}/${topicVals[1]}`, - ), + `${topicVals[0]}/${topicVals[1]}` + ) }; expect(result.events).to.not.have.lengthOf(0, JSON.stringify(result)); setupMock( this.axiosMock, { - startLedger: "1", + startLedger: '1', filters: [ { - topics: [[topicVals[0], topicVals[1]]], - }, + topics: [[topicVals[0], topicVals[1]]] + } ], - pagination: {}, + pagination: {} }, - result, + result ); this.server @@ -100,9 +100,9 @@ describe("Server#getEvents", function () { startLedger: 1, filters: [ { - topics: [[topicVals[0], topicVals[1]]], - }, - ], + topics: [[topicVals[0], topicVals[1]]] + } + ] }) .then(function (response) { expect(response).to.be.deep.equal(parseEvents(result)); @@ -111,28 +111,28 @@ describe("Server#getEvents", function () { .catch(done); }); - it("can build mixed filters", function (done) { + it('can build mixed filters', function (done) { let result = { latestLedger: 3, events: filterEventsByLedger( filterEvents(getEventsResponseFixture, `${topicVals[0]}/*`), - 2, - ), + 2 + ) }; expect(result.events).to.not.have.lengthOf(0, JSON.stringify(result)); setupMock( this.axiosMock, { - startLedger: "2", + startLedger: '2', filters: [ { - topics: [[topicVals[0], "*"]], - }, + topics: [[topicVals[0], '*']] + } ], - pagination: {}, + pagination: {} }, - result, + result ); this.server @@ -140,9 +140,9 @@ describe("Server#getEvents", function () { startLedger: 2, filters: [ { - topics: [[topicVals[0], "*"]], - }, - ], + topics: [[topicVals[0], '*']] + } + ] }) .then(function (response) { expect(response).to.be.deep.equal(parseEvents(result)); @@ -151,13 +151,13 @@ describe("Server#getEvents", function () { .catch(done); }); - it("can paginate", function (done) { + it('can paginate', function (done) { let result = { latestLedger: 3, events: filterEventsByLedger( - filterEvents(getEventsResponseFixture, "*/*"), - 2, - ), + filterEvents(getEventsResponseFixture, '*/*'), + 2 + ) }; expect(result.events).to.not.have.lengthOf(0, JSON.stringify(result)); @@ -166,26 +166,26 @@ describe("Server#getEvents", function () { { filters: [ { - topics: [["*", "*"]], - }, + topics: [['*', '*']] + } ], pagination: { limit: 10, - cursor: "0164090849041387521-0000000000", - }, + cursor: '0164090849041387521-0000000000' + } }, - result, + result ); this.server .getEvents({ filters: [ { - topics: [["*", "*"]], - }, + topics: [['*', '*']] + } ], - cursor: "0164090849041387521-0000000000", - limit: 10, + cursor: '0164090849041387521-0000000000', + limit: 10 }) .then(function (response) { expect(response).to.be.deep.equal(parseEvents(result)); @@ -196,11 +196,11 @@ describe("Server#getEvents", function () { }); function filterEvents(events, filter) { - const parts = filter.split("/"); + const parts = filter.split('/'); return events.filter( (e, i) => e.topic.length == parts.length && - e.topic.every((s, j) => s === parts[j] || parts[j] === "*"), + e.topic.every((s, j) => s === parts[j] || parts[j] === '*') ); } @@ -212,12 +212,12 @@ function filterEventsByLedger(events, start) { function setupMock(axiosMock, params, result) { axiosMock - .expects("post") + .expects('post') .withArgs(serverUrl, { - jsonrpc: "2.0", + jsonrpc: '2.0', id: 1, - method: "getEvents", - params: params, + method: 'getEvents', + params: params }) .returns(Promise.resolve({ data: { result } })); } @@ -226,64 +226,64 @@ function parseEvents(result) { return SorobanClient.parseRawEvents(result); } -const contractId = "CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE"; +const contractId = 'CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE'; const topicVals = [ - nativeToScVal("transfer", { type: "symbol" }).toXDR("base64"), - nativeToScVal(contractId, { type: "address" }).toXDR("base64"), - nativeToScVal(1234).toXDR("base64"), + nativeToScVal('transfer', { type: 'symbol' }).toXDR('base64'), + nativeToScVal(contractId, { type: 'address' }).toXDR('base64'), + nativeToScVal(1234).toXDR('base64') ]; -let eventVal = nativeToScVal("wassup").toXDR("base64"); +let eventVal = nativeToScVal('wassup').toXDR('base64'); let getEventsResponseFixture = [ { - type: "system", - ledger: "1", - ledgerClosedAt: "2022-11-16T16:10:41Z", + type: 'system', + ledger: '1', + ledgerClosedAt: '2022-11-16T16:10:41Z', contractId, - id: "0164090849041387521-0000000003", - pagingToken: "164090849041387521-3", + id: '0164090849041387521-0000000003', + pagingToken: '164090849041387521-3', inSuccessfulContractCall: true, topic: topicVals.slice(0, 2), value: { - xdr: eventVal, - }, + xdr: eventVal + } }, { - type: "contract", - ledger: "2", - ledgerClosedAt: "2022-11-16T16:10:41Z", + type: 'contract', + ledger: '2', + ledgerClosedAt: '2022-11-16T16:10:41Z', contractId, - id: "0164090849041387521-0000000003", - pagingToken: "164090849041387521-3", + id: '0164090849041387521-0000000003', + pagingToken: '164090849041387521-3', inSuccessfulContractCall: true, topic: topicVals.slice(0, 2), value: { - xdr: eventVal, - }, + xdr: eventVal + } }, { - type: "diagnostic", - ledger: "2", - ledgerClosedAt: "2022-11-16T16:10:41Z", + type: 'diagnostic', + ledger: '2', + ledgerClosedAt: '2022-11-16T16:10:41Z', contractId, - id: "0164090849041387521-0000000003", - pagingToken: "164090849041387521-3", + id: '0164090849041387521-0000000003', + pagingToken: '164090849041387521-3', inSuccessfulContractCall: true, topic: [topicVals[0]], value: { - xdr: eventVal, - }, + xdr: eventVal + } }, { - type: "contract", - ledger: "3", - ledgerClosedAt: "2022-12-14T01:01:20Z", + type: 'contract', + ledger: '3', + ledgerClosedAt: '2022-12-14T01:01:20Z', contractId, - id: "0000000171798695936-0000000001", - pagingToken: "0000000171798695936-0000000001", + id: '0000000171798695936-0000000001', + pagingToken: '0000000171798695936-0000000001', inSuccessfulContractCall: true, topic: topicVals, value: { - xdr: eventVal, - }, - }, + xdr: eventVal + } + } ];