Skip to content

Commit

Permalink
fix: use uint8 instead of int8 for instruction serialization
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ali-bahjati committed Jun 21, 2024
1 parent af0239d commit ae5817f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pythnetwork/client",
"version": "2.21.0",
"version": "2.21.1",
"description": "Client for consuming Pyth price data",
"homepage": "https://pyth.network",
"main": "lib/index.js",
Expand Down
4 changes: 2 additions & 2 deletions src/anchor/coder/instructions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ export class PythOracleInstructionCoder implements InstructionCoder {
if (methodName === 'updProduct' || methodName === 'addProduct') {
let offset = 0
for (const key of Object.keys(ix.productMetadata)) {
offset += buffer.subarray(offset).writeInt8(key.length)
offset += buffer.subarray(offset).writeUInt8(key.length)
offset += buffer.subarray(offset).write(key)
offset += buffer.subarray(offset).writeInt8(ix.productMetadata[key].length)
offset += buffer.subarray(offset).writeUInt8(ix.productMetadata[key].length)
offset += buffer.subarray(offset).write(ix.productMetadata[key])
}
if (offset > MAX_METADATA_SIZE) {
Expand Down

0 comments on commit ae5817f

Please sign in to comment.