Skip to content

Commit

Permalink
Update deprecation message with a specific version
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaptic committed Nov 30, 2023
1 parent e8b205d commit 5dd5ece
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 92 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/npm_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
178 changes: 89 additions & 89 deletions test/unit/server/get_events_test.js
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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
Expand All @@ -34,35 +34,35 @@ 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
.getEvents({
startLedger: 1,
filters: [
{
topics: [["*", "*"]],
},
],
topics: [['*', '*']]
}
]
})
.then(function (response) {
expect(response).to.be.deep.equal(parseEvents(result));
Expand All @@ -71,38 +71,38 @@ 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
.getEvents({
startLedger: 1,
filters: [
{
topics: [[topicVals[0], topicVals[1]]],
},
],
topics: [[topicVals[0], topicVals[1]]]
}
]
})
.then(function (response) {
expect(response).to.be.deep.equal(parseEvents(result));
Expand All @@ -111,38 +111,38 @@ 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
.getEvents({
startLedger: 2,
filters: [
{
topics: [[topicVals[0], "*"]],
},
],
topics: [[topicVals[0], '*']]
}
]
})
.then(function (response) {
expect(response).to.be.deep.equal(parseEvents(result));
Expand All @@ -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));

Expand All @@ -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));
Expand All @@ -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] === '*')
);
}

Expand All @@ -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 } }));
}
Expand All @@ -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
}
}
];

0 comments on commit 5dd5ece

Please sign in to comment.