-
Notifications
You must be signed in to change notification settings - Fork 11
cbor decode for emitted events ; spellings #331
base: master
Are you sure you want to change the base?
Conversation
packages/common/src/bytes.ts
Outdated
@@ -3,7 +3,7 @@ | |||
* @param keystring is the EthHex encoding of the value | |||
* @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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔
packages/service/src/coder/oasis.ts
Outdated
@@ -43,7 +43,8 @@ export class OasisCoder implements RpcCoder { | |||
} | |||
|
|||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
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);
?
There was a problem hiding this comment.
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
packages/service/src/coder/oasis.ts
Outdated
@@ -43,7 +43,8 @@ export class OasisCoder implements RpcCoder { | |||
} | |||
|
|||
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const event = cbor.decode(eventBytes); | |
const event = cbor.decode(payloadBytes); |
to get CI to pass, you'll want to update the toolchain installed in |
1f1aee7
to
1cedcb3
Compare
This PR:
packages/service/src/coder/oasis.ts
when decoding a subscription event.