Socket
Socket
Sign inDemoInstall

@metamask/controllers

Package Overview
Dependencies
295
Maintainers
7
Versions
78
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 30.2.0 to 30.3.0

33

dist/assets/CollectiblesController.d.ts

@@ -27,2 +27,3 @@ /// <reference types="node" />

* @property isCurrentlyOwned - Boolean indicating whether the address/chainId combination where it's currently stored currently owns this collectible
* @property transactionId - Transaction Id associated with the collectible
*/

@@ -95,2 +96,3 @@ export interface Collectible extends CollectibleMetadata {

lastSale?: ApiCollectibleLastSale;
transactionId?: string;
}

@@ -378,3 +380,34 @@ interface AccountParams {

updateCollectibleFavoriteStatus(address: string, tokenId: string, favorite: boolean): void;
/**
* Returns the collectible by the address and token id.
*
* @param address - Hex address of the collectible contract.
* @param tokenId - Number that represents the id of the token.
* @param selectedAddress - Hex address of the user account.
* @param chainId - Id of the current network.
* @returns Object containing the Collectible and their position in the array
*/
findCollectibleByAddressAndTokenId(address: string, tokenId: string, selectedAddress: string, chainId: string): {
collectible: Collectible;
index: number;
} | null;
/**
* Update collectible data.
*
* @param collectible - Collectible object to find the right collectible to updates.
* @param updates - Collectible partial object to update properties of the collectible.
* @param selectedAddress - Hex address of the user account.
* @param chainId - Id of the current network.
*/
updateCollectible(collectible: Collectible, updates: Partial<Collectible>, selectedAddress: string, chainId: string): void;
/**
* Resets the transaction status of a collectible.
*
* @param transactionId - Collectible transaction id.
* @param selectedAddress - Hex address of the user account.
* @param chainId - Id of the current network.
* @returns a boolean indicating if the reset was well succeded or not
*/
resetCollectibleTransactionStatusByTransactionId(transactionId: string, selectedAddress: string, chainId: string): boolean;
}
export default CollectiblesController;

@@ -756,2 +756,73 @@ "use strict";

}
/**
* Returns the collectible by the address and token id.
*
* @param address - Hex address of the collectible contract.
* @param tokenId - Number that represents the id of the token.
* @param selectedAddress - Hex address of the user account.
* @param chainId - Id of the current network.
* @returns Object containing the Collectible and their position in the array
*/
findCollectibleByAddressAndTokenId(address, tokenId, selectedAddress, chainId) {
var _a;
const { allCollectibles } = this.state;
const collectibles = ((_a = allCollectibles[selectedAddress]) === null || _a === void 0 ? void 0 : _a[chainId]) || [];
const index = collectibles.findIndex((collectible) => collectible.address.toLowerCase() === address.toLowerCase() &&
collectible.tokenId === tokenId);
if (index === -1) {
return null;
}
return { collectible: collectibles[index], index };
}
/**
* Update collectible data.
*
* @param collectible - Collectible object to find the right collectible to updates.
* @param updates - Collectible partial object to update properties of the collectible.
* @param selectedAddress - Hex address of the user account.
* @param chainId - Id of the current network.
*/
updateCollectible(collectible, updates, selectedAddress, chainId) {
var _a;
const { allCollectibles } = this.state;
const collectibles = ((_a = allCollectibles[selectedAddress]) === null || _a === void 0 ? void 0 : _a[chainId]) || [];
const collectibleInfo = this.findCollectibleByAddressAndTokenId(collectible.address, collectible.tokenId, selectedAddress, chainId);
if (!collectibleInfo) {
return;
}
const updatedCollectible = Object.assign(Object.assign({}, collectible), updates);
// Update Collectibles array
const newCollectibles = [
...collectibles.slice(0, collectibleInfo.index),
updatedCollectible,
...collectibles.slice(collectibleInfo.index + 1),
];
this.updateNestedCollectibleState(newCollectibles, ALL_COLLECTIBLES_STATE_KEY);
}
/**
* Resets the transaction status of a collectible.
*
* @param transactionId - Collectible transaction id.
* @param selectedAddress - Hex address of the user account.
* @param chainId - Id of the current network.
* @returns a boolean indicating if the reset was well succeded or not
*/
resetCollectibleTransactionStatusByTransactionId(transactionId, selectedAddress, chainId) {
var _a;
const { allCollectibles } = this.state;
const collectibles = ((_a = allCollectibles[selectedAddress]) === null || _a === void 0 ? void 0 : _a[chainId]) || [];
const index = collectibles.findIndex((collectible) => collectible.transactionId === transactionId);
if (index === -1) {
return false;
}
const updatedCollectible = Object.assign(Object.assign({}, collectibles[index]), { transactionId: undefined });
// Update Collectibles array
const newCollectibles = [
...collectibles.slice(0, index),
updatedCollectible,
...collectibles.slice(index + 1),
];
this.updateNestedCollectibleState(newCollectibles, ALL_COLLECTIBLES_STATE_KEY);
return true;
}
}

@@ -758,0 +829,0 @@ exports.CollectiblesController = CollectiblesController;

3

dist/index.d.ts
import 'isomorphic-fetch';
import * as util from './util';
import { formatIconUrlWithProxy } from './assets/assetsUtil';
export * from './assets/AccountTrackerController';

@@ -33,2 +34,2 @@ export * from './user/AddressBookController';

export * from './notification/NotificationController';
export { util };
export { util, formatIconUrlWithProxy };

@@ -29,6 +29,8 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.util = exports.getAnonymizedState = exports.getPersistentState = exports.BaseControllerV2 = void 0;
exports.formatIconUrlWithProxy = exports.util = exports.getAnonymizedState = exports.getPersistentState = exports.BaseControllerV2 = void 0;
require("isomorphic-fetch");
const util = __importStar(require("./util"));
exports.util = util;
const assetsUtil_1 = require("./assets/assetsUtil");
Object.defineProperty(exports, "formatIconUrlWithProxy", { enumerable: true, get: function () { return assetsUtil_1.formatIconUrlWithProxy; } });
__exportStar(require("./assets/AccountTrackerController"), exports);

@@ -35,0 +37,0 @@ __exportStar(require("./user/AddressBookController"), exports);

@@ -155,2 +155,9 @@ import { MetaMaskKeyring as QRKeyring, IKeyringState as IQRKeyringState } from '@keystonehq/metamask-airgapped-keyring';

/**
* Method to validate a password against the password from the keyring.
*
* @param password - Password of the keyring.
* @returns Boolean indicating if input password is valid
*/
validatePassword(password: string): boolean;
/**
* Returns the status of the vault.

@@ -157,0 +164,0 @@ *

@@ -210,2 +210,11 @@ "use strict";

/**
* Method to validate a password against the password from the keyring.
*
* @param password - Password of the keyring.
* @returns Boolean indicating if input password is valid
*/
validatePassword(password) {
return __classPrivateFieldGet(this, _KeyringController_keyring, "f").password === password;
}
/**
* Returns the status of the vault.

@@ -225,3 +234,3 @@ *

exportSeedPhrase(password) {
if (__classPrivateFieldGet(this, _KeyringController_keyring, "f").password === password) {
if (this.validatePassword(password)) {
return __classPrivateFieldGet(this, _KeyringController_keyring, "f").keyrings[0].mnemonic;

@@ -239,3 +248,3 @@ }

exportAccount(password, address) {
if (__classPrivateFieldGet(this, _KeyringController_keyring, "f").password === password) {
if (this.validatePassword(password)) {
return __classPrivateFieldGet(this, _KeyringController_keyring, "f").exportAccount(address);

@@ -242,0 +251,0 @@ }

{
"name": "@metamask/controllers",
"version": "30.2.0",
"version": "30.3.0",
"description": "Collection of platform-agnostic modules for creating secure data models for cryptocurrency wallets",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc