borsh icon indicating copy to clipboard operation
borsh copied to clipboard

Uncaught (in promise) TypeError: reader[capitalizeFirstLetter(...)] is not a function

Open easydeveloppement opened this issue 3 years ago • 2 comments

Hi, I'm trying to decode metadata with metaplex script, and i have the following error : Uncaught (in promise) TypeError: reader[capitalizeFirstLetter(...)] is not a function the filedType is "pubkeyAsString"

What am i doing wrong ?

easydeveloppement avatar Oct 10 '21 01:10 easydeveloppement

You are trying to serialize a type which is not supported. What is your schema?

unordered-set avatar Oct 12 '21 22:10 unordered-set


class Payload {
  constructor(
    public amountIn: number,
    public minimumAmountOut: number,
    public amount: number,
    public otherAmountThreshold: number,
    public sqrtPriceLimit: number,
    public amountSpecifiedIsInput: boolean,
    public aToB: boolean,
  ) {}
}

const PayloadSchema = new Map([
  [Payload, { kind: 'struct', fields: [
    ['amountIn', 'u64'],
    ['minimumAmountOut', 'u64'],
    ['amount', 'u64'],
    ['otherAmountThreshold', 'u64'],
    ['sqrtPriceLimit', 'u128'],
    ['amountSpecifiedIsInput', 'bool'],
    ['aToB', 'bool'],
  ]}],
]);

const payload = new Payload(
  100000,
  1,
  100000,
  785,
  4295048016,
  true,
  true,
);

const encodedPayload = borsh.serialize(PayloadSchema, payload);

arpit04 avatar Mar 03 '23 07:03 arpit04