diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f56cbb4..935b5f59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ - utils `v0.0.19` - nns-proto `v0.0.5` -# 0.18.0 (wip) +# 0.18.0 (2023-07-03) ## Release @@ -32,6 +32,13 @@ ## Features - add a new utils function `decodePayment` to the `@dfinity/ledger` library. Useful to decode payment through QR code that contains target address and amount +- add provisional create canister with cycles method +- `CreateServiceNervousSystem` <-> `RawCreateServiceNervousSystem` transformations for Nns proposal +- decode payment code (early support and not yet specified. see ICRC-22) + +## Build + +- bump `semver` # 0.17.2 (2023-06-21) diff --git a/package-lock.json b/package-lock.json index c29756a4..0aee08d5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,7 +42,7 @@ "text-encoding": "^0.7.0", "ts-jest": "^29.1.0", "ts-protoc-gen": "^0.15.0", - "tsdoc-markdown": "^0.0.1", + "tsdoc-markdown": "^0.0.4", "typescript": "^4.9.5", "whatwg-fetch": "^3.6.2" } @@ -6761,9 +6761,9 @@ } }, "node_modules/tsdoc-markdown": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/tsdoc-markdown/-/tsdoc-markdown-0.0.1.tgz", - "integrity": "sha512-tQ5+KjT/9DJNXqzTYQg1NVmSPBgpC2cUxFALxRdUa/08jjhjH2LsaGio9MSlLNjjFx4D24q6JIp4uuKsvfs8AQ==", + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/tsdoc-markdown/-/tsdoc-markdown-0.0.4.tgz", + "integrity": "sha512-/z9E0gniO2KzM5vLh2Wq7wc2RYkWxeBzlCfuISoJTRYkZgyWKhI299AiXkNy7TgvFnMxx7522wuTyHO1tS5vIg==", "dev": true, "bin": { "tsdoc": "bin/index.js" @@ -7179,7 +7179,7 @@ "peerDependencies": { "@dfinity/agent": "^0.15.4", "@dfinity/candid": "^0.15.4", - "@dfinity/nns-proto": "^0.0.4", + "@dfinity/nns-proto": "^0.0.5", "@dfinity/principal": "^0.15.4", "@dfinity/utils": "^0.0.19" } @@ -12012,9 +12012,9 @@ } }, "tsdoc-markdown": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/tsdoc-markdown/-/tsdoc-markdown-0.0.1.tgz", - "integrity": "sha512-tQ5+KjT/9DJNXqzTYQg1NVmSPBgpC2cUxFALxRdUa/08jjhjH2LsaGio9MSlLNjjFx4D24q6JIp4uuKsvfs8AQ==", + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/tsdoc-markdown/-/tsdoc-markdown-0.0.4.tgz", + "integrity": "sha512-/z9E0gniO2KzM5vLh2Wq7wc2RYkWxeBzlCfuISoJTRYkZgyWKhI299AiXkNy7TgvFnMxx7522wuTyHO1tS5vIg==", "dev": true, "requires": {} }, diff --git a/package.json b/package.json index 26c4628e..d5397d0d 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "text-encoding": "^0.7.0", "ts-jest": "^29.1.0", "ts-protoc-gen": "^0.15.0", - "tsdoc-markdown": "^0.0.1", + "tsdoc-markdown": "^0.0.4", "typescript": "^4.9.5", "whatwg-fetch": "^3.6.2" }, diff --git a/packages/ckbtc/README.md b/packages/ckbtc/README.md index f50fa226..68e01930 100644 --- a/packages/ckbtc/README.md +++ b/packages/ckbtc/README.md @@ -74,17 +74,11 @@ Parameters: - `params`: The Bitcoin address and network to parse - `params.network`: Optional. Default BtcNetwork is Mainnet -### :factory: CkBTCMinterCanister - -#### Constructors - -`public` +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/utils/btc.utils.ts#L194) -Parameters: +### :factory: CkBTCMinterCanister -- `id` -- `service` -- `certifiedService` +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L33) #### Methods @@ -102,6 +96,8 @@ Parameters: | -------- | ------------------------------------------------------------------------ | | `create` | `(options: CkBTCMinterCanisterOptions<_SERVICE>) => CkBTCMinterCanister` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L34) + ##### :gear: getBtcAddress Returns a BTC address for a given account. @@ -118,6 +114,8 @@ Parameters: - `params.owner`: The owner for which the BTC address should be generated. If not provided, the `caller` will be use instead. - `params.subaccount`: An optional subaccount to compute the address. +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L55) + ##### :gear: updateBalance Notify the minter about the bitcoin transfer. @@ -134,6 +132,8 @@ Parameters: - `params.owner`: The owner of the address. If not provided, the `caller` will be use instead. - `params.subaccount`: An optional subaccount of the address. +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L74) + ##### :gear: getWithdrawalAccount Returns the account to which the caller should deposit ckBTC before withdrawing BTC using the [retrieveBtc] endpoint. @@ -142,6 +142,8 @@ Returns the account to which the caller should deposit ckBTC before withdrawing | ---------------------- | ------------------------ | | `getWithdrawalAccount` | `() => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L97) + ##### :gear: retrieveBtc Submits a request to convert ckBTC to BTC. @@ -164,6 +166,8 @@ Parameters: - `params.address`: The bitcoin address. - `params.amount`: The ckBTC amount. +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L116) + ##### :gear: estimateWithdrawalFee Returns an estimation of the user's fee (in Satoshi) for a retrieve_btc request based on the current status of the Bitcoin network and the fee related to the minter. @@ -178,6 +182,8 @@ Parameters: - `params.certified`: query or update call - `params.amount`: The optional amount for which the fee should be estimated. +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L135) + ##### :gear: getMinterInfo Returns internal minter parameters such as the minimal amount to retrieve BTC, minimal number of confirmations or KYT fee. @@ -191,6 +197,8 @@ Parameters: - `params`: The parameters to get the deposit fee. - `params.certified`: query or update call +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L149) + ## Resources diff --git a/packages/cmc/README.md b/packages/cmc/README.md index 27526252..3f8d8fd8 100644 --- a/packages/cmc/README.md +++ b/packages/cmc/README.md @@ -55,6 +55,8 @@ const rate = await getIcpToCyclesConversionRate(); ### :factory: CMCCanister +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cmc/src/cmc.canister.ts#L13) + #### Methods - [create](#gear-create) @@ -68,6 +70,8 @@ const rate = await getIcpToCyclesConversionRate(); | -------- | ---------------------------------------------- | | `create` | `(options: CMCCanisterOptions) => CMCCanister` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cmc/src/cmc.canister.ts#L18) + ##### :gear: getIcpToCyclesConversionRate Returns conversion rate of ICP to Cycles @@ -76,6 +80,8 @@ Returns conversion rate of ICP to Cycles | ------------------------------ | ----------------------- | | `getIcpToCyclesConversionRate` | `() => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cmc/src/cmc.canister.ts#L37) + ##### :gear: notifyCreateCanister Notifies Cycles Minting Canister of the creation of a new canister. @@ -85,6 +91,8 @@ It returns the new canister principal. | ---------------------- | ---------------------------------------------------------- | | `notifyCreateCanister` | `(request: NotifyCreateCanisterArg) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cmc/src/cmc.canister.ts#L54) + ##### :gear: notifyTopUp Notifies Cycles Minting Canister of new cycles being added to canister. @@ -94,4 +102,6 @@ It returns the new Cycles of the canister. | ------------- | ---------------------------------------------- | | `notifyTopUp` | `(request: NotifyTopUpArg) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cmc/src/cmc.canister.ts#L82) + diff --git a/packages/ic-management/README.md b/packages/ic-management/README.md index f70bc064..34dd679c 100644 --- a/packages/ic-management/README.md +++ b/packages/ic-management/README.md @@ -1,6 +1,6 @@ # ic-management-js -A library for interfacing with [Internet Computer (IC) management canister](https://internetcomputer.org/docs/current/developer-docs/integrations/https-outcalls/https-outcalls-how-to-use/#ic-management-canister). +A library for interfacing with the [Internet Computer (IC) management canister](https://internetcomputer.org/docs/current/developer-docs/integrations/https-outcalls/https-outcalls-how-to-use/#ic-management-canister). [![npm version](https://img.shields.io/npm/v/@dfinity/ic-management.svg?logo=npm)](https://www.npmjs.com/package/@dfinity/ic-management) [![GitHub license](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) @@ -54,6 +54,8 @@ const { status, memory_size, ...rest } = await canisterStatus(YOUR_CANISTER_ID); ### :factory: ICManagementCanister +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ic-management/src/ic-management.canister.ts#L24) + #### Methods - [create](#gear-create) @@ -74,6 +76,8 @@ const { status, memory_size, ...rest } = await canisterStatus(YOUR_CANISTER_ID); | -------- | ---------------------------------------------------------------- | | `create` | `(options: ICManagementCanisterOptions) => ICManagementCanister` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ic-management/src/ic-management.canister.ts#L29) + ##### :gear: createCanister Create a new canister @@ -82,6 +86,8 @@ Create a new canister | ---------------- | ------------------------------------------------------------------------------------ | | `createCanister` | `({ settings, senderCanisterVerion, }?: CreateCanisterParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ic-management/src/ic-management.canister.ts#L50) + ##### :gear: updateSettings Update canister settings @@ -90,6 +96,8 @@ Update canister settings | ---------------- | ------------------------------------------------------------------------------------------ | | `updateSettings` | `({ canisterId, senderCanisterVerion, settings, }: UpdateSettingsParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ic-management/src/ic-management.canister.ts#L71) + ##### :gear: installCode Install code to a canister @@ -98,6 +106,8 @@ Install code to a canister | ------------- | ---------------------------------------------------------------------------------------------------- | | `installCode` | `({ mode, canisterId, wasmModule, arg, senderCanisterVerion, }: InstallCodeParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ic-management/src/ic-management.canister.ts#L93) + ##### :gear: uninstallCode Uninstall code from a canister @@ -106,6 +116,8 @@ Uninstall code from a canister | --------------- | ------------------------------------------------------------------------------- | | `uninstallCode` | `({ canisterId, senderCanisterVerion, }: UninstallCodeParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ic-management/src/ic-management.canister.ts#L116) + ##### :gear: startCanister Start a canister @@ -114,6 +126,8 @@ Start a canister | --------------- | ------------------------------------------ | | `startCanister` | `(canisterId: Principal) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ic-management/src/ic-management.canister.ts#L131) + ##### :gear: stopCanister Stop a canister @@ -122,21 +136,27 @@ Stop a canister | -------------- | ------------------------------------------ | | `stopCanister` | `(canisterId: Principal) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ic-management/src/ic-management.canister.ts#L140) + ##### :gear: canisterStatus Get canister details (memory size, status, etc.) -| Method | Type | -| ---------------- | --------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | -| `canisterStatus` | `(canisterId: Principal) => Promise<{ status: { stopped: null; } or { stopping: null; } | { running: null; }; memory_size: bigint; cycles: bigint; settings: definite_canister_settings; idle_cycles_burned_per_day: bigint; module_hash: [] | [...]; }>` | +| Method | Type | +| ---------------- | ---------------------------------------------------------------------------------- | +| `canisterStatus` | `(canisterId: Principal) => Promise>` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ic-management/src/ic-management.canister.ts#L149) ##### :gear: canisterInfo Get canister info (controllers, module hash, changes, etc.) -| Method | Type | -| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `canisterInfo` | `({ canisterId, numRequestChanges, }: CanisterInfoParams) => Promise<{ controllers: Principal[]; module_hash: [] or [Uint8Array]; recent_changes: change[]; total_num_changes: bigint; }>` | +| Method | Type | +| -------------- | ----------------------------------------------------------------------------------------------------------------- | +| `canisterInfo` | `({ canisterId, numRequestChanges, }: CanisterInfoParams) => Promise>` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ic-management/src/ic-management.canister.ts#L162) ##### :gear: deleteCanister @@ -146,6 +166,8 @@ Deletes a canister | ---------------- | ------------------------------------------ | | `deleteCanister` | `(canisterId: Principal) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ic-management/src/ic-management.canister.ts#L177) + ##### :gear: provisionalCreateCanisterWithCycles Creates a canister. Only available on development instances. @@ -154,6 +176,8 @@ Creates a canister. Only available on development instances. | ------------------------------------- | ------------------------------------------------------------------------------------------------------- | | `provisionalCreateCanisterWithCycles` | `({ settings, amount, canisterId, }?: ProvisionalCreateCanisterWithCyclesParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ic-management/src/ic-management.canister.ts#L189) + ## Resources diff --git a/packages/ledger/README.md b/packages/ledger/README.md index cae87514..80501545 100644 --- a/packages/ledger/README.md +++ b/packages/ledger/README.md @@ -73,6 +73,8 @@ 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. @@ -86,6 +88,8 @@ Parameters: - `accountString`: string +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/utils/ledger.utils.ts#L59) + #### :gear: decodePayment 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. @@ -96,12 +100,14 @@ Similarly, if an optional amount is provided but it's not a valid number, the pa 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 ] +``` +urn = token ":" address [ "?" params] +token = [ ckbtc / icp / chat / bitcoin / ethereum ... ] +address = STRING +params = param [ "&" params ] +param = [ amountparam ] +amountparam = "amount=" *digit [ "." *digit ] +``` | Function | Type | | --------------- | --------------------------------------------------------------------------- | @@ -111,17 +117,11 @@ Parameters: - `code`: string -### :factory: IcrcLedgerCanister - -#### Constructors +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/utils/payment.utils.ts#L24) -`public` - -Parameters: +### :factory: IcrcLedgerCanister -- `id` -- `service` -- `certifiedService` +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/ledger.canister.ts#L16) #### Methods @@ -138,6 +138,8 @@ Parameters: | -------- | ---------------------------------------------------------------------- | | `create` | `(options: IcrcLedgerCanisterOptions<_SERVICE>) => IcrcLedgerCanister` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/ledger.canister.ts#L17) + ##### :gear: metadata The token metadata (name, symbol, etc.). @@ -146,6 +148,8 @@ The token metadata (name, symbol, etc.). | ---------- | ------------------------------------------------------------- | | `metadata` | `(params: QueryParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/ledger.canister.ts#L31) + ##### :gear: transactionFee The ledger transaction fees. @@ -154,6 +158,8 @@ The ledger transaction fees. | ---------------- | ------------------------------------------ | | `transactionFee` | `(params: QueryParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/ledger.canister.ts#L39) + ##### :gear: balance Returns the balance for a given account provided as owner and with optional subaccount. @@ -166,6 +172,8 @@ 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#L48) + ##### :gear: transfer Transfers tokens from the sender to the given account. @@ -178,6 +186,8 @@ Parameters: - `params`: The parameters to transfer tokens. +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/ledger.canister.ts#L61) + ##### :gear: totalTokensSupply Returns the total supply of tokens. @@ -186,17 +196,11 @@ Returns the total supply of tokens. | ------------------- | ------------------------------------------ | | `totalTokensSupply` | `(params: QueryParams) => Promise` | -### :factory: IcrcIndexCanister - -#### Constructors +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/ledger.canister.ts#L77) -`public` - -Parameters: +### :factory: IcrcIndexCanister -- `id` -- `service` -- `certifiedService` +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/index.canister.ts#L13) #### Methods @@ -209,6 +213,8 @@ Parameters: | -------- | --------------------------------------------------------------------- | | `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 @@ -222,6 +228,8 @@ Index Canister only holds the transactions ids in state, not the whole transacti | ----------------- | -------------------------------------------------------------------- | | `getTransactions` | `(params: GetAccountTransactionsParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger/src/index.canister.ts#L33) + ## Resources diff --git a/packages/ledger/src/utils/payment.utils.ts b/packages/ledger/src/utils/payment.utils.ts index 00447626..8fd339b7 100644 --- a/packages/ledger/src/utils/payment.utils.ts +++ b/packages/ledger/src/utils/payment.utils.ts @@ -9,12 +9,14 @@ import { isNullish, nonNullish } from "@dfinity/utils"; * 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 ] + * ``` * * @param code string * @returns { token: string; identifier: string; amount?: number } | undefined diff --git a/packages/nns/README.md b/packages/nns/README.md index 7ba6e17a..d3d0be8b 100644 --- a/packages/nns/README.md +++ b/packages/nns/README.md @@ -87,6 +87,8 @@ Parameters: - `params.neurons`: The neurons to filter. - `params.proposal`: The proposal to match against the selected neurons. +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/utils/neurons.utils.ts#L39) + #### :gear: votableNeurons Filter the neurons that can vote for a proposal - i.e. the neurons that have not voted yet and are eligible @@ -100,6 +102,8 @@ Parameters: - `params.neurons`: The neurons to filter. - `params.proposal`: The proposal to match against the selected neurons. +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/utils/neurons.utils.ts#L68) + #### :gear: votedNeurons Filter the neurons that have voted for a proposal. @@ -113,8 +117,12 @@ Parameters: - `params.neurons`: The neurons to filter. - `params.proposal`: The proposal for which some neurons might have already voted. +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/utils/neurons.utils.ts#L94) + ### :factory: AccountIdentifier +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/account_identifier.ts#L12) + #### Methods - [fromHex](#gear-fromhex) @@ -131,44 +139,60 @@ Parameters: | --------- | ------------------------------------ | | `fromHex` | `(hex: string) => AccountIdentifier` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/account_identifier.ts#L15) + ##### :gear: fromPrincipal | Method | Type | | --------------- | ------------------------------------------------------------------------------------------------------- | | `fromPrincipal` | `({ principal, subAccount, }: { principal: Principal; subAccount?: SubAccount; }) => AccountIdentifier` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/account_identifier.ts#L19) + ##### :gear: toProto | Method | Type | | --------- | ---------------------------------- | | `toProto` | `() => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/account_identifier.ts#L46) + ##### :gear: toHex | Method | Type | | ------- | -------------- | | `toHex` | `() => string` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/account_identifier.ts#L54) + ##### :gear: toUint8Array | Method | Type | | -------------- | ------------------ | | `toUint8Array` | `() => Uint8Array` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/account_identifier.ts#L58) + ##### :gear: toNumbers | Method | Type | | ----------- | ---------------- | | `toNumbers` | `() => number[]` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/account_identifier.ts#L62) + ##### :gear: toAccountIdentifierHash | Method | Type | | ------------------------- | ------------------------- | | `toAccountIdentifierHash` | `() => AccountIdentifier` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/account_identifier.ts#L66) + ### :factory: SubAccount +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/account_identifier.ts#L73) + #### Methods - [fromBytes](#gear-frombytes) @@ -182,26 +206,36 @@ Parameters: | ----------- | -------------------------------------------- | | `fromBytes` | `(bytes: Uint8Array) => SubAccount or Error` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/account_identifier.ts#L76) + ##### :gear: fromPrincipal | Method | Type | | --------------- | -------------------------------------- | | `fromPrincipal` | `(principal: Principal) => SubAccount` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/account_identifier.ts#L84) + ##### :gear: fromID | Method | Type | | -------- | ---------------------------- | | `fromID` | `(id: number) => SubAccount` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/account_identifier.ts#L97) + ##### :gear: toUint8Array | Method | Type | | -------------- | ------------------ | | `toUint8Array` | `() => Uint8Array` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/account_identifier.ts#L109) + ### :factory: GenesisTokenCanister +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/genesis_token.canister.ts#L9) + #### Methods - [create](#gear-create) @@ -213,14 +247,20 @@ Parameters: | -------- | --------------------------------------------------------------- | | `create` | `(options?: CanisterOptions<_SERVICE>) => GenesisTokenCanister` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/genesis_token.canister.ts#L14) + ##### :gear: claimNeurons | Method | Type | | -------------- | --------------------------------------------------------------- | | `claimNeurons` | `({ hexPubKey, }: { hexPubKey: string; }) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/genesis_token.canister.ts#L27) + ### :factory: LedgerCanister +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/ledger.canister.ts#L27) + #### Methods - [create](#gear-create) @@ -234,6 +274,8 @@ Parameters: | -------- | ----------------------------------------------------- | | `create` | `(options?: LedgerCanisterOptions) => LedgerCanister` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/ledger.canister.ts#L38) + ##### :gear: accountBalance Returns the balance of the specified account identifier. @@ -245,6 +287,8 @@ it is fetched using a query call. | ---------------- | ------------------------------------------------------------------------------------------------------------------------ | | `accountBalance` | `({ accountIdentifier, certified, }: { accountIdentifier: AccountIdentifier; certified?: boolean; }) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/ledger.canister.ts#L70) + ##### :gear: transactionFee Returns the transaction fee of the ledger canister @@ -253,6 +297,8 @@ Returns the transaction fee of the ledger canister | ---------------- | ----------------------- | | `transactionFee` | `() => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/ledger.canister.ts#L94) + ##### :gear: transfer Transfer ICP from the caller to the destination `accountIdentifier`. @@ -262,8 +308,12 @@ Returns the index of the block containing the tx if it was successful. | ---------- | ----------------------------------------------- | | `transfer` | `(request: TransferRequest) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/ledger.canister.ts#L107) + ### :factory: GovernanceCanister +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L106) + #### Methods - [create](#gear-create) @@ -303,6 +353,8 @@ Returns the index of the block containing the tx if it was successful. | -------- | ------------------------------------------------------------- | | `create` | `(options?: GovernanceCanisterOptions) => GovernanceCanister` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L121) + ##### :gear: listNeurons Returns the list of neurons controlled by the caller. @@ -316,6 +368,8 @@ it is fetched using a query call. | ------------- | ----------------------------------------------------------------------------------------------------- | | `listNeurons` | `({ certified, neuronIds, }: { certified: boolean; neuronIds?: bigint[]; }) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L153) + ##### :gear: listKnownNeurons Returns the list of neurons who have been approved by the community to @@ -328,6 +382,8 @@ it is fetched using a query call. | ------------------ | ------------------------------------------------- | | `listKnownNeurons` | `(certified?: boolean) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L185) + ##### :gear: getLastestRewardEvent Returns the latest reward event. @@ -339,6 +395,8 @@ it's fetched using a query call. | ----------------------- | ----------------------------------------------- | | `getLastestRewardEvent` | `(certified?: boolean) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L208) + ##### :gear: listProposals Returns the list of proposals made for the community to vote on, @@ -356,12 +414,16 @@ Parameters: - `request`: the options to list the proposals (limit number of results, topics to search for, etc.) - `certified`: query or update calls +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L224) + ##### :gear: stakeNeuron | Method | Type | | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `stakeNeuron` | `({ stake, principal, fromSubAccount, ledgerCanister, createdAt, fee, }: { stake: bigint; principal: Principal; fromSubAccount?: number[]; ledgerCanister: LedgerCanister; createdAt?: bigint; fee?: bigint; }) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L244) + ##### :gear: increaseDissolveDelay Increases dissolve delay of a neuron @@ -370,6 +432,8 @@ Increases dissolve delay of a neuron | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------- | | `increaseDissolveDelay` | `({ neuronId, additionalDissolveDelaySeconds, }: { neuronId: bigint; additionalDissolveDelaySeconds: number; }) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L305) + ##### :gear: setDissolveDelay Sets dissolve delay of a neuron. @@ -379,6 +443,8 @@ The new date is now + dissolveDelaySeconds. | ------------------ | ------------------------------------------------------------------------------------------------------------- | | `setDissolveDelay` | `({ neuronId, dissolveDelaySeconds, }: { neuronId: bigint; dissolveDelaySeconds: number; }) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L337) + ##### :gear: startDissolving Start dissolving process of a neuron @@ -387,6 +453,8 @@ Start dissolving process of a neuron | ----------------- | ------------------------------------- | | `startDissolving` | `(neuronId: bigint) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L360) + ##### :gear: stopDissolving Stop dissolving process of a neuron @@ -395,6 +463,8 @@ Stop dissolving process of a neuron | ---------------- | ------------------------------------- | | `stopDissolving` | `(neuronId: bigint) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L377) + ##### :gear: joinCommunityFund Neuron joins the community fund @@ -403,6 +473,8 @@ Neuron joins the community fund | ------------------- | ------------------------------------- | | `joinCommunityFund` | `(neuronId: bigint) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L394) + ##### :gear: autoStakeMaturity Changes auto-stake maturity for this Neuron. While on, auto-stake maturity will cause all the maturity generated by voting rewards to this neuron to be automatically staked and contribute to the voting power of the neuron. @@ -416,6 +488,8 @@ Parameters: - `neuronId`: The id of the neuron for which to request a change of the auto stake feature - `autoStake`: `true` to enable the auto-stake maturity for this neuron, `false` to turn it off +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L416) + ##### :gear: leaveCommunityFund Neuron leaves the community fund @@ -424,6 +498,8 @@ Neuron leaves the community fund | -------------------- | ------------------------------------- | | `leaveCommunityFund` | `(neuronId: bigint) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L430) + ##### :gear: setNodeProviderAccount Sets node provider reward account. @@ -433,6 +509,8 @@ Where the reward is paid to. | ------------------------ | ---------------------------------------------- | | `setNodeProviderAccount` | `(accountIdentifier: string) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L447) + ##### :gear: mergeNeurons Merge two neurons @@ -441,6 +519,8 @@ Merge two neurons | -------------- | --------------------------------------------------------------------------------- | | `mergeNeurons` | `(request: { sourceNeuronId: bigint; targetNeuronId: bigint; }) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L467) + ##### :gear: simulateMergeNeurons Simulate merging two neurons @@ -449,6 +529,8 @@ Simulate merging two neurons | ---------------------- | --------------------------------------------------------------------------------------- | | `simulateMergeNeurons` | `(request: { sourceNeuronId: bigint; targetNeuronId: bigint; }) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L484) + ##### :gear: splitNeuron Splits a neuron creating a new one @@ -457,6 +539,8 @@ Splits a neuron creating a new one | ------------- | ----------------------------------------------------------------------------------- | | `splitNeuron` | `({ neuronId, amount, }: { neuronId: bigint; amount: bigint; }) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L529) + ##### :gear: getProposal Returns single proposal info @@ -468,6 +552,8 @@ it is fetched using a query call. | ------------- | ----------------------------------------------------------------------------------------------------- | | `getProposal` | `({ proposalId, certified, }: { proposalId: bigint; certified?: boolean; }) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L569) + ##### :gear: makeProposal Create new proposal @@ -476,6 +562,8 @@ Create new proposal | -------------- | ------------------------------------------------- | | `makeProposal` | `(request: MakeProposalRequest) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L586) + ##### :gear: registerVote Registers vote for a proposal from the neuron passed. @@ -484,6 +572,8 @@ Registers vote for a proposal from the neuron passed. | -------------- | ----------------------------------------------------------------------------------------------------------- | | `registerVote` | `({ neuronId, vote, proposalId, }: { neuronId: bigint; vote: Vote; proposalId: bigint; }) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L601) + ##### :gear: setFollowees Edit neuron followees per topic @@ -492,6 +582,8 @@ Edit neuron followees per topic | -------------- | ------------------------------------------------- | | `setFollowees` | `(followRequest: FollowRequest) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L623) + ##### :gear: disburse Disburse neuron on Account @@ -500,6 +592,8 @@ Disburse neuron on Account | ---------- | --------------------------------------------------------------------------------------------------------------------- | | `disburse` | `({ neuronId, toAccountId, amount, }: { neuronId: bigint; toAccountId?: string; amount?: bigint; }) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L638) + ##### :gear: mergeMaturity Merge Maturity of a neuron @@ -508,6 +602,8 @@ Merge Maturity of a neuron | --------------- | ------------------------------------------------------------------------------------------------------- | | `mergeMaturity` | `({ neuronId, percentageToMerge, }: { neuronId: bigint; percentageToMerge: number; }) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L677) + ##### :gear: stakeMaturity Stake the maturity of a neuron. @@ -521,6 +617,8 @@ Parameters: - `neuronId`: The id of the neuron for which to stake the maturity - `percentageToStake`: Optional. Percentage of the current maturity to stake. If not provided, all of the neuron's current maturity will be staked. +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L710) + ##### :gear: spawnNeuron Merge Maturity of a neuron @@ -529,6 +627,8 @@ Merge Maturity of a neuron | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `spawnNeuron` | `({ neuronId, percentageToSpawn, newController, nonce, }: { neuronId: bigint; percentageToSpawn?: number; newController?: Principal; nonce?: bigint; }) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L732) + ##### :gear: addHotkey Add hotkey to neuron @@ -537,6 +637,8 @@ Add hotkey to neuron | ----------- | ------------------------------------------------------------------------------------------ | | `addHotkey` | `({ neuronId, principal, }: { neuronId: bigint; principal: Principal; }) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L786) + ##### :gear: removeHotkey Remove hotkey to neuron @@ -545,6 +647,8 @@ Remove hotkey to neuron | -------------- | ------------------------------------------------------------------------------------------ | | `removeHotkey` | `({ neuronId, principal, }: { neuronId: bigint; principal: Principal; }) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L810) + ##### :gear: claimOrRefreshNeuronFromAccount Gets the NeuronID of a newly created neuron. @@ -553,6 +657,8 @@ Gets the NeuronID of a newly created neuron. | --------------------------------- | --------------------------------------------------------------------------------------- | | `claimOrRefreshNeuronFromAccount` | `({ memo, controller, }: { memo: bigint; controller?: Principal; }) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L831) + ##### :gear: claimOrRefreshNeuron Refreshes neuron and returns neuronId when successful @@ -562,6 +668,8 @@ Uses query call only. | ---------------------- | ----------------------------------------------------------- | | `claimOrRefreshNeuron` | `(request: ClaimOrRefreshNeuronRequest) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L862) + ##### :gear: getNeuron Return the data of the neuron provided as id. @@ -570,10 +678,14 @@ Return the data of the neuron provided as id. | ----------- | ---------------------------------------------------------------------------------------------- | | `getNeuron` | `({ certified, neuronId, }: { certified: boolean; neuronId: bigint; }) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L897) + ### :factory: ICP We don't extend to keep `fromE8s` and `fromString` as backwards compatible. +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/icp.ts#L14) + #### Methods - [fromE8s](#gear-frome8s) @@ -587,6 +699,8 @@ We don't extend to keep `fromE8s` and `fromString` as backwards compatible. | --------- | ------------------------- | | `fromE8s` | `(amount: bigint) => ICP` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/icp.ts#L17) + ##### :gear: fromString Initialize from a string. Accepted formats: @@ -599,20 +713,28 @@ Initialize from a string. Accepted formats: | ------------ | --------------------------------------------------- | | `fromString` | `(amount: string) => ICP or FromStringToTokenError` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/icp.ts#L28) + ##### :gear: toE8s | Method | Type | | ------- | -------------- | | `toE8s` | `() => bigint` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/icp.ts#L36) + ##### :gear: toProto | Method | Type | | --------- | ---------------------- | | `toProto` | `() => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/icp.ts#L40) + ### :factory: SnsWasmCanister +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/sns_wasm.canister.ts#L10) + #### Methods - [create](#gear-create) @@ -624,10 +746,14 @@ Initialize from a string. Accepted formats: | -------- | ---------------------------------------------------------- | | `create` | `(options?: CanisterOptions<_SERVICE>) => SnsWasmCanister` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/sns_wasm.canister.ts#L16) + ##### :gear: listSnses | Method | Type | | ----------- | ---------------------------------------------------------------------- | | `listSnses` | `({ certified, }: { certified?: boolean; }) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/sns_wasm.canister.ts#L29) + diff --git a/packages/sns/README.md b/packages/sns/README.md index 7656874b..fa49db3a 100644 --- a/packages/sns/README.md +++ b/packages/sns/README.md @@ -79,17 +79,11 @@ Lookup for the canister ids of a Sns and initialize the wrapper to access its fe | ---------------- | ---------------- | | `initSnsWrapper` | `InitSnsWrapper` | -### :factory: SnsGovernanceCanister - -#### Constructors +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.ts#L33) -`public` - -Parameters: +### :factory: SnsGovernanceCanister -- `id` -- `service` -- `certifiedService` +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L60) #### Methods @@ -130,6 +124,8 @@ Parameters: - `options`: Miscellaneous options to initialize the canister. Its ID being the only mandatory parammeter. +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L66) + ##### :gear: listNeurons List the neurons of the Sns @@ -138,6 +134,8 @@ List the neurons of the Sns | ------------- | ----------------------------------------------------- | | `listNeurons` | `(params: SnsListNeuronsParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L80) + ##### :gear: listProposals List the proposals of the Sns @@ -146,6 +144,8 @@ List the proposals of the Sns | --------------- | ------------------------------------------------------------- | | `listProposals` | `(params: SnsListProposalsParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L94) + ##### :gear: getProposal Get the proposal of the Sns @@ -154,6 +154,8 @@ Get the proposal of the Sns | ------------- | --------------------------------------------------------- | | `getProposal` | `(params: SnsGetProposalParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L108) + ##### :gear: listNervousSystemFunctions List Nervous System Functions @@ -163,6 +165,8 @@ Neurons can follow other neurons in specific Nervous System Functions. | ---------------------------- | ---------------------------------------------------------------------- | | `listNervousSystemFunctions` | `(params: QueryParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L127) + ##### :gear: metadata Get the Sns metadata (title, description, etc.) @@ -171,6 +175,8 @@ Get the Sns metadata (title, description, etc.) | ---------- | ------------------------------------------------------- | | `metadata` | `(params: QueryParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L135) + ##### :gear: nervousSystemParameters Get the Sns nervous system parameters (default followees, max dissolve delay, max number of neurons, etc.) @@ -179,6 +185,8 @@ Get the Sns nervous system parameters (default followees, max dissolve delay, ma | ------------------------- | ----------------------------------------------------------- | | `nervousSystemParameters` | `(params: QueryParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L141) + ##### :gear: getNeuron Get the neuron of the Sns @@ -187,6 +195,8 @@ Get the neuron of the Sns | ----------- | ------------------------------------------------- | | `getNeuron` | `(params: SnsGetNeuronParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L149) + ##### :gear: queryNeuron Same as `getNeuron` but returns undefined instead of raising error when not found. @@ -195,6 +205,8 @@ Same as `getNeuron` but returns undefined instead of raising error when not foun | ------------- | ------------------------------------------------- | | `queryNeuron` | `(params: SnsGetNeuronParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L167) + ##### :gear: manageNeuron Manage neuron. For advanced users. @@ -203,6 +215,8 @@ Manage neuron. For advanced users. | -------------- | ---------------------------------------------------------- | | `manageNeuron` | `(request: ManageNeuron) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L187) + ##### :gear: addNeuronPermissions Add permissions to a neuron for a specific principal @@ -211,6 +225,8 @@ Add permissions to a neuron for a specific principal | ---------------------- | ------------------------------------------------------- | | `addNeuronPermissions` | `(params: SnsNeuronPermissionsParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L200) + ##### :gear: removeNeuronPermissions Remove permissions to a neuron for a specific principal @@ -219,6 +235,8 @@ Remove permissions to a neuron for a specific principal | ------------------------- | ------------------------------------------------------- | | `removeNeuronPermissions` | `(params: SnsNeuronPermissionsParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L210) + ##### :gear: splitNeuron Split neuron @@ -227,6 +245,8 @@ Split neuron | ------------- | ----------------------------------------------------- | | `splitNeuron` | `(params: SnsSplitNeuronParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L220) + ##### :gear: disburse Disburse neuron on Account @@ -235,6 +255,8 @@ Disburse neuron on Account | ---------- | ---------------------------------------------------- | | `disburse` | `(params: SnsDisburseNeuronParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L251) + ##### :gear: startDissolving Start dissolving process of a neuron @@ -243,6 +265,8 @@ Start dissolving process of a neuron | ----------------- | --------------------------------------- | | `startDissolving` | `(neuronId: NeuronId) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L259) + ##### :gear: stopDissolving Stop dissolving process of a neuron @@ -251,6 +275,8 @@ Stop dissolving process of a neuron | ---------------- | --------------------------------------- | | `stopDissolving` | `(neuronId: NeuronId) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L267) + ##### :gear: stakeMaturity Stake the maturity of a neuron. @@ -264,6 +290,8 @@ Parameters: - `neuronId`: The id of the neuron for which to stake the maturity - `percentageToStake`: Optional. Percentage of the current maturity to stake. If not provided, all of the neuron's current maturity will be staked. +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L279) + ##### :gear: autoStakeMaturity Changes auto-stake maturity for a Neuron. @@ -277,6 +305,8 @@ Parameters: - `neuronId`: The id of the neuron for which to request a change of the auto stake feature - `autoStake`: `true` to enable the auto-stake maturity for this neuron, `false` to turn it off +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L299) + ##### :gear: setDissolveTimestamp Increase dissolve delay of a neuron @@ -285,6 +315,8 @@ Increase dissolve delay of a neuron | ---------------------- | ---------------------------------------------------------- | | `setDissolveTimestamp` | `(params: SnsSetDissolveTimestampParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L309) + ##### :gear: increaseDissolveDelay Increase dissolve delay of a neuron @@ -293,6 +325,8 @@ Increase dissolve delay of a neuron | ----------------------- | ----------------------------------------------------------- | | `increaseDissolveDelay` | `(params: SnsIncreaseDissolveDelayParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L319) + ##### :gear: setTopicFollowees Sets followees of a neuron for a specific Nervous System Function (topic) @@ -301,6 +335,8 @@ Sets followees of a neuron for a specific Nervous System Function (topic) | ------------------- | ------------------------------------------------- | | `setTopicFollowees` | `(params: SnsSetTopicFollowees) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L329) + ##### :gear: registerVote Registers vote for a proposal from the neuron passed. @@ -309,6 +345,8 @@ Registers vote for a proposal from the neuron passed. | -------------- | -------------------------------------------------- | | `registerVote` | `(params: SnsRegisterVoteParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L337) + ##### :gear: refreshNeuron Refresh neuron @@ -317,6 +355,8 @@ Refresh neuron | --------------- | --------------------------------------- | | `refreshNeuron` | `(neuronId: NeuronId) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L345) + ##### :gear: claimNeuron Claim neuron @@ -325,17 +365,11 @@ Claim neuron | ------------- | -------------------------------------------------------------------------------- | | `claimNeuron` | `({ memo, controller, subaccount, }: SnsClaimNeuronParams) => Promise` | -### :factory: SnsRootCanister - -#### Constructors - -`public` +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L355) -Parameters: +### :factory: SnsRootCanister -- `id` -- `service` -- `certifiedService` +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/root.canister.ts#L10) #### Methods @@ -348,6 +382,8 @@ Parameters: | -------- | ------------------------------------------------------------ | | `create` | `(options: SnsCanisterOptions<_SERVICE>) => SnsRootCanister` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/root.canister.ts#L11) + ##### :gear: listSnsCanisters List the canisters that are part of the Sns. @@ -358,17 +394,11 @@ Source code: https://github.com/dfinity/ic/blob/master/rs/sns/root/src/lib.rs | ------------------ | --------------------------------------------------------------------------------- | | `listSnsCanisters` | `({ certified, }: { certified?: boolean; }) => Promise` | -### :factory: SnsSwapCanister - -#### Constructors +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/root.canister.ts#L32) -`public` - -Parameters: +### :factory: SnsSwapCanister -- `id` -- `service` -- `certifiedService` +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/swap.canister.ts#L30) #### Methods @@ -389,6 +419,8 @@ Parameters: | -------- | ------------------------------------------------------------ | | `create` | `(options: SnsCanisterOptions<_SERVICE>) => SnsSwapCanister` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/swap.canister.ts#L31) + ##### :gear: state Get the state of the swap @@ -397,6 +429,8 @@ Get the state of the swap | ------- | ---------------------------------------------------- | | `state` | `(params: QueryParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/swap.canister.ts#L45) + ##### :gear: notifyPaymentFailure Notify of the payment failure to remove the ticket @@ -405,6 +439,8 @@ Notify of the payment failure to remove the ticket | ---------------------- | ----------------------- | | `notifyPaymentFailure` | `() => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/swap.canister.ts#L51) + ##### :gear: notifyParticipation Notify of the user participating in the swap @@ -413,6 +449,8 @@ Notify of the user participating in the swap | --------------------- | ---------------------------------------------------------------------------- | | `notifyParticipation` | `(params: RefreshBuyerTokensRequest) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/swap.canister.ts#L61) + ##### :gear: getUserCommitment Get user commitment @@ -421,6 +459,8 @@ Get user commitment | ------------------- | ----------------------------------------------------------------------- | | `getUserCommitment` | `(params: GetBuyerStateRequest and QueryParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/swap.canister.ts#L69) + ##### :gear: getDerivedState Get sale buyers state @@ -429,6 +469,8 @@ Get sale buyers state | ----------------- | ------------------------------------------------------------------- | | `getDerivedState` | `({ certified, }: QueryParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/swap.canister.ts#L81) + ##### :gear: getSaleParameters Get sale parameters @@ -437,6 +479,8 @@ Get sale parameters | ------------------- | --------------------------------------------------------------------- | | `getSaleParameters` | `({ certified, }: QueryParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/swap.canister.ts#L90) + ##### :gear: getOpenTicket Return a sale ticket if created and not yet removed (payment flow) @@ -445,6 +489,8 @@ Return a sale ticket if created and not yet removed (payment flow) | --------------- | ------------------------------------------ | | `getOpenTicket` | `(params: QueryParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/swap.canister.ts#L99) + ##### :gear: newSaleTicket Create a sale ticket (payment flow) @@ -453,6 +499,8 @@ Create a sale ticket (payment flow) | --------------- | -------------------------------------------------- | | `newSaleTicket` | `(params: NewSaleTicketParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/swap.canister.ts#L116) + ##### :gear: getLifecycle Get sale lifecycle state @@ -461,12 +509,16 @@ Get sale lifecycle state | -------------- | -------------------------------------------------------- | | `getLifecycle` | `(params: QueryParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/swap.canister.ts#L141) + ### :factory: SnsWrapper Sns wrapper - notably used by NNS-dapp - ease the access to a particular Sns. It knows all the Sns' canisters, wrap and enhance their available features. A wrapper either performs query or update calls. +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L82) + #### Constructors `public`: Constructor to instantiate a Sns @@ -525,78 +577,104 @@ Parameters: | ------------- | ------------------------------------------------------------------------ | | `listNeurons` | `(params: Omit) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L128) + ##### :gear: listProposals | Method | Type | | --------------- | -------------------------------------------------------------------------------- | | `listProposals` | `(params: Omit) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L132) + ##### :gear: getProposal | Method | Type | | ------------- | ---------------------------------------------------------------------------- | | `getProposal` | `(params: Omit) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L137) + ##### :gear: listNervousSystemFunctions | Method | Type | | ---------------------------- | ----------------------------------------------------------------------------------------- | | `listNervousSystemFunctions` | `(params: Omit) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L142) + ##### :gear: metadata | Method | Type | | ---------- | ------------------------------------------------------------------------------------------------------- | | `metadata` | `(params: Omit) => Promise<[GetMetadataResponse, IcrcTokenMetadataResponse]>` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L147) + ##### :gear: nervousSystemParameters | Method | Type | | ------------------------- | ------------------------------------------------------------------------------ | | `nervousSystemParameters` | `(params: Omit) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L155) + ##### :gear: ledgerMetadata | Method | Type | | ---------------- | -------------------------------------------------------------------------------- | | `ledgerMetadata` | `(params: Omit) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L160) + ##### :gear: transactionFee | Method | Type | | ---------------- | ------------------------------------------------------------- | | `transactionFee` | `(params: Omit) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L165) + ##### :gear: totalTokensSupply | Method | Type | | ------------------- | ------------------------------------------------------------- | | `totalTokensSupply` | `(params: Omit) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L170) + ##### :gear: balance | Method | Type | | --------- | --------------------------------------------------------------- | | `balance` | `(params: Omit) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L175) + ##### :gear: transfer | Method | Type | | ---------- | --------------------------------------------- | | `transfer` | `(params: TransferParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L179) + ##### :gear: getNeuron | Method | Type | | ----------- | -------------------------------------------------------------------- | | `getNeuron` | `(params: Omit) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L182) + ##### :gear: queryNeuron | Method | Type | | ------------- | -------------------------------------------------------------------- | | `queryNeuron` | `(params: Omit) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L186) + ##### :gear: nextNeuronAccount Returns the subaccount of the next neuron to be created. @@ -615,6 +693,8 @@ This is how the backend can identify which neuron is being claimed. | ------------------- | ------------------------------------------------------------------------------ | | `nextNeuronAccount` | `(controller: Principal) => Promise<{ account: IcrcAccount; index: bigint; }>` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L207) + ##### :gear: stakeNeuron Stakes a neuron. @@ -627,6 +707,8 @@ This is a convenient method that transfers the stake to the neuron subaccount an | ------------- | ------------------------------------------------------------------------------------------------ | | `stakeNeuron` | `({ stakeE8s, source, controller, createdAt, fee, }: SnsStakeNeuronParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L254) + ##### :gear: increaseStakeNeuron Increase the stake of a neuron. @@ -639,90 +721,120 @@ This is a convenient method that transfers the stake to the neuron subaccount an | --------------------- | ---------------------------------------------------------------------------------- | | `increaseStakeNeuron` | `({ stakeE8s, source, neuronId, }: SnsIncreaseStakeNeuronParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L302) + ##### :gear: getNeuronBalance | Method | Type | | ------------------ | ----------------------------------------- | | `getNeuronBalance` | `(neuronId: NeuronId) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L321) + ##### :gear: addNeuronPermissions | Method | Type | | ---------------------- | ------------------------------------------------------- | | `addNeuronPermissions` | `(params: SnsNeuronPermissionsParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L330) + ##### :gear: refreshNeuron | Method | Type | | --------------- | --------------------------------------- | | `refreshNeuron` | `(neuronId: NeuronId) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L334) + ##### :gear: claimNeuron | Method | Type | | ------------- | ----------------------------------------------------- | | `claimNeuron` | `(params: SnsClaimNeuronParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L338) + ##### :gear: removeNeuronPermissions | Method | Type | | ------------------------- | ------------------------------------------------------- | | `removeNeuronPermissions` | `(params: SnsNeuronPermissionsParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L342) + ##### :gear: splitNeuron | Method | Type | | ------------- | ----------------------------------------------------- | | `splitNeuron` | `(params: SnsSplitNeuronParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L347) + ##### :gear: disburse | Method | Type | | ---------- | ---------------------------------------------------- | | `disburse` | `(params: SnsDisburseNeuronParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L351) + ##### :gear: startDissolving | Method | Type | | ----------------- | --------------------------------------- | | `startDissolving` | `(neuronId: NeuronId) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L355) + ##### :gear: stopDissolving | Method | Type | | ---------------- | --------------------------------------- | | `stopDissolving` | `(neuronId: NeuronId) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L359) + ##### :gear: setDissolveTimestamp | Method | Type | | ---------------------- | ---------------------------------------------------------- | | `setDissolveTimestamp` | `(params: SnsSetDissolveTimestampParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L363) + ##### :gear: increaseDissolveDelay | Method | Type | | ----------------------- | ----------------------------------------------------------- | | `increaseDissolveDelay` | `(params: SnsIncreaseDissolveDelayParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L368) + ##### :gear: setTopicFollowees | Method | Type | | ------------------- | ------------------------------------------------- | | `setTopicFollowees` | `(params: SnsSetTopicFollowees) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L373) + ##### :gear: registerVote | Method | Type | | -------------- | -------------------------------------------------- | | `registerVote` | `(params: SnsRegisterVoteParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L377) + ##### :gear: swapState | Method | Type | | ----------- | ----------------------------------------------------------------------- | | `swapState` | `(params: Omit) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L380) + ##### :gear: notifyPaymentFailure Returns the ticket if a ticket was found for the caller and the ticket @@ -735,64 +847,86 @@ Always certified | ---------------------- | ----------------------- | | `notifyPaymentFailure` | `() => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L393) + ##### :gear: notifyParticipation | Method | Type | | --------------------- | ---------------------------------------------------------------------------- | | `notifyParticipation` | `(params: RefreshBuyerTokensRequest) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L397) + ##### :gear: getUserCommitment | Method | Type | | ------------------- | ------------------------------------------------------- | | `getUserCommitment` | `(params: GetBuyerStateRequest) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L402) + ##### :gear: getOpenTicket | Method | Type | | --------------- | ------------------------------------------------------------- | | `getOpenTicket` | `(params: Omit) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L407) + ##### :gear: newSaleTicket | Method | Type | | --------------- | -------------------------------------------------- | | `newSaleTicket` | `(params: NewSaleTicketParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L413) + ##### :gear: getLifecycle | Method | Type | | -------------- | --------------------------------------------------------------------------- | | `getLifecycle` | `(params: Omit) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L416) + ##### :gear: getSaleParameters | Method | Type | | ------------------- | -------------------------------------------------------------------------------- | | `getSaleParameters` | `(params: Omit) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L421) + ##### :gear: getDerivedState | Method | Type | | ----------------- | ------------------------------------------------------------------------------ | | `getDerivedState` | `(params: Omit) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L426) + ##### :gear: getTransactions | Method | Type | | ----------------- | -------------------------------------------------------------------- | | `getTransactions` | `(params: GetAccountTransactionsParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L432) + ##### :gear: stakeMaturity | Method | Type | | --------------- | --------------------------------------------------------- | | `stakeMaturity` | `(params: SnsNeuronStakeMaturityParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L437) + ##### :gear: autoStakeMaturity | Method | Type | | ------------------- | ------------------------------------------------------------- | | `autoStakeMaturity` | `(params: SnsNeuronAutoStakeMaturityParams) => Promise` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/sns.wrapper.ts#L441) + diff --git a/packages/utils/README.md b/packages/utils/README.md index 94a0c07a..a14deb67 100644 --- a/packages/utils/README.md +++ b/packages/utils/README.md @@ -71,6 +71,8 @@ Parameters: - `amount`: - in string format +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/parser/token.ts#L10) + #### :gear: defaultAgent Get a default agent that connects to mainnet with the anonymous identity. @@ -79,6 +81,8 @@ Get a default agent that connects to mainnet with the anonymous identity. | -------------- | ------------- | | `defaultAgent` | `() => Agent` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/agent.utils.ts#L8) + #### :gear: createAgent Create an agent for a given identity @@ -93,78 +97,104 @@ Parameters: - `host`: An optional host to connect to - `fetchRootKey`: Fetch root key for certificate validation during local development or on testnet +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/agent.utils.ts#L20) + #### :gear: createServices | Function | Type | | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `createServices` | `({ options: { canisterId, serviceOverride, certifiedServiceOverride, agent: agentOption, }, idlFactory, certifiedIdlFactory, }: { options: RequiredCanisterOptions; idlFactory: InterfaceFactory; certifiedIdlFactory: InterfaceFactory; }) => { ...; }` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/actor.utils.ts#L13) + #### :gear: assertNonNullish | Function | Type | | ------------------ | -------------------------------------------------------------------- | | `assertNonNullish` | `(value: T, message?: string) => asserts value is NonNullable` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/asserts.utils.ts#L7) + #### :gear: assertPercentageNumber | Function | Type | | ------------------------ | ------------------------------ | | `assertPercentageNumber` | `(percentage: number) => void` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/asserts.utils.ts#L15) + #### :gear: uint8ArrayToBigInt | Function | Type | | -------------------- | ------------------------------- | | `uint8ArrayToBigInt` | `(array: Uint8Array) => bigint` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/arrays.utils.ts#L3) + #### :gear: bigIntToUint8Array | Function | Type | | -------------------- | ------------------------------- | | `bigIntToUint8Array` | `(value: bigint) => Uint8Array` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/arrays.utils.ts#L15) + #### :gear: numberToUint8Array | Function | Type | | -------------------- | ------------------------------- | | `numberToUint8Array` | `(value: number) => Uint8Array` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/arrays.utils.ts#L31) + #### :gear: arrayBufferToUint8Array | Function | Type | | ------------------------- | ------------------------------------- | | `arrayBufferToUint8Array` | `(buffer: ArrayBuffer) => Uint8Array` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/arrays.utils.ts#L40) + #### :gear: uint8ArrayToArrayOfNumber | Function | Type | | --------------------------- | --------------------------------- | | `uint8ArrayToArrayOfNumber` | `(array: Uint8Array) => number[]` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/arrays.utils.ts#L43) + #### :gear: arrayOfNumberToUint8Array | Function | Type | | --------------------------- | ----------------------------------- | | `arrayOfNumberToUint8Array` | `(numbers: number[]) => Uint8Array` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/arrays.utils.ts#L46) + #### :gear: asciiStringToByteArray | Function | Type | | ------------------------ | ---------------------------- | | `asciiStringToByteArray` | `(text: string) => number[]` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/arrays.utils.ts#L49) + #### :gear: hexStringToUint8Array | Function | Type | | ----------------------- | ----------------------------------- | | `hexStringToUint8Array` | `(hexString: string) => Uint8Array` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/arrays.utils.ts#L52) + #### :gear: uint8ArrayToHexString | Function | Type | | ----------------------- | ------------------------------- | | `uint8ArrayToHexString` | `(bytes: Uint8Array) => string` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/arrays.utils.ts#L60) + #### :gear: encodeBase32 Encode an Uint8Array to a base32 string. @@ -177,6 +207,8 @@ Parameters: - `input`: The input array to encode. +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/base32.utils.ts#L21) + #### :gear: decodeBase32 Decode a base32 string to Uint8Array. @@ -190,18 +222,24 @@ Parameters: - `input`: The input string to decode. - `input`: The base32 encoded string to decode. +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/base32.utils.ts#L67) + #### :gear: bigEndianCrc32 | Function | Type | | ---------------- | ----------------------------------- | | `bigEndianCrc32` | `(bytes: Uint8Array) => Uint8Array` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/crc.utils.ts#L61) + #### :gear: debounce | Function | Type | | ---------- | -------------------------------------------------------------------- | | `debounce` | `(func: Function, timeout?: number) => (...args: unknown[]) => void` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/debounce.utils.ts#L2) + #### :gear: isNullish Is null or undefined @@ -210,6 +248,8 @@ Is null or undefined | ----------- | -------------------------------------- | | `isNullish` | `(argument: T) => argument is null` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/nullish.utils.ts#L2) + #### :gear: nonNullish Not null and not undefined @@ -218,6 +258,8 @@ Not null and not undefined | ------------ | ------------------------------------------------ | | `nonNullish` | `(argument: T) => argument is NonNullable` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/nullish.utils.ts#L7) + #### :gear: notEmptyString Not null and not undefined and not empty @@ -226,24 +268,32 @@ Not null and not undefined and not empty | ---------------- | ---------------------------- | | `notEmptyString` | `(value: string) => boolean` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/nullish.utils.ts#L12) + #### :gear: toNullable | Function | Type | | ------------ | ----------------------------- | | `toNullable` | `(value?: T) => [] or [T]` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/did.utils.ts#L4) + #### :gear: fromNullable | Function | Type | | -------------- | ---------------------------- | | `fromNullable` | `(value: [] or [T]) => T` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/did.utils.ts#L8) + #### :gear: fromDefinedNullable | Function | Type | | --------------------- | ---------------------------- | | `fromDefinedNullable` | `(value: [] or [T]) => T` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/did.utils.ts#L12) + #### :gear: principalToSubAccount Convert a principal to a Uint8Array 32 length. @@ -257,6 +307,8 @@ Parameters: - `principal`: The principal that needs to be converted to Subaccount +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/principal.utils.ts#L8) + #### :gear: smallerVersion Returns true if the current version is smaller than the minVersion, false if equal or bigger. @@ -266,6 +318,8 @@ Tags after patch version are ignored, e.g. 1.0.0-beta.1 is considered equal to 1 | ---------------- | ----------------------------------------------------------------------------------------------- | | `smallerVersion` | `({ minVersion, currentVersion, }: { minVersion: string; currentVersion: string; }) => boolean` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/version.utils.ts#L28) + ### :wrench: Constants - [E8S_PER_TOKEN](#gear-e8s_per_token) @@ -277,16 +331,22 @@ Tags after patch version are ignored, e.g. 1.0.0-beta.1 is considered equal to 1 | --------------- | -------- | | `E8S_PER_TOKEN` | `bigint` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/constants/constants.ts#L1) + #### :gear: ICPToken | Constant | Type | | ---------- | ------- | | `ICPToken` | `Token` | +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/parser/token.ts#L62) + ### :factory: TokenAmount Represents an amount of tokens. +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/parser/token.ts#L73) + #### Methods - [fromE8s](#gear-frome8s) @@ -307,6 +367,8 @@ Parameters: - `params.amount`: The amount in bigint format. - `params.token`: The token type. +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/parser/token.ts#L83) + ##### :gear: fromString Initialize from a string. Accepted formats: @@ -324,6 +386,8 @@ Parameters: - `params.amount`: The amount in string format. - `params.token`: The token type. +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/parser/token.ts#L104) + ##### :gear: fromNumber Initialize from a number. @@ -339,42 +403,26 @@ Parameters: - `params.amount`: The amount in number format. - `params.token`: The token type. +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/parser/token.ts#L128) + ##### :gear: toE8s | Method | Type | | ------- | -------------- | | `toE8s` | `() => bigint` | -### :factory: Canister - -#### Constructors +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/parser/token.ts#L154) -`public` - -Parameters: +### :factory: Canister -- `id` -- `service` -- `certifiedService` +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/services/canister.ts#L4) ### :factory: InvalidPercentageError -#### Constructors - -`public` - -Parameters: - -- `message` +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/asserts.utils.ts#L1) ### :factory: NullishError -#### Constructors - -`public` - -Parameters: - -- `message` +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/asserts.utils.ts#L2) diff --git a/scripts/docs.js b/scripts/docs.js index 44a0a1d6..af681bdb 100644 --- a/scripts/docs.js +++ b/scripts/docs.js @@ -44,51 +44,66 @@ const icMgmtInputFiles = [ "./packages/ic-management/src/ic-management.canister.ts", ]; +const buildOptions = { + repo: { url: "https://github.com/dfinity/ic-js" }, +}; + +const markdownOptions = { + headingLevel: "###", +}; + generateDocumentation({ inputFiles: nnsInputFiles, outputFile: "./packages/nns/README.md", - markdownOptions: { headingLevel: "###" }, + markdownOptions, + buildOptions, }); generateDocumentation({ inputFiles: snsInputFiles, outputFile: "./packages/sns/README.md", - markdownOptions: { headingLevel: "###" }, + markdownOptions, + buildOptions, }); generateDocumentation({ inputFiles: cmcInputFiles, outputFile: "./packages/cmc/README.md", - markdownOptions: { headingLevel: "###" }, + markdownOptions, + buildOptions, }); generateDocumentation({ inputFiles: ledgerInputFiles, outputFile: "./packages/ledger/README.md", - markdownOptions: { headingLevel: "###" }, + markdownOptions, + buildOptions, }); generateDocumentation({ inputFiles: ckBTCInputFiles, outputFile: "./packages/ckbtc/README.md", - markdownOptions: { headingLevel: "###" }, + markdownOptions, + buildOptions, }); generateDocumentation({ inputFiles: utilsInputFiles, outputFile: "./packages/utils/README.md", - markdownOptions: { headingLevel: "###" }, - buildOptions: { explore: true }, + markdownOptions, + buildOptions: { ...buildOptions, explore: true }, }); generateDocumentation({ inputFiles: rosettaInputFiles, outputFile: "./packages/rosetta-client/README.md", - markdownOptions: { headingLevel: "###" }, + markdownOptions, + buildOptions, }); generateDocumentation({ inputFiles: icMgmtInputFiles, outputFile: "./packages/ic-management/README.md", - markdownOptions: { headingLevel: "###" }, + markdownOptions, + buildOptions, });