Skip to content

Commit

Permalink
fix uri handling
Browse files Browse the repository at this point in the history
  • Loading branch information
yushih committed Jan 9, 2025
1 parent 8fe0f0e commit eaf82ad
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 21 deletions.
2 changes: 2 additions & 0 deletions packages/yoroi-extension/app/Routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ export const Routes = (stores: StoresMap): Node => {
component={props => wrapPortfolio({ ...props, stores }, PortfolioSubpages(stores))}
/>
</Switch>

<Redirect to={ROUTES.ROOT} />
</Suspense>
</QueryClientProvider>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ export default class URILandingDialogContainer extends Component<Props> {
<URIInvalidDialog
onClose={this.onCancel}
onSubmit={this.onCancel}
address={
this.props.stores.loading.uriParams
? this.props.stores.loading.uriParams.address
: null
}
address={this.props.stores.loading.uriParams?.address || null}
/>
);
}
Expand Down
4 changes: 0 additions & 4 deletions packages/yoroi-extension/app/containers/uri/URILandingPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ export default class URILandingPage extends Component<StoresProps> {
};

onConfirm: void => void = () => {
const firstSelectedWalletId = this.firstSelectedWalletId();
if (firstSelectedWalletId) {
this.props.stores.wallets.setActiveWallet({ publicDeriverId: firstSelectedWalletId });
}
// this will automatically reroute to the right page if no wallet exists
this.props.stores.app.goToRoute({ route: ROUTES.WALLETS.SEND });
};
Expand Down
23 changes: 12 additions & 11 deletions packages/yoroi-extension/app/stores/toplevel/ProfileStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,22 @@ export default class ProfileStore extends BaseProfileStore<StoresMap> {
await stores.memos.loadFromStorage();
await stores.tokenInfoStore.refreshTokenInfo();
await stores.coinPriceStore.loadFromStorage();

await wallets.restoreWalletsFromStorage();

const firstWallet =
wallets.wallets.length !== 0 ? wallets.wallets[0] : null;
if (firstWallet == null) {
stores.app.goToRoute({ route: ROUTES.WALLETS.ADD });
return;
}
const lastSelectedWallet = await this.stores.wallets.getLastSelectedWallet();
stores.wallets.setActiveWallet({
publicDeriverId: lastSelectedWallet?.publicDeriverId ?? firstWallet.publicDeriverId,
});

if (wallets.hasAnyWallets && stores.loading.fromUriScheme) {
stores.app.goToRoute({ route: ROUTES.SEND_FROM_URI.ROOT });
} else {
const firstWallet =
wallets.wallets.length !== 0 ? wallets.wallets[0] : null;
if (firstWallet == null) {
stores.app.goToRoute({ route: ROUTES.WALLETS.ADD });
return;
}
const lastSelectedWallet = await this.stores.wallets.getLastSelectedWallet();
stores.wallets.setActiveWallet({
publicDeriverId: lastSelectedWallet?.publicDeriverId ?? firstWallet.publicDeriverId,
});
stores.app.goToRoute({ route: ROUTES.WALLETS.ROOT });
}
runInAction(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/yoroi-extension/app/utils/URIHandling.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const extractAddress: (
currencyValidator,
) => {
// consider use of URLSearchParams
const addressRegex = new RegExp('cardano:([A-Za-z0-9]+)');
const addressRegex = new RegExp('cardano:([A-Za-z0-9_]+)');
const currencyRegex = new RegExp('(cardano+):');
const addressMatch = addressRegex.exec(uri);
const currencyMatch = currencyRegex.exec(uri);
Expand Down

0 comments on commit eaf82ad

Please sign in to comment.