@metamask/snaps-rpc-methods 11.1.1 → 11.3.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 +95 -1
- package/dist/permitted/createInterface.d.cts +2 -0
- package/dist/permitted/createInterface.d.cts.map +1 -1
- package/dist/permitted/createInterface.d.mts +2 -0
- package/dist/permitted/createInterface.d.mts.map +1 -1
- package/dist/permitted/getCurrencyRate.cjs +63 -0
- package/dist/permitted/getCurrencyRate.cjs.map +1 -0
- package/dist/permitted/getCurrencyRate.d.cts +20 -0
- package/dist/permitted/getCurrencyRate.d.cts.map +1 -0
- package/dist/permitted/getCurrencyRate.d.mts +20 -0
- package/dist/permitted/getCurrencyRate.d.mts.map +1 -0
- package/dist/permitted/getCurrencyRate.mjs +60 -0
- package/dist/permitted/getCurrencyRate.mjs.map +1 -0
- package/dist/permitted/handlers.cjs +2 -0
- package/dist/permitted/handlers.cjs.map +1 -1
- package/dist/permitted/handlers.d.cts +2 -1
- package/dist/permitted/handlers.d.cts.map +1 -1
- package/dist/permitted/handlers.d.mts +2 -1
- package/dist/permitted/handlers.d.mts.map +1 -1
- package/dist/permitted/handlers.mjs +2 -0
- package/dist/permitted/handlers.mjs.map +1 -1
- package/dist/permitted/index.cjs.map +1 -1
- package/dist/permitted/index.d.cts +2 -1
- package/dist/permitted/index.d.cts.map +1 -1
- package/dist/permitted/index.d.mts +2 -1
- package/dist/permitted/index.d.mts.map +1 -1
- package/dist/permitted/index.mjs.map +1 -1
- package/dist/permitted/updateInterface.d.cts +2 -0
- package/dist/permitted/updateInterface.d.cts.map +1 -1
- package/dist/permitted/updateInterface.d.mts +2 -0
- package/dist/permitted/updateInterface.d.mts.map +1 -1
- package/dist/restricted/dialog.d.cts +4 -0
- package/dist/restricted/dialog.d.cts.map +1 -1
- package/dist/restricted/dialog.d.mts +4 -0
- package/dist/restricted/dialog.d.mts.map +1 -1
- package/dist/restricted/notify.cjs +61 -5
- package/dist/restricted/notify.cjs.map +1 -1
- package/dist/restricted/notify.d.cts +96 -15
- package/dist/restricted/notify.d.cts.map +1 -1
- package/dist/restricted/notify.d.mts +96 -15
- package/dist/restricted/notify.d.mts.map +1 -1
- package/dist/restricted/notify.mjs +64 -8
- package/dist/restricted/notify.mjs.map +1 -1
- package/package.json +30 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
+
|
|
2
3
|
All notable changes to this project will be documented in this file.
|
|
3
4
|
|
|
4
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
@@ -6,16 +7,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
7
|
|
|
7
8
|
## [Unreleased]
|
|
8
9
|
|
|
10
|
+
## [11.3.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Add `snap_getCurrencyRate` JSON-RPC method ([#2763](https://github.com/MetaMask/snaps/pull/2763))
|
|
15
|
+
|
|
16
|
+
## [11.2.0]
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- Add support for `metamask:` schemed URLs ([#2719](https://github.com/MetaMask/snaps/pull/2719))
|
|
21
|
+
- Add support for JSX in `snap_notify` notifications ([#2706](https://github.com/MetaMask/snaps/pull/2706))
|
|
22
|
+
|
|
9
23
|
## [11.1.1]
|
|
24
|
+
|
|
10
25
|
### Fixed
|
|
26
|
+
|
|
11
27
|
- Fix invalid types in type declaration in some cases ([#2714](https://github.com/MetaMask/snaps/pull/2714))
|
|
12
28
|
|
|
13
29
|
## [11.1.0]
|
|
30
|
+
|
|
14
31
|
### Changed
|
|
32
|
+
|
|
15
33
|
- Improve error messaging ([#2696](https://github.com/MetaMask/snaps/pull/2696))
|
|
16
34
|
- Increase character limit for in-app notification messages ([#2684](https://github.com/MetaMask/snaps/pull/2684))
|
|
17
35
|
|
|
18
36
|
### Fixed
|
|
37
|
+
|
|
19
38
|
- Fix ESM version of the package ([#2682](https://github.com/MetaMask/snaps/pull/2682))
|
|
20
39
|
- This fixes the ESM version of the package to be fully compliant with the ESM
|
|
21
40
|
standard.
|
|
@@ -23,85 +42,118 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
23
42
|
- Bump other MetaMask dependencies ([#2703](https://github.com/MetaMask/snaps/pull/2703))
|
|
24
43
|
|
|
25
44
|
## [11.0.0]
|
|
45
|
+
|
|
26
46
|
### Added
|
|
47
|
+
|
|
27
48
|
- **BREAKING:** Add `snap_getPreferences` ([#2607](https://github.com/MetaMask/snaps/pull/2607))
|
|
28
49
|
- This is breaking because a `getPreferences` method hook is now required.
|
|
29
50
|
|
|
30
51
|
## [10.0.1]
|
|
52
|
+
|
|
31
53
|
### Changed
|
|
54
|
+
|
|
32
55
|
- Bump `@metamask/json-rpc-engine` from `^9.0.0` to `^9.0.2` ([#2593](https://github.com/metamask/snaps/pull/2593))
|
|
33
56
|
- Bump `@metamask/permission-controller` from `^10.0.1` to `^11.0.0` ([#2593](https://github.com/metamask/snaps/pull/2593))
|
|
34
57
|
- Bump `@metamask/snaps-utils` from `^7.8.0` to `^7.8.1` ([#2595](https://github.com/MetaMask/snaps/pull/2595))
|
|
35
58
|
|
|
36
59
|
## [10.0.0]
|
|
60
|
+
|
|
37
61
|
### Added
|
|
62
|
+
|
|
38
63
|
- **BREAKING:** `snap_dialog` now takes the `requestUserApproval` hook ([#2509](https://github.com/metamask/snaps/pull/2509))
|
|
39
64
|
- It should bind to the `addAndShowRequest` method of the `ApprovalController`.
|
|
40
65
|
- Add type `DialogApprovalTypes` and object `DIALOG_APPROVAL_TYPES`.
|
|
41
66
|
|
|
42
67
|
### Changed
|
|
68
|
+
|
|
43
69
|
- Bump `@metamask/key-tree` from `^9.1.1` to `^9.1.2` ([#2445](https://github.com/MetaMask/snaps/pull/2445))
|
|
44
70
|
- Bump `@metamask/permission-controller` from `^10.0.0` to `^10.0.1` ([#2445](https://github.com/MetaMask/snaps/pull/2445))
|
|
45
71
|
- Bump `@metamask/rpc-errors` from `^6.2.1` to `^6.3.1` ([#2445](https://github.com/MetaMask/snaps/pull/2445))
|
|
46
72
|
- Bump `@metamask/utils` from `^8.3.0` to `^9.1.0` ([#2445](https://github.com/MetaMask/snaps/pull/2445))
|
|
47
73
|
|
|
48
74
|
### Fixed
|
|
75
|
+
|
|
49
76
|
- Replace `superstruct` with ESM-compatible `@metamask/superstruct` `^3.1.0` ([#2445](https://github.com/MetaMask/snaps/pull/2445))
|
|
50
77
|
- This fixes the issue of this package being unusable by any TypeScript project that uses `Node16` or `NodeNext` as its `moduleResolution` option.
|
|
51
78
|
|
|
52
79
|
## [9.1.4]
|
|
80
|
+
|
|
53
81
|
### Changed
|
|
82
|
+
|
|
54
83
|
- Bump MetaMask dependencies ([#2516](https://github.com/MetaMask/snaps/pull/2516))
|
|
55
84
|
|
|
56
85
|
## [9.1.3]
|
|
86
|
+
|
|
57
87
|
### Changed
|
|
88
|
+
|
|
58
89
|
- Bump MetaMask dependencies ([#2460](https://github.com/MetaMask/snaps/pull/2460))
|
|
59
90
|
|
|
60
91
|
## [9.1.2]
|
|
92
|
+
|
|
61
93
|
### Fixed
|
|
94
|
+
|
|
62
95
|
- Fix invalid `@metamask/snaps-sdk` imports ([#2452](https://github.com/MetaMask/snaps/pull/2452))
|
|
63
96
|
|
|
64
97
|
## [9.1.1]
|
|
98
|
+
|
|
65
99
|
### Changed
|
|
100
|
+
|
|
66
101
|
- Bump `@metamask/key-tree` from `9.1.0` to `9.1.1` ([#2431](https://github.com/MetaMask/snaps/pull/2431))
|
|
67
102
|
|
|
68
103
|
## [9.1.0]
|
|
104
|
+
|
|
69
105
|
### Added
|
|
106
|
+
|
|
70
107
|
- Add `context` field to `snap_createInterface` ([#2413](https://github.com/MetaMask/snaps/pull/2413))
|
|
71
108
|
|
|
72
109
|
## [9.0.0]
|
|
110
|
+
|
|
73
111
|
### Added
|
|
112
|
+
|
|
74
113
|
- Add support for BIP-32-Ed25519 / CIP-3 key derivation ([#2408](https://github.com/MetaMask/snaps/pull/2408))
|
|
75
114
|
- The `ed25519Bip32` curve is now supported for `snap_getBip32Entropy` and `snap_getBip32PublicKey`
|
|
76
115
|
|
|
77
116
|
### Changed
|
|
117
|
+
|
|
78
118
|
- **BREAKING:** Use hooks in `wallet_invokeSnap` instead of remapping the request to `wallet_snap` ([#2406](https://github.com/MetaMask/snaps/pull/2406))
|
|
79
119
|
|
|
80
120
|
## [8.1.0]
|
|
121
|
+
|
|
81
122
|
### Added
|
|
123
|
+
|
|
82
124
|
- Add JSX support for custom UI ([#2258](https://github.com/MetaMask/snaps/pull/2258))
|
|
83
125
|
|
|
84
126
|
## [8.0.0]
|
|
127
|
+
|
|
85
128
|
### Changed
|
|
129
|
+
|
|
86
130
|
- **BREAKING:** Refactor to support changes to encryption ([#2316](https://github.com/MetaMask/snaps/pull/2316))
|
|
87
131
|
- No longer expects `encrypt` or `decrypt`, instead expects `updateSnapState` and `getSnapState` to be asynchronous
|
|
88
132
|
|
|
89
133
|
## [7.0.2]
|
|
134
|
+
|
|
90
135
|
### Changed
|
|
136
|
+
|
|
91
137
|
- Bump MetaMask dependencies ([#2270](https://github.com/MetaMask/snaps/pull/2270))
|
|
92
138
|
- Bump @metamask/json-rpc-engine from 7.3.2 to 7.3.3 ([#2247](https://github.com/MetaMask/snaps/pull/2247))
|
|
93
139
|
|
|
94
140
|
## [7.0.1]
|
|
141
|
+
|
|
95
142
|
### Fixed
|
|
143
|
+
|
|
96
144
|
- Fix minor build configuration problems ([#2220](https://github.com/MetaMask/snaps/pull/2220))
|
|
97
145
|
|
|
98
146
|
## [7.0.0]
|
|
147
|
+
|
|
99
148
|
### Changed
|
|
149
|
+
|
|
100
150
|
- **BREAKING:** Update ESM build to be fully compliant with the ESM standard ([#2210](https://github.com/MetaMask/snaps/pull/2210))
|
|
101
151
|
- Bump `@metamask/rpc-errors` to `^6.2.1` ([#2209](https://github.com/MetaMask/snaps/pull/2209))
|
|
102
152
|
|
|
103
153
|
## [6.0.0]
|
|
154
|
+
|
|
104
155
|
### Added
|
|
156
|
+
|
|
105
157
|
- **BREAKING:** Add support for dynamic user interfaces ([#1465](https://github.com/MetaMask/snaps/pull/1465), [#2144](https://github.com/MetaMask/snaps/pull/2144), [#2143](https://github.com/MetaMask/snaps/pull/2143))
|
|
106
158
|
- This adds the `snap_createInterface`, `snap_updateInterface`, and `snap_getInterfaceState` methods.
|
|
107
159
|
- This is breaking because it changes the expected type of the `showDialog` RPC method hook.
|
|
@@ -110,102 +162,144 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
110
162
|
- Add endowment permission specifications to this package ([#2155](https://github.com/MetaMask/snaps/pull/2155))
|
|
111
163
|
|
|
112
164
|
### Changed
|
|
165
|
+
|
|
113
166
|
- Bump MetaMask dependencies ([#2129](https://github.com/MetaMask/snaps/pull/2129), [#2142](https://github.com/MetaMask/snaps/pull/2142))
|
|
114
167
|
|
|
115
168
|
## [5.0.0]
|
|
169
|
+
|
|
116
170
|
### Added
|
|
171
|
+
|
|
117
172
|
- Add `snap_getClientStatus` ([#2051](https://github.com/MetaMask/snaps/pull/2051))
|
|
118
173
|
|
|
119
174
|
### Changed
|
|
175
|
+
|
|
120
176
|
- **BREAKING:** Use origin bound hooks for `invokeKeyring` ([#2090](https://github.com/MetaMask/snaps/pull/2090))
|
|
121
177
|
- Bump several MetaMask dependencies ([#2069](https://github.com/MetaMask/snaps/pull/2069), [#2100](https://github.com/MetaMask/snaps/pull/2100))
|
|
122
178
|
|
|
123
179
|
## [4.1.0]
|
|
180
|
+
|
|
124
181
|
### Added
|
|
182
|
+
|
|
125
183
|
- Add `wallet_getAllSnaps` method to get all installed Snaps ([#2047](https://github.com/MetaMask/snaps/pull/2047))
|
|
126
184
|
|
|
127
185
|
### Changed
|
|
186
|
+
|
|
128
187
|
- Bump several MetaMask dependencies ([#2064](https://github.com/MetaMask/snaps/pull/2064), [#2065](https://github.com/MetaMask/snaps/pull/2065))
|
|
129
188
|
|
|
130
189
|
## [4.0.3]
|
|
190
|
+
|
|
131
191
|
### Changed
|
|
192
|
+
|
|
132
193
|
- Use prototype `startsWith` for RPC method middleware ([#2035](https://github.com/MetaMask/snaps/pull/2035))
|
|
133
194
|
|
|
134
195
|
## [4.0.2]
|
|
196
|
+
|
|
135
197
|
### Changed
|
|
198
|
+
|
|
136
199
|
- Bump several MetaMask dependencies ([#1989](https://github.com/MetaMask/snaps/pull/1989))
|
|
137
200
|
|
|
138
201
|
## [4.0.1]
|
|
202
|
+
|
|
139
203
|
### Changed
|
|
204
|
+
|
|
140
205
|
- Bump several MetaMask dependencies ([#1964](https://github.com/MetaMask/snaps/pull/1964), [#1968](https://github.com/MetaMask/snaps/pull/1968))
|
|
141
206
|
|
|
142
207
|
## [4.0.0]
|
|
208
|
+
|
|
143
209
|
### Changed
|
|
210
|
+
|
|
144
211
|
- Use `@metamask/snaps-sdk` package ([#1930](https://github.com/MetaMask/snaps/pull/1930),
|
|
145
212
|
[#1950](https://github.com/MetaMask/snaps/pull/1950), [#1954](https://github.com/MetaMask/snaps/pull/1954))
|
|
146
213
|
- This package replaces the `@metamask/snaps-types` and
|
|
147
214
|
- `@metamask/snaps-ui` packages.
|
|
148
215
|
|
|
149
216
|
### Removed
|
|
217
|
+
|
|
150
218
|
- **BREAKING**: Remove `DialogType`, `ManageStateOperation`, and `NotificationType` enums ([#1930](https://github.com/MetaMask/snaps/pull/1930))
|
|
151
219
|
- These are now defined in the `@metamask/snaps-sdk` package.
|
|
152
220
|
|
|
153
221
|
## [3.3.0]
|
|
222
|
+
|
|
154
223
|
### Added
|
|
224
|
+
|
|
155
225
|
- Add support for unencrypted storage using `snap_manageState` ([#1902](https://github.com/MetaMask/snaps/pull/1902))
|
|
156
226
|
|
|
157
227
|
## [3.2.1]
|
|
228
|
+
|
|
158
229
|
### Fixed
|
|
230
|
+
|
|
159
231
|
- Fix `assertLinksAreSafe` import ([#1908](https://github.com/MetaMask/snaps/pull/1908))
|
|
160
232
|
|
|
161
233
|
## [3.2.0]
|
|
234
|
+
|
|
162
235
|
### Added
|
|
236
|
+
|
|
163
237
|
- Add support for links in custom UI and notifications ([#1814](https://github.com/MetaMask/snaps/pull/1814))
|
|
164
238
|
|
|
165
239
|
## [3.1.0]
|
|
240
|
+
|
|
166
241
|
### Changed
|
|
242
|
+
|
|
167
243
|
- Rename package to `@metamask/snaps-rpc-methods` ([#1864](https://github.com/MetaMask/snaps/pull/1864))
|
|
168
244
|
- Update multiple MetaMask dependencies ([#1841](https://github.com/MetaMask/snaps/pull/1841))
|
|
169
245
|
|
|
170
246
|
## [3.0.0]
|
|
247
|
+
|
|
171
248
|
### Added
|
|
249
|
+
|
|
172
250
|
- Add keyring export and endowment ([#1787](https://github.com/MetaMask/snaps/pull/1787))
|
|
173
251
|
|
|
174
252
|
### Changed
|
|
253
|
+
|
|
175
254
|
- **BREAKING:** Bump minimum Node.js version to `^18.16.0` ([#1741](https://github.com/MetaMask/snaps/pull/1741))
|
|
176
255
|
|
|
177
256
|
## [2.0.0]
|
|
257
|
+
|
|
178
258
|
### Changed
|
|
259
|
+
|
|
179
260
|
- Initial stable release from main branch ([#1757](https://github.com/MetaMask/snaps/pull/1757))
|
|
180
261
|
|
|
181
262
|
## [0.38.3-flask.1]
|
|
263
|
+
|
|
182
264
|
### Changed
|
|
265
|
+
|
|
183
266
|
- Bump `metamask/utils` and `metamask/snaps-registry` ([#1738](https://github.com/MetaMask/snaps/pull/1738))
|
|
184
267
|
|
|
185
268
|
## [0.38.2-flask.1]
|
|
269
|
+
|
|
186
270
|
### Changed
|
|
271
|
+
|
|
187
272
|
- Remove business-logic callbacks from `manageAccounts` ([#1725](https://github.com/MetaMask/snaps/pull/1725))
|
|
188
273
|
- Bump `@metamask/utils` and `@metamask/snaps-registry` ([#1694](https://github.com/MetaMask/snaps/pull/1694))
|
|
189
274
|
|
|
190
275
|
## [0.38.1-flask.1]
|
|
276
|
+
|
|
191
277
|
### Fixed
|
|
278
|
+
|
|
192
279
|
- Make `manageAccounts` arguments extend `RestrictedMethodParameters` ([#1687](https://github.com/MetaMask/snaps/pull/1687))
|
|
193
280
|
|
|
194
281
|
## [0.38.0-flask.1]
|
|
282
|
+
|
|
195
283
|
### Added
|
|
284
|
+
|
|
196
285
|
- Add `snap_getLocale` JSON-RPC method ([#1557](https://github.com/MetaMask/snaps/pull/1557))
|
|
197
286
|
- This will let snaps get the user locale from the client.
|
|
198
287
|
|
|
199
288
|
### Fixed
|
|
289
|
+
|
|
200
290
|
- Fix ed25519 public key derivation ([#1678](https://github.com/MetaMask/snaps/pull/1678))
|
|
201
291
|
|
|
202
292
|
## [0.37.2-flask.1]
|
|
293
|
+
|
|
203
294
|
### Changed
|
|
295
|
+
|
|
204
296
|
- Release package independently ([#1600](https://github.com/MetaMask/snaps/pull/1600))
|
|
205
297
|
- The version of the package no longer needs to match the version of all other
|
|
206
298
|
MetaMask Snaps packages.
|
|
207
299
|
|
|
208
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@11.
|
|
300
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@11.3.0...HEAD
|
|
301
|
+
[11.3.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@11.2.0...@metamask/snaps-rpc-methods@11.3.0
|
|
302
|
+
[11.2.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@11.1.1...@metamask/snaps-rpc-methods@11.2.0
|
|
209
303
|
[11.1.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@11.1.0...@metamask/snaps-rpc-methods@11.1.1
|
|
210
304
|
[11.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@11.0.0...@metamask/snaps-rpc-methods@11.1.0
|
|
211
305
|
[11.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@10.0.1...@metamask/snaps-rpc-methods@11.0.0
|
|
@@ -96,6 +96,7 @@ declare const CreateInterfaceParametersStruct: import("@metamask/superstruct").S
|
|
|
96
96
|
}, "Radio">>;
|
|
97
97
|
}, "RadioGroup"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
98
98
|
children: import("@metamask/snaps-sdk/jsx").StringElement;
|
|
99
|
+
size?: "md" | "lg" | undefined;
|
|
99
100
|
}, "Heading">;
|
|
100
101
|
context?: Record<string, import("@metamask/snaps-sdk").Json> | undefined;
|
|
101
102
|
}, {
|
|
@@ -185,6 +186,7 @@ declare const CreateInterfaceParametersStruct: import("@metamask/superstruct").S
|
|
|
185
186
|
}, "Radio">>;
|
|
186
187
|
}, "RadioGroup"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
187
188
|
children: import("@metamask/snaps-sdk/jsx").StringElement;
|
|
189
|
+
size?: "md" | "lg" | undefined;
|
|
188
190
|
}, "Heading">, null>;
|
|
189
191
|
context: import("@metamask/superstruct").Struct<Record<string, import("@metamask/snaps-sdk").Json> | undefined, null>;
|
|
190
192
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createInterface.d.cts","sourceRoot":"","sources":["../../src/permitted/createInterface.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,wCAAwC;AAE9E,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EAErB,kBAAkB,EAClB,gBAAgB,EACjB,4BAA4B;AAK7B,OAAO,EAAE,KAAK,aAAa,EAAE,8BAA8B;AAU3D,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;OAGG;IACH,eAAe,EAAE,CACf,EAAE,EAAE,kBAAkB,EACtB,OAAO,CAAC,EAAE,gBAAgB,KACvB,OAAO,CAAC,MAAM,CAAC,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,sBAAsB,CACzD,0BAA0B,EAC1B,yBAAyB,EACzB,qBAAqB,CAKtB,CAAC;AAEF,QAAA,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA4CrC;;;;;;WAMG
|
|
1
|
+
{"version":3,"file":"createInterface.d.cts","sourceRoot":"","sources":["../../src/permitted/createInterface.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,wCAAwC;AAE9E,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EAErB,kBAAkB,EAClB,gBAAgB,EACjB,4BAA4B;AAK7B,OAAO,EAAE,KAAK,aAAa,EAAE,8BAA8B;AAU3D,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;OAGG;IACH,eAAe,EAAE,CACf,EAAE,EAAE,kBAAkB,EACtB,OAAO,CAAC,EAAE,gBAAgB,KACvB,OAAO,CAAC,MAAM,CAAC,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,sBAAsB,CACzD,0BAA0B,EAC1B,yBAAyB,EACzB,qBAAqB,CAKtB,CAAC;AAEF,QAAA,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA4CrC;;;;;;WAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBANH;;;;;;WAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA/CD,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,aAAa,CACnD,OAAO,+BAA+B,EACtC,qBAAqB,CACtB,CAAC"}
|
|
@@ -96,6 +96,7 @@ declare const CreateInterfaceParametersStruct: import("@metamask/superstruct").S
|
|
|
96
96
|
}, "Radio">>;
|
|
97
97
|
}, "RadioGroup"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
98
98
|
children: import("@metamask/snaps-sdk/jsx").StringElement;
|
|
99
|
+
size?: "md" | "lg" | undefined;
|
|
99
100
|
}, "Heading">;
|
|
100
101
|
context?: Record<string, import("@metamask/snaps-sdk").Json> | undefined;
|
|
101
102
|
}, {
|
|
@@ -185,6 +186,7 @@ declare const CreateInterfaceParametersStruct: import("@metamask/superstruct").S
|
|
|
185
186
|
}, "Radio">>;
|
|
186
187
|
}, "RadioGroup"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
187
188
|
children: import("@metamask/snaps-sdk/jsx").StringElement;
|
|
189
|
+
size?: "md" | "lg" | undefined;
|
|
188
190
|
}, "Heading">, null>;
|
|
189
191
|
context: import("@metamask/superstruct").Struct<Record<string, import("@metamask/snaps-sdk").Json> | undefined, null>;
|
|
190
192
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createInterface.d.mts","sourceRoot":"","sources":["../../src/permitted/createInterface.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,wCAAwC;AAE9E,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EAErB,kBAAkB,EAClB,gBAAgB,EACjB,4BAA4B;AAK7B,OAAO,EAAE,KAAK,aAAa,EAAE,8BAA8B;AAU3D,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;OAGG;IACH,eAAe,EAAE,CACf,EAAE,EAAE,kBAAkB,EACtB,OAAO,CAAC,EAAE,gBAAgB,KACvB,OAAO,CAAC,MAAM,CAAC,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,sBAAsB,CACzD,0BAA0B,EAC1B,yBAAyB,EACzB,qBAAqB,CAKtB,CAAC;AAEF,QAAA,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA4CrC;;;;;;WAMG
|
|
1
|
+
{"version":3,"file":"createInterface.d.mts","sourceRoot":"","sources":["../../src/permitted/createInterface.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,wCAAwC;AAE9E,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EAErB,kBAAkB,EAClB,gBAAgB,EACjB,4BAA4B;AAK7B,OAAO,EAAE,KAAK,aAAa,EAAE,8BAA8B;AAU3D,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;OAGG;IACH,eAAe,EAAE,CACf,EAAE,EAAE,kBAAkB,EACtB,OAAO,CAAC,EAAE,gBAAgB,KACvB,OAAO,CAAC,MAAM,CAAC,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,sBAAsB,CACzD,0BAA0B,EAC1B,yBAAyB,EACzB,qBAAqB,CAKtB,CAAC;AAEF,QAAA,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA4CrC;;;;;;WAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBANH;;;;;;WAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA/CD,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,aAAa,CACnD,OAAO,+BAA+B,EACtC,qBAAqB,CACtB,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCurrencyRateHandler = void 0;
|
|
4
|
+
const rpc_errors_1 = require("@metamask/rpc-errors");
|
|
5
|
+
const snaps_utils_1 = require("@metamask/snaps-utils");
|
|
6
|
+
const superstruct_1 = require("@metamask/superstruct");
|
|
7
|
+
const hookNames = {
|
|
8
|
+
getCurrencyRate: true,
|
|
9
|
+
};
|
|
10
|
+
exports.getCurrencyRateHandler = {
|
|
11
|
+
methodNames: ['snap_getCurrencyRate'],
|
|
12
|
+
implementation: getGetCurrencyRateImplementation,
|
|
13
|
+
hookNames,
|
|
14
|
+
};
|
|
15
|
+
const GetCurrencyRateParametersStruct = (0, superstruct_1.object)({
|
|
16
|
+
currency: (0, superstruct_1.union)([(0, snaps_utils_1.currency)('btc')]),
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* The `snap_getCurrencyRate` method implementation.
|
|
20
|
+
*
|
|
21
|
+
* @param req - The JSON-RPC request object.
|
|
22
|
+
* @param res - The JSON-RPC response object.
|
|
23
|
+
* @param _next - The `json-rpc-engine` "next" callback. Not used by this
|
|
24
|
+
* function.
|
|
25
|
+
* @param end - The `json-rpc-engine` "end" callback.
|
|
26
|
+
* @param hooks - The RPC method hooks.
|
|
27
|
+
* @param hooks.getCurrencyRate - The function to get the rate.
|
|
28
|
+
* @returns Nothing.
|
|
29
|
+
*/
|
|
30
|
+
function getGetCurrencyRateImplementation(req, res, _next, end, { getCurrencyRate }) {
|
|
31
|
+
const { params } = req;
|
|
32
|
+
try {
|
|
33
|
+
const validatedParams = getValidatedParams(params);
|
|
34
|
+
const { currency: selectedCurrency } = validatedParams;
|
|
35
|
+
res.result = getCurrencyRate(selectedCurrency) ?? null;
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
return end(error);
|
|
39
|
+
}
|
|
40
|
+
return end();
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Validate the getCurrencyRate method `params` and returns them cast to the correct
|
|
44
|
+
* type. Throws if validation fails.
|
|
45
|
+
*
|
|
46
|
+
* @param params - The unvalidated params object from the method request.
|
|
47
|
+
* @returns The validated getCurrencyRate method parameter object.
|
|
48
|
+
*/
|
|
49
|
+
function getValidatedParams(params) {
|
|
50
|
+
try {
|
|
51
|
+
return (0, superstruct_1.create)(params, GetCurrencyRateParametersStruct);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
if (error instanceof superstruct_1.StructError) {
|
|
55
|
+
throw rpc_errors_1.rpcErrors.invalidParams({
|
|
56
|
+
message: `Invalid params: ${error.message}.`,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/* istanbul ignore next */
|
|
60
|
+
throw rpc_errors_1.rpcErrors.internal();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=getCurrencyRate.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCurrencyRate.cjs","sourceRoot":"","sources":["../../src/permitted/getCurrencyRate.ts"],"names":[],"mappings":";;;AAEA,qDAAiD;AAQjD,uDAAqE;AACrE,uDAA2E;AAK3E,MAAM,SAAS,GAAkD;IAC/D,eAAe,EAAE,IAAI;CACtB,CAAC;AAWW,QAAA,sBAAsB,GAI/B;IACF,WAAW,EAAE,CAAC,sBAAsB,CAAC;IACrC,cAAc,EAAE,gCAAgC;IAChD,SAAS;CACV,CAAC;AAEF,MAAM,+BAA+B,GAAG,IAAA,oBAAM,EAAC;IAC7C,QAAQ,EAAE,IAAA,mBAAK,EAAC,CAAC,IAAA,sBAAQ,EAAC,KAAK,CAAC,CAAC,CAAC;CACnC,CAAC,CAAC;AAOH;;;;;;;;;;;GAWG;AACH,SAAS,gCAAgC,CACvC,GAA8C,EAC9C,GAAkD,EAClD,KAAc,EACd,GAA6B,EAC7B,EAAE,eAAe,EAA8B;IAE/C,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IAEvB,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAEnD,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,GAAG,eAAe,CAAC;QAEvD,GAAG,CAAC,MAAM,GAAG,eAAe,CAAC,gBAAgB,CAAC,IAAI,IAAI,CAAC;IACzD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,GAAG,EAAE,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,SAAS,kBAAkB,CAAC,MAAe;IACzC,IAAI,CAAC;QACH,OAAO,IAAA,oBAAM,EAAC,MAAM,EAAE,+BAA+B,CAAC,CAAC;IACzD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,yBAAW,EAAE,CAAC;YACjC,MAAM,sBAAS,CAAC,aAAa,CAAC;gBAC5B,OAAO,EAAE,mBAAmB,KAAK,CAAC,OAAO,GAAG;aAC7C,CAAC,CAAC;QACL,CAAC;QACD,0BAA0B;QAC1B,MAAM,sBAAS,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;AACH,CAAC","sourcesContent":["import type { JsonRpcEngineEndCallback } from '@metamask/json-rpc-engine';\nimport type { PermittedHandlerExport } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type {\n AvailableCurrency,\n CurrencyRate,\n GetCurrencyRateParams,\n GetCurrencyRateResult,\n JsonRpcRequest,\n} from '@metamask/snaps-sdk';\nimport { currency, type InferMatching } from '@metamask/snaps-utils';\nimport { StructError, create, object, union } from '@metamask/superstruct';\nimport type { PendingJsonRpcResponse } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\n\nconst hookNames: MethodHooksObject<GetCurrencyRateMethodHooks> = {\n getCurrencyRate: true,\n};\n\nexport type GetCurrencyRateMethodHooks = {\n /**\n * @param currency - The currency symbol.\n * Currently only 'btc' is supported.\n * @returns The {@link CurrencyRate} object.\n */\n getCurrencyRate: (currency: AvailableCurrency) => CurrencyRate | undefined;\n};\n\nexport const getCurrencyRateHandler: PermittedHandlerExport<\n GetCurrencyRateMethodHooks,\n GetCurrencyRateParameters,\n GetCurrencyRateResult\n> = {\n methodNames: ['snap_getCurrencyRate'],\n implementation: getGetCurrencyRateImplementation,\n hookNames,\n};\n\nconst GetCurrencyRateParametersStruct = object({\n currency: union([currency('btc')]),\n});\n\nexport type GetCurrencyRateParameters = InferMatching<\n typeof GetCurrencyRateParametersStruct,\n GetCurrencyRateParams\n>;\n\n/**\n * The `snap_getCurrencyRate` method implementation.\n *\n * @param req - The JSON-RPC request object.\n * @param res - The JSON-RPC response object.\n * @param _next - The `json-rpc-engine` \"next\" callback. Not used by this\n * function.\n * @param end - The `json-rpc-engine` \"end\" callback.\n * @param hooks - The RPC method hooks.\n * @param hooks.getCurrencyRate - The function to get the rate.\n * @returns Nothing.\n */\nfunction getGetCurrencyRateImplementation(\n req: JsonRpcRequest<GetCurrencyRateParameters>,\n res: PendingJsonRpcResponse<GetCurrencyRateResult>,\n _next: unknown,\n end: JsonRpcEngineEndCallback,\n { getCurrencyRate }: GetCurrencyRateMethodHooks,\n): void {\n const { params } = req;\n\n try {\n const validatedParams = getValidatedParams(params);\n\n const { currency: selectedCurrency } = validatedParams;\n\n res.result = getCurrencyRate(selectedCurrency) ?? null;\n } catch (error) {\n return end(error);\n }\n\n return end();\n}\n\n/**\n * Validate the getCurrencyRate method `params` and returns them cast to the correct\n * type. Throws if validation fails.\n *\n * @param params - The unvalidated params object from the method request.\n * @returns The validated getCurrencyRate method parameter object.\n */\nfunction getValidatedParams(params: unknown): GetCurrencyRateParameters {\n try {\n return create(params, GetCurrencyRateParametersStruct);\n } catch (error) {\n if (error instanceof StructError) {\n throw rpcErrors.invalidParams({\n message: `Invalid params: ${error.message}.`,\n });\n }\n /* istanbul ignore next */\n throw rpcErrors.internal();\n }\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PermittedHandlerExport } from "@metamask/permission-controller";
|
|
2
|
+
import type { AvailableCurrency, CurrencyRate, GetCurrencyRateParams, GetCurrencyRateResult } from "@metamask/snaps-sdk";
|
|
3
|
+
import { type InferMatching } from "@metamask/snaps-utils";
|
|
4
|
+
export type GetCurrencyRateMethodHooks = {
|
|
5
|
+
/**
|
|
6
|
+
* @param currency - The currency symbol.
|
|
7
|
+
* Currently only 'btc' is supported.
|
|
8
|
+
* @returns The {@link CurrencyRate} object.
|
|
9
|
+
*/
|
|
10
|
+
getCurrencyRate: (currency: AvailableCurrency) => CurrencyRate | undefined;
|
|
11
|
+
};
|
|
12
|
+
export declare const getCurrencyRateHandler: PermittedHandlerExport<GetCurrencyRateMethodHooks, GetCurrencyRateParameters, GetCurrencyRateResult>;
|
|
13
|
+
declare const GetCurrencyRateParametersStruct: import("@metamask/superstruct").Struct<{
|
|
14
|
+
currency: "btc" | "BTC";
|
|
15
|
+
}, {
|
|
16
|
+
currency: import("@metamask/superstruct").Struct<"btc" | "BTC", null>;
|
|
17
|
+
}>;
|
|
18
|
+
export type GetCurrencyRateParameters = InferMatching<typeof GetCurrencyRateParametersStruct, GetCurrencyRateParams>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=getCurrencyRate.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCurrencyRate.d.cts","sourceRoot":"","sources":["../../src/permitted/getCurrencyRate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,wCAAwC;AAE9E,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,qBAAqB,EACrB,qBAAqB,EAEtB,4BAA4B;AAC7B,OAAO,EAAY,KAAK,aAAa,EAAE,8BAA8B;AAUrE,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;;OAIG;IACH,eAAe,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,YAAY,GAAG,SAAS,CAAC;CAC5E,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,sBAAsB,CACzD,0BAA0B,EAC1B,yBAAyB,EACzB,qBAAqB,CAKtB,CAAC;AAEF,QAAA,MAAM,+BAA+B;;;;EAEnC,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,aAAa,CACnD,OAAO,+BAA+B,EACtC,qBAAqB,CACtB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PermittedHandlerExport } from "@metamask/permission-controller";
|
|
2
|
+
import type { AvailableCurrency, CurrencyRate, GetCurrencyRateParams, GetCurrencyRateResult } from "@metamask/snaps-sdk";
|
|
3
|
+
import { type InferMatching } from "@metamask/snaps-utils";
|
|
4
|
+
export type GetCurrencyRateMethodHooks = {
|
|
5
|
+
/**
|
|
6
|
+
* @param currency - The currency symbol.
|
|
7
|
+
* Currently only 'btc' is supported.
|
|
8
|
+
* @returns The {@link CurrencyRate} object.
|
|
9
|
+
*/
|
|
10
|
+
getCurrencyRate: (currency: AvailableCurrency) => CurrencyRate | undefined;
|
|
11
|
+
};
|
|
12
|
+
export declare const getCurrencyRateHandler: PermittedHandlerExport<GetCurrencyRateMethodHooks, GetCurrencyRateParameters, GetCurrencyRateResult>;
|
|
13
|
+
declare const GetCurrencyRateParametersStruct: import("@metamask/superstruct").Struct<{
|
|
14
|
+
currency: "btc" | "BTC";
|
|
15
|
+
}, {
|
|
16
|
+
currency: import("@metamask/superstruct").Struct<"btc" | "BTC", null>;
|
|
17
|
+
}>;
|
|
18
|
+
export type GetCurrencyRateParameters = InferMatching<typeof GetCurrencyRateParametersStruct, GetCurrencyRateParams>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=getCurrencyRate.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCurrencyRate.d.mts","sourceRoot":"","sources":["../../src/permitted/getCurrencyRate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,wCAAwC;AAE9E,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,qBAAqB,EACrB,qBAAqB,EAEtB,4BAA4B;AAC7B,OAAO,EAAY,KAAK,aAAa,EAAE,8BAA8B;AAUrE,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;;OAIG;IACH,eAAe,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,YAAY,GAAG,SAAS,CAAC;CAC5E,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,sBAAsB,CACzD,0BAA0B,EAC1B,yBAAyB,EACzB,qBAAqB,CAKtB,CAAC;AAEF,QAAA,MAAM,+BAA+B;;;;EAEnC,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,aAAa,CACnD,OAAO,+BAA+B,EACtC,qBAAqB,CACtB,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { rpcErrors } from "@metamask/rpc-errors";
|
|
2
|
+
import { currency } from "@metamask/snaps-utils";
|
|
3
|
+
import { StructError, create, object, union } from "@metamask/superstruct";
|
|
4
|
+
const hookNames = {
|
|
5
|
+
getCurrencyRate: true,
|
|
6
|
+
};
|
|
7
|
+
export const getCurrencyRateHandler = {
|
|
8
|
+
methodNames: ['snap_getCurrencyRate'],
|
|
9
|
+
implementation: getGetCurrencyRateImplementation,
|
|
10
|
+
hookNames,
|
|
11
|
+
};
|
|
12
|
+
const GetCurrencyRateParametersStruct = object({
|
|
13
|
+
currency: union([currency('btc')]),
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* The `snap_getCurrencyRate` method implementation.
|
|
17
|
+
*
|
|
18
|
+
* @param req - The JSON-RPC request object.
|
|
19
|
+
* @param res - The JSON-RPC response object.
|
|
20
|
+
* @param _next - The `json-rpc-engine` "next" callback. Not used by this
|
|
21
|
+
* function.
|
|
22
|
+
* @param end - The `json-rpc-engine` "end" callback.
|
|
23
|
+
* @param hooks - The RPC method hooks.
|
|
24
|
+
* @param hooks.getCurrencyRate - The function to get the rate.
|
|
25
|
+
* @returns Nothing.
|
|
26
|
+
*/
|
|
27
|
+
function getGetCurrencyRateImplementation(req, res, _next, end, { getCurrencyRate }) {
|
|
28
|
+
const { params } = req;
|
|
29
|
+
try {
|
|
30
|
+
const validatedParams = getValidatedParams(params);
|
|
31
|
+
const { currency: selectedCurrency } = validatedParams;
|
|
32
|
+
res.result = getCurrencyRate(selectedCurrency) ?? null;
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
return end(error);
|
|
36
|
+
}
|
|
37
|
+
return end();
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Validate the getCurrencyRate method `params` and returns them cast to the correct
|
|
41
|
+
* type. Throws if validation fails.
|
|
42
|
+
*
|
|
43
|
+
* @param params - The unvalidated params object from the method request.
|
|
44
|
+
* @returns The validated getCurrencyRate method parameter object.
|
|
45
|
+
*/
|
|
46
|
+
function getValidatedParams(params) {
|
|
47
|
+
try {
|
|
48
|
+
return create(params, GetCurrencyRateParametersStruct);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
if (error instanceof StructError) {
|
|
52
|
+
throw rpcErrors.invalidParams({
|
|
53
|
+
message: `Invalid params: ${error.message}.`,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/* istanbul ignore next */
|
|
57
|
+
throw rpcErrors.internal();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=getCurrencyRate.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCurrencyRate.mjs","sourceRoot":"","sources":["../../src/permitted/getCurrencyRate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,6BAA6B;AAQjD,OAAO,EAAE,QAAQ,EAAsB,8BAA8B;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B;AAK3E,MAAM,SAAS,GAAkD;IAC/D,eAAe,EAAE,IAAI;CACtB,CAAC;AAWF,MAAM,CAAC,MAAM,sBAAsB,GAI/B;IACF,WAAW,EAAE,CAAC,sBAAsB,CAAC;IACrC,cAAc,EAAE,gCAAgC;IAChD,SAAS;CACV,CAAC;AAEF,MAAM,+BAA+B,GAAG,MAAM,CAAC;IAC7C,QAAQ,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;CACnC,CAAC,CAAC;AAOH;;;;;;;;;;;GAWG;AACH,SAAS,gCAAgC,CACvC,GAA8C,EAC9C,GAAkD,EAClD,KAAc,EACd,GAA6B,EAC7B,EAAE,eAAe,EAA8B;IAE/C,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IAEvB,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAEnD,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,GAAG,eAAe,CAAC;QAEvD,GAAG,CAAC,MAAM,GAAG,eAAe,CAAC,gBAAgB,CAAC,IAAI,IAAI,CAAC;IACzD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,GAAG,EAAE,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,SAAS,kBAAkB,CAAC,MAAe;IACzC,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,MAAM,EAAE,+BAA+B,CAAC,CAAC;IACzD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,WAAW,EAAE,CAAC;YACjC,MAAM,SAAS,CAAC,aAAa,CAAC;gBAC5B,OAAO,EAAE,mBAAmB,KAAK,CAAC,OAAO,GAAG;aAC7C,CAAC,CAAC;QACL,CAAC;QACD,0BAA0B;QAC1B,MAAM,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;AACH,CAAC","sourcesContent":["import type { JsonRpcEngineEndCallback } from '@metamask/json-rpc-engine';\nimport type { PermittedHandlerExport } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type {\n AvailableCurrency,\n CurrencyRate,\n GetCurrencyRateParams,\n GetCurrencyRateResult,\n JsonRpcRequest,\n} from '@metamask/snaps-sdk';\nimport { currency, type InferMatching } from '@metamask/snaps-utils';\nimport { StructError, create, object, union } from '@metamask/superstruct';\nimport type { PendingJsonRpcResponse } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\n\nconst hookNames: MethodHooksObject<GetCurrencyRateMethodHooks> = {\n getCurrencyRate: true,\n};\n\nexport type GetCurrencyRateMethodHooks = {\n /**\n * @param currency - The currency symbol.\n * Currently only 'btc' is supported.\n * @returns The {@link CurrencyRate} object.\n */\n getCurrencyRate: (currency: AvailableCurrency) => CurrencyRate | undefined;\n};\n\nexport const getCurrencyRateHandler: PermittedHandlerExport<\n GetCurrencyRateMethodHooks,\n GetCurrencyRateParameters,\n GetCurrencyRateResult\n> = {\n methodNames: ['snap_getCurrencyRate'],\n implementation: getGetCurrencyRateImplementation,\n hookNames,\n};\n\nconst GetCurrencyRateParametersStruct = object({\n currency: union([currency('btc')]),\n});\n\nexport type GetCurrencyRateParameters = InferMatching<\n typeof GetCurrencyRateParametersStruct,\n GetCurrencyRateParams\n>;\n\n/**\n * The `snap_getCurrencyRate` method implementation.\n *\n * @param req - The JSON-RPC request object.\n * @param res - The JSON-RPC response object.\n * @param _next - The `json-rpc-engine` \"next\" callback. Not used by this\n * function.\n * @param end - The `json-rpc-engine` \"end\" callback.\n * @param hooks - The RPC method hooks.\n * @param hooks.getCurrencyRate - The function to get the rate.\n * @returns Nothing.\n */\nfunction getGetCurrencyRateImplementation(\n req: JsonRpcRequest<GetCurrencyRateParameters>,\n res: PendingJsonRpcResponse<GetCurrencyRateResult>,\n _next: unknown,\n end: JsonRpcEngineEndCallback,\n { getCurrencyRate }: GetCurrencyRateMethodHooks,\n): void {\n const { params } = req;\n\n try {\n const validatedParams = getValidatedParams(params);\n\n const { currency: selectedCurrency } = validatedParams;\n\n res.result = getCurrencyRate(selectedCurrency) ?? null;\n } catch (error) {\n return end(error);\n }\n\n return end();\n}\n\n/**\n * Validate the getCurrencyRate method `params` and returns them cast to the correct\n * type. Throws if validation fails.\n *\n * @param params - The unvalidated params object from the method request.\n * @returns The validated getCurrencyRate method parameter object.\n */\nfunction getValidatedParams(params: unknown): GetCurrencyRateParameters {\n try {\n return create(params, GetCurrencyRateParametersStruct);\n } catch (error) {\n if (error instanceof StructError) {\n throw rpcErrors.invalidParams({\n message: `Invalid params: ${error.message}.`,\n });\n }\n /* istanbul ignore next */\n throw rpcErrors.internal();\n }\n}\n"]}
|
|
@@ -4,6 +4,7 @@ exports.handlers = exports.methodHandlers = void 0;
|
|
|
4
4
|
const createInterface_1 = require("./createInterface.cjs");
|
|
5
5
|
const getAllSnaps_1 = require("./getAllSnaps.cjs");
|
|
6
6
|
const getClientStatus_1 = require("./getClientStatus.cjs");
|
|
7
|
+
const getCurrencyRate_1 = require("./getCurrencyRate.cjs");
|
|
7
8
|
const getFile_1 = require("./getFile.cjs");
|
|
8
9
|
const getInterfaceState_1 = require("./getInterfaceState.cjs");
|
|
9
10
|
const getSnaps_1 = require("./getSnaps.cjs");
|
|
@@ -25,6 +26,7 @@ exports.methodHandlers = {
|
|
|
25
26
|
snap_updateInterface: updateInterface_1.updateInterfaceHandler,
|
|
26
27
|
snap_getInterfaceState: getInterfaceState_1.getInterfaceStateHandler,
|
|
27
28
|
snap_resolveInterface: resolveInterface_1.resolveInterfaceHandler,
|
|
29
|
+
snap_getCurrencyRate: getCurrencyRate_1.getCurrencyRateHandler,
|
|
28
30
|
};
|
|
29
31
|
/* eslint-enable @typescript-eslint/naming-convention */
|
|
30
32
|
exports.handlers = Object.values(exports.methodHandlers);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.cjs","sourceRoot":"","sources":["../../src/permitted/handlers.ts"],"names":[],"mappings":";;;AAAA,2DAA2D;AAC3D,mDAAmD;AACnD,2DAA2D;AAC3D,2CAA2C;AAC3C,+DAA+D;AAC/D,6CAA6C;AAC7C,uDAAuD;AACvD,2DAA2D;AAC3D,qDAAqD;AACrD,6DAA6D;AAC7D,2DAA2D;AAE3D,yDAAyD;AAC5C,QAAA,cAAc,GAAG;IAC5B,kBAAkB,EAAE,gCAAkB;IACtC,eAAe,EAAE,0BAAe;IAChC,mBAAmB,EAAE,kCAAmB;IACxC,iBAAiB,EAAE,wCAAsB;IACzC,oBAAoB,EAAE,oCAAoB;IAC1C,oBAAoB,EAAE,wCAAsB;IAC5C,YAAY,EAAE,wBAAc;IAC5B,oBAAoB,EAAE,wCAAsB;IAC5C,oBAAoB,EAAE,wCAAsB;IAC5C,sBAAsB,EAAE,4CAAwB;IAChD,qBAAqB,EAAE,0CAAuB;
|
|
1
|
+
{"version":3,"file":"handlers.cjs","sourceRoot":"","sources":["../../src/permitted/handlers.ts"],"names":[],"mappings":";;;AAAA,2DAA2D;AAC3D,mDAAmD;AACnD,2DAA2D;AAC3D,2DAA2D;AAC3D,2CAA2C;AAC3C,+DAA+D;AAC/D,6CAA6C;AAC7C,uDAAuD;AACvD,2DAA2D;AAC3D,qDAAqD;AACrD,6DAA6D;AAC7D,2DAA2D;AAE3D,yDAAyD;AAC5C,QAAA,cAAc,GAAG;IAC5B,kBAAkB,EAAE,gCAAkB;IACtC,eAAe,EAAE,0BAAe;IAChC,mBAAmB,EAAE,kCAAmB;IACxC,iBAAiB,EAAE,wCAAsB;IACzC,oBAAoB,EAAE,oCAAoB;IAC1C,oBAAoB,EAAE,wCAAsB;IAC5C,YAAY,EAAE,wBAAc;IAC5B,oBAAoB,EAAE,wCAAsB;IAC5C,oBAAoB,EAAE,wCAAsB;IAC5C,sBAAsB,EAAE,4CAAwB;IAChD,qBAAqB,EAAE,0CAAuB;IAC9C,oBAAoB,EAAE,wCAAsB;CAC7C,CAAC;AACF,wDAAwD;AAE3C,QAAA,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,sBAAc,CAAC,CAAC","sourcesContent":["import { createInterfaceHandler } from './createInterface';\nimport { getAllSnapsHandler } from './getAllSnaps';\nimport { getClientStatusHandler } from './getClientStatus';\nimport { getCurrencyRateHandler } from './getCurrencyRate';\nimport { getFileHandler } from './getFile';\nimport { getInterfaceStateHandler } from './getInterfaceState';\nimport { getSnapsHandler } from './getSnaps';\nimport { invokeKeyringHandler } from './invokeKeyring';\nimport { invokeSnapSugarHandler } from './invokeSnapSugar';\nimport { requestSnapsHandler } from './requestSnaps';\nimport { resolveInterfaceHandler } from './resolveInterface';\nimport { updateInterfaceHandler } from './updateInterface';\n\n/* eslint-disable @typescript-eslint/naming-convention */\nexport const methodHandlers = {\n wallet_getAllSnaps: getAllSnapsHandler,\n wallet_getSnaps: getSnapsHandler,\n wallet_requestSnaps: requestSnapsHandler,\n wallet_invokeSnap: invokeSnapSugarHandler,\n wallet_invokeKeyring: invokeKeyringHandler,\n snap_getClientStatus: getClientStatusHandler,\n snap_getFile: getFileHandler,\n snap_createInterface: createInterfaceHandler,\n snap_updateInterface: updateInterfaceHandler,\n snap_getInterfaceState: getInterfaceStateHandler,\n snap_resolveInterface: resolveInterfaceHandler,\n snap_getCurrencyRate: getCurrencyRateHandler,\n};\n/* eslint-enable @typescript-eslint/naming-convention */\n\nexport const handlers = Object.values(methodHandlers);\n"]}
|
|
@@ -20,8 +20,9 @@ export declare const methodHandlers: {
|
|
|
20
20
|
contents: string;
|
|
21
21
|
} | null> | null>>;
|
|
22
22
|
snap_resolveInterface: import("@metamask/permission-controller").PermittedHandlerExport<import("./resolveInterface.cjs").ResolveInterfaceMethodHooks, import("@metamask/snaps-sdk").ResolveInterfaceParams, null>;
|
|
23
|
+
snap_getCurrencyRate: import("@metamask/permission-controller").PermittedHandlerExport<import("./getCurrencyRate.cjs").GetCurrencyRateMethodHooks, import("@metamask/snaps-sdk").GetCurrencyRateParams, import("@metamask/snaps-sdk").GetCurrencyRateResult>;
|
|
23
24
|
};
|
|
24
|
-
export declare const handlers: (import("@metamask/permission-controller").PermittedHandlerExport<import("./createInterface.cjs").CreateInterfaceMethodHooks, import("@metamask/snaps-sdk").CreateInterfaceParams, string> | import("@metamask/permission-controller").PermittedHandlerExport<import("./getAllSnaps.cjs").GetAllSnapsHooks, import("@metamask/utils").JsonRpcParams, import("@metamask/snaps-sdk").GetSnapsResult> | import("@metamask/permission-controller").PermittedHandlerExport<import("./getClientStatus.cjs").GetClientStatusHooks, import("@metamask/utils").JsonRpcParams, import("@metamask/snaps-sdk").GetClientStatusResult> | import("@metamask/permission-controller").PermittedHandlerExport<import("./getInterfaceState.cjs").GetInterfaceStateMethodHooks, import("@metamask/snaps-sdk").GetInterfaceStateParams, Record<string, string | boolean | {
|
|
25
|
+
export declare const handlers: (import("@metamask/permission-controller").PermittedHandlerExport<import("./createInterface.cjs").CreateInterfaceMethodHooks, import("@metamask/snaps-sdk").CreateInterfaceParams, string> | import("@metamask/permission-controller").PermittedHandlerExport<import("./getAllSnaps.cjs").GetAllSnapsHooks, import("@metamask/utils").JsonRpcParams, import("@metamask/snaps-sdk").GetSnapsResult> | import("@metamask/permission-controller").PermittedHandlerExport<import("./getClientStatus.cjs").GetClientStatusHooks, import("@metamask/utils").JsonRpcParams, import("@metamask/snaps-sdk").GetClientStatusResult> | import("@metamask/permission-controller").PermittedHandlerExport<import("./getCurrencyRate.cjs").GetCurrencyRateMethodHooks, import("@metamask/snaps-sdk").GetCurrencyRateParams, import("@metamask/snaps-sdk").GetCurrencyRateResult> | import("@metamask/permission-controller").PermittedHandlerExport<import("./getInterfaceState.cjs").GetInterfaceStateMethodHooks, import("@metamask/snaps-sdk").GetInterfaceStateParams, Record<string, string | boolean | {
|
|
25
26
|
name: string;
|
|
26
27
|
size: number;
|
|
27
28
|
contentType: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.d.cts","sourceRoot":"","sources":["../../src/permitted/handlers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"handlers.d.cts","sourceRoot":"","sources":["../../src/permitted/handlers.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;CAa1B,CAAC;AAGF,eAAO,MAAM,QAAQ;;;;;;;;;;qzCAAgC,CAAC"}
|
|
@@ -20,8 +20,9 @@ export declare const methodHandlers: {
|
|
|
20
20
|
contents: string;
|
|
21
21
|
} | null> | null>>;
|
|
22
22
|
snap_resolveInterface: import("@metamask/permission-controller").PermittedHandlerExport<import("./resolveInterface.mjs").ResolveInterfaceMethodHooks, import("@metamask/snaps-sdk").ResolveInterfaceParams, null>;
|
|
23
|
+
snap_getCurrencyRate: import("@metamask/permission-controller").PermittedHandlerExport<import("./getCurrencyRate.mjs").GetCurrencyRateMethodHooks, import("@metamask/snaps-sdk").GetCurrencyRateParams, import("@metamask/snaps-sdk").GetCurrencyRateResult>;
|
|
23
24
|
};
|
|
24
|
-
export declare const handlers: (import("@metamask/permission-controller").PermittedHandlerExport<import("./createInterface.mjs").CreateInterfaceMethodHooks, import("@metamask/snaps-sdk").CreateInterfaceParams, string> | import("@metamask/permission-controller").PermittedHandlerExport<import("./getAllSnaps.mjs").GetAllSnapsHooks, import("@metamask/utils").JsonRpcParams, import("@metamask/snaps-sdk").GetSnapsResult> | import("@metamask/permission-controller").PermittedHandlerExport<import("./getClientStatus.mjs").GetClientStatusHooks, import("@metamask/utils").JsonRpcParams, import("@metamask/snaps-sdk").GetClientStatusResult> | import("@metamask/permission-controller").PermittedHandlerExport<import("./getInterfaceState.mjs").GetInterfaceStateMethodHooks, import("@metamask/snaps-sdk").GetInterfaceStateParams, Record<string, string | boolean | {
|
|
25
|
+
export declare const handlers: (import("@metamask/permission-controller").PermittedHandlerExport<import("./createInterface.mjs").CreateInterfaceMethodHooks, import("@metamask/snaps-sdk").CreateInterfaceParams, string> | import("@metamask/permission-controller").PermittedHandlerExport<import("./getAllSnaps.mjs").GetAllSnapsHooks, import("@metamask/utils").JsonRpcParams, import("@metamask/snaps-sdk").GetSnapsResult> | import("@metamask/permission-controller").PermittedHandlerExport<import("./getClientStatus.mjs").GetClientStatusHooks, import("@metamask/utils").JsonRpcParams, import("@metamask/snaps-sdk").GetClientStatusResult> | import("@metamask/permission-controller").PermittedHandlerExport<import("./getCurrencyRate.mjs").GetCurrencyRateMethodHooks, import("@metamask/snaps-sdk").GetCurrencyRateParams, import("@metamask/snaps-sdk").GetCurrencyRateResult> | import("@metamask/permission-controller").PermittedHandlerExport<import("./getInterfaceState.mjs").GetInterfaceStateMethodHooks, import("@metamask/snaps-sdk").GetInterfaceStateParams, Record<string, string | boolean | {
|
|
25
26
|
name: string;
|
|
26
27
|
size: number;
|
|
27
28
|
contentType: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.d.mts","sourceRoot":"","sources":["../../src/permitted/handlers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"handlers.d.mts","sourceRoot":"","sources":["../../src/permitted/handlers.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;CAa1B,CAAC;AAGF,eAAO,MAAM,QAAQ;;;;;;;;;;qzCAAgC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createInterfaceHandler } from "./createInterface.mjs";
|
|
2
2
|
import { getAllSnapsHandler } from "./getAllSnaps.mjs";
|
|
3
3
|
import { getClientStatusHandler } from "./getClientStatus.mjs";
|
|
4
|
+
import { getCurrencyRateHandler } from "./getCurrencyRate.mjs";
|
|
4
5
|
import { getFileHandler } from "./getFile.mjs";
|
|
5
6
|
import { getInterfaceStateHandler } from "./getInterfaceState.mjs";
|
|
6
7
|
import { getSnapsHandler } from "./getSnaps.mjs";
|
|
@@ -22,6 +23,7 @@ export const methodHandlers = {
|
|
|
22
23
|
snap_updateInterface: updateInterfaceHandler,
|
|
23
24
|
snap_getInterfaceState: getInterfaceStateHandler,
|
|
24
25
|
snap_resolveInterface: resolveInterfaceHandler,
|
|
26
|
+
snap_getCurrencyRate: getCurrencyRateHandler,
|
|
25
27
|
};
|
|
26
28
|
/* eslint-enable @typescript-eslint/naming-convention */
|
|
27
29
|
export const handlers = Object.values(methodHandlers);
|