Skip to content

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
adonesky1 committed Sep 26, 2023
1 parent 8984f50 commit 4d82178
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export class AssetsContractController extends BaseController<
const provider = networkClientId
? this.getNetworkClientById(networkClientId).provider
: this._provider;

if (provider === undefined) {
throw new Error(MISSING_PROVIDER_ERROR);
}
Expand Down
57 changes: 24 additions & 33 deletions packages/assets-controllers/src/NftController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -641,33 +641,24 @@ export class NftController extends BaseController<NftConfig, NftState> {
/**
* Adds an individual NFT to the stored NFT list.
*
* @param options - options.
* @param options.tokenAddress - Hex address of the NFT contract.
* @param options.tokenId - The NFT identifier.
* @param options.nftMetadata - NFT optional information (name, image and description).
* @param options.nftContract - An object containing contract data of the NFT being added.
* @param options.chainId - The chainId of the network where the NFT is being added.
* @param options.userAddress - The address of the account where the NFT is being added.
* @param options.source - Whether the NFT was detected, added manually or suggested by a dapp.
* @param tokenAddress - Hex address of the NFT contract.
* @param tokenId - The NFT identifier.
* @param nftMetadata - NFT optional information (name, image and description).
* @param nftContract - An object containing contract data of the NFT being added.
* @param chainId - The chainId of the network where the NFT is being added.
* @param userAddress - The address of the account where the NFT is being added.
* @param source - Whether the NFT was detected, added manually or suggested by a dapp.
* @returns Promise resolving to the current NFT list.
*/
private async addIndividualNft({
tokenAddress,
tokenId,
nftMetadata,
nftContract,
chainId,
userAddress,
source,
}: {
tokenAddress: string;
tokenId: string;
nftMetadata: NftMetadata;
nftContract: NftContract;
chainId: Hex;
userAddress: string;
source?: Source;
}): Promise<Nft[]> {
private async addIndividualNft(
tokenAddress: string,
tokenId: string,
nftMetadata: NftMetadata,
nftContract: NftContract,
chainId: Hex,
userAddress: string,
source: Source,
): Promise<Nft[]> {
// TODO: Remove unused return
const releaseLock = await this.mutex.acquire();
try {
Expand Down Expand Up @@ -723,7 +714,7 @@ export class NftController extends BaseController<NftConfig, NftState> {
symbol: nftContract.symbol,
tokenId: tokenId.toString(),
standard: nftMetadata.standard,
source: source ?? Source.Custom,
source,
});
}

Expand Down Expand Up @@ -1290,7 +1281,7 @@ export class NftController extends BaseController<NftConfig, NftState> {
nftMetadata,
chainId, // TODO remove and replace chainId arg with fetch chainId using getNetworkClientById(networkClientId).configuration.chainId once polling refactor is complete
userAddress,
source,
source = Source.Custom,
networkClientId,
}: {
nftMetadata?: NftMetadata;
Expand All @@ -1310,7 +1301,7 @@ export class NftController extends BaseController<NftConfig, NftState> {
chainId: currentChainId,
userAddress: selectedAddress,
networkClientId,
source: source ?? Source.Custom,
source,
});

nftMetadata =
Expand All @@ -1325,15 +1316,15 @@ export class NftController extends BaseController<NftConfig, NftState> {

// If NFT contract information, add individual NFT
if (nftContract) {
await this.addIndividualNft({
await this.addIndividualNft(
tokenAddress,
tokenId,
nftMetadata,
nftContract,
userAddress: selectedAddress,
chainId: currentChainId,
source: source ?? Source.Custom,
});
currentChainId,
selectedAddress,
source,
);
}
}

Expand Down

0 comments on commit 4d82178

Please sign in to comment.