All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Bump
@metamask/base-controller
from^7.0.0
to^7.1.0
(#5079)
- Remove use of
@metamask/keyring-api
(#4695)@metamask/providers
andwebextension-polyfill
peer dependencies are no longer required.
- Use new
@metamask/keyring-internal-api@^1.0.0
(#4695)- This package has been split out from the Keyring API. Its types are compatible with the
@metamask/keyring-api
package used previously.
- This package has been split out from the Keyring API. Its types are compatible with the
- Bump
@metamask/controller-utils
from^11.3.0
to^11.4.4
(#5012) - Bump
@metamask/polling-controller
from^12.0.1
to^12.0.2
(#5012)
- Make implicit peer dependencies explicit (#4974)
- Add the following packages as peer dependencies of this package to satisfy peer dependency requirements from other dependencies:
@metamask/providers
^18.1.0
(required by@metamask/keyring-api
)webextension-polyfill
^0.10.0 || ^0.11.0 || ^0.12.0
(required by@metamask/providers
)
- These dependencies really should be present in projects that consume this package (e.g. MetaMask clients), and this change ensures that they now are.
- Furthermore, we are assuming that clients already use these dependencies, since otherwise it would be impossible to consume this package in its entirety or even create a working build. Hence, the addition of these peer dependencies is really a formality and should not be breaking.
- Add the following packages as peer dependencies of this package to satisfy peer dependency requirements from other dependencies:
- Fix
TokensController.ignoreTokens
so that if a network is provided,allIgnoredTokens
,allTokens
, andallDetectedTokens
for that network no longer get corrupted with tokens from the globally selected network (#4967) - Correct ESM-compatible build so that imports of the following packages that re-export other modules via
export *
are no longer corrupted: (#5011)@metamask/abi-utils
@metamask/contract-metadata
@metamask/eth-query
@ethereumjs/util
bn.js
cockatiel
lodash
single-call-balance-checker-abi
chainIdToNativeTokenAddress
to record chains with unique (non-zero) addresses (#4952)getNativeTokenAddress()
exported function to return the correct native token address for native assets (#4952)- add support for all added networks when switching account for Token Detection (#4957)
- Update price API calls to use the native token by chain instead of relying on the zero address. (#4952)
- Update
TokenRatesController
market data mapping to usegetNativeTokenAddress
instead of the zero address for native tokens. (#4952)
- BREAKING: Bump
@metamask/keyring-controller
peer dependency from^18.0.0
to^19.0.0
(#4195) - BREAKING: Bump
@metamask/accounts-controller
peer dependency from^19.0.0
to^20.0.0
(#4195) - BREAKING: Bump
@metamask/preferences-controller
peer dependency from^14.0.0
to^15.0.0
(#4195)
- An argument
networkClientId
is added toTokensController.ignoreTokens
, allowing tokens to be ignored on specific chains. (#4949)
-
Fixes an issue where the token detection was unnecessarily falling back to an RPC approach, causing redundant detections. (#4928)
-
Fixes an issue where
TokensController.addTokens
was not respecting the network client id passed to it. (#4940)
-
BREAKING: The
TokenBalancesController
state is now across all chains and accounts under the fieldtokenBalances
, as a mapping from account address -> chain id -> token address -> balance. (#4782) -
BREAKING: The
TokenBalancesController
now extendsStaticIntervalPollingController
, and the new polling APIstartPolling
must be used to initiate polling (startPolling
,stopPollingByPollingToken
). (#4782) -
BREAKING:
TokenBalancesController
now requires subscriptions to thePreferencesController:stateChange
andNetworkController:stateChange
events. And access to theNetworkController:getNetworkClientById
,NetworkController:getState
,TokensController:getState
, andPreferencesController:getState
actions. (#4782) -
BREAKING:
TokensController
requires a subscription to theNetworkController:stateChange
event. It now now removes state for chain IDs when their network is removed. (#4782) -
TokenRatesController
now removes state for chain IDs when their network is removed. (#4782)
- Fix a bug in
TokensController.addTokens
where tokens could be added from the wrong chain. (#4924)
- Add Solana to the polled exchange rates (#4914)
AccountTrackerController
now tracks balances of staked ETH for each account, under the state propertystakedBalance
. (#4879)
- BREAKING: The polling input for
TokenListController
is now{chainId: Hex}
instead of{networkClientId: NetworkClientId}
. (#4878) - BREAKING: The polling input for
TokenDetectionController
is now{ chainIds: Hex[]; address: string; }
instead of{ networkClientId: NetworkClientId; address: string; }
. (#4894) - BREAKING: Bump
@metamask/keyring-controller
peer dependency from^17.0.0
to^18.0.0
(#4195) - BREAKING: Bump
@metamask/preferences-controller
peer dependency from^13.2.0
to^14.0.0
(#4909, #4915) - BREAKING: Bump
@metamask/accounts-controller
peer dependency from^18.0.0
to^19.0.0
(#4915) - Bump
@metamask/controller-utils
from^11.4.2
to^11.4.3
(#4195)
- Add
resetState
method toNftController
,TokensController
,TokenBalancesController
andTokenRatesController
to reset the controller's state back to their default state (#4880)
- BREAKING: A
platform
argument must now be passed to theTokenDetectionController
constructor, indicating whether the platform is extension or mobile. (#4877) - BREAKING: The
TokenRatesController
now accepts{chainId: Hex}
as its polling input tostartPolling()
instead of{networkClientId: NetworkClientId}
(#4887) - When the
TokenRatesController
's subscription toTokensController:stateChange
is fired, token prices are now updated across all chain IDs whose tokens changed, instead of just the current chain. (#4866) - The
TokenDetectionController
now passes ax-metamask-clientproduct
header when calling the account API. (#4877)
- BREAKING: The polling input accepted by
CurrencyRateController
is now an object with anativeCurrencies
property that is defined as astring
array type (#4852)- The
input
parameters of the controller's_executePoll
,_startPolling
,onPollingComplete
methods now only accept this new polling input type. - The
nativeCurrency
property (string
type) has been removed.
- The
- BREAKING:
RatesController
now types theconversionRate
andusdConversionRate
in its state asnumber
instead ofstring
, to match what it was actually storing. (#4852) - Bump
@metamask/base-controller
from^7.0.1
to^7.0.2
(#4862) - Bump
@metamask/controller-utils
from^11.4.0
to^11.4.1
(#4862) - Bump dev dependency
@metamask/approval-controller
from^7.1.0
to^7.1.1
(#4862)
- BREAKING: The CurrencyRateController polling input is now
{ nativeCurrency: string }
instead of a network client ID (#4839) - BREAKING: Bump
@metamask/network-controller
peer dependency to^22.0.0
(#4841) - Bump
@metamask/controller-utils
to^11.4.0
(#4834) - Bump
@metamask/rpc-errors
to^7.0.1
(#4831) - Bump
@metamask/utils
to^10.0.0
(#4831)
- Update TokenRatesController to not reset market data just after network switch but before loading new market data (#4832)
- BREAKING:
AccountTrackerController
,CurrencyRateController
,TokenDetectionController
,TokenListController
, andTokenRatesController
now use a new polling interface that accepts the generic parameterPollingInput
(#4752) - BREAKING: The inherited
AbstractPollingController
methodstartPollingByNetworkClientId
has been renamed tostartPolling
(#4752) - BREAKING: The inherited
AbstractPollingController
methodonPollingComplete
now returns the entire input object of typePollingInput
, instead of a network client id (#4752)
- The
includeDuplicateSymbolAssets
param is removed from our api call to TokenApi (#4768)
- The
TokenRatesController
now fetches token rates for all accounts, instead of just the selected account (#4759)
- Parallelization of detected tokens with balance (#4697)
- Bump accounts related packages (#4713), (#4728)
- Those packages are now built slightly differently and are part of the accounts monorepo.
- Bump
@metamask/keyring-api
from^8.1.0
to^8.1.4
- Produce and export ESM-compatible TypeScript type declaration files in addition to CommonJS-compatible declaration files (#4648)
- Previously, this package shipped with only one variant of type declaration
files, and these files were only CommonJS-compatible, and the
exports
field inpackage.json
linked to these files. This is an anti-pattern and was rightfully flagged by the "Are the Types Wrong?" tool as "masquerading as CJS". All of the ATTW checks now pass.
- Previously, this package shipped with only one variant of type declaration
files, and these files were only CommonJS-compatible, and the
- Remove chunk files (#4648).
- Previously, the build tool we used to generate JavaScript files extracted common code to "chunk" files. While this was intended to make this package more tree-shakeable, it also made debugging more difficult for our development teams. These chunk files are no longer present.
- Don't update currency rates on transient errors (#4662)
- In
CurrencyRateController
if unexpected errors occur during requests to crypto compare, the conversion rate in state will remain unchanged instead of being set to null.
- In
- Fix fallback conversion rate for token market data (#4615)
- On networks where the native currency is not ETH, token market data is now correctly priced in the native currency.
- Export
MarketDataDetails
type (#4622)
- BREAKING: Narrow
TokensController
constructor optionprovider
by removingundefined
from its type signature (#4567) - BREAKING: Bump devDependency and peerDependency
@metamask/network-controller
from^20.0.0
to^21.0.0
(#4618, #4651) - Bump
@metamask/base-controller
from^6.0.2
to^7.0.0
(#4625, #4643) - Bump
@metamask/controller-utils
from^11.0.2
to^11.2.0
(#4639, #4651) - Bump
@metamask/polling-controller
from^9.0.1
to^10.0.0
(#4651) - Bump
@metamask/keyring-api
to version8.1.0
(#4594) - Bump
typescript
from~5.0.4
to~5.2.2
(#4576, #4584)
- Fix
RatesController
setCryptocurrencyList
method, which was not using the correct field when updating internal state (#4572) - Fetch correct price for the $OMNI native currency (#4570)
- Add public
name
property toAssetsContractController
(#4564)
- Add elements to the
AssetsContractController
class: (#4397)- Add class field
messagingSystem
. - Add getters for
ipfsGateway
andchainId
. As corresponding setters have not been defined, these properties are not externally mutable.
- Add class field
- Add and export the
AssetsContractControllerMessenger
type (#4397)AssetsContractControllerMessenger
must allow the external actionsNetworkController:getNetworkClientById
,NetworkController:getNetworkConfigurationByNetworkClientId
,NetworkController:getSelectedNetworkClient
,NetworkController:getState
.AssetsContractControllerMessenger
must allow the external eventsPreferencesController:stateChange
,NetworkController:networkDidChange
.
- Add and export new types:
AssetsContractControllerActions
,AssetsContractControllerEvents
,AssetsContractControllerGetERC20StandardAction
,AssetsContractControllerGetERC721StandardAction
,AssetsContractControllerGetERC1155StandardAction
,AssetsContractControllerGetERC20BalanceOfAction
,AssetsContractControllerGetERC20TokenDecimalsAction
,AssetsContractControllerGetERC20TokenNameAction
,AssetsContractControllerGetERC721NftTokenIdAction
,AssetsContractControllerGetERC721TokenURIAction
,AssetsContractControllerGetERC721AssetNameAction
,AssetsContractControllerGetERC721AssetSymbolAction
,AssetsContractControllerGetERC721OwnerOfAction
,AssetsContractControllerGetERC1155TokenURIAction
,AssetsContractControllerGetERC1155BalanceOfAction
,AssetsContractControllerTransferSingleERC1155Action
,AssetsContractControllerGetTokenStandardAndDetailsAction
,AssetsContractControllerGetBalancesInSingleCallAction
(#4397) - Add a new
setProvider
method toAssetsContractController
(#4397)- Replaces the removed
provider
setter method, and widens theprovider
function parameter type fromProvider
toProvider | undefined
.
- Replaces the removed
- Export
TokenBalancesControllerState
type (#4535)- This was defined but not exported in v34.0.0.
- Add
getNFTContractInfo
method to theNFTController
for fetching NFT Collection Metadata from the NFT API (#4524)
- BREAKING: Add required constructor option
messenger
to theAssetsContractController
class (#4397) - BREAKING:
TokenBalancesControllerMessenger
must allow theAssetsContractController:getERC20BalanceOf
action in addition to its previous allowed actions (#4397) - BREAKING:
NftControllerMessenger
must allow the following actions in addition to its previous allowed actions:AssetsContractController:getERC721AssetName
,AssetsContractController:getERC721AssetSymbol
,AssetsContractController:getERC721TokenURI
,AssetsContractController:getERC721OwnerOf
,AssetsContractController:getERC1155BalanceOf
,AssetsContractController:getERC1155TokenURI
(#4397) - BREAKING: The type of
SINGLE_CALL_BALANCES_ADDRESS_BY_CHAINID
is narrowed fromRecord<Hex, string>
to the const-asserted literal properties of theSINGLE_CALL_BALANCES_ADDRESS_BY_CHAINID
object (#4397)- The index signature is restricted to the union of the enum keys of
SupportedTokenDetectionNetworks
. - The property value type is restricted to the type union of the addresses defined in the object.
- The object type is constrained by
Record<Hex, string>
using thesatisfies
keyword.
- The index signature is restricted to the union of the enum keys of
- BREAKING: Convert the
BalanceMap
type from aninterface
into a type alias (#4397)- Type aliases have an index signature of
string
by default, and are compatible with theStateConstraint
type defined in the@metamask/base-controller
package.
- Type aliases have an index signature of
- BREAKING:
getIpfsCIDv1AndPath
,getFormattedIpfsUrl
are now async functions (#3645) - BREAKING: Bump peerDependency
@metamask/accounts-controller
from^17.0.0
to^18.0.0
(#4548) - Remove
@metamask/accounts-controller
,@metamask/approval-controller
,@metamask/keyring-controller
, and@metamask/preferences-controller
dependencies #4556- These were listed under
peerDependencies
already, so they were redundant as dependencies.
- These were listed under
- Add
immer
^9.0.6
as a new dependency (#3645) - Bump
@metamask/abi-utils
from^2.0.2
to^2.0.3
(#3645) - Bump
@metamask/base-controller
from^6.0.0
to^6.0.2
(#4517, #4544) - Bump
@metamask/controller-utils
from^11.0.1
to^11.0.2
(#4544) - Bump
@metamask/utils
from^9.0.0
to^9.1.0
(#4529) - Bump
multiformats
from^9.5.2
to^13.1.0
(#3645) - Bump
@metamask/polling-controller
from^9.0.0
to^9.0.1
(#4548)
- BREAKING: Remove elements from the
AssetsContractController
class: (#4397)- BREAKING:
AssetsContractController
no longer inherits fromBaseControllerV1
. - BREAKING: Remove constructor option callbacks
onPreferencesStateChange
,onNetworkDidChange
,getNetworkClientById
, and replace with corresponding messenger actions and events. - BREAKING: Remove class fields:
name
,config
(along with its propertiesprovider
,ipfsGateway
,chainId
). - BREAKING: Remove methods:
getProvider
,getChainId
.- Use the getters
provider
andchainId
instead.
- Use the getters
- BREAKING: Remove the
provider
setter method.- Use the
setProvider
method instead.
- Use the
- BREAKING:
- BREAKING: Remove the
getERC20BalanceOf
constructor option callback from theTokenBalancesControllerOptions
type and theTokenBalancesController
constructor (#4397)- The messenger is expected to allow
AssetsContractController:getERC20BalanceOf
messenger action so that it can be used instead.
- The messenger is expected to allow
- BREAKING: Remove
NftController
constructor option callbacks:getERC721AssetName
,getERC721AssetSymbol
,getERC721TokenURI
,getERC721OwnerOf
,getERC1155BalanceOf
,getERC1155TokenURI
(#4397)- These are accessed through the messenger instead.
- BREAKING: Remove the
AssetsContractConfig
type (#4397) - BREAKING: Remove export for
MISSING_PROVIDER_ERROR
(#4397)
- BREAKING: Convert the
getERC721NftTokenId
method of theAssetsContractController
into an async function. (#4397)
- Add optional
topBid
property to theNftMetadata
type. This property must be of typeTopBid
. (#4522) - Add optional
floorAsk
property to theTokenCollection
type. This property must be of typeFloorAskCollection
. (#4522) - Add linea mainnet support to nft detection supported networks (#4515)
- The
Collection
type is expanded to include the following 'string'-type optional properties:contractDeployedAt
,creator
,ownerCount
, and an optional propertytopBid
of the typeTopBid & { sourceDomain?: string; }
. (#4443)
- Fetch NFT collections data from the NFT-API
Get Collections
endpoint when calling thedetectNfts
method ofNftDetectionController
, and theupdateNftMetadata
andwatchNft
methods ofNftController
. (#4443) - Bump
@metamask/utils
to^9.0.0
(#4516) - Bump
@metamask/rpc-errors
to^6.3.1
(#4516)
- BREAKING: The
attributes
property of theNftMetadata
type must be of typeAttributes[]
(#4522)- The
attributes
property was added and typed asAttributes
onv28.0.0
.
- The
- BREAKING: Bump peerDependency
@metamask/network-controller
to^20.0.0
(#4508) - Bump
@metamask/polling-controller
to^9.0.0
(#4508) - Bump
@metamask/accounts-controller
to^17.2.0
(#4498)
- Add support for tokenURI encoded images to
NftController
methodsaddNft
,watchNft
andupdateNftMetadata
(#4482)
- Add
AccountTrackerControllerGetStateAction
,AccountTrackerControllerActions
,AccountTrackerControllerStateChangeEvent
, andAccountTrackerControllerEvents
types (#4407) - Add
setIntervalLength
andgetIntervalLength
methods toAccountTrackerController
(#4407)setIntervalLength
replaces updating the polling interval viaconfigure
.
- BREAKING
TokenBalancesController
messenger must allow the actionAccountsController:getSelectedAccount
and removePreferencesController:getState
. (#4219) - BREAKING
TokenDetectionController
messenger must allow the actionAccountsController:getAccount
. (#4219) - BREAKING
TokenDetectionController
messenger must allow the eventAccountsController:selectedEvmAccountChange
and removeAccountsController:selectedAccountChange
. (#4219) - BREAKING
TokenRatesController
messenger must allow the actionAccountsController:getAccount
,AccountsController:getSelectedAccount
and removePreferencesController:getState
. (#4219) - BREAKING
TokenRatesController
messenger must allow the eventAccountsController:selectedEvmAccountChange
and removePreferencesController:stateChange
. (#4219) - BREAKING
TokensController
messenger must allow the actionAccountsController:getAccount
,AccountsController:getSelectedAccount
. - BREAKING
TokensController
messenger must allow the eventAccountsController:selectedEvmAccountChange
. (#4219) - Upgrade AccountTrackerController to BaseControllerV2 (#4407)
- BREAKING: Convert
AccountInformation
from interface to type (#4407) - BREAKING: Rename
AccountTrackerState
toAccountTrackerControllerState
and convert from interface to type (#4407) - BREAKING:
AccountTrackerController
now inherits fromStaticIntervalPollingController
instead ofStaticIntervalPollingControllerV1
(#4407)- The constructor now takes a single options object rather than three arguments. Some options have been removed; see later entries.
- BREAKING: The
AccountTrackerController
messenger must now allow the actionsPreferencesController:getState
,NetworkController:getState
, andNetworkController:getNetworkClientById
(#4407) - BREAKING: The
refresh
method is no longer pre-bound to the controller (#4407)- You may now need to pre-bind it e.g.
accountTrackerController.refresh.bind(accountTrackerController)
.
- You may now need to pre-bind it e.g.
- Bump
@metamask/accounts-controller
to^17.1.0
(#4460)
- BREAKING
TokensController
removesselectedAddress
constructor argument. (#4219) - BREAKING
TokenDetectionController
removesselectedAddress
constructor argument. (#4219) - BREAKING: Remove
AccountTrackerConfig
type (#4407)- Some of these properties have been merged into the options that the
AccountTrackerController
constructor takes.
- Some of these properties have been merged into the options that the
- BREAKING: Remove
config
property andconfigure
method fromAccountTrackerController
(#4407)- The controller now takes a single options object which can be used for configuration, and configuration is now kept internally.
- BREAKING: Remove
notify
,subscribe
, andunsubscribe
methods fromAccountTrackerController
(#4407)- Use the controller messenger for subscribing to and publishing events instead.
- BREAKING: Remove
provider
,getMultiAccountBalancesEnabled
,getCurrentChainId
, andgetNetworkClientById
from configuration options forAccountTrackerController
(#4407)- The provider is now obtained directly from the network controller on demand.
- The messenger is now used in place of the callbacks.
- BREAKING: Add
messenger
as a constructor option forAccountTrackerController
(#4225) - BREAKING: Add
messenger
option toTokenRatesController
(#4314)- This messenger must allow the actions
TokensController:getState
,NetworkController:getNetworkClientById
,NetworkController:getState
, andPreferencesController:getState
and allow the eventsPreferencesController:stateChange
,TokensController:stateChange
, andNetworkController:stateChange
.
- This messenger must allow the actions
- Add types
TokenRatesControllerGetStateAction
,TokenRatesControllerActions
,TokenRatesControllerStateChangeEvent
,TokenRatesControllerEvents
,TokenRatesControllerMessenger
(#4314) - Add function
getDefaultTokenRatesControllerState
(#4314) - Add
enable
anddisable
methods toTokenRatesController
(#4314)- These are used to stop and restart polling.
- Export
ContractExchangeRates
type (#4314)- Add
AccountTrackerControllerMessenger
type
- Add
- BREAKING: The
NftController
messenger must now allowAccountsController:getAccount
andAccountsController:getSelectedAccount
as messenger actions andAccountsController:selectedEvmAccountChange
as a messenger event (#4221) - BREAKING:
NftDetectionController
messenger must now allowAccountsController:getSelectedAccount
as a messenger action (#4221) - Token price API support for mantle network (#4376)
- BREAKING: Bump dependency and peer dependency
@metamask/accounts-controller
to^17.0.0
(#4413) - BREAKING:
TokenRatesController
now inherits fromStaticIntervalPollingController
instead ofStaticIntervalPollingControllerV1
(#4314)- The constructor now takes a single options object rather than three arguments. Some options have been removed; see later entries.
- BREAKING: Rename
TokenRatesState
toTokenRatesControllerState
, and convert frominterface
totype
(#4314) - The
NftController
now reads the selected address via theAccountsController
, using theAccountsController:selectedEvmAccountChange
messenger event to stay up to date (#4221) NftDetectionController
now reads the currently selected account fromAccountsController
instead ofPreferencesController
(#4221)- Bump
@metamask/keyring-api
to^8.0.0
(#4405) - Bump
@metamask/eth-snap-keyring
to^4.3.1
(#4405) - Bump
@metamask/keyring-controller
to^17.1.0
(#4413)
- BREAKING: Remove
nativeCurrency
,chainId
,selectedAddress
,allTokens
, andallDetectedTokens
from configuration options forTokenRatesController
(#4314)- The messenger is now used to obtain information from other controllers where this data was originally expected to come from.
- BREAKING: Remove
config
property andconfigure
method fromTokenRatesController
(#4314)- The controller now takes a single options object which can be used for configuration, and configuration is now kept internally.
- BREAKING: Remove
notify
,subscribe
, andunsubscribe
methods fromTokenRatesController
(#4314)- Use the controller messenger for subscribing to and publishing events instead.
- BREAKING: Remove
TokenRatesConfig
type (#4314)- Some of these properties have been merged into the options that
TokenRatesController
takes.
- Some of these properties have been merged into the options that
- BREAKING: Remove
NftController
constructor optionsselectedAddress
. (#4221) - BREAKING: Remove
AccountTrackerController
constructor optionsgetIdentities
,getSelectedAddress
andonPreferencesStateChange
(#4225) - BREAKING: Remove
value
property from the data for each token instate.marketData
(#4364)- The
price
property should be used instead.
- The
- Prevent unnecessary state updates when executing the
NftController
'supdateNftMetadata
method by comparing the metadata of fetched NFTs and NFTs in state and synchronizing state updates using a mutex lock. (#4325) - Prevent the use of market data when not available for a given token (#4361)
- Fix
refresh
method remaining locked indefinitely after it was run successfully. Now lock is released on successful as well as failed runs. (#4270) TokenRatesController
uses checksum instead of lowercase format for token addresses (#4377)
- BREAKING: Bump minimum Node version to 18.18 (#3611)
- BREAKING: Bump dependency and peer dependency
@metamask/accounts-controller
to^16.0.0
(#4352) - BREAKING: Bump dependency and peer dependency
@metamask/approval-controller
to^7.0.0
(#4352) - BREAKING: Bump dependency and peer dependency
@metamask/keyring-controller
to^17.0.0
(#4352) - BREAKING: Bump dependency and peer dependency
@metamask/network-controller
to^19.0.0
(#4352) - BREAKING: Bump dependency and peer dependency
@metamask/preferences-controller
to^13.0.0
(#4352) - Bump
@metamask/base-controller
to^6.0.0
(#4352) - Bump
@metamask/controller-utils
to^11.0.0
(#4352) - Bump
@metamask/polling-controller
to^8.0.0
(#4352)
- BREAKING: The
NftDetectionController
now takes amessenger
, which can be used for communication (#4312)- This messenger must allow the following actions
ApprovalController:addRequest
,NetworkController:getState
,NetworkController:getNetworkClientById
, andPreferencesController:getState
, and must allow the eventsPreferencesController:stateChange
andNetworkController:stateChange
- This messenger must allow the following actions
- Add
NftDetectionControllerMessenger
type (#4312) - Add
NftControllerGetStateAction
,NftControllerActions
,NftControllerStateChangeEvent
, andNftControllerEvents
types (#4310) - Add
NftController:getState
andNftController:stateChange
as an available action and event to theNftController
messenger (#4310)
- BREAKING: Change
TokensController
to inherit fromBaseController
rather thanBaseControllerV1
(#4304)- The constructor now takes a single options object rather than three arguments, and all properties in
config
are now part of options.
- The constructor now takes a single options object rather than three arguments, and all properties in
- BREAKING: Rename
TokensState
type toTokensControllerState
(#4304) - BREAKING: Make all
TokensController
methods and properties starting with_
private (#4304) - BREAKING: Convert
Token
frominterface
totype
(#4304) - BREAKING: Replace
balanceError
property inToken
withhasBalanceError
; updateTokenBalancesController
so that it no longer captures the error resulting from getting the balance of an ERC-20 token (#4304) - BREAKING: Change
NftDetectionController
to inherit fromStaticIntervalPollingController
rather thanStaticIntervalPollingControllerV1
(#4312)- The constructor now takes a single options object rather than three arguments, and all properties in
config
are now part of options.
- The constructor now takes a single options object rather than three arguments, and all properties in
- BREAKING: Convert
ApiNft
,ApiNftContract
,ApiNftLastSale
, andApiNftCreator
frominterface
totype
(#4312) - BREAKING: Change
NftController
to inherit fromBaseController
rather thanBaseControllerV1
(#4310)- The constructor now takes a single options object rather than three arguments, and all properties in
config
are now part of options.
- The constructor now takes a single options object rather than three arguments, and all properties in
- BREAKING: Convert
Nft
,NftContract
, andNftMetadata
frominterface
totype
(#4310) - BREAKING: Rename
NftState
toNftControllerState
, and convert totype
(#4310) - BREAKING: Rename
getDefaultNftState
togetDefaultNftControllerState
(#4310) - BREAKING: Bump dependency and peer dependency
@metamask/accounts-controller
to^15.0.0
(#4342) - BREAKING: Bump dependency and peer dependency
@metamask/approval-controller
to^6.0.2
(#4342) - BREAKING: Bump dependency and peer dependency
@metamask/keyring-controller
to^16.1.0
(#4342) - BREAKING: Bump dependency and peer dependency
@metamask/network-controller
to^18.1.3
(#4342) - BREAKING: Bump dependency and peer dependency
@metamask/preferences-controller
to^12.0.0
(#4342) - Change
NftDetectionController
methoddetectNfts
so thatuserAddress
option is optional (#4312)- This will default to the currently selected address as kept by PreferencesController.
- Bump
async-mutex
to^0.5.0
(#4335) - Bump
@metamask/polling-controller
to^7.0.0
(#4342)
- BREAKING: Remove
config
property andconfigure
method fromTokensController
(#4304)- The
TokensController
now takes a single options object which can be used for configuration, and configuration is now kept internally.
- The
- BREAKING: Remove
notify
,subscribe
, andunsubscribe
methods fromTokensController
(#4304)- Use the controller messenger for subscribing to and publishing events instead.
- BREAKING: Remove
TokensConfig
type (#4304)- These properties have been merged into the options that
TokensController
takes.
- These properties have been merged into the options that
- BREAKING: Remove
config
property andconfigure
method fromTokensController
(#4312)TokensController
now takes a single options object which can be used for configuration, and configuration is now kept internally.
- BREAKING: Remove
notify
,subscribe
, andunsubscribe
methods fromNftDetectionController
(#4312)- Use the controller messenger for subscribing to and publishing events instead.
- BREAKING: Remove
chainId
as aNftDetectionController
constructor argument (#4312)- The controller will now read the
networkClientId
from the NetworkController state through the messenger when needed.
- The controller will now read the
- BREAKING: Remove
getNetworkClientById
as aNftDetectionController
constructor argument (#4312)- The controller will now call
NetworkController:getNetworkClientId
through the messenger object.
- The controller will now call
- BREAKING: Remove
onPreferencesStateChange
as aNftDetectionController
constructor argument (#4312)- The controller will now call
PreferencesController:stateChange
through the messenger object.
- The controller will now call
- BREAKING: Remove
onNetworkStateChange
as aNftDetectionController
constructor argument (#4312)- The controller will now read the
networkClientId
from the NetworkController state through the messenger when needed.
- The controller will now read the
- BREAKING: Remove
getOpenSeaApiKey
as aNftDetectionController
constructor argument (#4312)- This was never used.
- BREAKING: Remove
getNftApi
as aNftDetectionController
constructor argument (#4312)- This was never used.
- BREAKING: Remove
NftDetectionConfig
type (#4312)- These properties have been merged into the options that
NftDetectionController
takes.
- These properties have been merged into the options that
- BREAKING: Remove
config
property andconfigure
method fromNftController
(#4310)NftController
now takes a single options object which can be used for configuration, and configuration is now kept internally.
- BREAKING: Remove
notify
,subscribe
, andunsubscribe
methods fromNftController
(#4310)- Use the controller messenger for subscribing to and publishing events instead.
- BREAKING: Remove
onPreferencesStateChange
as aNftController
constructor argument (#4310)- The controller will now call
PreferencesController:stateChange
through the messenger object.
- The controller will now call
- BREAKING: Remove
onNetworkStateChange
as aNftController
constructor argument (#4310)- The controller will now call
NetworkController:stateChange
through the messenger object.
- The controller will now call
- BREAKING: Remove
NftConfig
type (#4310)- These properties have been merged into the options that
NftController
takes.
- These properties have been merged into the options that
- BREAKING: Remove
config
property andconfigure
method fromNftController
(#4310)NftController
now takes a single options object which can be used for configuration, and configuration is now kept internally.
- BREAKING: Remove
hub
property fromNftController
(#4310)- Use the controller messenger for subscribing to and publishing events instead.
- BREAKING: Modify
TokenListController
so that tokens fetched from the API and stored in state will no longer havestorage
anderc20
properties (#4235)- These properties were never officially supported, but they were present in state anyway.
- Adds a new field
marketData
to the state ofTokenRatesController
(#4206) - Adds a new
RatesController
to manage prices for non-EVM blockchains (#4242)
- BREAKING: Changed price and token API endpoints from
*.metafi.codefi.network
to*.api.cx.metamask.io
(#4301) - When fetching token list for Linea Mainnet, use
occurrenceFloor
parameter of 1 instead of 3, and filter tokens to those with alineaTeam
aggregator or more than 3 aggregators (#4253) - BREAKING: The NftController messenger must now allow the
NetworkController:getNetworkClientById
action (#4305) - BREAKING: Bump dependency and peer dependency
@metamask/network-controller
to^18.1.2
(#4332) - Bump
@metamask/keyring-api
to^6.1.1
(#4262)
- BREAKING: Removed
contractExchangeRates
andcontractExchangeRatesByChainId
from the state ofTokenRatesController
(#4206)
- Only update NFT state when metadata actually changes (#4143)
- Add token detection on 7 more networks (#4184)
- New supported networks are: cronos, celo, gnosis, fantom, polygon_zkevm, moonbeam, and moonriver
- BREAKING Changed
NftDetectionController
constructoroptions
argument (#4178)- Added
options.disabled
andoptions.selectedAddress
properties
- Added
- BREAKING Bump
@metamask/keyring-controller
peer dependency to ^16.0.0 (#4234) - BREAKING Bump
@metamask/accounts-controller
peer dependency to ^14.0.0 (#4234) - BREAKING Bump
@metamask/preferences-controller
peer dependency to ^11.0.0 (#4234) - Bump
@metamask/keyring-api
to^6.0.0
(#4193) - Lower number of tokens returned by API calls (#4207)
- Limit changed from
200
to50
- Limit changed from
- Bump
@metamask/base-controller
to^5.0.2
(#4232) - Bump
@metamask/approval-controller
to^6.0.2
(#4234) - Bump
@metamask/polling-controller
to^6.0.2
(#4234)
- Add reservoir migration (#4030)
- Fix getting nft tokenURI (#4136)
- BREAKING Bump peer dependency on
@metamask/keyring-controller
(#4090) - Fix token detection during account change (#4133)
- Fix update nft metadata when toggles off (#4096)
- Adds
tokenMethodIncreaseAllowance
(#4069) - Fix mantle token mispriced (#4045)
-
CodefiTokenPricesServiceV2
exportsSUPPORTED_CHAIN_IDS
, an array of chain IDs supported by Codefi Price API V2. (#4079) -
Added
tokenURI
key tocompareNftMetadata
function to compare nft metadata entries with. (#3856)
- Add
updateNftMetadata
method toNftController
to update metadata for the requested NFTs (#4008)
- Fix
types
field inpackage.json
(#4047)
- BREAKING: Add ESM build (#3998)
- It's no longer possible to import files from
./dist
directly.
- It's no longer possible to import files from
- BREAKING: Bump dependency and peer dependency on
@metamask/accounts-controller
to^12.0.0
(#4039) - BREAKING: Bump dependency and peer dependency on
@metamask/approval-controller
to^6.0.0
(#4039) - BREAKING: Bump
@metamask/base-controller
to^5.0.0
(#4039)- This version has a number of breaking changes. See the changelog for more.
- BREAKING: Bump dependency and peer dependency on
@metamask/keyring-controller
to^14.0.0
(#4039) - BREAKING: Bump dependency and peer dependency on
@metamask/network-controller
to^18.0.0
(#4039) - BREAKING: Bump dependency and peer dependency on
@metamask/preferences-controller
to^9.0.0
(#4039) - Relax
TokensControllerGetStateAction
andTokensControllerStateChangeEvent
types so that they no longer constrain theTokensController
state in the action handler and event payload toRecord<string, Json>
(#3949) - Bump
@metamask/controller-utils
to^9.0.0
(#4039) - Bump
@metamask/polling-controller
to^6.0.0
(#4039)
- BREAKING:
TokenDetectionController
newly subscribes to thePreferencesController:stateChange
,AccountsController:selectedAccountChange
,KeyringController:lock
, andKeyringController:unlock
events, and allows messenger actionsAccountsController:getSelectedAccount
,NetworkController:getNetworkClientById
,NetworkController:getNetworkConfigurationByNetworkClientId
,NetworkController:getState
,KeyringController:getState
,PreferencesController:getState
,TokenListController:getState
,TokensController:getState
, andTokensController:addDetectedTokens
(#3775, #3923, #3938) TokensController
now exportsTokensControllerActions
,TokensControllerGetStateAction
,TokensControllerAddDetectedTokensAction
,TokensControllerEvents
, andTokensControllerStateChangeEvent
(#3690)
- BREAKING: Add
@metamask/accounts-controller
^11.0.0
as dependency and peer dependency (#3775, #4007) - BREAKING: Add
@metamask/keyring-controller
^13.0.0
as dependency and peer dependency (#3775, #4007) - BREAKING: Bump
@metamask/preferences-controller
dependency and peer dependency to^8.0.0
(#4007) - BREAKING:
TokenDetectionController
is merged withDetectTokensController
from themetamask-extension
repo (#3775, #3923), (#3938)- BREAKING:
TokenDetectionController
now resets its polling interval to the default value of 3 minutes when token detection is triggered by external controller eventsKeyringController:unlock
,TokenListController:stateChange
,PreferencesController:stateChange
,AccountsController:selectedAccountChange
. - BREAKING:
TokenDetectionController
now refetches tokens onNetworkController:networkDidChange
if thenetworkClientId
is changed instead ofchainId
. - BREAKING:
TokenDetectionController
cannot initiate polling or token detection ifKeyringController
state is locked. - BREAKING: The
detectTokens
method input optionaccountAddress
has been renamed toselectedAddress
. - BREAKING: The
detectTokens
method now excludes tokens that are already included in theTokensController
'sdetectedTokens
list from the batch of incoming tokens it sends to theTokensController
addDetectedTokens
method. - BREAKING: The constructor for
TokenDetectionController
expects a new required propertytrackMetaMetricsEvent
, which defines the callback that is called in thedetectTokens
method. - BREAKING: In Mainnet, even if the
PreferenceController
'suseTokenDetection
option is set to false, automatic token detection is performed on the legacy token list (token data from the contract-metadata repo). - BREAKING: The
TokensState
type is now defined as a type alias rather than an interface. (#3690)- This is breaking because it could affect how this type is used with other types, such as
Json
, which does not support TypeScript interfaces.
- This is breaking because it could affect how this type is used with other types, such as
- The constructor option
selectedAddress
no longer defaults to''
if omitted. Instead, the correct address is assigned using theAccountsController:getSelectedAccount
messenger action.
- BREAKING:
- BREAKING: Change type of
provider
property inAssetsContractController
fromany
toProvider
from@metamask/network-controller
(#3818) - BREAKING: Change type of
provider
property inTokensController
fromany
toProvider
from@metamask/network-controller
(#3818) - Bump
@metamask/approval-controller
to^5.1.3
(#4007) - Bump
@metamask/controller-utils
to^8.0.4
(#4007) - Bump
@metamask/ethjs-unit
to^0.3.0
(#3897) - Bump
@metamask/network-controller
to^17.2.1
(#4007) - Bump
@metamask/polling-controller
to^5.0.1
(#4007) - Bump
@metamask/rpc-errors
to^6.2.1
(#3970, #3954) - Replace
ethereumjs-util
with@ethereumjs/util
andbn.js
(#3943) - Update
CodefiTokenPricesServiceV2
so that requests to the price API now use theNo-Cache
HTTP header (#3939)
- BREAKING:
TokenDetectionController
constructor no longer accepts optionsnetworkClientId
,onPreferencesStateChange
,getPreferencesState
,getTokensState
, oraddDetectedTokens
(#3690, #3775, #3938) - BREAKING:
TokenDetectionController
no longer allows theNetworkController:stateChange
event. (#3775)- The
NetworkController:networkDidChange
event can be used instead.
- The
- BREAKING:
TokenDetectionController
constructor no longer accepts optionsnetworkClientId
,onPreferencesStateChange
,getPreferencesState
,getTokensState
, oraddDetectedTokens
(#3690, #3775, #3938) - BREAKING:
TokenBalancesController
constructor no longer accepts optionsonTokensStateChange
,getSelectedAddress
(#3690)
TokenDetectionController.detectTokens()
now reads the chain ID keyed state properties fromTokenListController
andTokensController
rather than incorrectly using the globally selected state properties when a network client ID is passed (#3914)- Fix
PreferencesController
state listener inNftDetectionController
so that NFT detection is not run when any preference changes, but only when NFT detection is enabled (#3917) - Fix
isTokenListSupportedForNetwork
so that it returns false for chain 1337 (#3777)- When used in combination with
TokensController
, this makes it possible to import an ERC-20 token on a locally run chain.
- When used in combination with
- Add Linea to price api supported chains (#3797)
- BREAKING: Convert
TokenBalancesController
toBaseControllerV2
(#3750)- The constructor parameters have changed; rather than accepting a "config" parameter for interval and tokens we now pass both values as controller options, and a "state" parameter, there is now just a single object for all constructor arguments. This object has a mandatory
messenger
and an optionalstate
,tokens
,interval
properties a disabled property has also been added. - State now saves tokens balances as strings and not as a BNs.
- Additional BN export has been removed as it was intended to be removed in the next major release.
- The constructor parameters have changed; rather than accepting a "config" parameter for interval and tokens we now pass both values as controller options, and a "state" parameter, there is now just a single object for all constructor arguments. This object has a mandatory
- BREAKING: Bump
@metamask/approval-controller
peer dependency to^5.1.2
(#3821) - BREAKING: Bump
@metamask/network-controller
peer dependency to^17.2.0
(#3821) - BREAKING: Bump
@metamask/preferences-controller
peer dependency to^7.0.0
(#3821) - Bump
@metamask/utils
to^8.3.0
(#3769) - Bump
@metamask/base-controller
to^4.1.1
(#3760, #3821) - Bump
@metamask/controller-utils
to^8.0.2
(#3821) - Bump
@metamask/polling-controller
to^5.0.0
(#3821)
- Add
getDefaultTokenListState
function toTokenListController
(#3744) - Add
getDefaultNftState
function to theNftController
(#3742) - Add
getDefaultTokensState
function to theTokensController
(#3743)
- BREAKING: Bump
@metamask/preferences-controller
to ^6.0.0 - Price API perf improvements (#3753, #3755)
- Reduce token batch size from 100 to 30
- Sort token addresses in query params for more cache hits
- Add support to
CodefiTokenPricesServiceV2
for tracking degraded service (#3691)- The constructor has two new options:
onDegraded
anddegradedThreshold
.onDegraded
is an event handler for instances of degraded service (i.e. failed or slow requests), anddegradedThreshold
determines how slow a request has to be before we consider service to be degraded.
- The constructor has two new options:
- Add
onBreak
handler toCodefiTokenPricesServiceV2
(#3677)- This allows listening for "circuit breaks", which can indicate an outage. Useful for metrics.
- Add
fetchTokenContractExchangeRates
utility method (#3657) TokenListController
now exports aTokenListControllerMessenger
type (#3609).TokenDetectionController
exports typesTokenDetectionControllerMessenger
,TokenDetectionControllerActions
,TokenDetectionControllerGetStateAction
,TokenDetectionControllerEvents
,TokenDetectionControllerStateChangeEvent
(#3609).- Add
enable
anddisable
methods toTokenDetectionController
, which control whether the controller is able to make polling requests or all of its network calls are blocked. (#3609).- Note that if the controller is initiated without the
disabled
constructor option set tofalse
, theenable
method will need to be called before the controller can make polling requests in response to subscribed events.
- Note that if the controller is initiated without the
- BREAKING: Bump
@metamask/approval-controller
dependency and peer dependency from^5.1.0
to^5.1.1
(#3695) - BREAKING: Bump
@metamask/network-controller
dependency and peer dependency from^17.0.0
to^17.1.0
(#3695) - BREAKING: Bump
@metamask/preferences-controller
dependency and peer dependency from^5.0.0
to^5.0.1
(#3695) - BREAKING: Update
OpenSeaV2Contract
type, renamingsupply
tototal_supply
(#3692) - BREAKING:
TokenDetectionController
is upgraded to extendBaseControllerV2
andStaticIntervalPollingController
(#3609).- The constructor now expects an options object as its only argument, with required properties
messenger
,networkClientId
, required callbacksonPreferencesStateChange
,getBalancesInSingleCall
,addDetectedTokens
,getTokenState
,getPreferencesState
, and optional propertiesdisabled
,interval
,selectedAddress
.
- The constructor now expects an options object as its only argument, with required properties
- Bump
@metamask/base-controller
to^4.0.1
(#3695) - Bump
@metamask/polling-controller
to^4.0.0
(#3695) - Bump
cockatiel
from3.1.1
to^3.1.2
(#3682) - Bump
@metamask/controller-utils
from8.0.0
to^8.0.1
(#3695)
- Fix error caused by OpenSea API rename of
supply
tototal_supply
(#3692) - Fix
CodefiTokenPricesServiceV2
support for Shiden (#3683) - Improve how
CodefiTokenPricesServiceV2
handles token price update failures (#3687)- Previously a single failed token price update would prevent all other token prices from updating as well. With this update, we log and error and continue when we fail to update a token price, ensuring the others still get updated.
- BREAKING: OpenSea V2 API is used instead of V1 (#3654)
NftDetectionController
constructor now requires theNftController.getNftApi
function.- NFT controllers will no longer return
last_sale
information for NFTs fetched after the OpenSea V2 update
- Add
CodefiTokenPricesServiceV2
(#3600, #3655, #3655)- This class can be used for the new
tokenPricesService
argument for TokenRatesController. It uses a MetaMask API to fetch prices for tokens instead of CoinGecko. - The
CodefiTokenPricesServiceV2
will retry if the token price update fails- We retry each request up to 3 times using a randomized exponential backoff strategy
- If the token price update still fails 12 times consecutively (3 update attempts, each of which has 4 calls due to retries), we stop trying for 30 minutes before we try again.
- This class can be used for the new
- Add polling by
networkClientId
toAccountTrackerController
(#3586)- A new state property,
accountByChainId
has been added for keeping track of account balances across chains AccountTrackerController
implementsPollingController
and can now poll bynetworkClientId
via the new methodsstartPollingByNetworkClientId
,stopPollingByPollingToken
, andstopPollingByPollingToken
.AccountTrackerController
accepts an optionalnetworkClientId
value on therefresh
methodAccountTrackerController
accepts an optionalnetworkClientId
value as the last parameter of thesyncBalanceWithAddresses
method
- A new state property,
- Support token detection on Base and zkSync (#3584)
- Support token detection on Arbitrum and Optimism (#2035)
- BREAKING:
TokenRatesController
now takes a required argumenttokenPricesService
(#3600)- This object is responsible for fetching the prices for tokens held by this controller.
- BREAKING: Update signature of
TokenRatesController.updateExchangeRatesByChainId
(#3600, #3653)- Change the type of
tokenAddresses
fromstring[]
toHex[]
- Change the type of
- BREAKING:
AccountTrackerController
constructor params object requiresgetCurrentChainId
andgetNetworkClientById
hooks (#3586)- These are needed for the new "polling by
networkClientId
" feature
- These are needed for the new "polling by
- BREAKING:
AccountTrackerController
has a new required state property,accountByChainId
(#3586)- This is needed to track balances accross chains. It was introduced for the "polling by
networkClientId
" feature, but is useful on its own as well.
- This is needed to track balances accross chains. It was introduced for the "polling by
- BREAKING:
AccountTrackerController
adds a mutex torefresh
making it only possible for one call to be executed at time (#3586) - BREAKING:
TokensController.watchAsset
now performs on-chain validation of the asset's symbol and decimals, if they're defined in the contract (#1745)- The
TokensController
constructor no longer accepts agetERC20TokenName
option. It was no longer needed due to this change. - Add new method
_getProvider
, though this is intended for internal use and should not be called externally. - Additionally, if the symbol and decimals are defined in the contract, they are no longer required to be passed to
watchAsset
- The
- BREAKING: Update controllers that rely on provider to listen to
NetworkController:networkDidChange
instead ofNetworkController:stateChange
(#3610)- The
networkDidChange
event is safer in cases where the provider is used because the provider is guaranteed to have been updated by the time that event is emitted. The same is not true of thestateChange
event. - The following controllers now accept a
onNetworkDidChange
constructor option instead of aonNetworkStateChange
option:TokensController
AssetsContractController
- The
- Update
@metamask/polling-controller
to v3 (#3636)- This update adds two new methods to each polling controller:
_startPollingByNetworkClientId
and_stopPollingByPollingTokenSetId
. These methods are intended for internal use, and should not be called directly. - The affected controllers are:
AccountTrackerController
CurrencyRateController
NftDetectionController
TokenDetectionController
TokenListController
TokenRatesController
- This update adds two new methods to each polling controller:
- Update
@metamask/controller-utils
to v7 (#3636) - Update
TokenListController
to fetch prefiltered set of tokens from the API, reducing response data and removing the need for filtering logic (#2054) - Update
TokenRatesController
to request token rates from the Price API in batches of 100 (#3650) - Add dependencies
cockatiel
andlodash
(#3586, #3655)
- BREAKING: Remove
fetchExchangeRate
method from TokenRatesController (#3600)- This method (not to be confused with
updateExchangeRate
, which is still present) was only ever intended to be used internally and should not be accessed directly.
- This method (not to be confused with
- BREAKING: Remove
getChainSlug
method from TokenRatesController (#3600)- This method was previously used in TokenRatesController to access the CoinGecko API. There is no equivalent.
- BREAKING: Remove
CoinGeckoResponse
andCoinGeckoPlatform
types (#3600)- These types were previously used in TokenRatesController to represent data returned from the CoinGecko API. There is no equivalent.
- BREAKING: The TokenRatesController now only supports updating and polling rates for tokens tracked by the TokensController (#3639)
- The
tokenAddresses
option has been removed fromstartPollingByNetworkClientId
- The
tokenContractAddresses
option has been removed fromupdateExchangeRatesByChainId
- The
- BREAKING:
TokenRatesController.fetchAndMapExchangeRates
is no longer exposed publicly (#3621)
- Prevent
TokenRatesController
from making redundant token rate updates when tokens change (#3647, #3663)- Previously, token rates would be re-fetched for the globally selected network on all TokensController state changes, but now token rates are always performed for a deduplicated and normalized set of addresses, and changes to this set determine whether rates should be re-fetched.
- Prevent redundant overlapping token rate updates in
TokenRatesController
(#3635) - Fix
TokenRatesController
bug where thecontractExchangeRates
state would sometimes be stale after callingupdateExchangeRatesByChainId
(#3624) - Make
TokenRatesController.updateExchangeRatesByChainId
respectdisabled
state (#3596) - Fix error in
NftController
when attempt to get NFT information from on-chain fails, and ensure metadata always contains contract address and blankname
field (#3629)- When fetching on-chain NFT information fails, we now proceed with whatever we have (either the OpenSea metadata, or a blank metadata object)
- Previously, if we were unable to retrieve NFT metadata from on-chain or OpenSea, the returned NFT metadata would be missing a
name
field and the contract address. Now the returned metadata always has those entries, though thename
is set tonull
. - This affects
watchNft
andaddNft
methods
- BREAKING:
TokenRatesControllerState
now has requiredcontractExchangeRatesByChainId
property which an object keyed bychainId
andnativeCurrency
(#2015) - BREAKING:
TokenRatesController
constructor params now requiresgetNetworkClientById
(#2015) - Add types
CurrencyRateControllerEvents
andCurrencyRateControllerActions
(#2029) - Add polling-related methods to TokenRatesController (#2015)
startPollingByNetworkClientId
stopPollingByPollingToken
stopAllPolling
_executePoll
- Add
updateExchangeRatesByChainId
method to TokenRatesController (#2015)- This is a lower-level version of
updateExchangeRates
that takes chain ID, native currency, and token addresses.
- This is a lower-level version of
TokenRatesController
constructor params now accepts optionalinterval
andthreshold
(#2015)TokenRatesController.fetchExchangeRate()
now accepts an optionaltokenAddresses
as the last parameter (#2015)TokenRatesController.getChainSlug()
now accepts an optionalchainId
parameter (#2015)TokenRatesController.fetchAndMapExchangeRates()
now accepts an optionaltokenAddresses
as the last parameter (#2015)
- BREAKING: Bump dependency on
@metamask/base-controller
to ^4.0.0 (#2063)- This is breaking because the type of the
messenger
has backward-incompatible changes. See the changelog for this package for more.
- This is breaking because the type of the
- Bump
@metamask/approval-controller
to ^5.0.0 (#2063) - Bump
@metamask/controller-utils
to ^6.0.0 (#2063) - Bump
@metamask/network-controller
to ^17.0.0 (#2063) - Bump
@metamask/polling-controller
to ^2.0.0 (#2063) - Bump
@metamask/preferences-controller
to ^5.0.0 (#2063)
- BREAKING: Bump dependency and peer dependency on
@metamask/network-controller
to ^16.0.0 - Add optional
networkClientId
anduserAddress
args to remainingNftController
public methods (#2006)watchNft
,removeNft
,removeAndIgnoreNft
,removeNftContract
,updateNftFavoriteStatus
, andcheckAndUpdateAllNftsOwnershipStatus
methods onNftController
all now accept an optional options object argument containingnetworkClientId
anduserAddress
to identify where in state to mutate.- BREAKING:
addNft
no longer accepts achainId
property in its options argument since this value can be retrieved by thenetworkClientId
property and is therefore redundant. - BREAKING: The third and fourth arguments on NftController's
addNftVerifyOwnership
method, have been replaced with an options object containing optional propertiesnetworkClientId
,userAddress
andsource
. This method signature is more aligned with the options pattern for passingnetworkClientId
anduserAddress
on this controller and elsewhere. - BREAKING:
checkAndUpdateSingleNftOwnershipStatus
on NftController no longer accepts achainId
in its options argument. This is replaced with an optionalnetworkClientId
property which can be used to fetch chainId. *BREAKING: The fourth argument of theisNftOwner
method onNftController
is now an options object with an optionalnetworkClientId
property. This method signature is more aligned with the options pattern for passingnetworkClientId
on this controller and elsewhere. - BREAKING:
validateWatchNft
method onNftController
is now private. - BREAKING:
detectNfts
onNftDetectionController
now accepts a single object argument with optional propertiesnetworkClientId
anduserAddress
, rather than taking these as two sequential arguments.
- Bump dependency
@metamask/eth-query
from ^3.0.1 to ^4.0.0 (#2028) - Bump dependency on
@metamask/polling-controller
to ^1.0.2 - Bump
@metamask/utils
from 8.1.0 to 8.2.0 (#1957)
- Add name and symbol to the payload returned by the
ERC1155Standard
classgetDetails
method forERC1155
contracts (#1727)
- BREAKING:
CurrencyRateController
is now keyed bynativeCurrency
(i.e. ticker) forconversionDate
,conversionRate
, andusdConversionRate
in thecurrencyRates
object.nativeCurrency
,pendingNativeCurrency
, andpendingCurrentCurrency
have been removed.-
export type CurrencyRateState = { currentCurrency: string; currencyRates: Record< string, // nativeCurrency { conversionDate: number | null; conversionRate: number | null; usdConversionRate: number | null; } >; };
-
- BREAKING:
CurrencyRateController
now extendsPollingController
(#1805)start()
andstop()
methods replaced withstartPollingByNetworkClientId()
,stopPollingByPollingToken()
, andstopAllPolling()
- BREAKING:
CurrencyRateController
now sends theNetworkController:getNetworkClientById
action via messaging controller (#1805)
- Parallelize network requests in assets controllers for performance enhancement (#1801)
- Fix token detection on accounts when user changes account after token detection request is inflight (#1848)
- BREAKING: Bump dependency on
@metamask/polling-controller
to ^1.0.0 - Bump dependency and peer dependency on
@metamask/network-controller
to ^15.1.0
- Add way to start and stop different polling sessions for the same network client ID by providing extra scoping data (#1776)
- Add optional second argument to
stopPollingByPollingToken
(formerlystopPollingByNetworkClientId
) - Add optional second argument to
onPollingCompleteByNetworkClientId
- Add optional second argument to
- Add support for token detection for Linea mainnet and Linea Goerli (#1799)
- BREAKING: Bump dependency and peer dependency on
@metamask/network-controller
to ^15.0.0 - BREAKING: Make
executePoll
in TokenListController private (#1810) - BREAKING: Update TokenListController to rename
stopPollingByNetworkClientId
tostopPollingByPollingToken
(#1810) - Add missing dependency on
@metamask/polling-controller
(#1831) - Bump dependency and peer dependency on
@metamask/approval-controller
to ^4.0.1 - Bump dependency and peer dependency on
@metamask/preferences-controller
to ^4.4.3 - Fix support for NFT metadata stored outside IPFS (#1772)
- BREAKING:
NftController
now expectsgetNetworkClientById
in constructor options (#1698) - BREAKING:
NftController.addNft
function signature has changed (#1698)- Previously
now:
address: string, tokenId: string, nftMetadata?: NftMetadata, accountParams?: { userAddress: string; chainId: Hex; }, source = Source.Custom,
tokenAddress: string, tokenId: string, { nftMetadata?: NftMetadata; chainId?: Hex; // extracts from AccountParams userAddress?: string // extracted from AccountParams source?: Source; networkClientId?: NetworkClientId; // new },
- Previously
NftController.addNftVerifyOwnership
: Now accepts optional 3rd argumentnetworkClientId
which is used to fetch NFT metadata and determine by which chainId the added NFT should be stored in state. Also accepts optional 4th argumentsource
used for metrics to identify the flow in which the NFT was added to the wallet. (#1698)NftController.isNftOwner
: Now accepts optionalnetworkClientId
which is used to instantiate the provider for the correct chain and call the NFT contract to verify ownership (#1698)NftController.addNft
will use the chainId value derived fromnetworkClientId
if provided (#1698)NftController.watchNft
options now accepts optionalnetworkClientId
which is used to fetch NFT metadata and determine by which chainId the added NFT should be stored in state (#1698)- Bump dependency on
@metamask/utils
to ^8.1.0 (#1639) - Bump dependency and peer dependency on
@metamask/approval-controller
to ^4.0.0 - Bump dependency on
@metamask/base-controller
to ^3.2.3 - Bump dependency on
@metamask/controller-utils
to ^5.0.2 - Bump dependency and peer dependency on
@metamask/network-controller
to ^14.0.0
- Fix bug in TokensController where batched
addToken
overwrote each other because mutex was acquired after reading state (#1768)
- BREAKING: Remove AbortController polyfill
- This package now assumes that the AbortController global exists
- BREAKING:
TokensController
now expectsgetNetworkClientById
in constructor options (#1676) - BREAKING:
TokensController.addToken
now accepts a single options object (#1676){ address: string; symbol: string; decimals: number; name?: string; image?: string; interactingAddress?: string; networkClientId?: NetworkClientId; }
- BREAKING: Bump peer dependency on
@metamask/network-controller
to ^13.0.0 (#1633) - CHANGED:
TokensController.addToken
will use the chain ID value derived from state fornetworkClientId
if provided (#1676) - CHANGED:
TokensController.addTokens
now accepts an optionalnetworkClientId
as the last parameter (#1676) - CHANGED:
TokensController.addTokens
will use the chain ID value derived from state fornetworkClientId
if provided (#1676) - CHANGED:
TokensController.watchAsset
options now accepts optionalnetworkClientId
which is used to get the ERC-20 token name if provided (#1676) - Bump dependency on
@metamask/controller-utils
to ^5.0.0 (#1633) - Bump dependency on
@metamask/preferences-controller
to ^4.4.1 (#1676)
- Add
AssetsContractController
methodsgetProvider
,getChainId
,getERC721Standard
, andgetERC1155Standard
(#1638)
- BREAKING: Add
getNetworkClientById
toAssetsContractController
constructor options (#1638) - Add optional
networkClientId
parameter to variousAssetContractController
methods (#1638) - The affected methods are:
getERC20BalanceOf
getERC20TokenDecimals
getERC20TokenName
getERC721NftTokenId
getTokenStandardAndDetails
getERC721TokenURI
getERC721AssetName
getERC721AssetSymbol
getERC721OwnerOf
getERC1155TokenURI
getERC1155BalanceOf
transferSingleERC1155
getBalancesInSingleCall
- Bump dependency and peer dependency on
@metamask/approval-controller
to ^3.5.1 - Bump dependency on
@metamask/base-controller
to ^3.2.1 - Bump dependency on
@metamask/controller-utils
to ^4.3.2 - Bump dependency and peer dependency on
@metamask/network-controller
to ^12.1.2 - Bump dependency and peer dependency on
@metamask/preferences-controller
to ^4.4.0 - Update NftController to add fallback for when IPFS gateway is disabled (#1577)
- Replace
eth-query
^2.1.2 with@metamask/eth-query
^3.0.1 (#1546)
- Add a
stop
method to stop polling
- BREAKING: New required constructor parameters for the
TokenRatesController
(#1497, #1511)- The new required parameters are
ticker
,onSelectedAddress
, andonPreferencesStateChange
- The new required parameters are
- BREAKING: Remove
onCurrencyRateStateChange
constructor parameter fromTokenRatesController
(#1496) - BREAKING: Disable
TokenRatesController
automatic polling (#1501)- Polling must be started explicitly by calling the
start
method - The token rates are not updated upon state changes when polling is disabled.
- Polling must be started explicitly by calling the
- BREAKING: Replace the
poll
method withstart
(#1501)- The
start
method does not offer a way to change the interval. That must be done by calling.configure
instead
- The
- BREAKING: Remove
TokenRatecontroller
setter forchainId
andtokens
properties (#1505) - Bump @metamask/abi-utils from 1.2.0 to 2.0.1 (#1525)
- Update
@metamask/utils
to^6.2.0
(#1514) - Remove unnecessary
babel-runtime
dependency (#1504)
- Fix bug where token rates were incorrect after first update if initialized with a non-Ethereum selected network (#1497)
- Fix bug where token rates would be invalid if event handlers were triggered in the wrong order (#1496, #1511)
- Prevent redundant token rate updates (#1512)
- The method
getERC20TokenName
has been added toAssetsContractController
(#1127)- This method gets the token name from the token contract
- BREAKING: The tokens controller now requires
onTokenListStateChange
andgetERC20TokenName
as constructor parameters (#1127)- The
getERC20TokenName
method is used to get the token name for tokens added viawallet_watchAsset
- The
onTokenListStateChange
method is used to trigger a name update when the token list changes. On each change, token names are copied from the token list if they're missing from token controller state.
- The
- BREAKING: The signature of the tokens controller method
addToken
has changed- The fourth and fifth positional parameters (
image
andinteractingAddress
) have been replaced by anoptions
object - The new options parameter includes the
image
andinteractingAddress
properties, and a newname
property
- The fourth and fifth positional parameters (
- The token detection controller now sets the token name when new tokens are detected (#1127)
- The
Token
type now includes an optionalname
field (#1127)
- Add validation that the nft standard matches the type argument of a
wallet_watchAsset
request when type is 'ERC721' or 'ERC1155' (#1455)
- Add a fifth argument,
source
, to NftController'saddNft
method (#1417)- This argument can be used to specify whether the NFT was detected, added manually, or suggested by a dapp
- Fix
watchNft
in NftController to ensure that if the network changes before the user accepts the request, the NFT is added to the chain ID and address before the request was initiated (#1417)
- BREAKING: Add required options
getSelectedAddress
andgetMultiAccountBalancesEnabled
to AccountTrackerController constructor and make use of them when refreshing account balances (#1146)- Previously, the controller would refresh all account balances, but these options can be used to only refresh the currently selected account
- BREAKING: Add logic to support validating and adding ERC721 and ERC1155 tokens to NFTController state via
wallet_watchAsset
API. (#1173, #1406)- The
NFTController
now has a newwatchNFT
method that can be called to send a message to theApprovalController
and prompt the user to add an NFT to their wallet state. - The
NFTController
now requires an instance of a ControllerMessenger to be passed to its constructor. This is messenger is used to pass thewatchNFT
message to theApprovalController
.
- The
- Add dependency on
@ethersproject/address
(#1173) - Replace
eth-rpc-errors
with@metamask/rpc-errors
(#1173)
- Support NFT detection on Ethereum Mainnet custom RPC endpoints (#1360)
- Enable token detection for the Aurora network (#1327)
- BREAKING: Bump to Node 16 (#1262)
- BREAKING: Change format of chain ID in state to 0x-prefixed hex string (#1367)
- The functions
isTokenDetectionSupportedForNetwork
andformatIconUrlWithProxy
now expect a chain ID as typeHex
rather than as a decimalstring
- The assets contract controller now expects the
chainId
configuration entry and constructor parameter as typeHex
rather than decimalstring
- The NFT controller now expects the
chainId
configuration entry and constructor parameter as typeHex
rather than decimalstring
- The NFT controller methods
addNft
,checkAndUpdateSingleNftOwnershipStatus
,findNftByAddressAndTokenId
,updateNft
, andresetNftTransactionStatusByTransactionId
now expect the chain ID to be typeHex
rather than a decimalstring
- The NFT controller state properties
allNftContracts
andallNfts
are now keyed by address andHex
chain ID, rather than by address and decimalstring
chain ID- This requires a state migration
- The NFT detection controller now expects the
chainId
configuration entry and constructor parameter as typeHex
rather than decimalstring
- The token detection controller now expects the
chainId
configuration entry as typeHex
rather than decimalstring
- The token list controller now expects the
chainId
constructor parameter as typeHex
rather than decimalstring
- The token list controller state property
tokensChainsCache
is now keyed byHex
chain ID rather than by decimalstring
chain ID.- This requires a state migration
- The token rates controller now expects the
chainId
configuration entry and constructor parameter as typeHex
rather than decimalstring
- The token rates controller
chainId
setter now expects the chain ID asHex
rather than as a decimal string - The tokens controller now expects the
chainId
configuration entry and constructor parameter as typeHex
rather than decimalstring
- The tokens controller
addDetectedTokens
method now accepts thechainId
property of thedetectionDetails
parameter to be of typeHex
rather than decimalstring
. - The tokens controller state properties
allTokens
,allIgnoredTokens
, andallDetectedTokens
are now keyed by chain ID inHex
format rather than decimalstring
.- This requires a state migration
- The functions
- BREAKING: Use approval controller for suggested assets (#1261, #1268)
- The actions
ApprovalController:acceptRequest
andApprovalController:rejectRequest
are no longer required by the token controller messenger. - The
suggestedAssets
state has been removed, which means that suggested assets are no longer persisted in state - The return type for
watchAsset
has changed. It now returns a Promise that settles after the request has been confirmed or rejected.
- The actions
- BREAKING: Initialize controllers with the current network (#1361)
- The following controllers now have a new
chainId
required constructor parameter:AssetsContractController
NftController
NftDetectionController
TokenRatesController
TokensController
- The following controllers now have a new
- BREAKING: The token list controller messenger requires the
NetworkController:stateChange
event instead of theNetworkController:providerConfigChange
event (#1329) - BREAKING: The token list controller
onNetworkStateChange
option now has a more restrictive type (#1329)- The event handler parameter type has been changed from
NetworkState | ProviderConfig
toNetworkState
- The event handler parameter type has been changed from
- BREAKING: Update the account tracker controller
provider
type (#1266)- The
provider
setter and theprovider
config entry now use ourProvider
type frometh-query
rather thanany
- The
- BREAKING: Update
@metamask/preferences-controller
dependency and add it as a peer dependency (#1393) - BREAKING: Update
@metamask/approval-controller
and@metamask/network-controller
dependencies and peer dependencies - Bump @metamask/abi-utils from 1.1.0 to 1.2.0 (#1287)
- Bump @metamask/utils from 5.0.1 to 5.0.2 (#1271)
- BREAKING: Remove the
networkType
configuration option from the NFT detection controller, NFT controller, and tokens controller (#1360, #1359) - BREAKING: Remove the
SuggestedAssetMeta
andSuggestedAssetMetaBase
types from the token controller (#1268) - BREAKING: Remove the
acceptWatchAsset
andrejectWatchAsset
methods from the token controller (#1268)- Suggested assets can be accepted or rejected using the approval controller instead
- BREAKING: peerDeps: @metamask/network-controller@6.0.0->8.0.0 (#1196)
- BREAKING: Create approval requests using
@metamask/approval-controller
(#1166)
- Support watching assets on a specific account (#1124)
- Update
@metamask/contract-metadata
from 2.1.0 to 2.3.1 (#1141)
- BREAKING: Remove
isomorphic-fetch
(#1106)- Consumers must now import
isomorphic-fetch
or another polyfill themselves if they are running in an environment withoutfetch
- Consumers must now import
- Update Nft Controller to add the NFT back to its own group if we are re-importing it (#1082)
- Add Sepolia support to the currency rate controller (#1041)
- The currency rate controller will now treat Sepolia as a testnet, and return the Mainnet exchange rate when asked for the Sepolia exchange rate.
- BREAKING: Update
@metamask/network-controller
peer dependency to v3 (#1041) - BREAKING: Migrate from
metaswap
tometafi
subdomain for OpenSea proxy and token icons API (#1060) - Rename this repository to
core
(#1031) - Update ERC20Standard to use
@metamask/abi-utils
instead of@ethersproject/abi
(#985) - Update
@metamask/controller-utils
package (#1041)
- BREAKING: Drop support for Ropsten, Rinkeby, and Kovan (#1041)
- The currency rate controller no longer has special handling of these three networks. It used to return the Mainnet exchange rate for these three networks, but now it includes no special handling for them.
- The NFT controller no longer supports the Rinkeby OpenSea test API.
- Export
isTokenDetectionSupportedForNetwork
function (#1034) - Update
@metamask/contract-metadata
from 1.35.0 to 2.1.0 (#1013)
- Fix token controller state updates (#1015)
- Attempts to empty the list of "added", "ignored", or "detected" tokens were not saved in state correctly, resulting in that operation being undone after switching account or network.
- BREAKING: A new private property, controlled by the
start
andstop
methods, is added to the CurrencyRateController:enabled
. When this is false, no network requests will be made from the controller. Previously, setNativeCurrency or setCurrentCurrency would trigger a network request. That is now prevented ifenabled
is false. (#1002)
- The TokenRatesController no longer overwrites the
disabled
config property passed to the constructor, allowing the controller to be instantiated withconfig.disabled
set to either true or false. (#1002) - This package will now warn if a required package is not present (#1003)
- BREAKING: Update
onNetworkStateChange
, a constructor option for several controllers, to take an object with aproviderConfig
property instead ofprovider
(#995)- This affects:
- AssetsContractController
- NftController
- NftDetectionController
- TokenDetectionController
- TokenListController
- TokenRatesController
- TokenController
- This affects:
- BREAKING: [TokenDetectionController] Update
getNetworkState
constructor option to take an object withproviderConfig
property rather thanproviderConfig
(#995) - Relax dependencies on
@metamask/base-controller
,@metamask/controller-utils
,@metamask/network-controller
, and@metamask/preferences-controller
(use^
instead of~
) (#998)
- Fix race condition where some token detections can get mistakenly added to the wrong account (#956)
-
Initial release
-
As a result of converting our shared controllers repo into a monorepo (#831), we've created this package from select parts of
@metamask/controllers
v33.0.0, namely:- Everything in
src/assets
- Asset-related functions from
src/util.ts
and accompanying tests
All changes listed after this point were applied to this package following the monorepo conversion.
- Everything in
-
- Use Ethers for AssetsContractController (#845)