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: Add CAIP-25 permission and adapters to @metamask/multichain #4784

Merged
merged 169 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
169 commits
Select commit Hold shift + click to select a range
bc56104
Initial package
jiexi Oct 10, 2024
a4b52ad
Fix caip25Permission
jiexi Oct 10, 2024
86ab58a
scopes
jiexi Oct 10, 2024
186d4b3
Fix middlewares
jiexi Oct 10, 2024
6a93d1d
Fix adapters except permission middleware
jiexi Oct 10, 2024
231bcaa
Rename handlers js to ts
jiexi Oct 10, 2024
4e52fc0
permission middleware test js ts rename
jiexi Oct 10, 2024
151eaac
fix: typescript + linting (#4788)
shanejonas Oct 11, 2024
85a723e
Added exports for multichain package (#4789)
shanejonas Oct 11, 2024
a0bb278
Add requires
jiexi Oct 11, 2024
1cd8ef2
add permittedChains adapter to exports
jiexi Oct 11, 2024
c636def
kill scope index barrel
jiexi Oct 11, 2024
a6aa7c1
barrel
jiexi Oct 14, 2024
42134f7
Merge branch 'main' into caip-multichain
jiexi Oct 14, 2024
a13b9c7
remove subjectTypes from CAIP-25 permission
jiexi Oct 14, 2024
81db877
update eth accounts adapter with empty wallet and wallet:eip155 Scope…
jiexi Oct 14, 2024
a3fc263
fix caip25permission spec
jiexi Oct 14, 2024
afe5cb9
upsert empty wallet:eip155 when setting permittedChains
jiexi Oct 14, 2024
9ea78be
lint
jiexi Oct 14, 2024
5650d31
Rename scope.test.ts to types.test.ts
jiexi Oct 14, 2024
df5167e
add networkClientId type to permission-adapter-middleware
jiexi Oct 15, 2024
9446b0b
fix snapshot
jiexi Oct 15, 2024
f65ca24
Merge branch 'main' into caip-multichain
jiexi Oct 15, 2024
941849d
add KnownWalletScopeString enum
jiexi Oct 15, 2024
a250de2
stop upserting wallet scope in setEthAccounts()
jiexi Oct 15, 2024
aa7ba39
lint
jiexi Oct 15, 2024
8415be6
update removeScope mutator to not revoke permission if requiredScope …
jiexi Oct 15, 2024
c7f510e
Fix specificationBuilder jsdoc and typing
jiexi Oct 15, 2024
4afa8f8
Fix caip25permission type
jiexi Oct 15, 2024
597e837
Fix caip25permission type
jiexi Oct 15, 2024
1872188
small dry todo fix
adonesky1 Oct 15, 2024
c5d8005
another small dry
adonesky1 Oct 15, 2024
54f7c49
Added handler wrappers to better integrate with existing middleware (…
shanejonas Oct 15, 2024
ada451d
change subscriptionManager require to import
jiexi Oct 15, 2024
2322e39
lint
jiexi Oct 15, 2024
9b21677
Merge branch 'main' into caip-multichain
jiexi Oct 16, 2024
00a41cb
Jl/caip multichain/update scope object account types (#4803)
jiexi Oct 16, 2024
f30dd8b
update @metamask/rpc-errors version
adonesky1 Oct 17, 2024
71085a0
fix merge
adonesky1 Oct 17, 2024
f2be8f0
Merge branch 'main' into caip-multichain
jiexi Oct 17, 2024
644f4d0
Add isEqualCaseInsensitive to controller-utils
jiexi Oct 17, 2024
1b78bbc
create initial multichain package
jiexi Oct 17, 2024
fc28c89
remove API related logic
jiexi Oct 17, 2024
ba25ce5
Merge branch 'initialize-caip-multichain' into caip-multichain
jiexi Oct 17, 2024
4ceb118
remove api related deps
jiexi Oct 17, 2024
9bcf869
Fix package.json
jiexi Oct 17, 2024
633485c
Merge branch 'initialize-caip-multichain' into caip-multichain
jiexi Oct 17, 2024
afb2e2c
fix bad merge
jiexi Oct 17, 2024
109a7bf
Update packages/controller-utils/src/util.test.ts
jiexi Oct 17, 2024
1e67641
Merge branch 'controller-utils-isEqualCaseInsensitive' into initializ…
jiexi Oct 17, 2024
32b213a
Merge branch 'initialize-caip-multichain' into caip-multichain
jiexi Oct 17, 2024
dae4f73
add account support check in validator (#4816)
jiexi Oct 17, 2024
d7ed999
Merge branch 'main' into initialize-caip-multichain
jiexi Oct 21, 2024
b4b65e2
Merge branch 'initialize-caip-multichain' into caip-multichain
jiexi Oct 21, 2024
fad338d
remove caip-permission-adapter-middleware
jiexi Oct 21, 2024
c5980c6
remove caip-permission-adapter-middleware from exports
jiexi Oct 21, 2024
a7a8e6e
remove types/@metamask/eth-json-rpc-filters.d.ts
jiexi Oct 21, 2024
6b367f0
Merge branch 'main' into caip-multichain
adonesky1 Oct 21, 2024
42297f9
add back readme content
adonesky1 Oct 21, 2024
26acfcd
Merge branch 'main' into initialize-caip-multichain
jiexi Oct 21, 2024
2e3bfb4
Merge branch 'initialize-caip-multichain' into caip-multichain
jiexi Oct 21, 2024
7203358
bump network-controller dep
jiexi Oct 22, 2024
046133a
add Scoped Properties to Caip25Authorization type
jiexi Oct 22, 2024
eea9f46
Merge branch 'main' into caip-multichain
jiexi Oct 22, 2024
67b222e
Fix ScopedProperties type
jiexi Oct 22, 2024
009fb4a
Loosen get adapter param types (#4835)
jiexi Oct 22, 2024
0631c48
Seperate types and constants
jiexi Oct 23, 2024
4685547
Merge branch 'main' into caip-multichain
jiexi Oct 23, 2024
18d1112
remove jest.resetAllMocks
jiexi Oct 23, 2024
1ba77c7
yarn lock
jiexi Oct 23, 2024
bb50a19
yarn
jiexi Oct 23, 2024
7d32a0b
100% coverage
jiexi Oct 23, 2024
f095370
Remove accountsChanged and chainChanged from KnownNotifications (sinc…
jiexi Oct 23, 2024
62929a4
Merge branch 'main' into caip-multichain
jiexi Oct 23, 2024
491552f
Update packages/multichain/src/scope/transform.test.ts
jiexi Oct 24, 2024
bd0f50f
Merge branch 'main' into caip-multichain
jiexi Oct 24, 2024
cad5e3e
Merge branch 'main' into caip-multichain
jiexi Oct 28, 2024
757b177
align deps
jiexi Oct 28, 2024
dcb593b
rename Caip25CaveatFactoryFn to createCaip25Caveat
jiexi Oct 28, 2024
16aa686
switch removeScope param order
jiexi Oct 28, 2024
f8b887c
switch removeAccount param order
jiexi Oct 28, 2024
632db4b
do not export removeScope directly. fix Caip25CaveatMutatorFactories …
jiexi Oct 28, 2024
628a38c
reorder removeAccountOnScope params
jiexi Oct 28, 2024
6346955
rename Caip25CaveatMutatorFactories to Caip25CaveatMutators
jiexi Oct 28, 2024
d40d63d
fix barrel export
jiexi Oct 28, 2024
d75d5d6
replace node assert with lodash.isEqual
jiexi Oct 28, 2024
23d10ed
reorganize describes in caip25Permission.test.ts
jiexi Oct 29, 2024
30948a7
Merge branch 'main' into caip-multichain
jiexi Oct 29, 2024
788c9eb
adjust caveat mutator scenarios
jiexi Oct 29, 2024
b859af5
Update packages/multichain/src/adapters/caip-permission-adapter-eth-a…
jiexi Oct 29, 2024
5902e74
Update packages/multichain/src/adapters/caip-permission-adapter-permi…
jiexi Oct 29, 2024
8c10fc0
Update packages/multichain/src/adapters/caip-permission-adapter-permi…
jiexi Oct 29, 2024
7712d54
nest noramlizeScope 'scopeString is chain scoped'
jiexi Oct 29, 2024
1d4a076
Merge remote-tracking branch 'origin/caip-multichain' into caip-multi…
jiexi Oct 29, 2024
d3fbaa9
make Scope Transform normalizeScope chain scoped test body more explicit
jiexi Oct 29, 2024
02f35f5
replace type cast with @ts-expect-error
jiexi Oct 29, 2024
053b5ea
yarn
jiexi Oct 29, 2024
ac9835c
Flatten isValidScope test
jiexi Oct 29, 2024
72e228e
Fix validation.test.ts ts-expect-error
jiexi Oct 29, 2024
bd10406
flatten isSupportedAccount it.each
jiexi Oct 29, 2024
e5e39eb
cleanup removeAccount function docs/comments
adonesky1 Nov 7, 2024
27e0808
add JSDoc for caip25EndowmentBuilder
adonesky1 Nov 7, 2024
0c679a8
repace reduceKeyHelper with Object.fromEntries
adonesky1 Nov 7, 2024
c5ed91c
add bip122 entries to "known" method consts
adonesky1 Nov 7, 2024
91e426c
removeAccountOnScope -> removeAccountFromScopeObject
adonesky1 Nov 7, 2024
619e34d
rename param of 'removeAccount' caip25Permission helper function
adonesky1 Nov 7, 2024
35a81ce
remove unnecessary type assertion
adonesky1 Nov 7, 2024
b04a941
fix bug in normalizeScope
adonesky1 Nov 7, 2024
41e0413
refactor normalizeScope for clarity
adonesky1 Nov 7, 2024
3f56531
add JSDocs for scope(s)Object types
adonesky1 Nov 7, 2024
9c40d69
add JSDocs for Scope types
adonesky1 Nov 7, 2024
71f254a
add 'Internal' prefix to CAIP-25 Scope types
adonesky1 Nov 7, 2024
828080f
improve JSDoc
adonesky1 Nov 7, 2024
de7ac07
Update packages/multichain/src/scope/authorization.ts
adonesky1 Nov 7, 2024
aa24e96
cleanup consts/types and comments
adonesky1 Nov 7, 2024
da87d65
fix imports
adonesky1 Nov 7, 2024
be5a235
Merge branch 'main' into caip-multichain
adonesky1 Nov 7, 2024
8194afd
add more TSDocs
adonesky1 Nov 7, 2024
20311d3
update lock file
adonesky1 Nov 7, 2024
6e345cf
add more documentation + function annotations
adonesky1 Nov 8, 2024
ef5d500
align package versions
adonesky1 Nov 8, 2024
71b9820
update lockfile
adonesky1 Nov 8, 2024
f37586d
add error constants
adonesky1 Nov 8, 2024
67bd1d2
Update packages/multichain/src/scope/constants.ts
adonesky1 Nov 8, 2024
cc686bc
add snapshot test for KnownRpcMethods
adonesky1 Nov 8, 2024
664069b
improve ScopeObject validation
adonesky1 Nov 8, 2024
1abd454
error builder methods
adonesky1 Nov 8, 2024
0899f26
lint
adonesky1 Nov 8, 2024
b99b78f
improve type checks in supported helper methods
adonesky1 Nov 8, 2024
97c59e8
lint
adonesky1 Nov 8, 2024
b700e4f
validateScopes -> getValidScopes
adonesky1 Nov 8, 2024
e576295
narrow validation of references property
adonesky1 Nov 8, 2024
ba9c728
fixup type check functions
adonesky1 Nov 8, 2024
ee616de
add tests for errors file
adonesky1 Nov 8, 2024
5633bdd
add TSDoc
adonesky1 Nov 8, 2024
43cddcc
Update packages/multichain/src/scope/transform.ts
adonesky1 Nov 8, 2024
693ee5c
chore: Suggestion on simplifying type guard (#4912)
Gudahtt Nov 8, 2024
4b1b1b9
lint
adonesky1 Nov 8, 2024
7ceab94
add more tests for transform helpers
adonesky1 Nov 11, 2024
86450dc
add caip25 error code snapshot tests
adonesky1 Nov 11, 2024
858f764
add mocking to fix test
adonesky1 Nov 11, 2024
b525790
fix typo
adonesky1 Nov 11, 2024
6c313bc
Update packages/multichain/src/adapters/caip-permission-adapter-eth-a…
adonesky1 Nov 11, 2024
1a59b95
add getEthAccounts tests
adonesky1 Nov 11, 2024
d73f644
cleanup type casting
adonesky1 Nov 11, 2024
5371ff0
Expand setEthAccounts TSDoc comment
adonesky1 Nov 12, 2024
8d490f7
fix type casting
adonesky1 Nov 12, 2024
aba8857
update TSDoc for addPermittedEthChainId
adonesky1 Nov 12, 2024
fc71fc6
update setPermittedEthChainIds TSDoc
adonesky1 Nov 12, 2024
f7444b2
Update packages/multichain/src/index.ts
adonesky1 Nov 12, 2024
da672b9
Update packages/multichain/src/caip25Permission.ts
adonesky1 Nov 12, 2024
76a0afd
Update packages/multichain/src/caip25Permission.ts
adonesky1 Nov 12, 2024
d10f7d0
improve caip25permission caveat type validation
adonesky1 Nov 12, 2024
e5096d7
Update packages/multichain/src/caip25Permission.ts
adonesky1 Nov 12, 2024
e39e025
Merge branch 'main' into caip-multichain
adonesky1 Nov 12, 2024
f93eb36
update lock file
adonesky1 Nov 12, 2024
5b08f70
fix constraints
adonesky1 Nov 12, 2024
6557b46
update lockfile again
adonesky1 Nov 12, 2024
161dad9
fix tests
adonesky1 Nov 13, 2024
7b3e149
add tests for caip25permission caveat type validation
adonesky1 Nov 13, 2024
a532409
fix Hex type casting
adonesky1 Nov 13, 2024
6c38448
remove redundant addition of wallet:eip155 optional scope
adonesky1 Nov 13, 2024
bce9360
added to setEthAccounts TSDoc to explain why we inject a wallet:eip15…
adonesky1 Nov 13, 2024
f905350
add type/const docs
adonesky1 Nov 13, 2024
d0865d4
lint
adonesky1 Nov 13, 2024
30e6842
Merge branch 'main' into caip-multichain
adonesky1 Nov 13, 2024
555383c
Update packages/multichain/src/index.ts
adonesky1 Nov 13, 2024
bc21a36
update snapshot
adonesky1 Nov 13, 2024
fa20bc0
Merge branch 'main' into caip-multichain
adonesky1 Nov 13, 2024
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
28 changes: 17 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ This repository contains the following packages [^fn1]:
- [`@metamask/keyring-controller`](packages/keyring-controller)
- [`@metamask/logging-controller`](packages/logging-controller)
- [`@metamask/message-manager`](packages/message-manager)
- [`@metamask/multichain`](packages/multichain)
- [`@metamask/name-controller`](packages/name-controller)
- [`@metamask/network-controller`](packages/network-controller)
- [`@metamask/notification-controller`](packages/notification-controller)
Expand Down Expand Up @@ -71,6 +72,7 @@ linkStyle default opacity:0.5
keyring_controller(["@metamask/keyring-controller"]);
logging_controller(["@metamask/logging-controller"]);
message_manager(["@metamask/message-manager"]);
multichain(["@metamask/multichain"]);
name_controller(["@metamask/name-controller"]);
network_controller(["@metamask/network-controller"]);
notification_controller(["@metamask/notification-controller"]);
Expand All @@ -93,14 +95,15 @@ linkStyle default opacity:0.5
address_book_controller --> controller_utils;
announcement_controller --> base_controller;
approval_controller --> base_controller;
assets_controllers --> accounts_controller;
assets_controllers --> approval_controller;
assets_controllers --> base_controller;
assets_controllers --> controller_utils;
assets_controllers --> polling_controller;
assets_controllers --> accounts_controller;
assets_controllers --> approval_controller;
assets_controllers --> keyring_controller;
assets_controllers --> network_controller;
assets_controllers --> polling_controller;
assets_controllers --> preferences_controller;
base_controller --> json_rpc_engine;
chain_controller --> base_controller;
composable_controller --> base_controller;
composable_controller --> json_rpc_engine;
Expand All @@ -110,8 +113,8 @@ linkStyle default opacity:0.5
eth_json_rpc_provider --> json_rpc_engine;
gas_fee_controller --> base_controller;
gas_fee_controller --> controller_utils;
gas_fee_controller --> network_controller;
gas_fee_controller --> polling_controller;
gas_fee_controller --> network_controller;
json_rpc_middleware_stream --> json_rpc_engine;
keyring_controller --> base_controller;
keyring_controller --> message_manager;
Expand Down Expand Up @@ -145,6 +148,9 @@ linkStyle default opacity:0.5
preferences_controller --> controller_utils;
preferences_controller --> keyring_controller;
profile_sync_controller --> base_controller;
profile_sync_controller --> keyring_controller;
profile_sync_controller --> accounts_controller;
profile_sync_controller --> network_controller;
queued_request_controller --> base_controller;
queued_request_controller --> controller_utils;
queued_request_controller --> json_rpc_engine;
Expand All @@ -155,26 +161,26 @@ linkStyle default opacity:0.5
selected_network_controller --> json_rpc_engine;
selected_network_controller --> network_controller;
selected_network_controller --> permission_controller;
signature_controller --> approval_controller;
signature_controller --> base_controller;
signature_controller --> controller_utils;
signature_controller --> message_manager;
signature_controller --> approval_controller;
signature_controller --> keyring_controller;
signature_controller --> logging_controller;
signature_controller --> message_manager;
transaction_controller --> accounts_controller;
transaction_controller --> approval_controller;
transaction_controller --> base_controller;
transaction_controller --> controller_utils;
transaction_controller --> accounts_controller;
transaction_controller --> approval_controller;
transaction_controller --> eth_json_rpc_provider;
transaction_controller --> gas_fee_controller;
transaction_controller --> network_controller;
transaction_controller --> eth_json_rpc_provider;
user_operation_controller --> approval_controller;
user_operation_controller --> base_controller;
user_operation_controller --> controller_utils;
user_operation_controller --> polling_controller;
user_operation_controller --> approval_controller;
user_operation_controller --> gas_fee_controller;
user_operation_controller --> keyring_controller;
user_operation_controller --> network_controller;
user_operation_controller --> polling_controller;
user_operation_controller --> transaction_controller;
```

Expand Down
26 changes: 5 additions & 21 deletions packages/assets-controllers/src/TokenDetectionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import type {
ControllerStateChangeEvent,
} from '@metamask/base-controller';
import contractMap from '@metamask/contract-metadata';
import { ChainId, safelyExecute } from '@metamask/controller-utils';
import {
ChainId,
safelyExecute,
isEqualCaseInsensitive,
} from '@metamask/controller-utils';
import type {
KeyringControllerGetStateAction,
KeyringControllerLockEvent,
Expand Down Expand Up @@ -44,26 +48,6 @@ import type {

const DEFAULT_INTERVAL = 180000;

/**
* Compare 2 given strings and return boolean
* eg: "foo" and "FOO" => true
* eg: "foo" and "bar" => false
* eg: "foo" and 123 => false
*
* @param value1 - first string to compare
* @param value2 - first string to compare
* @returns true if 2 strings are identical when they are lowercase
*/
export function isEqualCaseInsensitive(
value1: string,
value2: string,
): boolean {
if (typeof value1 !== 'string' || typeof value2 !== 'string') {
return false;
}
return value1.toLowerCase() === value2.toLowerCase();
}

type LegacyToken = {
name: string;
logo: `${string}.svg`;
Expand Down
1 change: 1 addition & 0 deletions packages/controller-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export {
toChecksumHexAddress,
toHex,
weiHexToGweiDec,
isEqualCaseInsensitive,
} from './util';
export * from './types';
export * from './siwe';
26 changes: 26 additions & 0 deletions packages/controller-utils/src/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,3 +611,29 @@ describe('util', () => {
});
});
});

describe('isEqualCaseInsensitive', () => {
it('returns false for non-string values', () => {
// @ts-expect-error Invalid type for testing purposes
expect(util.isEqualCaseInsensitive(null, 'test')).toBe(false);
// @ts-expect-error Invalid type for testing purposes
expect(util.isEqualCaseInsensitive('test', null)).toBe(false);
// @ts-expect-error Invalid type for testing purposes
expect(util.isEqualCaseInsensitive(5, 'test')).toBe(false);
// @ts-expect-error Invalid type for testing purposes
expect(util.isEqualCaseInsensitive('test', 5)).toBe(false);
});

it('returns false for strings that are not equal', () => {
expect(util.isEqualCaseInsensitive('test', 'test1')).toBe(false);
expect(util.isEqualCaseInsensitive('test1', 'test')).toBe(false);
});

it('returns true for strings that are equal', () => {
expect(util.isEqualCaseInsensitive('test', 'TEST')).toBe(true);
expect(util.isEqualCaseInsensitive('test', 'test')).toBe(true);
expect(util.isEqualCaseInsensitive('TEST', 'TEST')).toBe(true);
expect(util.isEqualCaseInsensitive('test', 'Test')).toBe(true);
expect(util.isEqualCaseInsensitive('Test', 'test')).toBe(true);
});
});
17 changes: 17 additions & 0 deletions packages/controller-utils/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -619,3 +619,20 @@ function logOrRethrowError(error: unknown, codesToCatch: number[] = []) {
throw error;
}
}

/**
* Checks if two strings are equal, ignoring case.
*
* @param value1 - The first string to compare.
* @param value2 - The second string to compare.
* @returns `true` if the strings are equal, ignoring case; otherwise, `false`.
*/
export function isEqualCaseInsensitive(
value1: string,
value2: string,
): boolean {
if (typeof value1 !== 'string' || typeof value2 !== 'string') {
return false;
}
return value1.toLowerCase() === value2.toLowerCase();
}
10 changes: 10 additions & 0 deletions packages/multichain/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# 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/
20 changes: 20 additions & 0 deletions packages/multichain/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
MIT License

Copyright (c) 2024 MetaMask

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
15 changes: 15 additions & 0 deletions packages/multichain/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# `@metamask/multichain`

Provides types, helpers, adapters, and wrappers for facilitating CAIP Multichain sessions

## Installation

`yarn add @metamask/multichain`

or

`npm install @metamask/multichain`

## 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/multichain/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: 82.38,
jiexi marked this conversation as resolved.
Show resolved Hide resolved
functions: 87.37,
lines: 86.65,
statements: 87.09,
},
},
});
85 changes: 85 additions & 0 deletions packages/multichain/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"name": "@metamask/multichain",
"version": "0.0.0",
"description": "Provides types, helpers, adapters, and wrappers for facilitating CAIP Multichain sessions",
"keywords": [
"MetaMask",
"Ethereum"
],
"homepage": "https://github.com/MetaMask/core/tree/main/packages/multichain#readme",
"bugs": {
"url": "https://github.com/MetaMask/core/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/MetaMask/core.git"
},
"license": "MIT",
"sideEffects": false,
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
},
"./package.json": "./package.json"
},
"main": "./dist/index.cjs",
"types": "./dist/index.d.cts",
"files": [
"dist/"
],
"scripts": {
"build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
"build:docs": "typedoc",
"changelog:update": "../../scripts/update-changelog.sh @metamask/multichain",
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/multichain",
"publish:preview": "yarn npm publish --tag preview",
"since-latest-release": "../../scripts/since-latest-release.sh",
"test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
"test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
"test:verbose": "NODE_OPTIONS=--experimental-vm-modules jest --verbose",
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
},
"dependencies": {
"@metamask/api-specs": "^0.10.12",
"@metamask/controller-utils": "^11.3.0",
"@metamask/eth-json-rpc-filters": "^7.0.0",
"@metamask/rpc-errors": "^6.3.1",
"@metamask/safe-event-emitter": "^3.0.0",
"@metamask/utils": "^9.1.0",
"@open-rpc/schema-utils-js": "^2.0.5",
"jsonschema": "^1.2.4",
"lodash": "^4.17.21"
},
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
"@metamask/json-rpc-engine": "^9.0.3",
"@metamask/network-controller": "^21.0.1",
"@metamask/permission-controller": "^11.0.2",
"@open-rpc/meta-schema": "^1.14.6",
"@types/jest": "^27.4.1",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
"ts-jest": "^27.1.4",
"typedoc": "^0.24.8",
"typedoc-plugin-missing-exports": "^2.0.0",
"typescript": "~5.2.2"
},
"peerDependencies": {
"@metamask/network-controller": "^21.0.0",
"@metamask/permission-controller": "^11.0.0"
},
"engines": {
"node": "^18.18 || >=20"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
}
}
Loading
Loading