borsh
borsh copied to clipboard
Uncaught (in promise) TypeError: reader[capitalizeFirstLetter(...)] is not a function
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 ?
You are trying to serialize a type which is not supported. What is your schema?
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);