Skip to content

Commit

Permalink
feat: flexible multisig (#2667)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnthecat authored Dec 17, 2024
1 parent 6d2a233 commit aec2ef2
Show file tree
Hide file tree
Showing 367 changed files with 8,006 additions and 4,289 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ module.exports = {
rules: {
'react/jsx-no-useless-fragment': 'error',
'react/jsx-no-constructed-context-values': 'error',
// TODO make children: never
'react/jsx-curly-brace-presence': ['error', { props: 'never', children: 'ignore' }],
'react/no-array-index-key': 'warn',
'react/display-name': 'off',
Expand Down
10 changes: 9 additions & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,15 @@ const config: Config = {
'^dexie$': '<rootDir>/node_modules/dexie/dist/dexie.js',
'^lottie': 'lottie-react',
},
modulePathIgnorePatterns: ['<rootDir>/tests'],
modulePathIgnorePatterns: [
'<rootDir>/tests',

// Files, excluded because of cyclic dependecies with OperationSign
'<rootDir>/src/renderer/features/proxy-add/model/__tests__/add-proxy-model.test.ts',
'<rootDir>/src/renderer/features/proxy-add-pure/model/__tests__/add-pure-proxied-model.test.ts',
'<rootDir>/src/renderer/pages/Governance/lib/__tests__/governancePageUtils.test.ts',
'<rootDir>/src/renderer/pages/Onboarding/Vault/ManageVault/model/__tests__/manage-vault-model.test.ts',
],
collectCoverageFrom: [
'src/renderer/**/*.{js,ts}',
'!src/renderer/pages/**/*.{js,ts}',
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,15 @@
"@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-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-scroll-area": "1.2.0",
"@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.3",
"@radix-ui/react-tooltip": "1.1.4",
"@react-spring/web": "9.7.5",
"@remote-ui/rpc": "^1.4.4",
"@substrate/connect": "2.1.1",
Expand Down
48 changes: 37 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions src/renderer/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { Paths } from '@/shared/routes';
import { walletModel } from '@/entities/wallet';
import { navigationModel } from '@/features/navigation';
import { CreateWalletProvider } from '@/widgets/CreateWallet';
import { WalletDetailsProvider } from '@/widgets/WalletDetails';
import { ROUTES_CONFIG } from '@/pages/index';

import { initModel } from './modelInit';
Expand Down Expand Up @@ -39,7 +38,6 @@ export const App = () => {
<GraphqlProvider>
{appRoutes}
<CreateWalletProvider />
<WalletDetailsProvider />
</GraphqlProvider>
</StatusModalProvider>
</ConfirmDialogProvider>
Expand Down
10 changes: 6 additions & 4 deletions src/renderer/app/modelInit.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import { kernelModel } from '@/shared/core';
import { basketModel } from '@/entities/basket';
import { governanceModel } from '@/entities/governance';
import { multisigsModel } from '@/entities/multisig';
import { networkModel } from '@/entities/network';
import { notificationModel } from '@/entities/notification';
import { proxyModel } from '@/entities/proxy';
import { walletModel } from '@/entities/wallet';
import { multisigsModel } from '@/processes/multisigs';
import { assetsSettingsModel } from '@/features/assets';
import { assetsNavigationFeature } from '@/features/assets-navigation';
import { basketNavigationFeature } from '@/features/basket-navigation';
import { contactsNavigationFeature } from '@/features/contacts-navigation';
import { fellowshipNavigationFeature } from '@/features/fellowship-navigation';
import { flexibleMultisigNavigationFeature } from '@/features/flexible-multisig-navigation';
import { governanceNavigationFeature } from '@/features/governance-navigation';
import { notificationsNavigationFeature } from '@/features/notifications-navigation';
import { operationsNavigationFeature } from '@/features/operations-navigation';
import { proxiesModel } from '@/features/proxies';
import { settingsNavigationFeature } from '@/features/settings-navigation';
import { stakingNavigationFeature } from '@/features/staking-navigation';
import { walletsSelectFeature } from '@/features/wallets-select';
import { walletSelectFeature } from '@/features/wallet-select';

export const initModel = () => {
assetsNavigationFeature.start();
Expand All @@ -29,8 +30,9 @@ export const initModel = () => {
notificationsNavigationFeature.start();
settingsNavigationFeature.start();
basketNavigationFeature.start();
flexibleMultisigNavigationFeature.start();

walletsSelectFeature.start();
walletSelectFeature.feature.start();

kernelModel.events.appStarted();
governanceModel.events.governanceStarted();
Expand All @@ -41,5 +43,5 @@ export const initModel = () => {
assetsSettingsModel.events.assetsStarted();
notificationModel.events.notificationsStarted();
basketModel.events.basketStarted();
multisigsModel.events.multisigsDiscoveryStarted();
multisigsModel.events.subscribe();
};
12 changes: 6 additions & 6 deletions src/renderer/domains/collectives/model/members/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ const {
} = createDataSubscription<CollectivesStruct<(Member | CoreMember)[]>, RequestParams, (Member | CoreMember)[]>({
initial: {},
fn: ({ api, palletType }, callback) => {
let currentAbortController = new AbortController();
let abortController = new AbortController();

const fn = async () => {
currentAbortController.abort();
currentAbortController = new AbortController();
abortController.abort();
abortController = new AbortController();

const collectiveMembers = await collectivePallet.storage.members(palletType, api);
if (currentAbortController.signal.aborted) return;
if (abortController.signal.aborted) return;

const coreMembers = await collectiveCorePallet.storage.member(palletType, api);
if (currentAbortController.signal.aborted) return;
if (abortController.signal.aborted) return;

const result: Member[] = [];

Expand Down Expand Up @@ -71,7 +71,7 @@ const {

// TODO check if section name is correct
return polkadotjsHelpers.subscribeSystemEvents({ api, section: `${palletType}Core` }, fn).then(fn => () => {
currentAbortController.abort();
abortController.abort();
fn();
});
},
Expand Down
12 changes: 6 additions & 6 deletions src/renderer/domains/collectives/model/referendum/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ const { pending, subscribe, unsubscribe, received, fulfilled } = createDataSubsc
>({
initial: $list,
fn: ({ api, palletType }, callback) => {
let currectAbortController = new AbortController();
let abortController = new AbortController();

const fetchPages = createPagesHandler({
fn: () => referendaPallet.storage.referendumInfoForPaged(palletType, api, 200),
map: mapReferendums,
});

fetchPages(currectAbortController, callback);
fetchPages(abortController, callback);

const fn = () => {
currectAbortController.abort();
currectAbortController = new AbortController();
fetchPages(currectAbortController, callback);
abortController.abort();
abortController = new AbortController();
fetchPages(abortController, callback);
};

/**
Expand All @@ -47,7 +47,7 @@ const { pending, subscribe, unsubscribe, received, fulfilled } = createDataSubsc
* @see https://github.com/paritytech/polkadot-sdk/blob/43cd6fd4370d3043272f64a79aeb9e6dc0edd13f/substrate/frame/collective/src/lib.rs#L459
*/
return polkadotjsHelpers.subscribeSystemEvents({ api, section: `${palletType}Referenda` }, fn).then(fn => () => {
currectAbortController.abort();
abortController.abort();
fn();
});
},
Expand Down
7 changes: 7 additions & 0 deletions src/renderer/domains/multisig/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { multisigsDomainModel } from './model/multisigs/model';

export const multisigDomain = {
multisigs: multisigsDomainModel,
};

export type { Multisig } from './model/multisigs/types';
6 changes: 6 additions & 0 deletions src/renderer/domains/multisig/model/multisigs/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const MultisigEventFieldIndex = {
ACCOUNT_ID: 0,
TIMEPOINT: 1,
MULTISIG: 2,
CALL_HASH: 3,
};
Loading

0 comments on commit aec2ef2

Please sign in to comment.