From ae5817fc27ce9020c66b12171909162993160eec Mon Sep 17 00:00:00 2001 From: Ali Behjati Date: Fri, 21 Jun 2024 15:41:00 +0200 Subject: [PATCH] fix: use uint8 instead of int8 for instruction serialization 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. --- package-lock.json | 4 ++-- package.json | 2 +- src/anchor/coder/instructions.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index fe417fb..d9080fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@pythnetwork/client", - "version": "2.20.0", + "version": "2.21.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@pythnetwork/client", - "version": "2.20.0", + "version": "2.21.1", "license": "Apache-2.0", "dependencies": { "@coral-xyz/anchor": "^0.29.0", diff --git a/package.json b/package.json index 2621321..e17962b 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/anchor/coder/instructions.ts b/src/anchor/coder/instructions.ts index 22bd93c..695b780 100644 --- a/src/anchor/coder/instructions.ts +++ b/src/anchor/coder/instructions.ts @@ -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) {