Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Bump @metamask/permission-controller to ^11.0.0 #28743

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions app/scripts/controllers/permissions/caveat-mutators.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ function removeAccount(targetAccount, existingAccounts) {
);

if (newAccounts.length === existingAccounts.length) {
return { operation: CaveatMutatorOperation.noop };
return { operation: CaveatMutatorOperation.Noop };
} else if (newAccounts.length > 0) {
return {
operation: CaveatMutatorOperation.updateValue,
operation: CaveatMutatorOperation.UpdateValue,
value: newAccounts,
};
}
return { operation: CaveatMutatorOperation.revokePermission };
return { operation: CaveatMutatorOperation.RevokePermission };
}

/**
Expand All @@ -60,12 +60,12 @@ function removeChainId(targetChainId, existingChainIds) {
);

if (newChainIds.length === existingChainIds.length) {
return { operation: CaveatMutatorOperation.noop };
return { operation: CaveatMutatorOperation.Noop };
} else if (newChainIds.length > 0) {
return {
operation: CaveatMutatorOperation.updateValue,
operation: CaveatMutatorOperation.UpdateValue,
value: newChainIds,
};
}
return { operation: CaveatMutatorOperation.revokePermission };
return { operation: CaveatMutatorOperation.RevokePermission };
}
14 changes: 7 additions & 7 deletions app/scripts/controllers/permissions/caveat-mutators.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ describe('caveat mutators', () => {
describe('removeAccount', () => {
it('returns the no-op operation if the target account is not permitted', () => {
expect(removeAccount(address2, [address1])).toStrictEqual({
operation: CaveatMutatorOperation.noop,
operation: CaveatMutatorOperation.Noop,
});
});

it('returns the update operation and a new value if the target account is permitted', () => {
expect(removeAccount(address2, [address1, address2])).toStrictEqual({
operation: CaveatMutatorOperation.updateValue,
operation: CaveatMutatorOperation.UpdateValue,
value: [address1],
});
});

it('returns the revoke permission operation the target account is the only permitted account', () => {
expect(removeAccount(address1, [address1])).toStrictEqual({
operation: CaveatMutatorOperation.revokePermission,
operation: CaveatMutatorOperation.RevokePermission,
});
});

Expand All @@ -36,28 +36,28 @@ describe('caveat mutators', () => {
const checksummedAddress3 =
'0x95222290dd7278AA3DDd389cc1E1d165Cc4BaeE5';
expect(removeAccount(checksummedAddress3, [address3])).toStrictEqual({
operation: CaveatMutatorOperation.revokePermission,
operation: CaveatMutatorOperation.RevokePermission,
});
});

describe('Multichain behaviour', () => {
it('returns the no-op operation if the target account is not permitted', () => {
expect(removeAccount(address2, [nonEvmAddress])).toStrictEqual({
operation: CaveatMutatorOperation.noop,
operation: CaveatMutatorOperation.Noop,
});
});

it('can revoke permission for non-EVM addresses', () => {
expect(removeAccount(nonEvmAddress, [nonEvmAddress])).toStrictEqual({
operation: CaveatMutatorOperation.revokePermission,
operation: CaveatMutatorOperation.RevokePermission,
});
});

it('returns the update operation and a new value if the target non-EVM account is permitted', () => {
expect(
removeAccount(nonEvmAddress, [address1, nonEvmAddress]),
).toStrictEqual({
operation: CaveatMutatorOperation.updateValue,
operation: CaveatMutatorOperation.UpdateValue,
value: [address1],
});
});
Expand Down
135 changes: 7 additions & 128 deletions lavamoat/browserify/beta/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -2173,82 +2173,16 @@
"console.error": true
},
"packages": {
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"@metamask/permission-controller>@metamask/base-controller": true,
"@metamask/permission-controller>@metamask/json-rpc-engine": true,
"@metamask/permission-controller>@metamask/rpc-errors": true,
"@metamask/permission-controller>@metamask/utils": true,
"@metamask/json-rpc-engine": true,
"@metamask/permission-controller>nanoid": true,
"@metamask/rpc-errors": true,
"@metamask/utils": true,
"deep-freeze-strict": true,
"immer": true
}
},
"@metamask/permission-controller>@metamask/base-controller": {
"globals": {
"setTimeout": true
},
"packages": {
"immer": true
}
},
"@metamask/permission-controller>@metamask/json-rpc-engine": {
"packages": {
"@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/utils": true,
"@metamask/permission-controller>@metamask/rpc-errors": true,
"@metamask/safe-event-emitter": true
}
},
"@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
},
"packages": {
"@metamask/utils>@metamask/superstruct": true,
"@metamask/utils>@scure/base": true,
"@metamask/utils>pony-cause": true,
"@noble/hashes": true,
"browserify>buffer": true,
"nock>debug": true,
"semver": true
}
},
"@metamask/permission-controller>@metamask/rpc-errors": {
"packages": {
"@metamask/permission-controller>@metamask/rpc-errors>@metamask/utils": true,
"@metamask/rpc-errors>fast-safe-stringify": true
}
},
"@metamask/permission-controller>@metamask/rpc-errors>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
},
"packages": {
"@metamask/utils>@metamask/superstruct": true,
"@metamask/utils>@scure/base": true,
"@metamask/utils>pony-cause": true,
"@noble/hashes": true,
"browserify>buffer": true,
"nock>debug": true,
"semver": true
}
},
"@metamask/permission-controller>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
},
"packages": {
"@metamask/utils>@metamask/superstruct": true,
"@metamask/utils>@scure/base": true,
"@metamask/utils>pony-cause": true,
"@noble/hashes": true,
"browserify>buffer": true,
"nock>debug": true,
"semver": true
}
},
"@metamask/permission-controller>nanoid": {
"globals": {
"crypto.getRandomValues": true
Expand Down Expand Up @@ -2822,9 +2756,9 @@
"@metamask/json-rpc-engine": true,
"@metamask/json-rpc-middleware-stream": true,
"@metamask/object-multiplex": true,
"@metamask/permission-controller": true,
"@metamask/post-message-stream": true,
"@metamask/rpc-errors": true,
"@metamask/snaps-controllers>@metamask/permission-controller": true,
"@metamask/snaps-controllers>@xstate/fsm": true,
"@metamask/snaps-controllers>concat-stream": true,
"@metamask/snaps-controllers>get-npm-tarball-url": true,
Expand All @@ -2848,21 +2782,6 @@
"crypto.getRandomValues": true
}
},
"@metamask/snaps-controllers>@metamask/permission-controller": {
"globals": {
"console.error": true
},
"packages": {
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"@metamask/json-rpc-engine": true,
"@metamask/rpc-errors": true,
"@metamask/snaps-controllers>nanoid": true,
"@metamask/utils": true,
"deep-freeze-strict": true,
"immer": true
}
},
"@metamask/snaps-controllers>concat-stream": {
"packages": {
"browserify>buffer": true,
Expand Down Expand Up @@ -2920,8 +2839,8 @@
},
"@metamask/snaps-rpc-methods": {
"packages": {
"@metamask/permission-controller": true,
"@metamask/rpc-errors": true,
"@metamask/snaps-rpc-methods>@metamask/permission-controller": true,
"@metamask/snaps-sdk": true,
"@metamask/snaps-sdk>@metamask/key-tree": true,
"@metamask/snaps-utils": true,
Expand All @@ -2930,26 +2849,6 @@
"@noble/hashes": true
}
},
"@metamask/snaps-rpc-methods>@metamask/permission-controller": {
"globals": {
"console.error": true
},
"packages": {
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"@metamask/json-rpc-engine": true,
"@metamask/rpc-errors": true,
"@metamask/snaps-rpc-methods>@metamask/permission-controller>nanoid": true,
"@metamask/utils": true,
"deep-freeze-strict": true,
"immer": true
}
},
"@metamask/snaps-rpc-methods>@metamask/permission-controller>nanoid": {
"globals": {
"crypto.getRandomValues": true
}
},
"@metamask/snaps-sdk": {
"globals": {
"fetch": true
Expand Down Expand Up @@ -3000,10 +2899,10 @@
"fetch": true
},
"packages": {
"@metamask/permission-controller": true,
"@metamask/rpc-errors": true,
"@metamask/snaps-sdk": true,
"@metamask/snaps-sdk>@metamask/key-tree": true,
"@metamask/snaps-utils>@metamask/permission-controller": true,
"@metamask/snaps-utils>@metamask/slip44": true,
"@metamask/snaps-utils>cron-parser": true,
"@metamask/snaps-utils>fast-json-stable-stringify": true,
Expand All @@ -3019,26 +2918,6 @@
"semver": true
}
},
"@metamask/snaps-utils>@metamask/permission-controller": {
"globals": {
"console.error": true
},
"packages": {
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"@metamask/json-rpc-engine": true,
"@metamask/rpc-errors": true,
"@metamask/snaps-utils>@metamask/permission-controller>nanoid": true,
"@metamask/utils": true,
"deep-freeze-strict": true,
"immer": true
}
},
"@metamask/snaps-utils>@metamask/permission-controller>nanoid": {
"globals": {
"crypto.getRandomValues": true
}
},
"@metamask/snaps-utils>@metamask/snaps-registry": {
"packages": {
"@metamask/message-signing-snap>@noble/curves": true,
Expand Down
Loading
Loading