{"id":18707611,"url":"https://github.com/descartesnetwork/idl-parser-core","last_synced_at":"2025-11-09T09:30:27.066Z","repository":{"id":38370947,"uuid":"493598137","full_name":"DescartesNetwork/idl-parser-core","owner":"DescartesNetwork","description":null,"archived":false,"fork":false,"pushed_at":"2022-07-26T14:36:04.000Z","size":512,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-01-28T10:37:02.951Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DescartesNetwork.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-18T09:35:39.000Z","updated_at":"2022-07-04T08:17:02.000Z","dependencies_parsed_at":"2022-07-12T01:47:18.719Z","dependency_job_id":null,"html_url":"https://github.com/DescartesNetwork/idl-parser-core","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DescartesNetwork%2Fidl-parser-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DescartesNetwork%2Fidl-parser-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DescartesNetwork%2Fidl-parser-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DescartesNetwork%2Fidl-parser-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DescartesNetwork","download_url":"https://codeload.github.com/DescartesNetwork/idl-parser-core/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239571542,"owners_count":19661164,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T12:19:04.144Z","updated_at":"2025-11-09T09:30:27.032Z","avatar_url":"https://github.com/DescartesNetwork.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **IDL Parser**\n\n\u003e Support converting IDL files to `transaction instruction`. Useful for smart contract test run, time-saving for writing test case.\n\n## Install\n\n`yarn add idl-parser-core`\n\n## Usage\n\n```js\nimport { ParserProvider } from 'idl-parser-core'\n\nconst RPC: 'https://api.devnet.solana.com'\n\nconst App = () =\u003e {\n  return (\n    \u003cParserProvider\n      rpc={RPC}\n      walletAddress={walletAddress}\n      programAddresses={{ provider }}\n    \u003e\n      \u003cView /\u003e\n    \u003c/ParserProvider\u003e\n  )\n}\n```\n\n\u003e rpc: rpc api url address \\\n\u003e walletAddress: user wallet address \\\n\u003e programAddresses: địa chỉ chương trình smartcontract\\\n\u003e appId: id html element hiển thị modal.\n\n## Component\n\n_Giao diện mặc định của thư viện idl-parser-core_\n\n#### IDLParserWrapper\n\n\u003e ` import { IDLParserWrapper } from 'idl-parser-core'`\n\n```html\n\u003cIDLParserWrapper /\u003e\n```\n\n- _Giao diện mặc định của thư viện idl-parser-core: upload file idl, form accounts và arguments_\n\n#### TemplateView, InstructionView\n\n\u003e `import { TemplateView, InstructionView } from 'idl-parser-core'`\n\n```html\n\u003cTemplateView /\u003e\n\n\u003cInstructionView /\u003e\n```\n\n- _**TemplateView**: Giao diện cấu trúc file IDL được tải lên._\n- _**[InstructionView](#instructionview)**: Giao diện mặc định form accounts và arguments của file IDL được tải lên._\n\n#### UploadIdl, ViewUploadedIdl\n\n\u003e `import { UploadIdl, ViewUploadedIdl } from 'idl-parser-core'`\n\n```html\n\u003cUploadIdl /\u003e\n\n\u003cViewUploadedIdl /\u003e\n```\n\n- _**UploadIdl**: Giao diện mặc định để tải lên file IDL._\n- **ViewUploadedIdl**: Giao diện mặc định hiển thị file IDL được tải lên.\\_\n\n## Hooks\n\n_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._\n\n- ### useParser\n\n  - **uploadIdl**: function tải lên file IDL\n  - **removeIdl:** function xoá file IDL được tải lên\n  - **parser**: dữ liệu của file IDL được tải lên\n    ```js\n    const {\n      parser: { idl, ixSelected, accountsMetas, argsMetas, remainingAccounts },\n    } = useParser()\n    ```\n    - **idl**: file IDL được tải lên\n    - **accountsMetas**: dữ liệu accounts.\n    - **argsMetas**: dữ liệu argsMetas.\n    - **ixSelected**: instruction đang được chọn.\n    - **remainingAccounts**: dữ liệu remainingAccounts.\n  - **rpc**: địa chỉ rpc blockchain.\n  - **walletAddress**: địa chỉ ví của người dùng.\n  - **programAddresses**: địa chỉ chương trình smartcontract.\\\n    **`programAddress.idl`** địa chỉ program được lấy từ file IDL tải lên.\\\n    **`programAddress.custom`** địa chỉ program được người dùng thêm, sửa , xoá.\\\n    **`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.\n    ```js\n    const {\n      programAddress: {\n        custom: customProgramAddress,\n        idl: idlProgramAddress,\n        provider: providerProgramAddress,\n      },\n    } = useParser()\n    ```\n  - **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`_\n    ```js\n    const {\n      programAddress: { custom: customProgramAddress },\n    } = useParser()\n    ```\n  - **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`_.\n    ```js\n    const {\n      parser: { accountsMetas },\n    } = useParser()\n    ```\n  - **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`_.\n    ```js\n    const {\n      parser: { argsMetas },\n    } = useParser()\n    ```\n  - **setInstruction**(val: string): function chọn instruction để thao tác. Instruction được chọn sẽ thêm vào _`parser.ixSelected`_.\n    ```js\n    const {\n      parser: { ixSelected },\n    } = useParser()\n    ```\n  - **txInstructions**: transaction instruction được chuyển đổi sau khi điền đầy đủ thông tin accounts, argument và remainning accounts nếu có.\n    ```js\n    const { txInstructions } = useParser()\n    ```\n  - **setTxInstructions**: function thêm dữ liệu cho txInstructions.\n\n    ```js\n    const { setTxInstructions } = useParser()\n\n    function () {\n      ...\n      setTxInstructions(instruction)\n      ...\n    }\n    ```\n\n# \u003ca id=\"guideline\" href=\"javascript:void\"\u003e\u003c/a\u003e Guideline\n\n\u003c/br\u003e\n\n### \u003ca id=\"upload_idl\" href=\"javascript:void\"\u003e\u003c/a\u003e Upload file idl\n\n- Button `Choose IDL file`: select to upload file idl.\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"./src/static/images/docs/upload_file.png\" width=\"400\"/\u003e\u003c/p\u003e\n\n#\n\n\u003c/br\u003e\n\n### \u003ca id=\"idl_instruction\" href=\"javascript:void\"\u003e\u003c/a\u003e IDL instructions\n\n- `Program Address`: địa chỉ chương trình idl đang tương tác.\n- `File details`:\n  - File name.\n  - Icon \u003cimg src=\"https://unpkg.com/ionicons@5.5.2/dist/svg/trash-outline.svg\" width=\"16\"/\u003e: click to remove idl file.\n- `Group button instructions`: Select instruction wana parse to transaction.\n- `Accounts`: Bao gồm những địa chỉ account cần để tạo và thực hiện transaction.\n- `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.\n\u003cp align=\"center\"\u003e\u003cimg src=\"./src/static/images/docs/uploaded.png\" width=\"600\"/\u003e\u003c/p\u003e\n\n- `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:\n\n  ```js\n    {\n      isSigner: boolean,\n      isWriter: boolean,\n      publicKey: PublicKey\n    }\n  ```\n\n  \u003e _Bấm nút `Add` để tạo thêm và bấm nút \u003cimg src=\"https://unpkg.com/ionicons@5.5.2/dist/svg/trash-outline.svg\" width=\"16\"/\u003e để xoá remaining account._\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"./src/static/images/docs/remaining.png\" width=\"600\"/\u003e\u003c/p\u003e\n\n#\n\n### \u003ca id=\"auto\" href=\"javascript:void\"\u003e\u003c/a\u003e Auto complete\n\n\u003e Coming soon\n\n#\n\n### \u003ca id=\"selection\" href=\"javascript:void\"\u003e\u003c/a\u003e Selection\n\nHỗ trợ người dùng điền nhanh chóng những trường của accounts, arguments và remaining.\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"./src/static/images/docs/selection.png\" width=\"400\"/\u003e\u003c/p\u003e\n\n- `Wallet Address`: địa chỉ ví được cung cấp từ parserProvider\n- `New Keypaire`: tạo 1 keypair mới.\n- `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.\n- `PDA - Token Account`: derive địa chỉ token acount từ địa chỉ mint và địa chỉ owner.\n- `PDA - Orther`: tạo một địa chỉ bằng cách hash 2 chuổi ký tự với nhau.\n- `Recents`: Tất cả những địa chỉ đã nhập trước đó.\n- `System`: những địa chỉ chương trình mặc định được cung cấp bởi Solana\n\n#\n\n### \u003ca id=\"review\" href=\"javascript:void\"\u003e\u003c/a\u003e Review\n\nXem lại Transaction được tạo ra khi điền đầy đủ accounts và arguments của instruction.\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"./src/static/images/docs/review.png\" width=\"600\"/\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003cimg src=\"./src/static/images/docs/review_full.png\" width=\"600\"/\u003e\u003c/p\u003e\n\n#\n\n### Project example: [https://github.com/DescartesNetwork/idl-parser](https://github.com/DescartesNetwork/idl-parser)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdescartesnetwork%2Fidl-parser-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdescartesnetwork%2Fidl-parser-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdescartesnetwork%2Fidl-parser-core/lists"}