Skip to content

Commit

Permalink
feat: proxied name in notification
Browse files Browse the repository at this point in the history
  • Loading branch information
tuul-wq committed Jan 12, 2024
1 parent 95851a1 commit 2192a0d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/renderer/entities/wallet/model/wallet-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const multishardCreatedFx = createEffect(
// TODO: Move wallet creation to it's own feature
const proxiedWalletsCreatedFx = createEffect(
(proxiedWallets: CreateParams<ProxiedAccount>[]): Promise<(CreateResult | undefined)[]> => {
return Promise.all(proxiedWallets.map((p) => walletCreatedFx(p)));
return Promise.all(proxiedWallets.map(walletCreatedFx));
},
);

Expand Down
22 changes: 11 additions & 11 deletions src/renderer/features/proxies/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NotificationType, Chain } from '@shared/core';
import type { ProxyAccount, Account, ProxyAction, NoID, Wallet } from '@shared/core';
import type { Account, ProxyAction, NoID, Wallet } from '@shared/core';
import { NotificationType, Chain, type PartialProxiedAccount } from '@shared/core';
import { dictionary } from '@shared/lib/utils';
import { proxyUtils } from '@entities/proxy';

Expand All @@ -13,23 +13,23 @@ function isRegularProxy(chain: Chain): boolean {
}

function getNotification(
proxies: ProxyAccount[],
proxiedAccounts: PartialProxiedAccount[],
wallets: Wallet[],
accounts: Account[],
type: NotificationType,
): NoID<ProxyAction>[] {
const walletsMap = dictionary(wallets, 'id', ({ name, type }) => ({ name, type }));
const accountsWalletsMap = dictionary(accounts, 'accountId', (account) => walletsMap[account.walletId]);

return proxies.map((proxy) => ({
chainId: proxy.chainId,
return proxiedAccounts.map((proxied) => ({
chainId: proxied.chainId,
dateCreated: Date.now(),
proxyType: proxy.proxyType,
proxyAccountId: proxy.accountId,
proxyWalletName: accountsWalletsMap[proxy.accountId].name,
proxyWalletType: accountsWalletsMap[proxy.accountId].type,
proxiedAccountId: proxy.proxiedAccountId,
proxiedWalletName: proxyUtils.getProxiedName(proxy.accountId, proxy.proxyType),
proxyType: proxied.proxyType,
proxyAccountId: proxied.proxyAccountId,
proxyWalletName: accountsWalletsMap[proxied.proxyAccountId].name,
proxyWalletType: accountsWalletsMap[proxied.proxyAccountId].type,
proxiedAccountId: proxied.accountId,
proxiedWalletName: proxyUtils.getProxiedName(proxied.accountId, proxied.proxyType),
read: false,
type,
}));
Expand Down
12 changes: 6 additions & 6 deletions src/renderer/features/proxies/model/proxies-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ sample({
wallets: walletModel.$wallets,
accounts: walletModel.$accounts,
},
filter: (_, proxies) => proxies.proxiesToAdd.length > 0,
fn: ({ wallets, accounts }, proxies) => {
return proxiesUtils.getNotification(proxies.proxiesToAdd, wallets, accounts, NotificationType.PROXY_CREATED);
filter: (_, data) => data.proxiedAccountsToAdd.length > 0,
fn: ({ wallets, accounts }, data) => {
return proxiesUtils.getNotification(data.proxiedAccountsToAdd, wallets, accounts, NotificationType.PROXY_CREATED);
},
target: notificationModel.events.notificationsAdded,
});
Expand All @@ -180,9 +180,9 @@ sample({
wallets: walletModel.$wallets,
accounts: walletModel.$accounts,
},
filter: (_, proxies) => proxies.proxiesToRemove.length > 0,
fn: ({ wallets, accounts }, proxies) => {
return proxiesUtils.getNotification(proxies.proxiesToRemove, wallets, accounts, NotificationType.PROXY_REMOVED);
filter: (_, data) => data.proxiedAccountsToRemove.length > 0,
fn: ({ wallets, accounts }, data) => {
return proxiesUtils.getNotification(data.proxiedAccountsToRemove, wallets, accounts, NotificationType.PROXY_REMOVED);

Check failure on line 185 in src/renderer/features/proxies/model/proxies-model.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `data.proxiedAccountsToRemove,·wallets,·accounts,·NotificationType.PROXY_REMOVED` with `⏎······data.proxiedAccountsToRemove,⏎······wallets,⏎······accounts,⏎······NotificationType.PROXY_REMOVED,⏎····`
},
target: notificationModel.events.notificationsAdded,
});
Expand Down
1 change: 0 additions & 1 deletion src/renderer/features/proxies/workers/proxy-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ async function getProxies(
ep.proxyType === p.proxyType,
),
);
console.log('XXX ', proxiesToAdd, chainId);

return {
proxiesToAdd,
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/shared/core/types/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export type ProxyAction = BaseNotification & {
proxyWalletName: string;
proxyWalletType: WalletType;
proxiedAccountId: AccountId;
proxiedWalletName: AccountId;
proxiedWalletName: string;
};

export type Notification = MultisigInvite | MultisigOperation | ProxyAction;

0 comments on commit 2192a0d

Please sign in to comment.