Skip to content

Commit

Permalink
fix addChains logical issue and make test pass
Browse files Browse the repository at this point in the history
  • Loading branch information
theothersideofgods committed Jun 18, 2024
1 parent d5f38a3 commit 8a4879e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions packages/core/__tests__/manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,14 @@ describe('WalletManager', () => {
})
});

// it('should addChains functional', () => {
// walletManager.addChains(['osmosis'], assets);
// expect(walletManager.chainRecords).toHaveLength(2)
// expect(walletManager.walletRepos).toHaveLength(2)
// walletManager.addChains(['stargaze'], assets);
// expect(walletManager.chainRecords).toHaveLength(3)
// expect(walletManager.walletRepos).toHaveLength(3)
// });
it('should addChains functional', () => {
walletManager.addChains(['osmosis'], assets);
expect(walletManager.chainRecords).toHaveLength(2)
expect(walletManager.walletRepos).toHaveLength(2)
walletManager.addChains(['stargaze'], assets);
expect(walletManager.chainRecords).toHaveLength(3)
expect(walletManager.walletRepos).toHaveLength(3)
});

it('should register event handlers with on()', () => {
const event = 'refresh_connection';
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ export class WalletManager extends StateBase {
];
wallets.forEach(
({ walletName }) =>
(this._reconnectMap[walletName] = () =>
this._reconnect(walletName, true))
(this._reconnectMap[walletName] = () =>
this._reconnect(walletName, true))
);
this.init(
chains,
Expand Down Expand Up @@ -195,7 +195,7 @@ export class WalletManager extends StateBase {
});
newChainRecords.forEach((chainRecord) => {
const index = this.chainRecords.findIndex(
(chainRecord2) => chainRecord2.name !== chainRecord.name
(chainRecord2) => chainRecord2.name === chainRecord.name
);
if (index == -1) {
this.chainRecords.push(chainRecord);
Expand Down Expand Up @@ -237,7 +237,7 @@ export class WalletManager extends StateBase {
}

const index = this.walletRepos.findIndex(
(repo2) => repo2.chainName !== repo.chainName
(repo2) => repo2.chainName === repo.chainName
);
if (index == -1) {
this.walletRepos.push(repo);
Expand Down

0 comments on commit 8a4879e

Please sign in to comment.