-
Notifications
You must be signed in to change notification settings - Fork 4
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
7.0.0 #30
7.0.0 #30
Conversation
* standardize providers * fix build by upgrading ledgerhq packages * fix specs * update signer field * refactoring * changes according to code review
src/hwProvider.ts
Outdated
const message = new Message({ | ||
data: Buffer.from(messageToSign.data), | ||
address: messageToSign.address ?? Address.fromBech32(this._account.address), | ||
signer: 'ledger', |
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.
Can be defined in constants.ts
.
let serializedMessageBuffer = Buffer.from(serializedMessage); | ||
const message = new Message({ | ||
data: Buffer.from(messageToSign.data), | ||
address: messageToSign.address ?? Address.fromBech32(this._account.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.
Actually, I think we should always override it instead? That is, I think we should ignore messageToSign.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.
Is more optimistic for page reload:
- login
- save address to localStorage in dApp
- reload
- sign message
- => ledger device could sign but since address is no longer present in hw-provider, a re login is required
if (!this.hwApp) { | ||
throw new ErrNotInitialized(); | ||
} | ||
|
||
await this.setAddressIndex(options.addressIndex); | ||
const { address } = await this.hwApp.getAddress(0, options.addressIndex, true); | ||
|
||
return address; | ||
this._account = { |
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.
In the PR description, there's:
make login return an IProviderAccount object instead of string
Maybe we should document the breaking changes in a bit more detail? E.g. 6x vs. 7x.
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.
A "migration support" issue on GitHub could be useful.
Examples:
src/hwProvider.spec.ts
Outdated
|
||
assert.equal(signedMessage.message.toString(), "Hello World"); | ||
assert.equal(signedMessage.address.toString(), "erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th"); | ||
assert.equal(Buffer.from(signedMessage.data).toString(), "Hello World"); |
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 test is somehow legacy (does not bring very much value).
Maybe the preparation of the data to be signed (get message size, concatenation) can be extracted in a function, and unit tested. Optional.
account
, with public methodsgetAccount
andsetAccount
isConnected()
returnboolean
instead ofPromise<boolean>
login
return anIProviderAccount
object instead ofstring
Message