npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

idl-parser-core

v0.4.40

Published

> Support converting IDL files to `transaction instruction`. Useful for smart contract test run, time-saving for writing test case.

Downloads

55

Readme

IDL Parser

Support converting IDL files to transaction instruction. Useful for smart contract test run, time-saving for writing test case.

Install

yarn add idl-parser-core

Usage

import { ParserProvider } from 'idl-parser-core'

const RPC: 'https://api.devnet.solana.com'

const App = () => {
  return (
    <ParserProvider
      rpc={RPC}
      walletAddress={walletAddress}
      programAddresses={{ provider }}
    >
      <View />
    </ParserProvider>
  )
}

rpc: rpc api url address
walletAddress: user wallet address
programAddresses: địa chỉ chương trình smartcontract
appId: id html element hiển thị modal.

Component

Giao diện mặc định của thư viện idl-parser-core

IDLParserWrapper

import { IDLParserWrapper } from 'idl-parser-core'

<IDLParserWrapper />
  • Giao diện mặc định của thư viện idl-parser-core: upload file idl, form accounts và arguments

TemplateView, InstructionView

import { TemplateView, InstructionView } from 'idl-parser-core'

<TemplateView />

<InstructionView />
  • TemplateView: Giao diện cấu trúc file IDL được tải lên.
  • InstructionView: Giao diện mặc định form accounts và arguments của file IDL được tải lên.

UploadIdl, ViewUploadedIdl

import { UploadIdl, ViewUploadedIdl } from 'idl-parser-core'

<UploadIdl />

<ViewUploadedIdl />
  • UploadIdl: Giao diện mặc định để tải lên file IDL.
  • ViewUploadedIdl: Giao diện mặc định hiển thị file IDL được tải lên._

Hooks

Cung cấp các function để thao tác với dữ liệu, thêm, sửa, xoá với file IDL được tải lên. Lấy thông tin được điền vào từ form accounts, arguments, hoặc dữ liệu file IDL sau khi chuyển đổi.

  • useParser

    • uploadIdl: function tải lên file IDL

    • removeIdl: function xoá file IDL được tải lên

    • parser: dữ liệu của file IDL được tải lên

      const {
        parser: { idl, ixSelected, accountsMetas, argsMetas, remainingAccounts },
      } = useParser()
      • idl: file IDL được tải lên
      • accountsMetas: dữ liệu accounts.
      • argsMetas: dữ liệu argsMetas.
      • ixSelected: instruction đang được chọn.
      • remainingAccounts: dữ liệu remainingAccounts.
    • rpc: địa chỉ rpc blockchain.

    • walletAddress: địa chỉ ví của người dùng.

    • programAddresses: địa chỉ chương trình smartcontract.
      programAddress.idl địa chỉ program được lấy từ file IDL tải lên.
      programAddress.custom địa chỉ program được người dùng thêm, sửa , xoá.
      programAddress.provider địa chỉ program bắt buộc thêm vào khi khởi tạo providerParser để thư viện xác định địa chỉ chương trình mà fileIDL đang tương tác.

      const {
        programAddress: {
          custom: customProgramAddress,
          idl: idlProgramAddress,
          provider: providerProgramAddress,
        },
      } = useParser()
    • setProgramAddress(programAddress: string): function cài địa chỉ cho chương trình IDL. Địa chỉ chương trình sẽ được thêm vào programAddress.custom

      const {
        programAddress: { custom: customProgramAddress },
      } = useParser()
    • setAccountsMeta({ name: string, data: KeypairMeta }): function thêm dữ liệu cho trường accounts. Dữ liệu sẽ được thêm vào parser.accountsMetas.

      const {
        parser: { accountsMetas },
      } = useParser()
    • setArgsMeta({ name: string, val: string }): function thêm dữ liệu cho trường arguments. Dữ liệu sẽ được thêm vào parser.argsMetas.

      const {
        parser: { argsMetas },
      } = useParser()
    • setInstruction(val: string): function chọn instruction để thao tác. Instruction được chọn sẽ thêm vào parser.ixSelected.

      const {
        parser: { ixSelected },
      } = useParser()
    • txInstructions: transaction instruction được chuyển đổi sau khi điền đầy đủ thông tin accounts, argument và remainning accounts nếu có.

      const { txInstructions } = useParser()
    • setTxInstructions: function thêm dữ liệu cho txInstructions.

      const { setTxInstructions } = useParser()
      
      function () {
        ...
        setTxInstructions(instruction)
        ...
      }

Guideline

Upload file idl

  • Button Choose IDL file: select to upload file idl.

IDL instructions

  • Program Address: địa chỉ chương trình idl đang tương tác.
  • File details:
    • File name.
    • Icon : click to remove idl file.
  • Group button instructions: Select instruction wana parse to transaction.
  • Accounts: Bao gồm những địa chỉ account cần để tạo và thực hiện transaction.
  • Arguments: Là những giá trị được truyền vào tương ứng với giá trị được yêu cầu của transaction.
  • Remaining accounts: Là tham số được dùng trong một số transaction đặc biệt như tạo account, deposit .v.v .Có dạng như sau:

      {
        isSigner: boolean,
        isWriter: boolean,
        publicKey: PublicKey
      }

    Bấm nút Add để tạo thêm và bấm nút để xoá remaining account.

Auto complete

Coming soon

Selection

Hỗ trợ người dùng điền nhanh chóng những trường của accounts, arguments và remaining.

  • Wallet Address: địa chỉ ví được cung cấp từ parserProvider
  • New Keypaire: tạo 1 keypair mới.
  • Program Account Data: lấy dữ liệu của account từ địa chỉ account. Ví dụ nhập địa chỉ pool để lấy thông tin của pool.
  • PDA - Token Account: derive địa chỉ token acount từ địa chỉ mint và địa chỉ owner.
  • PDA - Orther: tạo một địa chỉ bằng cách hash 2 chuổi ký tự với nhau.
  • Recents: Tất cả những địa chỉ đã nhập trước đó.
  • System: những địa chỉ chương trình mặc định được cung cấp bởi Solana

Review

Xem lại Transaction được tạo ra khi điền đầy đủ accounts và arguments của instruction.

Project example: https://github.com/DescartesNetwork/idl-parser