@zondax/ledger-cosmos-js 2.1.8 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +39 -7
  3. package/dist/commandsV1.d.ts +4 -0
  4. package/dist/commandsV1.js +129 -0
  5. package/dist/commandsV1.js.map +1 -0
  6. package/dist/commandsV2.d.ts +4 -0
  7. package/dist/commandsV2.js +104 -0
  8. package/dist/commandsV2.js.map +1 -0
  9. package/dist/common.d.ts +39 -0
  10. package/dist/common.js +143 -132
  11. package/dist/common.js.map +1 -0
  12. package/dist/cosmosApp.d.ts +19 -0
  13. package/dist/cosmosApp.js +377 -0
  14. package/dist/cosmosApp.js.map +1 -0
  15. package/dist/index.d.ts +16 -0
  16. package/dist/index.js +17 -608
  17. package/dist/index.js.map +1 -0
  18. package/package.json +64 -50
  19. package/yarn.lock +6661 -0
  20. package/.babelrc +0 -13
  21. package/.circleci/config.yml +0 -62
  22. package/.editorconfig +0 -14
  23. package/.eslintrc.json +0 -31
  24. package/.idea/codeStyles/Project.xml +0 -57
  25. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  26. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  27. package/.idea/jsLibraryMappings.xml +0 -6
  28. package/.idea/ledger-cosmos-js.iml +0 -12
  29. package/.idea/modules.xml +0 -8
  30. package/.idea/vcs.xml +0 -6
  31. package/.idea/workspace.xml +0 -57
  32. package/.prettierrc.json +0 -4
  33. package/certs/.gitkeep +0 -0
  34. package/certs/openssl.cnf +0 -12
  35. package/dist/helperV1.js +0 -127
  36. package/dist/helperV2.js +0 -97
  37. package/docs/example.png +0 -0
  38. package/jest.config.integration.js +0 -9
  39. package/jest.config.js +0 -32
  40. package/jest.config.unit.js +0 -9
  41. package/public/favicon.ico +0 -0
  42. package/public/index.html +0 -17
  43. package/src/common.js +0 -114
  44. package/src/helperV1.js +0 -73
  45. package/src/helperV2.js +0 -44
  46. package/src/index.js +0 -336
  47. package/tests/basic.ispec.js +0 -390
  48. package/tests/basic.spec.js +0 -8
  49. package/tests/jest.js +0 -2
  50. package/vue.config.js +0 -11
  51. package/vue_example/App.vue +0 -29
  52. package/vue_example/assets/logo.png +0 -0
  53. package/vue_example/components/LedgerExample.vue +0 -252
  54. package/vue_example/main.js +0 -9
@@ -1,252 +0,0 @@
1
- <template>
2
- <div class="cosmosLedger">
3
- <input id="webusb" v-model="transportChoice" type="radio" value="WebUSB" />
4
- <label for="webusb">WebUSB</label>
5
- <input id="u2f" v-model="transportChoice" type="radio" value="U2F" />
6
- <label for="u2f">U2F</label>
7
- <br />
8
- <!--
9
- Commands
10
- -->
11
- <button @click="getVersion">
12
- Get Version
13
- </button>
14
-
15
- <button @click="appInfo">
16
- AppInfo
17
- </button>
18
-
19
- <button @click="getPublicKey">
20
- Get pubkey only
21
- </button>
22
-
23
- <button @click="getAddress">
24
- Get Address and Pubkey
25
- </button>
26
-
27
- <button @click="showAddress">
28
- Show Address and Pubkey
29
- </button>
30
-
31
- <button @click="signExampleTx">
32
- Sign Example TX
33
- </button>
34
- <!--
35
- Commands
36
- -->
37
- <ul id="ledger-status">
38
- <li v-for="item in ledgerStatus" :key="item.index">
39
- {{ item.msg }}
40
- </li>
41
- </ul>
42
- </div>
43
- </template>
44
-
45
- <script>
46
- // eslint-disable-next-line import/no-extraneous-dependencies
47
- import TransportWebUSB from "@ledgerhq/hw-transport-webusb";
48
- // eslint-disable-next-line import/no-extraneous-dependencies
49
- import TransportU2F from "@ledgerhq/hw-transport-u2f";
50
- import CosmosApp from "../../src";
51
- import { ERROR_CODE } from "../../src/common";
52
-
53
- const path = [44, 118, 5, 0, 3];
54
-
55
- export default {
56
- name: "CosmosLedger",
57
- props: {},
58
- data() {
59
- return {
60
- deviceLog: [],
61
- transportChoice: "WebUSB",
62
- };
63
- },
64
- computed: {
65
- ledgerStatus() {
66
- return this.deviceLog;
67
- },
68
- },
69
- methods: {
70
- log(msg) {
71
- this.deviceLog.push({
72
- index: this.deviceLog.length,
73
- msg,
74
- });
75
- },
76
- async getTransport() {
77
- let transport = null;
78
-
79
- this.log(`Trying to connect via ${this.transportChoice}...`);
80
- if (this.transportChoice === "WebUSB") {
81
- try {
82
- transport = await TransportWebUSB.create();
83
- } catch (e) {
84
- this.log(e);
85
- }
86
- }
87
-
88
- if (this.transportChoice === "U2F") {
89
- try {
90
- transport = await TransportU2F.create(10000);
91
- } catch (e) {
92
- this.log(e);
93
- }
94
- }
95
-
96
- return transport;
97
- },
98
- async getVersion() {
99
- this.deviceLog = [];
100
-
101
- // Given a transport (U2F/HIF/WebUSB) it is possible instantiate the app
102
- const transport = await this.getTransport();
103
- const app = new CosmosApp(transport);
104
-
105
- // now it is possible to access all commands in the app
106
- const response = await app.getVersion();
107
- if (response.return_code !== ERROR_CODE.NoError) {
108
- this.log(`Error [${response.return_code}] ${response.error_message}`);
109
- return;
110
- }
111
-
112
- this.log("Response received!");
113
- this.log(`App Version ${response.major}.${response.minor}.${response.patch}`);
114
- this.log(`Device Locked: ${response.device_locked}`);
115
- this.log(`Test mode: ${response.test_mode}`);
116
- this.log("Full response:");
117
- this.log(response);
118
- },
119
- async appInfo() {
120
- this.deviceLog = [];
121
-
122
- // Given a transport (U2F/HIF/WebUSB) it is possible instantiate the app
123
- const transport = await this.getTransport();
124
- const app = new CosmosApp(transport);
125
-
126
- // now it is possible to access all commands in the app
127
- const response = await app.appInfo();
128
- if (response.return_code !== 0x9000) {
129
- this.log(`Error [${response.return_code}] ${response.error_message}`);
130
- return;
131
- }
132
-
133
- this.log("Response received!");
134
- this.log(response);
135
- },
136
- async getPublicKey() {
137
- this.deviceLog = [];
138
-
139
- // Given a transport (U2F/HIF/WebUSB) it is possible instantiate the app
140
- const transport = await this.getTransport();
141
- const app = new CosmosApp(transport);
142
-
143
- let response = await app.getVersion();
144
- this.log(`App Version ${response.major}.${response.minor}.${response.patch}`);
145
- this.log(`Device Locked: ${response.device_locked}`);
146
- this.log(`Test mode: ${response.test_mode}`);
147
-
148
- // now it is possible to access all commands in the app
149
- response = await app.publicKey(path);
150
- if (response.return_code !== 0x9000) {
151
- this.log(`Error [${response.return_code}] ${response.error_message}`);
152
- return;
153
- }
154
-
155
- this.log("Response received!");
156
- this.log("Full response:");
157
- this.log(response);
158
- },
159
- async getAddress() {
160
- this.deviceLog = [];
161
-
162
- // Given a transport (U2F/HIF/WebUSB) it is possible instantiate the app
163
- const transport = await this.getTransport();
164
- const app = new CosmosApp(transport);
165
-
166
- let response = await app.getVersion();
167
- this.log(`App Version ${response.major}.${response.minor}.${response.patch}`);
168
- this.log(`Device Locked: ${response.device_locked}`);
169
- this.log(`Test mode: ${response.test_mode}`);
170
-
171
- // now it is possible to access all commands in the app
172
- response = await app.getAddressAndPubKey(path, "cosmos");
173
- if (response.return_code !== 0x9000) {
174
- this.log(`Error [${response.return_code}] ${response.error_message}`);
175
- return;
176
- }
177
-
178
- this.log("Response received!");
179
- this.log("Full response:");
180
- this.log(response);
181
- },
182
- async showAddress() {
183
- this.deviceLog = [];
184
-
185
- // Given a transport (U2F/HIF/WebUSB) it is possible instantiate the app
186
- const transport = await this.getTransport();
187
- const app = new CosmosApp(transport);
188
-
189
- let response = await app.getVersion();
190
- this.log(`App Version ${response.major}.${response.minor}.${response.patch}`);
191
- this.log(`Device Locked: ${response.device_locked}`);
192
- this.log(`Test mode: ${response.test_mode}`);
193
-
194
- // now it is possible to access all commands in the app
195
- this.log("Please click in the device");
196
- response = await app.showAddressAndPubKey(path, "cosmos");
197
- if (response.return_code !== ERROR_CODE.NoError) {
198
- this.log(`Error [${response.return_code}] ${response.error_message}`);
199
- return;
200
- }
201
-
202
- this.log("Response received!");
203
- this.log("Full response:");
204
- this.log(response);
205
- },
206
- async signExampleTx() {
207
- this.deviceLog = [];
208
-
209
- // Given a transport (U2F/HID/WebUSB) it is possible instantiate the app
210
- const transport = await this.getTransport();
211
- const app = new CosmosApp(transport);
212
-
213
- let response = await app.getVersion();
214
- this.log(`App Version ${response.major}.${response.minor}.${response.patch}`);
215
- this.log(`Device Locked: ${response.device_locked}`);
216
- this.log(`Test mode: ${response.test_mode}`);
217
-
218
- // now it is possible to access all commands in the app
219
- const message =
220
- '{"account_number":"6571","chain_id":"cosmoshub-2","fee":{"amount":[{"amount":"5000","denom":"uatom"}],"gas":"200000"},"memo":"Delegated with Ledger from union.market","msgs":[{"type":"cosmos-sdk/MsgDelegate","value":{"amount":{"amount":"1000000","denom":"uatom"},"delegator_address":"cosmos102hty0jv2s29lyc4u0tv97z9v298e24t3vwtpl","validator_address":"cosmosvaloper1grgelyng2v6v3t8z87wu3sxgt9m5s03xfytvz7"}}],"sequence":"0"}';
221
- response = await app.sign(path, message);
222
-
223
- this.log("Response received!");
224
- this.log("Full response:");
225
- this.log(response);
226
- },
227
- },
228
- };
229
- </script>
230
-
231
- <!-- Add "scoped" attribute to limit CSS to this component only -->
232
- <style scoped>
233
- h3 {
234
- margin: 40px 0 0;
235
- }
236
-
237
- button {
238
- padding: 5px;
239
- font-weight: bold;
240
- font-size: medium;
241
- }
242
-
243
- ul {
244
- padding: 10px;
245
- text-align: left;
246
- alignment: left;
247
- list-style-type: none;
248
- background: black;
249
- font-weight: bold;
250
- color: greenyellow;
251
- }
252
- </style>
@@ -1,9 +0,0 @@
1
- /* eslint-disable */
2
- import Vue from 'vue';
3
- import App from './App.vue';
4
-
5
- Vue.config.productionTip = false;
6
-
7
- new Vue({
8
- render: h => h(App),
9
- }).$mount('#app');