Skip to content

Commit

Permalink
rename filter helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
jiexi committed Dec 17, 2024
1 parent ff57ba3 commit dc0283e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/multichain/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('@metamask/multichain', () => {
"KnownWalletNamespaceRpcMethods",
"KnownNotifications",
"KnownWalletScopeString",
"filterScopeObjectsSupported",
"getSupportedScopeObjects",
"parseScopeString",
"normalizeScope",
"mergeScopeObject",
Expand Down
2 changes: 1 addition & 1 deletion packages/multichain/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export {
KnownNotifications,
KnownWalletScopeString,
} from './scope/constants';
export { filterScopeObjectsSupported } from './scope/filter';
export { getSupportedScopeObjects } from './scope/filter';
export type {
ExternalScopeString,
ExternalScopeObject,
Expand Down
22 changes: 11 additions & 11 deletions packages/multichain/src/scope/filter.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as Assert from './assert';
import {
filterScopesSupported,
getSupportedScopes,
bucketScopesBySupport,
filterScopeObjectsSupported,
getSupportedScopeObjects,
} from './filter';
import * as Supported from './supported';

Expand All @@ -20,11 +20,11 @@ jest.mock('./supported', () => ({
const MockSupported = jest.mocked(Supported);

describe('filter', () => {
describe('filterScopesSupported', () => {
describe('getSupportedScopes', () => {
const isChainIdSupported = jest.fn();

it('checks if each scope is supported', () => {
filterScopesSupported(
getSupportedScopes(
{
'eip155:1': {
methods: ['a'],
Expand Down Expand Up @@ -68,7 +68,7 @@ describe('filter', () => {
});

expect(
filterScopesSupported(
getSupportedScopes(
{
'eip155:1': {
methods: ['a'],
Expand Down Expand Up @@ -175,9 +175,9 @@ describe('filter', () => {
});
});

describe('filterScopeObjectsSupported', () => {
describe('getSupportedScopeObjects', () => {
it('checks if each scopeObject method is supported', () => {
filterScopeObjectsSupported({
getSupportedScopeObjects({
'eip155:1': {
methods: ['method1', 'method2'],
notifications: [],
Expand Down Expand Up @@ -222,7 +222,7 @@ describe('filter', () => {
},
);

const result = filterScopeObjectsSupported({
const result = getSupportedScopeObjects({
'eip155:1': {
methods: ['method1', 'method2'],
notifications: [],
Expand Down Expand Up @@ -250,7 +250,7 @@ describe('filter', () => {
});

it('checks if each scopeObject notification is supported', () => {
filterScopeObjectsSupported({
getSupportedScopeObjects({
'eip155:1': {
methods: [],
notifications: ['notification1', 'notification2'],
Expand Down Expand Up @@ -295,7 +295,7 @@ describe('filter', () => {
},
);

const result = filterScopeObjectsSupported({
const result = getSupportedScopeObjects({
'eip155:1': {
methods: [],
notifications: ['notification1', 'notification2'],
Expand Down Expand Up @@ -323,7 +323,7 @@ describe('filter', () => {
});

it('does not modify accounts', () => {
const result = filterScopeObjectsSupported({
const result = getSupportedScopeObjects({
'eip155:1': {
methods: [],
notifications: [],
Expand Down
8 changes: 4 additions & 4 deletions packages/multichain/src/scope/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const bucketScopesBySupport = (
* @param hooks.isChainIdSupported - A helper that returns true if an eth chainId is currently supported by the wallet.
* @returns a NormalizedScopesObject with only scopes that are currently supported.
*/
export const filterScopesSupported = (
export const getSupportedScopes = (
scopes: NormalizedScopesObject,
{
isChainIdSupported,
Expand All @@ -73,7 +73,7 @@ export const filterScopesSupported = (
* @param scopeObject - The NormalizedScopeObject to filter.
* @returns a NormalizedScopeObject with only methods and notifications that are currently supported.
*/
const filterScopeObjectSupported = (
const getSupportedScopeObject = (
scopeString: InternalScopeString,
scopeObject: NormalizedScopeObject,
) => {
Expand All @@ -100,12 +100,12 @@ const filterScopeObjectSupported = (
* @param scopes - The NormalizedScopesObject to filter.
* @returns a NormalizedScopesObject with only methods, and notifications that are currently supported.
*/
export const filterScopeObjectsSupported = (scopes: NormalizedScopesObject) => {
export const getSupportedScopeObjects = (scopes: NormalizedScopesObject) => {
const filteredScopesObject: NormalizedScopesObject = {};

for (const [scopeString, scopeObject] of Object.entries(scopes)) {
assertIsInternalScopeString(scopeString);
filteredScopesObject[scopeString] = filterScopeObjectSupported(
filteredScopesObject[scopeString] = getSupportedScopeObject(
scopeString,
scopeObject,
);
Expand Down

0 comments on commit dc0283e

Please sign in to comment.