Skip to content

Commit 8a9c94b

Browse files
authored
fix: use uint8 instead of int8 for instruction serialization (#79)
We have some instructions to update product metadata that have size of more than int8 max (127) and the on-chain program reads them as u8. So we are switching to UInt8 instead.
1 parent af0239d commit 8a9c94b

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pythnetwork/client",
3-
"version": "2.21.0",
3+
"version": "2.21.1",
44
"description": "Client for consuming Pyth price data",
55
"homepage": "https://pyth.network",
66
"main": "lib/index.js",

src/anchor/coder/instructions.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ export class PythOracleInstructionCoder implements InstructionCoder {
9393
if (methodName === 'updProduct' || methodName === 'addProduct') {
9494
let offset = 0
9595
for (const key of Object.keys(ix.productMetadata)) {
96-
offset += buffer.subarray(offset).writeInt8(key.length)
96+
offset += buffer.subarray(offset).writeUInt8(key.length)
9797
offset += buffer.subarray(offset).write(key)
98-
offset += buffer.subarray(offset).writeInt8(ix.productMetadata[key].length)
98+
offset += buffer.subarray(offset).writeUInt8(ix.productMetadata[key].length)
9999
offset += buffer.subarray(offset).write(ix.productMetadata[key])
100100
}
101101
if (offset > MAX_METADATA_SIZE) {

0 commit comments

Comments
 (0)