New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ADR14 M1 update #627
ADR14 M1 update #627
Conversation
package.json
Outdated
@@ -1,6 +1,6 @@ | |||
{ | |||
"name": "@oasisprotocol/ledger", | |||
"version": "0.2.3", | |||
"version": "0.2.4", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep consistency with the new methods, getAddressAndPubKey was renamed to getAddressAndPubKey_ed25519 (new method is called getAddressAndPubKey_secp256k1)
To respect SemVer, major field should be bumped. However, if you don't want to make breaking changes in the API, it's possible to keep the old names.
I think that this should be decided by Oasis team 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I will bump the major so that we have a version that respects SemVer, since the changes in this PR ask for that. Then Oasis Team can decide to merge this as is or we change the old method names.
I'm getting bunch of linter errors when running |
Nevermind, it seems I had some leftovers from the old repo. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- please add proper secp256k1 tests (the pubkey and address should match the ones from Ethereum when using testing mnemonics)
- please add the secp256k1 address and ParaTime transaction signing also to the UI (e.g. by adding 4 new buttons)
- Please fix the integration tests. I'm having issues running
yarn test:integration
. This https://github.com/chcmedeiros/ledger-js/blob/zondax-M1-update/tests/basic.ispec.js#L59 does not seem to be a vaild native Oasis address (it's too long). Should integration tests be working?
0152d30
to
fb41011
Compare
@matevz I have fixed the old tests that were not correct and added tests coverage for the new methods. Also tested it using a NanoS with the test mnemonic). |
tests/basic.ispec.js
Outdated
|
||
expect(resp.return_code).toEqual(0x9000); | ||
expect(resp.error_message).toEqual("No errors"); | ||
expect(resp.hex_address).toEqual("7dac3ca6b185b7778a7027a52c0cc3940d2e1ca0"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The standard BIP44 address for testing mnemonic equip will roof matter pink blind book anxiety banner elbow sun young
is 95e5e3C1BDD92cd4A0c14c62480DB5867946281D
. Where does discrepancy come from?
tests/basic.ispec.js
Outdated
const transport = await TransportNodeHid.create(1000); | ||
const app = new OasisApp(transport); | ||
// Derivation path. First 3 items are automatically hardened! | ||
const path = [44, 60, 0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also cover the case for the 2nd key [44', 60', 0', 0, 1]
. The helper function in helperV1.js
will probably need to be updated or a new one added, but please don't break backward compatibility.
I'm getting compilation error after applying ac681ad. Can you take a look? $ yarn build
yarn run v1.22.5
warning ../package.json: No license field
$ babel src --out-dir dist && yarn build-types
Successfully compiled 3 files with Babel (610ms).
warning ../package.json: No license field
$ tsc -p ./tsconfig.json
src/types.ts:39:30 - error TS2345: Argument of type 'Buffer | { return_code: number; error_message: string; } | { pk: Buffer; hex_address: string; return_code: any; error_message: string; }' is not assignable to parameter of type 'Response<Buffer | { pk: Buffer; hex_address: string; return_code: any; error_message: string; }>'.
Type 'Buffer' is not assignable to type 'Response<Buffer | { pk: Buffer; hex_address: string; return_code: any; error_message: string; }>'.
Type 'Buffer' is not assignable to type 'Buffer & { return_code: number; error_message: string; }'.
Type 'Buffer' is missing the following properties from type '{ return_code: number; error_message: string; }': return_code, error_message
39 console.log(successOrThrow(await app.getAddressAndPubKey_secp256k1([44])).hex_address.trim());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/types.ts:39:77 - error TS2339: Property 'hex_address' does not exist on type 'Buffer | { pk: Buffer; hex_address: string; return_code: any; error_message: string; }'.
Property 'hex_address' does not exist on type 'Buffer'.
39 console.log(successOrThrow(await app.getAddressAndPubKey_secp256k1([44])).hex_address.trim());
~~~~~~~~~~~
src/types.ts:40:30 - error TS2345: Argument of type 'Buffer | { return_code: number; error_message: string; } | { pk: Buffer; hex_address: string; return_code: any; error_message: string; }' is not assignable to parameter of type 'Response<Buffer | { pk: Buffer; hex_address: string; return_code: any; error_message: string; }>'.
40 console.log(successOrThrow(await app.showAddressAndPubKey_secp256k1([44])).hex_address.trim());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/types.ts:40:78 - error TS2339: Property 'hex_address' does not exist on type 'Buffer | { pk: Buffer; hex_address: string; return_code: any; error_message: string; }'.
Property 'hex_address' does not exist on type 'Buffer'.
40 console.log(successOrThrow(await app.showAddressAndPubKey_secp256k1([44])).hex_address.trim());
~~~~~~~~~~~
Found 4 errors in the same file, starting at: src/types.ts:39 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, thanks.
de0978b
to
f358afa
Compare
@matevz are we waiting for anything before merging this? |
Looks like the tests did not run for some reason. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm getting an error when running yarn build-example
. @chcmedeiros Can you take a look and then merge this so we can add ParaTime support for Ledger to our javascript wallets as well.
src/index.js
Outdated
const returnCode = errorCodeData[0] * 256 + errorCodeData[1]; | ||
|
||
const pk = Buffer.from(response.slice(0, 33)); | ||
const hex_address = Buffer.from(response.slice(33, 73)).toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const hex_address = Buffer.from(response.slice(33, 73)).toString(); | |
const hexAddress = Buffer.from(response.slice(33, 73)).toString(); |
src/index.js
Outdated
|
||
return { | ||
pk, | ||
hex_address, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hex_address, | |
hex_address: hexAddress, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I will take a look
@matevz Regarding the vue-example that example has some time, and we have deprecated it months ago. If it's ok with you and since we have test coverage for the package with the real device we would remove that vue-example folder, avoiding more errors. |
sure, sounds good. would reduce the dev dependency tree by a lot too |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chcmedeiros yarn test:integration
freezes on the second test for me using hardware ledger with the latest firmware you sent to me (UI fixes). Can you check it out? Also, what would be the easiest way to do Ledger tests inside CI?
Hey @matevz The M3-maintenance branch now has a version that is working here on the ledger-js, if you want to test. Regarding the ledger tests, I think the procedure would be to compile the app from the repository to get the .elf and then use our tool zemu (device emulator) combined with this repo to run the tests. This should require some more work, so maybe we can merge this, discuss these tests implementation and possibly do it in the future PR for SR25519. |
I can confirm that integration tests now pass with Zondax/ledger-oasis@9b9c85a . Feel free to merge this PR. |
@matevz I am not able to merge, probably don't haver permission to do so. |
Support Milestone 1 of ADR14 implementation: