Skip to content

Commit

Permalink
chore: update from base branch
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnbusuttil committed Apr 23, 2024
2 parents 43ca81c + 0601346 commit 66aaba8
Show file tree
Hide file tree
Showing 200 changed files with 3,078 additions and 1,938 deletions.
5 changes: 2 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ module.exports = {
'no-invalid-this': 0,
'react/prop-types': 'off',
'max-len': 'off', // prettier is already handling this automatically,
// note: prod webpack config strips console logs anyway, nevertheless
// we don't want the dev build to be spammed by needless logging
'@typescript-eslint/no-explicit-any': ['error'],
'no-console': ['error', { allow: ['warn', 'error', 'info', 'debug'] }],
'lodash/import-scope': ['error', 'method']
'lodash/import-scope': ['error', 'method'],
'promise/avoid-new': 'off',
},
overrides: [
{
Expand Down
1 change: 1 addition & 0 deletions apps/browser-extension-wallet/.env.developerpreview
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ PRODUCTION_MODE_TRACKING=false
POSTHOG_DEV_TOKEN_MAINNET=phc_gH96Lx5lEVXTTWEyytSdTFPDk3Xsxwi4BqG88mKObd1
POSTHOG_DEV_TOKEN_PREPROD=phc_Xlmldm6EYSfQVgB9Uxm3b2xC1noDlgFFXpF9AJ6SMfJ
POSTHOG_DEV_TOKEN_PREVIEW=phc_e8SaOOWpXpNE59TnpLumeUjWm4iv024AWjhQqU406jr
POSTHOG_DEV_TOKEN_SANCHONET=phc_OUu6sPucDu5S6skRmYbWN5Jn8TpggWTQu1Y1ETkm3xt

# Cardano Services
CARDANO_SERVICES_URL_MAINNET=https://dev-mainnet.lw.iog.io
Expand Down
2 changes: 1 addition & 1 deletion apps/browser-extension-wallet/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "$WALLET_MANIFEST_NAME",
"description": "One fast, accessible, and secure platform for digital assets, DApps, NFTs, and DeFi.",
"version": "1.10.0",
"version": "1.10.2",
"manifest_version": 3,
"key": "$LACE_EXTENSION_KEY",
"icons": {
Expand Down
14 changes: 7 additions & 7 deletions apps/browser-extension-wallet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lace/browser-extension-wallet",
"version": "1.10.0",
"version": "1.10.2",
"description": "A fully capable wallet packaged as browser extensions for Chrome, Firefox, and Edge",
"homepage": "https://github.com/input-output-hk/lace/blob/master/apps/browser-extension-wallet/README.md",
"bugs": {
Expand Down Expand Up @@ -39,14 +39,14 @@
},
"dependencies": {
"@ant-design/icons": "^4.7.0",
"@cardano-sdk/cardano-services-client": "0.18.0",
"@cardano-sdk/cardano-services-client": "0.19.0",
"@cardano-sdk/core": "0.30.0",
"@cardano-sdk/dapp-connector": "0.12.14",
"@cardano-sdk/input-selection": "0.12.26",
"@cardano-sdk/tx-construction": "0.18.2",
"@cardano-sdk/input-selection": "0.12.27",
"@cardano-sdk/tx-construction": "0.18.3",
"@cardano-sdk/util": "0.15.0",
"@cardano-sdk/wallet": "0.35.2",
"@cardano-sdk/web-extension": "0.26.1",
"@cardano-sdk/wallet": "0.37.0",
"@cardano-sdk/web-extension": "0.27.0",
"@emurgo/cip14-js": "~3.0.1",
"@koralabs/handles-public-api-interfaces": "^1.6.6",
"@lace/cardano": "0.1.0",
Expand All @@ -59,7 +59,7 @@
"@vespaiach/axios-fetch-adapter": "^0.3.0",
"antd": "^4.24.10",
"are-you-es5": "^2.1.2",
"axios": "0.21.4",
"axios": "0.28.0",
"bignumber.js": "9.0.1",
"bip39": "^3.0.4",
"blake2b-no-wasm": "2.1.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ const NonSSLBanner = () => {
const authorize = (authorization: 'deny' | 'just-once' | 'allow', url: string) => {
const api$ = of({
allowOrigin(origin: cip30.Origin): Promise<'deny' | 'just-once' | 'allow'> {
/* eslint-disable-next-line promise/avoid-new */
if (!url.startsWith(origin)) {
return Promise.reject();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
padding-top: size_unit(0);
}

.transactionContainer {
.transactionContainer {
display: flex;
flex-direction: column;
flex: 1;
Expand All @@ -15,13 +15,13 @@

.actions {
@extend %flex-column;
height: size_unit(17.12);
justify-content: space-between;
padding: size_unit(2) size_unit(3) size_unit(2) size_unit(3);
padding: size_unit(3) 0;
border-top: 1px solid var(--light-mode-light-grey-plus, var(--dark-mode-mid-grey));
position: sticky;
bottom: 0;
z-index: 10;
gap: size_unit(1);
background-color: var(--light-mode-body, var(--dark-mode-bg-black));
.actionBtn {
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Flex } from '@lace/ui';
import { useViewsFlowContext } from '@providers/ViewFlowProvider';

import { Wallet } from '@lace/cardano';
import { withAddressBookContext } from '@src/features/address-book/context';
import { useAddressBookContext, withAddressBookContext } from '@src/features/address-book/context';
import { useWalletStore } from '@stores';
import { useFetchCoinPrice, useChainHistoryProvider } from '@hooks';
import {
Expand All @@ -20,9 +20,11 @@ import { createWalletAssetProvider } from '@cardano-sdk/wallet';
import { Skeleton } from 'antd';

import { useCurrencyStore, useAppSettingsContext } from '@providers';
import { logger } from '@lib/wallet-api-ui';
import { logger, walletRepository } from '@lib/wallet-api-ui';
import { useComputeTxCollateral } from '@hooks/useComputeTxCollateral';
import { utxoAndBackendChainHistoryResolver } from '@src/utils/utxo-chain-history-resolver';
import { AddressBookSchema, useDbStateValue } from '@lib/storage';
import { getAllWalletsAddresses } from '@src/utils/get-all-wallets-addresses';

interface DappTransactionContainerProps {
errorMessage?: string;
Expand All @@ -43,6 +45,10 @@ export const DappTransactionContainer = withAddressBookContext(
walletState
} = useWalletStore();

const ownAddresses = useObservable(inMemoryWallet.addresses$)?.map((a) => a.address);
const { list: addressBook } = useAddressBookContext() as useDbStateValue<AddressBookSchema>;
const addressToNameMap = new Map(addressBook?.map((entry) => [entry.address as string, entry.name]));

const { fiatCurrency } = useCurrencyStore();
const { priceResult } = useFetchCoinPrice();

Expand Down Expand Up @@ -77,6 +83,7 @@ export const DappTransactionContainer = withAddressBookContext(
const userRewardAccounts = useObservable(inMemoryWallet.delegation.rewardAccounts$);
const rewardAccountsAddresses = useMemo(() => userRewardAccounts?.map((key) => key.address), [userRewardAccounts]);
const protocolParameters = useObservable(inMemoryWallet?.protocolParameters$);
const allWalletsAddresses = getAllWalletsAddresses(useObservable(walletRepository.wallets$));

useEffect(() => {
if (!req || !protocolParameters) {
Expand Down Expand Up @@ -146,6 +153,8 @@ export const DappTransactionContainer = withAddressBookContext(
errorMessage={errorMessage}
toAddress={toAddressTokens}
collateral={txCollateral}
ownAddresses={allWalletsAddresses.length > 0 ? allWalletsAddresses : ownAddresses}
addressToNameMap={addressToNameMap}
/>
) : (
<Skeleton loading />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ const hash = Crypto.Hash28ByteBase16(Buffer.from('dRepCredentialHashdRepCreden')
const getPubDRepKey = async () => await hash;

const inMemoryWallet = {
getPubDRepKey,
governance: {
getPubDRepKey
},
assetInfo$,
balance: {
utxo: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ import { DappTransactionContainer } from '../DappTransactionContainer';
import '@testing-library/jest-dom';
import { BehaviorSubject } from 'rxjs';
import { act } from 'react-dom/test-utils';
import { buildMockTx } from '@src/utils/mocks/tx';
import { buildMockTx, sendingAddress } from '@src/utils/mocks/tx';
import { Wallet } from '@lace/cardano';
import { SignTxData } from '../types';
import { getWrapper } from '../testing.utils';
import { TransactionWitnessRequest } from '@cardano-sdk/web-extension';
import { cardanoCoin } from '@src/utils/constants';
import { AddressBookSchema } from '@lib/storage';

const { Cardano, Crypto } = Wallet;

Expand All @@ -51,6 +52,7 @@ const mockedAssetsInfo = new Map([['id', 'data']]);
const assetInfo$ = new BehaviorSubject(mockedAssetsInfo);
const available$ = new BehaviorSubject([]);
const signed$ = new BehaviorSubject([]);
const addresses$ = new BehaviorSubject([sendingAddress]);
const rewardAccounts$ = new BehaviorSubject([
{
// eslint-disable-next-line unicorn/consistent-destructuring
Expand All @@ -65,6 +67,7 @@ const protocolParameters$ = new BehaviorSubject({
});

const inMemoryWallet = {
addresses$,
assetInfo$,
balance: {
utxo: {
Expand Down Expand Up @@ -133,12 +136,12 @@ jest.mock('react-i18next', () => {
};
});

const addressList = ['addressList'];
const addressBook: AddressBookSchema[] = [];
jest.mock('@src/features/address-book/context', () => ({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
...jest.requireActual<any>('@src/features/address-book/context'),
withAddressBookContext: mockWithAddressBookContext,
useAddressBookContext: () => ({ list: addressList })
useAddressBookContext: () => ({ list: addressBook })
}));

jest.mock('antd', () => {
Expand Down Expand Up @@ -332,7 +335,9 @@ describe('Testing DappTransactionContainer component', () => {
errorMessage,
coinSymbol: 'ADA',
collateral: BigInt(1_000_000),
txInspectionDetails
txInspectionDetails,
ownAddresses: [sendingAddress.address],
addressToNameMap: new Map()
},
{}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@ describe('Testing hooks', () => {
mockUseWalletStore.mockReset();
mockUseWalletStore.mockReturnValue({
inMemoryWallet: {
getPubDRepKey: jest.fn(async () => await ed25519PublicKeyHexMock)
governance: {
getPubDRepKey: jest.fn(async () => await ed25519PublicKeyHexMock)
}
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export const useGetOwnPubDRepKeyHash = (): UseGetOwnPubDRepKeyHash => {
useEffect(() => {
if (!inMemoryWallet) return;
const get = async () => {
const ownPubDRepKey = await inMemoryWallet.getPubDRepKey();
const ownPubDRepKey = await inMemoryWallet.governance.getPubDRepKey();
const ownDRepKeyHash = await pubDRepKeyToHash(ownPubDRepKey);

setOwnPubDRepKeyHash(ownDRepKeyHash);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OutsideHandlesProvider, StakingPopup } from '@lace/staking';
import { DEFAULT_STAKING_BROWSER_PREFERENCES, OutsideHandlesProvider, StakingPopup } from '@lace/staking';
import React, { useCallback, useEffect } from 'react';
import {
useAnalyticsContext,
Expand Down Expand Up @@ -89,7 +89,7 @@ export const MultiDelegationStakingPopup = (): JSX.Element => {
] = useLocalStorage(MULTIDELEGATION_FIRST_VISIT_SINCE_PORTFOLIO_PERSISTENCE_LS_KEY, true);

const [stakingBrowserPreferencesPersistence, { updateLocalStorage: setStakingBrowserPreferencesPersistence }] =
useLocalStorage(STAKING_BROWSER_PREFERENCES_LS_KEY);
useLocalStorage(STAKING_BROWSER_PREFERENCES_LS_KEY, DEFAULT_STAKING_BROWSER_PREFERENCES);

const walletAddress = walletInfo.addresses?.[0].address?.toString();
const analytics = useAnalyticsContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ jest.mock('../../stores', () => ({
})
}));

// eslint-disable-next-line promise/avoid-new
const flushPromises = () => new Promise(setImmediate);

describe('Testing useBuildDelegation hook', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import SpyInstance = jest.SpyInstance;
const mockEmip3decrypt = jest.fn();
const mockEmip3encrypt = jest.fn();
const mockConnectDevice = jest.fn();
const mockGetHwExtendedAccountPublicKey = jest.fn();
const mockRestoreWalletFromKeyAgent = jest.fn();
const mockSwitchKeyAgents = jest.fn();
const mockLedgerCheckDeviceConnection = jest.fn();
Expand Down Expand Up @@ -80,6 +81,7 @@ jest.mock('@lace/cardano', () => {
restoreWalletFromKeyAgent: mockRestoreWalletFromKeyAgent,
switchKeyAgents: mockSwitchKeyAgents,
connectDevice: mockConnectDevice,
getHwExtendedAccountPublicKey: mockGetHwExtendedAccountPublicKey,
KeyManagement: {
...actual.Wallet.KeyManagement,
emip3decrypt: mockEmip3decrypt,
Expand Down Expand Up @@ -382,7 +384,7 @@ describe('Testing useWalletManager hook', () => {
describe('createHardwareWallet', () => {
test('should use cardano manager to create wallet', async () => {
const walletId = 'walletId';
mockLedgerGetXpub.mockResolvedValue('pubkey');
mockGetHwExtendedAccountPublicKey.mockResolvedValue('pubkey');
(walletApiUi.walletRepository as any).addWallet = jest.fn().mockResolvedValue(walletId);
(walletApiUi.walletRepository as any).addAccount = jest.fn().mockResolvedValue(undefined);
(walletApiUi.walletManager as any).activate = jest.fn().mockResolvedValue(undefined);
Expand Down Expand Up @@ -696,11 +698,11 @@ describe('Testing useWalletManager hook', () => {
},
{
type: WalletType.Trezor,
prepare: () => mockTrezorGetXpub.mockResolvedValueOnce(extendedAccountPublicKey)
prepare: () => mockGetHwExtendedAccountPublicKey.mockResolvedValueOnce(extendedAccountPublicKey)
},
{
type: WalletType.Ledger,
prepare: () => mockLedgerGetXpub.mockResolvedValueOnce(extendedAccountPublicKey)
prepare: () => mockGetHwExtendedAccountPublicKey.mockResolvedValueOnce(extendedAccountPublicKey)
}
];

Expand Down
Loading

0 comments on commit 66aaba8

Please sign in to comment.