Skip to content

Commit

Permalink
fix: revert query-string append changes
Browse files Browse the repository at this point in the history
  • Loading branch information
esaminu committed Feb 9, 2022
1 parent c8c2e36 commit f397b54
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 26 deletions.
4 changes: 0 additions & 4 deletions packages/frontend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ module.exports = {
'name': 'URLSearchParams',
'message': 'Use `query-string` package instead'
}],
'no-restricted-properties': ['error', {
'property': 'searchParams',
'message': 'Use `query-string` package instead'
}],
'no-restricted-syntax': ['error', {
'selector': `VariableDeclarator[id.type='ObjectPattern'] Property[key.name='searchParams']`,
'message': 'URL.searchParams is not allowed, Use `query-string` package instead'
Expand Down
22 changes: 7 additions & 15 deletions packages/frontend/src/redux/actions/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,13 @@ export const allowLogin = () => async (dispatch, getState) => {
const availableKeys = await wallet.getAvailableKeys();

const allKeys = availableKeys.map(key => key.toString());
const url = new URL(successUrl);
const originalSearchParams = parse(url.search);
window.location = successUrl.replace(url.search, `?${stringify(
{
...originalSearchParams,
account_id: wallet.accountId,
public_key: publicKey,
all_keys: allKeys.join(","),
},
{
skipEmptyString: true,
skipNull: true,
arrayFormat: "comma"
}
)}`);
const parsedUrl = new URL(successUrl);
parsedUrl.searchParams.set('account_id', wallet.accountId);
if (publicKey) {
parsedUrl.searchParams.set('public_key', publicKey);
}
parsedUrl.searchParams.set('all_keys', allKeys.join(','));
window.location = parsedUrl.href;
} else {
await dispatch(withAlert(addAccessKey(wallet.accountId, contractId, publicKey, false, methodNames), { data: { title } }));
dispatch(redirectTo('/authorized-apps', { globalAlertPreventClear: true }));
Expand Down
13 changes: 6 additions & 7 deletions packages/frontend/src/redux/slices/sign/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createAsyncThunk, createAction } from "@reduxjs/toolkit";
import BN from 'bn.js';
import cloneDeep from 'lodash.clonedeep';
import { parse, stringify } from "query-string";
import { createSelector } from "reselect";

import { Mixpanel } from "../../../mixpanel";
Expand Down Expand Up @@ -80,13 +79,13 @@ export const handleSignTransactions = createAsyncThunk(
}
);

export function addQueryParams(baseUrl, queryParams = {}) {
export function addQueryParams(baseUrl, queryParams) {
const url = new URL(baseUrl);
const originalSearchParams = parse(url.search);
return baseUrl.replace(url.search,`?${stringify({...originalSearchParams, ...queryParams}, {
skipEmptyString: true,
skipNull: true,
})}`);
for (let key in queryParams) {
const param = queryParams[key];
if(param) url.searchParams.set(key, param);
}
return url.toString();
}

export const removeSuccessTransactions = ({ transactions, successHashes }) => {
Expand Down

0 comments on commit f397b54

Please sign in to comment.