Skip to content

Commit 70bd65f

Browse files
jiexiGudahttadonesky1
authored
feat: create initial @metamask/multichain package (#4812)
## Explanation Creates the initial (empty) `@metamask/multichain` package to make downstream additions to this package easier to review. ## References Upstream: #4811 Downstream: #4784 ## Changelog ### `@metamask/multichain` - **ADDED**: Initial skeleton package for `@metamask/multichain` ## Checklist - [X] I've updated the test suite for new or updated code as appropriate - [X] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [X] I've highlighted breaking changes using the "BREAKING" category above as appropriate - [X] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes --------- Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: Alex <adonesky@gmail.com>
1 parent fe28a23 commit 70bd65f

File tree

14 files changed

+213
-11
lines changed

14 files changed

+213
-11
lines changed

README.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ This repository contains the following packages [^fn1]:
2626
- [`@metamask/keyring-controller`](packages/keyring-controller)
2727
- [`@metamask/logging-controller`](packages/logging-controller)
2828
- [`@metamask/message-manager`](packages/message-manager)
29+
- [`@metamask/multichain`](packages/multichain)
2930
- [`@metamask/name-controller`](packages/name-controller)
3031
- [`@metamask/network-controller`](packages/network-controller)
3132
- [`@metamask/notification-controller`](packages/notification-controller)
@@ -71,6 +72,7 @@ linkStyle default opacity:0.5
7172
keyring_controller(["@metamask/keyring-controller"]);
7273
logging_controller(["@metamask/logging-controller"]);
7374
message_manager(["@metamask/message-manager"]);
75+
multichain(["@metamask/multichain"]);
7476
name_controller(["@metamask/name-controller"]);
7577
network_controller(["@metamask/network-controller"]);
7678
notification_controller(["@metamask/notification-controller"]);
@@ -93,14 +95,15 @@ linkStyle default opacity:0.5
9395
address_book_controller --> controller_utils;
9496
announcement_controller --> base_controller;
9597
approval_controller --> base_controller;
96-
assets_controllers --> accounts_controller;
97-
assets_controllers --> approval_controller;
9898
assets_controllers --> base_controller;
9999
assets_controllers --> controller_utils;
100+
assets_controllers --> polling_controller;
101+
assets_controllers --> accounts_controller;
102+
assets_controllers --> approval_controller;
100103
assets_controllers --> keyring_controller;
101104
assets_controllers --> network_controller;
102-
assets_controllers --> polling_controller;
103105
assets_controllers --> preferences_controller;
106+
base_controller --> json_rpc_engine;
104107
chain_controller --> base_controller;
105108
composable_controller --> base_controller;
106109
composable_controller --> json_rpc_engine;
@@ -110,8 +113,8 @@ linkStyle default opacity:0.5
110113
eth_json_rpc_provider --> json_rpc_engine;
111114
gas_fee_controller --> base_controller;
112115
gas_fee_controller --> controller_utils;
113-
gas_fee_controller --> network_controller;
114116
gas_fee_controller --> polling_controller;
117+
gas_fee_controller --> network_controller;
115118
json_rpc_middleware_stream --> json_rpc_engine;
116119
keyring_controller --> base_controller;
117120
keyring_controller --> message_manager;
@@ -145,6 +148,9 @@ linkStyle default opacity:0.5
145148
preferences_controller --> controller_utils;
146149
preferences_controller --> keyring_controller;
147150
profile_sync_controller --> base_controller;
151+
profile_sync_controller --> keyring_controller;
152+
profile_sync_controller --> accounts_controller;
153+
profile_sync_controller --> network_controller;
148154
queued_request_controller --> base_controller;
149155
queued_request_controller --> controller_utils;
150156
queued_request_controller --> json_rpc_engine;
@@ -155,26 +161,25 @@ linkStyle default opacity:0.5
155161
selected_network_controller --> json_rpc_engine;
156162
selected_network_controller --> network_controller;
157163
selected_network_controller --> permission_controller;
158-
signature_controller --> approval_controller;
159164
signature_controller --> base_controller;
160165
signature_controller --> controller_utils;
166+
signature_controller --> approval_controller;
161167
signature_controller --> keyring_controller;
162168
signature_controller --> logging_controller;
163-
signature_controller --> message_manager;
164-
transaction_controller --> accounts_controller;
165-
transaction_controller --> approval_controller;
166169
transaction_controller --> base_controller;
167170
transaction_controller --> controller_utils;
171+
transaction_controller --> accounts_controller;
172+
transaction_controller --> approval_controller;
173+
transaction_controller --> eth_json_rpc_provider;
168174
transaction_controller --> gas_fee_controller;
169175
transaction_controller --> network_controller;
170-
transaction_controller --> eth_json_rpc_provider;
171-
user_operation_controller --> approval_controller;
172176
user_operation_controller --> base_controller;
173177
user_operation_controller --> controller_utils;
178+
user_operation_controller --> polling_controller;
179+
user_operation_controller --> approval_controller;
174180
user_operation_controller --> gas_fee_controller;
175181
user_operation_controller --> keyring_controller;
176182
user_operation_controller --> network_controller;
177-
user_operation_controller --> polling_controller;
178183
user_operation_controller --> transaction_controller;
179184
```
180185

packages/multichain/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
[Unreleased]: https://github.com/MetaMask/core/

packages/multichain/LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
MIT License
2+
3+
Copyright (c) 2024 MetaMask
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

packages/multichain/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# `@metamask/multichain`
2+
3+
Provides types, helpers, adapters, and wrappers for facilitating CAIP Multichain sessions
4+
5+
## Installation
6+
7+
`yarn add @metamask/multichain`
8+
9+
or
10+
11+
`npm install @metamask/multichain`
12+
13+
## Contributing
14+
15+
This package is part of a monorepo. Instructions for contributing can be found in the [monorepo README](https://github.com/MetaMask/core#readme).

packages/multichain/jest.config.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* For a detailed explanation regarding each configuration property and type check, visit:
3+
* https://jestjs.io/docs/configuration
4+
*/
5+
6+
const merge = require('deepmerge');
7+
const path = require('path');
8+
9+
const baseConfig = require('../../jest.config.packages');
10+
11+
const displayName = path.basename(__dirname);
12+
13+
module.exports = merge(baseConfig, {
14+
// The display name when running multiple projects
15+
displayName,
16+
17+
// An object that configures minimum threshold enforcement for coverage results
18+
coverageThreshold: {
19+
global: {
20+
branches: 100,
21+
functions: 100,
22+
lines: 100,
23+
statements: 100,
24+
},
25+
},
26+
});

packages/multichain/package.json

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"name": "@metamask/multichain",
3+
"version": "0.0.0",
4+
"description": "Provides types, helpers, adapters, and wrappers for facilitating CAIP Multichain sessions",
5+
"keywords": [
6+
"MetaMask",
7+
"Ethereum"
8+
],
9+
"homepage": "https://github.com/MetaMask/core/tree/main/packages/multichain#readme",
10+
"bugs": {
11+
"url": "https://github.com/MetaMask/core/issues"
12+
},
13+
"repository": {
14+
"type": "git",
15+
"url": "https://github.com/MetaMask/core.git"
16+
},
17+
"license": "MIT",
18+
"sideEffects": false,
19+
"exports": {
20+
".": {
21+
"import": {
22+
"types": "./dist/index.d.mts",
23+
"default": "./dist/index.mjs"
24+
},
25+
"require": {
26+
"types": "./dist/index.d.cts",
27+
"default": "./dist/index.cjs"
28+
}
29+
},
30+
"./package.json": "./package.json"
31+
},
32+
"main": "./dist/index.cjs",
33+
"types": "./dist/index.d.cts",
34+
"files": [
35+
"dist/"
36+
],
37+
"scripts": {
38+
"build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
39+
"build:docs": "typedoc",
40+
"changelog:update": "../../scripts/update-changelog.sh @metamask/multichain",
41+
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/multichain",
42+
"publish:preview": "yarn npm publish --tag preview",
43+
"since-latest-release": "../../scripts/since-latest-release.sh",
44+
"test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
45+
"test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
46+
"test:verbose": "NODE_OPTIONS=--experimental-vm-modules jest --verbose",
47+
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
48+
},
49+
"devDependencies": {
50+
"@metamask/auto-changelog": "^3.4.4",
51+
"@types/jest": "^27.4.1",
52+
"deepmerge": "^4.2.2",
53+
"jest": "^27.5.1",
54+
"ts-jest": "^27.1.4",
55+
"typedoc": "^0.24.8",
56+
"typedoc-plugin-missing-exports": "^2.0.0",
57+
"typescript": "~5.2.2"
58+
},
59+
"engines": {
60+
"node": "^18.18 || >=20"
61+
},
62+
"publishConfig": {
63+
"access": "public",
64+
"registry": "https://registry.npmjs.org/"
65+
}
66+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import greeter from '.';
2+
3+
describe('Test', () => {
4+
it('greets', () => {
5+
const name = 'Huey';
6+
const result = greeter(name);
7+
expect(result).toBe('Hello, Huey!');
8+
});
9+
});

packages/multichain/src/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Example function that returns a greeting for the given name.
3+
*
4+
* @param name - The name to greet.
5+
* @returns The greeting.
6+
*/
7+
export default function greeter(name: string): string {
8+
return `Hello, ${name}!`;
9+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "../../tsconfig.packages.build.json",
3+
"compilerOptions": {
4+
"baseUrl": "./",
5+
"outDir": "./dist",
6+
"rootDir": "./src"
7+
},
8+
"references": [],
9+
"include": ["../../types", "./src"]
10+
}

packages/multichain/tsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../../tsconfig.packages.json",
3+
"compilerOptions": {
4+
"baseUrl": "./"
5+
},
6+
"references": [],
7+
"include": ["../../types", "./src"]
8+
}

0 commit comments

Comments
 (0)