Skip to content
This repository was archived by the owner on Mar 2, 2026. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const flowContext = flow
},
mapMethod,
} = ctx;
consoleLog('flow - use #3 - check approval', mapMethod, origin, name, icon);
consoleLog('flow - use #3 - check approval', mapMethod, origin, name, icon, params);

const [approvalType, condition, { height = 599 } = {}] =
Reflect.getMetadata('APPROVAL', providerController, mapMethod) || [];
Expand Down
14 changes: 9 additions & 5 deletions apps/extension/src/background/controller/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
} from '@onflow/flow-wallet-shared/types/network-types';
import {
type NFTCollectionData,
type NFTCollections,
type CollectionNftList,
} from '@onflow/flow-wallet-shared/types/nft-types';
import { type CategoryScripts } from '@onflow/flow-wallet-shared/types/script-types';
import { type TokenInfo } from '@onflow/flow-wallet-shared/types/token-info';
Expand Down Expand Up @@ -142,8 +142,8 @@ import {
coinListKey,
evmNftCollectionListKey,
type EvmNftCollectionListStore,
evmNftIdsKey,
type EvmNftIdsStore,
evmNftCollectionsIdsKey,
type EvmCollectionNftIdsStore,
getCachedNftCollection,
getCachedScripts,
mainAccountsKey,
Expand Down Expand Up @@ -3271,7 +3271,9 @@ export class WalletController extends BaseController {

getCollectionCache = async (address: string) => {
const network = await this.getNetwork();
const list = await getValidData<NFTCollections[]>(nftCatalogCollectionsKey(network, address));
const list = await getValidData<CollectionNftList[]>(
nftCatalogCollectionsKey(network, address)
);
if (!list || list.length === 0) {
return await this.refreshCollection(address);
}
Expand Down Expand Up @@ -3532,7 +3534,9 @@ export class WalletController extends BaseController {
throw new Error('Invalid Ethereum address');
}
const network = await this.getNetwork();
const cacheData = await getValidData<EvmNftIdsStore>(evmNftIdsKey(network, address));
const cacheData = await getValidData<EvmCollectionNftIdsStore>(
evmNftCollectionsIdsKey(network, address)
);
if (cacheData) {
return cacheData;
}
Expand Down
8 changes: 4 additions & 4 deletions apps/extension/src/core/service/nft-evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { isValidEthereumAddress } from '@onflow/flow-wallet-shared/utils/address
import {
evmNftCollectionListKey,
evmNftCollectionListRefreshRegex,
evmNftIdsKey,
evmNftIdsRefreshRegex,
evmNftCollectionsIdsKey,
evmNftCollectionIdsRefreshRegex,
} from '@/data-model/cache-data-keys';

import { openapiService } from '.';
Expand All @@ -14,7 +14,7 @@ import { fclConfirmNetwork } from '../utils/fclConfig';
class EvmNfts {
init = async () => {
registerRefreshListener(evmNftCollectionListRefreshRegex, this.loadEvmCollectionList);
registerRefreshListener(evmNftIdsRefreshRegex, this.loadEvmNftIds);
registerRefreshListener(evmNftCollectionIdsRefreshRegex, this.loadEvmNftIds);
};

loadEvmNftIds = async (network: string, address: string) => {
Expand All @@ -25,7 +25,7 @@ class EvmNfts {
}
const result = await openapiService.EvmNFTID(network, address);

setCachedData(evmNftIdsKey(network, address), result);
setCachedData(evmNftCollectionsIdsKey(network, address), result);
return result;
};

Expand Down
53 changes: 48 additions & 5 deletions apps/extension/src/core/service/nft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import {
} from '@onflow/flow-wallet-shared/types/network-types';
import {
type NFTCollectionData,
type NFTCollections,
type CollectionNftList,
} from '@onflow/flow-wallet-shared/types/nft-types';

import {
childAccountAllowTypesKey,
childAccountAllowTypesRefreshRegex,
childAccountNftsKey,
childAccountNFTsRefreshRegex,
type ChildAccountNFTsStore,
nftCatalogCollectionsKey,
nftCatalogCollectionsRefreshRegex,
nftCollectionKey,
Expand All @@ -38,7 +39,36 @@ class NFT {
registerRefreshListener(nftListRefreshRegex, this.loadNftList);
};

loadChildAccountNFTs = async (network: string, parentAddress: string) => {
/**
* Gets all accessible NFTs for a specific child account
*
* The getAccessibleChildAccountNFTs script is a comprehensive NFT discovery and inventory function
* that provides a complete view of all NFTs accessible through child accounts.
*
* Parents get a bird's-eye view of all NFTs they can manage across all child accounts
*
* @param network - The network to get the NFTs for
* @param parentAddress - The address of the parent account
* @returns ChildAccountNFTsStore or undefined if the network is switched.
*
* Returns comprehensive inventory: A nested structure showing all NFTs across all child accounts
*
* Example:
* {
* "0x123": {
* "ExampleNFT.NFT": [1, 2, 3, 5, 8],
* "CryptoKitties.Kitty": [42, 1337]
* },
* "0x456": {
* "FlowToken.NFT": [100, 101, 102],
* "ExampleNFT.NFT": [10, 11]
* }
* }
*/
loadChildAccountNFTs = async (
network: string,
parentAddress: string
): Promise<ChildAccountNFTsStore | undefined> => {
if (!(await fclConfirmNetwork(network))) {
// Do nothing if the network is switched
// Don't update the cache
Expand All @@ -56,6 +86,19 @@ class NFT {
return result;
};

/**
* Gets all accessible provider types (NFT and FT) for a specific child account
* The getChildAccountAllowTypes script is a query function that discovers what types of assets a parent account can access within a specific child account. It returns an array of strings containing the type identifiers of all accessible asset types
* What Are "Accessible Provider Types"?
* The "accessible provider types" are the specific token/asset types that the parent can withdraw from the child account. These are represented as type identifiers (strings) that identify:
* - NFT Collections: Like "ExampleNFT.Collection", "FlowToken.NFT", etc.
* - Fungible Token Vaults: Like "FlowToken.Vault", "USDC.Vault", etc.
* This script is crucial for determining what assets a parent can access within a child account.
* @param network - The network to get the allow types for
* @param parentAddress - The address of the parent account
* @param childAddress - The address of the child account
* @returns The allow types for the child account
*/
loadChildAccountAllowTypes = async (
network: string,
parentAddress: string,
Expand All @@ -78,7 +121,7 @@ class NFT {
loadNftCatalogCollections = async (
network: string,
address: string
): Promise<NFTCollections[]> => {
): Promise<CollectionNftList[]> => {
if (!(await fclConfirmNetwork(network))) {
// Do nothing if the network is switched
// Don't update the cache
Expand Down Expand Up @@ -156,8 +199,8 @@ class NFT {
getNftCatalogCollections = async (
network: string,
address: string
): Promise<NFTCollections[] | undefined> => {
const collections = await getValidData<NFTCollections[]>(
): Promise<CollectionNftList[] | undefined> => {
const collections = await getValidData<CollectionNftList[]>(
nftCatalogCollectionsKey(network, address)
);
if (!collections) {
Expand Down
7 changes: 5 additions & 2 deletions apps/extension/src/core/service/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import {
type StorageInfo,
type UserInfoResponse,
} from '@onflow/flow-wallet-shared/types/network-types';
import { type NFTCollections } from '@onflow/flow-wallet-shared/types/nft-types';
import { type CollectionNftList } from '@onflow/flow-wallet-shared/types/nft-types';
import { type NetworkScripts } from '@onflow/flow-wallet-shared/types/script-types';
import type { TokenInfo } from '@onflow/flow-wallet-shared/types/token-info';
import {
Expand Down Expand Up @@ -1590,7 +1590,10 @@ export class OpenApiService {
return data;
};

nftCatalogCollections = async (address: string, network: string): Promise<NFTCollections[]> => {
nftCatalogCollections = async (
address: string,
network: string
): Promise<CollectionNftList[]> => {
const { data } = await this.sendRequest(
'GET',
`/api/v2/nft/id?address=${address}&network=${network}`,
Expand Down
34 changes: 26 additions & 8 deletions apps/extension/src/data-model/cache-data-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import {
type UserInfoResponse,
} from '@onflow/flow-wallet-shared/types/network-types';
import {
type EvmNFTCollectionList,
type EvmNFTIds,
type EvmCollectionNftItemList,
type EvmCollectionNFTList,
type NFTCollectionData,
type NFTCollections,
type CollectionNftList,
} from '@onflow/flow-wallet-shared/types/nft-types';
import { type NetworkScripts } from '@onflow/flow-wallet-shared/types/script-types';
import { type TransferItem } from '@onflow/flow-wallet-shared/types/transaction-types';
Expand Down Expand Up @@ -206,11 +206,20 @@ export const getCachedNftCollection = async (
);
};

export const triggerNftCollectionRefresh = (
network: string,
address: string,
collectionId: string,
offset: number
) => {
triggerRefresh(nftCollectionKey(network, address, collectionId, `${offset}`));
};

export const nftCatalogCollectionsKey = (network: string, address: string) =>
`nft-catalog-collections-${network}-${address}`;

export const nftCatalogCollectionsRefreshRegex = refreshKey(nftCatalogCollectionsKey);
export type NftCatalogCollectionsStore = NFTCollections[];
export type NftCatalogCollectionsStore = CollectionNftList[];

export const getCachedNftCatalogCollections = async (network: string, address: string) => {
return getCachedData<NftCatalogCollectionsStore>(nftCatalogCollectionsKey(network, address));
Expand Down Expand Up @@ -253,11 +262,11 @@ export const getCachedChildAccountNfts = async (network: string, parentAddress:
};

// EVM NFTs
export const evmNftIdsKey = (network: string, address: string) =>
export const evmNftCollectionsIdsKey = (network: string, address: string) =>
`evm-nft-collection-ids-${network}-${address}`;

export const evmNftIdsRefreshRegex = refreshKey(evmNftIdsKey);
export type EvmNftIdsStore = EvmNFTIds[];
export const evmNftCollectionIdsRefreshRegex = refreshKey(evmNftCollectionsIdsKey);
export type EvmCollectionNftIdsStore = EvmCollectionNFTList[];

export const evmNftCollectionListKey = (
network: string,
Expand All @@ -267,7 +276,7 @@ export const evmNftCollectionListKey = (
) => `evm-nft-collection-list-${network}-${address}-${collectionIdentifier}-${offset}`;

export const evmNftCollectionListRefreshRegex = refreshKey(evmNftCollectionListKey);
export type EvmNftCollectionListStore = EvmNFTCollectionList[];
export type EvmNftCollectionListStore = EvmCollectionNftItemList[];

export const getCachedEvmNftCollectionList = async (
network: string,
Expand All @@ -279,6 +288,15 @@ export const getCachedEvmNftCollectionList = async (
evmNftCollectionListKey(network, address, collectionIdentifier, `${offset}`)
);
};

export const triggerEvmNftCollectionRefresh = (
network: string,
address: string,
collectionIdentifier: string,
offset: number
) => {
triggerRefresh(evmNftCollectionListKey(network, address, collectionIdentifier, `${offset}`));
};
/**
* Fungible Token information
*/
Expand Down
6 changes: 6 additions & 0 deletions apps/extension/src/data-model/user-data-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ export type UserWalletStore = {
export const getUserWalletsData = async (): Promise<UserWalletStore | undefined> => {
return await getUserData<UserWalletStore>(userWalletsKey);
};

export const developerModeKey = 'developerMode';
export const getDeveloperModeData = async (): Promise<boolean | undefined> => {
return await getUserData<boolean>(developerModeKey);
};

// Profile Current Account - the user selected account on a given network
export const activeAccountsKey = (network: string, publicKey: string) =>
`active-accounts-${network}-${publicKey}`;
Expand Down
Loading
Loading