Skip to content

Commit

Permalink
Merge pull request #180 from lidofinance/fix/ledger-live-provider-req…
Browse files Browse the repository at this point in the history
…uest

fix: enable chain/account change in ll connector
  • Loading branch information
alx-khramov authored Oct 10, 2024
2 parents 9e70f90 + f338a95 commit f10f022
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 38 deletions.
2 changes: 1 addition & 1 deletion apps/demo-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@lido-sdk/constants": "^3.2.1",
"@lido-sdk/providers": "^1.4.14",
"@lido-sdk/react": "2.0.2",
"@lidofinance/lido-ethereum-sdk": "^3.1.1",
"@lidofinance/lido-ethereum-sdk": "3.5.0-alpha.3",
"@lidofinance/lido-ui": "^3.18.0",
"@svgr/webpack": "^8.0.1",
"@tanstack/react-query": "^5.29.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/connectors/ledger-connector/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @reef-knot/ledger-connector

## 4.1.2

### Patch Changes

- Fix: onAccountsChanged, onChainChanged methods for ledgerLiveConnector

## 4.1.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/connectors/ledger-connector/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@reef-knot/ledger-connector",
"version": "4.1.1",
"version": "4.1.2",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
Expand Down
14 changes: 4 additions & 10 deletions packages/connectors/ledger-connector/src/iframe/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export function ledgerLiveConnector({
try {
const provider = await this.getProvider();

// works without bind because it's an obj created(scoped) in a function
provider.on('accountsChanged', this.onAccountsChanged);
provider.on('chainChanged', this.onChainChanged);

Expand Down Expand Up @@ -142,15 +143,16 @@ export function ledgerLiveConnector({
}
},

AccountsChanged(accounts: Address[]) {
onAccountsChanged(accounts: Address[]) {
if (accounts.length === 0 || !accounts[0]) {
emitter.emit('disconnect');
this.disconnect();
} else {
emitter.emit('change', { accounts });
}
},

ChainChanged(chainId: number | string) {
onChainChanged(chainId: number | string) {
emitter.emit('change', { chainId: Number(chainId) });
},

Expand All @@ -163,13 +165,5 @@ export function ledgerLiveConnector({
onDisconnect() {
emitter.emit('disconnect');
},

onAccountsChanged() {
// NOOP
},

onChainChanged() {
// NOOP
},
}));
}
8 changes: 8 additions & 0 deletions packages/reef-knot/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# reef-knot

## 5.7.2

### Patch Changes

- Fix: onAccountsChanged, onChainChanged methods for ledgerLiveConnector
- Updated dependencies
- @reef-knot/ledger-connector@4.1.2

## 5.7.1

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/reef-knot/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reef-knot",
"version": "5.7.1",
"version": "5.7.2",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
Expand Down Expand Up @@ -48,7 +48,7 @@
"@reef-knot/wallets-list": "2.3.0",
"@reef-knot/wallets-helpers": "2.1.0",
"@reef-knot/types": "2.1.0",
"@reef-knot/ledger-connector": "4.1.1"
"@reef-knot/ledger-connector": "4.1.2"
},
"peerDependencies": {
"@lidofinance/lido-ui": "^3.18.0",
Expand Down
28 changes: 4 additions & 24 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2673,15 +2673,14 @@
dependencies:
typescript "^4.7"

"@lidofinance/lido-ethereum-sdk@^3.1.1":
version "3.1.1"
resolved "https://registry.yarnpkg.com/@lidofinance/lido-ethereum-sdk/-/lido-ethereum-sdk-3.1.1.tgz#7903ea512eed6d6658ab2a2d6731e41329e300bf"
integrity sha512-niZciaZTq8Lr3+U6Y61anVBnRSCWu0DCQKT9oJqPXP0MUBkqKsrFKYIV5BHXlEGHj5Z8UQbIm9fRm7iL7YZefw==
"@lidofinance/lido-ethereum-sdk@3.5.0-alpha.3":
version "3.5.0-alpha.3"
resolved "https://registry.yarnpkg.com/@lidofinance/lido-ethereum-sdk/-/lido-ethereum-sdk-3.5.0-alpha.3.tgz#a503a0686f8e4e5438995149d1316b0c98d09cfe"
integrity sha512-FvrW7Dk5n802qES5F5nZo5NzTw+pWBh3jSMJltOYCtsaIO97bUXkqm6p4cfURnvj1coI5MH00BqJuUj7yDI2NQ==
dependencies:
"@ethersproject/bytes" "^5.7.0"
graphql "^16.8.1"
graphql-request "^6.1.0"
viem "^2.0.6"

"@lidofinance/lido-ui@^3.18.0":
version "3.18.2"
Expand Down Expand Up @@ -8292,11 +8291,6 @@ [email protected]:
node-fetch "^2.6.1"
unfetch "^4.2.0"

[email protected]:
version "1.0.3"
resolved "https://registry.yarnpkg.com/isows/-/isows-1.0.3.tgz#93c1cf0575daf56e7120bab5c8c448b0809d0d74"
integrity sha512-2cKei4vlmg2cxEjm3wVSqn8pcoRF/LX/wpifuuNquFO4SQmPwarClT+SUCA2lt+l581tTeZIPIZuIDo2jWN1fg==

[email protected]:
version "1.0.4"
resolved "https://registry.yarnpkg.com/isows/-/isows-1.0.4.tgz#810cd0d90cc4995c26395d2aa4cfa4037ebdf061"
Expand Down Expand Up @@ -11880,20 +11874,6 @@ [email protected]:
isows "1.0.4"
ws "8.13.0"

viem@^2.0.6:
version "2.7.11"
resolved "https://registry.yarnpkg.com/viem/-/viem-2.7.11.tgz#e432885f412c6faf2772a1e0569e8269b6ad93cb"
integrity sha512-qlEPF9YOgPVqjTyom73TVAekAYrIe68megO07u55p7pKWgLt0i9KD6Mrmiw7pd7oHh86vIppcygwQMDNGX1YAw==
dependencies:
"@adraffy/ens-normalize" "1.10.0"
"@noble/curves" "1.2.0"
"@noble/hashes" "1.3.2"
"@scure/bip32" "1.3.2"
"@scure/bip39" "1.2.1"
abitype "1.0.0"
isows "1.0.3"
ws "8.13.0"

viem@^2.1.1:
version "2.18.5"
resolved "https://registry.yarnpkg.com/viem/-/viem-2.18.5.tgz#6b29c2b30c8c01de4f4c5a3cc99b8e30ae942df8"
Expand Down

0 comments on commit f10f022

Please sign in to comment.