Skip to content

Typescript 里 mysten/sui.js 使用 getObjectBatch 后得到的数据没法通过类型检查 #247

Answered by leo-web3
qiwihui asked this question in Q&A
Discussion options

You must be logged in to vote

根据返回值 定义 interface 接口

interface ObjectBatch {
  details: {
    data: {
      dataType: string,
      type: string,
      has_public_transfer: boolean,
      fields: {
        description: string,
        id: {
          id: string
        },
        name: string,
        url: string
      }
    },
    owner: {
      AddressOwner: string
    },
    previousTransaction: string,
      storageRebate: number,
      reference: {
      objectId: string,
        version: number,
        digest: string
    }
  }
};

用法

const nfts = nftObjects.filter(item => item.status === "Exists").map((item: ObjectBatch)=> {
    return {
        id: item.details.data.fields.id.id,
        name: item.details.data.f…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by qiwihui
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants