Skip to content

Commit 232994d

Browse files
authored
Parse new events schema more reliably and release rc.3 (#1186)
* Turns out the arrays are omitted when empty
1 parent 19ccb64 commit 232994d

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ A breaking change will get clearly marked in this log.
77
## Unreleased
88

99

10+
## [v14.0.0-rc.3](https://github.com/stellar/js-stellar-sdk/compare/v13.1.0...v14.0.0-rc.3)
11+
12+
### Fixed
13+
* Fixes a bug in `Rpc.Server.getTransaction` where either `transactionEventsXdr` and/or `contractEventsXdr` may not be present in the new `events` field.
14+
15+
1016
## [v14.0.0-rc.2](https://github.com/stellar/js-stellar-sdk/compare/v13.1.0...v14.0.0-rc.2)
1117

1218
### Breaking Changes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@stellar/stellar-sdk",
3-
"version": "14.0.0-rc.2",
3+
"version": "14.0.0-rc.3",
44
"description": "A library for working with the Stellar network, including communication with the Horizon and Soroban RPC servers.",
55
"keywords": [
66
"stellar"

src/rpc/api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ export namespace Api {
139139
}
140140

141141
export interface RawTransactionEvents {
142-
transactionEventsXdr: string[];
143-
contractEventsXdr: string[][];
142+
transactionEventsXdr?: string[];
143+
contractEventsXdr?: string[][];
144144
}
145145

146146
export interface RawTransactionInfo {

src/rpc/parsers.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ export function parseTransactionInfo(
4747
resultXdr: xdr.TransactionResult.fromXDR(raw.resultXdr!, 'base64'),
4848
resultMetaXdr: meta,
4949
events: {
50-
contractEventsXdr: raw.events?.contractEventsXdr.map(
50+
contractEventsXdr: (raw.events?.contractEventsXdr ?? []).map(
5151
lst => lst.map(e => xdr.ContractEvent.fromXDR(e, "base64"))
52-
) ?? [],
53-
transactionEventsXdr: raw.events?.transactionEventsXdr.map(
52+
),
53+
transactionEventsXdr: (raw.events?.transactionEventsXdr ?? []).map(
5454
e => xdr.TransactionEvent.fromXDR(e, "base64")
55-
) ?? [],
56-
}
55+
),
56+
},
5757
};
5858

5959
switch (meta.switch()) {

0 commit comments

Comments
 (0)