|
1 | | -# @sei-js/ledger |
2 | | - |
3 | | -## Table of Contents |
4 | | -- [Installation](#installation) |
5 | | -- [Usage](#usage) |
6 | | -- [createTransportAndApp](#createtransportandapp) |
7 | | - - [Parameters](#createTransportAndApp-parameters) |
8 | | -- [getAddresses](#getaddresses) |
9 | | - - [Parameters](#getAddresses-parameters) |
10 | | -- [SeiLedgerOfflineAminoSigner](#seiledgerofflineaminosigner) |
11 | | - - [Constructor](#SeiLedgerOfflineAminoSigner-constructor) |
12 | | - - [getAccounts](#SeiLedgerOfflineAminoSigner-getAccounts) |
13 | | - - [signAmino](#SeiLedgerOfflineAminoSigner-signAmino) |
14 | | -- [removeLeadingZeros](#removeleadingzeros) |
15 | | - - [Parameters](#removeLeadingZeros-parameters) |
16 | | - |
17 | | -## Installation |
18 | | -```bash |
19 | | -yarn add @sei-js/ledger |
20 | | -``` |
21 | | - |
22 | | -## Example Usage |
23 | | -```typescript |
24 | | -import { |
25 | | - coins, |
26 | | - SigningStargateClient, |
27 | | - StdFee |
28 | | -} from "@cosmjs/stargate"; |
29 | | - |
30 | | -import { |
31 | | - createTransportAndApp, |
32 | | - getAddresses, |
33 | | - SeiLedgerOfflineAminoSigner |
34 | | -} from "@sei-js/ledger"; |
35 | | - |
36 | | -const testApp = async () => { |
37 | | - const validatorAddress = "seivaloper1sq7x0r2mf3gvwr2l9amtlye0yd3c6dqa4th95v"; |
38 | | - const rpcUrl = "https://rpc-testnet.sei-apis.com/"; |
39 | | - const memo = "Delegation"; |
40 | | - const path = "m/44'/60'/0'/0/0"; |
41 | | - |
42 | | - const {app} = await createTransportAndApp(); |
43 | | - const {nativeAddress} = await getAddresses(app, path); |
44 | | - const ledgerSigner = new SeiLedgerOfflineAminoSigner(app, path) |
45 | | - const signingStargateClient = await SigningStargateClient.connectWithSigner(rpcUrl, ledgerSigner) |
46 | | - |
47 | | - const msgDelegate = { |
48 | | - typeUrl: "/cosmos.staking.v1beta1.MsgDelegate", |
49 | | - value: { |
50 | | - delegatorAddress: nativeAddress.address, |
51 | | - validatorAddress: validatorAddress, |
52 | | - amount: coins(500, "usei"), |
53 | | - }, |
54 | | - }; |
55 | | - |
56 | | - const fee: StdFee = { |
57 | | - amount: [{denom: "usei", amount: "20000"}], |
58 | | - gas: "200000", |
59 | | - }; |
60 | | - |
61 | | - const result = await signingStargateClient.signAndBroadcast(nativeAddress.address, [msgDelegate], fee, memo) |
62 | | - console.log("Broadcast result:", result); |
63 | | -}; |
64 | | - |
65 | | -testApp(); |
66 | | -``` |
67 | | - |
68 | | - |
69 | | -## createTransportAndApp |
70 | | - |
71 | | -### Parameters: |
72 | | -- None. |
73 | | - |
74 | | -### Returns: |
75 | | -- `Promise<{transport: Transport, app: SeiApp}>`: A promise that resolves to an object containing the `transport` and `app` instances. |
| 1 | +<div align="center"> |
76 | 2 |
|
77 | | -### Usage: |
78 | | -```typescript |
79 | | -import { createTransportAndApp } from '@sei-js/ledger'; |
80 | | - |
81 | | -const { transport, app } = await createTransportAndApp(); |
82 | | -console.log(transport, app); |
83 | | -``` |
84 | | - |
85 | | -## getAddresses |
86 | | - |
87 | | -### Parameters: |
88 | | -- `app` (`SeiApp`): An instance of the Ledger Sei app. |
89 | | -- `path` (`string`): The HD derivation path (e.g., `"m/44'/60'/0'/0/0"`). |
90 | | - |
91 | | -### Returns: |
92 | | -- `Promise<{evmAddress: string, nativeAddress: string}>`: A promise that resolves to an object containing the EVM and Cosmos addresses. |
93 | | - |
94 | | -### Usage: |
95 | | -```typescript |
96 | | -import { getAddresses } from '@sei-js/ledger'; |
97 | | - |
98 | | -const { evmAddress, nativeAddress } = await getAddresses(app, "m/44'/60'/0'/0/0"); |
99 | | -console.log(evmAddress, nativeAddress); |
100 | | -``` |
101 | | - |
102 | | -## SeiLedgerOfflineAminoSigner |
103 | | - |
104 | | -### Constructor |
105 | | - |
106 | | -```typescript |
107 | | -new SeiLedgerOfflineAminoSigner(app: SeiApp, path: string) |
108 | | -``` |
| 3 | +# @sei-js/ledger |
109 | 4 |
|
110 | | -#### Parameters: |
111 | | -- `app` (`SeiApp`): An instance of the Ledger Sei app. |
112 | | -- `path` (`string`): The HD derivation path (e.g., `"m/44'/60'/0'/0/0"`). |
| 5 | +[](https://badge.fury.io/js/@sei-js%2Fledger) |
| 6 | +[](https://opensource.org/licenses/MIT) |
| 7 | +[](https://www.typescriptlang.org/) |
| 8 | +[](https://sei.io) |
113 | 9 |
|
114 | | -#### Usage: |
115 | | -```typescript |
116 | | -import { SeiLedgerOfflineAminoSigner } from '@sei-js/ledger'; |
| 10 | +**Hardware wallet integration for secure transaction signing** |
117 | 11 |
|
118 | | -const ledgerSigner = new SeiLedgerOfflineAminoSigner(app, "m/44'/60'/0'/0/0"); |
119 | | -``` |
| 12 | +[Documentation](https://sei-js.docs.sei.io/ledger/introduction) • [GitHub](https://github.com/sei-protocol/sei-js) • [NPM](https://www.npmjs.com/package/@sei-js/ledger) • [Telegram](https://t.me/+LPW_1djQwRQwMzlk) |
120 | 13 |
|
121 | | -### getAccounts |
| 14 | +</div> |
122 | 15 |
|
123 | | -#### Returns: |
124 | | -- `Promise<readonly AccountData[]>`: A promise that resolves to an array of `AccountData` objects containing the address and public key. |
| 16 | +## 🚀 Quick Start |
125 | 17 |
|
126 | | -#### Usage: |
127 | | -```typescript |
128 | | -import { SeiLedgerOfflineAminoSigner } from '@sei-js/ledger'; |
129 | | - |
130 | | -const accounts = await ledgerSigner.getAccounts(); |
131 | | -console.log(accounts); // { address: 'sei1...', pubkey: { type: 'tendermint/PubKeySecp256k1', value: '...' } } |
| 18 | +```bash |
| 19 | +npm install @sei-js/ledger |
132 | 20 | ``` |
133 | 21 |
|
134 | | -### signAmino |
| 22 | +## 📚 Documentation |
135 | 23 |
|
136 | | -#### Parameters: |
137 | | -- `_signerAddress` (`string`): The address of the signer (unused in this method). |
138 | | -- `signDoc` (`StdSignDoc`): The sign document to be signed. |
| 24 | +For complete documentation, examples, and guides, visit: |
| 25 | +**[sei-js.docs.sei.io/ledger](https://sei-js.docs.sei.io/ledger/introduction)** |
139 | 26 |
|
140 | | -#### Returns: |
141 | | -- `Promise<AminoSignResponse>`: A promise that resolves to an object containing the signed document and the signature. |
142 | 27 |
|
143 | | -#### Usage: |
144 | | -```typescript |
145 | | -import { SeiLedgerOfflineAminoSigner } from '@sei-js/ledger'; |
146 | | -import { StdSignDoc } from '@cosmjs/amino'; |
147 | | - |
148 | | -const signDoc: StdSignDoc = { /* your StdSignDoc object */ }; |
149 | | -const signResponse = await ledgerSigner.signAmino('sei123...', signDoc); |
150 | | -console.log(signResponse.signed, signResponse.signature); |
151 | | -``` |
0 commit comments