-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc generation for viem to account ledger (#390)
### Description It looks like our new package was not included in docs. ### Other changes I narrowed which files were included in docs to just the functions and constants actually exported publically ### Tested <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on enhancing the `@celo/viem-account-ledger` library by updating type definitions, improving documentation, and modifying the CI workflow to include all package directories. ### Detailed summary - Updated `Hex` type definition in `types.ts`. - Added module documentation in `modules.md`. - Updated `typedoc.json` to include README and entry points. - Modified CI workflow to track all package directories. - Changed `LedgerAccount` type to be exported in `ledger-to-account.ts`. - Added detailed documentation for `ledgerToAccount` function. - Enhanced README with installation and usage instructions. - Created detailed module documentation for `ledger-to-account`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
- Loading branch information
Showing
9 changed files
with
199 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
@celo/viem-account-ledger / [Modules](modules.md) | ||
|
||
# @celo/viem-account-ledger | ||
|
||
This library aims to ease the usage of a ledger device with (viem)[https://viem.sh/]. | ||
|
||
## Installation | ||
|
||
```bash | ||
npm install @celo/viem-account-ledger viem@2 @ledgerhq/[email protected] | ||
# or yarn or bun or ... | ||
``` | ||
|
||
> [!IMPORTANT] > `viem` is a peer dependency and MUST be installed alongside this library. | ||
> `@ledgerhq/transport-node-hid` is a peer dependency and MUST be installed alongside this library. | ||
## Usage | ||
|
||
```ts | ||
import TransportNodeHid from '@ledgerhq/hw-transport-node-hid' | ||
import { createWalletClient } from 'viem' | ||
import { celo, celoAlfajores } from 'viem/chains' | ||
import { ledgerToAccount } from '@celo/viem-account-ledger' | ||
|
||
async function main() => { | ||
const account = await ledgerToAccount({ | ||
transport: await TransportNodeHid.open(''), | ||
}) | ||
const client = createWalletClient({ | ||
account, | ||
chain: celo, | ||
transport: http() | ||
}); | ||
await client.sendTransaction({ | ||
to: '0x123...', | ||
value: 10n, | ||
feeCurrency: '0x123...' | ||
}); | ||
} | ||
``` | ||
|
||
You can also use the `account` directly eg: | ||
|
||
```ts | ||
const account = await ledgerToAccount({ | ||
transport: await TransportNodeHid.open(''), | ||
}) | ||
account.signTransaction({ | ||
to: '0x123...', | ||
value: 123n, | ||
chainId: celoAlfajores.id, | ||
nonce: 42, | ||
maxFeePerGas: 100n, | ||
maxPriorityFeePerGas: 100n, | ||
feeCurrency: '0x123...', | ||
}) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[@celo/viem-account-ledger](README.md) / Modules | ||
|
||
# @celo/viem-account-ledger | ||
|
||
## Table of contents | ||
|
||
### Modules | ||
|
||
- [index](modules/index.md) | ||
- [ledger-to-account](modules/ledger_to_account.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[@celo/viem-account-ledger](../README.md) / [Modules](../modules.md) / index | ||
|
||
# Module: index | ||
|
||
## Table of contents | ||
|
||
### References | ||
|
||
- [CELO\_BASE\_DERIVATION\_PATH](index.md#celo_base_derivation_path) | ||
- [DEFAULT\_DERIVATION\_PATH](index.md#default_derivation_path) | ||
- [ledgerToAccount](index.md#ledgertoaccount) | ||
|
||
## References | ||
|
||
### CELO\_BASE\_DERIVATION\_PATH | ||
|
||
Re-exports [CELO_BASE_DERIVATION_PATH](ledger_to_account.md#celo_base_derivation_path) | ||
|
||
___ | ||
|
||
### DEFAULT\_DERIVATION\_PATH | ||
|
||
Re-exports [DEFAULT_DERIVATION_PATH](ledger_to_account.md#default_derivation_path) | ||
|
||
___ | ||
|
||
### ledgerToAccount | ||
|
||
Re-exports [ledgerToAccount](ledger_to_account.md#ledgertoaccount) |
86 changes: 86 additions & 0 deletions
86
packages/docs/viem-account-ledger/modules/ledger_to_account.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
[@celo/viem-account-ledger](../README.md) / [Modules](../modules.md) / ledger-to-account | ||
|
||
# Module: ledger-to-account | ||
|
||
## Table of contents | ||
|
||
### Type Aliases | ||
|
||
- [LedgerAccount](ledger_to_account.md#ledgeraccount) | ||
|
||
### Variables | ||
|
||
- [CELO\_BASE\_DERIVATION\_PATH](ledger_to_account.md#celo_base_derivation_path) | ||
- [DEFAULT\_DERIVATION\_PATH](ledger_to_account.md#default_derivation_path) | ||
- [ETH\_DERIVATION\_PATH\_BASE](ledger_to_account.md#eth_derivation_path_base) | ||
|
||
### Functions | ||
|
||
- [ledgerToAccount](ledger_to_account.md#ledgertoaccount) | ||
|
||
## Type Aliases | ||
|
||
### LedgerAccount | ||
|
||
Ƭ **LedgerAccount**: `LocalAccount`\<``"ledger"``\> | ||
|
||
#### Defined in | ||
|
||
[ledger-to-account.ts:10](https://github.com/celo-org/developer-tooling/blob/master/packages/viem-account-ledger/src/ledger-to-account.ts#L10) | ||
|
||
## Variables | ||
|
||
### CELO\_BASE\_DERIVATION\_PATH | ||
|
||
• `Const` **CELO\_BASE\_DERIVATION\_PATH**: `string` | ||
|
||
#### Defined in | ||
|
||
[ledger-to-account.ts:13](https://github.com/celo-org/developer-tooling/blob/master/packages/viem-account-ledger/src/ledger-to-account.ts#L13) | ||
|
||
___ | ||
|
||
### DEFAULT\_DERIVATION\_PATH | ||
|
||
• `Const` **DEFAULT\_DERIVATION\_PATH**: `string` | ||
|
||
#### Defined in | ||
|
||
[ledger-to-account.ts:14](https://github.com/celo-org/developer-tooling/blob/master/packages/viem-account-ledger/src/ledger-to-account.ts#L14) | ||
|
||
___ | ||
|
||
### ETH\_DERIVATION\_PATH\_BASE | ||
|
||
• `Const` **ETH\_DERIVATION\_PATH\_BASE**: ``"m/44'/60'/0'"`` | ||
|
||
#### Defined in | ||
|
||
[ledger-to-account.ts:12](https://github.com/celo-org/developer-tooling/blob/master/packages/viem-account-ledger/src/ledger-to-account.ts#L12) | ||
|
||
## Functions | ||
|
||
### ledgerToAccount | ||
|
||
▸ **ledgerToAccount**(`options`): `Promise`\<[`LedgerAccount`](ledger_to_account.md#ledgeraccount)\> | ||
|
||
A function to create a ledger account for viem | ||
|
||
#### Parameters | ||
|
||
| Name | Type | Default value | Description | | ||
| :------ | :------ | :------ | :------ | | ||
| `options` | `Object` | `undefined` | | | ||
| `options.baseDerivationPath?` | `string` | `DEFAULT_DERIVATION_PATH` | defaults to "m/44'/60'/0" | | ||
| `options.derivationPathIndex?` | `string` \| `number` | `0` | aka addressIndex | | ||
| `options.transport` | `default` | `undefined` | a Ledger Transport | | ||
|
||
#### Returns | ||
|
||
`Promise`\<[`LedgerAccount`](ledger_to_account.md#ledgeraccount)\> | ||
|
||
a viem LocalAccount<"ledger"> | ||
|
||
#### Defined in | ||
|
||
[ledger-to-account.ts:25](https://github.com/celo-org/developer-tooling/blob/master/packages/viem-account-ledger/src/ledger-to-account.ts#L25) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/** @internal */ | ||
export type Hex = `0x${string}` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters