Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
pyramation committed Jun 18, 2024
1 parent 52d8076 commit e210e6d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
21 changes: 10 additions & 11 deletions wallets/keplr-extension/src/extension/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,15 @@ export class KeplrClient implements WalletClient {
async addChain(chainInfo: ChainRecord) {
// TODO later allow walletInfo getter to be available here
// make this more generic
const chainsAlreadyAdded = ExpiringLocalStorage.getItems('keplr/supported-chain')
const chainsAlreadyAdded = ExpiringLocalStorage.getItems(
'cosmos-kit@2:keplr/supported-chain'
);
if (chainsAlreadyAdded && chainsAlreadyAdded.length > 0) {
if (chainsAlreadyAdded.includes(chainInfo.name)) {
console.warn(
`${chainInfo.name} is already added. No need to call experimentalSuggestChain()`
);
return;
}
}



const suggestChain = chainRegistryChainToKeplr(
chainInfo.chain,
chainInfo.assetList ? [chainInfo.assetList] : []
Expand All @@ -154,13 +151,15 @@ export class KeplrClient implements WalletClient {

try {
await this.client.experimentalSuggestChain(suggestChain);
ExpiringLocalStorage.addItem('keplr/supported-chain', chainInfo.name, 1000 * 60)
ExpiringLocalStorage.addItem(
'cosmos-kit@2:keplr/supported-chain',
chainInfo.name,
1000 * 60
);
} catch (error) {
console.log('Error while adding chain', error)
throw error
console.log('Error while adding chain', error);
throw error;
}


}

async signAmino(
Expand Down
17 changes: 11 additions & 6 deletions wallets/keplr-extension/src/extension/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,22 @@ export class ExpiringLocalStorage {
const validItems = [];

// Filter out expired items
for (let item of items) {
for (const item of items) {
if (now.getTime() <= item.expiry) {
validItems.push(item.value);
}
}

// Update local storage with only valid items
localStorage.setItem(key, JSON.stringify(validItems.map(value => ({
value,
expiry: items.find(item => item.value === value).expiry
}))));
localStorage.setItem(
key,
JSON.stringify(
validItems.map((value) => ({
value,
expiry: items.find((item) => item.value === value).expiry,
}))
)
);

return validItems;
}
Expand All @@ -74,7 +79,7 @@ export class ExpiringLocalStorage {
let items = JSON.parse(itemStr);

// Filter out the item to be removed
items = items.filter(item => item.value !== value);
items = items.filter((item) => item.value !== value);

// Update local storage with the remaining items
localStorage.setItem(key, JSON.stringify(items));
Expand Down

0 comments on commit e210e6d

Please sign in to comment.