Skip to content

Commit

Permalink
Remove separate internals export from SDK (#1950)
Browse files Browse the repository at this point in the history
The `/internals` export is causing issues with Browserify. The easiest
solution for now is to remove it, until we switch to the Webpack
LavaMoat bundler.
  • Loading branch information
Mrtenz authored Nov 10, 2023
1 parent 1edfa52 commit 394c1dd
Show file tree
Hide file tree
Showing 19 changed files with 23 additions and 36 deletions.
2 changes: 1 addition & 1 deletion packages/examples/packages/bip32/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "vFlTu8q42PboHqLABN36nBmcx+DnUwDRRCxFwlJ16Ck=",
"shasum": "7z2/4sDVSx8+xUi9dVoD9v/o10rIhzxLfv7G1pfxGFw=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/bip44/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "Oiv12trzteVv2P04KfUkW3moGNz6nx8PrPK0oENq0bc=",
"shasum": "v9l9sN0gm3hxCFfQWRjV1p+5D05NIrFvjRozzVwFUpM=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/dialogs/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "hS/TvMPnSKpfGoXEkPPtM+zMptv2gRX7lTlsSDOZb8c=",
"shasum": "bG5IXFSsasgMlDWgtj3I5iZY2D16sO8nRBCf61lSJK0=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/get-entropy/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "quVJens+ULBSoasW4pUoM4YP5N8p+SpyDffOMc6Q11Y=",
"shasum": "uDuEEIVV6EC+OXaBNvU6+4ZKxUQ3E3dDkS0G58YB9N0=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "pHFf1bazmVzdooZXDfXOhpWCos54j6T+TdXoDlm1V7o=",
"shasum": "lWhar69WgLA0R5em8DwBvk2Yt8ZDf8SODJ5Dad7uHvw=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/manage-state/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "QABCZPnE2qG6CVjidksOyFwbKB9u+SwQ9n3e6OzFE9c=",
"shasum": "SzHiX2GC8aoBExEgj5G09/89Lu6O54VcSsL3mWD3jjs=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "3tURebEzqLrC80sRrUy/sXLBumaWAI6qJHxrk71VX2c=",
"shasum": "Zkp4KW44svcE/TeX2RccTLWaj5GYnksM+hp1KYP3sUQ=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "8EUnyGuJxtysKLHL5AohBTxI73cqlGep66dEkPL3Q7Y=",
"shasum": "A2ry7NMMa+c8vSduxDSDzcKXk8qBIU7JChnrnyy7/nk=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
3 changes: 1 addition & 2 deletions packages/snaps-jest/src/internals/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { NotificationType } from '@metamask/snaps-sdk';
import type { EnumToUnion } from '@metamask/snaps-sdk/internals';
import type { NotificationType, EnumToUnion } from '@metamask/snaps-sdk';
import type { ApplicationState, Dispatch } from '@metamask/snaps-simulator';

declare global {
Expand Down
3 changes: 1 addition & 2 deletions packages/snaps-jest/src/matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

import type { MatcherFunction } from '@jest/expect';
import { expect } from '@jest/globals';
import type { NotificationType } from '@metamask/snaps-sdk';
import type { EnumToUnion } from '@metamask/snaps-sdk/internals';
import type { NotificationType, EnumToUnion } from '@metamask/snaps-sdk';
import type { Component } from '@metamask/snaps-ui';
import type { Json } from '@metamask/utils';
import { hasProperty } from '@metamask/utils';
Expand Down
3 changes: 1 addition & 2 deletions packages/snaps-jest/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { NotificationType } from '@metamask/snaps-sdk';
import type { EnumToUnion } from '@metamask/snaps-sdk/internals';
import type { NotificationType, EnumToUnion } from '@metamask/snaps-sdk';
import type { Component } from '@metamask/snaps-ui';
import type { JsonRpcId, JsonRpcParams } from '@metamask/utils';
import type { Infer } from 'superstruct';
Expand Down
3 changes: 1 addition & 2 deletions packages/snaps-rpc-methods/src/restricted/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import type {
} from '@metamask/permission-controller';
import { PermissionType, SubjectType } from '@metamask/permission-controller';
import { rpcErrors } from '@metamask/rpc-errors';
import type { DialogParams } from '@metamask/snaps-sdk';
import { DialogType } from '@metamask/snaps-sdk';
import type { EnumToUnion } from '@metamask/snaps-sdk/internals';
import type { DialogParams, EnumToUnion } from '@metamask/snaps-sdk';
import type { Component } from '@metamask/snaps-ui';
import { ComponentStruct, assertUILinksAreSafe } from '@metamask/snaps-ui';
import type { InferMatching } from '@metamask/snaps-utils';
Expand Down
7 changes: 5 additions & 2 deletions packages/snaps-rpc-methods/src/restricted/notify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import type {
} from '@metamask/permission-controller';
import { PermissionType, SubjectType } from '@metamask/permission-controller';
import { rpcErrors } from '@metamask/rpc-errors';
import type { NotifyParams, NotifyResult } from '@metamask/snaps-sdk';
import { NotificationType } from '@metamask/snaps-sdk';
import type { EnumToUnion } from '@metamask/snaps-sdk/internals';
import type {
NotifyParams,
NotifyResult,
EnumToUnion,
} from '@metamask/snaps-sdk';
import { assertLinksAreSafe } from '@metamask/snaps-ui';
import type { NonEmptyArray } from '@metamask/utils';
import { isObject } from '@metamask/utils';
Expand Down
13 changes: 0 additions & 13 deletions packages/snaps-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,6 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"sideEffects": false,
"exports": {
".": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js",
"types": "./dist/types/index.d.ts"
},
"./internals": {
"import": "./dist/esm/internals/index.js",
"require": "./dist/cjs/internals/index.js",
"types": "./dist/types/internals/index.d.ts"
},
"./package.json": "./package.json"
},
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
Expand Down
3 changes: 3 additions & 0 deletions packages/snaps-sdk/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
// Only internals that are used by other Snaps packages should be exported here.
export type { EnumToUnion } from './internals';

export * from './types';
2 changes: 2 additions & 0 deletions packages/snaps-sdk/src/internals/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import type { JsonRpcParams, JsonRpcRequest } from '@metamask/utils';
*
* const foo: FooValue = Foo.Bar; // Works
* const foo: FooValue = 'bar'; // Also works
* @internal
*/
export type EnumToUnion<Type extends string> = `${Type}`;

Expand All @@ -27,6 +28,7 @@ export type EnumToUnion<Type extends string> = `${Type}`;
* @example
* // MyMethod is { method: 'my_method', params: { foo: string } }
* type MyMethod = Method<'my_method', { foo: string }>;
* @internal
*/
export type Method<
MethodName extends string,
Expand Down
3 changes: 0 additions & 3 deletions packages/snaps-sdk/src/internals/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
// Internals that are used by the SDK but not exposed to the user. These can be
// imported from other packages using `@metamask/snaps-sdk/internals`.

export * from './helpers';
2 changes: 1 addition & 1 deletion packages/snaps-utils/src/enum.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { EnumToUnion } from '@metamask/snaps-sdk/internals';
import type { EnumToUnion } from '@metamask/snaps-sdk';
import type { Struct } from 'superstruct';

import { literal } from './structs';
Expand Down
1 change: 0 additions & 1 deletion tsconfig.packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"module": "CommonJS",
"moduleResolution": "node",
"paths": {
"@metamask/*/internals": ["../*/src/internals"],
"@metamask/*/test-utils": ["../*/src/test-utils"],
"@metamask/*": ["../*/src"]
},
Expand Down

0 comments on commit 394c1dd

Please sign in to comment.