Skip to content

Commit

Permalink
fix: don't crash when bech32 decoding fails (#717)
Browse files Browse the repository at this point in the history
Signed-off-by: Norman Meier <[email protected]>
  • Loading branch information
n0izn0iz authored Oct 16, 2023
1 parent f409f3a commit b329e1f
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions packages/store/slices/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,16 @@ export const selectMultisigToken = (
if (!userAddress) {
return undefined;
}
let addr;
try {
addr = universalUserAddress(userAddress);
} catch (error) {
console.warn("failed to transform user address", error, userAddress);
return undefined;
}
const token = multisigTokensSelectors.selectById(
state.settings.multisigTokens,
universalUserAddress(userAddress)
addr
);
if (!token || Date.parse(token.expiration) <= Date.now()) {
return undefined;
Expand Down Expand Up @@ -160,10 +167,14 @@ const settingsSlice = createSlice({
}>
) => {
if (!action.payload.token) {
multisigTokensAdapter.removeOne(
state.multisigTokens,
universalUserAddress(action.payload.userAddress)
);
let addr;
try {
addr = universalUserAddress(action.payload.userAddress);
} catch (error) {
console.warn("failed to transform user address", error, action);
return;
}
multisigTokensAdapter.removeOne(state.multisigTokens, addr);
return;
}
state.multisigTokens = multisigTokensAdapter.setOne(
Expand Down

0 comments on commit b329e1f

Please sign in to comment.