Skip to content
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

Merged
merged 7 commits into from
Sep 23, 2024
Merged

7.0.0 #30

merged 7 commits into from
Sep 23, 2024

Conversation

arhtudormorar
Copy link
Contributor

@arhtudormorar arhtudormorar commented Sep 23, 2024

  • upgrade sdk-core, @LedgerHQ, typescript
  • added private memeber account, with public methods getAccount and setAccount
  • make isConnected() return boolean instead of Promise<boolean>
  • make login return an IProviderAccount object instead of string
  • upgrade signMessage to use Message

CiprianDraghici and others added 5 commits September 6, 2024 19:14
* standardize providers

* fix build by upgrading ledgerhq packages

* fix specs

* update signer field

* refactoring

* changes according to code review
andreibancioiu
andreibancioiu previously approved these changes Sep 23, 2024
const message = new Message({
data: Buffer.from(messageToSign.data),
address: messageToSign.address ?? Address.fromBech32(this._account.address),
signer: 'ledger',
Copy link
Contributor

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),
Copy link
Contributor

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.

Copy link
Contributor Author

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:

  1. login
  2. save address to localStorage in dApp
  3. reload
  4. sign message
  5. => 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 = {
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


assert.equal(signedMessage.message.toString(), "Hello World");
assert.equal(signedMessage.address.toString(), "erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th");
assert.equal(Buffer.from(signedMessage.data).toString(), "Hello World");
Copy link
Contributor

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.

@arhtudormorar arhtudormorar merged commit 6c0d0b3 into main Sep 23, 2024
1 check passed
@arhtudormorar arhtudormorar deleted the next branch September 23, 2024 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants