Skip to content

Commit

Permalink
use utils from @w3ux/utils
Browse files Browse the repository at this point in the history
  • Loading branch information
rossbulat committed Oct 26, 2024
1 parent 7f14e1e commit 292a97f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 21 deletions.
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@w3ux/react-connect-kit": "^1.7.0",
"@w3ux/react-odometer": "^1.1.0",
"@w3ux/react-polkicon": "^1.3.0",
"@w3ux/utils": "^0.9.0",
"@w3ux/utils": "0.9.1",
"@walletconnect/modal": "^2.6.2",
"@walletconnect/universal-provider": "^2.15.2",
"@walletconnect/utils": "^2.15.3",
Expand Down
16 changes: 0 additions & 16 deletions packages/app/src/contexts/ChainSpaceEnv/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,3 @@ export const getApiInstanceOwnerAndIndex = (instanceId: ApiInstanceId) => {
index: Number(last),
};
};

// Check if 2 sets contain the same elements.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const eqSet = (xs: Set<any>, ys: Set<any>) =>
xs.size === ys.size && [...xs].every((x) => ys.has(x));

// Check if one set contains all the elements of another set.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const isSuperset = (set: Set<any>, subset: Set<any>) => {
for (const elem of subset) {
if (!set.has(elem)) {
return false;
}
}
return true;
};
4 changes: 2 additions & 2 deletions packages/app/src/contexts/ChainSpaceEnv/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2024 @polkadot-cloud/polkadot-developer-console authors & contributors
// SPDX-License-Identifier: AGPL-3.0

import { setStateWithRef } from '@w3ux/utils';
import { eqSet, setStateWithRef } from '@w3ux/utils';
import { isCustomEvent } from 'Utils';
import { SubscriptionsController } from 'controllers/Subscriptions';
import { AccountBalances } from 'model/AccountBalances';
Expand Down Expand Up @@ -36,7 +36,7 @@ import { PalletScraper } from 'model/Scraper/Pallet';
import { xxhashAsHex } from '@w3ux/utils/util-crypto';
import { u16 } from 'scale-ts';
import type { AnyJson } from '@w3ux/types';
import { eqSet, getApiInstanceOwnerAndIndex } from './Utils';
import { getApiInstanceOwnerAndIndex } from './Utils';
import { useTxMeta } from 'contexts/TxMeta';

export const ChainSpaceEnv = createContext<ChainSpaceEnvContextInterface>(
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/contexts/WalletConnect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import type { AnyFunction, AnyJson } from '@w3ux/types';
import { useChainSpaceEnv } from 'contexts/ChainSpaceEnv';
import { getSdkError } from '@walletconnect/utils';
import { useTabs } from 'contexts/Tabs';
import { isSuperset } from 'contexts/ChainSpaceEnv/Utils';
import { getUnixTime } from 'date-fns';
import { isSuperset } from '@w3ux/utils';

export const WalletConnectContext =
createContext<WalletConnectContextInterface>(defaults.defaultWalletConnect);
Expand Down
13 changes: 12 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2068,7 +2068,7 @@ __metadata:
"@w3ux/react-connect-kit": "npm:^1.7.0"
"@w3ux/react-odometer": "npm:^1.1.0"
"@w3ux/react-polkicon": "npm:^1.3.0"
"@w3ux/utils": "npm:^0.9.0"
"@w3ux/utils": "npm:0.9.1"
"@walletconnect/modal": "npm:^2.6.2"
"@walletconnect/universal-provider": "npm:^2.15.2"
"@walletconnect/utils": "npm:^2.15.3"
Expand Down Expand Up @@ -4005,6 +4005,17 @@ __metadata:
languageName: node
linkType: hard

"@w3ux/utils@npm:0.9.1":
version: 0.9.1
resolution: "@w3ux/utils@npm:0.9.1"
dependencies:
"@polkadot/util": "npm:^13.1.1"
"@polkadot/util-crypto": "npm:^13.1.1"
bignumber.js: "npm:^9.1.1"
checksum: 10c0/624ca3fd80cd5a0ed16b28342b41d643cc1aac7dbe68e00f3c4a9e460da21ac28d09e86582aad7c642e5907069c4544705c3bc638d836625916694e21774861c
languageName: node
linkType: hard

"@w3ux/utils@npm:^0.9.0":
version: 0.9.0
resolution: "@w3ux/utils@npm:0.9.0"
Expand Down

0 comments on commit 292a97f

Please sign in to comment.