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 11 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
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: 83.05,
functions: 87.37,
lines: 86.73,
statements: 87.17,
},
},
});
Loading
Loading