@metamask/snaps-sdk 0.0.0 → 1.0.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 +6 -1
- package/dist/cjs/errors.js +157 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/index.js +44 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/internals/errors.js +59 -0
- package/dist/cjs/internals/errors.js.map +1 -0
- package/dist/cjs/internals/helpers.js +6 -0
- package/dist/cjs/internals/helpers.js.map +1 -0
- package/dist/cjs/internals/index.js +21 -0
- package/dist/cjs/internals/index.js.map +1 -0
- package/dist/cjs/types/caip.js +10 -0
- package/dist/cjs/types/caip.js.map +1 -0
- package/dist/cjs/types/global.js +6 -0
- package/dist/cjs/types/global.js.map +1 -0
- package/dist/cjs/types/handlers/cronjob.js +6 -0
- package/dist/cjs/types/handlers/cronjob.js.map +1 -0
- package/dist/cjs/types/handlers/home-page.js +6 -0
- package/dist/cjs/types/handlers/home-page.js.map +1 -0
- package/dist/cjs/types/handlers/index.js +26 -0
- package/dist/cjs/types/handlers/index.js.map +1 -0
- package/dist/cjs/types/handlers/keyring.js +6 -0
- package/dist/cjs/types/handlers/keyring.js.map +1 -0
- package/dist/cjs/types/handlers/lifecycle.js +6 -0
- package/dist/cjs/types/handlers/lifecycle.js.map +1 -0
- package/dist/cjs/types/handlers/name-lookup.js +6 -0
- package/dist/cjs/types/handlers/name-lookup.js.map +1 -0
- package/dist/cjs/types/handlers/rpc-request.js +6 -0
- package/dist/cjs/types/handlers/rpc-request.js.map +1 -0
- package/dist/cjs/types/handlers/transaction.js +16 -0
- package/dist/cjs/types/handlers/transaction.js.map +1 -0
- package/dist/cjs/types/index.js +28 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/types/methods/dialog.js +18 -0
- package/dist/cjs/types/methods/dialog.js.map +1 -0
- package/dist/cjs/types/methods/get-bip32-entropy.js +6 -0
- package/dist/cjs/types/methods/get-bip32-entropy.js.map +1 -0
- package/dist/cjs/types/methods/get-bip32-public-key.js +6 -0
- package/dist/cjs/types/methods/get-bip32-public-key.js.map +1 -0
- package/dist/cjs/types/methods/get-bip44-entropy.js +6 -0
- package/dist/cjs/types/methods/get-bip44-entropy.js.map +1 -0
- package/dist/cjs/types/methods/get-entropy.js +6 -0
- package/dist/cjs/types/methods/get-entropy.js.map +1 -0
- package/dist/cjs/types/methods/get-file.js +18 -0
- package/dist/cjs/types/methods/get-file.js.map +1 -0
- package/dist/cjs/types/methods/get-locale.js +10 -0
- package/dist/cjs/types/methods/get-locale.js.map +1 -0
- package/dist/cjs/types/methods/get-snaps.js +6 -0
- package/dist/cjs/types/methods/get-snaps.js.map +1 -0
- package/dist/cjs/types/methods/index.js +34 -0
- package/dist/cjs/types/methods/index.js.map +1 -0
- package/dist/cjs/types/methods/invoke-keyring.js +6 -0
- package/dist/cjs/types/methods/invoke-keyring.js.map +1 -0
- package/dist/cjs/types/methods/invoke-snap.js +6 -0
- package/dist/cjs/types/methods/invoke-snap.js.map +1 -0
- package/dist/cjs/types/methods/manage-accounts.js +6 -0
- package/dist/cjs/types/methods/manage-accounts.js.map +1 -0
- package/dist/cjs/types/methods/manage-state.js +18 -0
- package/dist/cjs/types/methods/manage-state.js.map +1 -0
- package/dist/cjs/types/methods/methods.js +6 -0
- package/dist/cjs/types/methods/methods.js.map +1 -0
- package/dist/cjs/types/methods/notify.js +17 -0
- package/dist/cjs/types/methods/notify.js.map +1 -0
- package/dist/cjs/types/methods/request-snaps.js +6 -0
- package/dist/cjs/types/methods/request-snaps.js.map +1 -0
- package/dist/cjs/types/permissions.js +6 -0
- package/dist/cjs/types/permissions.js.map +1 -0
- package/dist/cjs/types/provider.js +6 -0
- package/dist/cjs/types/provider.js.map +1 -0
- package/dist/cjs/types/snap.js +6 -0
- package/dist/cjs/types/snap.js.map +1 -0
- package/dist/cjs/ui/builder.js +44 -0
- package/dist/cjs/ui/builder.js.map +1 -0
- package/dist/cjs/ui/component.js +29 -0
- package/dist/cjs/ui/component.js.map +1 -0
- package/dist/cjs/ui/components/copyable.js +32 -0
- package/dist/cjs/ui/components/copyable.js.map +1 -0
- package/dist/cjs/ui/components/divider.js +27 -0
- package/dist/cjs/ui/components/divider.js.map +1 -0
- package/dist/cjs/ui/components/heading.js +30 -0
- package/dist/cjs/ui/components/heading.js.map +1 -0
- package/dist/cjs/ui/components/image.js +47 -0
- package/dist/cjs/ui/components/image.js.map +1 -0
- package/dist/cjs/ui/components/index.js +49 -0
- package/dist/cjs/ui/components/index.js.map +1 -0
- package/dist/cjs/ui/components/panel.js +55 -0
- package/dist/cjs/ui/components/panel.js.map +1 -0
- package/dist/cjs/ui/components/spinner.js +27 -0
- package/dist/cjs/ui/components/spinner.js.map +1 -0
- package/dist/cjs/ui/components/text.js +32 -0
- package/dist/cjs/ui/components/text.js.map +1 -0
- package/dist/cjs/ui/index.js +28 -0
- package/dist/cjs/ui/index.js.map +1 -0
- package/dist/cjs/ui/nodes.js +41 -0
- package/dist/cjs/ui/nodes.js.map +1 -0
- package/dist/esm/errors.js +150 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/index.js +5 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/internals/errors.js +58 -0
- package/dist/esm/internals/errors.js.map +1 -0
- package/dist/esm/internals/helpers.js +3 -0
- package/dist/esm/internals/helpers.js.map +1 -0
- package/dist/esm/internals/index.js +4 -0
- package/dist/esm/internals/index.js.map +1 -0
- package/dist/esm/types/caip.js +7 -0
- package/dist/esm/types/caip.js.map +1 -0
- package/dist/esm/types/global.js +3 -0
- package/dist/esm/types/global.js.map +1 -0
- package/dist/esm/types/handlers/cronjob.js +3 -0
- package/dist/esm/types/handlers/cronjob.js.map +1 -0
- package/dist/esm/types/handlers/home-page.js +3 -0
- package/dist/esm/types/handlers/home-page.js.map +1 -0
- package/dist/esm/types/handlers/index.js +9 -0
- package/dist/esm/types/handlers/index.js.map +1 -0
- package/dist/esm/types/handlers/keyring.js +3 -0
- package/dist/esm/types/handlers/keyring.js.map +1 -0
- package/dist/esm/types/handlers/lifecycle.js +3 -0
- package/dist/esm/types/handlers/lifecycle.js.map +1 -0
- package/dist/esm/types/handlers/name-lookup.js +3 -0
- package/dist/esm/types/handlers/name-lookup.js.map +1 -0
- package/dist/esm/types/handlers/rpc-request.js +3 -0
- package/dist/esm/types/handlers/rpc-request.js.map +1 -0
- package/dist/esm/types/handlers/transaction.js +6 -0
- package/dist/esm/types/handlers/transaction.js.map +1 -0
- package/dist/esm/types/index.js +11 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/methods/dialog.js +8 -0
- package/dist/esm/types/methods/dialog.js.map +1 -0
- package/dist/esm/types/methods/get-bip32-entropy.js +3 -0
- package/dist/esm/types/methods/get-bip32-entropy.js.map +1 -0
- package/dist/esm/types/methods/get-bip32-public-key.js +3 -0
- package/dist/esm/types/methods/get-bip32-public-key.js.map +1 -0
- package/dist/esm/types/methods/get-bip44-entropy.js +3 -0
- package/dist/esm/types/methods/get-bip44-entropy.js.map +1 -0
- package/dist/esm/types/methods/get-entropy.js +3 -0
- package/dist/esm/types/methods/get-entropy.js.map +1 -0
- package/dist/esm/types/methods/get-file.js +8 -0
- package/dist/esm/types/methods/get-file.js.map +1 -0
- package/dist/esm/types/methods/get-locale.js +7 -0
- package/dist/esm/types/methods/get-locale.js.map +1 -0
- package/dist/esm/types/methods/get-snaps.js +3 -0
- package/dist/esm/types/methods/get-snaps.js.map +1 -0
- package/dist/esm/types/methods/index.js +17 -0
- package/dist/esm/types/methods/index.js.map +1 -0
- package/dist/esm/types/methods/invoke-keyring.js +3 -0
- package/dist/esm/types/methods/invoke-keyring.js.map +1 -0
- package/dist/esm/types/methods/invoke-snap.js +3 -0
- package/dist/esm/types/methods/invoke-snap.js.map +1 -0
- package/dist/esm/types/methods/manage-accounts.js +3 -0
- package/dist/esm/types/methods/manage-accounts.js.map +1 -0
- package/dist/esm/types/methods/manage-state.js +8 -0
- package/dist/esm/types/methods/manage-state.js.map +1 -0
- package/dist/esm/types/methods/methods.js +3 -0
- package/dist/esm/types/methods/methods.js.map +1 -0
- package/dist/esm/types/methods/notify.js +7 -0
- package/dist/esm/types/methods/notify.js.map +1 -0
- package/dist/esm/types/methods/request-snaps.js +3 -0
- package/dist/esm/types/methods/request-snaps.js.map +1 -0
- package/dist/esm/types/permissions.js +3 -0
- package/dist/esm/types/permissions.js.map +1 -0
- package/dist/esm/types/provider.js +3 -0
- package/dist/esm/types/provider.js.map +1 -0
- package/dist/esm/types/snap.js +3 -0
- package/dist/esm/types/snap.js.map +1 -0
- package/dist/esm/ui/builder.js +50 -0
- package/dist/esm/ui/builder.js.map +1 -0
- package/dist/esm/ui/component.js +23 -0
- package/dist/esm/ui/component.js.map +1 -0
- package/dist/esm/ui/components/copyable.js +27 -0
- package/dist/esm/ui/components/copyable.js.map +1 -0
- package/dist/esm/ui/components/divider.js +15 -0
- package/dist/esm/ui/components/divider.js.map +1 -0
- package/dist/esm/ui/components/heading.js +22 -0
- package/dist/esm/ui/components/heading.js.map +1 -0
- package/dist/esm/ui/components/image.js +37 -0
- package/dist/esm/ui/components/image.js.map +1 -0
- package/dist/esm/ui/components/index.js +9 -0
- package/dist/esm/ui/components/index.js.map +1 -0
- package/dist/esm/ui/components/panel.js +56 -0
- package/dist/esm/ui/components/panel.js.map +1 -0
- package/dist/esm/ui/components/spinner.js +15 -0
- package/dist/esm/ui/components/spinner.js.map +1 -0
- package/dist/esm/ui/components/text.js +29 -0
- package/dist/esm/ui/components/text.js.map +1 -0
- package/dist/esm/ui/index.js +5 -0
- package/dist/esm/ui/index.js.map +1 -0
- package/dist/esm/ui/nodes.js +24 -0
- package/dist/esm/ui/nodes.js.map +1 -0
- package/dist/types/errors.d.ts +88 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/internals/errors.d.ts +41 -0
- package/dist/types/internals/helpers.d.ts +36 -0
- package/dist/types/internals/index.d.ts +2 -0
- package/dist/types/types/caip.d.ts +12 -0
- package/dist/types/types/global.d.ts +8 -0
- package/dist/types/types/handlers/cronjob.d.ts +14 -0
- package/dist/types/types/handlers/home-page.d.ts +19 -0
- package/dist/types/types/handlers/index.d.ts +7 -0
- package/dist/types/types/handlers/keyring.d.ts +20 -0
- package/dist/types/types/handlers/lifecycle.d.ts +41 -0
- package/dist/types/types/handlers/name-lookup.d.ts +59 -0
- package/dist/types/types/handlers/rpc-request.d.ts +21 -0
- package/dist/types/types/handlers/transaction.d.ts +110 -0
- package/dist/types/types/index.d.ts +7 -0
- package/dist/types/types/methods/dialog.d.ts +67 -0
- package/dist/types/types/methods/get-bip32-entropy.d.ts +15 -0
- package/dist/types/types/methods/get-bip32-public-key.d.ts +19 -0
- package/dist/types/types/methods/get-bip44-entropy.d.ts +14 -0
- package/dist/types/types/methods/get-entropy.d.ts +16 -0
- package/dist/types/types/methods/get-file.d.ts +23 -0
- package/dist/types/types/methods/get-locale.d.ts +12 -0
- package/dist/types/types/methods/get-snaps.d.ts +16 -0
- package/dist/types/types/methods/index.d.ts +15 -0
- package/dist/types/types/methods/invoke-keyring.d.ts +14 -0
- package/dist/types/types/methods/invoke-snap.d.ts +16 -0
- package/dist/types/types/methods/manage-accounts.d.ts +18 -0
- package/dist/types/types/methods/manage-state.d.ts +69 -0
- package/dist/types/types/methods/methods.d.ts +62 -0
- package/dist/types/types/methods/notify.d.ts +27 -0
- package/dist/types/types/methods/request-snaps.d.ts +18 -0
- package/dist/types/types/permissions.d.ts +46 -0
- package/dist/types/types/provider.d.ts +14 -0
- package/dist/types/types/snap.d.ts +12 -0
- package/dist/types/ui/builder.d.ts +42 -0
- package/dist/types/ui/component.d.ts +17 -0
- package/dist/types/ui/components/copyable.d.ts +49 -0
- package/dist/types/ui/components/divider.d.ts +21 -0
- package/dist/types/ui/components/heading.d.ts +36 -0
- package/dist/types/ui/components/image.d.ts +42 -0
- package/dist/types/ui/components/index.d.ts +9 -0
- package/dist/types/ui/components/panel.d.ts +153 -0
- package/dist/types/ui/components/spinner.d.ts +22 -0
- package/dist/types/ui/components/text.d.ts +46 -0
- package/dist/types/ui/index.d.ts +3 -0
- package/dist/types/ui/nodes.d.ts +51 -0
- package/package.json +10 -2
package/CHANGELOG.md
CHANGED
|
@@ -6,4 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
-
[
|
|
9
|
+
## [1.0.0]
|
|
10
|
+
### Added
|
|
11
|
+
- Initial release of this package.
|
|
12
|
+
|
|
13
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@1.0.0...HEAD
|
|
14
|
+
[1.0.0]: https://github.com/MetaMask/snaps/releases/tag/@metamask/snaps-sdk@1.0.0
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "SnapError", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return SnapError;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _internals = require("./internals");
|
|
12
|
+
function _check_private_redeclaration(obj, privateCollection) {
|
|
13
|
+
if (privateCollection.has(obj)) {
|
|
14
|
+
throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
18
|
+
if (descriptor.get) {
|
|
19
|
+
return descriptor.get.call(receiver);
|
|
20
|
+
}
|
|
21
|
+
return descriptor.value;
|
|
22
|
+
}
|
|
23
|
+
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
24
|
+
if (descriptor.set) {
|
|
25
|
+
descriptor.set.call(receiver, value);
|
|
26
|
+
} else {
|
|
27
|
+
if (!descriptor.writable) {
|
|
28
|
+
throw new TypeError("attempted to set read only private field");
|
|
29
|
+
}
|
|
30
|
+
descriptor.value = value;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
34
|
+
if (!privateMap.has(receiver)) {
|
|
35
|
+
throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
36
|
+
}
|
|
37
|
+
return privateMap.get(receiver);
|
|
38
|
+
}
|
|
39
|
+
function _class_private_field_get(receiver, privateMap) {
|
|
40
|
+
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
41
|
+
return _class_apply_descriptor_get(receiver, descriptor);
|
|
42
|
+
}
|
|
43
|
+
function _class_private_field_init(obj, privateMap, value) {
|
|
44
|
+
_check_private_redeclaration(obj, privateMap);
|
|
45
|
+
privateMap.set(obj, value);
|
|
46
|
+
}
|
|
47
|
+
function _class_private_field_set(receiver, privateMap, value) {
|
|
48
|
+
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
49
|
+
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
var _code = /*#__PURE__*/ new WeakMap(), _message = /*#__PURE__*/ new WeakMap(), _data = /*#__PURE__*/ new WeakMap(), _stack = /*#__PURE__*/ new WeakMap();
|
|
53
|
+
class SnapError extends Error {
|
|
54
|
+
/**
|
|
55
|
+
* The error name.
|
|
56
|
+
*
|
|
57
|
+
* @returns The error name.
|
|
58
|
+
*/ get name() {
|
|
59
|
+
return 'SnapError';
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The error code.
|
|
63
|
+
*
|
|
64
|
+
* @returns The error code.
|
|
65
|
+
*/ get code() {
|
|
66
|
+
return _class_private_field_get(this, _code);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The error message.
|
|
70
|
+
*
|
|
71
|
+
* @returns The error message.
|
|
72
|
+
*/ // This line is covered, but Jest doesn't pick it up for some reason.
|
|
73
|
+
/* istanbul ignore next */ get message() {
|
|
74
|
+
return _class_private_field_get(this, _message);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Additional data for the error.
|
|
78
|
+
*
|
|
79
|
+
* @returns Additional data for the error.
|
|
80
|
+
*/ get data() {
|
|
81
|
+
return _class_private_field_get(this, _data);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The error stack.
|
|
85
|
+
*
|
|
86
|
+
* @returns The error stack.
|
|
87
|
+
*/ // This line is covered, but Jest doesn't pick it up for some reason.
|
|
88
|
+
/* istanbul ignore next */ get stack() {
|
|
89
|
+
return _class_private_field_get(this, _stack);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Convert the error to a JSON object.
|
|
93
|
+
*
|
|
94
|
+
* @returns The JSON object.
|
|
95
|
+
*/ toJSON() {
|
|
96
|
+
return {
|
|
97
|
+
code: _internals.SNAP_ERROR_CODE,
|
|
98
|
+
message: _internals.SNAP_ERROR_MESSAGE,
|
|
99
|
+
data: {
|
|
100
|
+
cause: {
|
|
101
|
+
code: this.code,
|
|
102
|
+
message: this.message,
|
|
103
|
+
stack: this.stack,
|
|
104
|
+
data: this.data
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Serialize the error to a JSON object. This is called by
|
|
111
|
+
* `@metamask/rpc-errors` when serializing the error.
|
|
112
|
+
*
|
|
113
|
+
* @returns The JSON object.
|
|
114
|
+
*/ serialize() {
|
|
115
|
+
return this.toJSON();
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Create a new `SnapError`.
|
|
119
|
+
*
|
|
120
|
+
* @param error - The error to create the `SnapError` from. If this is a
|
|
121
|
+
* `string`, it will be used as the error message. If this is an `Error`, its
|
|
122
|
+
* `message` property will be used as the error message. If this is a
|
|
123
|
+
* `JsonRpcError`, its `message` property will be used as the error message
|
|
124
|
+
* and its `code` property will be used as the error code. Otherwise, the
|
|
125
|
+
* error will be converted to a string and used as the error message.
|
|
126
|
+
* @param data - Additional data to include in the error. This will be merged
|
|
127
|
+
* with the error data, if any.
|
|
128
|
+
*/ constructor(error, data = {}){
|
|
129
|
+
const message = (0, _internals.getErrorMessage)(error);
|
|
130
|
+
super(message);
|
|
131
|
+
_class_private_field_init(this, _code, {
|
|
132
|
+
writable: true,
|
|
133
|
+
value: void 0
|
|
134
|
+
});
|
|
135
|
+
_class_private_field_init(this, _message, {
|
|
136
|
+
writable: true,
|
|
137
|
+
value: void 0
|
|
138
|
+
});
|
|
139
|
+
_class_private_field_init(this, _data, {
|
|
140
|
+
writable: true,
|
|
141
|
+
value: void 0
|
|
142
|
+
});
|
|
143
|
+
_class_private_field_init(this, _stack, {
|
|
144
|
+
writable: true,
|
|
145
|
+
value: void 0
|
|
146
|
+
});
|
|
147
|
+
_class_private_field_set(this, _message, message);
|
|
148
|
+
_class_private_field_set(this, _code, (0, _internals.getErrorCode)(error));
|
|
149
|
+
_class_private_field_set(this, _data, {
|
|
150
|
+
...(0, _internals.getErrorData)(error),
|
|
151
|
+
...data
|
|
152
|
+
});
|
|
153
|
+
_class_private_field_set(this, _stack, super.stack);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/errors.ts"],"sourcesContent":["import type { Json, JsonRpcError } from '@metamask/utils';\n\nimport {\n getErrorCode,\n getErrorData,\n getErrorMessage,\n SNAP_ERROR_CODE,\n SNAP_ERROR_MESSAGE,\n} from './internals';\n\n/**\n * A generic error which can be thrown by a Snap, without it causing the Snap to\n * crash.\n */\nexport class SnapError extends Error {\n readonly #code: number;\n\n readonly #message: string;\n\n readonly #data: Record<string, Json>;\n\n readonly #stack?: string;\n\n /**\n * Create a new `SnapError`.\n *\n * @param error - The error to create the `SnapError` from. If this is a\n * `string`, it will be used as the error message. If this is an `Error`, its\n * `message` property will be used as the error message. If this is a\n * `JsonRpcError`, its `message` property will be used as the error message\n * and its `code` property will be used as the error code. Otherwise, the\n * error will be converted to a string and used as the error message.\n * @param data - Additional data to include in the error. This will be merged\n * with the error data, if any.\n */\n constructor(\n error: string | Error | JsonRpcError,\n data: Record<string, Json> = {},\n ) {\n const message = getErrorMessage(error);\n super(message);\n\n this.#message = message;\n this.#code = getErrorCode(error);\n this.#data = { ...getErrorData(error), ...data };\n this.#stack = super.stack;\n }\n\n /**\n * The error name.\n *\n * @returns The error name.\n */\n get name() {\n return 'SnapError';\n }\n\n /**\n * The error code.\n *\n * @returns The error code.\n */\n get code() {\n return this.#code;\n }\n\n /**\n * The error message.\n *\n * @returns The error message.\n */\n // This line is covered, but Jest doesn't pick it up for some reason.\n /* istanbul ignore next */\n get message() {\n return this.#message;\n }\n\n /**\n * Additional data for the error.\n *\n * @returns Additional data for the error.\n */\n get data() {\n return this.#data;\n }\n\n /**\n * The error stack.\n *\n * @returns The error stack.\n */\n // This line is covered, but Jest doesn't pick it up for some reason.\n /* istanbul ignore next */\n get stack() {\n return this.#stack;\n }\n\n /**\n * Convert the error to a JSON object.\n *\n * @returns The JSON object.\n */\n toJSON(): SerializedSnapError {\n return {\n code: SNAP_ERROR_CODE,\n message: SNAP_ERROR_MESSAGE,\n data: {\n cause: {\n code: this.code,\n message: this.message,\n stack: this.stack,\n data: this.data,\n },\n },\n };\n }\n\n /**\n * Serialize the error to a JSON object. This is called by\n * `@metamask/rpc-errors` when serializing the error.\n *\n * @returns The JSON object.\n */\n serialize() {\n return this.toJSON();\n }\n}\n\n/**\n * A serialized {@link SnapError}. It's JSON-serializable, so it can be sent\n * over the RPC. The original error is wrapped in the `cause` property.\n *\n * @property code - The error code. This is always `-31002`.\n * @property message - The error message. This is always `'Snap Error'`.\n * @property data - The error data.\n * @property data.cause - The cause of the error.\n * @property data.cause.code - The error code.\n * @property data.cause.message - The error message.\n * @property data.cause.stack - The error stack.\n * @property data.cause.data - Additional data for the error.\n * @see SnapError\n */\nexport type SerializedSnapError = {\n code: typeof SNAP_ERROR_CODE;\n message: typeof SNAP_ERROR_MESSAGE;\n data: {\n cause: JsonRpcError & {\n data: Record<string, Json>;\n };\n };\n};\n"],"names":["SnapError","Error","name","code","message","data","stack","toJSON","SNAP_ERROR_CODE","SNAP_ERROR_MESSAGE","cause","serialize","constructor","error","getErrorMessage","getErrorCode","getErrorData"],"mappings":";;;;+BAcaA;;;eAAAA;;;2BANN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAOI,qCAEA,wCAEA,qCAEA;AAPJ,MAAMA,kBAAkBC;IAkC7B;;;;GAIC,GACD,IAAIC,OAAO;QACT,OAAO;IACT;IAEA;;;;GAIC,GACD,IAAIC,OAAO;QACT,gCAAO,IAAI,EAAEA;IACf;IAEA;;;;GAIC,GACD,qEAAqE;IACrE,wBAAwB,GACxB,IAAIC,UAAU;QACZ,gCAAO,IAAI,EAAEA;IACf;IAEA;;;;GAIC,GACD,IAAIC,OAAO;QACT,gCAAO,IAAI,EAAEA;IACf;IAEA;;;;GAIC,GACD,qEAAqE;IACrE,wBAAwB,GACxB,IAAIC,QAAQ;QACV,gCAAO,IAAI,EAAEA;IACf;IAEA;;;;GAIC,GACDC,SAA8B;QAC5B,OAAO;YACLJ,MAAMK,0BAAe;YACrBJ,SAASK,6BAAkB;YAC3BJ,MAAM;gBACJK,OAAO;oBACLP,MAAM,IAAI,CAACA,IAAI;oBACfC,SAAS,IAAI,CAACA,OAAO;oBACrBE,OAAO,IAAI,CAACA,KAAK;oBACjBD,MAAM,IAAI,CAACA,IAAI;gBACjB;YACF;QACF;IACF;IAEA;;;;;GAKC,GACDM,YAAY;QACV,OAAO,IAAI,CAACJ,MAAM;IACpB;IAtGA;;;;;;;;;;;GAWC,GACDK,YACEC,KAAoC,EACpCR,OAA6B,CAAC,CAAC,CAC/B;QACA,MAAMD,UAAUU,IAAAA,0BAAe,EAACD;QAChC,KAAK,CAACT;QAzBR,gCAAS;;mBAAT,KAAA;;QAEA,gCAAS;;mBAAT,KAAA;;QAEA,gCAAS;;mBAAT,KAAA;;QAEA,gCAAS;;mBAAT,KAAA;;uCAqBQA,UAAUA;uCACVD,OAAOY,IAAAA,uBAAY,EAACF;uCACpBR,OAAO;YAAE,GAAGW,IAAAA,uBAAY,EAACH,MAAM;YAAE,GAAGR,IAAI;QAAC;uCACzCC,QAAQ,KAAK,CAACA;IACtB;AAgFF"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
|
-
//
|
|
2
|
-
// eslint-disable-next-line import/unambiguous
|
|
1
|
+
// Only internals that are used by other Snaps packages should be exported here.
|
|
3
2
|
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
function _export(target, all) {
|
|
7
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
getErrorData: function() {
|
|
14
|
+
return _internals.getErrorData;
|
|
15
|
+
},
|
|
16
|
+
getErrorMessage: function() {
|
|
17
|
+
return _internals.getErrorMessage;
|
|
18
|
+
},
|
|
19
|
+
getErrorStack: function() {
|
|
20
|
+
return _internals.getErrorStack;
|
|
21
|
+
},
|
|
22
|
+
SNAP_ERROR_CODE: function() {
|
|
23
|
+
return _internals.SNAP_ERROR_CODE;
|
|
24
|
+
},
|
|
25
|
+
SNAP_ERROR_MESSAGE: function() {
|
|
26
|
+
return _internals.SNAP_ERROR_MESSAGE;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
const _internals = require("./internals");
|
|
30
|
+
_export_star(require("./errors"), exports);
|
|
31
|
+
_export_star(require("./types"), exports);
|
|
32
|
+
_export_star(require("./ui"), exports);
|
|
33
|
+
function _export_star(from, to) {
|
|
34
|
+
Object.keys(from).forEach(function(k) {
|
|
35
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
36
|
+
Object.defineProperty(to, k, {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function() {
|
|
39
|
+
return from[k];
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return from;
|
|
45
|
+
}
|
|
4
46
|
|
|
5
47
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["//
|
|
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;;;2BACb;qBAUO;qBACA;qBACA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
SNAP_ERROR_CODE: function() {
|
|
13
|
+
return SNAP_ERROR_CODE;
|
|
14
|
+
},
|
|
15
|
+
SNAP_ERROR_MESSAGE: function() {
|
|
16
|
+
return SNAP_ERROR_MESSAGE;
|
|
17
|
+
},
|
|
18
|
+
getErrorMessage: function() {
|
|
19
|
+
return getErrorMessage;
|
|
20
|
+
},
|
|
21
|
+
getErrorStack: function() {
|
|
22
|
+
return getErrorStack;
|
|
23
|
+
},
|
|
24
|
+
getErrorCode: function() {
|
|
25
|
+
return getErrorCode;
|
|
26
|
+
},
|
|
27
|
+
getErrorData: function() {
|
|
28
|
+
return getErrorData;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const _utils = require("@metamask/utils");
|
|
32
|
+
const SNAP_ERROR_CODE = -31002;
|
|
33
|
+
const SNAP_ERROR_MESSAGE = 'Snap Error';
|
|
34
|
+
function getErrorMessage(error) {
|
|
35
|
+
if ((0, _utils.isObject)(error) && (0, _utils.hasProperty)(error, 'message') && typeof error.message === 'string') {
|
|
36
|
+
return error.message;
|
|
37
|
+
}
|
|
38
|
+
return String(error);
|
|
39
|
+
}
|
|
40
|
+
function getErrorStack(error) {
|
|
41
|
+
if ((0, _utils.isObject)(error) && (0, _utils.hasProperty)(error, 'stack') && typeof error.stack === 'string') {
|
|
42
|
+
return error.stack;
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
function getErrorCode(error) {
|
|
47
|
+
if ((0, _utils.isObject)(error) && (0, _utils.hasProperty)(error, 'code') && typeof error.code === 'number' && Number.isInteger(error.code)) {
|
|
48
|
+
return error.code;
|
|
49
|
+
}
|
|
50
|
+
return -32603;
|
|
51
|
+
}
|
|
52
|
+
function getErrorData(error) {
|
|
53
|
+
if ((0, _utils.isObject)(error) && (0, _utils.hasProperty)(error, 'data') && typeof error.data === 'object' && error.data !== null && (0, _utils.isValidJson)(error.data) && !Array.isArray(error.data)) {
|
|
54
|
+
return error.data;
|
|
55
|
+
}
|
|
56
|
+
return {};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/internals/errors.ts"],"sourcesContent":["import { hasProperty, isObject, isValidJson } from '@metamask/utils';\n\nexport const SNAP_ERROR_CODE = -31002;\nexport const SNAP_ERROR_MESSAGE = 'Snap Error';\n\n/**\n * Get the error message from an unknown error type.\n *\n * - If the error is an object with a `message` property, return the message.\n * - Otherwise, return the error converted to a string.\n *\n * @param error - The error to get the message from.\n * @returns The error message.\n * @internal\n */\nexport function getErrorMessage(error: unknown) {\n if (\n isObject(error) &&\n hasProperty(error, 'message') &&\n typeof error.message === 'string'\n ) {\n return error.message;\n }\n\n return String(error);\n}\n\n/**\n * Get the error stack from an unknown error type.\n *\n * @param error - The error to get the stack from.\n * @returns The error stack, or undefined if the error does not have a valid\n * stack.\n * @internal\n */\nexport function getErrorStack(error: unknown) {\n if (\n isObject(error) &&\n hasProperty(error, 'stack') &&\n typeof error.stack === 'string'\n ) {\n return error.stack;\n }\n\n return undefined;\n}\n\n/**\n * Get the error code from an unknown error type.\n *\n * @param error - The error to get the code from.\n * @returns The error code, or `-32603` if the error does not have a valid code.\n * @internal\n */\nexport function getErrorCode(error: unknown) {\n if (\n isObject(error) &&\n hasProperty(error, 'code') &&\n typeof error.code === 'number' &&\n Number.isInteger(error.code)\n ) {\n return error.code;\n }\n\n return -32603;\n}\n\n/**\n * Get the error data from an unknown error type.\n *\n * @param error - The error to get the data from.\n * @returns The error data, or an empty object if the error does not have valid\n * data.\n * @internal\n */\nexport function getErrorData(error: unknown) {\n if (\n isObject(error) &&\n hasProperty(error, 'data') &&\n typeof error.data === 'object' &&\n error.data !== null &&\n isValidJson(error.data) &&\n !Array.isArray(error.data)\n ) {\n return error.data;\n }\n\n return {};\n}\n"],"names":["SNAP_ERROR_CODE","SNAP_ERROR_MESSAGE","getErrorMessage","getErrorStack","getErrorCode","getErrorData","error","isObject","hasProperty","message","String","stack","undefined","code","Number","isInteger","data","isValidJson","Array","isArray"],"mappings":";;;;;;;;;;;IAEaA,eAAe;eAAfA;;IACAC,kBAAkB;eAAlBA;;IAYGC,eAAe;eAAfA;;IAoBAC,aAAa;eAAbA;;IAmBAC,YAAY;eAAZA;;IAqBAC,YAAY;eAAZA;;;uBA3EmC;AAE5C,MAAML,kBAAkB,CAAC;AACzB,MAAMC,qBAAqB;AAY3B,SAASC,gBAAgBI,KAAc;IAC5C,IACEC,IAAAA,eAAQ,EAACD,UACTE,IAAAA,kBAAW,EAACF,OAAO,cACnB,OAAOA,MAAMG,OAAO,KAAK,UACzB;QACA,OAAOH,MAAMG,OAAO;IACtB;IAEA,OAAOC,OAAOJ;AAChB;AAUO,SAASH,cAAcG,KAAc;IAC1C,IACEC,IAAAA,eAAQ,EAACD,UACTE,IAAAA,kBAAW,EAACF,OAAO,YACnB,OAAOA,MAAMK,KAAK,KAAK,UACvB;QACA,OAAOL,MAAMK,KAAK;IACpB;IAEA,OAAOC;AACT;AASO,SAASR,aAAaE,KAAc;IACzC,IACEC,IAAAA,eAAQ,EAACD,UACTE,IAAAA,kBAAW,EAACF,OAAO,WACnB,OAAOA,MAAMO,IAAI,KAAK,YACtBC,OAAOC,SAAS,CAACT,MAAMO,IAAI,GAC3B;QACA,OAAOP,MAAMO,IAAI;IACnB;IAEA,OAAO,CAAC;AACV;AAUO,SAASR,aAAaC,KAAc;IACzC,IACEC,IAAAA,eAAQ,EAACD,UACTE,IAAAA,kBAAW,EAACF,OAAO,WACnB,OAAOA,MAAMU,IAAI,KAAK,YACtBV,MAAMU,IAAI,KAAK,QACfC,IAAAA,kBAAW,EAACX,MAAMU,IAAI,KACtB,CAACE,MAAMC,OAAO,CAACb,MAAMU,IAAI,GACzB;QACA,OAAOV,MAAMU,IAAI;IACnB;IAEA,OAAO,CAAC;AACV"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/internals/helpers.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./errors"), exports);
|
|
6
|
+
_export_star(require("./helpers"), exports);
|
|
7
|
+
function _export_star(from, to) {
|
|
8
|
+
Object.keys(from).forEach(function(k) {
|
|
9
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
10
|
+
Object.defineProperty(to, k, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function() {
|
|
13
|
+
return from[k];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return from;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/internals/index.ts"],"sourcesContent":["export * from './errors';\nexport * from './helpers';\n"],"names":[],"mappings":";;;;qBAAc;qBACA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/types/caip.ts"],"sourcesContent":["/**\n * A CAIP-2 chain ID, i.e., a human-readable namespace and reference.\n *\n * @see https://chainagnostic.org/CAIPs/caip-2\n */\nexport type ChainId = `${string}:${string}`;\n\n/**\n * A CAIP-10 account ID, i.e., a chain ID and an account address.\n *\n * @see https://chainagnostic.org/CAIPs/caip-10\n */\nexport type AccountId = `${ChainId}:${string}`;\n"],"names":[],"mappings":"AAAA;;;;CAIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/types/global.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/handlers/cronjob.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/handlers/home-page.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./cronjob"), exports);
|
|
6
|
+
_export_star(require("./home-page"), exports);
|
|
7
|
+
_export_star(require("./keyring"), exports);
|
|
8
|
+
_export_star(require("./lifecycle"), exports);
|
|
9
|
+
_export_star(require("./name-lookup"), exports);
|
|
10
|
+
_export_star(require("./rpc-request"), exports);
|
|
11
|
+
_export_star(require("./transaction"), exports);
|
|
12
|
+
function _export_star(from, to) {
|
|
13
|
+
Object.keys(from).forEach(function(k) {
|
|
14
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
15
|
+
Object.defineProperty(to, k, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function() {
|
|
18
|
+
return from[k];
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return from;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/handlers/index.ts"],"sourcesContent":["export * from './cronjob';\nexport * from './home-page';\nexport * from './keyring';\nexport * from './lifecycle';\nexport * from './name-lookup';\nexport * from './rpc-request';\nexport * from './transaction';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/handlers/keyring.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/handlers/lifecycle.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/handlers/name-lookup.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/handlers/rpc-request.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "SeverityLevel", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return SeverityLevel;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var SeverityLevel;
|
|
12
|
+
(function(SeverityLevel) {
|
|
13
|
+
SeverityLevel["Critical"] = 'critical';
|
|
14
|
+
})(SeverityLevel || (SeverityLevel = {}));
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/handlers/transaction.ts"],"sourcesContent":["import type { EnumToUnion } from '../../internals';\nimport type { Component } from '../../ui';\nimport type { ChainId } from '../caip';\n\n/**\n * The severity level of content being returned from a transaction insight.\n * Currently only one level is supported:\n *\n * - `critical` - The transaction is critical and should not be submitted by the\n * user.\n */\nexport enum SeverityLevel {\n Critical = 'critical',\n}\n\n/**\n * An EIP-1559 (type 2) transaction object.\n *\n * @property from - The address the transaction is being sent from.\n * @property to - The address the transaction is being sent to.\n * @property nonce - The nonce of the transaction.\n * @property value - The value of the transaction.\n * @property data - The data of the transaction.\n * @property gas - The gas limit of the transaction.\n * @property maxFeePerGas - The maximum fee per gas of the transaction.\n * @property maxPriorityFeePerGas - The maximum priority fee per gas of the\n * transaction.\n * @property estimateSuggested - The suggested gas price for the transaction.\n * @property estimateUsed - The gas price used for the transaction.\n * @see https://eips.ethereum.org/EIPS/eip-1559\n */\nexport type EIP1559Transaction = {\n from: string;\n to: string;\n nonce: string;\n value: string;\n data: string;\n gas: string;\n maxFeePerGas: string;\n maxPriorityFeePerGas: string;\n estimateSuggested: string;\n estimateUsed: string;\n};\n\n/**\n * A legacy (type \"0\") transaction object.\n *\n * @property from - The address the transaction is being sent from.\n * @property to - The address the transaction is being sent to.\n * @property nonce - The nonce of the transaction.\n * @property value - The value of the transaction.\n * @property data - The data of the transaction.\n * @property gas - The gas limit of the transaction.\n * @property gasPrice - The gas price of the transaction.\n * @property estimateSuggested - The suggested gas price for the transaction.\n * @property estimateUsed - The gas price used for the transaction.\n */\nexport type LegacyTransaction = {\n from: string;\n to: string;\n nonce: string;\n value: string;\n data: string;\n gas: string;\n gasPrice: string;\n estimateSuggested: string;\n estimateUsed: string;\n};\n\n/**\n * A transaction object. This can be either an EIP-1559 transaction or a legacy\n * transaction.\n *\n * @see EIP1559Transaction\n * @see LegacyTransaction\n */\nexport type Transaction = EIP1559Transaction | LegacyTransaction;\n\n/**\n * The `onTransaction` handler. This is called whenever a transaction is\n * submitted to the snap. It can return insights about the transaction, which\n * will be displayed to the user.\n *\n * Note that using this handler requires the `endowment:transaction-insights`\n * permission.\n *\n * @param args - The request arguments.\n * @param args.transaction - The transaction object, containing the address,\n * value, data, and other properties of the transaction.\n * @param args.chainId - The CAIP-2 {@link ChainId} of the network the\n * transaction is being submitted to.\n * @param args.transactionOrigin - The origin of the transaction. This is the\n * URL of the website that submitted the transaction. This is only available if\n * the Snap has enabled the `allowTransactionOrigin` option in the\n * `endowment:transaction-insight` permission.\n * @returns An object containing insights about the transaction. See\n * {@link OnTransactionResponse}. Can also return `null` if no insights are\n * available.\n */\nexport type OnTransactionHandler = (args: {\n transaction: Transaction;\n chainId: ChainId;\n transactionOrigin?: string;\n}) => Promise<OnTransactionResponse | null>;\n\n/**\n * The response from a Snap's `onTransaction` handler.\n *\n * @property component - A custom UI component, that will be shown in MetaMask.\n * @property severity - The severity level of the content. Currently only one\n * level is supported: `critical`.\n */\nexport type OnTransactionResponse = {\n content: Component;\n severity?: EnumToUnion<SeverityLevel>;\n};\n"],"names":["SeverityLevel","Critical"],"mappings":";;;;;;;;;;IAWO;UAAKA,aAAa;IAAbA,cACVC,cAAW;GADDD,kBAAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// This is intentionally imported, rather than re-exported.
|
|
2
|
+
// eslint-disable-next-line import/no-unassigned-import
|
|
3
|
+
"use strict";
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
require("./global");
|
|
8
|
+
_export_star(require("./caip"), exports);
|
|
9
|
+
_export_star(require("./handlers"), exports);
|
|
10
|
+
_export_star(require("./methods"), exports);
|
|
11
|
+
_export_star(require("./permissions"), exports);
|
|
12
|
+
_export_star(require("./provider"), exports);
|
|
13
|
+
_export_star(require("./snap"), exports);
|
|
14
|
+
function _export_star(from, to) {
|
|
15
|
+
Object.keys(from).forEach(function(k) {
|
|
16
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
17
|
+
Object.defineProperty(to, k, {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return from[k];
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return from;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/types/index.ts"],"sourcesContent":["// This is intentionally imported, rather than re-exported.\n// eslint-disable-next-line import/no-unassigned-import\nimport './global';\n\nexport * from './caip';\nexport * from './handlers';\nexport * from './methods';\nexport * from './permissions';\nexport * from './provider';\nexport * from './snap';\n"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,uDAAuD;;;;;QAChD;qBAEO;qBACA;qBACA;qBACA;qBACA;qBACA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "DialogType", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return DialogType;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var DialogType;
|
|
12
|
+
(function(DialogType) {
|
|
13
|
+
DialogType["Alert"] = 'alert';
|
|
14
|
+
DialogType["Confirmation"] = 'confirmation';
|
|
15
|
+
DialogType["Prompt"] = 'prompt';
|
|
16
|
+
})(DialogType || (DialogType = {}));
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=dialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/methods/dialog.ts"],"sourcesContent":["import type { EnumToUnion } from '../../internals';\nimport type { Component } from '../../ui';\n\n/**\n * The type of dialog to display.\n *\n * - `alert` - A dialog with a single button.\n * - `confirmation` - A dialog with two buttons, one to confirm and one to\n * cancel.\n * - `prompt` - A dialog with two buttons and a text input.\n */\nexport enum DialogType {\n Alert = 'alert',\n Confirmation = 'confirmation',\n Prompt = 'prompt',\n}\n\n/**\n * An alert dialog.\n *\n * @property type - The type of dialog. Must be `alert`.\n * @property content - The content to display in the dialog.\n */\nexport type AlertDialog = {\n type: EnumToUnion<DialogType.Alert>;\n content: Component;\n};\n\n/**\n * A confirmation dialog.\n *\n * @property type - The type of dialog. Must be `confirmation`.\n * @property content - The content to display in the dialog.\n */\nexport type ConfirmationDialog = {\n type: EnumToUnion<DialogType.Confirmation>;\n content: Component;\n};\n\n/**\n * A prompt dialog.\n *\n * @property type - The type of dialog. Must be `prompt`.\n * @property content - The content to display in the dialog.\n * @property placeholder - An optional placeholder text to display in the text\n * input.\n */\nexport type PromptDialog = {\n type: EnumToUnion<DialogType.Prompt>;\n content: Component;\n placeholder?: string;\n};\n\n/**\n * The request parameters for the `snap_dialog` method.\n *\n * @property type - The type of dialog to display.\n * @property content - The content to display in the dialog.\n * @property placeholder - The placeholder text to display in the dialog. Only\n * applicable for the `prompt` dialog.\n */\nexport type DialogParams = AlertDialog | ConfirmationDialog | PromptDialog;\n\n/**\n * The result returned by the `snap_dialog` method.\n *\n * - If the dialog is an `alert`, the result is `null`.\n * - If the dialog is a `confirmation`, the result is a boolean indicating\n * whether the user confirmed the dialog.\n * - If the dialog is a `prompt`, the result is the value entered by\n * the user.\n */\nexport type DialogResult = null | boolean | string;\n"],"names":["DialogType","Alert","Confirmation","Prompt"],"mappings":";;;;;;;;;;IAWO;UAAKA,UAAU;IAAVA,WACVC,WAAQ;IADED,WAEVE,kBAAe;IAFLF,WAGVG,YAAS;GAHCH,eAAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/methods/get-bip32-entropy.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/methods/get-bip32-public-key.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/methods/get-bip44-entropy.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/methods/get-entropy.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "AuxiliaryFileEncoding", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return AuxiliaryFileEncoding;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var AuxiliaryFileEncoding;
|
|
12
|
+
(function(AuxiliaryFileEncoding) {
|
|
13
|
+
AuxiliaryFileEncoding["Base64"] = 'base64';
|
|
14
|
+
AuxiliaryFileEncoding["Hex"] = 'hex';
|
|
15
|
+
AuxiliaryFileEncoding["Utf8"] = 'utf8';
|
|
16
|
+
})(AuxiliaryFileEncoding || (AuxiliaryFileEncoding = {}));
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=get-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/methods/get-file.ts"],"sourcesContent":["import type { EnumToUnion } from '../../internals';\n\n/**\n * The encoding to use when retrieving the file. Defaults to `Base64`.\n */\nexport enum AuxiliaryFileEncoding {\n Base64 = 'base64',\n Hex = 'hex',\n Utf8 = 'utf8',\n}\n\n/**\n * The request parameters for the `snap_getFile` method.\n *\n * @property path - The path to the file to retrieve.\n * @property encoding - The encoding to use when retrieving the file.\n */\nexport type GetFileParams = {\n path: string;\n encoding?: EnumToUnion<AuxiliaryFileEncoding>;\n};\n\n/**\n * The result returned by the `snap_getFile` method.\n */\nexport type GetFileResult = string;\n"],"names":["AuxiliaryFileEncoding","Base64","Hex","Utf8"],"mappings":";;;;;;;;;;IAKO;UAAKA,qBAAqB;IAArBA,sBACVC,YAAS;IADCD,sBAEVE,SAAM;IAFIF,sBAGVG,UAAO;GAHGH,0BAAAA"}
|