[英]encoding typescript lib "solana/buffer-layout"
error when I try to encode scheme from solana contract当我尝试从 solana 合同编码方案时出错
const settingsSchema = lo.struct([
lo.ns64("cost"),
lo.u32("width"),
lo.u32("height"),
lo.u16("max_players"),
])
error message: Type 'UInt' is not assignable to type 'Layout<never>'
Type 'NearInt64' is not assignable to type 'Layout<never>'
Type 'Sequence<number>' is not assignable to type 'Layout<never>'
错误消息:
Type 'UInt' is not assignable to type 'Layout<never>'
Type 'NearInt64' is not assignable to type 'Layout<never>'
Type 'Sequence<number>' is not assignable to type 'Layout<never>'
If you're in TypeScript, the buffer-layout
package requires that you provide a type for the struct
that you're creating.如果您使用 TypeScript,则
buffer-layout
包要求您为正在创建的struct
提供类型。 In your case, you can change this to:在您的情况下,您可以将其更改为:
interface Settings {
cost: bigint,
width: number,
height: number,
max_players: number,
}
const settingsSchema = lo.struct<Settings>([
lo.ns64("cost"),
lo.u32("width"),
lo.u32("height"),
lo.u16("max_players"),
])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.