Skip to content

监听 onLogs 可能会漏过指令的情况 #5

@doskoi

Description

@doskoi

根据观察,在某些情况下(如通过其他program调用的部分场景, 这时Raydium的instruction作为Inner Instructions,当然只有部分情况) program log 可能被夹而不出现在logs中的情况

https://github.com/ChainBuff/solana-web3js/blob/main/example-02-subNewPool/index.ts

if (logs && logs.some(log => log.includes("initialize2"))) {

这种场景下,这个代码就无法匹配到相应的指令, 不局限于 initialize2, 任何指令都可能.
要兼容所有情况必须捕获 program 的所有 invoke, 然后 decode instruction 的名字做对比.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions