@metamask/snaps-sdk 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -1
- package/dist/cjs/error-wrappers.js +80 -0
- package/dist/cjs/error-wrappers.js.map +1 -0
- package/dist/cjs/index.js +9 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/internals/error-wrappers.js +25 -0
- package/dist/cjs/internals/error-wrappers.js.map +1 -0
- package/dist/cjs/internals/index.js +2 -0
- package/dist/cjs/internals/index.js.map +1 -1
- package/dist/cjs/internals/structs.js +43 -0
- package/dist/cjs/internals/structs.js.map +1 -0
- package/dist/cjs/ui/components/address.js +30 -0
- package/dist/cjs/ui/components/address.js.map +1 -0
- package/dist/cjs/ui/components/index.js +2 -0
- package/dist/cjs/ui/components/index.js.map +1 -1
- package/dist/cjs/ui/components/panel.js +5 -1
- package/dist/cjs/ui/components/panel.js.map +1 -1
- package/dist/cjs/ui/components/row.js +57 -0
- package/dist/cjs/ui/components/row.js.map +1 -0
- package/dist/cjs/ui/nodes.js +2 -0
- package/dist/cjs/ui/nodes.js.map +1 -1
- package/dist/esm/error-wrappers.js +128 -0
- package/dist/esm/error-wrappers.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/internals/error-wrappers.js +25 -0
- package/dist/esm/internals/error-wrappers.js.map +1 -0
- package/dist/esm/internals/index.js +2 -0
- package/dist/esm/internals/index.js.map +1 -1
- package/dist/esm/internals/structs.js +59 -0
- package/dist/esm/internals/structs.js.map +1 -0
- package/dist/esm/ui/components/address.js +22 -0
- package/dist/esm/ui/components/address.js.map +1 -0
- package/dist/esm/ui/components/index.js +2 -0
- package/dist/esm/ui/components/index.js.map +1 -1
- package/dist/esm/ui/components/panel.js +5 -1
- package/dist/esm/ui/components/panel.js.map +1 -1
- package/dist/esm/ui/components/row.js +50 -0
- package/dist/esm/ui/components/row.js.map +1 -0
- package/dist/esm/ui/nodes.js +2 -0
- package/dist/esm/ui/nodes.js.map +1 -1
- package/dist/types/error-wrappers.d.ts +413 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/internals/error-wrappers.d.ts +33 -0
- package/dist/types/internals/index.d.ts +2 -0
- package/dist/types/internals/structs.d.ts +50 -0
- package/dist/types/ui/components/address.d.ts +34 -0
- package/dist/types/ui/components/index.d.ts +2 -0
- package/dist/types/ui/components/panel.d.ts +90 -0
- package/dist/types/ui/components/row.d.ts +104 -0
- package/dist/types/ui/nodes.d.ts +3 -1
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -6,9 +6,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [1.2.0]
|
|
10
|
+
### Added
|
|
11
|
+
- Add `row` and `address` component ([#1968](https://github.com/MetaMask/snaps/pull/1968))
|
|
12
|
+
- Add `enumValue`, `literal` and `union` from `snaps-utils` ([#1968](https://github.com/MetaMask/snaps/pull/1968))
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
- Bump several MetaMask dependencies ([#1964](https://github.com/MetaMask/snaps/pull/1964))
|
|
16
|
+
|
|
17
|
+
## [1.1.0]
|
|
18
|
+
### Added
|
|
19
|
+
- Add Snap error wrappers of JSON-RPC errors ([#1924](https://github.com/MetaMask/snaps/pull/1924))
|
|
20
|
+
|
|
9
21
|
## [1.0.0]
|
|
10
22
|
### Added
|
|
11
23
|
- Initial release of this package.
|
|
12
24
|
|
|
13
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@1.
|
|
25
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@1.2.0...HEAD
|
|
26
|
+
[1.2.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@1.1.0...@metamask/snaps-sdk@1.2.0
|
|
27
|
+
[1.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@1.0.0...@metamask/snaps-sdk@1.1.0
|
|
14
28
|
[1.0.0]: https://github.com/MetaMask/snaps/releases/tag/@metamask/snaps-sdk@1.0.0
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
InternalError: function() {
|
|
13
|
+
return InternalError;
|
|
14
|
+
},
|
|
15
|
+
InvalidInputError: function() {
|
|
16
|
+
return InvalidInputError;
|
|
17
|
+
},
|
|
18
|
+
InvalidParamsError: function() {
|
|
19
|
+
return InvalidParamsError;
|
|
20
|
+
},
|
|
21
|
+
InvalidRequestError: function() {
|
|
22
|
+
return InvalidRequestError;
|
|
23
|
+
},
|
|
24
|
+
LimitExceededError: function() {
|
|
25
|
+
return LimitExceededError;
|
|
26
|
+
},
|
|
27
|
+
MethodNotFoundError: function() {
|
|
28
|
+
return MethodNotFoundError;
|
|
29
|
+
},
|
|
30
|
+
MethodNotSupportedError: function() {
|
|
31
|
+
return MethodNotSupportedError;
|
|
32
|
+
},
|
|
33
|
+
ParseError: function() {
|
|
34
|
+
return ParseError;
|
|
35
|
+
},
|
|
36
|
+
ResourceNotFoundError: function() {
|
|
37
|
+
return ResourceNotFoundError;
|
|
38
|
+
},
|
|
39
|
+
ResourceUnavailableError: function() {
|
|
40
|
+
return ResourceUnavailableError;
|
|
41
|
+
},
|
|
42
|
+
TransactionRejected: function() {
|
|
43
|
+
return TransactionRejected;
|
|
44
|
+
},
|
|
45
|
+
ChainDisconnectedError: function() {
|
|
46
|
+
return ChainDisconnectedError;
|
|
47
|
+
},
|
|
48
|
+
DisconnectedError: function() {
|
|
49
|
+
return DisconnectedError;
|
|
50
|
+
},
|
|
51
|
+
UnauthorizedError: function() {
|
|
52
|
+
return UnauthorizedError;
|
|
53
|
+
},
|
|
54
|
+
UnsupportedMethodError: function() {
|
|
55
|
+
return UnsupportedMethodError;
|
|
56
|
+
},
|
|
57
|
+
UserRejectedRequestError: function() {
|
|
58
|
+
return UserRejectedRequestError;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
const _rpcerrors = require("@metamask/rpc-errors");
|
|
62
|
+
const _internals = require("./internals");
|
|
63
|
+
const InternalError = (0, _internals.createSnapError)(_rpcerrors.rpcErrors.internal);
|
|
64
|
+
const InvalidInputError = (0, _internals.createSnapError)(_rpcerrors.rpcErrors.invalidInput);
|
|
65
|
+
const InvalidParamsError = (0, _internals.createSnapError)(_rpcerrors.rpcErrors.invalidParams);
|
|
66
|
+
const InvalidRequestError = (0, _internals.createSnapError)(_rpcerrors.rpcErrors.invalidRequest);
|
|
67
|
+
const LimitExceededError = (0, _internals.createSnapError)(_rpcerrors.rpcErrors.limitExceeded);
|
|
68
|
+
const MethodNotFoundError = (0, _internals.createSnapError)(_rpcerrors.rpcErrors.methodNotFound);
|
|
69
|
+
const MethodNotSupportedError = (0, _internals.createSnapError)(_rpcerrors.rpcErrors.methodNotSupported);
|
|
70
|
+
const ParseError = (0, _internals.createSnapError)(_rpcerrors.rpcErrors.parse);
|
|
71
|
+
const ResourceNotFoundError = (0, _internals.createSnapError)(_rpcerrors.rpcErrors.resourceNotFound);
|
|
72
|
+
const ResourceUnavailableError = (0, _internals.createSnapError)(_rpcerrors.rpcErrors.resourceUnavailable);
|
|
73
|
+
const TransactionRejected = (0, _internals.createSnapError)(_rpcerrors.rpcErrors.transactionRejected);
|
|
74
|
+
const ChainDisconnectedError = (0, _internals.createSnapError)(_rpcerrors.providerErrors.chainDisconnected);
|
|
75
|
+
const DisconnectedError = (0, _internals.createSnapError)(_rpcerrors.providerErrors.disconnected);
|
|
76
|
+
const UnauthorizedError = (0, _internals.createSnapError)(_rpcerrors.providerErrors.unauthorized);
|
|
77
|
+
const UnsupportedMethodError = (0, _internals.createSnapError)(_rpcerrors.providerErrors.unsupportedMethod);
|
|
78
|
+
const UserRejectedRequestError = (0, _internals.createSnapError)(_rpcerrors.providerErrors.userRejectedRequest);
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=error-wrappers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/error-wrappers.ts"],"sourcesContent":["import { providerErrors, rpcErrors } from '@metamask/rpc-errors';\n\nimport { createSnapError } from './internals';\n\n/**\n * A JSON-RPC 2.0 Internal (-32603) error.\n *\n * This can be thrown by a Snap to indicate that an internal error occurred,\n * without crashing the Snap.\n *\n * @see https://www.jsonrpc.org/specification#error_object\n */\nexport const InternalError = createSnapError(rpcErrors.internal);\n\n/**\n * An Ethereum JSON-RPC Invalid Input (-32000) error.\n *\n * This can be thrown by a Snap to indicate that the input to a method is\n * invalid, without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1474#error-codes\n */\nexport const InvalidInputError = createSnapError(rpcErrors.invalidInput);\n\n/**\n * A JSON-RPC 2.0 Invalid Params (-32602) error.\n *\n * This can be thrown by a Snap to indicate that the parameters to a method are\n * invalid, without crashing the Snap.\n *\n * @see https://www.jsonrpc.org/specification#error_object\n */\nexport const InvalidParamsError = createSnapError(rpcErrors.invalidParams);\n\n/**\n * A JSON-RPC 2.0 Invalid Request (-32600) error.\n *\n * This can be thrown by a Snap to indicate that the request is invalid, without\n * crashing the Snap.\n *\n * @see https://www.jsonrpc.org/specification#error_object\n */\nexport const InvalidRequestError = createSnapError(rpcErrors.invalidRequest);\n\n/**\n * An Ethereum JSON-RPC Limit Exceeded (-32005) error.\n *\n * This can be thrown by a Snap to indicate that a limit has been exceeded,\n * without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1474#error-codes\n */\nexport const LimitExceededError = createSnapError(rpcErrors.limitExceeded);\n\n/**\n * An Ethereum JSON-RPC Method Not Found (-32601) error.\n *\n * This can be thrown by a Snap to indicate that a method does not exist,\n * without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1474#error-codes\n */\nexport const MethodNotFoundError = createSnapError(rpcErrors.methodNotFound);\n\n/**\n * An Ethereum JSON-RPC Method Not Supported (-32004) error.\n *\n * This can be thrown by a Snap to indicate that a method is not supported,\n * without crashing the Snap.\n */\nexport const MethodNotSupportedError = createSnapError(\n rpcErrors.methodNotSupported,\n);\n\n/**\n * A JSON-RPC 2.0 Parse (-32700) error.\n *\n * This can be thrown by a Snap to indicate that a request is not valid JSON,\n * without crashing the Snap.\n *\n * @see https://www.jsonrpc.org/specification#error_object\n */\nexport const ParseError = createSnapError(rpcErrors.parse);\n\n/**\n * An Ethereum JSON-RPC Resource Not Found (-32001) error.\n *\n * This can be thrown by a Snap to indicate that a resource does not exist,\n * without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1474#error-codes\n */\nexport const ResourceNotFoundError = createSnapError(\n rpcErrors.resourceNotFound,\n);\n\n/**\n * An Ethereum JSON-RPC Resource Unavailable (-32002) error.\n *\n * This can be thrown by a Snap to indicate that a resource is unavailable,\n * without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1474#error-codes\n */\nexport const ResourceUnavailableError = createSnapError(\n rpcErrors.resourceUnavailable,\n);\n\n/**\n * An Ethereum JSON-RPC Transaction Rejected (-32003) error.\n *\n * This can be thrown by a Snap to indicate that a transaction was rejected,\n * without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1474#error-codes\n */\nexport const TransactionRejected = createSnapError(\n rpcErrors.transactionRejected,\n);\n\n/**\n * An Ethereum Provider Chain Disconnected (4901) error.\n *\n * This can be thrown by a Snap to indicate that the provider is disconnected\n * from the requested chain, without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors\n */\nexport const ChainDisconnectedError = createSnapError(\n providerErrors.chainDisconnected,\n);\n\n/**\n * An Ethereum Provider Disconnected (4900) error.\n *\n * This can be thrown by a Snap to indicate that the provider is disconnected,\n * without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors\n */\nexport const DisconnectedError = createSnapError(providerErrors.disconnected);\n\n/**\n * An Ethereum Provider Unauthorized (4100) error.\n *\n * This can be thrown by a Snap to indicate that the requested method / account\n * is not authorized by the user, without crashing the Snap.\n */\nexport const UnauthorizedError = createSnapError(providerErrors.unauthorized);\n\n/**\n * An Ethereum Provider Unsupported Method (4200) error.\n *\n * This can be thrown by a Snap to indicate that the requested method is not\n * supported by the provider, without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors\n */\nexport const UnsupportedMethodError = createSnapError(\n providerErrors.unsupportedMethod,\n);\n\n/**\n * An Ethereum Provider User Rejected Request (4001) error.\n *\n * This can be thrown by a Snap to indicate that the user rejected the request,\n * without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors\n */\nexport const UserRejectedRequestError = createSnapError(\n providerErrors.userRejectedRequest,\n);\n"],"names":["InternalError","InvalidInputError","InvalidParamsError","InvalidRequestError","LimitExceededError","MethodNotFoundError","MethodNotSupportedError","ParseError","ResourceNotFoundError","ResourceUnavailableError","TransactionRejected","ChainDisconnectedError","DisconnectedError","UnauthorizedError","UnsupportedMethodError","UserRejectedRequestError","createSnapError","rpcErrors","internal","invalidInput","invalidParams","invalidRequest","limitExceeded","methodNotFound","methodNotSupported","parse","resourceNotFound","resourceUnavailable","transactionRejected","providerErrors","chainDisconnected","disconnected","unauthorized","unsupportedMethod","userRejectedRequest"],"mappings":";;;;;;;;;;;IAYaA,aAAa;eAAbA;;IAUAC,iBAAiB;eAAjBA;;IAUAC,kBAAkB;eAAlBA;;IAUAC,mBAAmB;eAAnBA;;IAUAC,kBAAkB;eAAlBA;;IAUAC,mBAAmB;eAAnBA;;IAQAC,uBAAuB;eAAvBA;;IAYAC,UAAU;eAAVA;;IAUAC,qBAAqB;eAArBA;;IAYAC,wBAAwB;eAAxBA;;IAYAC,mBAAmB;eAAnBA;;IAYAC,sBAAsB;eAAtBA;;IAYAC,iBAAiB;eAAjBA;;IAQAC,iBAAiB;eAAjBA;;IAUAC,sBAAsB;eAAtBA;;IAYAC,wBAAwB;eAAxBA;;;2BA1K6B;2BAEV;AAUzB,MAAMf,gBAAgBgB,IAAAA,0BAAe,EAACC,oBAAS,CAACC,QAAQ;AAUxD,MAAMjB,oBAAoBe,IAAAA,0BAAe,EAACC,oBAAS,CAACE,YAAY;AAUhE,MAAMjB,qBAAqBc,IAAAA,0BAAe,EAACC,oBAAS,CAACG,aAAa;AAUlE,MAAMjB,sBAAsBa,IAAAA,0BAAe,EAACC,oBAAS,CAACI,cAAc;AAUpE,MAAMjB,qBAAqBY,IAAAA,0BAAe,EAACC,oBAAS,CAACK,aAAa;AAUlE,MAAMjB,sBAAsBW,IAAAA,0BAAe,EAACC,oBAAS,CAACM,cAAc;AAQpE,MAAMjB,0BAA0BU,IAAAA,0BAAe,EACpDC,oBAAS,CAACO,kBAAkB;AAWvB,MAAMjB,aAAaS,IAAAA,0BAAe,EAACC,oBAAS,CAACQ,KAAK;AAUlD,MAAMjB,wBAAwBQ,IAAAA,0BAAe,EAClDC,oBAAS,CAACS,gBAAgB;AAWrB,MAAMjB,2BAA2BO,IAAAA,0BAAe,EACrDC,oBAAS,CAACU,mBAAmB;AAWxB,MAAMjB,sBAAsBM,IAAAA,0BAAe,EAChDC,oBAAS,CAACW,mBAAmB;AAWxB,MAAMjB,yBAAyBK,IAAAA,0BAAe,EACnDa,yBAAc,CAACC,iBAAiB;AAW3B,MAAMlB,oBAAoBI,IAAAA,0BAAe,EAACa,yBAAc,CAACE,YAAY;AAQrE,MAAMlB,oBAAoBG,IAAAA,0BAAe,EAACa,yBAAc,CAACG,YAAY;AAUrE,MAAMlB,yBAAyBE,IAAAA,0BAAe,EACnDa,yBAAc,CAACI,iBAAiB;AAW3B,MAAMlB,2BAA2BC,IAAAA,0BAAe,EACrDa,yBAAc,CAACK,mBAAmB"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -24,6 +24,15 @@ _export(exports, {
|
|
|
24
24
|
},
|
|
25
25
|
SNAP_ERROR_MESSAGE: function() {
|
|
26
26
|
return _internals.SNAP_ERROR_MESSAGE;
|
|
27
|
+
},
|
|
28
|
+
literal: function() {
|
|
29
|
+
return _internals.literal;
|
|
30
|
+
},
|
|
31
|
+
union: function() {
|
|
32
|
+
return _internals.union;
|
|
33
|
+
},
|
|
34
|
+
enumValue: function() {
|
|
35
|
+
return _internals.enumValue;
|
|
27
36
|
}
|
|
28
37
|
});
|
|
29
38
|
const _internals = require("./internals");
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Only internals that are used by other Snaps packages should be exported here.\nexport type { EnumToUnion } from './internals';\nexport {\n getErrorData,\n getErrorMessage,\n getErrorStack,\n SNAP_ERROR_CODE,\n SNAP_ERROR_MESSAGE,\n} from './internals';\n\n// Re-exported from `@metamask/utils` for convenience.\nexport type {\n Json,\n JsonRpcError,\n JsonRpcRequest,\n JsonRpcParams,\n} from '@metamask/utils';\n\nexport * from './errors';\nexport * from './types';\nexport * from './ui';\n"],"names":["getErrorData","getErrorMessage","getErrorStack","SNAP_ERROR_CODE","SNAP_ERROR_MESSAGE"],"mappings":"AAAA,gFAAgF;;;;;;;;;;;;IAG9EA,YAAY;eAAZA,uBAAY;;IACZC,eAAe;eAAfA,0BAAe;;IACfC,aAAa;eAAbA,wBAAa;;IACbC,eAAe;eAAfA,0BAAe;;IACfC,kBAAkB;eAAlBA,6BAAkB;;;
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Only internals that are used by other Snaps packages should be exported here.\nexport type { EnumToUnion } from './internals';\nexport {\n getErrorData,\n getErrorMessage,\n getErrorStack,\n SNAP_ERROR_CODE,\n SNAP_ERROR_MESSAGE,\n literal,\n union,\n enumValue,\n} from './internals';\n\n// Re-exported from `@metamask/utils` for convenience.\nexport type {\n Json,\n JsonRpcError,\n JsonRpcRequest,\n JsonRpcParams,\n} from '@metamask/utils';\n\nexport * from './errors';\nexport * from './types';\nexport * from './ui';\n"],"names":["getErrorData","getErrorMessage","getErrorStack","SNAP_ERROR_CODE","SNAP_ERROR_MESSAGE","literal","union","enumValue"],"mappings":"AAAA,gFAAgF;;;;;;;;;;;;IAG9EA,YAAY;eAAZA,uBAAY;;IACZC,eAAe;eAAfA,0BAAe;;IACfC,aAAa;eAAbA,wBAAa;;IACbC,eAAe;eAAfA,0BAAe;;IACfC,kBAAkB;eAAlBA,6BAAkB;;IAClBC,OAAO;eAAPA,kBAAO;;IACPC,KAAK;eAALA,gBAAK;;IACLC,SAAS;eAATA,oBAAS;;;2BACJ;qBAUO;qBACA;qBACA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "createSnapError", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return createSnapError;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _errors = require("../errors");
|
|
12
|
+
function createSnapError(fn) {
|
|
13
|
+
return class SnapJsonRpcError extends _errors.SnapError {
|
|
14
|
+
constructor(message, data){
|
|
15
|
+
const error = fn(message);
|
|
16
|
+
super({
|
|
17
|
+
code: error.code,
|
|
18
|
+
message: error.message,
|
|
19
|
+
data
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=error-wrappers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/internals/error-wrappers.ts"],"sourcesContent":["import type { rpcErrors } from '@metamask/rpc-errors';\nimport type { Json } from '@metamask/utils';\n\nimport { SnapError } from '../errors';\n\nexport type JsonRpcErrorFunction = typeof rpcErrors.parse;\n\n/**\n * Create a `SnapError` class from an error function from\n * `@metamask/rpc-errors`. This is useful for creating custom error classes\n * which can be thrown by a Snap.\n *\n * The created class will inherit the message, code, and data properties from\n * the error function.\n *\n * @param fn - The error function to create the class from.\n * @returns The created `SnapError` class.\n */\nexport function createSnapError(fn: JsonRpcErrorFunction) {\n return class SnapJsonRpcError extends SnapError {\n constructor(message?: string, data?: Record<string, Json>) {\n const error = fn(message);\n\n super({\n code: error.code,\n message: error.message,\n data,\n });\n }\n };\n}\n"],"names":["createSnapError","fn","SnapJsonRpcError","SnapError","constructor","message","data","error","code"],"mappings":";;;;+BAkBgBA;;;eAAAA;;;wBAfU;AAenB,SAASA,gBAAgBC,EAAwB;IACtD,OAAO,MAAMC,yBAAyBC,iBAAS;QAC7CC,YAAYC,OAAgB,EAAEC,IAA2B,CAAE;YACzD,MAAMC,QAAQN,GAAGI;YAEjB,KAAK,CAAC;gBACJG,MAAMD,MAAMC,IAAI;gBAChBH,SAASE,MAAMF,OAAO;gBACtBC;YACF;QACF;IACF;AACF"}
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
+
_export_star(require("./error-wrappers"), exports);
|
|
5
6
|
_export_star(require("./errors"), exports);
|
|
6
7
|
_export_star(require("./helpers"), exports);
|
|
8
|
+
_export_star(require("./structs"), exports);
|
|
7
9
|
function _export_star(from, to) {
|
|
8
10
|
Object.keys(from).forEach(function(k) {
|
|
9
11
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/internals/index.ts"],"sourcesContent":["export * from './errors';\nexport * from './helpers';\n"],"names":[],"mappings":";;;;qBAAc;qBACA"}
|
|
1
|
+
{"version":3,"sources":["../../../src/internals/index.ts"],"sourcesContent":["export * from './error-wrappers';\nexport * from './errors';\nexport * from './helpers';\nexport * from './structs';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
literal: function() {
|
|
13
|
+
return literal;
|
|
14
|
+
},
|
|
15
|
+
union: function() {
|
|
16
|
+
return union;
|
|
17
|
+
},
|
|
18
|
+
enumValue: function() {
|
|
19
|
+
return enumValue;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const _superstruct = require("superstruct");
|
|
23
|
+
function literal(value) {
|
|
24
|
+
return (0, _superstruct.define)(JSON.stringify(value), (0, _superstruct.literal)(value).validator);
|
|
25
|
+
}
|
|
26
|
+
function union([head, ...tail]) {
|
|
27
|
+
const struct = (0, _superstruct.union)([
|
|
28
|
+
head,
|
|
29
|
+
...tail
|
|
30
|
+
]);
|
|
31
|
+
return new _superstruct.Struct({
|
|
32
|
+
...struct,
|
|
33
|
+
schema: [
|
|
34
|
+
head,
|
|
35
|
+
...tail
|
|
36
|
+
]
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function enumValue(constant) {
|
|
40
|
+
return literal(constant);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=structs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/internals/structs.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport {\n Struct,\n define,\n literal as superstructLiteral,\n union as superstructUnion,\n} from 'superstruct';\nimport type { AnyStruct, InferStructTuple } from 'superstruct/dist/utils';\n\nimport type { EnumToUnion } from './helpers';\n\n/**\n * A wrapper of `superstruct`'s `literal` struct that also defines the name of\n * the struct as the literal value.\n *\n * This is useful for improving the error messages returned by `superstruct`.\n * For example, instead of returning an error like:\n *\n * ```\n * Expected the value to satisfy a union of `literal | literal`, but received: \\\"baz\\\"\n * ```\n *\n * This struct will return an error like:\n *\n * ```\n * Expected the value to satisfy a union of `\"foo\" | \"bar\"`, but received: \\\"baz\\\"\n * ```\n *\n * @param value - The literal value.\n * @returns The `superstruct` struct, which validates that the value is equal\n * to the literal value.\n */\nexport function literal<Type extends string | number | boolean>(value: Type) {\n return define<Type>(\n JSON.stringify(value),\n superstructLiteral(value).validator,\n );\n}\n\n/**\n * A wrapper of `superstruct`'s `union` struct that also defines the schema as\n * the union of the schemas of the structs.\n *\n * This is useful for improving the error messages returned by `superstruct`.\n *\n * @param structs - The structs to union.\n * @param structs.\"0\" - The first struct.\n * @param structs.\"1\" - The remaining structs.\n * @returns The `superstruct` struct, which validates that the value satisfies\n * one of the structs.\n */\nexport function union<Head extends AnyStruct, Tail extends AnyStruct[]>([\n head,\n ...tail\n]: [head: Head, ...tail: Tail]): Struct<\n Infer<Head> | InferStructTuple<Tail>[number],\n [head: Head, ...tail: Tail]\n> {\n const struct = superstructUnion([head, ...tail]);\n\n return new Struct({\n ...struct,\n schema: [head, ...tail],\n });\n}\n\n/**\n * Superstruct struct for validating an enum value. This allows using both the\n * enum string values and the enum itself as values.\n *\n * @param constant - The enum to validate against.\n * @returns The superstruct struct.\n */\nexport function enumValue<Type extends string>(\n constant: Type,\n): Struct<EnumToUnion<Type>, null> {\n return literal(constant as EnumToUnion<Type>);\n}\n"],"names":["literal","union","enumValue","value","define","JSON","stringify","superstructLiteral","validator","head","tail","struct","superstructUnion","Struct","schema","constant"],"mappings":";;;;;;;;;;;IAgCgBA,OAAO;eAAPA;;IAmBAC,KAAK;eAALA;;IAsBAC,SAAS;eAATA;;;6BAnET;AA0BA,SAASF,QAAgDG,KAAW;IACzE,OAAOC,IAAAA,mBAAM,EACXC,KAAKC,SAAS,CAACH,QACfI,IAAAA,oBAAkB,EAACJ,OAAOK,SAAS;AAEvC;AAcO,SAASP,MAAwD,CACtEQ,MACA,GAAGC,KACyB;IAI5B,MAAMC,SAASC,IAAAA,kBAAgB,EAAC;QAACH;WAASC;KAAK;IAE/C,OAAO,IAAIG,mBAAM,CAAC;QAChB,GAAGF,MAAM;QACTG,QAAQ;YAACL;eAASC;SAAK;IACzB;AACF;AASO,SAASR,UACda,QAAc;IAEd,OAAOf,QAAQe;AACjB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
AddressStruct: function() {
|
|
13
|
+
return AddressStruct;
|
|
14
|
+
},
|
|
15
|
+
address: function() {
|
|
16
|
+
return address;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _superstruct = require("superstruct");
|
|
20
|
+
const _builder = require("../builder");
|
|
21
|
+
const _nodes = require("../nodes");
|
|
22
|
+
const AddressStruct = (0, _superstruct.assign)(_nodes.LiteralStruct, (0, _superstruct.object)({
|
|
23
|
+
type: (0, _superstruct.literal)(_nodes.NodeType.Address),
|
|
24
|
+
value: (0, _superstruct.pattern)((0, _superstruct.string)(), /0x[a-fA-F0-9]{40}/u)
|
|
25
|
+
}));
|
|
26
|
+
const address = (0, _builder.createBuilder)(_nodes.NodeType.Address, AddressStruct, [
|
|
27
|
+
'value'
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=address.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/ui/components/address.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { assign, literal, object, pattern, string } from 'superstruct';\n\nimport { createBuilder } from '../builder';\nimport { LiteralStruct, NodeType } from '../nodes';\n\nexport const AddressStruct = assign(\n LiteralStruct,\n object({\n type: literal(NodeType.Address),\n value: pattern(string(), /0x[a-fA-F0-9]{40}/u),\n }),\n);\n\n/**\n * A address node, that renders an EVM-like address and its icon.\n *\n * @property type - The type of the node. Must be the string `address`.\n * @property value - The address in hexadecimal, including 0x.\n */\nexport type Address = Infer<typeof AddressStruct>;\n\n/**\n * Create an {@link Address} node.\n *\n * @param args - The node arguments. This can either be a string, or an object\n * with the `value` property.\n * @param args.value - The address to be rendered.\n * @returns The address node as an object.\n * @example\n * const node = address({ value: '0x4bbeeb066ed09b7aed07bf39eee0460dfa261520' });\n * const node = address('0x4bbeeb066ed09b7aed07bf39eee0460dfa261520');\n */\nexport const address = createBuilder(NodeType.Address, AddressStruct, [\n 'value',\n]);\n"],"names":["AddressStruct","address","assign","LiteralStruct","object","type","literal","NodeType","Address","value","pattern","string","createBuilder"],"mappings":";;;;;;;;;;;IAMaA,aAAa;eAAbA;;IA2BAC,OAAO;eAAPA;;;6BAhC4C;yBAE3B;uBACU;AAEjC,MAAMD,gBAAgBE,IAAAA,mBAAM,EACjCC,oBAAa,EACbC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,OAAO;IAC9BC,OAAOC,IAAAA,oBAAO,EAACC,IAAAA,mBAAM,KAAI;AAC3B;AAsBK,MAAMV,UAAUW,IAAAA,sBAAa,EAACL,eAAQ,CAACC,OAAO,EAAER,eAAe;IACpE;CACD"}
|
|
@@ -25,6 +25,7 @@ _export(exports, {
|
|
|
25
25
|
return _panel.PanelStruct;
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
+
_export_star(require("./address"), exports);
|
|
28
29
|
_export_star(require("./copyable"), exports);
|
|
29
30
|
_export_star(require("./divider"), exports);
|
|
30
31
|
_export_star(require("./heading"), exports);
|
|
@@ -32,6 +33,7 @@ const _image = require("./image");
|
|
|
32
33
|
const _panel = require("./panel");
|
|
33
34
|
_export_star(require("./spinner"), exports);
|
|
34
35
|
_export_star(require("./text"), exports);
|
|
36
|
+
_export_star(require("./row"), exports);
|
|
35
37
|
function _export_star(from, to) {
|
|
36
38
|
Object.keys(from).forEach(function(k) {
|
|
37
39
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ui/components/index.ts"],"sourcesContent":["export * from './copyable';\nexport * from './divider';\nexport * from './heading';\nexport type { Image } from './image';\nexport { image, ImageStruct } from './image';\nexport type { Component, Panel } from './panel';\nexport { ComponentStruct, panel, PanelStruct } from './panel';\nexport * from './spinner';\nexport * from './text';\n"],"names":["image","ImageStruct","ComponentStruct","panel","PanelStruct"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../../src/ui/components/index.ts"],"sourcesContent":["export * from './address';\nexport * from './copyable';\nexport * from './divider';\nexport * from './heading';\nexport type { Image } from './image';\nexport { image, ImageStruct } from './image';\nexport type { Component, Panel } from './panel';\nexport { ComponentStruct, panel, PanelStruct } from './panel';\nexport * from './spinner';\nexport * from './text';\nexport * from './row';\n"],"names":["image","ImageStruct","ComponentStruct","panel","PanelStruct"],"mappings":";;;;;;;;;;;IAKSA,KAAK;eAALA,YAAK;;IAAEC,WAAW;eAAXA,kBAAW;;IAElBC,eAAe;eAAfA,sBAAe;;IAAEC,KAAK;eAALA,YAAK;;IAAEC,WAAW;eAAXA,kBAAW;;;qBAP9B;qBACA;qBACA;qBACA;uBAEqB;uBAEiB;qBACtC;qBACA;qBACA"}
|
|
@@ -25,10 +25,12 @@ _export(exports, {
|
|
|
25
25
|
const _superstruct = require("superstruct");
|
|
26
26
|
const _builder = require("../builder");
|
|
27
27
|
const _nodes = require("../nodes");
|
|
28
|
+
const _address = require("./address");
|
|
28
29
|
const _copyable = require("./copyable");
|
|
29
30
|
const _divider = require("./divider");
|
|
30
31
|
const _heading = require("./heading");
|
|
31
32
|
const _image = require("./image");
|
|
33
|
+
const _row = require("./row");
|
|
32
34
|
const _spinner = require("./spinner");
|
|
33
35
|
const _text = require("./text");
|
|
34
36
|
const ParentStruct = (0, _superstruct.assign)(_nodes.NodeStruct, (0, _superstruct.object)({
|
|
@@ -49,7 +51,9 @@ const ComponentStruct = (0, _superstruct.union)([
|
|
|
49
51
|
_image.ImageStruct,
|
|
50
52
|
PanelStruct,
|
|
51
53
|
_spinner.SpinnerStruct,
|
|
52
|
-
_text.TextStruct
|
|
54
|
+
_text.TextStruct,
|
|
55
|
+
_row.RowStruct,
|
|
56
|
+
_address.AddressStruct
|
|
53
57
|
]);
|
|
54
58
|
|
|
55
59
|
//# sourceMappingURL=panel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ui/components/panel.ts"],"sourcesContent":["import type { Infer, Struct } from 'superstruct';\nimport { array, assign, lazy, literal, object, union } from 'superstruct';\n\nimport { createBuilder } from '../builder';\nimport { NodeStruct, NodeType } from '../nodes';\nimport { CopyableStruct } from './copyable';\nimport { DividerStruct } from './divider';\nimport { HeadingStruct } from './heading';\nimport { ImageStruct } from './image';\nimport { SpinnerStruct } from './spinner';\nimport { TextStruct } from './text';\n\n/**\n * @internal\n */\nexport const ParentStruct = assign(\n NodeStruct,\n object({\n // This node references itself indirectly, so we need to use `lazy()`.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n children: array(lazy(() => ComponentStruct)),\n }),\n);\n\n/**\n * A node which supports child nodes. This is used for nodes that render their\n * children, such as {@link Panel}.\n *\n * @property type - The type of the node.\n * @property children - The children of the node\n * @internal\n */\nexport type Parent = Infer<typeof ParentStruct>;\n\n/**\n * @internal\n */\nexport const PanelStruct: Struct<Panel> = assign(\n ParentStruct,\n object({\n type: literal(NodeType.Panel),\n }),\n);\n\n/**\n * A panel node, which renders its children.\n *\n * @property type - The type of the node, must be the string 'text'.\n * @property value - The text content of the node, either as plain text, or as a\n * markdown string.\n */\n// This node references itself indirectly, so it cannot be inferred.\nexport type Panel = {\n type: NodeType.Panel;\n children: Component[];\n};\n\n/**\n * Create a {@link Panel} node.\n *\n * @param args - The node arguments. This can be either an array of children, or\n * an object with a `children` property.\n * @param args.children - The child nodes of the panel. This can be any valid\n * {@link Component}.\n * @returns The panel node as object.\n * @example\n * const node = panel({\n * children: [\n * heading({ text: 'Hello, world!' }),\n * text({ text: 'This is a panel.' }),\n * ],\n * });\n *\n * const node = panel([\n * heading('Hello, world!'),\n * text('This is a panel.'),\n * ]);\n */\nexport const panel = createBuilder(NodeType.Panel, PanelStruct, ['children']);\n\n// This is defined separately from `Component` to avoid circular dependencies.\nexport const ComponentStruct = union([\n CopyableStruct,\n DividerStruct,\n HeadingStruct,\n ImageStruct,\n PanelStruct,\n SpinnerStruct,\n TextStruct,\n]);\n\n/**\n * All supported component types.\n */\nexport type Component = Infer<typeof ComponentStruct>;\n"],"names":["ParentStruct","PanelStruct","panel","ComponentStruct","assign","NodeStruct","object","children","array","lazy","type","literal","NodeType","Panel","createBuilder","union","CopyableStruct","DividerStruct","HeadingStruct","ImageStruct","SpinnerStruct","TextStruct"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../../src/ui/components/panel.ts"],"sourcesContent":["import type { Infer, Struct } from 'superstruct';\nimport { array, assign, lazy, literal, object, union } from 'superstruct';\n\nimport { createBuilder } from '../builder';\nimport { NodeStruct, NodeType } from '../nodes';\nimport { AddressStruct } from './address';\nimport { CopyableStruct } from './copyable';\nimport { DividerStruct } from './divider';\nimport { HeadingStruct } from './heading';\nimport { ImageStruct } from './image';\nimport { RowStruct } from './row';\nimport { SpinnerStruct } from './spinner';\nimport { TextStruct } from './text';\n\n/**\n * @internal\n */\nexport const ParentStruct = assign(\n NodeStruct,\n object({\n // This node references itself indirectly, so we need to use `lazy()`.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n children: array(lazy(() => ComponentStruct)),\n }),\n);\n\n/**\n * A node which supports child nodes. This is used for nodes that render their\n * children, such as {@link Panel}.\n *\n * @property type - The type of the node.\n * @property children - The children of the node\n * @internal\n */\nexport type Parent = Infer<typeof ParentStruct>;\n\n/**\n * @internal\n */\nexport const PanelStruct: Struct<Panel> = assign(\n ParentStruct,\n object({\n type: literal(NodeType.Panel),\n }),\n);\n\n/**\n * A panel node, which renders its children.\n *\n * @property type - The type of the node, must be the string 'text'.\n * @property value - The text content of the node, either as plain text, or as a\n * markdown string.\n */\n// This node references itself indirectly, so it cannot be inferred.\nexport type Panel = {\n type: NodeType.Panel;\n children: Component[];\n};\n\n/**\n * Create a {@link Panel} node.\n *\n * @param args - The node arguments. This can be either an array of children, or\n * an object with a `children` property.\n * @param args.children - The child nodes of the panel. This can be any valid\n * {@link Component}.\n * @returns The panel node as object.\n * @example\n * const node = panel({\n * children: [\n * heading({ text: 'Hello, world!' }),\n * text({ text: 'This is a panel.' }),\n * ],\n * });\n *\n * const node = panel([\n * heading('Hello, world!'),\n * text('This is a panel.'),\n * ]);\n */\nexport const panel = createBuilder(NodeType.Panel, PanelStruct, ['children']);\n\n// This is defined separately from `Component` to avoid circular dependencies.\nexport const ComponentStruct = union([\n CopyableStruct,\n DividerStruct,\n HeadingStruct,\n ImageStruct,\n PanelStruct,\n SpinnerStruct,\n TextStruct,\n RowStruct,\n AddressStruct,\n]);\n\n/**\n * All supported component types.\n */\nexport type Component = Infer<typeof ComponentStruct>;\n"],"names":["ParentStruct","PanelStruct","panel","ComponentStruct","assign","NodeStruct","object","children","array","lazy","type","literal","NodeType","Panel","createBuilder","union","CopyableStruct","DividerStruct","HeadingStruct","ImageStruct","SpinnerStruct","TextStruct","RowStruct","AddressStruct"],"mappings":";;;;;;;;;;;IAiBaA,YAAY;eAAZA;;IAsBAC,WAAW;eAAXA;;IAyCAC,KAAK;eAALA;;IAGAC,eAAe;eAAfA;;;6BAlF+C;yBAE9B;uBACO;yBACP;0BACC;yBACD;yBACA;uBACF;qBACF;yBACI;sBACH;AAKpB,MAAMH,eAAeI,IAAAA,mBAAM,EAChCC,iBAAU,EACVC,IAAAA,mBAAM,EAAC;IACL,sEAAsE;IACtE,mEAAmE;IACnEC,UAAUC,IAAAA,kBAAK,EAACC,IAAAA,iBAAI,EAAC,IAAMN;AAC7B;AAgBK,MAAMF,cAA6BG,IAAAA,mBAAM,EAC9CJ,cACAM,IAAAA,mBAAM,EAAC;IACLI,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,KAAK;AAC9B;AAqCK,MAAMX,QAAQY,IAAAA,sBAAa,EAACF,eAAQ,CAACC,KAAK,EAAEZ,aAAa;IAAC;CAAW;AAGrE,MAAME,kBAAkBY,IAAAA,kBAAK,EAAC;IACnCC,wBAAc;IACdC,sBAAa;IACbC,sBAAa;IACbC,kBAAW;IACXlB;IACAmB,sBAAa;IACbC,gBAAU;IACVC,cAAS;IACTC,sBAAa;CACd"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
RowVariant: function() {
|
|
13
|
+
return RowVariant;
|
|
14
|
+
},
|
|
15
|
+
RowStruct: function() {
|
|
16
|
+
return RowStruct;
|
|
17
|
+
},
|
|
18
|
+
row: function() {
|
|
19
|
+
return row;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const _superstruct = require("superstruct");
|
|
23
|
+
const _internals = require("../../internals");
|
|
24
|
+
const _builder = require("../builder");
|
|
25
|
+
const _nodes = require("../nodes");
|
|
26
|
+
const _address = require("./address");
|
|
27
|
+
const _image = require("./image");
|
|
28
|
+
const _text = require("./text");
|
|
29
|
+
var RowVariant;
|
|
30
|
+
(function(RowVariant) {
|
|
31
|
+
RowVariant["Default"] = 'default';
|
|
32
|
+
RowVariant["Critical"] = 'critical';
|
|
33
|
+
RowVariant["Warning"] = 'warning';
|
|
34
|
+
})(RowVariant || (RowVariant = {}));
|
|
35
|
+
// A subset of components made available to the row
|
|
36
|
+
const RowComponentStruct = (0, _superstruct.union)([
|
|
37
|
+
_image.ImageStruct,
|
|
38
|
+
_text.TextStruct,
|
|
39
|
+
_address.AddressStruct
|
|
40
|
+
]);
|
|
41
|
+
const RowStruct = (0, _superstruct.assign)(_nodes.LiteralStruct, (0, _superstruct.object)({
|
|
42
|
+
type: (0, _superstruct.literal)(_nodes.NodeType.Row),
|
|
43
|
+
variant: (0, _superstruct.optional)((0, _superstruct.union)([
|
|
44
|
+
(0, _internals.enumValue)(RowVariant.Default),
|
|
45
|
+
(0, _internals.enumValue)(RowVariant.Critical),
|
|
46
|
+
(0, _internals.enumValue)(RowVariant.Warning)
|
|
47
|
+
])),
|
|
48
|
+
label: (0, _superstruct.string)(),
|
|
49
|
+
value: RowComponentStruct
|
|
50
|
+
}));
|
|
51
|
+
const row = (0, _builder.createBuilder)(_nodes.NodeType.Row, RowStruct, [
|
|
52
|
+
'label',
|
|
53
|
+
'value',
|
|
54
|
+
'variant'
|
|
55
|
+
]);
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=row.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/ui/components/row.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { assign, literal, object, string, optional, union } from 'superstruct';\n\nimport { enumValue } from '../../internals';\nimport { createBuilder } from '../builder';\nimport { LiteralStruct, NodeType } from '../nodes';\nimport { AddressStruct } from './address';\nimport { ImageStruct } from './image';\nimport { TextStruct } from './text';\n\nexport enum RowVariant {\n Default = 'default',\n Critical = 'critical',\n Warning = 'warning',\n}\n\n// A subset of components made available to the row\nconst RowComponentStruct = union([ImageStruct, TextStruct, AddressStruct]);\n\nexport const RowStruct = assign(\n LiteralStruct,\n object({\n type: literal(NodeType.Row),\n variant: optional(\n union([\n enumValue(RowVariant.Default),\n enumValue(RowVariant.Critical),\n enumValue(RowVariant.Warning),\n ]),\n ),\n label: string(),\n value: RowComponentStruct,\n }),\n);\n\n/**\n * A row node, that renders a row with a label and a value.\n *\n * @property type - The type of the node. Must be the string `row`.\n * @property label - The label for the row.\n * @property value - A sub component to be rendered\n * on one side of the row.\n * @property variant - Optional variant for styling.\n */\nexport type Row = Infer<typeof RowStruct>;\n\n/**\n * Create a {@link Row} node.\n *\n * @param args - The node arguments. This can either be a string, a component and an optional variant or an object\n * with the properties: `label`, `value` and `variant`.\n * @param args.label - The label for the row.\n * @param args.value - Another component, is currently limited to `image`, `text` and `address`.\n * @param args.variant - An optional variant, either `default`, `warning` or `critical`.\n * @returns The row node as an object.\n * @example\n * const node = row({ label: 'Address', value: address('0x4bbeeb066ed09b7aed07bf39eee0460dfa261520') });\n * const node = row({ label: 'Address', value: address('0x4bbeeb066ed09b7aed07bf39eee0460dfa261520'), variant: RowVariant.Warning });\n * const node = row('Address', address('0x4bbeeb066ed09b7aed07bf39eee0460dfa261520'));\n * const node = row('Address', address('0x4bbeeb066ed09b7aed07bf39eee0460dfa261520'), RowVariant.Warning);\n */\nexport const row = createBuilder(NodeType.Row, RowStruct, [\n 'label',\n 'value',\n 'variant',\n]);\n"],"names":["RowStruct","row","RowVariant","Default","Critical","Warning","RowComponentStruct","union","ImageStruct","TextStruct","AddressStruct","assign","LiteralStruct","object","type","literal","NodeType","Row","variant","optional","enumValue","label","string","value","createBuilder"],"mappings":";;;;;;;;;;;;;;IAmBaA,SAAS;eAATA;;IA0CAC,GAAG;eAAHA;;;6BA5DoD;2BAEvC;yBACI;uBACU;yBACV;uBACF;sBACD;IAEpB;UAAKC,UAAU;IAAVA,WACVC,aAAU;IADAD,WAEVE,cAAW;IAFDF,WAGVG,aAAU;GAHAH,eAAAA;AAMZ,mDAAmD;AACnD,MAAMI,qBAAqBC,IAAAA,kBAAK,EAAC;IAACC,kBAAW;IAAEC,gBAAU;IAAEC,sBAAa;CAAC;AAElE,MAAMV,YAAYW,IAAAA,mBAAM,EAC7BC,oBAAa,EACbC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,GAAG;IAC1BC,SAASC,IAAAA,qBAAQ,EACfZ,IAAAA,kBAAK,EAAC;QACJa,IAAAA,oBAAS,EAAClB,WAAWC,OAAO;QAC5BiB,IAAAA,oBAAS,EAAClB,WAAWE,QAAQ;QAC7BgB,IAAAA,oBAAS,EAAClB,WAAWG,OAAO;KAC7B;IAEHgB,OAAOC,IAAAA,mBAAM;IACbC,OAAOjB;AACT;AA6BK,MAAML,MAAMuB,IAAAA,sBAAa,EAACR,eAAQ,CAACC,GAAG,EAAEjB,WAAW;IACxD;IACA;IACA;CACD"}
|
package/dist/cjs/ui/nodes.js
CHANGED
|
@@ -30,6 +30,8 @@ var NodeType;
|
|
|
30
30
|
NodeType[// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
31
31
|
"Text"] = 'text';
|
|
32
32
|
NodeType["Image"] = 'image';
|
|
33
|
+
NodeType["Row"] = 'row';
|
|
34
|
+
NodeType["Address"] = 'address';
|
|
33
35
|
})(NodeType || (NodeType = {}));
|
|
34
36
|
const NodeStruct = (0, _superstruct.object)({
|
|
35
37
|
type: (0, _superstruct.string)()
|
package/dist/cjs/ui/nodes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ui/nodes.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { assign, object, string, unknown } from 'superstruct';\n\n/**\n * The supported node types. This is based on SIP-7.\n *\n * @see https://metamask.github.io/SIPs/SIPS/sip-7\n */\nexport enum NodeType {\n Copyable = 'copyable',\n Divider = 'divider',\n Heading = 'heading',\n Panel = 'panel',\n Spinner = 'spinner',\n // eslint-disable-next-line @typescript-eslint/no-shadow\n Text = 'text',\n Image = 'image',\n}\n\n/**\n * @internal\n */\nexport const NodeStruct = object({\n type: string(),\n});\n\n/**\n * The base node type. All nodes extend this type.\n *\n * @property type - The type of the node. See {@link NodeType} for the supported\n * node types.\n * @internal\n */\nexport type Node = Infer<typeof NodeStruct>;\n\n/**\n * @internal\n */\nexport const LiteralStruct = assign(\n NodeStruct,\n object({\n value: unknown(),\n }),\n);\n\n/**\n * A node with a value. This is used for nodes that render a value, such as\n * {@link Text}.\n *\n * @property type - The type of the node.\n * @property value - The value of the node. The type of the value depends on the\n * node type.\n * @internal\n */\nexport type Literal = Infer<typeof LiteralStruct>;\n"],"names":["NodeStruct","LiteralStruct","NodeType","Copyable","Divider","Heading","Panel","Spinner","Text","Image","object","type","string","assign","value","unknown"],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/ui/nodes.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { assign, object, string, unknown } from 'superstruct';\n\n/**\n * The supported node types. This is based on SIP-7.\n *\n * @see https://metamask.github.io/SIPs/SIPS/sip-7\n */\nexport enum NodeType {\n Copyable = 'copyable',\n Divider = 'divider',\n Heading = 'heading',\n Panel = 'panel',\n Spinner = 'spinner',\n // eslint-disable-next-line @typescript-eslint/no-shadow\n Text = 'text',\n Image = 'image',\n Row = 'row',\n Address = 'address',\n}\n\n/**\n * @internal\n */\nexport const NodeStruct = object({\n type: string(),\n});\n\n/**\n * The base node type. All nodes extend this type.\n *\n * @property type - The type of the node. See {@link NodeType} for the supported\n * node types.\n * @internal\n */\nexport type Node = Infer<typeof NodeStruct>;\n\n/**\n * @internal\n */\nexport const LiteralStruct = assign(\n NodeStruct,\n object({\n value: unknown(),\n }),\n);\n\n/**\n * A node with a value. This is used for nodes that render a value, such as\n * {@link Text}.\n *\n * @property type - The type of the node.\n * @property value - The value of the node. The type of the value depends on the\n * node type.\n * @internal\n */\nexport type Literal = Infer<typeof LiteralStruct>;\n"],"names":["NodeStruct","LiteralStruct","NodeType","Copyable","Divider","Heading","Panel","Spinner","Text","Image","Row","Address","object","type","string","assign","value","unknown"],"mappings":";;;;;;;;;;;;;;IAwBaA,UAAU;eAAVA;;IAgBAC,aAAa;eAAbA;;;6BAvCmC;IAOzC;UAAKC,QAAQ;IAARA,SACVC,cAAW;IADDD,SAEVE,aAAU;IAFAF,SAGVG,aAAU;IAHAH,SAIVI,WAAQ;IAJEJ,SAKVK,aAAU;IALAL,SAMV,wDAAwD;IACxDM,UAAO;IAPGN,SAQVO,WAAQ;IAREP,SASVQ,SAAM;IATIR,SAUVS,aAAU;GAVAT,aAAAA;AAgBL,MAAMF,aAAaY,IAAAA,mBAAM,EAAC;IAC/BC,MAAMC,IAAAA,mBAAM;AACd;AAcO,MAAMb,gBAAgBc,IAAAA,mBAAM,EACjCf,YACAY,IAAAA,mBAAM,EAAC;IACLI,OAAOC,IAAAA,oBAAO;AAChB"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { providerErrors, rpcErrors } from '@metamask/rpc-errors';
|
|
2
|
+
import { createSnapError } from './internals';
|
|
3
|
+
/**
|
|
4
|
+
* A JSON-RPC 2.0 Internal (-32603) error.
|
|
5
|
+
*
|
|
6
|
+
* This can be thrown by a Snap to indicate that an internal error occurred,
|
|
7
|
+
* without crashing the Snap.
|
|
8
|
+
*
|
|
9
|
+
* @see https://www.jsonrpc.org/specification#error_object
|
|
10
|
+
*/ export const InternalError = createSnapError(rpcErrors.internal);
|
|
11
|
+
/**
|
|
12
|
+
* An Ethereum JSON-RPC Invalid Input (-32000) error.
|
|
13
|
+
*
|
|
14
|
+
* This can be thrown by a Snap to indicate that the input to a method is
|
|
15
|
+
* invalid, without crashing the Snap.
|
|
16
|
+
*
|
|
17
|
+
* @see https://eips.ethereum.org/EIPS/eip-1474#error-codes
|
|
18
|
+
*/ export const InvalidInputError = createSnapError(rpcErrors.invalidInput);
|
|
19
|
+
/**
|
|
20
|
+
* A JSON-RPC 2.0 Invalid Params (-32602) error.
|
|
21
|
+
*
|
|
22
|
+
* This can be thrown by a Snap to indicate that the parameters to a method are
|
|
23
|
+
* invalid, without crashing the Snap.
|
|
24
|
+
*
|
|
25
|
+
* @see https://www.jsonrpc.org/specification#error_object
|
|
26
|
+
*/ export const InvalidParamsError = createSnapError(rpcErrors.invalidParams);
|
|
27
|
+
/**
|
|
28
|
+
* A JSON-RPC 2.0 Invalid Request (-32600) error.
|
|
29
|
+
*
|
|
30
|
+
* This can be thrown by a Snap to indicate that the request is invalid, without
|
|
31
|
+
* crashing the Snap.
|
|
32
|
+
*
|
|
33
|
+
* @see https://www.jsonrpc.org/specification#error_object
|
|
34
|
+
*/ export const InvalidRequestError = createSnapError(rpcErrors.invalidRequest);
|
|
35
|
+
/**
|
|
36
|
+
* An Ethereum JSON-RPC Limit Exceeded (-32005) error.
|
|
37
|
+
*
|
|
38
|
+
* This can be thrown by a Snap to indicate that a limit has been exceeded,
|
|
39
|
+
* without crashing the Snap.
|
|
40
|
+
*
|
|
41
|
+
* @see https://eips.ethereum.org/EIPS/eip-1474#error-codes
|
|
42
|
+
*/ export const LimitExceededError = createSnapError(rpcErrors.limitExceeded);
|
|
43
|
+
/**
|
|
44
|
+
* An Ethereum JSON-RPC Method Not Found (-32601) error.
|
|
45
|
+
*
|
|
46
|
+
* This can be thrown by a Snap to indicate that a method does not exist,
|
|
47
|
+
* without crashing the Snap.
|
|
48
|
+
*
|
|
49
|
+
* @see https://eips.ethereum.org/EIPS/eip-1474#error-codes
|
|
50
|
+
*/ export const MethodNotFoundError = createSnapError(rpcErrors.methodNotFound);
|
|
51
|
+
/**
|
|
52
|
+
* An Ethereum JSON-RPC Method Not Supported (-32004) error.
|
|
53
|
+
*
|
|
54
|
+
* This can be thrown by a Snap to indicate that a method is not supported,
|
|
55
|
+
* without crashing the Snap.
|
|
56
|
+
*/ export const MethodNotSupportedError = createSnapError(rpcErrors.methodNotSupported);
|
|
57
|
+
/**
|
|
58
|
+
* A JSON-RPC 2.0 Parse (-32700) error.
|
|
59
|
+
*
|
|
60
|
+
* This can be thrown by a Snap to indicate that a request is not valid JSON,
|
|
61
|
+
* without crashing the Snap.
|
|
62
|
+
*
|
|
63
|
+
* @see https://www.jsonrpc.org/specification#error_object
|
|
64
|
+
*/ export const ParseError = createSnapError(rpcErrors.parse);
|
|
65
|
+
/**
|
|
66
|
+
* An Ethereum JSON-RPC Resource Not Found (-32001) error.
|
|
67
|
+
*
|
|
68
|
+
* This can be thrown by a Snap to indicate that a resource does not exist,
|
|
69
|
+
* without crashing the Snap.
|
|
70
|
+
*
|
|
71
|
+
* @see https://eips.ethereum.org/EIPS/eip-1474#error-codes
|
|
72
|
+
*/ export const ResourceNotFoundError = createSnapError(rpcErrors.resourceNotFound);
|
|
73
|
+
/**
|
|
74
|
+
* An Ethereum JSON-RPC Resource Unavailable (-32002) error.
|
|
75
|
+
*
|
|
76
|
+
* This can be thrown by a Snap to indicate that a resource is unavailable,
|
|
77
|
+
* without crashing the Snap.
|
|
78
|
+
*
|
|
79
|
+
* @see https://eips.ethereum.org/EIPS/eip-1474#error-codes
|
|
80
|
+
*/ export const ResourceUnavailableError = createSnapError(rpcErrors.resourceUnavailable);
|
|
81
|
+
/**
|
|
82
|
+
* An Ethereum JSON-RPC Transaction Rejected (-32003) error.
|
|
83
|
+
*
|
|
84
|
+
* This can be thrown by a Snap to indicate that a transaction was rejected,
|
|
85
|
+
* without crashing the Snap.
|
|
86
|
+
*
|
|
87
|
+
* @see https://eips.ethereum.org/EIPS/eip-1474#error-codes
|
|
88
|
+
*/ export const TransactionRejected = createSnapError(rpcErrors.transactionRejected);
|
|
89
|
+
/**
|
|
90
|
+
* An Ethereum Provider Chain Disconnected (4901) error.
|
|
91
|
+
*
|
|
92
|
+
* This can be thrown by a Snap to indicate that the provider is disconnected
|
|
93
|
+
* from the requested chain, without crashing the Snap.
|
|
94
|
+
*
|
|
95
|
+
* @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors
|
|
96
|
+
*/ export const ChainDisconnectedError = createSnapError(providerErrors.chainDisconnected);
|
|
97
|
+
/**
|
|
98
|
+
* An Ethereum Provider Disconnected (4900) error.
|
|
99
|
+
*
|
|
100
|
+
* This can be thrown by a Snap to indicate that the provider is disconnected,
|
|
101
|
+
* without crashing the Snap.
|
|
102
|
+
*
|
|
103
|
+
* @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors
|
|
104
|
+
*/ export const DisconnectedError = createSnapError(providerErrors.disconnected);
|
|
105
|
+
/**
|
|
106
|
+
* An Ethereum Provider Unauthorized (4100) error.
|
|
107
|
+
*
|
|
108
|
+
* This can be thrown by a Snap to indicate that the requested method / account
|
|
109
|
+
* is not authorized by the user, without crashing the Snap.
|
|
110
|
+
*/ export const UnauthorizedError = createSnapError(providerErrors.unauthorized);
|
|
111
|
+
/**
|
|
112
|
+
* An Ethereum Provider Unsupported Method (4200) error.
|
|
113
|
+
*
|
|
114
|
+
* This can be thrown by a Snap to indicate that the requested method is not
|
|
115
|
+
* supported by the provider, without crashing the Snap.
|
|
116
|
+
*
|
|
117
|
+
* @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors
|
|
118
|
+
*/ export const UnsupportedMethodError = createSnapError(providerErrors.unsupportedMethod);
|
|
119
|
+
/**
|
|
120
|
+
* An Ethereum Provider User Rejected Request (4001) error.
|
|
121
|
+
*
|
|
122
|
+
* This can be thrown by a Snap to indicate that the user rejected the request,
|
|
123
|
+
* without crashing the Snap.
|
|
124
|
+
*
|
|
125
|
+
* @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors
|
|
126
|
+
*/ export const UserRejectedRequestError = createSnapError(providerErrors.userRejectedRequest);
|
|
127
|
+
|
|
128
|
+
//# sourceMappingURL=error-wrappers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/error-wrappers.ts"],"sourcesContent":["import { providerErrors, rpcErrors } from '@metamask/rpc-errors';\n\nimport { createSnapError } from './internals';\n\n/**\n * A JSON-RPC 2.0 Internal (-32603) error.\n *\n * This can be thrown by a Snap to indicate that an internal error occurred,\n * without crashing the Snap.\n *\n * @see https://www.jsonrpc.org/specification#error_object\n */\nexport const InternalError = createSnapError(rpcErrors.internal);\n\n/**\n * An Ethereum JSON-RPC Invalid Input (-32000) error.\n *\n * This can be thrown by a Snap to indicate that the input to a method is\n * invalid, without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1474#error-codes\n */\nexport const InvalidInputError = createSnapError(rpcErrors.invalidInput);\n\n/**\n * A JSON-RPC 2.0 Invalid Params (-32602) error.\n *\n * This can be thrown by a Snap to indicate that the parameters to a method are\n * invalid, without crashing the Snap.\n *\n * @see https://www.jsonrpc.org/specification#error_object\n */\nexport const InvalidParamsError = createSnapError(rpcErrors.invalidParams);\n\n/**\n * A JSON-RPC 2.0 Invalid Request (-32600) error.\n *\n * This can be thrown by a Snap to indicate that the request is invalid, without\n * crashing the Snap.\n *\n * @see https://www.jsonrpc.org/specification#error_object\n */\nexport const InvalidRequestError = createSnapError(rpcErrors.invalidRequest);\n\n/**\n * An Ethereum JSON-RPC Limit Exceeded (-32005) error.\n *\n * This can be thrown by a Snap to indicate that a limit has been exceeded,\n * without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1474#error-codes\n */\nexport const LimitExceededError = createSnapError(rpcErrors.limitExceeded);\n\n/**\n * An Ethereum JSON-RPC Method Not Found (-32601) error.\n *\n * This can be thrown by a Snap to indicate that a method does not exist,\n * without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1474#error-codes\n */\nexport const MethodNotFoundError = createSnapError(rpcErrors.methodNotFound);\n\n/**\n * An Ethereum JSON-RPC Method Not Supported (-32004) error.\n *\n * This can be thrown by a Snap to indicate that a method is not supported,\n * without crashing the Snap.\n */\nexport const MethodNotSupportedError = createSnapError(\n rpcErrors.methodNotSupported,\n);\n\n/**\n * A JSON-RPC 2.0 Parse (-32700) error.\n *\n * This can be thrown by a Snap to indicate that a request is not valid JSON,\n * without crashing the Snap.\n *\n * @see https://www.jsonrpc.org/specification#error_object\n */\nexport const ParseError = createSnapError(rpcErrors.parse);\n\n/**\n * An Ethereum JSON-RPC Resource Not Found (-32001) error.\n *\n * This can be thrown by a Snap to indicate that a resource does not exist,\n * without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1474#error-codes\n */\nexport const ResourceNotFoundError = createSnapError(\n rpcErrors.resourceNotFound,\n);\n\n/**\n * An Ethereum JSON-RPC Resource Unavailable (-32002) error.\n *\n * This can be thrown by a Snap to indicate that a resource is unavailable,\n * without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1474#error-codes\n */\nexport const ResourceUnavailableError = createSnapError(\n rpcErrors.resourceUnavailable,\n);\n\n/**\n * An Ethereum JSON-RPC Transaction Rejected (-32003) error.\n *\n * This can be thrown by a Snap to indicate that a transaction was rejected,\n * without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1474#error-codes\n */\nexport const TransactionRejected = createSnapError(\n rpcErrors.transactionRejected,\n);\n\n/**\n * An Ethereum Provider Chain Disconnected (4901) error.\n *\n * This can be thrown by a Snap to indicate that the provider is disconnected\n * from the requested chain, without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors\n */\nexport const ChainDisconnectedError = createSnapError(\n providerErrors.chainDisconnected,\n);\n\n/**\n * An Ethereum Provider Disconnected (4900) error.\n *\n * This can be thrown by a Snap to indicate that the provider is disconnected,\n * without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors\n */\nexport const DisconnectedError = createSnapError(providerErrors.disconnected);\n\n/**\n * An Ethereum Provider Unauthorized (4100) error.\n *\n * This can be thrown by a Snap to indicate that the requested method / account\n * is not authorized by the user, without crashing the Snap.\n */\nexport const UnauthorizedError = createSnapError(providerErrors.unauthorized);\n\n/**\n * An Ethereum Provider Unsupported Method (4200) error.\n *\n * This can be thrown by a Snap to indicate that the requested method is not\n * supported by the provider, without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors\n */\nexport const UnsupportedMethodError = createSnapError(\n providerErrors.unsupportedMethod,\n);\n\n/**\n * An Ethereum Provider User Rejected Request (4001) error.\n *\n * This can be thrown by a Snap to indicate that the user rejected the request,\n * without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors\n */\nexport const UserRejectedRequestError = createSnapError(\n providerErrors.userRejectedRequest,\n);\n"],"names":["providerErrors","rpcErrors","createSnapError","InternalError","internal","InvalidInputError","invalidInput","InvalidParamsError","invalidParams","InvalidRequestError","invalidRequest","LimitExceededError","limitExceeded","MethodNotFoundError","methodNotFound","MethodNotSupportedError","methodNotSupported","ParseError","parse","ResourceNotFoundError","resourceNotFound","ResourceUnavailableError","resourceUnavailable","TransactionRejected","transactionRejected","ChainDisconnectedError","chainDisconnected","DisconnectedError","disconnected","UnauthorizedError","unauthorized","UnsupportedMethodError","unsupportedMethod","UserRejectedRequestError","userRejectedRequest"],"mappings":"AAAA,SAASA,cAAc,EAAEC,SAAS,QAAQ,uBAAuB;AAEjE,SAASC,eAAe,QAAQ,cAAc;AAE9C;;;;;;;CAOC,GACD,OAAO,MAAMC,gBAAgBD,gBAAgBD,UAAUG,QAAQ,EAAE;AAEjE;;;;;;;CAOC,GACD,OAAO,MAAMC,oBAAoBH,gBAAgBD,UAAUK,YAAY,EAAE;AAEzE;;;;;;;CAOC,GACD,OAAO,MAAMC,qBAAqBL,gBAAgBD,UAAUO,aAAa,EAAE;AAE3E;;;;;;;CAOC,GACD,OAAO,MAAMC,sBAAsBP,gBAAgBD,UAAUS,cAAc,EAAE;AAE7E;;;;;;;CAOC,GACD,OAAO,MAAMC,qBAAqBT,gBAAgBD,UAAUW,aAAa,EAAE;AAE3E;;;;;;;CAOC,GACD,OAAO,MAAMC,sBAAsBX,gBAAgBD,UAAUa,cAAc,EAAE;AAE7E;;;;;CAKC,GACD,OAAO,MAAMC,0BAA0Bb,gBACrCD,UAAUe,kBAAkB,EAC5B;AAEF;;;;;;;CAOC,GACD,OAAO,MAAMC,aAAaf,gBAAgBD,UAAUiB,KAAK,EAAE;AAE3D;;;;;;;CAOC,GACD,OAAO,MAAMC,wBAAwBjB,gBACnCD,UAAUmB,gBAAgB,EAC1B;AAEF;;;;;;;CAOC,GACD,OAAO,MAAMC,2BAA2BnB,gBACtCD,UAAUqB,mBAAmB,EAC7B;AAEF;;;;;;;CAOC,GACD,OAAO,MAAMC,sBAAsBrB,gBACjCD,UAAUuB,mBAAmB,EAC7B;AAEF;;;;;;;CAOC,GACD,OAAO,MAAMC,yBAAyBvB,gBACpCF,eAAe0B,iBAAiB,EAChC;AAEF;;;;;;;CAOC,GACD,OAAO,MAAMC,oBAAoBzB,gBAAgBF,eAAe4B,YAAY,EAAE;AAE9E;;;;;CAKC,GACD,OAAO,MAAMC,oBAAoB3B,gBAAgBF,eAAe8B,YAAY,EAAE;AAE9E;;;;;;;CAOC,GACD,OAAO,MAAMC,yBAAyB7B,gBACpCF,eAAegC,iBAAiB,EAChC;AAEF;;;;;;;CAOC,GACD,OAAO,MAAMC,2BAA2B/B,gBACtCF,eAAekC,mBAAmB,EAClC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Only internals that are used by other Snaps packages should be exported here.
|
|
2
|
-
export { getErrorData, getErrorMessage, getErrorStack, SNAP_ERROR_CODE, SNAP_ERROR_MESSAGE } from './internals';
|
|
2
|
+
export { getErrorData, getErrorMessage, getErrorStack, SNAP_ERROR_CODE, SNAP_ERROR_MESSAGE, literal, union, enumValue } from './internals';
|
|
3
3
|
export * from './errors';
|
|
4
4
|
export * from './types';
|
|
5
5
|
export * from './ui';
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Only internals that are used by other Snaps packages should be exported here.\nexport type { EnumToUnion } from './internals';\nexport {\n getErrorData,\n getErrorMessage,\n getErrorStack,\n SNAP_ERROR_CODE,\n SNAP_ERROR_MESSAGE,\n} from './internals';\n\n// Re-exported from `@metamask/utils` for convenience.\nexport type {\n Json,\n JsonRpcError,\n JsonRpcRequest,\n JsonRpcParams,\n} from '@metamask/utils';\n\nexport * from './errors';\nexport * from './types';\nexport * from './ui';\n"],"names":["getErrorData","getErrorMessage","getErrorStack","SNAP_ERROR_CODE","SNAP_ERROR_MESSAGE"],"mappings":"AAAA,gFAAgF;AAEhF,SACEA,YAAY,EACZC,eAAe,EACfC,aAAa,EACbC,eAAe,EACfC,kBAAkB,
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Only internals that are used by other Snaps packages should be exported here.\nexport type { EnumToUnion } from './internals';\nexport {\n getErrorData,\n getErrorMessage,\n getErrorStack,\n SNAP_ERROR_CODE,\n SNAP_ERROR_MESSAGE,\n literal,\n union,\n enumValue,\n} from './internals';\n\n// Re-exported from `@metamask/utils` for convenience.\nexport type {\n Json,\n JsonRpcError,\n JsonRpcRequest,\n JsonRpcParams,\n} from '@metamask/utils';\n\nexport * from './errors';\nexport * from './types';\nexport * from './ui';\n"],"names":["getErrorData","getErrorMessage","getErrorStack","SNAP_ERROR_CODE","SNAP_ERROR_MESSAGE","literal","union","enumValue"],"mappings":"AAAA,gFAAgF;AAEhF,SACEA,YAAY,EACZC,eAAe,EACfC,aAAa,EACbC,eAAe,EACfC,kBAAkB,EAClBC,OAAO,EACPC,KAAK,EACLC,SAAS,QACJ,cAAc;AAUrB,cAAc,WAAW;AACzB,cAAc,UAAU;AACxB,cAAc,OAAO"}
|