Skip to content

Commit

Permalink
Merge branch 'dev' into feat/flexible-final-sign
Browse files Browse the repository at this point in the history
  • Loading branch information
sokolova-an authored Dec 27, 2024
2 parents e6d32e7 + fcc48ca commit 2f468e6
Show file tree
Hide file tree
Showing 82 changed files with 1,287 additions and 603 deletions.
1 change: 1 addition & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import '@/app/index.css';
import '@/app/styles/theme/default.css';
import './theme/root.css';

import { I18Provider } from '@/shared/i18n';
import { ThemeProvider } from '@/shared/ui-kit';
Expand Down
3 changes: 3 additions & 0 deletions .storybook/theme/root.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
html, body {
height: 100%;
}
1 change: 1 addition & 0 deletions app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ module.exports = {
RENDERER: 'src/renderer/app/index.tsx',
},

APP_ROOT: 'src/renderer/app',
INDEX_HTML: 'src/renderer/app/index.html',
RESOURCES: 'src/main/resources',
DEV_BUILD: 'release/build/',
Expand Down
22 changes: 12 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@
"@polkadot/types": "15.0.2",
"@polkadot/util": "13.2.3",
"@polkadot/util-crypto": "13.2.3",
"@radix-ui/react-accordion": "1.2.1",
"@radix-ui/react-checkbox": "1.1.2",
"@radix-ui/react-dialog": "1.1.2",
"@radix-ui/react-dropdown-menu": "2.1.2",
"@radix-ui/react-popover": "1.1.2",
"@radix-ui/react-progress": "1.1.0",
"@radix-ui/react-scroll-area": "1.2.1",
"@radix-ui/react-select": "2.1.2",
"@radix-ui/react-slider": "1.2.1",
"@radix-ui/react-tooltip": "1.1.4",
"@radix-ui/react-accordion": "1.2.2",
"@radix-ui/react-checkbox": "1.1.3",
"@radix-ui/react-dialog": "1.1.4",
"@radix-ui/react-dropdown-menu": "2.1.4",
"@radix-ui/react-popover": "1.1.4",
"@radix-ui/react-progress": "1.1.1",
"@radix-ui/react-scroll-area": "1.2.0",
"@radix-ui/react-select": "2.1.4",
"@radix-ui/react-slider": "1.2.2",
"@radix-ui/react-tooltip": "1.1.6",
"@react-spring/web": "9.7.5",
"@remote-ui/rpc": "^1.4.4",
"@substrate/connect": "2.1.1",
Expand Down Expand Up @@ -205,6 +205,8 @@
"eslint-plugin-react": "7.37.1",
"eslint-plugin-unused-imports": "4.1.4",
"fake-indexeddb": "4.0.2",
"favicons": "7.2.0",
"favicons-webpack-plugin": "6.0.1",
"file-loader": "6.2.0",
"html-webpack-plugin": "5.6.0",
"husky": "9.1.6",
Expand Down
792 changes: 596 additions & 196 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

Binary file removed public/android-chrome-192x192.png
Binary file not shown.
Binary file removed public/android-chrome-256x256.png
Binary file not shown.
Binary file removed public/apple-touch-icon.png
Binary file not shown.
Binary file removed public/favicon-16x16.png
Binary file not shown.
Binary file removed public/favicon-32x32.png
Binary file not shown.
Binary file removed public/favicon.ico
Binary file not shown.
Binary file removed public/mstile-150x150.png
Binary file not shown.
18 changes: 0 additions & 18 deletions public/safari-pinned-tab.svg

This file was deleted.

19 changes: 0 additions & 19 deletions public/site.webmanifest

This file was deleted.

Binary file added src/renderer/app/favicon.dev.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/renderer/app/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 0 additions & 11 deletions src/renderer/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@
<head>
<meta charset="UTF-8" />

<link rel="apple-touch-icon" sizes="180x180" href="./apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="./favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="./favicon-16x16.png">
<link rel="manifest" href="./site.webmanifest">
<link rel="mask-icon" href="./safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">

<!-- This tag commented on purpose - that's the way to "support" mobile devices-->
<!-- <meta name="viewport" content="width=device-width, initial-scale=1" />-->
Expand All @@ -29,11 +23,6 @@
<meta name="twitter:image" content="https://framerusercontent.com/assets/1jyzdPx8VawFTKoBm8yig14Flm8.png">
<!-- <link rel="stylesheet" href="theme/default.css" />-->
<!-- <link rel="stylesheet" href="theme/dark.css" /> Add when dark theme colors are ready -->
<!-- <meta property="twitter:url" content="https://omni.enterprise" />-->
<!-- <meta property="twitter:image" content="%PUBLIC_URL%/og-image.png" />-->

<!-- <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />-->
<!-- <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />-->

<!-- TODO: add CSP https://csplite.com/ru/csp216/-->
<title>Nova Spektr</title>
Expand Down
23 changes: 13 additions & 10 deletions src/renderer/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { resetFeatureStatuses, updateFeatureStatus } from '@/shared/config/featu
import { I18Provider } from '@/shared/i18n';
import { isElectron } from '@/shared/lib/utils';
import { FallbackScreen } from '@/shared/ui';
import { ThemeProvider } from '@/shared/ui-kit';
import { APP_CONFIG } from '../../../app.config';

import { LoadingDelay, controlledLazy, suspenseDelay } from './DelayedSuspense';
Expand Down Expand Up @@ -61,16 +62,18 @@ const Root = () => {
const splashScreen = renderSplashScreen ? isElectron() ? <ElectronSplashScreen /> : <WebSplashScreen /> : null;

return (
<HashRouter>
<I18Provider>
<ErrorBoundary FallbackComponent={FallbackScreen} onError={console.error}>
<Suspense fallback={splashScreen}>
<App onReady={() => setAppLoaded(true)} />
<LoadingDelay suspense={loadingDelay} />
</Suspense>
</ErrorBoundary>
</I18Provider>
</HashRouter>
<ThemeProvider theme="light" iconStyle="colored">
<HashRouter>
<I18Provider>
<ErrorBoundary FallbackComponent={FallbackScreen} onError={console.error}>
<Suspense fallback={splashScreen}>
<App onReady={() => setAppLoaded(true)} />
<LoadingDelay suspense={loadingDelay} />
</Suspense>
</ErrorBoundary>
</I18Provider>
</HashRouter>
</ThemeProvider>
);
};

Expand Down
6 changes: 6 additions & 0 deletions src/renderer/app/manifest.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "Nova Spektr",
"short_name": "Spektr",
"display": "standalone",
"start_url": "/"
}
12 changes: 6 additions & 6 deletions src/renderer/domains/collectives/model/members/service.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { type Account, type Chain } from '@/shared/core';
import { type Account, type Chain, type Wallet } from '@/shared/core';
import { dictionary } from '@/shared/lib/utils';
import { accountUtils } from '@/entities/wallet';

import { type CoreMember, type Member } from './types';

const findMachingMember = (accounts: Account[], members: Member[], chain: Chain) => {
const findMatchingMember = (wallet: Wallet, accounts: Account[], chain: Chain, members: Member[]) => {
const walletAccounts = accounts.filter(account => {
return !accountUtils.isBaseAccount(account) && accountUtils.isChainAndCryptoMatch(account, chain);
return accountUtils.isNonBaseVaultAccount(account, wallet) && accountUtils.isChainAndCryptoMatch(account, chain);
});
const accountsDictionary = dictionary(walletAccounts, 'accountId');

return members.find(member => member.accountId in accountsDictionary) ?? null;
};

const findMachingAccount = (accounts: Account[], member: Member) => {
const findMatchingAccount = (accounts: Account[], member: Member) => {
return accounts.find(a => a.accountId === member.accountId) ?? null;
};

Expand All @@ -26,7 +26,7 @@ const isCoreMember = (member: Member | CoreMember): member is CoreMember => {
};

export const membersService = {
findMachingMember,
findMachingAccount,
findMatchingMember,
findMatchingAccount,
isCoreMember,
};
18 changes: 7 additions & 11 deletions src/renderer/domains/identity/model/identity/model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type ApiPromise } from '@polkadot/api';
import { createEvent, sample } from 'effector';
import { attach } from 'effector';

import { type ChainId } from '@/shared/core';
import { createDataSource } from '@/shared/effector';
Expand Down Expand Up @@ -27,6 +27,7 @@ type InnerRequestParams = {
const {
$: $list,
request: requestIdentity,
fulfilled,
pending,
fail,
} = createDataSource<IdentityStore, InnerRequestParams, IdentityData>({
Expand Down Expand Up @@ -73,15 +74,10 @@ const {

const { $apis, $chains } = networkModel;

const request = createEvent<RequestParams>();

sample({
clock: request,
source: {
apis: $apis,
chains: $chains,
},
fn: ({ apis, chains }, { chainId, accounts }) => {
const request = attach({
effect: requestIdentity,
source: { apis: $apis, chains: $chains },
mapParams: ({ chainId, accounts }: RequestParams, { apis, chains }) => {
const identityChain = identityService.findIdentityChain(chains, chainId);
if (nullable(identityChain)) {
throw new Error(`Chain path from ${chainId} is broken, trace chain.parentId fields in config.`);
Expand All @@ -98,11 +94,11 @@ sample({
api,
};
},
target: requestIdentity,
});

export const identityDomainModel = {
$list,
$fulfilled: fulfilled,
request,
pending,
fail,
Expand Down
9 changes: 9 additions & 0 deletions src/renderer/entities/transaction/lib/callDataDecoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,15 @@ export const useCallDataDecoder = (): ICallDataDecoder => {

return xcmService.decodeXcm(chainId, parsedData);
},
[TransactionType.POLKADOT_XCM_TRANSFER_ASSETS]: (decoded, chainId): Record<string, any> => {
const parsedData = xcmService.parseXcmPalletExtrinsic({
dest: decoded.args[0].toHuman(),
beneficiary: decoded.args[1].toHuman(),
assets: decoded.args[2].toHuman(),
});

return xcmService.decodeXcm(chainId, parsedData);
},
[TransactionType.XTOKENS_TRANSFER_MULTIASSET]: (decoded, chainId): Record<string, any> => {
const parsedData = xcmService.parseXTokensExtrinsic({
asset: decoded.args[0].toHuman(),
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/entities/transaction/lib/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const XcmTypes = [
TransactionType.XCM_LIMITED_TRANSFER,
TransactionType.POLKADOT_XCM_TELEPORT,
TransactionType.POLKADOT_XCM_LIMITED_TRANSFER,
TransactionType.POLKADOT_XCM_TRANSFER_ASSETS,
TransactionType.XTOKENS_TRANSFER_MULTIASSET,
];

Expand All @@ -53,6 +54,7 @@ export type XcmTransactionTypes =
| TransactionType.XCM_LIMITED_TRANSFER
| TransactionType.POLKADOT_XCM_TELEPORT
| TransactionType.POLKADOT_XCM_LIMITED_TRANSFER
| TransactionType.POLKADOT_XCM_TRANSFER_ASSETS
| TransactionType.XTOKENS_TRANSFER_MULTIASSET;

export type MultisigTransactionTypes =
Expand Down
13 changes: 10 additions & 3 deletions src/renderer/entities/transaction/lib/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ export const findCoreBatchAll = (coreTx: Transaction | DecodedTransaction): Tran
return coreTx.args?.transactions?.find((t: Transaction) => t.type === TransactionType.UNLOCK) || coreTx;
}

return coreTx.args?.transactions?.find((tx: Transaction) => isWrappedInBatchAll(tx.type));
const supportedTransaction = coreTx.args?.transactions?.find((tx: Transaction) => isWrappedInBatchAll(tx.type));

return supportedTransaction || coreTx.args?.transactions?.[0];
};

export const getTransactionAmount = (tx: Transaction | DecodedTransaction): string | null => {
Expand Down Expand Up @@ -231,6 +233,7 @@ const TransactionTitles: Record<TransactionType, string> = {
[TransactionType.XCM_TELEPORT]: 'operations.titles.crossChainTransfer',
[TransactionType.POLKADOT_XCM_LIMITED_TRANSFER]: 'operations.titles.crossChainTransfer',
[TransactionType.POLKADOT_XCM_TELEPORT]: 'operations.titles.crossChainTransfer',
[TransactionType.POLKADOT_XCM_TRANSFER_ASSETS]: 'operations.titles.crossChainTransfer',
[TransactionType.XTOKENS_TRANSFER_MULTIASSET]: 'operations.titles.crossChainTransfer',
// Staking
[TransactionType.BOND]: 'operations.titles.startStaking',
Expand All @@ -242,7 +245,7 @@ const TransactionTitles: Record<TransactionType, string> = {
[TransactionType.UNSTAKE]: 'operations.titles.unstake',
// Technical
[TransactionType.CHILL]: 'operations.titles.unstake',
[TransactionType.BATCH_ALL]: 'operations.titles.unknown',
[TransactionType.BATCH_ALL]: 'operations.titles.batchAll',
// Proxy
[TransactionType.ADD_PROXY]: 'operations.titles.addProxy',
[TransactionType.CREATE_PURE_PROXY]: 'operations.titles.createPureProxy',
Expand Down Expand Up @@ -283,6 +286,8 @@ const TransactionTitlesModal: Record<TransactionType, (crossChain: boolean) => s
`operations.modalTitles.${crossChain ? 'transferFrom' : 'transferOn'}`,
[TransactionType.POLKADOT_XCM_TELEPORT]: (crossChain) =>
`operations.modalTitles.${crossChain ? 'transferFrom' : 'transferOn'}`,
[TransactionType.POLKADOT_XCM_TRANSFER_ASSETS]: (crossChain) =>
`operations.modalTitles.${crossChain ? 'transferFrom' : 'transferOn'}`,
[TransactionType.XTOKENS_TRANSFER_MULTIASSET]: (crossChain) =>
`operations.modalTitles.${crossChain ? 'transferFrom' : 'transferOn'}`,
// Staking
Expand Down Expand Up @@ -355,7 +360,9 @@ export const getModalTransactionTitle = (
}

if (transaction.type === TransactionType.BATCH_ALL) {
return getModalTransactionTitle(crossChain, t, transaction.args?.transactions?.[0]);
const txMatch = findCoreBatchAll(transaction);

return getModalTransactionTitle(crossChain, t, txMatch);
}

if (transaction.type === TransactionType.PROXY) {
Expand Down
19 changes: 19 additions & 0 deletions src/renderer/entities/transaction/lib/common/xcmMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,25 @@ export function limitedTeleportAssets(
);
}

export function transferAssets(
pallet: XcmPallet,
args: XcmPalletTransferArgs,
info: BaseTxInfo,
options: OptionsWithMeta,
): UnsignedTransaction {
return defineMethod(
{
method: {
args,
name: 'transferAssets',
pallet,
},
...info,
},
options,
);
}

export function transferMultiAsset(
args: XTokenPalletTransferArgs,
info: BaseTxInfo,
Expand Down
19 changes: 19 additions & 0 deletions src/renderer/entities/transaction/lib/extrinsicService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,20 @@ export const getUnsignedTransaction: Record<
options,
);
},
[TransactionType.POLKADOT_XCM_TRANSFER_ASSETS]: (transaction, info, options) => {
return xcmMethods.transferAssets(
'polkadotXcm',
{
dest: transaction.args.xcmDest,
beneficiary: transaction.args.xcmBeneficiary,
assets: transaction.args.xcmAsset,
feeAssetItem: DEFAULT_FEE_ASSET_ITEM,
weightLimit: { Unlimited: true },
},
info,
options,
);
},
[TransactionType.XTOKENS_TRANSFER_MULTIASSET]: (transaction, info, options) => {
return xcmMethods.transferMultiAsset(
{
Expand Down Expand Up @@ -527,6 +541,11 @@ export const getExtrinsic: Record<
Unlimited: true,
});
},
[TransactionType.POLKADOT_XCM_TRANSFER_ASSETS]: ({ xcmDest, xcmBeneficiary, xcmAsset }, api) => {
return api.tx.polkadotXcm.transferAssets(xcmDest, xcmBeneficiary, xcmAsset, DEFAULT_FEE_ASSET_ITEM, {
Unlimited: true,
});
},
[TransactionType.XTOKENS_TRANSFER_MULTIASSET]: ({ xcmDest, xcmAsset, xcmWeight }, api) => {
const weight = hasDestWeight(api) ? xcmWeight : { Unlimited: true };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const TransactionIcons: Record<TransactionType, IconNames> = {
[TransactionType.XCM_TELEPORT]: 'crossChainConfirm',
[TransactionType.POLKADOT_XCM_LIMITED_TRANSFER]: 'crossChainConfirm',
[TransactionType.POLKADOT_XCM_TELEPORT]: 'crossChainConfirm',
[TransactionType.POLKADOT_XCM_TRANSFER_ASSETS]: 'crossChainConfirm',
[TransactionType.XTOKENS_TRANSFER_MULTIASSET]: 'crossChainConfirm',
// Staking
[TransactionType.BOND]: 'startStakingConfirm',
Expand Down
Loading

0 comments on commit 2f468e6

Please sign in to comment.