diff --git a/packages/ledger-icp/README.md b/packages/ledger-icp/README.md index bbd68c65..cc1425f1 100644 --- a/packages/ledger-icp/README.md +++ b/packages/ledger-icp/README.md @@ -55,6 +55,184 @@ const data = await metadata(); +### :factory: AccountIdentifier + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icp/src/account_identifier.ts#L12) + +#### Methods + +- [fromHex](#gear-fromhex) +- [fromPrincipal](#gear-fromprincipal) +- [toProto](#gear-toproto) +- [toHex](#gear-tohex) +- [toUint8Array](#gear-touint8array) +- [toNumbers](#gear-tonumbers) +- [toAccountIdentifierHash](#gear-toaccountidentifierhash) + +##### :gear: fromHex + +| Method | Type | +| --------- | ------------------------------------ | +| `fromHex` | `(hex: string) => AccountIdentifier` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icp/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/ledger-icp/src/account_identifier.ts#L19) + +##### :gear: toProto + +| Method | Type | +| --------- | ---------------------------------- | +| `toProto` | `() => Promise` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icp/src/account_identifier.ts#L48) + +##### :gear: toHex + +| Method | Type | +| ------- | -------------- | +| `toHex` | `() => string` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icp/src/account_identifier.ts#L56) + +##### :gear: toUint8Array + +| Method | Type | +| -------------- | ------------------ | +| `toUint8Array` | `() => Uint8Array` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icp/src/account_identifier.ts#L60) + +##### :gear: toNumbers + +| Method | Type | +| ----------- | ---------------- | +| `toNumbers` | `() => number[]` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icp/src/account_identifier.ts#L64) + +##### :gear: toAccountIdentifierHash + +| Method | Type | +| ------------------------- | ----------------------------- | +| `toAccountIdentifierHash` | `() => { hash: Uint8Array; }` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icp/src/account_identifier.ts#L68) + +### :factory: SubAccount + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icp/src/account_identifier.ts#L75) + +#### Methods + +- [fromBytes](#gear-frombytes) +- [fromPrincipal](#gear-fromprincipal) +- [fromID](#gear-fromid) +- [toUint8Array](#gear-touint8array) + +##### :gear: fromBytes + +| Method | Type | +| ----------- | -------------------------------------------- | +| `fromBytes` | `(bytes: Uint8Array) => SubAccount or Error` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icp/src/account_identifier.ts#L78) + +##### :gear: fromPrincipal + +| Method | Type | +| --------------- | -------------------------------------- | +| `fromPrincipal` | `(principal: Principal) => SubAccount` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icp/src/account_identifier.ts#L86) + +##### :gear: fromID + +| Method | Type | +| -------- | ---------------------------- | +| `fromID` | `(id: number) => SubAccount` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icp/src/account_identifier.ts#L99) + +##### :gear: toUint8Array + +| Method | Type | +| -------------- | ------------------ | +| `toUint8Array` | `() => Uint8Array` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icp/src/account_identifier.ts#L111) + +### :factory: LedgerCanister + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icp/src/ledger.canister.ts#L32) + +#### Methods + +- [create](#gear-create) +- [accountBalance](#gear-accountbalance) +- [transactionFee](#gear-transactionfee) +- [transfer](#gear-transfer) +- [icrc1Transfer](#gear-icrc1transfer) + +##### :gear: create + +| Method | Type | +| -------- | ----------------------------------------------------- | +| `create` | `(options?: LedgerCanisterOptions) => LedgerCanister` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icp/src/ledger.canister.ts#L43) + +##### :gear: accountBalance + +Returns the balance of the specified account identifier. + +If `certified` is true, the request is fetched as an update call, otherwise +it is fetched using a query call. + +| Method | Type | +| ---------------- | ------------------------------------------------------------------------------------------------------------------------ | +| `accountBalance` | `({ accountIdentifier, certified, }: { accountIdentifier: AccountIdentifier; certified?: boolean; }) => Promise` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icp/src/ledger.canister.ts#L75) + +##### :gear: transactionFee + +Returns the transaction fee of the ledger canister + +| Method | Type | +| ---------------- | ----------------------- | +| `transactionFee` | `() => Promise` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icp/src/ledger.canister.ts#L99) + +##### :gear: transfer + +Transfer ICP from the caller to the destination `accountIdentifier`. +Returns the index of the block containing the tx if it was successful. + +| Method | Type | +| ---------- | ----------------------------------------------- | +| `transfer` | `(request: TransferRequest) => Promise` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icp/src/ledger.canister.ts#L112) + +##### :gear: icrc1Transfer + +Transfer ICP from the caller to the destination `Account`. +Returns the index of the block containing the tx if it was successful. + +| Method | Type | +| --------------- | ---------------------------------------------------- | +| `icrc1Transfer` | `(request: Icrc1TransferRequest) => Promise` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icp/src/ledger.canister.ts#L142) + ## Resources diff --git a/scripts/docs.js b/scripts/docs.js index 20791097..d705b186 100644 --- a/scripts/docs.js +++ b/scripts/docs.js @@ -30,8 +30,8 @@ const ledgerIcrcInputFiles = [ ]; const ledgerICPInputFiles = [ - "./packages/nns/src/ledger.canister.ts", - "./packages/nns/src/account_identifier.ts", + "./packages/ledger-icp/src/ledger.canister.ts", + "./packages/ledger-icp/src/account_identifier.ts", ]; const ckBTCInputFiles = [