Skip to content

Commit

Permalink
BREAKING: Move SnapError to SDK (#1949)
Browse files Browse the repository at this point in the history
This moves `SnapError` and some used utility functions to `snaps-sdk`.

## Breaking changes

- `SnapError` was moved from `snaps-utils` to `snaps-sdk`.
  • Loading branch information
Mrtenz authored Nov 10, 2023
1 parent 394c1dd commit d360f8e
Show file tree
Hide file tree
Showing 36 changed files with 778 additions and 604 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": "7z2/4sDVSx8+xUi9dVoD9v/o10rIhzxLfv7G1pfxGFw=",
"shasum": "a6nSBZXDUyWbimLESJxAVZRqTWFy5YXXO/+Si9nhLNY=",
"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": "v9l9sN0gm3hxCFfQWRjV1p+5D05NIrFvjRozzVwFUpM=",
"shasum": "kC7naDIca71EEh+FvGppoEgpkdOCNzgSC2noYtZVgKk=",
"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": "bG5IXFSsasgMlDWgtj3I5iZY2D16sO8nRBCf61lSJK0=",
"shasum": "p1WpZhW7JUQMqqNVoMPpK3kRu0bN2TLBFMU4IU0ayDA=",
"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": "uDuEEIVV6EC+OXaBNvU6+4ZKxUQ3E3dDkS0G58YB9N0=",
"shasum": "WcUEK4cnEAv1J4efCUFaXxK4XvzzSIYf9j8qscNOOQ0=",
"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": "lWhar69WgLA0R5em8DwBvk2Yt8ZDf8SODJ5Dad7uHvw=",
"shasum": "mGKJ1s3TMRHRpWEB274UktA7EBsNRbVfWwnms6BE434=",
"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": "SzHiX2GC8aoBExEgj5G09/89Lu6O54VcSsL3mWD3jjs=",
"shasum": "zP59BnhJYduugozloTON06CZSbzVAE1h3ktZs+qK94s=",
"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": "Zkp4KW44svcE/TeX2RccTLWaj5GYnksM+hp1KYP3sUQ=",
"shasum": "uRjhwtFYVPOgRw1VrLKnUlymmVCA0E37WCldywWvRds=",
"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": "A2ry7NMMa+c8vSduxDSDzcKXk8qBIU7JChnrnyy7/nk=",
"shasum": "nA7PTqhnqnS5xJ+V9Pkql2BN4t2wMb3q38esxkTuOus=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
3 changes: 1 addition & 2 deletions packages/snaps-controllers/src/snaps/SnapController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import type {
RequestSnapsResult,
SnapId,
} from '@metamask/snaps-sdk';
import { AuxiliaryFileEncoding } from '@metamask/snaps-sdk';
import { AuxiliaryFileEncoding, getErrorMessage } from '@metamask/snaps-sdk';
import { assertUILinksAreSafe } from '@metamask/snaps-ui';
import type {
FetchedSnapFiles,
Expand All @@ -56,7 +56,6 @@ import {
DEFAULT_ENDOWMENTS,
DEFAULT_REQUESTED_SNAP_VERSION,
encodeAuxiliaryFile,
getErrorMessage,
HandlerType,
isOriginAllowed,
logError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,29 @@
"eslint>debug>ms": true
}
},
"external:../snaps-sdk/src/errors.ts": {
"packages": {
"external:../snaps-sdk/src/internals/index.ts": true
}
},
"external:../snaps-sdk/src/index.ts": {
"packages": {
"external:../snaps-sdk/src/errors.ts": true,
"external:../snaps-sdk/src/internals/index.ts": true,
"external:../snaps-sdk/src/types/index.ts": true
}
},
"external:../snaps-sdk/src/internals/errors.ts": {
"packages": {
"@metamask/utils": true
}
},
"external:../snaps-sdk/src/internals/index.ts": {
"packages": {
"external:../snaps-sdk/src/internals/errors.ts": true,
"external:../snaps-sdk/src/internals/helpers.ts": true
}
},
"external:../snaps-sdk/src/types/handlers/index.ts": {
"packages": {
"external:../snaps-sdk/src/types/handlers/cronjob.ts": true,
Expand Down Expand Up @@ -386,7 +404,8 @@
"external:../snaps-utils/src/errors.ts": {
"packages": {
"@metamask/rpc-errors": true,
"@metamask/utils": true
"@metamask/utils": true,
"external:../snaps-sdk/src/index.ts": true
}
},
"external:../snaps-utils/src/handlers.ts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,29 @@
"util": true
}
},
"external:../snaps-sdk/src/errors.ts": {
"packages": {
"external:../snaps-sdk/src/internals/index.ts": true
}
},
"external:../snaps-sdk/src/index.ts": {
"packages": {
"external:../snaps-sdk/src/errors.ts": true,
"external:../snaps-sdk/src/internals/index.ts": true,
"external:../snaps-sdk/src/types/index.ts": true
}
},
"external:../snaps-sdk/src/internals/errors.ts": {
"packages": {
"@metamask/utils": true
}
},
"external:../snaps-sdk/src/internals/index.ts": {
"packages": {
"external:../snaps-sdk/src/internals/errors.ts": true,
"external:../snaps-sdk/src/internals/helpers.ts": true
}
},
"external:../snaps-sdk/src/types/handlers/index.ts": {
"packages": {
"external:../snaps-sdk/src/types/handlers/cronjob.ts": true,
Expand Down Expand Up @@ -450,7 +468,8 @@
"external:../snaps-utils/src/errors.ts": {
"packages": {
"@metamask/rpc-errors": true,
"@metamask/utils": true
"@metamask/utils": true,
"external:../snaps-sdk/src/index.ts": true
}
},
"external:../snaps-utils/src/handlers.ts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,29 @@
"util": true
}
},
"external:../snaps-sdk/src/errors.ts": {
"packages": {
"external:../snaps-sdk/src/internals/index.ts": true
}
},
"external:../snaps-sdk/src/index.ts": {
"packages": {
"external:../snaps-sdk/src/errors.ts": true,
"external:../snaps-sdk/src/internals/index.ts": true,
"external:../snaps-sdk/src/types/index.ts": true
}
},
"external:../snaps-sdk/src/internals/errors.ts": {
"packages": {
"@metamask/utils": true
}
},
"external:../snaps-sdk/src/internals/index.ts": {
"packages": {
"external:../snaps-sdk/src/internals/errors.ts": true,
"external:../snaps-sdk/src/internals/helpers.ts": true
}
},
"external:../snaps-sdk/src/types/handlers/index.ts": {
"packages": {
"external:../snaps-sdk/src/types/handlers/cronjob.ts": true,
Expand Down Expand Up @@ -450,7 +468,8 @@
"external:../snaps-utils/src/errors.ts": {
"packages": {
"@metamask/rpc-errors": true,
"@metamask/utils": true
"@metamask/utils": true,
"external:../snaps-sdk/src/index.ts": true
}
},
"external:../snaps-utils/src/handlers.ts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,29 @@
"eslint>debug>ms": true
}
},
"external:../snaps-sdk/src/errors.ts": {
"packages": {
"external:../snaps-sdk/src/internals/index.ts": true
}
},
"external:../snaps-sdk/src/index.ts": {
"packages": {
"external:../snaps-sdk/src/errors.ts": true,
"external:../snaps-sdk/src/internals/index.ts": true,
"external:../snaps-sdk/src/types/index.ts": true
}
},
"external:../snaps-sdk/src/internals/errors.ts": {
"packages": {
"@metamask/utils": true
}
},
"external:../snaps-sdk/src/internals/index.ts": {
"packages": {
"external:../snaps-sdk/src/internals/errors.ts": true,
"external:../snaps-sdk/src/internals/helpers.ts": true
}
},
"external:../snaps-sdk/src/types/handlers/index.ts": {
"packages": {
"external:../snaps-sdk/src/types/handlers/cronjob.ts": true,
Expand Down Expand Up @@ -220,7 +238,8 @@
"external:../snaps-utils/src/errors.ts": {
"packages": {
"@metamask/rpc-errors": true,
"@metamask/utils": true
"@metamask/utils": true,
"external:../snaps-sdk/src/index.ts": true
}
},
"external:../snaps-utils/src/handlers.ts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,29 @@
"eslint>debug>ms": true
}
},
"external:../snaps-sdk/src/errors.ts": {
"packages": {
"external:../snaps-sdk/src/internals/index.ts": true
}
},
"external:../snaps-sdk/src/index.ts": {
"packages": {
"external:../snaps-sdk/src/errors.ts": true,
"external:../snaps-sdk/src/internals/index.ts": true,
"external:../snaps-sdk/src/types/index.ts": true
}
},
"external:../snaps-sdk/src/internals/errors.ts": {
"packages": {
"@metamask/utils": true
}
},
"external:../snaps-sdk/src/internals/index.ts": {
"packages": {
"external:../snaps-sdk/src/internals/errors.ts": true,
"external:../snaps-sdk/src/internals/helpers.ts": true
}
},
"external:../snaps-sdk/src/types/handlers/index.ts": {
"packages": {
"external:../snaps-sdk/src/types/handlers/cronjob.ts": true,
Expand Down Expand Up @@ -386,7 +404,8 @@
"external:../snaps-utils/src/errors.ts": {
"packages": {
"@metamask/rpc-errors": true,
"@metamask/utils": true
"@metamask/utils": true,
"external:../snaps-sdk/src/index.ts": true
}
},
"external:../snaps-utils/src/handlers.ts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,29 @@
"eslint>debug>ms": true
}
},
"external:../snaps-sdk/src/errors.ts": {
"packages": {
"external:../snaps-sdk/src/internals/index.ts": true
}
},
"external:../snaps-sdk/src/index.ts": {
"packages": {
"external:../snaps-sdk/src/errors.ts": true,
"external:../snaps-sdk/src/internals/index.ts": true,
"external:../snaps-sdk/src/types/index.ts": true
}
},
"external:../snaps-sdk/src/internals/errors.ts": {
"packages": {
"@metamask/utils": true
}
},
"external:../snaps-sdk/src/internals/index.ts": {
"packages": {
"external:../snaps-sdk/src/internals/errors.ts": true,
"external:../snaps-sdk/src/internals/helpers.ts": true
}
},
"external:../snaps-sdk/src/types/handlers/index.ts": {
"packages": {
"external:../snaps-sdk/src/types/handlers/cronjob.ts": true,
Expand Down Expand Up @@ -220,7 +238,8 @@
"external:../snaps-utils/src/errors.ts": {
"packages": {
"@metamask/rpc-errors": true,
"@metamask/utils": true
"@metamask/utils": true,
"external:../snaps-sdk/src/index.ts": true
}
},
"external:../snaps-utils/src/handlers.ts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { StreamProvider } from '@metamask/providers';
import type { RequestArguments } from '@metamask/providers/dist/BaseProvider';
import { errorCodes, rpcErrors, serializeError } from '@metamask/rpc-errors';
import type { SnapsProvider } from '@metamask/snaps-sdk';
import { getErrorData } from '@metamask/snaps-sdk';
import type {
SnapExports,
HandlerType,
Expand All @@ -15,7 +16,6 @@ import {
logError,
SNAP_EXPORTS,
WrappedSnapError,
getErrorData,
unwrapError,
} from '@metamask/snaps-utils';
import type {
Expand Down
1 change: 1 addition & 0 deletions packages/snaps-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"@metamask/eslint-config-jest": "^12.1.0",
"@metamask/eslint-config-nodejs": "^12.1.0",
"@metamask/eslint-config-typescript": "^12.1.0",
"@metamask/rpc-errors": "^6.1.0",
"@swc/cli": "^0.1.62",
"@swc/core": "1.3.78",
"@swc/jest": "^0.2.26",
Expand Down
Loading

0 comments on commit d360f8e

Please sign in to comment.