Skip to content

Commit

Permalink
Import permission log controller (#1871)
Browse files Browse the repository at this point in the history
## Description

<!--
Thanks for your contribution! Take a moment to answer these questions so
that reviewers have the information they need to properly understand
your changes:

* What is the current state of things and why does it need to change?
* What is the solution your changes offer and how does it work?
* What packages are you updating?
* Are you introducing a breaking change to a package (renaming or
removing a part of a public interface)?
-->

This PR adds the `permission-log-controller` from metamask-extension.

## Changes

<!--
Pretend that you're updating a changelog. How would you categorize your
changes?

CATEGORY is one of:

- BREAKING
- ADDED
- CHANGED
- DEPRECATED
- REMOVED
- FIXED

(Security-related changes should go through the Security Advisory
process.)
-->

- **ADDED**: `permission-log-controller` controller

## References

<!--
Are there any issues or other links that reviewers should consult to
understand this pull request better? For instance:

* Fixes #12345
* See: #67890
-->

* Fixes: #1826

## Checklist

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation for new or updated code as appropriate
(note: this will usually be JSDoc)
- [x] I've highlighted breaking changes using the "BREAKING" category
above as appropriate

---------

Co-authored-by: Jongsun Suh <34228073+MajorLift@users.noreply.github.com>
  • Loading branch information
cryptodev-2s and MajorLift authored Nov 7, 2023
1 parent 7c74b62 commit e56b975
Show file tree
Hide file tree
Showing 19 changed files with 1,926 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ This repository houses the following packages:
- [`@metamask/selected-network-controller`](packages/selected-network-controller);
- [`@metamask/signature-controller`](packages/signature-controller)
- [`@metamask/transaction-controller`](packages/transaction-controller)
- [`@metamask/permission-log-controller`](packages/permission-log-controller)

Or, in graph form [^fn1]:

Expand Down Expand Up @@ -63,6 +64,7 @@ linkStyle default opacity:0.5
network_controller(["@metamask/network-controller"]);
notification_controller(["@metamask/notification-controller"]);
permission_controller(["@metamask/permission-controller"]);
permission_log_controller(["@metamask/permission-log-controller"]);
phishing_controller(["@metamask/phishing-controller"]);
polling_controller(["@metamask/polling-controller"]);
preferences_controller(["@metamask/preferences-controller"]);
Expand Down Expand Up @@ -110,6 +112,8 @@ linkStyle default opacity:0.5
permission_controller --> base_controller;
permission_controller --> controller_utils;
permission_controller --> json_rpc_engine;
permission_log_controller --> base_controller;
permission_log_controller --> json_rpc_engine;
phishing_controller --> base_controller;
phishing_controller --> controller_utils;
polling_controller --> base_controller;
Expand Down
5 changes: 5 additions & 0 deletions constraints.pro
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ gen_enforced_field(WorkspaceCwd, 'license', 'MIT') :-
\+ workspace_field(WorkspaceCwd, 'private', true),
WorkspaceCwd \= 'packages/json-rpc-engine',
WorkspaceCwd \= 'packages/json-rpc-middleware-stream',
WorkspaceCwd \= 'packages/permission-log-controller',
WorkspaceCwd \= 'packages/eth-json-rpc-provider'.
% The following published packages use an ISC license instead of MIT.
gen_enforced_field(WorkspaceCwd, 'license', 'ISC') :-
Expand All @@ -221,6 +222,10 @@ gen_enforced_field(WorkspaceCwd, 'license', 'ISC') :-
WorkspaceCwd == 'packages/json-rpc-middleware-stream' ;
WorkspaceCwd == 'packages/eth-json-rpc-provider'
).
% The following published packages use a custom license instead of MIT.
gen_enforced_field(WorkspaceCwd, 'license', 'SEE LICENSE IN LICENSE') :-
\+ workspace_field(WorkspaceCwd, 'private', true),
WorkspaceCwd == 'packages/permission-log-controller'.
% Non-published packages do not have a license.
gen_enforced_field(WorkspaceCwd, 'license', null) :-
workspace_field(WorkspaceCwd, 'private', true).
Expand Down
9 changes: 9 additions & 0 deletions packages/permission-log-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

[Unreleased]: https://github.com/MetaMask/core/
18 changes: 18 additions & 0 deletions packages/permission-log-controller/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Copyright ConsenSys Software Inc. 2022. All rights reserved.

You acknowledge and agree that ConsenSys Software Inc. (“ConsenSys”) (or ConsenSys’s licensors) own all legal right, title and interest in and to the work, software, application, source code, documentation and any other documents in this repository (collectively, the “Program”), including any intellectual property rights which subsist in the Program (whether those rights happen to be registered or not, and wherever in the world those rights may exist), whether in source code or any other form.

Subject to the limited license below, you may not (and you may not permit anyone else to) distribute, publish, copy, modify, merge, combine with another program, create derivative works of, reverse engineer, decompile or otherwise attempt to extract the source code of, the Program or any part thereof, except that you may contribute to this repository.

You are granted a non-exclusive, non-transferable, non-sublicensable license to distribute, publish, copy, modify, merge, combine with another program or create derivative works of the Program (such resulting program, collectively, the “Resulting Program”) solely for Non-Commercial Use as long as you:
1. give prominent notice (“Notice”) with each copy of the Resulting Program that the Program is used in the Resulting Program and that the Program is the copyright of ConsenSys; and
2. subject the Resulting Program and any distribution, publication, copy, modification, merger therewith, combination with another program or derivative works thereof to the same Notice requirement and Non-Commercial Use restriction set forth herein.

“Non-Commercial Use” means each use as described in clauses (1)-(3) below, as reasonably determined by ConsenSys in its sole discretion:
1. personal use for research, personal study, private entertainment, hobby projects or amateur pursuits, in each case without any anticipated commercial application;
2. use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization or government institution; or
3. the number of monthly active users of the Resulting Program across all versions thereof and platforms globally do not exceed 10,000 at any time.

You will not use any trade mark, service mark, trade name, logo of ConsenSys or any other company or organization in a way that is likely or intended to cause confusion about the owner or authorized user of such marks, names or logos.

If you have any questions, comments or interest in pursuing any other use cases, please reach out to us at communications@metamask.io.
15 changes: 15 additions & 0 deletions packages/permission-log-controller/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# `@metamask/permission-log-controller`

Controller with middleware for logging requests and responses to restricted and permissions-related methods.

## Installation

`yarn add @metamask/permission-log-controller`

or

`npm install @metamask/permission-log-controller`

## Contributing

This package is part of a monorepo. Instructions for contributing can be found in the [monorepo README](https://github.com/MetaMask/core#readme).
26 changes: 26 additions & 0 deletions packages/permission-log-controller/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/configuration
*/

const merge = require('deepmerge');
const path = require('path');

const baseConfig = require('../../jest.config.packages');

const displayName = path.basename(__dirname);

module.exports = merge(baseConfig, {
// The display name when running multiple projects
displayName,

// An object that configures minimum threshold enforcement for coverage results
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
},
},
});
58 changes: 58 additions & 0 deletions packages/permission-log-controller/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"name": "@metamask/permission-log-controller",
"version": "0.0.0",
"description": "Controller with middleware for logging requests and responses to restricted and permissions-related methods",
"keywords": [
"MetaMask",
"Ethereum"
],
"homepage": "https://github.com/MetaMask/core/tree/main/packages/permission-log-controller#readme",
"bugs": {
"url": "https://github.com/MetaMask/core/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/MetaMask/core.git"
},
"license": "SEE LICENSE IN LICENSE",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist/"
],
"scripts": {
"build:docs": "typedoc",
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/permission-log-controller",
"publish:preview": "yarn npm publish --tag preview",
"test": "jest --reporters=jest-silent-reporter",
"test:clean": "jest --clearCache",
"test:verbose": "jest --verbose",
"test:watch": "jest --watch"
},
"dependencies": {
"@metamask/base-controller": "^3.2.3",
"@metamask/json-rpc-engine": "^7.2.0",
"@metamask/utils": "^8.2.0"
},
"devDependencies": {
"@metamask/auto-changelog": "^3.4.3",
"@types/deep-freeze-strict": "^1.1.0",
"@types/jest": "^27.4.1",
"deep-freeze-strict": "^1.1.1",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
"nanoid": "^3.1.31",
"sinon": "^9.2.4",
"ts-jest": "^27.1.4",
"typedoc": "^0.24.8",
"typedoc-plugin-missing-exports": "^2.0.0",
"typescript": "~4.8.4"
},
"engines": {
"node": ">=16.0.0"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
}
}
Loading

0 comments on commit e56b975

Please sign in to comment.