fix string decoding

This commit is contained in:
Jackson Jessup 2022-10-28 14:11:05 -04:00
parent 06d4d98cfe
commit 58ae299b61
1 changed files with 4 additions and 7 deletions

View File

@ -782,8 +782,7 @@ export class AggregatorAccount {
* @param aggregator A preloaded aggregator object. * @param aggregator A preloaded aggregator object.
* @return The name of the aggregator. * @return The name of the aggregator.
*/ */
static getName = (aggregator: any) => static getName = (aggregator: any) => Buffer.from(aggregator.name).toString();
String.fromCharCode(...aggregator.name).replace(/\u0000/g, "");
/** /**
* Returns the aggregator's metadata buffer in a stringified format. * Returns the aggregator's metadata buffer in a stringified format.
@ -791,7 +790,7 @@ export class AggregatorAccount {
* @return The stringified metadata of the aggregator. * @return The stringified metadata of the aggregator.
*/ */
static getMetadata = (aggregator: any) => static getMetadata = (aggregator: any) =>
String.fromCharCode(...aggregator.metadata).replace(/\u0000/g, ""); Buffer.from(aggregator.metadata).toString();
/** /**
* Load and parse AggregatorAccount state based on the program IDL. * Load and parse AggregatorAccount state based on the program IDL.
@ -2156,16 +2155,14 @@ export class OracleQueueAccount {
* @param queue A preloaded queue object. * @param queue A preloaded queue object.
* @return The name of the queue. * @return The name of the queue.
*/ */
static getName = (queue: any) => static getName = (queue: any) => Buffer.from(queue.name).toString();
String.fromCharCode(...queue.name).replace(/\u0000/g, "");
/** /**
* Returns the queue's metadata buffer in a stringified format. * Returns the queue's metadata buffer in a stringified format.
* @param queue A preloaded queue object. * @param queue A preloaded queue object.
* @return The stringified metadata of the queue. * @return The stringified metadata of the queue.
*/ */
static getMetadata = (queue: any) => static getMetadata = (queue: any) => Buffer.from(queue.metadata).toString();
String.fromCharCode(...queue.metadata).replace(/\u0000/g, "");
async loadMint(): Promise<spl.Mint> { async loadMint(): Promise<spl.Mint> {
const queue = await this.loadData(); const queue = await this.loadData();