@metamask-previews/multichain-network-controller 0.12.0-preview-f059664 → 1.0.0-preview-8ccfcb37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,12 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.0.0]
11
+
10
12
  ### Added
11
13
 
12
14
  - Add two new controller state metadata properties: `includeInStateLogs` and `usedInUi` ([#6525](https://github.com/MetaMask/core/pull/6525))
15
+ - Add Solana Devnet support to multichain network controller ([#6670](https://github.com/MetaMask/core/pull/6670))
13
16
 
14
17
  ### Changed
15
18
 
19
+ - Bump package version to v1.0 to mark stabilization ([#6676](https://github.com/MetaMask/core/pull/6676))
16
20
  - Bump `@metamask/controller-utils` from `^11.12.0` to `^11.14.0` ([#6620](https://github.com/MetaMask/core/pull/6620), [#6629](https://github.com/MetaMask/core/pull/6629))
17
21
  - Bump `@metamask/base-controller` from `^8.1.0` to `^8.4.0` ([#6355](https://github.com/MetaMask/core/pull/6355), [#6465](https://github.com/MetaMask/core/pull/6465), [#6632](https://github.com/MetaMask/core/pull/6632))
18
22
  - Bump `@metamask/keyring-api` from `^20.1.0` to `^21.0.0` ([#6560](https://github.com/MetaMask/core/pull/6560))
@@ -158,7 +162,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
158
162
  - Handle both EVM and non-EVM network and account switching for the associated network.
159
163
  - Act as a proxy for the `NetworkController` (for EVM network changes).
160
164
 
161
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/multichain-network-controller@0.12.0...HEAD
165
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/multichain-network-controller@1.0.0...HEAD
166
+ [1.0.0]: https://github.com/MetaMask/core/compare/@metamask/multichain-network-controller@0.12.0...@metamask/multichain-network-controller@1.0.0
162
167
  [0.12.0]: https://github.com/MetaMask/core/compare/@metamask/multichain-network-controller@0.11.1...@metamask/multichain-network-controller@0.12.0
163
168
  [0.11.1]: https://github.com/MetaMask/core/compare/@metamask/multichain-network-controller@0.11.0...@metamask/multichain-network-controller@0.11.1
164
169
  [0.11.0]: https://github.com/MetaMask/core/compare/@metamask/multichain-network-controller@0.10.0...@metamask/multichain-network-controller@0.11.0
@@ -29,6 +29,7 @@ exports.MULTICHAIN_ALLOWED_ACTIVE_NETWORK_SCOPES = [
29
29
  String(keyring_api_1.BtcScope.Signet),
30
30
  String(keyring_api_1.BtcScope.Regtest),
31
31
  String(keyring_api_1.SolScope.Mainnet),
32
+ String(keyring_api_1.SolScope.Devnet),
32
33
  String(keyring_api_1.EthScope.Mainnet),
33
34
  String(keyring_api_1.EthScope.Testnet),
34
35
  String(keyring_api_1.EthScope.Eoa),
@@ -1 +1 @@
1
- {"version":3,"file":"accounts-api.cjs","sourceRoot":"","sources":["../../src/api/accounts-api.ts"],"names":[],"mappings":";;;AAAA,uDAA+E;AAE/E,uDAAkE;AAClE,2CAA0E;AAQ7D,QAAA,4BAA4B,GAAG,IAAA,oBAAM,EAAC;IACjD,cAAc,EAAE,IAAA,mBAAK,EAAC,2BAAmB,CAAC;CAC3C,CAAC,CAAC;AAiBH;;GAEG;AACU,QAAA,4BAA4B,GACvC,qCAAqC,CAAC;AAExC;;GAEG;AACU,QAAA,iCAAiC,GAAG,0BAA0B,CAAC;AAE5E;;GAEG;AACU,QAAA,6BAA6B,GACxC,wCAAwC,CAAC;AAE3C;;GAEG;AACU,QAAA,wCAAwC,GAAG;IACtD,MAAM,CAAC,sBAAQ,CAAC,OAAO,CAAC;IACxB,MAAM,CAAC,sBAAQ,CAAC,OAAO,CAAC;IACxB,MAAM,CAAC,sBAAQ,CAAC,QAAQ,CAAC;IACzB,MAAM,CAAC,sBAAQ,CAAC,MAAM,CAAC;IACvB,MAAM,CAAC,sBAAQ,CAAC,OAAO,CAAC;IACxB,MAAM,CAAC,sBAAQ,CAAC,OAAO,C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;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,UAA2B;IAChE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,oCAA4B,oBAAoB,CAAC,CAAC;IACzE,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5D,OAAO,GAAG,CAAC;AACb,CAAC;AAJD,wDAIC","sourcesContent":["import { BtcScope, SolScope, EthScope, TrxScope } from '@metamask/keyring-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport { type Infer, array, object } from '@metamask/superstruct';\nimport { CaipAccountIdStruct, parseCaipAccountId } from '@metamask/utils';\nimport type {\n CaipAccountAddress,\n CaipAccountId,\n CaipNamespace,\n CaipReference,\n} from '@metamask/utils';\n\nexport const ActiveNetworksResponseStruct = object({\n activeNetworks: array(CaipAccountIdStruct),\n});\n\nexport type ActiveNetworksResponse = Infer<typeof ActiveNetworksResponseStruct>;\n\n/**\n * The active networks for the currently selected account.\n */\nexport type ActiveNetworksByAddress = Record<\n CaipAccountAddress,\n {\n // CAIP-2 namespace of the network.\n namespace: CaipNamespace;\n // Active chain IDs (CAIP-2 references) on that network (primarily used for EVM networks).\n activeChains: CaipReference[];\n }\n>;\n\n/**\n * The domain for multichain accounts API.\n */\nexport const MULTICHAIN_ACCOUNTS_BASE_URL =\n 'https://accounts.api.cx.metamask.io';\n\n/**\n * The client header for the multichain accounts API.\n */\nexport const MULTICHAIN_ACCOUNTS_CLIENT_HEADER = 'x-metamask-clientproduct';\n\n/**\n * The client ID for the multichain accounts API.\n */\nexport const MULTICHAIN_ACCOUNTS_CLIENT_ID =\n 'metamask-multichain-network-controller';\n\n/**\n * The allowed active network scopes for the multichain network controller.\n */\nexport const MULTICHAIN_ALLOWED_ACTIVE_NETWORK_SCOPES = [\n String(BtcScope.Mainnet),\n String(BtcScope.Testnet),\n String(BtcScope.Testnet4),\n String(BtcScope.Signet),\n String(BtcScope.Regtest),\n String(SolScope.Mainnet),\n String(EthScope.Mainnet),\n String(EthScope.Testnet),\n String(EthScope.Eoa),\n String(TrxScope.Mainnet),\n String(TrxScope.Nile),\n String(TrxScope.Shasta),\n];\n\n/**\n * Converts an internal account to an array of CAIP-10 account IDs.\n *\n * @param account - The internal account to convert\n * @returns The CAIP-10 account IDs\n */\nexport function toAllowedCaipAccountIds(\n account: InternalAccount,\n): CaipAccountId[] {\n const formattedAccounts: CaipAccountId[] = [];\n for (const scope of account.scopes) {\n if (MULTICHAIN_ALLOWED_ACTIVE_NETWORK_SCOPES.includes(scope)) {\n formattedAccounts.push(`${scope}:${account.address}`);\n }\n }\n\n return formattedAccounts;\n}\n\n/**\n * Formats the API response into our state structure.\n * Example input: [\"eip155:1:0x123...\", \"eip155:137:0x123...\", \"solana:1:0xabc...\"]\n *\n * @param response - The raw API response\n * @returns Formatted networks by address\n */\nexport function toActiveNetworksByAddress(\n response: ActiveNetworksResponse,\n): ActiveNetworksByAddress {\n const networksByAddress: ActiveNetworksByAddress = {};\n\n response.activeNetworks.forEach((network) => {\n const {\n address,\n chain: { namespace, reference },\n } = parseCaipAccountId(network);\n\n if (!networksByAddress[address]) {\n networksByAddress[address] = {\n namespace,\n activeChains: [],\n };\n }\n networksByAddress[address].activeChains.push(reference);\n });\n\n return networksByAddress;\n}\n\n/**\n * Constructs the URL for the active networks API endpoint.\n *\n * @param accountIds - Array of account IDs\n * @returns URL object for the API endpoint\n */\nexport function buildActiveNetworksUrl(accountIds: CaipAccountId[]): URL {\n const url = new URL(`${MULTICHAIN_ACCOUNTS_BASE_URL}/v2/activeNetworks`);\n url.searchParams.append('accountIds', accountIds.join(','));\n return url;\n}\n"]}
1
+ {"version":3,"file":"accounts-api.cjs","sourceRoot":"","sources":["../../src/api/accounts-api.ts"],"names":[],"mappings":";;;AAAA,uDAA+E;AAE/E,uDAAkE;AAClE,2CAA0E;AAQ7D,QAAA,4BAA4B,GAAG,IAAA,oBAAM,EAAC;IACjD,c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SAAgB,yBAAyB,CACvC,QAAgC;IAEhC,MAAM,iBAAiB,GAA4B,EAAE,CAAC;IAEtD,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC1C,MAAM,EACJ,OAAO,EACP,KAAK,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,GAChC,GAAG,IAAA,0BAAkB,EAAC,OAAO,CAAC,CAAC;QAEhC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAAE;YAC/B,iBAAiB,CAAC,OAAO,CAAC,GAAG;gBAC3B,SAAS;gBACT,YAAY,EAAE,EAAE;aACjB,CAAC;SACH;QACD,iBAAiB,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AArBD,8DAqBC;AAED;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,UAA2B;IAChE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,oCAA4B,oBAAoB,CAAC,CAAC;IACzE,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5D,OAAO,GAAG,CAAC;AACb,CAAC;AAJD,wDAIC","sourcesContent":["import { BtcScope, SolScope, EthScope, TrxScope } from '@metamask/keyring-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport { type Infer, array, object } from '@metamask/superstruct';\nimport { CaipAccountIdStruct, parseCaipAccountId } from '@metamask/utils';\nimport type {\n CaipAccountAddress,\n CaipAccountId,\n CaipNamespace,\n CaipReference,\n} from '@metamask/utils';\n\nexport const ActiveNetworksResponseStruct = object({\n activeNetworks: array(CaipAccountIdStruct),\n});\n\nexport type ActiveNetworksResponse = Infer<typeof ActiveNetworksResponseStruct>;\n\n/**\n * The active networks for the currently selected account.\n */\nexport type ActiveNetworksByAddress = Record<\n CaipAccountAddress,\n {\n // CAIP-2 namespace of the network.\n namespace: CaipNamespace;\n // Active chain IDs (CAIP-2 references) on that network (primarily used for EVM networks).\n activeChains: CaipReference[];\n }\n>;\n\n/**\n * The domain for multichain accounts API.\n */\nexport const MULTICHAIN_ACCOUNTS_BASE_URL =\n 'https://accounts.api.cx.metamask.io';\n\n/**\n * The client header for the multichain accounts API.\n */\nexport const MULTICHAIN_ACCOUNTS_CLIENT_HEADER = 'x-metamask-clientproduct';\n\n/**\n * The client ID for the multichain accounts API.\n */\nexport const MULTICHAIN_ACCOUNTS_CLIENT_ID =\n 'metamask-multichain-network-controller';\n\n/**\n * The allowed active network scopes for the multichain network controller.\n */\nexport const MULTICHAIN_ALLOWED_ACTIVE_NETWORK_SCOPES = [\n String(BtcScope.Mainnet),\n String(BtcScope.Testnet),\n String(BtcScope.Testnet4),\n String(BtcScope.Signet),\n String(BtcScope.Regtest),\n String(SolScope.Mainnet),\n String(SolScope.Devnet),\n String(EthScope.Mainnet),\n String(EthScope.Testnet),\n String(EthScope.Eoa),\n String(TrxScope.Mainnet),\n String(TrxScope.Nile),\n String(TrxScope.Shasta),\n];\n\n/**\n * Converts an internal account to an array of CAIP-10 account IDs.\n *\n * @param account - The internal account to convert\n * @returns The CAIP-10 account IDs\n */\nexport function toAllowedCaipAccountIds(\n account: InternalAccount,\n): CaipAccountId[] {\n const formattedAccounts: CaipAccountId[] = [];\n for (const scope of account.scopes) {\n if (MULTICHAIN_ALLOWED_ACTIVE_NETWORK_SCOPES.includes(scope)) {\n formattedAccounts.push(`${scope}:${account.address}`);\n }\n }\n\n return formattedAccounts;\n}\n\n/**\n * Formats the API response into our state structure.\n * Example input: [\"eip155:1:0x123...\", \"eip155:137:0x123...\", \"solana:1:0xabc...\"]\n *\n * @param response - The raw API response\n * @returns Formatted networks by address\n */\nexport function toActiveNetworksByAddress(\n response: ActiveNetworksResponse,\n): ActiveNetworksByAddress {\n const networksByAddress: ActiveNetworksByAddress = {};\n\n response.activeNetworks.forEach((network) => {\n const {\n address,\n chain: { namespace, reference },\n } = parseCaipAccountId(network);\n\n if (!networksByAddress[address]) {\n networksByAddress[address] = {\n namespace,\n activeChains: [],\n };\n }\n networksByAddress[address].activeChains.push(reference);\n });\n\n return networksByAddress;\n}\n\n/**\n * Constructs the URL for the active networks API endpoint.\n *\n * @param accountIds - Array of account IDs\n * @returns URL object for the API endpoint\n */\nexport function buildActiveNetworksUrl(accountIds: CaipAccountId[]): URL {\n const url = new URL(`${MULTICHAIN_ACCOUNTS_BASE_URL}/v2/activeNetworks`);\n url.searchParams.append('accountIds', accountIds.join(','));\n return url;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"accounts-api.d.cts","sourceRoot":"","sources":["../../src/api/accounts-api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,EAAE,KAAK,KAAK,EAAiB,8BAA8B;AAElE,OAAO,KAAK,EACV,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,aAAa,EACd,wBAAwB;AAEzB,eAAO,MAAM,4BAA4B;;;;EAEvC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAEhF;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAC1C,kBAAkB,EAClB;IAEE,SAAS,EAAE,aAAa,CAAC;IAEzB,YAAY,EAAE,aAAa,EAAE,CAAC;CAC/B,CACF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4BAA4B,wCACF,CAAC;AAExC;;GAEG;AACH,eAAO,MAAM,iCAAiC,6BAA6B,CAAC;AAE5E;;GAEG;AACH,eAAO,MAAM,6BAA6B,2CACA,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,wCAAwC,UAapD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,eAAe,GACvB,aAAa,EAAE,CASjB;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,sBAAsB,GAC/B,uBAAuB,CAmBzB;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,aAAa,EAAE,GAAG,GAAG,CAIvE"}
1
+ {"version":3,"file":"accounts-api.d.cts","sourceRoot":"","sources":["../../src/api/accounts-api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,EAAE,KAAK,KAAK,EAAiB,8BAA8B;AAElE,OAAO,KAAK,EACV,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,aAAa,EACd,wBAAwB;AAEzB,eAAO,MAAM,4BAA4B;;;;EAEvC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAEhF;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAC1C,kBAAkB,EAClB;IAEE,SAAS,EAAE,aAAa,CAAC;IAEzB,YAAY,EAAE,aAAa,EAAE,CAAC;CAC/B,CACF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4BAA4B,wCACF,CAAC;AAExC;;GAEG;AACH,eAAO,MAAM,iCAAiC,6BAA6B,CAAC;AAE5E;;GAEG;AACH,eAAO,MAAM,6BAA6B,2CACA,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,wCAAwC,UAcpD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,eAAe,GACvB,aAAa,EAAE,CASjB;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,sBAAsB,GAC/B,uBAAuB,CAmBzB;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,aAAa,EAAE,GAAG,GAAG,CAIvE"}
@@ -1 +1 @@
1
- {"version":3,"file":"accounts-api.d.mts","sourceRoot":"","sources":["../../src/api/accounts-api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,EAAE,KAAK,KAAK,EAAiB,8BAA8B;AAElE,OAAO,KAAK,EACV,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,aAAa,EACd,wBAAwB;AAEzB,eAAO,MAAM,4BAA4B;;;;EAEvC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAEhF;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAC1C,kBAAkB,EAClB;IAEE,SAAS,EAAE,aAAa,CAAC;IAEzB,YAAY,EAAE,aAAa,EAAE,CAAC;CAC/B,CACF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4BAA4B,wCACF,CAAC;AAExC;;GAEG;AACH,eAAO,MAAM,iCAAiC,6BAA6B,CAAC;AAE5E;;GAEG;AACH,eAAO,MAAM,6BAA6B,2CACA,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,wCAAwC,UAapD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,eAAe,GACvB,aAAa,EAAE,CASjB;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,sBAAsB,GAC/B,uBAAuB,CAmBzB;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,aAAa,EAAE,GAAG,GAAG,CAIvE"}
1
+ {"version":3,"file":"accounts-api.d.mts","sourceRoot":"","sources":["../../src/api/accounts-api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,EAAE,KAAK,KAAK,EAAiB,8BAA8B;AAElE,OAAO,KAAK,EACV,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,aAAa,EACd,wBAAwB;AAEzB,eAAO,MAAM,4BAA4B;;;;EAEvC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAEhF;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAC1C,kBAAkB,EAClB;IAEE,SAAS,EAAE,aAAa,CAAC;IAEzB,YAAY,EAAE,aAAa,EAAE,CAAC;CAC/B,CACF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4BAA4B,wCACF,CAAC;AAExC;;GAEG;AACH,eAAO,MAAM,iCAAiC,6BAA6B,CAAC;AAE5E;;GAEG;AACH,eAAO,MAAM,6BAA6B,2CACA,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,wCAAwC,UAcpD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,eAAe,GACvB,aAAa,EAAE,CASjB;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,sBAAsB,GAC/B,uBAAuB,CAmBzB;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,aAAa,EAAE,GAAG,GAAG,CAIvE"}
@@ -26,6 +26,7 @@ export const MULTICHAIN_ALLOWED_ACTIVE_NETWORK_SCOPES = [
26
26
  String(BtcScope.Signet),
27
27
  String(BtcScope.Regtest),
28
28
  String(SolScope.Mainnet),
29
+ String(SolScope.Devnet),
29
30
  String(EthScope.Mainnet),
30
31
  String(EthScope.Testnet),
31
32
  String(EthScope.Eoa),
@@ -1 +1 @@
1
- {"version":3,"file":"accounts-api.mjs","sourceRoot":"","sources":["../../src/api/accounts-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,8BAA8B;AAE/E,OAAO,EAAc,KAAK,EAAE,MAAM,EAAE,8BAA8B;AAClE,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,wBAAwB;AAQ1E,MAAM,CAAC,M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;GAMG;AACH,MAAM,UAAU,yBAAyB,CACvC,QAAgC;IAEhC,MAAM,iBAAiB,GAA4B,EAAE,CAAC;IAEtD,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC1C,MAAM,EACJ,OAAO,EACP,KAAK,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,GAChC,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAEhC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAAE;YAC/B,iBAAiB,CAAC,OAAO,CAAC,GAAG;gBAC3B,SAAS;gBACT,YAAY,EAAE,EAAE;aACjB,CAAC;SACH;QACD,iBAAiB,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,UAA2B;IAChE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,4BAA4B,oBAAoB,CAAC,CAAC;IACzE,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5D,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { BtcScope, SolScope, EthScope, TrxScope } from '@metamask/keyring-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport { type Infer, array, object } from '@metamask/superstruct';\nimport { CaipAccountIdStruct, parseCaipAccountId } from '@metamask/utils';\nimport type {\n CaipAccountAddress,\n CaipAccountId,\n CaipNamespace,\n CaipReference,\n} from '@metamask/utils';\n\nexport const ActiveNetworksResponseStruct = object({\n activeNetworks: array(CaipAccountIdStruct),\n});\n\nexport type ActiveNetworksResponse = Infer<typeof ActiveNetworksResponseStruct>;\n\n/**\n * The active networks for the currently selected account.\n */\nexport type ActiveNetworksByAddress = Record<\n CaipAccountAddress,\n {\n // CAIP-2 namespace of the network.\n namespace: CaipNamespace;\n // Active chain IDs (CAIP-2 references) on that network (primarily used for EVM networks).\n activeChains: CaipReference[];\n }\n>;\n\n/**\n * The domain for multichain accounts API.\n */\nexport const MULTICHAIN_ACCOUNTS_BASE_URL =\n 'https://accounts.api.cx.metamask.io';\n\n/**\n * The client header for the multichain accounts API.\n */\nexport const MULTICHAIN_ACCOUNTS_CLIENT_HEADER = 'x-metamask-clientproduct';\n\n/**\n * The client ID for the multichain accounts API.\n */\nexport const MULTICHAIN_ACCOUNTS_CLIENT_ID =\n 'metamask-multichain-network-controller';\n\n/**\n * The allowed active network scopes for the multichain network controller.\n */\nexport const MULTICHAIN_ALLOWED_ACTIVE_NETWORK_SCOPES = [\n String(BtcScope.Mainnet),\n String(BtcScope.Testnet),\n String(BtcScope.Testnet4),\n String(BtcScope.Signet),\n String(BtcScope.Regtest),\n String(SolScope.Mainnet),\n String(EthScope.Mainnet),\n String(EthScope.Testnet),\n String(EthScope.Eoa),\n String(TrxScope.Mainnet),\n String(TrxScope.Nile),\n String(TrxScope.Shasta),\n];\n\n/**\n * Converts an internal account to an array of CAIP-10 account IDs.\n *\n * @param account - The internal account to convert\n * @returns The CAIP-10 account IDs\n */\nexport function toAllowedCaipAccountIds(\n account: InternalAccount,\n): CaipAccountId[] {\n const formattedAccounts: CaipAccountId[] = [];\n for (const scope of account.scopes) {\n if (MULTICHAIN_ALLOWED_ACTIVE_NETWORK_SCOPES.includes(scope)) {\n formattedAccounts.push(`${scope}:${account.address}`);\n }\n }\n\n return formattedAccounts;\n}\n\n/**\n * Formats the API response into our state structure.\n * Example input: [\"eip155:1:0x123...\", \"eip155:137:0x123...\", \"solana:1:0xabc...\"]\n *\n * @param response - The raw API response\n * @returns Formatted networks by address\n */\nexport function toActiveNetworksByAddress(\n response: ActiveNetworksResponse,\n): ActiveNetworksByAddress {\n const networksByAddress: ActiveNetworksByAddress = {};\n\n response.activeNetworks.forEach((network) => {\n const {\n address,\n chain: { namespace, reference },\n } = parseCaipAccountId(network);\n\n if (!networksByAddress[address]) {\n networksByAddress[address] = {\n namespace,\n activeChains: [],\n };\n }\n networksByAddress[address].activeChains.push(reference);\n });\n\n return networksByAddress;\n}\n\n/**\n * Constructs the URL for the active networks API endpoint.\n *\n * @param accountIds - Array of account IDs\n * @returns URL object for the API endpoint\n */\nexport function buildActiveNetworksUrl(accountIds: CaipAccountId[]): URL {\n const url = new URL(`${MULTICHAIN_ACCOUNTS_BASE_URL}/v2/activeNetworks`);\n url.searchParams.append('accountIds', accountIds.join(','));\n return url;\n}\n"]}
1
+ {"version":3,"file":"accounts-api.mjs","sourceRoot":"","sources":["../../src/api/accounts-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,8BAA8B;AAE/E,OAAO,EAAc,KAAK,EAAE,MAAM,EAAE,8BAA8B;AAClE,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,wBAAwB;AAQ1E,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAC;IACjD,cAAc,EAAE,KAAK,CAAC,mBAAmB,CAAC;CAC3C,CAAC,CAAC;AAiBH;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GACvC,qCAAqC,CAAC;AAExC;;GAEG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,0BAA0B,CAAC;AAE5E;;GAEG;AACH,MAAM,CAAC,MAAM,6BAA6B,GACxC,wCAAwC,CAAC;AAE3C;;GAEG;AACH,MAAM,CAAC,MAAM,wCAAwC,GAAG;IACtD,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC;IACxB,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC;IACxB,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;IACzB,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;IACvB,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC;IACx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;IAEH,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,UAA2B;IAChE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,4BAA4B,oBAAoB,CAAC,CAAC;IACzE,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5D,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { BtcScope, SolScope, EthScope, TrxScope } from '@metamask/keyring-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport { type Infer, array, object } from '@metamask/superstruct';\nimport { CaipAccountIdStruct, parseCaipAccountId } from '@metamask/utils';\nimport type {\n CaipAccountAddress,\n CaipAccountId,\n CaipNamespace,\n CaipReference,\n} from '@metamask/utils';\n\nexport const ActiveNetworksResponseStruct = object({\n activeNetworks: array(CaipAccountIdStruct),\n});\n\nexport type ActiveNetworksResponse = Infer<typeof ActiveNetworksResponseStruct>;\n\n/**\n * The active networks for the currently selected account.\n */\nexport type ActiveNetworksByAddress = Record<\n CaipAccountAddress,\n {\n // CAIP-2 namespace of the network.\n namespace: CaipNamespace;\n // Active chain IDs (CAIP-2 references) on that network (primarily used for EVM networks).\n activeChains: CaipReference[];\n }\n>;\n\n/**\n * The domain for multichain accounts API.\n */\nexport const MULTICHAIN_ACCOUNTS_BASE_URL =\n 'https://accounts.api.cx.metamask.io';\n\n/**\n * The client header for the multichain accounts API.\n */\nexport const MULTICHAIN_ACCOUNTS_CLIENT_HEADER = 'x-metamask-clientproduct';\n\n/**\n * The client ID for the multichain accounts API.\n */\nexport const MULTICHAIN_ACCOUNTS_CLIENT_ID =\n 'metamask-multichain-network-controller';\n\n/**\n * The allowed active network scopes for the multichain network controller.\n */\nexport const MULTICHAIN_ALLOWED_ACTIVE_NETWORK_SCOPES = [\n String(BtcScope.Mainnet),\n String(BtcScope.Testnet),\n String(BtcScope.Testnet4),\n String(BtcScope.Signet),\n String(BtcScope.Regtest),\n String(SolScope.Mainnet),\n String(SolScope.Devnet),\n String(EthScope.Mainnet),\n String(EthScope.Testnet),\n String(EthScope.Eoa),\n String(TrxScope.Mainnet),\n String(TrxScope.Nile),\n String(TrxScope.Shasta),\n];\n\n/**\n * Converts an internal account to an array of CAIP-10 account IDs.\n *\n * @param account - The internal account to convert\n * @returns The CAIP-10 account IDs\n */\nexport function toAllowedCaipAccountIds(\n account: InternalAccount,\n): CaipAccountId[] {\n const formattedAccounts: CaipAccountId[] = [];\n for (const scope of account.scopes) {\n if (MULTICHAIN_ALLOWED_ACTIVE_NETWORK_SCOPES.includes(scope)) {\n formattedAccounts.push(`${scope}:${account.address}`);\n }\n }\n\n return formattedAccounts;\n}\n\n/**\n * Formats the API response into our state structure.\n * Example input: [\"eip155:1:0x123...\", \"eip155:137:0x123...\", \"solana:1:0xabc...\"]\n *\n * @param response - The raw API response\n * @returns Formatted networks by address\n */\nexport function toActiveNetworksByAddress(\n response: ActiveNetworksResponse,\n): ActiveNetworksByAddress {\n const networksByAddress: ActiveNetworksByAddress = {};\n\n response.activeNetworks.forEach((network) => {\n const {\n address,\n chain: { namespace, reference },\n } = parseCaipAccountId(network);\n\n if (!networksByAddress[address]) {\n networksByAddress[address] = {\n namespace,\n activeChains: [],\n };\n }\n networksByAddress[address].activeChains.push(reference);\n });\n\n return networksByAddress;\n}\n\n/**\n * Constructs the URL for the active networks API endpoint.\n *\n * @param accountIds - Array of account IDs\n * @returns URL object for the API endpoint\n */\nexport function buildActiveNetworksUrl(accountIds: CaipAccountId[]): URL {\n const url = new URL(`${MULTICHAIN_ACCOUNTS_BASE_URL}/v2/activeNetworks`);\n url.searchParams.append('accountIds', accountIds.join(','));\n return url;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/multichain-network-controller",
3
- "version": "0.12.0-preview-f059664",
3
+ "version": "1.0.0-preview-8ccfcb37",
4
4
  "description": "Multichain network controller",
5
5
  "keywords": [
6
6
  "MetaMask",
@@ -60,7 +60,7 @@
60
60
  "@metamask/accounts-controller": "^33.1.0",
61
61
  "@metamask/auto-changelog": "^3.4.4",
62
62
  "@metamask/keyring-controller": "^23.1.0",
63
- "@metamask/network-controller": "^24.1.0",
63
+ "@metamask/network-controller": "^24.2.0",
64
64
  "@types/jest": "^27.4.1",
65
65
  "@types/lodash": "^4.14.191",
66
66
  "@types/uuid": "^8.3.0",