Socket
Socket
Sign inDemoInstall

@metamask/snaps-sdk

Package Overview
Dependencies
Maintainers
12
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metamask/snaps-sdk - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

dist/cjs/internals/svg.js

12

CHANGELOG.md

@@ -9,2 +9,11 @@ # Changelog

## [2.1.0]
### Changed
- Improve support for Snap errors without a message ([#2176](https://github.com/MetaMask/snaps/pull/2176))
- You can now add data to an error without having to specify a message. For example:
```ts
throw new MethodNotFoundError({ method: 'some method name' });
```
- Strip empty `data` from Snap errors ([#2179](https://github.com/MetaMask/snaps/pull/2179))
## [2.0.0]

@@ -59,3 +68,4 @@ ### Changed

[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@2.0.0...HEAD
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@2.1.0...HEAD
[2.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@2.0.0...@metamask/snaps-sdk@2.1.0
[2.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@1.4.0...@metamask/snaps-sdk@2.0.0

@@ -62,0 +72,0 @@ [1.4.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@1.3.2...@metamask/snaps-sdk@1.4.0

11

dist/cjs/errors.js

@@ -104,3 +104,5 @@ "use strict";

stack: this.stack,
data: this.data
...this.data ? {
data: this.data
} : {}
}

@@ -150,6 +152,9 @@ }

_class_private_field_set(this, _code, (0, _internals.getErrorCode)(error));
_class_private_field_set(this, _data, {
const mergedData = {
...(0, _internals.getErrorData)(error),
...data
});
};
if (Object.keys(mergedData).length > 0) {
_class_private_field_set(this, _data, mergedData);
}
_class_private_field_set(this, _stack, super.stack);

@@ -156,0 +161,0 @@ }

@@ -37,2 +37,8 @@ // Only internals that are used by other Snaps packages should be exported here.

},
parseSvg: function() {
return _internals.parseSvg;
},
isSvg: function() {
return _internals.isSvg;
},
assert: function() {

@@ -39,0 +45,0 @@ return _utils.assert;

@@ -14,3 +14,17 @@ "use strict";

return class SnapJsonRpcError extends _errors.SnapError {
constructor(message, data){
/**
* Create a new `SnapJsonRpcError` from a message and data.
*
* @param message - The message to create the error from.
* @param data - The data to create the error from.
*/ constructor(message, data){
if (typeof message === 'object') {
const error = fn();
super({
code: error.code,
message: error.message,
data: message
});
return;
}
const error = fn(message);

@@ -17,0 +31,0 @@ super({

@@ -9,2 +9,3 @@ "use strict";

_export_star(require("./structs"), exports);
_export_star(require("./svg"), exports);
function _export_star(from, to) {

@@ -11,0 +12,0 @@ Object.keys(from).forEach(function(k) {

@@ -22,14 +22,9 @@ "use strict";

});
const _issvg = /*#__PURE__*/ _interop_require_default(require("is-svg"));
const _superstruct = require("superstruct");
const _internals = require("../../internals");
const _builder = require("../builder");
const _nodes = require("../nodes");
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function svg() {
return (0, _superstruct.refine)((0, _superstruct.string)(), 'SVG', (value)=>{
if (!(0, _issvg.default)(value)) {
if (!(0, _internals.isSvg)(value)) {
return 'Value is not a valid SVG.';

@@ -36,0 +31,0 @@ }

@@ -97,3 +97,5 @@ function _check_private_redeclaration(obj, privateCollection) {

stack: this.stack,
data: this.data
...this.data ? {
data: this.data
} : {}
}

@@ -143,6 +145,9 @@ }

_class_private_field_set(this, _code, getErrorCode(error));
_class_private_field_set(this, _data, {
const mergedData = {
...getErrorData(error),
...data
});
};
if (Object.keys(mergedData).length > 0) {
_class_private_field_set(this, _data, mergedData);
}
_class_private_field_set(this, _stack, super.stack);

@@ -149,0 +154,0 @@ }

// Only internals that are used by other Snaps packages should be exported here.
export { getErrorData, getErrorMessage, getErrorStack, SNAP_ERROR_CODE, SNAP_ERROR_MESSAGE, literal, union, enumValue } from './internals';
export { getErrorData, getErrorMessage, getErrorStack, SNAP_ERROR_CODE, SNAP_ERROR_MESSAGE, literal, union, enumValue, parseSvg, isSvg } from './internals';
export { assert } from '@metamask/utils';

@@ -4,0 +4,0 @@ export * from './errors';

@@ -14,3 +14,17 @@ import { SnapError } from '../errors';

return class SnapJsonRpcError extends SnapError {
constructor(message, data){
/**
* Create a new `SnapJsonRpcError` from a message and data.
*
* @param message - The message to create the error from.
* @param data - The data to create the error from.
*/ constructor(message, data){
if (typeof message === 'object') {
const error = fn();
super({
code: error.code,
message: error.message,
data: message
});
return;
}
const error = fn(message);

@@ -17,0 +31,0 @@ super({

@@ -5,3 +5,4 @@ export * from './error-wrappers';

export * from './structs';
export * from './svg';
//# sourceMappingURL=index.js.map

@@ -1,3 +0,3 @@

import isSvg from 'is-svg';
import { assign, literal, object, refine, string } from 'superstruct';
import { isSvg } from '../../internals';
import { createBuilder } from '../builder';

@@ -4,0 +4,0 @@ import { NodeStruct, NodeType } from '../nodes';

@@ -11,6 +11,6 @@ /// <reference types="node" />

export declare const InternalError: {
new (message?: string | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
new (message?: string | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data": Record<string, import("@metamask/utils").Json>;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;

@@ -20,3 +20,3 @@ readonly name: string;

readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json>;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;

@@ -26,2 +26,28 @@ toJSON(): import("./errors").SerializedSnapError;

};
new (data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
new (message?: string | Record<string, import("@metamask/utils").Json> | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;

@@ -40,6 +66,6 @@ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;

export declare const InvalidInputError: {
new (message?: string | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
new (message?: string | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data": Record<string, import("@metamask/utils").Json>;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;

@@ -49,3 +75,3 @@ readonly name: string;

readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json>;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;

@@ -55,2 +81,28 @@ toJSON(): import("./errors").SerializedSnapError;

};
new (data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
new (message?: string | Record<string, import("@metamask/utils").Json> | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;

@@ -69,6 +121,6 @@ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;

export declare const InvalidParamsError: {
new (message?: string | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
new (message?: string | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data": Record<string, import("@metamask/utils").Json>;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;

@@ -78,3 +130,3 @@ readonly name: string;

readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json>;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;

@@ -84,2 +136,28 @@ toJSON(): import("./errors").SerializedSnapError;

};
new (data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
new (message?: string | Record<string, import("@metamask/utils").Json> | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;

@@ -98,6 +176,6 @@ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;

export declare const InvalidRequestError: {
new (message?: string | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
new (message?: string | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data": Record<string, import("@metamask/utils").Json>;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;

@@ -107,3 +185,3 @@ readonly name: string;

readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json>;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;

@@ -113,2 +191,28 @@ toJSON(): import("./errors").SerializedSnapError;

};
new (data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
new (message?: string | Record<string, import("@metamask/utils").Json> | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;

@@ -127,6 +231,6 @@ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;

export declare const LimitExceededError: {
new (message?: string | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
new (message?: string | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data": Record<string, import("@metamask/utils").Json>;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;

@@ -136,3 +240,3 @@ readonly name: string;

readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json>;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;

@@ -142,2 +246,28 @@ toJSON(): import("./errors").SerializedSnapError;

};
new (data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
new (message?: string | Record<string, import("@metamask/utils").Json> | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;

@@ -156,6 +286,6 @@ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;

export declare const MethodNotFoundError: {
new (message?: string | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
new (message?: string | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data": Record<string, import("@metamask/utils").Json>;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;

@@ -165,3 +295,3 @@ readonly name: string;

readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json>;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;

@@ -171,2 +301,28 @@ toJSON(): import("./errors").SerializedSnapError;

};
new (data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
new (message?: string | Record<string, import("@metamask/utils").Json> | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;

@@ -183,6 +339,6 @@ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;

export declare const MethodNotSupportedError: {
new (message?: string | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
new (message?: string | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data": Record<string, import("@metamask/utils").Json>;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;

@@ -192,3 +348,3 @@ readonly name: string;

readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json>;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;

@@ -198,2 +354,28 @@ toJSON(): import("./errors").SerializedSnapError;

};
new (data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
new (message?: string | Record<string, import("@metamask/utils").Json> | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;

@@ -212,6 +394,6 @@ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;

export declare const ParseError: {
new (message?: string | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
new (message?: string | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data": Record<string, import("@metamask/utils").Json>;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;

@@ -221,3 +403,3 @@ readonly name: string;

readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json>;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;

@@ -227,2 +409,28 @@ toJSON(): import("./errors").SerializedSnapError;

};
new (data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
new (message?: string | Record<string, import("@metamask/utils").Json> | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;

@@ -241,6 +449,6 @@ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;

export declare const ResourceNotFoundError: {
new (message?: string | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
new (message?: string | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data": Record<string, import("@metamask/utils").Json>;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;

@@ -250,3 +458,3 @@ readonly name: string;

readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json>;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;

@@ -256,2 +464,28 @@ toJSON(): import("./errors").SerializedSnapError;

};
new (data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
new (message?: string | Record<string, import("@metamask/utils").Json> | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;

@@ -270,6 +504,6 @@ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;

export declare const ResourceUnavailableError: {
new (message?: string | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
new (message?: string | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data": Record<string, import("@metamask/utils").Json>;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;

@@ -279,3 +513,3 @@ readonly name: string;

readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json>;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;

@@ -285,2 +519,28 @@ toJSON(): import("./errors").SerializedSnapError;

};
new (data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
new (message?: string | Record<string, import("@metamask/utils").Json> | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;

@@ -299,6 +559,6 @@ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;

export declare const TransactionRejected: {
new (message?: string | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
new (message?: string | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data": Record<string, import("@metamask/utils").Json>;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;

@@ -308,3 +568,3 @@ readonly name: string;

readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json>;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;

@@ -314,2 +574,28 @@ toJSON(): import("./errors").SerializedSnapError;

};
new (data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
new (message?: string | Record<string, import("@metamask/utils").Json> | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;

@@ -328,6 +614,6 @@ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;

export declare const ChainDisconnectedError: {
new (message?: string | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
new (message?: string | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data": Record<string, import("@metamask/utils").Json>;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;

@@ -337,3 +623,3 @@ readonly name: string;

readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json>;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;

@@ -343,2 +629,28 @@ toJSON(): import("./errors").SerializedSnapError;

};
new (data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
new (message?: string | Record<string, import("@metamask/utils").Json> | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;

@@ -357,6 +669,6 @@ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;

export declare const DisconnectedError: {
new (message?: string | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
new (message?: string | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data": Record<string, import("@metamask/utils").Json>;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;

@@ -366,3 +678,3 @@ readonly name: string;

readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json>;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;

@@ -372,2 +684,28 @@ toJSON(): import("./errors").SerializedSnapError;

};
new (data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
new (message?: string | Record<string, import("@metamask/utils").Json> | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;

@@ -384,6 +722,6 @@ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;

export declare const UnauthorizedError: {
new (message?: string | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
new (message?: string | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data": Record<string, import("@metamask/utils").Json>;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;

@@ -393,3 +731,3 @@ readonly name: string;

readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json>;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;

@@ -399,2 +737,28 @@ toJSON(): import("./errors").SerializedSnapError;

};
new (data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
new (message?: string | Record<string, import("@metamask/utils").Json> | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;

@@ -413,6 +777,6 @@ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;

export declare const UnsupportedMethodError: {
new (message?: string | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
new (message?: string | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data": Record<string, import("@metamask/utils").Json>;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;

@@ -422,3 +786,3 @@ readonly name: string;

readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json>;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;

@@ -428,2 +792,28 @@ toJSON(): import("./errors").SerializedSnapError;

};
new (data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
new (message?: string | Record<string, import("@metamask/utils").Json> | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;

@@ -442,6 +832,6 @@ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;

export declare const UserRejectedRequestError: {
new (message?: string | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
new (message?: string | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data": Record<string, import("@metamask/utils").Json>;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;

@@ -451,3 +841,3 @@ readonly name: string;

readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json>;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;

@@ -457,2 +847,28 @@ toJSON(): import("./errors").SerializedSnapError;

};
new (data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
new (message?: string | Record<string, import("@metamask/utils").Json> | undefined, data?: Record<string, import("@metamask/utils").Json> | undefined): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, import("@metamask/utils").Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, import("@metamask/utils").Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("./errors").SerializedSnapError;
serialize(): import("./errors").SerializedSnapError;
};
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;

@@ -459,0 +875,0 @@ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;

@@ -45,3 +45,3 @@ import type { Json, JsonRpcError } from '@metamask/utils';

*/
get data(): Record<string, Json>;
get data(): Record<string, Json> | undefined;
/**

@@ -85,6 +85,4 @@ * The error stack.

data: {
cause: JsonRpcError & {
data: Record<string, Json>;
};
cause: JsonRpcError;
};
};
export type { EnumToUnion } from './internals';
export { getErrorData, getErrorMessage, getErrorStack, SNAP_ERROR_CODE, SNAP_ERROR_MESSAGE, literal, union, enumValue, } from './internals';
export { getErrorData, getErrorMessage, getErrorStack, SNAP_ERROR_CODE, SNAP_ERROR_MESSAGE, literal, union, enumValue, parseSvg, isSvg, } from './internals';
export type { Json, JsonRpcError, JsonRpcRequest, JsonRpcParams, } from '@metamask/utils';

@@ -4,0 +4,0 @@ export { assert } from '@metamask/utils';

@@ -17,6 +17,6 @@ /// <reference types="node" />

export declare function createSnapError(fn: JsonRpcErrorFunction): {
new (message?: string, data?: Record<string, Json>): {
new (message?: string): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data": Record<string, Json>;
readonly "__#3@#data"?: Record<string, Json> | undefined;
readonly "__#3@#stack"?: string | undefined;

@@ -26,3 +26,3 @@ readonly name: string;

readonly message: string;
readonly data: Record<string, Json>;
readonly data: Record<string, Json> | undefined;
readonly stack: string | undefined;

@@ -32,2 +32,28 @@ toJSON(): import("../errors").SerializedSnapError;

};
new (data?: Record<string, Json>): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("../errors").SerializedSnapError;
serialize(): import("../errors").SerializedSnapError;
};
new (message?: string | Record<string, Json>, data?: Record<string, Json>): {
readonly "__#3@#code": number;
readonly "__#3@#message": string;
readonly "__#3@#data"?: Record<string, Json> | undefined;
readonly "__#3@#stack"?: string | undefined;
readonly name: string;
readonly code: number;
readonly message: string;
readonly data: Record<string, Json> | undefined;
readonly stack: string | undefined;
toJSON(): import("../errors").SerializedSnapError;
serialize(): import("../errors").SerializedSnapError;
};
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;

@@ -34,0 +60,0 @@ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;

@@ -5,1 +5,2 @@ export * from './error-wrappers';

export * from './structs';
export * from './svg';
{
"name": "@metamask/snaps-sdk",
"version": "2.0.0",
"version": "2.1.0",
"repository": {

@@ -42,7 +42,7 @@ "type": "git",

"@metamask/utils": "^8.3.0",
"is-svg": "^4.4.0",
"fast-xml-parser": "^4.3.4",
"superstruct": "^1.0.3"
},
"devDependencies": {
"@lavamoat/allow-scripts": "^3.0.0",
"@lavamoat/allow-scripts": "^3.0.2",
"@metamask/auto-changelog": "^3.4.4",

@@ -49,0 +49,0 @@ "@metamask/eslint-config": "^12.1.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc