Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: axios get request for wallet config #4545

Merged
merged 2 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/features/hiro-messages/in-app-messages.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Flex, FlexProps } from 'leather-styles/jsx';

import { useRemoteHiroMessages } from '@app/query/common/remote-config/remote-config.query';
import { useRemoteLeatherMessages } from '@app/query/common/remote-config/remote-config.query';
import { useCurrentNetworkState } from '@app/store/networks/networks.hooks';
import { useDismissMessage } from '@app/store/settings/settings.actions';
import { useDismissedMessageIds } from '@app/store/settings/settings.selectors';

import { HiroMessageItem } from './components/in-app-message-item';

export function InAppMessages(props: FlexProps) {
const messages = useRemoteHiroMessages();
const messages = useRemoteLeatherMessages();

const { mode } = useCurrentNetworkState();
const dismissMessage = useDismissMessage();
Expand Down
9 changes: 5 additions & 4 deletions src/app/query/common/remote-config/remote-config.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,15 @@ const githubWalletConfigRawUrl = `https://raw.githubusercontent.com/${GITHUB_ORG
BRANCH_NAME || defaultBranch
}/config/wallet-config.json`;

async function fetchHiroMessages(): Promise<RemoteConfig> {
async function fetchLeatherMessages(): Promise<RemoteConfig> {
if ((!BRANCH_NAME && WALLET_ENVIRONMENT !== 'production') || IS_TEST_ENV)
return localConfig as RemoteConfig;
return axios.get(githubWalletConfigRawUrl);
const resp = await axios.get(githubWalletConfigRawUrl);
return resp.data;
}

function useRemoteConfig() {
const { data } = useQuery(['walletConfig'], fetchHiroMessages, {
const { data } = useQuery(['walletConfig'], fetchLeatherMessages, {
// As we're fetching from Github, a third-party, we want
// to avoid any unnecessary stress on their services, so
// we use quite slow stale/retry times
Expand All @@ -91,7 +92,7 @@ function useRemoteConfig() {
return data;
}

export function useRemoteHiroMessages(): HiroMessage[] {
export function useRemoteLeatherMessages(): HiroMessage[] {
const config = useRemoteConfig();
return get(config, 'messages.global', []);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ test.describe('Bitcoin Contract Request Test', () => {
}) =>
page.evaluate(
async params =>
(window as any).HiroWalletProvider.request('acceptBitcoinContractOffer', params).catch(
(window as any).LeatherProvider.request('acceptBitcoinContractOffer', params).catch(
(e: unknown) => e
),
requestParams
Expand Down
2 changes: 1 addition & 1 deletion tests/specs/message-signing/bip322-message-signing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ test.describe('Message signing', () =>
return async (message: string) =>
page.evaluate(
async message =>
(window as any).HiroWalletProvider.request('signMessage', {
(window as any).LeatherProvider.request('signMessage', {
message,
paymentType: 'p2wpkh',
}).catch((e: unknown) => e),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ test.describe('Transaction signing', () => {
return async (txHex: string) =>
page.evaluate(
async txHex =>
(window as any).HiroWalletProvider.request('stx_signTransaction', {
(window as any).LeatherProvider.request('stx_signTransaction', {
txHex,
network: 'mainnet',
}).catch((e: unknown) => e),
Expand Down
2 changes: 1 addition & 1 deletion tests/specs/settings/settings-menu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ test.describe('Settings menu', () => {
test.expect(currentNetwork).toContain('mainnet');

await page.getByTestId(SettingsSelectors.ChangeNetworkAction).click();
await page.waitForTimeout(850);
await page.waitForTimeout(1000);
const networkListItems = await page.getByTestId(SettingsSelectors.NetworkListItem).all();
test.expect(networkListItems).toHaveLength(5);
});
Expand Down