From 0900c8e20b518db2755fc138763223fc2598b52c Mon Sep 17 00:00:00 2001 From: Yuhang Shi Date: Wed, 17 Jul 2024 15:45:33 +0800 Subject: [PATCH] fix: correct Buffer.from hex string input fix: TypeError: Invalid hex string Changed Buffer.from("0", "hex") to Buffer.from("00", "hex") to ensure a valid even-length hex string input. This prevents creation of an empty Buffer and correctly creates a Buffer of length 1 containing 0x00. --- src/raydium/tradeV2/trade.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/raydium/tradeV2/trade.ts b/src/raydium/tradeV2/trade.ts index 7b339a8f..5e2c89d8 100644 --- a/src/raydium/tradeV2/trade.ts +++ b/src/raydium/tradeV2/trade.ts @@ -655,7 +655,7 @@ export default class TradeV2 extends ModuleBase { decimals: p.mintA.decimals, isInitialized: true, freezeAuthority: null, - tlvData: Buffer.from("0", "hex"), + tlvData: Buffer.from("00", "hex"), feeConfig: undefined, }; @@ -668,7 +668,7 @@ export default class TradeV2 extends ModuleBase { decimals: p.mintB.decimals, isInitialized: true, freezeAuthority: null, - tlvData: Buffer.from("0", "hex"), + tlvData: Buffer.from("00", "hex"), feeConfig: undefined, }; }); @@ -691,7 +691,7 @@ export default class TradeV2 extends ModuleBase { decimals: p.mintDecimalA, isInitialized: true, freezeAuthority: null, - tlvData: Buffer.from("0", "hex"), + tlvData: Buffer.from("00", "hex"), feeConfig: undefined, }; } else mintSet.add(mintA); // 2022, need to fetch fee config @@ -705,7 +705,7 @@ export default class TradeV2 extends ModuleBase { decimals: p.mintDecimalB, isInitialized: true, freezeAuthority: null, - tlvData: Buffer.from("0", "hex"), + tlvData: Buffer.from("00", "hex"), feeConfig: undefined, }; } else mintSet.add(mintB); // 2022, need to fetch fee config