Skip to content

Commit

Permalink
fix: handle server urls
Browse files Browse the repository at this point in the history
  • Loading branch information
vetalcore committed Oct 15, 2024
1 parent 5935fa5 commit 1c14541
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
/* eslint-disable import/imports-first */
const mockUseMaxAda = jest.fn();
const mockUseBuitTxState = jest.fn();
const mockToastNotify = jest.fn();
const mockUseSyncingTheFirstTime = jest.fn();
const mockCreateTxBuilder = jest.fn();
const mockUseWalletStore = jest.fn();
Expand Down Expand Up @@ -70,23 +69,15 @@ jest.mock('@hooks/useSyncingTheFirstTime', () => ({
useSyncingTheFirstTime: mockUseSyncingTheFirstTime
}));

jest.mock('@lace/common', () => ({
...jest.requireActual<any>('@lace/common'),
toast: {
notify: mockToastNotify
}
}));

const getWrapper =
() =>
({ children }: { children: React.ReactNode }) =>
(
<AppSettingsProvider>
<StoreProvider appMode={APP_MODE_BROWSER}>
<I18nextProvider i18n={i18n}>{children}</I18nextProvider>
</StoreProvider>
</AppSettingsProvider>
);
({ children }: { children: React.ReactNode }) => (

Check failure on line 74 in apps/browser-extension-wallet/src/hooks/__tests__/useCollateral.test.tsx

View workflow job for this annotation

GitHub Actions / Release package

Insert `⏎···`
<AppSettingsProvider>

Check failure on line 75 in apps/browser-extension-wallet/src/hooks/__tests__/useCollateral.test.tsx

View workflow job for this annotation

GitHub Actions / Release package

Insert `··`
<StoreProvider appMode={APP_MODE_BROWSER}>

Check failure on line 76 in apps/browser-extension-wallet/src/hooks/__tests__/useCollateral.test.tsx

View workflow job for this annotation

GitHub Actions / Release package

Insert `··`
<I18nextProvider i18n={i18n}>{children}</I18nextProvider>

Check failure on line 77 in apps/browser-extension-wallet/src/hooks/__tests__/useCollateral.test.tsx

View workflow job for this annotation

GitHub Actions / Release package

Insert `··`
</StoreProvider>

Check failure on line 78 in apps/browser-extension-wallet/src/hooks/__tests__/useCollateral.test.tsx

View workflow job for this annotation

GitHub Actions / Release package

Insert `··`
</AppSettingsProvider>

Check failure on line 79 in apps/browser-extension-wallet/src/hooks/__tests__/useCollateral.test.tsx

View workflow job for this annotation

GitHub Actions / Release package

Insert `··`
);

Check failure on line 80 in apps/browser-extension-wallet/src/hooks/__tests__/useCollateral.test.tsx

View workflow job for this annotation

GitHub Actions / Release package

Insert `··`

describe('Testing useCollateral hook', () => {
beforeEach(() => {
Expand Down Expand Up @@ -262,7 +253,6 @@ describe('Testing useCollateral hook', () => {
expect(mockSetUnspendable).not.toHaveBeenCalled();
expect(inspect).not.toHaveBeenCalled();
expect(mockSetBuiltTxData).not.toHaveBeenCalled();
expect(mockToastNotify).not.toHaveBeenCalled();
});

mockUseMaxAda.mockReset();
Expand All @@ -280,7 +270,6 @@ describe('Testing useCollateral hook', () => {
expect(mockSetUnspendable).not.toHaveBeenCalled();
expect(inspect).not.toHaveBeenCalled();
expect(mockSetBuiltTxData).not.toHaveBeenCalled();
expect(mockToastNotify).not.toHaveBeenCalled();
});
});

Expand Down Expand Up @@ -311,7 +300,6 @@ describe('Testing useCollateral hook', () => {

await waitFor(() => {
expect(mockSubmitTx).toBeCalledWith(signedTx);
expect(mockToastNotify).toBeCalledWith({ text: 'Collateral added' });
expect(mockSetUnspendable).toBeCalledWith([utxo]);
expect(mockSetBuiltTxData).not.toBeCalled();
});
Expand All @@ -333,7 +321,6 @@ describe('Testing useCollateral hook', () => {

await waitFor(() => {
expect(mockSubmitTx).toBeCalledWith(signedTx);
expect(mockToastNotify).toBeCalledWith({ text: 'Collateral added' });
expect(mockSetUnspendable).toBeCalledWith([utxo]);
expect(mockSetBuiltTxData).toBeCalledWith({
uiTx: {
Expand Down
10 changes: 6 additions & 4 deletions packages/nami/src/features/ada-handle/config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { Cardano } from '@cardano-sdk/core';
import { Wallet } from '@lace/cardano';

export const ADA_HANDLE_POLICY_ID = Wallet.ADA_HANDLE_POLICY_ID;
export const isAdaHandleEnabled = process.env.USE_ADA_HANDLE === 'true';
export const HANDLE_SERVER_URLS: Record<Cardano.NetworkMagics, string> = {
[Cardano.NetworkMagics.Mainnet]: process.env.ADA_HANDLE_URL_MAINNET!,
[Cardano.NetworkMagics.Preprod]: process.env.ADA_HANDLE_URL_PREPROD!,
[Cardano.NetworkMagics.Preview]: process.env.ADA_HANDLE_URL_PREVIEW!,
[Cardano.NetworkMagics.Sanchonet]: process.env.ADA_HANDLE_URL_SANCHONET!,
[Cardano.NetworkMagics.Mainnet]: process.env.CARDANO_SERVICES_URL_MAINNET!,
[Cardano.NetworkMagics.Preprod]: process.env.CARDANO_SERVICES_URL_PREPROD!,
[Cardano.NetworkMagics.Preview]: process.env.CARDANO_SERVICES_URL_PREVIEW!,
[Cardano.NetworkMagics.Sanchonet]:
process.env.CARDANO_SERVICES_URL_SANCHONET!,
};
3 changes: 2 additions & 1 deletion packages/nami/src/features/ada-handle/useHandleResolver.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { useMemo } from 'react';

import { handleHttpProvider } from '@cardano-sdk/cardano-services-client';
import axiosFetchAdapter from '@shiroyasha9/axios-fetch-adapter';

import { HANDLE_SERVER_URLS } from './config';

Expand All @@ -13,6 +13,7 @@ export const useHandleResolver = (
return useMemo(() => {
const serverUrl = HANDLE_SERVER_URLS[networkMagic];
return handleHttpProvider({
adapter: axiosFetchAdapter,
baseUrl: serverUrl,
logger: console,
});
Expand Down

0 comments on commit 1c14541

Please sign in to comment.