parent
10d6cfd03d
commit
6d86914c94
@ -1,62 +0,0 @@ |
|||||||
diff --git a/node_modules/@metamask/snap-controllers/dist/snaps/SnapController.js b/node_modules/@metamask/snap-controllers/dist/snaps/SnapController.js
|
|
||||||
index ad84417..158e8e6 100644
|
|
||||||
--- a/node_modules/@metamask/snap-controllers/dist/snaps/SnapController.js
|
|
||||||
+++ b/node_modules/@metamask/snap-controllers/dist/snaps/SnapController.js
|
|
||||||
@@ -30,6 +30,7 @@ const RequestQueue_1 = require("./RequestQueue");
|
|
||||||
const utils_3 = require("./utils");
|
|
||||||
const Timer_1 = require("./Timer");
|
|
||||||
exports.controllerName = 'SnapController';
|
|
||||||
+exports.SNAP_APPROVAL_INSTALL = 'wallet_installSnap';
|
|
||||||
exports.SNAP_APPROVAL_UPDATE = 'wallet_updateSnap';
|
|
||||||
const TRUNCATED_SNAP_PROPERTIES = new Set([
|
|
||||||
'initialPermissions',
|
|
||||||
@@ -738,7 +739,7 @@ class SnapController extends controllers_1.BaseControllerV2 {
|
|
||||||
id: snapId,
|
|
||||||
versionRange,
|
|
||||||
});
|
|
||||||
- await this.authorize(snapId);
|
|
||||||
+ await this.authorize(origin, snapId);
|
|
||||||
await this._startSnap({
|
|
||||||
snapId,
|
|
||||||
sourceCode,
|
|
||||||
@@ -1073,18 +1074,34 @@ class SnapController extends controllers_1.BaseControllerV2 {
|
|
||||||
* @param snapId - The id of the Snap.
|
|
||||||
* @returns The snap's approvedPermissions.
|
|
||||||
*/
|
|
||||||
- async authorize(snapId) {
|
|
||||||
+ async authorize(origin, snapId) {
|
|
||||||
console.info(`Authorizing snap: ${snapId}`);
|
|
||||||
const snapsState = this.state.snaps;
|
|
||||||
const snap = snapsState[snapId];
|
|
||||||
const { initialPermissions } = snap;
|
|
||||||
try {
|
|
||||||
- if ((0, utils_1.isNonEmptyArray)(Object.keys(initialPermissions))) {
|
|
||||||
- const processedPermissions = this.processSnapPermissions(initialPermissions);
|
|
||||||
- const [approvedPermissions] = await this.messagingSystem.call('PermissionController:requestPermissions', { origin: snapId }, processedPermissions);
|
|
||||||
- return Object.values(approvedPermissions).map((perm) => perm.parentCapability);
|
|
||||||
+ const processedPermissions = this.processSnapPermissions(initialPermissions);
|
|
||||||
+ const id = (0, nanoid_1.nanoid)();
|
|
||||||
+ const isApproved = await this.messagingSystem.call('ApprovalController:addRequest', {
|
|
||||||
+ origin,
|
|
||||||
+ id,
|
|
||||||
+ type: exports.SNAP_APPROVAL_INSTALL,
|
|
||||||
+ requestData: {
|
|
||||||
+ // Mirror previous installation metadata
|
|
||||||
+ metadata: { id, origin: snapId, dappOrigin: origin },
|
|
||||||
+ permissions: processedPermissions,
|
|
||||||
+ snapId,
|
|
||||||
+ },
|
|
||||||
+ }, true);
|
|
||||||
+ if (!isApproved) {
|
|
||||||
+ throw eth_rpc_errors_1.ethErrors.provider.userRejectedRequest();
|
|
||||||
+ }
|
|
||||||
+ if ((0, utils_1.isNonEmptyArray)(Object.keys(processedPermissions))) {
|
|
||||||
+ await this.messagingSystem.call('PermissionController:grantPermissions', {
|
|
||||||
+ approvedPermissions: processedPermissions,
|
|
||||||
+ subject: { origin: snapId },
|
|
||||||
+ });
|
|
||||||
}
|
|
||||||
- return [];
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
const runtime = this.getRuntimeExpect(snapId);
|
|
@ -1,23 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<testsuites name="jest tests" tests="9" failures="0" errors="0" time="1.589"> |
|
||||||
<testsuite name="migration #74" errors="0" failures="0" skipped="0" timestamp="2022-09-28T15:39:56" time="1.319" tests="9"> |
|
||||||
<testcase classname="migration #74 should update the version metadata" name="migration #74 should update the version metadata" time="0.002"> |
|
||||||
</testcase> |
|
||||||
<testcase classname="migration #74 should add a deprecated testnet to custom networks if that network is currently selected and modify the provider type" name="migration #74 should add a deprecated testnet to custom networks if that network is currently selected and modify the provider type" time="0.001"> |
|
||||||
</testcase> |
|
||||||
<testcase classname="migration #74 should not add a deprecated testnet to custom networks if no deprecated testnet is selected" name="migration #74 should not add a deprecated testnet to custom networks if no deprecated testnet is selected" time="0"> |
|
||||||
</testcase> |
|
||||||
<testcase classname="migration #74 should add a deprecated testnet to custom networks if a transaction has been sent from that network" name="migration #74 should add a deprecated testnet to custom networks if a transaction has been sent from that network" time="0.001"> |
|
||||||
</testcase> |
|
||||||
<testcase classname="migration #74 should add a deprecated testnet to custom networks if there is balance on that network" name="migration #74 should add a deprecated testnet to custom networks if there is balance on that network" time="0.001"> |
|
||||||
</testcase> |
|
||||||
<testcase classname="migration #74 should add all three deprecated testnets to custom networks if each has a different reason for being added" name="migration #74 should add all three deprecated testnets to custom networks if each has a different reason for being added" time="0"> |
|
||||||
</testcase> |
|
||||||
<testcase classname="migration #74 should not add deprecated testnets to custom networks if none is selected and showTestNetworks is false" name="migration #74 should not add deprecated testnets to custom networks if none is selected and showTestNetworks is false" time="0"> |
|
||||||
</testcase> |
|
||||||
<testcase classname="migration #74 should not alter or remove existing custom networks when no deprecated testnets are being added" name="migration #74 should not alter or remove existing custom networks when no deprecated testnets are being added" time="0"> |
|
||||||
</testcase> |
|
||||||
<testcase classname="migration #74 should not modify an existing custom network with the same chainId as a deprecated testnet" name="migration #74 should not modify an existing custom network with the same chainId as a deprecated testnet" time="0.001"> |
|
||||||
</testcase> |
|
||||||
</testsuite> |
|
||||||
</testsuites> |
|
Loading…
Reference in new issue