near / borsh

Binary Object Representation Serializer for Hashing
https://borsh.io/
487 stars 41 forks source link

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

Open easydeveloppement opened 2 years ago

easydeveloppement commented 2 years ago

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 ?

unordered-set commented 2 years ago

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

arpit04 commented 1 year ago


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);