Skip to content
This repository was archived by the owner on Oct 6, 2021. It is now read-only.

cbor decode for emitted events ; spellings#331

Open
ssavvides wants to merge 4 commits into
masterfrom
ss/cbor
Open

cbor decode for emitted events ; spellings#331
ssavvides wants to merge 4 commits into
masterfrom
ss/cbor

Conversation

@ssavvides
Copy link
Copy Markdown
Contributor

This PR:

  • Fixes a bug in packages/service/src/coder/oasis.ts when decoding a subscription event.
  • Fixes some minor spelling mistakes

@ssavvides ssavvides requested a review from nhynes December 3, 2019 07:09
Comment thread packages/common/src/bytes.ts Outdated
* @param littleEndian is true if the keystring should be interpreted as
* little endian. Otherwise, defaults to big endian.
* @returns the byte incoding of the value
* @returns the byte encoding of the value
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔

Comment thread packages/service/src/coder/oasis.ts Outdated

public async decodeSubscriptionEvent(e: any, _idl: Idl): Promise<any> {
const event = cbor.decode(bytes.parseHex(e.data));
const eventBytes = bytes.parseHex(e.data).slice(4); // remove size of event
Copy link
Copy Markdown
Contributor

@nhynes nhynes Dec 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const eventBytes = bytes.parseHex(e.data).slice(4); // remove size of event
const eventBytes = bytes.parseHex(e.data);
const payloadSize = new Uint32Array(new Uint8Array(eventBytes.splice(0, 4)))[0];
const payloadBytes = eventBytes).slice(payloadSize);

probably best not to ignore it. at the very least it's a sanity check

Copy link
Copy Markdown
Contributor Author

@ssavvides ssavvides Dec 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this meant to be const payloadBytes = eventBytes.slice(-payloadSize);?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah. (0, payloadSize) thanks for catching

Comment thread packages/service/src/coder/oasis.ts Outdated
public async decodeSubscriptionEvent(e: any, _idl: Idl): Promise<any> {
const event = cbor.decode(bytes.parseHex(e.data));
const eventBytes = bytes.parseHex(e.data).slice(4); // remove size of event
const event = cbor.decode(eventBytes);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const event = cbor.decode(eventBytes);
const event = cbor.decode(payloadBytes);

@nhynes
Copy link
Copy Markdown
Contributor

nhynes commented Dec 3, 2019

to get CI to pass, you'll want to update the toolchain installed in .circleci/config.yml to unstable

@nhynes nhynes force-pushed the master branch 2 times, most recently from 1f1aee7 to 1cedcb3 Compare February 21, 2020 16:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants