diff --git a/package-lock.json b/package-lock.json index 60f792d81..a53bc4b34 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,8 @@ "packages/sns", "packages/cmc", "packages/ckbtc", - "packages/ic-management" + "packages/ic-management", + "packages/ledger-icp" ], "devDependencies": { "@size-limit/esbuild": "^8.2.4", @@ -700,6 +701,10 @@ "resolved": "packages/ledger", "link": true }, + "node_modules/@dfinity/ledger-icp": { + "resolved": "packages/ledger-icp", + "link": true + }, "node_modules/@dfinity/nns": { "resolved": "packages/nns", "link": true @@ -7190,6 +7195,11 @@ "@dfinity/utils": "^0.0.23" } }, + "packages/ledger-icp": { + "version": "0.0.1", + "license": "Apache-2.0", + "devDependencies": {} + }, "packages/nns": { "name": "@dfinity/nns", "version": "0.16.8", @@ -7753,6 +7763,9 @@ "version": "file:packages/ledger", "requires": {} }, + "@dfinity/ledger-icp": { + "version": "file:packages/ledger-icp" + }, "@dfinity/nns": { "version": "file:packages/nns", "requires": { diff --git a/package.json b/package.json index 93e293dfe..a6c474ffa 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "packages/sns", "packages/cmc", "packages/ckbtc", - "packages/ic-management" + "packages/ic-management", + "packages/ledger-icp" ], "scripts": { "did": "scripts/compile-idl-js", @@ -93,6 +94,17 @@ "@dfinity/utils" ] }, + { + "name": "@dfinity/ledger-icp", + "path": "./packages/ledger-icp/dist/index.js", + "limit": "4 kB", + "ignore": [ + "@dfinity/agent", + "@dfinity/candid", + "@dfinity/principal", + "@dfinity/utils" + ] + }, { "name": "@dfinity/nns", "path": "./packages/nns/dist/index.js", diff --git a/packages/ledger-icp/LICENSE b/packages/ledger-icp/LICENSE new file mode 100644 index 000000000..4874b73b8 --- /dev/null +++ b/packages/ledger-icp/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2021 DFINITY LLC. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/packages/ledger-icp/README.md b/packages/ledger-icp/README.md new file mode 100644 index 000000000..64c8c7135 --- /dev/null +++ b/packages/ledger-icp/README.md @@ -0,0 +1,293 @@ +# ledger-icp-js + +A library for interfacing with the [ICP ledger](https://internetcomputer.org/icp-tokens/) on the Internet Computer. + +[![npm version](https://img.shields.io/npm/v/@dfinity/ledger-icp.svg?logo=npm)](https://www.npmjs.com/package/@dfinity/ledger-icp) [![GitHub license](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) + +> ℹī¸ This library is meant to interface with the ICP ledger only. If you are looking to interact with Snses, ckBTC, or other ICRC tokens, use the [ledger-icrc-js](../ledger-ircc) library. + +## Table of contents + +- [Installation](#installation) +- [Usage](#usage) +- [Features](#features) +- [Resources](#resources) + +## Installation + +You can use `ledger-icp-js` by installing it in your project. + +```bash +npm i @dfinity/ledger-icp +``` + +The bundle needs peer dependencies, be sure that following resources are available in your project as well. + +```bash +npm i @dfinity/agent @dfinity/candid @dfinity/principal @dfinity/utils +``` + +## Usage + +The features are available through the class `LedgerCanister`. It has to be instantiated with a canister ID. + +e.g. fetching a token metadata. + +```ts +import { IcrcLedgerCanister } from "@dfinity/ledger-icp"; +import { createAgent } from "@dfinity/utils"; + +const agent = await createAgent({ + identity, + host: HOST, +}); + +const { metadata } = LedgerCanister.create({ + agent, + canisterId: MY_LEDGER_CANISTER_ID, +}); + +const data = await metadata(); +``` + +## Features + +`ledger-icp-js` implements following features: + + + +### :toolbox: Functions + +- [encodeIcrcAccount](#gear-encodeicrcaccount) +- [decodeIcrcAccount](#gear-decodeicrcaccount) +- [decodePayment](#gear-decodepayment) + +#### :gear: encodeIcrcAccount + +Encodes an Icrc-1 account compatible into a string. +Formatting Reference: https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-1/TextualEncoding.md + +| Function | Type | +| ------------------- | ------------------------------------------------- | +| `encodeIcrcAccount` | `({ owner, subaccount, }: IcrcAccount) => string` | + +Parameters: + +- `account`: : Principal, subaccount?: Uint8Array } + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/utils/ledger.utils.ts#L21) + +#### :gear: decodeIcrcAccount + +Decodes a string into an Icrc-1 compatible account. +Formatting Reference: https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-1/TextualEncoding.md + +| Function | Type | +| ------------------- | ---------------------------------------- | +| `decodeIcrcAccount` | `(accountString: string) => IcrcAccount` | + +Parameters: + +- `accountString`: string + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/utils/ledger.utils.ts#L59) + +#### :gear: decodePayment + +👀 This feature is currently in draft. You can find more information about it at https://github.com/dfinity/ICRC/issues/22. + +A naive implementation of a payment parser. Given a code, the function attempts to extract a token name, account identifier (textual representation), and an optional amount. + +If the code doesn't match the expected pattern, `undefined` is returned for simplicity. +Similarly, if an optional amount is provided but it's not a valid number, the parser will not throw an exception and returns `undefined`. + +Please note that this function doesn't perform any validity checks on the extracted information. +It does not verify if the token is known or if the identifier is a valid address. + +``` +urn = token ":" address [ "?" params] +token = [ ckbtc / icp / chat / bitcoin / ethereum ... ] +address = STRING +params = param [ "&" params ] +param = [ amountparam ] +amountparam = "amount=" *digit [ "." *digit ] +``` + +| Function | Type | +| --------------- | --------------------------------------------------------------------------- | +| `decodePayment` | `(code: string) => { token: string; identifier: string; amount?: number; }` | + +Parameters: + +- `code`: string + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/utils/payment.utils.ts#L26) + +### :factory: IcrcLedgerCanister + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/ledger.canister.ts#L27) + +#### Methods + +- [create](#gear-create) +- [metadata](#gear-metadata) +- [transactionFee](#gear-transactionfee) +- [balance](#gear-balance) +- [transfer](#gear-transfer) +- [totalTokensSupply](#gear-totaltokenssupply) +- [transferFrom](#gear-transferfrom) +- [approve](#gear-approve) +- [allowance](#gear-allowance) + +##### :gear: create + +| Method | Type | +| -------- | ---------------------------------------------------------------------- | +| `create` | `(options: IcrcLedgerCanisterOptions<_SERVICE>) => IcrcLedgerCanister` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/ledger.canister.ts#L28) + +##### :gear: metadata + +The token metadata (name, symbol, etc.). + +| Method | Type | +| ---------- | ------------------------------------------------------------- | +| `metadata` | `(params: QueryParams) => Promise` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/ledger.canister.ts#L42) + +##### :gear: transactionFee + +The ledger transaction fees. + +| Method | Type | +| ---------------- | ------------------------------------------ | +| `transactionFee` | `(params: QueryParams) => Promise` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/ledger.canister.ts#L50) + +##### :gear: balance + +Returns the balance for a given account provided as owner and with optional subaccount. + +| Method | Type | +| --------- | -------------------------------------------- | +| `balance` | `(params: BalanceParams) => Promise` | + +Parameters: + +- `params`: The parameters to get the balance of an account. + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/ledger.canister.ts#L59) + +##### :gear: transfer + +Transfers tokens from the sender to the given account. + +| Method | Type | +| ---------- | --------------------------------------------- | +| `transfer` | `(params: TransferParams) => Promise` | + +Parameters: + +- `params`: The parameters to transfer tokens. + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/ledger.canister.ts#L72) + +##### :gear: totalTokensSupply + +Returns the total supply of tokens. + +| Method | Type | +| ------------------- | ------------------------------------------ | +| `totalTokensSupply` | `(params: QueryParams) => Promise` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/ledger.canister.ts#L88) + +##### :gear: transferFrom + +Transfers a token amount from the `from` account to the `to` account using the allowance of the spender's account (`SpenderAccount = { owner = caller; subaccount = spender_subaccount }`). The ledger draws the fees from the `from` account. + +Reference: https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-2/README.md#icrc2_transfer_from + +| Method | Type | +| -------------- | ------------------------------------------------- | +| `transferFrom` | `(params: TransferFromParams) => Promise` | + +Parameters: + +- `params`: The parameters to transfer tokens from to. + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/ledger.canister.ts#L101) + +##### :gear: approve + +This method entitles the `spender` to transfer token `amount` on behalf of the caller from account `{ owner = caller; subaccount = from_subaccount }`. + +Reference: https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-2/README.md#icrc2_approve + +| Method | Type | +| --------- | -------------------------------------------- | +| `approve` | `(params: ApproveParams) => Promise` | + +Parameters: + +- `params`: The parameters to approve. + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/ledger.canister.ts#L123) + +##### :gear: allowance + +Returns the token allowance that the `spender` account can transfer from the specified `account`, and the expiration time for that allowance, if any. + +Reference: https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-2/README.md#icrc2_allowance + +| Method | Type | +| ----------- | ------------------------------------------------- | +| `allowance` | `(params: AllowanceParams) => Promise` | + +Parameters: + +- `params`: The parameters to call the allowance. + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/ledger.canister.ts#L145) + +### :factory: IcrcIndexCanister + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/index.canister.ts#L13) + +#### Methods + +- [create](#gear-create) +- [getTransactions](#gear-gettransactions) + +##### :gear: create + +| Method | Type | +| -------- | --------------------------------------------------------------------- | +| `create` | `(options: IcrcLedgerCanisterOptions<_SERVICE>) => IcrcIndexCanister` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/index.canister.ts#L14) + +##### :gear: getTransactions + +Get the transactions of an account + +Always certified. +`get_account_transactions` needs to be called with an update +because the index canisters makes a call to the ledger canister to get the transaction data. +Index Canister only holds the transactions ids in state, not the whole transaction data. + +| Method | Type | +| ----------------- | -------------------------------------------------------------------- | +| `getTransactions` | `(params: GetAccountTransactionsParams) => Promise` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/index.canister.ts#L33) + + + +## Resources + +- [Ledger & Tokenization Working Group Standards](https://github.com/dfinity/ICRC-1/) +- [ICP ledger](https://github.com/dfinity/ic/tree/master/rs/rosetta-api/icp_ledger) diff --git a/packages/ledger-icp/esbuild.mjs b/packages/ledger-icp/esbuild.mjs new file mode 100644 index 000000000..f3cda319f --- /dev/null +++ b/packages/ledger-icp/esbuild.mjs @@ -0,0 +1,5 @@ +#!/usr/bin/env node + +import { build } from "../../scripts/esbuild.mjs"; + +build(); diff --git a/packages/ledger-icp/jest.config.js b/packages/ledger-icp/jest.config.js new file mode 100644 index 000000000..e75ede62b --- /dev/null +++ b/packages/ledger-icp/jest.config.js @@ -0,0 +1,7 @@ +const rootJestConfig = require("../../jest.config"); + +module.exports = { + ...rootJestConfig, + setupFiles: [`../../test-setup.ts`], + modulePathIgnorePatterns: ["./dist"], +}; diff --git a/packages/ledger-icp/package.json b/packages/ledger-icp/package.json new file mode 100644 index 000000000..7b863b19a --- /dev/null +++ b/packages/ledger-icp/package.json @@ -0,0 +1,46 @@ +{ + "name": "@dfinity/ledger-icp", + "version": "0.0.1", + "description": "A library for interfacing with the ICP ledger on the Internet Computer.", + "license": "Apache-2.0", + "main": "dist/cjs/index.cjs.js", + "module": "dist/esm/index.js", + "types": "dist/types/index.d.ts", + "files": [ + "dist", + "README.md", + "LICENSE" + ], + "scripts": { + "rmdir": "node ../../scripts/rmdir.mjs", + "ts-declaration": "tsc --emitDeclarationOnly --outDir dist/types", + "build": "npm run rmdir && mkdir -p dist && cp -R candid dist && node esbuild.mjs && npm run ts-declaration", + "prepack": "npm run build", + "test": "jest" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/dfinity/ic-js.git", + "directory": "packages/ledger-icp" + }, + "bugs": { + "url": "https://github.com/dfinity/ic-js" + }, + "keywords": [ + "internet computer", + "internet-computer", + "ic", + "dfinity", + "Ledger", + "ICP ledger", + "token", + "icp" + ], + "homepage": "https://github.com/dfinity/ic-js#readme", + "peerDependencies": { + "@dfinity/agent": "^0.19.2", + "@dfinity/candid": "^0.19.2", + "@dfinity/principal": "^0.19.2", + "@dfinity/utils": "^0.0.23" + } +} diff --git a/packages/ledger-icp/src/index.ts b/packages/ledger-icp/src/index.ts new file mode 100644 index 000000000..f59d2fbb5 --- /dev/null +++ b/packages/ledger-icp/src/index.ts @@ -0,0 +1 @@ +export * from "./ledger.canister"; diff --git a/packages/ledger-icp/src/ledger.canister.ts b/packages/ledger-icp/src/ledger.canister.ts new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/packages/ledger-icp/src/ledger.canister.ts @@ -0,0 +1 @@ +export {}; diff --git a/packages/ledger-icp/tsconfig.json b/packages/ledger-icp/tsconfig.json new file mode 100644 index 000000000..ca17af186 --- /dev/null +++ b/packages/ledger-icp/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "include": ["src/**/*", "candid/**/*"] +} diff --git a/scripts/build-next b/scripts/build-next index 4f62740bb..3dee425a0 100755 --- a/scripts/build-next +++ b/scripts/build-next @@ -7,6 +7,7 @@ npm ci node ./scripts/update-version.mjs utils node ./scripts/update-version.mjs nns-proto node ./scripts/update-version.mjs ledger +node ./scripts/update-version.mjs ledger-icp node ./scripts/update-version.mjs nns node ./scripts/update-version.mjs sns node ./scripts/update-version.mjs cmc diff --git a/scripts/compile-idl-js b/scripts/compile-idl-js index f412d86cb..f7ef5b5ef 100755 --- a/scripts/compile-idl-js +++ b/scripts/compile-idl-js @@ -26,6 +26,7 @@ did_files_to_compile() { did_files_to_compile_for_pkg "sns" did_files_to_compile_for_pkg "cmc" did_files_to_compile_for_pkg "ledger" + did_files_to_compile_for_pkg "ledger-icp" did_files_to_compile_for_pkg "ckbtc" did_files_to_compile_for_pkg "ic-management" } diff --git a/scripts/docs.js b/scripts/docs.js index 400cdbcae..1a1c405bf 100644 --- a/scripts/docs.js +++ b/scripts/docs.js @@ -33,6 +33,8 @@ const ledgerInputFiles = [ "./packages/ledger/src/index.canister.ts", ]; +const ledgerICPInputFiles = ["./packages/ledger/src/ledger.canister.ts"]; + const ckBTCInputFiles = [ "./packages/ckbtc/src/minter.canister.ts", "./packages/ckbtc/src/utils/btc.utils.ts", @@ -78,6 +80,13 @@ generateDocumentation({ buildOptions, }); +generateDocumentation({ + inputFiles: ledgerICPInputFiles, + outputFile: "./packages/ledger-icp/README.md", + markdownOptions, + buildOptions, +}); + generateDocumentation({ inputFiles: ckBTCInputFiles, outputFile: "./packages/ckbtc/README.md", diff --git a/scripts/import-candid b/scripts/import-candid index 4aeabfeda..f70a4081e 100755 --- a/scripts/import-candid +++ b/scripts/import-candid @@ -56,7 +56,6 @@ THIS_SCRIPT_NAME="$(basename "$0")" : Import canisters mkdir -p packages/nns/candid import_did "rs/nns/governance/canister/governance.did" "governance.did" "nns" -import_did "rs/rosetta-api/icp_ledger/ledger.did" "ledger.did" "nns" import_did "rs/nns/gtc/canister/gtc.did" "genesis_token.did" "nns" import_did "rs/nns/sns-wasm/canister/sns-wasm.did" "sns_wasm.did" "nns" @@ -73,6 +72,9 @@ mkdir -p packages/ledger/candid import_did "rs/rosetta-api/icrc1/ledger/ledger.did" "icrc1_ledger.did" "ledger" import_did "rs/rosetta-api/icrc1/index/index.did" "icrc1_index.did" "ledger" +mkdir -p packages/ledger-icp/candid +import_did "rs/rosetta-api/icp_ledger/ledger.did" "ledger.did" "nns" + mkdir -p packages/ckbtc/candid import_did "rs/bitcoin/ckbtc/minter/ckbtc_minter.did" "minter.did" "ckbtc"