@bitsocial/bitsocial-react-hooks 0.1.20 → 0.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## [0.1.22](https://github.com/bitsocialnet/bitsocial-react-hooks/compare/v0.1.21...v0.1.22) (2026-06-25)
2
+
3
+
4
+
5
+ ## [0.1.21](https://github.com/bitsocialnet/bitsocial-react-hooks/compare/v0.1.20...v0.1.21) (2026-06-24)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **accounts:** handle empty account comment lookups ([#65](https://github.com/bitsocialnet/bitsocial-react-hooks/issues/65)) ([eb1bd79](https://github.com/bitsocialnet/bitsocial-react-hooks/commit/eb1bd797180c620eed611cffd879abdb5c793578))
11
+
12
+
13
+
1
14
  ## [0.1.20](https://github.com/bitsocialnet/bitsocial-react-hooks/compare/v0.1.19...v0.1.20) (2026-06-24)
2
15
 
3
16
 
package/README.md CHANGED
@@ -893,6 +893,7 @@ const account = useAccount() // or useAccount('Account 2') to use an account oth
893
893
  // `account.author.wallets` only auto-generates an `eth` wallet by default.
894
894
  // `account.chainProviders` is the canonical chain config for wallets, NFT lookups, and other chain reads.
895
895
  // Defaults use multiple explicit Ethereum RPCs for `.eth` / `.bso` author-name resolution.
896
+ // Defaults use multiple HTTP routers for IPFS/IPNS delegated routing.
896
897
  // `account.nameResolversChainProviders` optionally overrides only the RPCs used for that resolution.
897
898
  console.log(account.author.wallets.eth)
898
899
 
@@ -905,6 +906,15 @@ const ethResolverRpcUrls = [
905
906
  'https://eth-pokt.nodies.app',
906
907
  ]
907
908
 
909
+ const httpRoutersOptions = [
910
+ 'https://peers.pleb.bot',
911
+ 'https://routing.lol',
912
+ 'https://peers.forumindex.com',
913
+ 'https://peers.plebpubsub.xyz',
914
+ 'https://routerofbitsocial.xyz',
915
+ 'https://bsotracker.online',
916
+ ]
917
+
908
918
  const author: {...account.author, displayName: 'John'}
909
919
  const editedAccount = {
910
920
  ...account,
@@ -913,6 +923,10 @@ const editedAccount = {
913
923
  ...account.chainProviders,
914
924
  eth: { urls: [...ethResolverRpcUrls, 'ethers.js'], chainId: 1 },
915
925
  },
926
+ pkcOptions: {
927
+ ...account.pkcOptions,
928
+ httpRoutersOptions,
929
+ },
916
930
  nameResolversChainProviders: {
917
931
  eth: { urls: ethResolverRpcUrls, chainId: 1 },
918
932
  },
@@ -435,7 +435,7 @@ export function useAccountComment(options) {
435
435
  Number.isInteger(normalizedCommentIndex) &&
436
436
  normalizedCommentIndex >= 0
437
437
  ? normalizedCommentIndex
438
- : (commentCidToAccountComment === null || commentCidToAccountComment === void 0 ? void 0 : commentCidToAccountComment.accountId) === accountId
438
+ : commentCidToAccountComment && commentCidToAccountComment.accountId === accountId
439
439
  ? commentCidToAccountComment.accountCommentIndex
440
440
  : undefined;
441
441
  const storedAccountComment = useMemo(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../../src/hooks/accounts/accounts.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AACrD,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAC3D,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,sCAAsC,CAAC,CAAC;AAC3D,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AA8BpE,OAAO,EACL,mCAAmC,EACnC,kCAAkC,EAClC,0BAA0B,GAC3B,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,qCAAqC,EACrC,6BAA6B,GAC9B,MAAM,6BAA6B,CAAC;AACrC,OAAO,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useState, useEffect } from \"react\";\nimport isEqual from \"lodash.isequal\";\nimport useAccountsStore from \"../../stores/accounts\";\nimport useCommunitiesStore from \"../../stores/communities\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:accounts:hooks\");\nimport assert from \"assert\";\nimport { useListCommunities, useCommunities } from \"../communities\";\nimport type {\n AccountComment,\n AccountComments,\n Account,\n Accounts,\n AccountVote,\n AccountsComments,\n AccountsCommentsReplies,\n UseAccountCommunitiesOptions,\n UseAccountCommunitiesResult,\n UseAccountVoteOptions,\n UseAccountVoteResult,\n UseAccountVotesOptions,\n UseAccountVotesResult,\n UseAccountCommentsOptions,\n UseAccountCommentsResult,\n UseAccountCommentOptions,\n UseAccountCommentResult,\n UseNotificationsOptions,\n UseNotificationsResult,\n UseAccountEditsOptions,\n UseAccountEditsResult,\n UseEditedCommentOptions,\n UseEditedCommentResult,\n UseAccountOptions,\n UseAccountResult,\n UsePubsubSubscribeOptions,\n UsePubsubSubscribeResult,\n} from \"../../types\";\nimport {\n useAccountsWithCalculatedProperties,\n useAccountWithCalculatedProperties,\n useCalculatedNotifications,\n} from \"./utils\";\nimport {\n COMMENT_MODERATION_AUTHOR_SUMMARY_KEY,\n getAccountEditPropertySummary,\n} from \"../../stores/accounts/utils\";\nimport {\n getCanonicalCommunityAddress,\n getEquivalentCommunityAddressGroupKey,\n pickPreferredEquivalentCommunityAddress,\n} from \"../../lib/community-address\";\nimport { addCommentModeration } from \"../../lib/utils/comment-moderation\";\nimport useInterval from \"../utils/use-interval\";\nimport PkcJs from \"../../lib/pkc-js\";\n\nconst getCommentEditPropertyValue = (comment: any, propertyName: string) => {\n if (propertyName !== COMMENT_MODERATION_AUTHOR_SUMMARY_KEY) {\n return comment?.[propertyName];\n }\n\n const commentModeration = comment?.commentModeration;\n if (\n commentModeration &&\n typeof commentModeration === \"object\" &&\n Object.prototype.hasOwnProperty.call(commentModeration, \"author\")\n ) {\n return commentModeration.author;\n }\n\n return comment?.author?.community?.banExpiresAt !== undefined\n ? { banExpiresAt: comment.author.community.banExpiresAt }\n : undefined;\n};\n\nconst applyEditedCommentProperty = (comment: any, propertyName: string, value: any) => {\n if (propertyName !== COMMENT_MODERATION_AUTHOR_SUMMARY_KEY) {\n comment[propertyName] = value;\n return;\n }\n\n comment.commentModeration = comment.commentModeration ? { ...comment.commentModeration } : {};\n if (value === undefined) {\n delete comment.commentModeration.author;\n } else {\n comment.commentModeration.author = value;\n }\n\n comment.author = comment.author ? { ...comment.author } : {};\n comment.author.community = comment.author.community ? { ...comment.author.community } : {};\n if (value?.banExpiresAt === undefined) {\n delete comment.author.community.banExpiresAt;\n } else {\n comment.author.community.banExpiresAt = value.banExpiresAt;\n }\n};\n\n/**\n * @param accountName - The nickname of the account, e.g. 'Account 1'. If no accountName is provided, return\n * the active account id.\n */\nexport function useAccountId(accountName?: string) {\n const accountId = useAccountsStore((state) => state.accountNamesToAccountIds[accountName || \"\"]);\n // don't consider active account if account name is defined\n const activeAccountId = useAccountsStore((state) => !accountName && state.activeAccountId);\n const accountIdToUse = accountName ? accountId : activeAccountId;\n return accountIdToUse;\n}\n\n/**\n * @param accountName - The nickname of the account, e.g. 'Account 1'. If no accountName is provided, return\n * the active account.\n */\nexport function useAccount(options?: UseAccountOptions): UseAccountResult {\n assert(\n !options || typeof options === \"object\",\n `useAccount options argument '${options}' not an object`,\n );\n const { accountName } = options || {};\n // get state\n const accountId = useAccountId(accountName);\n const accountStore = useAccountsStore((state) => state.accounts[accountId || \"\"]);\n const accountComments = useAccountsStore((state) => state.accountsComments[accountId || \"\"]);\n const accountCommentsReplies = useAccountsStore(\n (state) => state.accountsCommentsReplies[accountId || \"\"],\n );\n const account = useAccountWithCalculatedProperties(\n accountStore,\n accountComments,\n accountCommentsReplies,\n );\n log(\"useAccount\", { accountId, account, accountName });\n return account;\n}\n\n/**\n * Return all accounts in the order of `accountsStore.accountIds`. To reorder, use `accountsActions.setAccountsOrder(accountNames)`.\n */\nexport function useAccounts() {\n const accountIds = useAccountsStore((state) => state.accountIds);\n const accountsStore = useAccountsStore((state) => state.accounts);\n const accountsComments = useAccountsStore((state) => state.accountsComments);\n const accountsCommentsReplies = useAccountsStore((state) => state.accountsCommentsReplies);\n const accounts = useAccountsWithCalculatedProperties(\n accountsStore,\n accountsComments,\n accountsCommentsReplies,\n );\n const accountsArray: Account[] = useMemo(() => {\n const accountsArray = [];\n if (accountIds?.length && accounts) {\n for (const accountId of accountIds) {\n accountsArray.push(accounts[accountId]);\n }\n }\n return accountsArray;\n }, [accounts, accountIds]);\n\n log(\"useAccounts\", { accounts, accountIds });\n\n const state = accountsArray?.length ? \"succeeded\" : \"initializing\";\n\n return useMemo(\n () => ({\n accounts: accountsArray,\n state,\n error: undefined,\n errors: [],\n }),\n [accountsArray, state],\n );\n}\n\n/**\n * Returns all communities where the account is a creator or moderator\n */\nexport function useAccountCommunities(\n options?: UseAccountCommunitiesOptions,\n): UseAccountCommunitiesResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountCommunities options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { accountName, onlyIfCached } = opts;\n const accountId = useAccountId(accountName);\n const accountIdKey = accountId || \"\";\n const accountsStoreAccountCommunities = useAccountsStore(\n (state) => state.accounts[accountIdKey]?.communities,\n );\n\n // get all unique account community addresses\n const ownerCommunityAddresses = useListCommunities(accountName);\n const groupedCommunityAddresses = useMemo(() => {\n const accountCommunityAddresses = [];\n if (accountsStoreAccountCommunities) {\n for (const communityAddress in accountsStoreAccountCommunities) {\n accountCommunityAddresses.push(communityAddress);\n }\n }\n const allCommunityAddresses = [\n ...new Set([...ownerCommunityAddresses, ...accountCommunityAddresses]),\n ].sort();\n const groupedAddresses = new Map<string, string[]>();\n for (const communityAddress of allCommunityAddresses) {\n const groupKey = getEquivalentCommunityAddressGroupKey(communityAddress);\n const addresses = groupedAddresses.get(groupKey);\n if (addresses) {\n addresses.push(communityAddress);\n } else {\n groupedAddresses.set(groupKey, [communityAddress]);\n }\n }\n return [...groupedAddresses.entries()].map(([groupKey, addresses]) => ({\n groupKey,\n addresses,\n preferredAddress: pickPreferredEquivalentCommunityAddress(addresses),\n }));\n }, [accountsStoreAccountCommunities, ownerCommunityAddresses]);\n const uniqueCommunityAddresses = useMemo(\n () => groupedCommunityAddresses.map(({ preferredAddress }) => preferredAddress),\n [groupedCommunityAddresses],\n );\n\n // fetch all community data\n const {\n communities: communitiesArray,\n state: communitiesState,\n error: communitiesError,\n errors: communitiesErrors,\n } = useCommunities({\n communities: uniqueCommunityAddresses.map((communityAddress) => ({ name: communityAddress })),\n accountName,\n onlyIfCached,\n });\n const communityFetchErrors = useCommunitiesStore((state: any) =>\n uniqueCommunityAddresses.flatMap((communityAddress) => state.errors[communityAddress] || []),\n );\n const canonicalAddressByGroupKey = useMemo(() => {\n const canonicalAddresses: { [groupKey: string]: string } = {};\n for (const [i, { groupKey, preferredAddress }] of groupedCommunityAddresses.entries()) {\n const fetchedAddress = communitiesArray[i]?.address;\n canonicalAddresses[groupKey] = getCanonicalCommunityAddress(\n fetchedAddress || preferredAddress,\n );\n }\n return canonicalAddresses;\n }, [groupedCommunityAddresses, communitiesArray]);\n const communities: any = useMemo(() => {\n const communities: any = {};\n for (const [i, community] of communitiesArray.entries()) {\n const { groupKey, preferredAddress } = groupedCommunityAddresses[i];\n const canonicalAddress = canonicalAddressByGroupKey[groupKey];\n communities[canonicalAddress] = {\n ...communities[canonicalAddress],\n ...community,\n // make sure the canonical address is defined even if the community hasn't fetched yet\n address: canonicalAddress,\n };\n }\n return communities;\n }, [communitiesArray, groupedCommunityAddresses, canonicalAddressByGroupKey]);\n\n // merged community data with account.communities data\n const accountCommunities: any = useMemo(() => {\n const accountCommunities: any = { ...communities };\n if (accountsStoreAccountCommunities) {\n for (const communityAddress in accountsStoreAccountCommunities) {\n const groupKey = getEquivalentCommunityAddressGroupKey(communityAddress);\n const canonicalAddress = canonicalAddressByGroupKey[groupKey];\n accountCommunities[canonicalAddress] = {\n ...accountCommunities[canonicalAddress],\n ...accountsStoreAccountCommunities[communityAddress],\n address: canonicalAddress,\n };\n }\n }\n // add pkc.communities data\n for (const communityAddress of ownerCommunityAddresses) {\n const groupKey = getEquivalentCommunityAddressGroupKey(communityAddress);\n const canonicalAddress = canonicalAddressByGroupKey[groupKey];\n accountCommunities[canonicalAddress] = {\n ...accountCommunities[canonicalAddress],\n address: canonicalAddress,\n role: { role: \"owner\" },\n };\n }\n return accountCommunities;\n }, [\n accountsStoreAccountCommunities,\n ownerCommunityAddresses,\n communities,\n canonicalAddressByGroupKey,\n ]);\n\n if (accountId) {\n log(\"useAccountCommunities\", { accountCommunities });\n }\n\n const pendingAccountCommunities = Object.values(accountCommunities).some(\n (community: any) => community?.address && !community?.updatedAt,\n );\n const errors = communityFetchErrors.length ? communityFetchErrors : communitiesErrors;\n const error = communitiesError || errors[errors.length - 1];\n const state = !accountId\n ? \"initializing\"\n : error\n ? \"failed\"\n : pendingAccountCommunities\n ? \"fetching-ipns\"\n : communitiesState;\n\n return useMemo(\n () => ({\n accountCommunities,\n state,\n error,\n errors,\n }),\n [accountCommunities, state, error, errors],\n );\n}\n\n/**\n * Returns an account's notifications in an array. Unread notifications have a field markedAsRead: false.\n *\n * @param accountName - The nickname of the account, e.g. 'Account 1'. If no accountName is provided, return\n * the active account's notifications.\n */\nexport function useNotifications(options?: UseNotificationsOptions): UseNotificationsResult {\n assert(\n !options || typeof options === \"object\",\n `useNotifications options argument '${options}' not an object`,\n );\n const { accountName } = options || {};\n // get state\n const accountId = useAccountId(accountName);\n const account = useAccountsStore((state) => state.accounts[accountId || \"\"]);\n const accountCommentsReplies = useAccountsStore(\n (state) => state.accountsCommentsReplies[accountId || \"\"],\n );\n const accountsActionsInternal = useAccountsStore((state) => state.accountsActionsInternal);\n const notifications = useCalculatedNotifications(account, accountCommentsReplies);\n const [errors, setErrors] = useState<Error[]>([]);\n\n const markAsRead = async () => {\n try {\n if (!account) {\n throw Error(\"useNotifications cannot mark as read accounts not initalized yet\");\n }\n accountsActionsInternal.markNotificationsAsRead(account);\n } catch (e: any) {\n setErrors([...errors, e]);\n }\n };\n\n if (account) {\n log(\"useNotifications\", { notifications });\n }\n\n const state = accountId ? \"succeeded\" : \"initializing\";\n\n return useMemo(\n () => ({\n notifications,\n markAsRead,\n state,\n error: errors[errors.length - 1],\n errors,\n }),\n [notifications, errors],\n );\n}\n\nconst getAccountCommentsStates = (accountComments: AccountComment[]) => {\n // Without a cid, the account comment is still a local pending publish. pkc-js marks\n // terminal publish failures when `publishingState === \"failed\"` and publication `state`\n // is `\"stopped\"`, so we derive failed from that terminal pair or recorded publish errors.\n const now = Math.round(Date.now() / 1000);\n const expiryTime = now - 60 * 20;\n\n const states: string[] = [];\n for (const accountComment of accountComments) {\n let state = \"succeeded\";\n if (!accountComment.cid) {\n const ac = accountComment as AccountComment & {\n error?: Error;\n errors?: Error[];\n publishingState?: string;\n state?: string;\n };\n const resolvedPublishFailed =\n (ac.publishingState === \"failed\" && ac.state === \"stopped\") ||\n ac.error != null ||\n (Array.isArray(ac.errors) && ac.errors.length > 0);\n\n if (resolvedPublishFailed) {\n state = \"failed\";\n } else if (accountComment.timestamp > expiryTime) {\n state = \"pending\";\n } else {\n state = \"failed\";\n }\n }\n states.push(state);\n }\n\n return states;\n};\n\nexport const haveAccountCommentStatesChanged = (nextStates: string[], previousStates: string[]) =>\n nextStates.toString() !== previousStates.toString();\n\nconst getAccountHistorySortType = (\n sortType?: \"new\" | \"old\",\n order?: \"asc\" | \"desc\",\n): \"new\" | \"old\" => {\n if (sortType === \"new\" || sortType === \"old\") {\n return sortType;\n }\n return order === \"desc\" ? \"new\" : \"old\";\n};\n\nconst getAccountCommentWithAccountAuthor = (\n accountComment: AccountComment,\n account?: Account,\n accountId?: string,\n): AccountComment => {\n const accountAuthor = account?.author;\n if (\n !accountId ||\n accountComment.accountId !== accountId ||\n !accountAuthor?.address ||\n accountComment.author?.address\n ) {\n return accountComment;\n }\n\n const accountShortAddress =\n accountAuthor.shortAddress || PkcJs.PKC.getShortAddress({ address: accountAuthor.address });\n\n return {\n ...accountComment,\n author: {\n ...accountAuthor,\n ...accountComment.author,\n address: accountAuthor.address,\n ...(accountShortAddress ? { shortAddress: accountShortAddress } : {}),\n },\n };\n};\n\nexport function useAccountComments(options?: UseAccountCommentsOptions): UseAccountCommentsResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountComments options argument '${options}' not an object`,\n );\n const {\n accountName,\n filter,\n commentCid,\n commentIndices,\n communityAddress,\n parentCid,\n newerThan,\n page,\n pageSize,\n sortType,\n order,\n } = options || {};\n assert(\n !filter || typeof filter === \"function\",\n `useAccountComments options.filter argument '${filter}' not an function`,\n );\n const accountId = useAccountId(accountName);\n const accountCommentsIndexes = useAccountsStore(\n (state) => state.accountsCommentsIndexes[accountId || \"\"],\n );\n const commentCidToAccountComment = useAccountsStore(\n (state) => state.commentCidsToAccountsComments[commentCid || \"\"],\n );\n const account = useAccountsStore((state) => state.accounts[accountId || \"\"]);\n const accountComments = useAccountsStore((state) => state.accountsComments[accountId || \"\"]);\n const [accountCommentStates, setAccountCommentStates] = useState<string[]>([]);\n const accountHistorySortType = getAccountHistorySortType(sortType, order);\n\n const filteredAccountComments = useMemo(() => {\n if (!accountComments) {\n return [];\n }\n\n let scopedAccountComments = accountComments;\n if (Array.isArray(commentIndices) && commentIndices.length > 0) {\n const normalizedCommentIndices = commentIndices\n .map((commentIndex) => Number(commentIndex))\n .filter((commentIndex) => Number.isInteger(commentIndex) && commentIndex >= 0);\n scopedAccountComments = normalizedCommentIndices\n .map((commentIndex) => accountComments[commentIndex])\n .filter(Boolean);\n } else if (commentCid) {\n const mappedIndex =\n commentCidToAccountComment?.accountId === accountId\n ? commentCidToAccountComment.accountCommentIndex\n : undefined;\n scopedAccountComments =\n typeof mappedIndex === \"number\" ? [accountComments[mappedIndex]].filter(Boolean) : [];\n } else if (parentCid) {\n const parentIndexes = accountCommentsIndexes?.byParentCid?.[parentCid];\n scopedAccountComments = parentIndexes?.length\n ? parentIndexes.map((index) => accountComments[index]).filter(Boolean)\n : accountComments.filter((accountComment) => accountComment.parentCid === parentCid);\n } else if (communityAddress) {\n const communityIndexes = accountCommentsIndexes?.byCommunityAddress?.[communityAddress];\n scopedAccountComments = communityIndexes?.length\n ? communityIndexes.map((index) => accountComments[index]).filter(Boolean)\n : accountComments.filter(\n (accountComment) => accountComment.communityAddress === communityAddress,\n );\n }\n\n if (typeof newerThan === \"number\") {\n const newerThanTimestamp =\n newerThan === Infinity ? 0 : Math.floor(Date.now() / 1000) - newerThan;\n scopedAccountComments = scopedAccountComments.filter(\n (accountComment) => accountComment.timestamp > newerThanTimestamp,\n );\n }\n if (filter) {\n scopedAccountComments = scopedAccountComments.filter(filter);\n }\n if (accountHistorySortType === \"new\") {\n scopedAccountComments = [...scopedAccountComments].reverse();\n }\n if (typeof pageSize === \"number\" && pageSize > 0) {\n const pageNumber = Math.max(page || 0, 0);\n const startIndex = pageNumber * pageSize;\n return scopedAccountComments.slice(startIndex, startIndex + pageSize);\n }\n return scopedAccountComments;\n }, [\n accountComments,\n accountCommentsIndexes,\n accountId,\n commentCid,\n commentIndices,\n commentCidToAccountComment,\n communityAddress,\n filter,\n newerThan,\n accountHistorySortType,\n page,\n pageSize,\n parentCid,\n ]);\n\n // Recheck periodically so the 20-minute “stale pending → failed” transition updates without other store events\n const delay = 60_000;\n const immediate = false;\n useInterval(\n () => {\n const states = getAccountCommentsStates(filteredAccountComments);\n if (haveAccountCommentStatesChanged(states, accountCommentStates)) {\n setAccountCommentStates(states);\n }\n },\n delay,\n immediate,\n );\n\n const filteredAccountCommentsWithStates = useMemo(() => {\n const states = getAccountCommentsStates(filteredAccountComments);\n return filteredAccountComments.map((comment, i) => ({\n ...getAccountCommentWithAccountAuthor(comment, account, accountId || undefined),\n state: states[i],\n }));\n }, [filteredAccountComments, accountCommentStates, account, accountId]);\n\n if (options) {\n log(\"useAccountComments\", {\n accountId,\n filteredAccountCommentsWithStates,\n accountComments,\n commentCid,\n commentIndices,\n communityAddress,\n filter,\n newerThan,\n sortType: accountHistorySortType,\n page,\n pageSize,\n parentCid,\n });\n }\n\n const state = accountId ? \"succeeded\" : \"initializing\";\n\n return useMemo(\n () => ({\n accountComments: filteredAccountCommentsWithStates,\n state,\n error: undefined,\n errors: [],\n }),\n [filteredAccountCommentsWithStates, state],\n );\n}\n\n/**\n * Returns an account's single comment, e.g. a pending comment they published.\n */\nexport function useAccountComment(options?: UseAccountCommentOptions): UseAccountCommentResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountComment options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { commentIndex, commentCid, accountName } = opts;\n const accountId = useAccountId(accountName);\n const commentCidToAccountComment = useAccountsStore(\n (state) => state.commentCidsToAccountsComments[commentCid || \"\"],\n );\n const account = useAccountsStore((state) => state.accounts[accountId || \"\"]);\n const accountComments = useAccountsStore((state) => state.accountsComments[accountId || \"\"]);\n const normalizedCommentIndex = commentIndex === undefined ? undefined : Number(commentIndex);\n const resolvedCommentIndex =\n typeof normalizedCommentIndex === \"number\" &&\n Number.isInteger(normalizedCommentIndex) &&\n normalizedCommentIndex >= 0\n ? normalizedCommentIndex\n : commentCidToAccountComment?.accountId === accountId\n ? commentCidToAccountComment.accountCommentIndex\n : undefined;\n const storedAccountComment = useMemo(() => {\n if (typeof resolvedCommentIndex !== \"number\") {\n return undefined;\n }\n return accountComments?.[resolvedCommentIndex];\n }, [accountComments, resolvedCommentIndex]);\n const state = storedAccountComment\n ? getAccountCommentsStates([storedAccountComment])[0]\n : \"initializing\";\n\n return useMemo(() => {\n const accountComment = (\n storedAccountComment\n ? getAccountCommentWithAccountAuthor(storedAccountComment, account, accountId || undefined)\n : {}\n ) as Partial<AccountComment> & {\n error?: Error;\n errors?: Error[];\n };\n return {\n ...accountComment,\n state,\n error: accountComment.error,\n errors: accountComment.errors || [],\n } as UseAccountCommentResult;\n }, [storedAccountComment, account, accountId, state]);\n}\n\n/**\n * Returns the own user's votes stored locally, even those not yet published by the community owner.\n * Check UseAccountCommentsOptions type in types.tsx to filter them, e.g. filter = {communityAddresses: ['memes.eth']}.\n */\nexport function useAccountVotes(options?: UseAccountVotesOptions): UseAccountVotesResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountVotes options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const {\n accountName,\n filter,\n vote,\n commentCid,\n communityAddress,\n newerThan,\n page,\n pageSize,\n sortType,\n order,\n } = opts;\n assert(\n !filter || typeof filter === \"function\",\n `useAccountVotes options.filter argument '${filter}' not an function`,\n );\n const accountId = useAccountId(accountName);\n const accountVotes = useAccountsStore((state) => state.accountsVotes[accountId || \"\"]);\n const accountHistorySortType = getAccountHistorySortType(sortType, order);\n\n const filteredAccountVotesArray = useMemo(() => {\n let accountVotesArray: AccountVote[] = [];\n if (!accountVotes) {\n return accountVotesArray;\n }\n for (const i in accountVotes) {\n accountVotesArray.push(accountVotes[i]);\n }\n if (typeof vote === \"number\") {\n accountVotesArray = accountVotesArray.filter((accountVote) => accountVote.vote === vote);\n }\n if (commentCid) {\n accountVotesArray = accountVotesArray.filter(\n (accountVote) => accountVote.commentCid === commentCid,\n );\n }\n if (communityAddress) {\n accountVotesArray = accountVotesArray.filter(\n (accountVote) => accountVote.communityAddress === communityAddress,\n );\n }\n if (typeof newerThan === \"number\") {\n const newerThanTimestamp =\n newerThan === Infinity ? 0 : Math.floor(Date.now() / 1000) - newerThan;\n accountVotesArray = accountVotesArray.filter(\n (accountVote) => accountVote.timestamp > newerThanTimestamp,\n );\n }\n if (filter) {\n accountVotesArray = accountVotesArray.filter(filter);\n }\n accountVotesArray = [...accountVotesArray].sort(\n (firstVote, secondVote) => (firstVote.timestamp || 0) - (secondVote.timestamp || 0),\n );\n if (accountHistorySortType === \"new\") {\n accountVotesArray = [...accountVotesArray].reverse();\n }\n if (typeof pageSize === \"number\" && pageSize > 0) {\n const pageNumber = Math.max(page || 0, 0);\n const startIndex = pageNumber * pageSize;\n accountVotesArray = accountVotesArray.slice(startIndex, startIndex + pageSize);\n }\n return accountVotesArray;\n }, [\n accountVotes,\n accountHistorySortType,\n commentCid,\n communityAddress,\n filter,\n newerThan,\n page,\n pageSize,\n vote,\n ]);\n\n if (accountVotes && options) {\n log(\"useAccountVotes\", {\n accountId,\n filteredAccountVotesArray,\n accountVotes,\n commentCid,\n communityAddress,\n filter,\n newerThan,\n sortType: accountHistorySortType,\n page,\n pageSize,\n vote,\n });\n }\n\n // TODO: add failed / pending states\n\n const state = accountId ? \"succeeded\" : \"initializing\";\n\n return useMemo(\n () => ({\n accountVotes: filteredAccountVotesArray,\n state,\n error: undefined,\n errors: [],\n }),\n [filteredAccountVotesArray, state],\n );\n}\n\n/**\n * Returns an account's single vote on a comment, e.g. to know if you already voted on a comment.\n */\nexport function useAccountVote(options?: UseAccountVoteOptions): UseAccountVoteResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountVote options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { commentCid, accountName } = opts;\n const accountId = useAccountId(accountName);\n const accountIdKey = accountId || \"\";\n const commentCidKey = commentCid || \"\";\n const accountVotes = useAccountsStore((state) => state.accountsVotes[accountIdKey]);\n const accountVote: any = accountVotes?.[commentCidKey];\n const state = accountId && commentCid ? \"succeeded\" : \"initializing\";\n\n // TODO: add failed / pending state\n\n return useMemo(\n () => ({\n ...accountVote,\n state,\n error: undefined,\n errors: [],\n }),\n [accountVote, state],\n );\n}\n\n/**\n * Returns all the comment and community edits published by an account.\n */\nexport function useAccountEdits(options?: UseAccountEditsOptions): UseAccountEditsResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountEdits options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { filter, accountName } = opts;\n assert(\n !filter || typeof filter === \"function\",\n `useAccountEdits options.filter argument '${filter}' not an function`,\n );\n const accountId = useAccountId(accountName);\n const ensureAccountEditsLoaded = useAccountsStore(\n (state) => state.accountsActionsInternal.ensureAccountEditsLoaded,\n );\n const accountEdits = useAccountsStore((state) => state.accountsEdits[accountId || \"\"]);\n const accountEditsLoaded = useAccountsStore(\n (state) => state.accountsEditsLoaded[accountId || \"\"],\n );\n\n useEffect(() => {\n if (!accountId || accountEditsLoaded) {\n return;\n }\n ensureAccountEditsLoaded(accountId).catch((error: unknown) =>\n log.error(\"useAccountEdits ensureAccountEditsLoaded error\", { accountId, error }),\n );\n }, [accountEditsLoaded, accountId, ensureAccountEditsLoaded]);\n\n const accountEditsArray = useMemo(() => {\n const accountEditsArray = [];\n for (const i in accountEdits || {}) {\n accountEditsArray.push(...accountEdits[i]);\n }\n // sort by oldest first\n return accountEditsArray.sort((a, b) => a.timestamp - b.timestamp);\n }, [accountEdits]);\n\n const filteredAccountEditsArray = useMemo(() => {\n if (!filter) {\n return accountEditsArray;\n }\n return accountEditsArray.filter(filter);\n }, [accountEditsArray, filter]);\n\n // TODO: add failed / pending states\n\n const state = accountId ? (accountEditsLoaded ? \"succeeded\" : \"initializing\") : \"initializing\";\n\n return useMemo(\n () => ({\n accountEdits: filteredAccountEditsArray,\n state,\n error: undefined,\n errors: [],\n }),\n [filteredAccountEditsArray, state],\n );\n}\n\n/**\n * Returns the comment edited (if has any edits), as well as the pending, succeeded or failed state of the edit.\n */\nexport function useEditedComment(options?: UseEditedCommentOptions): UseEditedCommentResult {\n assert(\n !options || typeof options === \"object\",\n `useEditedComment options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { comment, accountName } = opts;\n const accountId = useAccountId(accountName);\n const accountIdKey = accountId || \"\";\n const commentCidKey = (comment && comment.cid) || \"\";\n const commentEdits = useAccountsStore(\n (state) => state.accountsEdits[accountIdKey]?.[commentCidKey],\n );\n const commentEditSummary = useAccountsStore(\n (state) => state.accountsEditsSummaries[accountIdKey]?.[commentCidKey],\n );\n\n let initialState = \"initializing\";\n if (accountId && comment && comment.cid) {\n initialState = \"unedited\";\n }\n\n const editedResult = useMemo(() => {\n const editedResult: any = {\n editedComment: undefined,\n succeededEdits: {},\n pendingEdits: {},\n failedEdits: {},\n state: undefined,\n };\n\n // there are no edits\n const propertyNameEdits: any =\n commentEdits?.length > 0 ? getAccountEditPropertySummary(commentEdits) : commentEditSummary;\n\n if (!propertyNameEdits || Object.keys(propertyNameEdits).length === 0) {\n return editedResult;\n }\n\n const now = Math.round(Date.now() / 1000);\n // no longer consider an edit pending ater an expiry time of 20 minutes\n const expiryTime = 60 * 20;\n\n // iterate over propertyNameEdits and find if succeeded, pending or failed\n for (const propertyName in propertyNameEdits) {\n const propertyNameEdit = propertyNameEdits[propertyName];\n\n const setPropertyNameEditState = (state: \"succeeded\" | \"pending\" | \"failed\") => {\n // set propertyNameEdit e.g. editedResult.succeededEdits.removed = true\n editedResult[`${state}Edits`][propertyName] = propertyNameEdit.value;\n\n // if any propertyNameEdit failed, consider the commentEdit failed\n if (state === \"failed\") {\n editedResult.state = \"failed\";\n }\n // if all propertyNameEdit succeeded, consider the commentEdit succeeded\n if (state === \"succeeded\" && !editedResult.state) {\n editedResult.state = \"succeeded\";\n }\n // if any propertyNameEdit are pending, and none have failed, consider the commentEdit pending\n if (state === \"pending\" && editedResult.state !== \"failed\") {\n editedResult.state = \"pending\";\n }\n };\n\n // Without a newer update we can only treat recent edits as pending. Older edits that never\n // produced any update are effectively stale and should stop shadowing the live comment.\n if (!comment?.updatedAt) {\n if (isEqual(getCommentEditPropertyValue(comment, propertyName), propertyNameEdit.value)) {\n setPropertyNameEditState(\"succeeded\");\n } else if (propertyNameEdit.timestamp > now - expiryTime) {\n setPropertyNameEditState(\"pending\");\n } else {\n setPropertyNameEditState(\"failed\");\n }\n continue;\n }\n\n // comment.updatedAt is older than propertyNameEdit, propertyNameEdit is pending\n // because we haven't received the update yet and can't evaluate\n if (comment.updatedAt < propertyNameEdit.timestamp) {\n setPropertyNameEditState(\"pending\");\n continue;\n }\n\n // comment.updatedAt is newer than propertyNameEdit, a comment update\n // has been received after the edit was published so we can evaluate\n else {\n // comment has propertyNameEdit, propertyNameEdit succeeded\n if (isEqual(getCommentEditPropertyValue(comment, propertyName), propertyNameEdit.value)) {\n setPropertyNameEditState(\"succeeded\");\n continue;\n }\n\n // comment does not have propertyNameEdit\n else {\n // propertyNameEdit is newer than 20min, it is too recent to evaluate\n // so we should assume pending\n if (propertyNameEdit.timestamp > now - expiryTime) {\n setPropertyNameEditState(\"pending\");\n continue;\n }\n\n // propertyNameEdit is older than 20min, we can evaluate it\n else {\n // comment update was received too shortly after propertyNameEdit was\n // published, assume pending until a more recent comment update is received\n const timeSinceUpdate = comment.updatedAt - propertyNameEdit.timestamp;\n if (timeSinceUpdate < expiryTime) {\n setPropertyNameEditState(\"pending\");\n continue;\n }\n\n // comment update time is sufficiently distanced from propertyNameEdit\n // and comment doesn't have propertyNameEdit, assume failed\n else {\n setPropertyNameEditState(\"failed\");\n continue;\n }\n }\n }\n }\n }\n\n // define editedComment\n editedResult.editedComment = { ...comment };\n // add pending and succeeded props so the editor can see his changes right away\n // don't add failed edits to reflect the current state of the edited comment\n for (const propertyName in editedResult.pendingEdits) {\n applyEditedCommentProperty(\n editedResult.editedComment,\n propertyName,\n editedResult.pendingEdits[propertyName],\n );\n }\n for (const propertyName in editedResult.succeededEdits) {\n applyEditedCommentProperty(\n editedResult.editedComment,\n propertyName,\n editedResult.succeededEdits[propertyName],\n );\n }\n editedResult.editedComment = addCommentModeration(editedResult.editedComment);\n\n return editedResult;\n }, [comment, commentEditSummary, commentEdits]);\n\n return useMemo(\n () => ({\n ...editedResult,\n state: editedResult.state || initialState,\n error: undefined,\n errors: [],\n }),\n [editedResult, initialState],\n );\n}\n\n/**\n * This hook should be added to pages where the user is likely to publish something, i,e. the\n * submit page and the /c/<commentCid> page, it improves the speed of publishing to the pubsub\n * by subscribing to the pubsub right away.\n *\n * @param accountName - The nickname of the account, e.g. 'Account 1'.\n * @param communityAddress - The community address to subscribe to, e.g. 'news.eth'.\n */\nexport function usePubsubSubscribe(options?: UsePubsubSubscribeOptions): UsePubsubSubscribeResult {\n assert(\n !options || typeof options === \"object\",\n `usePubsubSubscribe options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { accountName, communityAddress } = opts;\n const accountId = useAccountId(accountName);\n const accountIdKey = accountId || \"\";\n const account = useAccountsStore((state) => state.accounts[accountIdKey]);\n const [state, setState] = useState(\"initializing\");\n const [errors, setErrors] = useState<Error[]>([]);\n\n useEffect(() => {\n if (!account?.pkc || !communityAddress) {\n return;\n }\n setState(\"subscribing\");\n account.pkc\n .pubsubSubscribe(communityAddress)\n .then(() => setState(\"succeeded\"))\n .catch((error: any) => {\n setErrors([...errors, error]);\n setState(\"failed\");\n log.error(\"usePubsubSubscribe pkc.pubsubSubscribe error\", { communityAddress, error });\n });\n\n // unsub on component unmount\n return function () {\n account.pkc.pubsubUnsubscribe(communityAddress).catch((error: any) => {\n setErrors([...errors, error]);\n log.error(\"usePubsubSubscribe pkc.pubsubUnsubscribe error\", {\n communityAddress,\n error,\n });\n });\n };\n }, [account?.pkc, communityAddress]);\n\n return useMemo(\n () => ({\n state,\n error: errors[errors.length - 1],\n errors,\n }),\n [state, errors],\n );\n}\n"]}
1
+ {"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../../src/hooks/accounts/accounts.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AACrD,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAC3D,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,sCAAsC,CAAC,CAAC;AAC3D,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AA8BpE,OAAO,EACL,mCAAmC,EACnC,kCAAkC,EAClC,0BAA0B,GAC3B,MAAM,SAAS,CAAC;AACjB,OAAO,EACL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ChB,CAAC;AACJ,CAAC","sourcesContent":["import { useMemo, useState, useEffect } from \"react\";\nimport isEqual from \"lodash.isequal\";\nimport useAccountsStore from \"../../stores/accounts\";\nimport useCommunitiesStore from \"../../stores/communities\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:accounts:hooks\");\nimport assert from \"assert\";\nimport { useListCommunities, useCommunities } from \"../communities\";\nimport type {\n AccountComment,\n AccountComments,\n Account,\n Accounts,\n AccountVote,\n AccountsComments,\n AccountsCommentsReplies,\n UseAccountCommunitiesOptions,\n UseAccountCommunitiesResult,\n UseAccountVoteOptions,\n UseAccountVoteResult,\n UseAccountVotesOptions,\n UseAccountVotesResult,\n UseAccountCommentsOptions,\n UseAccountCommentsResult,\n UseAccountCommentOptions,\n UseAccountCommentResult,\n UseNotificationsOptions,\n UseNotificationsResult,\n UseAccountEditsOptions,\n UseAccountEditsResult,\n UseEditedCommentOptions,\n UseEditedCommentResult,\n UseAccountOptions,\n UseAccountResult,\n UsePubsubSubscribeOptions,\n UsePubsubSubscribeResult,\n} from \"../../types\";\nimport {\n useAccountsWithCalculatedProperties,\n useAccountWithCalculatedProperties,\n useCalculatedNotifications,\n} from \"./utils\";\nimport {\n COMMENT_MODERATION_AUTHOR_SUMMARY_KEY,\n getAccountEditPropertySummary,\n} from \"../../stores/accounts/utils\";\nimport {\n getCanonicalCommunityAddress,\n getEquivalentCommunityAddressGroupKey,\n pickPreferredEquivalentCommunityAddress,\n} from \"../../lib/community-address\";\nimport { addCommentModeration } from \"../../lib/utils/comment-moderation\";\nimport useInterval from \"../utils/use-interval\";\nimport PkcJs from \"../../lib/pkc-js\";\n\nconst getCommentEditPropertyValue = (comment: any, propertyName: string) => {\n if (propertyName !== COMMENT_MODERATION_AUTHOR_SUMMARY_KEY) {\n return comment?.[propertyName];\n }\n\n const commentModeration = comment?.commentModeration;\n if (\n commentModeration &&\n typeof commentModeration === \"object\" &&\n Object.prototype.hasOwnProperty.call(commentModeration, \"author\")\n ) {\n return commentModeration.author;\n }\n\n return comment?.author?.community?.banExpiresAt !== undefined\n ? { banExpiresAt: comment.author.community.banExpiresAt }\n : undefined;\n};\n\nconst applyEditedCommentProperty = (comment: any, propertyName: string, value: any) => {\n if (propertyName !== COMMENT_MODERATION_AUTHOR_SUMMARY_KEY) {\n comment[propertyName] = value;\n return;\n }\n\n comment.commentModeration = comment.commentModeration ? { ...comment.commentModeration } : {};\n if (value === undefined) {\n delete comment.commentModeration.author;\n } else {\n comment.commentModeration.author = value;\n }\n\n comment.author = comment.author ? { ...comment.author } : {};\n comment.author.community = comment.author.community ? { ...comment.author.community } : {};\n if (value?.banExpiresAt === undefined) {\n delete comment.author.community.banExpiresAt;\n } else {\n comment.author.community.banExpiresAt = value.banExpiresAt;\n }\n};\n\n/**\n * @param accountName - The nickname of the account, e.g. 'Account 1'. If no accountName is provided, return\n * the active account id.\n */\nexport function useAccountId(accountName?: string) {\n const accountId = useAccountsStore((state) => state.accountNamesToAccountIds[accountName || \"\"]);\n // don't consider active account if account name is defined\n const activeAccountId = useAccountsStore((state) => !accountName && state.activeAccountId);\n const accountIdToUse = accountName ? accountId : activeAccountId;\n return accountIdToUse;\n}\n\n/**\n * @param accountName - The nickname of the account, e.g. 'Account 1'. If no accountName is provided, return\n * the active account.\n */\nexport function useAccount(options?: UseAccountOptions): UseAccountResult {\n assert(\n !options || typeof options === \"object\",\n `useAccount options argument '${options}' not an object`,\n );\n const { accountName } = options || {};\n // get state\n const accountId = useAccountId(accountName);\n const accountStore = useAccountsStore((state) => state.accounts[accountId || \"\"]);\n const accountComments = useAccountsStore((state) => state.accountsComments[accountId || \"\"]);\n const accountCommentsReplies = useAccountsStore(\n (state) => state.accountsCommentsReplies[accountId || \"\"],\n );\n const account = useAccountWithCalculatedProperties(\n accountStore,\n accountComments,\n accountCommentsReplies,\n );\n log(\"useAccount\", { accountId, account, accountName });\n return account;\n}\n\n/**\n * Return all accounts in the order of `accountsStore.accountIds`. To reorder, use `accountsActions.setAccountsOrder(accountNames)`.\n */\nexport function useAccounts() {\n const accountIds = useAccountsStore((state) => state.accountIds);\n const accountsStore = useAccountsStore((state) => state.accounts);\n const accountsComments = useAccountsStore((state) => state.accountsComments);\n const accountsCommentsReplies = useAccountsStore((state) => state.accountsCommentsReplies);\n const accounts = useAccountsWithCalculatedProperties(\n accountsStore,\n accountsComments,\n accountsCommentsReplies,\n );\n const accountsArray: Account[] = useMemo(() => {\n const accountsArray = [];\n if (accountIds?.length && accounts) {\n for (const accountId of accountIds) {\n accountsArray.push(accounts[accountId]);\n }\n }\n return accountsArray;\n }, [accounts, accountIds]);\n\n log(\"useAccounts\", { accounts, accountIds });\n\n const state = accountsArray?.length ? \"succeeded\" : \"initializing\";\n\n return useMemo(\n () => ({\n accounts: accountsArray,\n state,\n error: undefined,\n errors: [],\n }),\n [accountsArray, state],\n );\n}\n\n/**\n * Returns all communities where the account is a creator or moderator\n */\nexport function useAccountCommunities(\n options?: UseAccountCommunitiesOptions,\n): UseAccountCommunitiesResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountCommunities options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { accountName, onlyIfCached } = opts;\n const accountId = useAccountId(accountName);\n const accountIdKey = accountId || \"\";\n const accountsStoreAccountCommunities = useAccountsStore(\n (state) => state.accounts[accountIdKey]?.communities,\n );\n\n // get all unique account community addresses\n const ownerCommunityAddresses = useListCommunities(accountName);\n const groupedCommunityAddresses = useMemo(() => {\n const accountCommunityAddresses = [];\n if (accountsStoreAccountCommunities) {\n for (const communityAddress in accountsStoreAccountCommunities) {\n accountCommunityAddresses.push(communityAddress);\n }\n }\n const allCommunityAddresses = [\n ...new Set([...ownerCommunityAddresses, ...accountCommunityAddresses]),\n ].sort();\n const groupedAddresses = new Map<string, string[]>();\n for (const communityAddress of allCommunityAddresses) {\n const groupKey = getEquivalentCommunityAddressGroupKey(communityAddress);\n const addresses = groupedAddresses.get(groupKey);\n if (addresses) {\n addresses.push(communityAddress);\n } else {\n groupedAddresses.set(groupKey, [communityAddress]);\n }\n }\n return [...groupedAddresses.entries()].map(([groupKey, addresses]) => ({\n groupKey,\n addresses,\n preferredAddress: pickPreferredEquivalentCommunityAddress(addresses),\n }));\n }, [accountsStoreAccountCommunities, ownerCommunityAddresses]);\n const uniqueCommunityAddresses = useMemo(\n () => groupedCommunityAddresses.map(({ preferredAddress }) => preferredAddress),\n [groupedCommunityAddresses],\n );\n\n // fetch all community data\n const {\n communities: communitiesArray,\n state: communitiesState,\n error: communitiesError,\n errors: communitiesErrors,\n } = useCommunities({\n communities: uniqueCommunityAddresses.map((communityAddress) => ({ name: communityAddress })),\n accountName,\n onlyIfCached,\n });\n const communityFetchErrors = useCommunitiesStore((state: any) =>\n uniqueCommunityAddresses.flatMap((communityAddress) => state.errors[communityAddress] || []),\n );\n const canonicalAddressByGroupKey = useMemo(() => {\n const canonicalAddresses: { [groupKey: string]: string } = {};\n for (const [i, { groupKey, preferredAddress }] of groupedCommunityAddresses.entries()) {\n const fetchedAddress = communitiesArray[i]?.address;\n canonicalAddresses[groupKey] = getCanonicalCommunityAddress(\n fetchedAddress || preferredAddress,\n );\n }\n return canonicalAddresses;\n }, [groupedCommunityAddresses, communitiesArray]);\n const communities: any = useMemo(() => {\n const communities: any = {};\n for (const [i, community] of communitiesArray.entries()) {\n const { groupKey, preferredAddress } = groupedCommunityAddresses[i];\n const canonicalAddress = canonicalAddressByGroupKey[groupKey];\n communities[canonicalAddress] = {\n ...communities[canonicalAddress],\n ...community,\n // make sure the canonical address is defined even if the community hasn't fetched yet\n address: canonicalAddress,\n };\n }\n return communities;\n }, [communitiesArray, groupedCommunityAddresses, canonicalAddressByGroupKey]);\n\n // merged community data with account.communities data\n const accountCommunities: any = useMemo(() => {\n const accountCommunities: any = { ...communities };\n if (accountsStoreAccountCommunities) {\n for (const communityAddress in accountsStoreAccountCommunities) {\n const groupKey = getEquivalentCommunityAddressGroupKey(communityAddress);\n const canonicalAddress = canonicalAddressByGroupKey[groupKey];\n accountCommunities[canonicalAddress] = {\n ...accountCommunities[canonicalAddress],\n ...accountsStoreAccountCommunities[communityAddress],\n address: canonicalAddress,\n };\n }\n }\n // add pkc.communities data\n for (const communityAddress of ownerCommunityAddresses) {\n const groupKey = getEquivalentCommunityAddressGroupKey(communityAddress);\n const canonicalAddress = canonicalAddressByGroupKey[groupKey];\n accountCommunities[canonicalAddress] = {\n ...accountCommunities[canonicalAddress],\n address: canonicalAddress,\n role: { role: \"owner\" },\n };\n }\n return accountCommunities;\n }, [\n accountsStoreAccountCommunities,\n ownerCommunityAddresses,\n communities,\n canonicalAddressByGroupKey,\n ]);\n\n if (accountId) {\n log(\"useAccountCommunities\", { accountCommunities });\n }\n\n const pendingAccountCommunities = Object.values(accountCommunities).some(\n (community: any) => community?.address && !community?.updatedAt,\n );\n const errors = communityFetchErrors.length ? communityFetchErrors : communitiesErrors;\n const error = communitiesError || errors[errors.length - 1];\n const state = !accountId\n ? \"initializing\"\n : error\n ? \"failed\"\n : pendingAccountCommunities\n ? \"fetching-ipns\"\n : communitiesState;\n\n return useMemo(\n () => ({\n accountCommunities,\n state,\n error,\n errors,\n }),\n [accountCommunities, state, error, errors],\n );\n}\n\n/**\n * Returns an account's notifications in an array. Unread notifications have a field markedAsRead: false.\n *\n * @param accountName - The nickname of the account, e.g. 'Account 1'. If no accountName is provided, return\n * the active account's notifications.\n */\nexport function useNotifications(options?: UseNotificationsOptions): UseNotificationsResult {\n assert(\n !options || typeof options === \"object\",\n `useNotifications options argument '${options}' not an object`,\n );\n const { accountName } = options || {};\n // get state\n const accountId = useAccountId(accountName);\n const account = useAccountsStore((state) => state.accounts[accountId || \"\"]);\n const accountCommentsReplies = useAccountsStore(\n (state) => state.accountsCommentsReplies[accountId || \"\"],\n );\n const accountsActionsInternal = useAccountsStore((state) => state.accountsActionsInternal);\n const notifications = useCalculatedNotifications(account, accountCommentsReplies);\n const [errors, setErrors] = useState<Error[]>([]);\n\n const markAsRead = async () => {\n try {\n if (!account) {\n throw Error(\"useNotifications cannot mark as read accounts not initalized yet\");\n }\n accountsActionsInternal.markNotificationsAsRead(account);\n } catch (e: any) {\n setErrors([...errors, e]);\n }\n };\n\n if (account) {\n log(\"useNotifications\", { notifications });\n }\n\n const state = accountId ? \"succeeded\" : \"initializing\";\n\n return useMemo(\n () => ({\n notifications,\n markAsRead,\n state,\n error: errors[errors.length - 1],\n errors,\n }),\n [notifications, errors],\n );\n}\n\nconst getAccountCommentsStates = (accountComments: AccountComment[]) => {\n // Without a cid, the account comment is still a local pending publish. pkc-js marks\n // terminal publish failures when `publishingState === \"failed\"` and publication `state`\n // is `\"stopped\"`, so we derive failed from that terminal pair or recorded publish errors.\n const now = Math.round(Date.now() / 1000);\n const expiryTime = now - 60 * 20;\n\n const states: string[] = [];\n for (const accountComment of accountComments) {\n let state = \"succeeded\";\n if (!accountComment.cid) {\n const ac = accountComment as AccountComment & {\n error?: Error;\n errors?: Error[];\n publishingState?: string;\n state?: string;\n };\n const resolvedPublishFailed =\n (ac.publishingState === \"failed\" && ac.state === \"stopped\") ||\n ac.error != null ||\n (Array.isArray(ac.errors) && ac.errors.length > 0);\n\n if (resolvedPublishFailed) {\n state = \"failed\";\n } else if (accountComment.timestamp > expiryTime) {\n state = \"pending\";\n } else {\n state = \"failed\";\n }\n }\n states.push(state);\n }\n\n return states;\n};\n\nexport const haveAccountCommentStatesChanged = (nextStates: string[], previousStates: string[]) =>\n nextStates.toString() !== previousStates.toString();\n\nconst getAccountHistorySortType = (\n sortType?: \"new\" | \"old\",\n order?: \"asc\" | \"desc\",\n): \"new\" | \"old\" => {\n if (sortType === \"new\" || sortType === \"old\") {\n return sortType;\n }\n return order === \"desc\" ? \"new\" : \"old\";\n};\n\nconst getAccountCommentWithAccountAuthor = (\n accountComment: AccountComment,\n account?: Account,\n accountId?: string,\n): AccountComment => {\n const accountAuthor = account?.author;\n if (\n !accountId ||\n accountComment.accountId !== accountId ||\n !accountAuthor?.address ||\n accountComment.author?.address\n ) {\n return accountComment;\n }\n\n const accountShortAddress =\n accountAuthor.shortAddress || PkcJs.PKC.getShortAddress({ address: accountAuthor.address });\n\n return {\n ...accountComment,\n author: {\n ...accountAuthor,\n ...accountComment.author,\n address: accountAuthor.address,\n ...(accountShortAddress ? { shortAddress: accountShortAddress } : {}),\n },\n };\n};\n\nexport function useAccountComments(options?: UseAccountCommentsOptions): UseAccountCommentsResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountComments options argument '${options}' not an object`,\n );\n const {\n accountName,\n filter,\n commentCid,\n commentIndices,\n communityAddress,\n parentCid,\n newerThan,\n page,\n pageSize,\n sortType,\n order,\n } = options || {};\n assert(\n !filter || typeof filter === \"function\",\n `useAccountComments options.filter argument '${filter}' not an function`,\n );\n const accountId = useAccountId(accountName);\n const accountCommentsIndexes = useAccountsStore(\n (state) => state.accountsCommentsIndexes[accountId || \"\"],\n );\n const commentCidToAccountComment = useAccountsStore(\n (state) => state.commentCidsToAccountsComments[commentCid || \"\"],\n );\n const account = useAccountsStore((state) => state.accounts[accountId || \"\"]);\n const accountComments = useAccountsStore((state) => state.accountsComments[accountId || \"\"]);\n const [accountCommentStates, setAccountCommentStates] = useState<string[]>([]);\n const accountHistorySortType = getAccountHistorySortType(sortType, order);\n\n const filteredAccountComments = useMemo(() => {\n if (!accountComments) {\n return [];\n }\n\n let scopedAccountComments = accountComments;\n if (Array.isArray(commentIndices) && commentIndices.length > 0) {\n const normalizedCommentIndices = commentIndices\n .map((commentIndex) => Number(commentIndex))\n .filter((commentIndex) => Number.isInteger(commentIndex) && commentIndex >= 0);\n scopedAccountComments = normalizedCommentIndices\n .map((commentIndex) => accountComments[commentIndex])\n .filter(Boolean);\n } else if (commentCid) {\n const mappedIndex =\n commentCidToAccountComment?.accountId === accountId\n ? commentCidToAccountComment.accountCommentIndex\n : undefined;\n scopedAccountComments =\n typeof mappedIndex === \"number\" ? [accountComments[mappedIndex]].filter(Boolean) : [];\n } else if (parentCid) {\n const parentIndexes = accountCommentsIndexes?.byParentCid?.[parentCid];\n scopedAccountComments = parentIndexes?.length\n ? parentIndexes.map((index) => accountComments[index]).filter(Boolean)\n : accountComments.filter((accountComment) => accountComment.parentCid === parentCid);\n } else if (communityAddress) {\n const communityIndexes = accountCommentsIndexes?.byCommunityAddress?.[communityAddress];\n scopedAccountComments = communityIndexes?.length\n ? communityIndexes.map((index) => accountComments[index]).filter(Boolean)\n : accountComments.filter(\n (accountComment) => accountComment.communityAddress === communityAddress,\n );\n }\n\n if (typeof newerThan === \"number\") {\n const newerThanTimestamp =\n newerThan === Infinity ? 0 : Math.floor(Date.now() / 1000) - newerThan;\n scopedAccountComments = scopedAccountComments.filter(\n (accountComment) => accountComment.timestamp > newerThanTimestamp,\n );\n }\n if (filter) {\n scopedAccountComments = scopedAccountComments.filter(filter);\n }\n if (accountHistorySortType === \"new\") {\n scopedAccountComments = [...scopedAccountComments].reverse();\n }\n if (typeof pageSize === \"number\" && pageSize > 0) {\n const pageNumber = Math.max(page || 0, 0);\n const startIndex = pageNumber * pageSize;\n return scopedAccountComments.slice(startIndex, startIndex + pageSize);\n }\n return scopedAccountComments;\n }, [\n accountComments,\n accountCommentsIndexes,\n accountId,\n commentCid,\n commentIndices,\n commentCidToAccountComment,\n communityAddress,\n filter,\n newerThan,\n accountHistorySortType,\n page,\n pageSize,\n parentCid,\n ]);\n\n // Recheck periodically so the 20-minute “stale pending → failed” transition updates without other store events\n const delay = 60_000;\n const immediate = false;\n useInterval(\n () => {\n const states = getAccountCommentsStates(filteredAccountComments);\n if (haveAccountCommentStatesChanged(states, accountCommentStates)) {\n setAccountCommentStates(states);\n }\n },\n delay,\n immediate,\n );\n\n const filteredAccountCommentsWithStates = useMemo(() => {\n const states = getAccountCommentsStates(filteredAccountComments);\n return filteredAccountComments.map((comment, i) => ({\n ...getAccountCommentWithAccountAuthor(comment, account, accountId || undefined),\n state: states[i],\n }));\n }, [filteredAccountComments, accountCommentStates, account, accountId]);\n\n if (options) {\n log(\"useAccountComments\", {\n accountId,\n filteredAccountCommentsWithStates,\n accountComments,\n commentCid,\n commentIndices,\n communityAddress,\n filter,\n newerThan,\n sortType: accountHistorySortType,\n page,\n pageSize,\n parentCid,\n });\n }\n\n const state = accountId ? \"succeeded\" : \"initializing\";\n\n return useMemo(\n () => ({\n accountComments: filteredAccountCommentsWithStates,\n state,\n error: undefined,\n errors: [],\n }),\n [filteredAccountCommentsWithStates, state],\n );\n}\n\n/**\n * Returns an account's single comment, e.g. a pending comment they published.\n */\nexport function useAccountComment(options?: UseAccountCommentOptions): UseAccountCommentResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountComment options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { commentIndex, commentCid, accountName } = opts;\n const accountId = useAccountId(accountName);\n const commentCidToAccountComment = useAccountsStore(\n (state) => state.commentCidsToAccountsComments[commentCid || \"\"],\n );\n const account = useAccountsStore((state) => state.accounts[accountId || \"\"]);\n const accountComments = useAccountsStore((state) => state.accountsComments[accountId || \"\"]);\n const normalizedCommentIndex = commentIndex === undefined ? undefined : Number(commentIndex);\n const resolvedCommentIndex =\n typeof normalizedCommentIndex === \"number\" &&\n Number.isInteger(normalizedCommentIndex) &&\n normalizedCommentIndex >= 0\n ? normalizedCommentIndex\n : commentCidToAccountComment && commentCidToAccountComment.accountId === accountId\n ? commentCidToAccountComment.accountCommentIndex\n : undefined;\n const storedAccountComment = useMemo(() => {\n if (typeof resolvedCommentIndex !== \"number\") {\n return undefined;\n }\n return accountComments?.[resolvedCommentIndex];\n }, [accountComments, resolvedCommentIndex]);\n const state = storedAccountComment\n ? getAccountCommentsStates([storedAccountComment])[0]\n : \"initializing\";\n\n return useMemo(() => {\n const accountComment = (\n storedAccountComment\n ? getAccountCommentWithAccountAuthor(storedAccountComment, account, accountId || undefined)\n : {}\n ) as Partial<AccountComment> & {\n error?: Error;\n errors?: Error[];\n };\n return {\n ...accountComment,\n state,\n error: accountComment.error,\n errors: accountComment.errors || [],\n } as UseAccountCommentResult;\n }, [storedAccountComment, account, accountId, state]);\n}\n\n/**\n * Returns the own user's votes stored locally, even those not yet published by the community owner.\n * Check UseAccountCommentsOptions type in types.tsx to filter them, e.g. filter = {communityAddresses: ['memes.eth']}.\n */\nexport function useAccountVotes(options?: UseAccountVotesOptions): UseAccountVotesResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountVotes options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const {\n accountName,\n filter,\n vote,\n commentCid,\n communityAddress,\n newerThan,\n page,\n pageSize,\n sortType,\n order,\n } = opts;\n assert(\n !filter || typeof filter === \"function\",\n `useAccountVotes options.filter argument '${filter}' not an function`,\n );\n const accountId = useAccountId(accountName);\n const accountVotes = useAccountsStore((state) => state.accountsVotes[accountId || \"\"]);\n const accountHistorySortType = getAccountHistorySortType(sortType, order);\n\n const filteredAccountVotesArray = useMemo(() => {\n let accountVotesArray: AccountVote[] = [];\n if (!accountVotes) {\n return accountVotesArray;\n }\n for (const i in accountVotes) {\n accountVotesArray.push(accountVotes[i]);\n }\n if (typeof vote === \"number\") {\n accountVotesArray = accountVotesArray.filter((accountVote) => accountVote.vote === vote);\n }\n if (commentCid) {\n accountVotesArray = accountVotesArray.filter(\n (accountVote) => accountVote.commentCid === commentCid,\n );\n }\n if (communityAddress) {\n accountVotesArray = accountVotesArray.filter(\n (accountVote) => accountVote.communityAddress === communityAddress,\n );\n }\n if (typeof newerThan === \"number\") {\n const newerThanTimestamp =\n newerThan === Infinity ? 0 : Math.floor(Date.now() / 1000) - newerThan;\n accountVotesArray = accountVotesArray.filter(\n (accountVote) => accountVote.timestamp > newerThanTimestamp,\n );\n }\n if (filter) {\n accountVotesArray = accountVotesArray.filter(filter);\n }\n accountVotesArray = [...accountVotesArray].sort(\n (firstVote, secondVote) => (firstVote.timestamp || 0) - (secondVote.timestamp || 0),\n );\n if (accountHistorySortType === \"new\") {\n accountVotesArray = [...accountVotesArray].reverse();\n }\n if (typeof pageSize === \"number\" && pageSize > 0) {\n const pageNumber = Math.max(page || 0, 0);\n const startIndex = pageNumber * pageSize;\n accountVotesArray = accountVotesArray.slice(startIndex, startIndex + pageSize);\n }\n return accountVotesArray;\n }, [\n accountVotes,\n accountHistorySortType,\n commentCid,\n communityAddress,\n filter,\n newerThan,\n page,\n pageSize,\n vote,\n ]);\n\n if (accountVotes && options) {\n log(\"useAccountVotes\", {\n accountId,\n filteredAccountVotesArray,\n accountVotes,\n commentCid,\n communityAddress,\n filter,\n newerThan,\n sortType: accountHistorySortType,\n page,\n pageSize,\n vote,\n });\n }\n\n // TODO: add failed / pending states\n\n const state = accountId ? \"succeeded\" : \"initializing\";\n\n return useMemo(\n () => ({\n accountVotes: filteredAccountVotesArray,\n state,\n error: undefined,\n errors: [],\n }),\n [filteredAccountVotesArray, state],\n );\n}\n\n/**\n * Returns an account's single vote on a comment, e.g. to know if you already voted on a comment.\n */\nexport function useAccountVote(options?: UseAccountVoteOptions): UseAccountVoteResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountVote options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { commentCid, accountName } = opts;\n const accountId = useAccountId(accountName);\n const accountIdKey = accountId || \"\";\n const commentCidKey = commentCid || \"\";\n const accountVotes = useAccountsStore((state) => state.accountsVotes[accountIdKey]);\n const accountVote: any = accountVotes?.[commentCidKey];\n const state = accountId && commentCid ? \"succeeded\" : \"initializing\";\n\n // TODO: add failed / pending state\n\n return useMemo(\n () => ({\n ...accountVote,\n state,\n error: undefined,\n errors: [],\n }),\n [accountVote, state],\n );\n}\n\n/**\n * Returns all the comment and community edits published by an account.\n */\nexport function useAccountEdits(options?: UseAccountEditsOptions): UseAccountEditsResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountEdits options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { filter, accountName } = opts;\n assert(\n !filter || typeof filter === \"function\",\n `useAccountEdits options.filter argument '${filter}' not an function`,\n );\n const accountId = useAccountId(accountName);\n const ensureAccountEditsLoaded = useAccountsStore(\n (state) => state.accountsActionsInternal.ensureAccountEditsLoaded,\n );\n const accountEdits = useAccountsStore((state) => state.accountsEdits[accountId || \"\"]);\n const accountEditsLoaded = useAccountsStore(\n (state) => state.accountsEditsLoaded[accountId || \"\"],\n );\n\n useEffect(() => {\n if (!accountId || accountEditsLoaded) {\n return;\n }\n ensureAccountEditsLoaded(accountId).catch((error: unknown) =>\n log.error(\"useAccountEdits ensureAccountEditsLoaded error\", { accountId, error }),\n );\n }, [accountEditsLoaded, accountId, ensureAccountEditsLoaded]);\n\n const accountEditsArray = useMemo(() => {\n const accountEditsArray = [];\n for (const i in accountEdits || {}) {\n accountEditsArray.push(...accountEdits[i]);\n }\n // sort by oldest first\n return accountEditsArray.sort((a, b) => a.timestamp - b.timestamp);\n }, [accountEdits]);\n\n const filteredAccountEditsArray = useMemo(() => {\n if (!filter) {\n return accountEditsArray;\n }\n return accountEditsArray.filter(filter);\n }, [accountEditsArray, filter]);\n\n // TODO: add failed / pending states\n\n const state = accountId ? (accountEditsLoaded ? \"succeeded\" : \"initializing\") : \"initializing\";\n\n return useMemo(\n () => ({\n accountEdits: filteredAccountEditsArray,\n state,\n error: undefined,\n errors: [],\n }),\n [filteredAccountEditsArray, state],\n );\n}\n\n/**\n * Returns the comment edited (if has any edits), as well as the pending, succeeded or failed state of the edit.\n */\nexport function useEditedComment(options?: UseEditedCommentOptions): UseEditedCommentResult {\n assert(\n !options || typeof options === \"object\",\n `useEditedComment options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { comment, accountName } = opts;\n const accountId = useAccountId(accountName);\n const accountIdKey = accountId || \"\";\n const commentCidKey = (comment && comment.cid) || \"\";\n const commentEdits = useAccountsStore(\n (state) => state.accountsEdits[accountIdKey]?.[commentCidKey],\n );\n const commentEditSummary = useAccountsStore(\n (state) => state.accountsEditsSummaries[accountIdKey]?.[commentCidKey],\n );\n\n let initialState = \"initializing\";\n if (accountId && comment && comment.cid) {\n initialState = \"unedited\";\n }\n\n const editedResult = useMemo(() => {\n const editedResult: any = {\n editedComment: undefined,\n succeededEdits: {},\n pendingEdits: {},\n failedEdits: {},\n state: undefined,\n };\n\n // there are no edits\n const propertyNameEdits: any =\n commentEdits?.length > 0 ? getAccountEditPropertySummary(commentEdits) : commentEditSummary;\n\n if (!propertyNameEdits || Object.keys(propertyNameEdits).length === 0) {\n return editedResult;\n }\n\n const now = Math.round(Date.now() / 1000);\n // no longer consider an edit pending ater an expiry time of 20 minutes\n const expiryTime = 60 * 20;\n\n // iterate over propertyNameEdits and find if succeeded, pending or failed\n for (const propertyName in propertyNameEdits) {\n const propertyNameEdit = propertyNameEdits[propertyName];\n\n const setPropertyNameEditState = (state: \"succeeded\" | \"pending\" | \"failed\") => {\n // set propertyNameEdit e.g. editedResult.succeededEdits.removed = true\n editedResult[`${state}Edits`][propertyName] = propertyNameEdit.value;\n\n // if any propertyNameEdit failed, consider the commentEdit failed\n if (state === \"failed\") {\n editedResult.state = \"failed\";\n }\n // if all propertyNameEdit succeeded, consider the commentEdit succeeded\n if (state === \"succeeded\" && !editedResult.state) {\n editedResult.state = \"succeeded\";\n }\n // if any propertyNameEdit are pending, and none have failed, consider the commentEdit pending\n if (state === \"pending\" && editedResult.state !== \"failed\") {\n editedResult.state = \"pending\";\n }\n };\n\n // Without a newer update we can only treat recent edits as pending. Older edits that never\n // produced any update are effectively stale and should stop shadowing the live comment.\n if (!comment?.updatedAt) {\n if (isEqual(getCommentEditPropertyValue(comment, propertyName), propertyNameEdit.value)) {\n setPropertyNameEditState(\"succeeded\");\n } else if (propertyNameEdit.timestamp > now - expiryTime) {\n setPropertyNameEditState(\"pending\");\n } else {\n setPropertyNameEditState(\"failed\");\n }\n continue;\n }\n\n // comment.updatedAt is older than propertyNameEdit, propertyNameEdit is pending\n // because we haven't received the update yet and can't evaluate\n if (comment.updatedAt < propertyNameEdit.timestamp) {\n setPropertyNameEditState(\"pending\");\n continue;\n }\n\n // comment.updatedAt is newer than propertyNameEdit, a comment update\n // has been received after the edit was published so we can evaluate\n else {\n // comment has propertyNameEdit, propertyNameEdit succeeded\n if (isEqual(getCommentEditPropertyValue(comment, propertyName), propertyNameEdit.value)) {\n setPropertyNameEditState(\"succeeded\");\n continue;\n }\n\n // comment does not have propertyNameEdit\n else {\n // propertyNameEdit is newer than 20min, it is too recent to evaluate\n // so we should assume pending\n if (propertyNameEdit.timestamp > now - expiryTime) {\n setPropertyNameEditState(\"pending\");\n continue;\n }\n\n // propertyNameEdit is older than 20min, we can evaluate it\n else {\n // comment update was received too shortly after propertyNameEdit was\n // published, assume pending until a more recent comment update is received\n const timeSinceUpdate = comment.updatedAt - propertyNameEdit.timestamp;\n if (timeSinceUpdate < expiryTime) {\n setPropertyNameEditState(\"pending\");\n continue;\n }\n\n // comment update time is sufficiently distanced from propertyNameEdit\n // and comment doesn't have propertyNameEdit, assume failed\n else {\n setPropertyNameEditState(\"failed\");\n continue;\n }\n }\n }\n }\n }\n\n // define editedComment\n editedResult.editedComment = { ...comment };\n // add pending and succeeded props so the editor can see his changes right away\n // don't add failed edits to reflect the current state of the edited comment\n for (const propertyName in editedResult.pendingEdits) {\n applyEditedCommentProperty(\n editedResult.editedComment,\n propertyName,\n editedResult.pendingEdits[propertyName],\n );\n }\n for (const propertyName in editedResult.succeededEdits) {\n applyEditedCommentProperty(\n editedResult.editedComment,\n propertyName,\n editedResult.succeededEdits[propertyName],\n );\n }\n editedResult.editedComment = addCommentModeration(editedResult.editedComment);\n\n return editedResult;\n }, [comment, commentEditSummary, commentEdits]);\n\n return useMemo(\n () => ({\n ...editedResult,\n state: editedResult.state || initialState,\n error: undefined,\n errors: [],\n }),\n [editedResult, initialState],\n );\n}\n\n/**\n * This hook should be added to pages where the user is likely to publish something, i,e. the\n * submit page and the /c/<commentCid> page, it improves the speed of publishing to the pubsub\n * by subscribing to the pubsub right away.\n *\n * @param accountName - The nickname of the account, e.g. 'Account 1'.\n * @param communityAddress - The community address to subscribe to, e.g. 'news.eth'.\n */\nexport function usePubsubSubscribe(options?: UsePubsubSubscribeOptions): UsePubsubSubscribeResult {\n assert(\n !options || typeof options === \"object\",\n `usePubsubSubscribe options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { accountName, communityAddress } = opts;\n const accountId = useAccountId(accountName);\n const accountIdKey = accountId || \"\";\n const account = useAccountsStore((state) => state.accounts[accountIdKey]);\n const [state, setState] = useState(\"initializing\");\n const [errors, setErrors] = useState<Error[]>([]);\n\n useEffect(() => {\n if (!account?.pkc || !communityAddress) {\n return;\n }\n setState(\"subscribing\");\n account.pkc\n .pubsubSubscribe(communityAddress)\n .then(() => setState(\"succeeded\"))\n .catch((error: any) => {\n setErrors([...errors, error]);\n setState(\"failed\");\n log.error(\"usePubsubSubscribe pkc.pubsubSubscribe error\", { communityAddress, error });\n });\n\n // unsub on component unmount\n return function () {\n account.pkc.pubsubUnsubscribe(communityAddress).catch((error: any) => {\n setErrors([...errors, error]);\n log.error(\"usePubsubSubscribe pkc.pubsubUnsubscribe error\", {\n communityAddress,\n error,\n });\n });\n };\n }, [account?.pkc, communityAddress]);\n\n return useMemo(\n () => ({\n state,\n error: errors[errors.length - 1],\n errors,\n }),\n [state, errors],\n );\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { AccountCommunity, ChainProviders } from "../../types.js";
2
2
  export declare const DEFAULT_ETH_RPC_URL = "https://ethereum-rpc.publicnode.com";
3
3
  export declare const DEFAULT_ETH_RPC_URLS: string[];
4
+ export declare const DEFAULT_HTTP_ROUTER_URLS: string[];
4
5
  export declare const overwritePkcOptions: {
5
6
  resolveAuthorNames: boolean;
6
7
  resolveAuthorAddresses: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"account-generator.d.ts","sourceRoot":"","sources":["../../../src/stores/accounts/account-generator.ts"],"names":[],"mappings":"AAKA,OAAO,EAAY,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AASzE,eAAO,MAAM,mBAAmB,wCAAwC,CAAC;AACzE,eAAO,MAAM,oBAAoB,UAOhC,CAAC;AAgBF,eAAO,MAAM,mBAAmB;;;;CAI/B,CAAC;AAqBF,eAAO,MAAM,wBAAwB,QAQd,cACtB,CAAC;AAGF,eAAO,MAAM,oBAAoB;;;CAoChC,CAAC;AAuFF,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGrB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"account-generator.d.ts","sourceRoot":"","sources":["../../../src/stores/accounts/account-generator.ts"],"names":[],"mappings":"AAKA,OAAO,EAAY,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AASzE,eAAO,MAAM,mBAAmB,wCAAwC,CAAC;AACzE,eAAO,MAAM,oBAAoB,UAOhC,CAAC;AACF,eAAO,MAAM,wBAAwB,UAOpC,CAAC;AAgBF,eAAO,MAAM,mBAAmB;;;;CAI/B,CAAC;AAqBF,eAAO,MAAM,wBAAwB,QAQd,cACtB,CAAC;AAGF,eAAO,MAAM,oBAAoB;;;CA+BhC,CAAC;AAuFF,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGrB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -24,6 +24,14 @@ export const DEFAULT_ETH_RPC_URLS = [
24
24
  "https://1rpc.io/eth",
25
25
  "https://eth-pokt.nodies.app",
26
26
  ];
27
+ export const DEFAULT_HTTP_ROUTER_URLS = [
28
+ "https://peers.pleb.bot",
29
+ "https://routing.lol",
30
+ "https://peers.forumindex.com",
31
+ "https://peers.plebpubsub.xyz",
32
+ "https://routerofbitsocial.xyz",
33
+ "https://bsotracker.online",
34
+ ];
27
35
  // default chain providers
28
36
  const chainProviders = {
29
37
  eth: {
@@ -91,12 +99,7 @@ export const getDefaultPkcOptions = () => {
91
99
  "https://pubsubprovider.xyz/api/v0",
92
100
  "https://plebpubsub.xyz/api/v0",
93
101
  "https://rannithepleb.com/api/v0",
94
- ], httpRoutersOptions: [
95
- "https://routing.lol",
96
- "https://peers.pleb.bot",
97
- "https://peers.plebpubsub.xyz",
98
- "https://peers.forumindex.com",
99
- ] }, overwritePkcOptions));
102
+ ], httpRoutersOptions: [...DEFAULT_HTTP_ROUTER_URLS] }, overwritePkcOptions));
100
103
  };
101
104
  // the gateway to use in <img src> for nft avatars
102
105
  // @ts-ignore
@@ -1 +1 @@
1
- {"version":3,"file":"account-generator.js","sourceRoot":"","sources":["../../../src/stores/accounts/account-generator.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,kBAAkB,CAAC;AACrC,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAC5C,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EACL,mBAAmB,EACnB,8BAA8B,EAC9B,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,uCAAuC,CAAC,CAAC;AAE5D,MAAM,CAAC,MAAM,mBAAmB,GAAG,qCAAqC,CAAC;AACzE,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,mBAAmB;IACnB,sBAAsB;IACtB,iCAAiC;IACjC,2BAA2B;IAC3B,qBAAqB;IACrB,6BAA6B;CAC9B,CAAC;AAEF,0BAA0B;AAC1B,MAAM,cAAc,GAAmB;IACrC,GAAG,EAAE;QACH,qFAAqF;QACrF,IAAI,EAAE,CAAC,GAAG,oBAAoB,EAAE,WAAW,CAAC;QAC5C,OAAO,EAAE,CAAC;KACX;IACD,KAAK,EAAE;QACL,IAAI,EAAE,CAAC,yBAAyB,CAAC;QACjC,OAAO,EAAE,GAAG;KACb;CACF,CAAC;AAEF,8CAA8C;AAC9C,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,kBAAkB,EAAE,KAAK;IACzB,s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,CAAC,UAAU,CAAC,CAAC;QACjF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IACD,IAAI,aAAa,GAAG,CAAC,CAAC;IACtB,IAAI,CAAC,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,MAAM,CAAA,EAAE,CAAC;QAC1B,OAAO,WAAW,aAAa,EAAE,CAAC;IACpC,CAAC;IACD,SAAS,CAAC,oCAAoC,CAAC,YAAY,CAAC,CAAC;IAE7D,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;IAC9C,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,WAAW,GAAG,WAAW,aAAa,EAAE,CAAC;QAC/C,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YACtC,OAAO,WAAW,CAAC;QACrB,CAAC;QACD,aAAa,EAAE,CAAC;IAClB,CAAC;AACH,CAAC,CAAA,CAAC;AAEF,MAAM,gBAAgB,GAAG;IACvB,sBAAsB;IACtB,oBAAoB;CACrB,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import PkcJs from \"../../lib/pkc-js\";\nimport validator from \"../../lib/validator\";\nimport chain from \"../../lib/chain\";\nimport { v4 as uuid } from \"uuid\";\nimport accountsDatabase from \"./accounts-database\";\nimport { Accounts, AccountCommunity, ChainProviders } from \"../../types\";\nimport {\n getPkcClientOptions,\n normalizeAccountProtocolConfig,\n withProtocolAliases,\n} from \"../../lib/pkc-compat\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:accounts:stores\");\n\nexport const DEFAULT_ETH_RPC_URL = \"https://ethereum-rpc.publicnode.com\";\nexport const DEFAULT_ETH_RPC_URLS = [\n DEFAULT_ETH_RPC_URL,\n \"https://eth.drpc.org\",\n \"https://ethereum.publicnode.com\",\n \"https://rpc.mevblocker.io\",\n \"https://1rpc.io/eth\",\n \"https://eth-pokt.nodies.app\",\n];\n\n// default chain providers\nconst chainProviders: ChainProviders = {\n eth: {\n // Use explicit RPCs for default name resolution; viem's default transport is opt-in.\n urls: [...DEFAULT_ETH_RPC_URLS, \"ethers.js\"],\n chainId: 1,\n },\n matic: {\n urls: [\"https://polygon-rpc.com\"],\n chainId: 137,\n },\n};\n\n// force using these options or can cause bugs\nexport const overwritePkcOptions = {\n resolveAuthorNames: false,\n resolveAuthorAddresses: false,\n validatePages: false,\n};\n\nconst aliasProtocolOptions = (options: Record<string, any>) => ({\n ...options,\n resolveAuthorNames: options.resolveAuthorNames ?? options.resolveAuthorAddresses ?? false,\n resolveAuthorAddresses: options.resolveAuthorAddresses ?? options.resolveAuthorNames ?? false,\n});\n\nconst addMissingChainProviders = (options: Record<string, any>) => {\n const optionsWithChainProviders = { ...options };\n if (!optionsWithChainProviders.chainProviders) {\n optionsWithChainProviders.chainProviders = {};\n }\n for (const chainTicker in chainProviders) {\n if (!optionsWithChainProviders.chainProviders[chainTicker]) {\n optionsWithChainProviders.chainProviders[chainTicker] = chainProviders[chainTicker];\n }\n }\n return optionsWithChainProviders;\n};\n\nexport const getDefaultChainProviders = () => {\n // @ts-ignore\n const defaultWindowOptions = window.defaultPkcOptions;\n const windowChainProviders = defaultWindowOptions?.chainProviders\n ? JSON.parse(JSON.stringify(defaultWindowOptions.chainProviders))\n : undefined;\n return addMissingChainProviders({\n chainProviders: windowChainProviders,\n }).chainProviders as ChainProviders;\n};\n\n// default options aren't saved to database so they can be changed\nexport const getDefaultPkcOptions = () => {\n // default PKC options defined by the electron process\n // @ts-ignore\n const defaultWindowOptions = window.defaultPkcOptions;\n if (defaultWindowOptions) {\n // @ts-ignore\n const defaultPkcOptions: any = JSON.parse(\n JSON.stringify({ ...defaultWindowOptions, libp2pJsClientsOptions: undefined }),\n );\n delete defaultPkcOptions.chainProviders;\n delete defaultPkcOptions.nameResolversChainProviders;\n // @ts-ignore\n defaultPkcOptions.libp2pJsClientsOptions = defaultWindowOptions.libp2pJsClientsOptions; // libp2pJsClientsOptions is not always just json\n return aliasProtocolOptions({ ...defaultPkcOptions, ...overwritePkcOptions });\n }\n // default PKC options for web client\n return aliasProtocolOptions({\n ipfsGatewayUrls: [\n \"https://ipfsgateway.xyz\",\n \"https://gateway.plebpubsub.xyz\",\n \"https://gateway.forumindex.com\",\n ],\n kuboRpcClientsOptions: undefined,\n pubsubKuboRpcClientsOptions: [\n \"https://pubsubprovider.xyz/api/v0\",\n \"https://plebpubsub.xyz/api/v0\",\n \"https://rannithepleb.com/api/v0\",\n ],\n httpRoutersOptions: [\n \"https://routing.lol\",\n \"https://peers.pleb.bot\",\n \"https://peers.plebpubsub.xyz\",\n \"https://peers.forumindex.com\",\n ],\n ...overwritePkcOptions,\n });\n};\n\n// the gateway to use in <img src> for nft avatars\n// @ts-ignore\nconst defaultMediaIpfsGatewayUrl = window.defaultMediaIpfsGatewayUrl || \"https://ipfs.io\";\n\nconst generateDefaultAccount = async () => {\n const pkcOptions = getDefaultPkcOptions();\n const chainProviders = getDefaultChainProviders();\n const pkc = await PkcJs.PKC(\n getPkcClientOptions(\n {\n chainProviders,\n pkcOptions,\n },\n pkcOptions,\n ),\n );\n // handle errors or error events are uncaught\n // no need to log them because pkc-js already logs them\n pkc.on(\"error\", (error: any) =>\n log.error(\"uncaught pkc instance error, should never happen\", { error }),\n );\n\n const signer = await pkc.createSigner();\n const author = {\n address: signer.address,\n wallets: {\n eth: await chain.getEthWalletFromPkcPrivateKey(signer.privateKey, signer.address),\n },\n };\n\n const accountName = await getNextAvailableDefaultAccountName();\n\n // communities where the account has a role, like moderator, admin, owner, etc.\n const communities: { [communityAddress: string]: AccountCommunity } = {};\n\n const account = normalizeAccountProtocolConfig(\n withProtocolAliases(\n {\n id: uuid(),\n version: accountsDatabase.accountVersion,\n name: accountName,\n author,\n signer,\n chainProviders,\n pkcOptions,\n subscriptions: [],\n blockedAddresses: {},\n blockedCids: {},\n communities,\n mediaIpfsGatewayUrl: defaultMediaIpfsGatewayUrl,\n },\n pkc,\n pkcOptions,\n ),\n chainProviders,\n );\n return account;\n};\n\nconst getNextAvailableDefaultAccountName = async () => {\n const accountIds: string[] | null =\n await accountsDatabase.accountsMetadataDatabase.getItem(\"accountIds\");\n const accountNames = [];\n if (accountIds?.length) {\n const accounts: Accounts | null = await accountsDatabase.getAccounts(accountIds);\n for (const accountId of accountIds) {\n accountNames.push(accounts[accountId].name);\n }\n }\n let accountNumber = 1;\n if (!accountNames?.length) {\n return `Account ${accountNumber}`;\n }\n validator.validateAccountsDatabaseAccountNames(accountNames);\n\n const accountNamesSet = new Set(accountNames);\n while (true) {\n const accountName = `Account ${accountNumber}`;\n if (!accountNamesSet.has(accountName)) {\n return accountName;\n }\n accountNumber++;\n }\n};\n\nconst accountGenerator = {\n generateDefaultAccount,\n getDefaultPkcOptions,\n};\n\nexport default accountGenerator;\n"]}
1
+ {"version":3,"file":"account-generator.js","sourceRoot":"","sources":["../../../src/stores/accounts/account-generator.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,kBAAkB,CAAC;AACrC,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAC5C,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EACL,mBAAmB,EACnB,8BAA8B,EAC9B,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,uCAAuC,CAAC,CAAC;AAE5D,MAAM,CAAC,MAAM,mBAAmB,GAAG,qCAAqC,CAAC;AACzE,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,mBAAmB;IACnB,sBAAs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BAAgB,GAAG;IACvB,sBAAsB;IACtB,oBAAoB;CACrB,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import PkcJs from \"../../lib/pkc-js\";\nimport validator from \"../../lib/validator\";\nimport chain from \"../../lib/chain\";\nimport { v4 as uuid } from \"uuid\";\nimport accountsDatabase from \"./accounts-database\";\nimport { Accounts, AccountCommunity, ChainProviders } from \"../../types\";\nimport {\n getPkcClientOptions,\n normalizeAccountProtocolConfig,\n withProtocolAliases,\n} from \"../../lib/pkc-compat\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:accounts:stores\");\n\nexport const DEFAULT_ETH_RPC_URL = \"https://ethereum-rpc.publicnode.com\";\nexport const DEFAULT_ETH_RPC_URLS = [\n DEFAULT_ETH_RPC_URL,\n \"https://eth.drpc.org\",\n \"https://ethereum.publicnode.com\",\n \"https://rpc.mevblocker.io\",\n \"https://1rpc.io/eth\",\n \"https://eth-pokt.nodies.app\",\n];\nexport const DEFAULT_HTTP_ROUTER_URLS = [\n \"https://peers.pleb.bot\",\n \"https://routing.lol\",\n \"https://peers.forumindex.com\",\n \"https://peers.plebpubsub.xyz\",\n \"https://routerofbitsocial.xyz\",\n \"https://bsotracker.online\",\n];\n\n// default chain providers\nconst chainProviders: ChainProviders = {\n eth: {\n // Use explicit RPCs for default name resolution; viem's default transport is opt-in.\n urls: [...DEFAULT_ETH_RPC_URLS, \"ethers.js\"],\n chainId: 1,\n },\n matic: {\n urls: [\"https://polygon-rpc.com\"],\n chainId: 137,\n },\n};\n\n// force using these options or can cause bugs\nexport const overwritePkcOptions = {\n resolveAuthorNames: false,\n resolveAuthorAddresses: false,\n validatePages: false,\n};\n\nconst aliasProtocolOptions = (options: Record<string, any>) => ({\n ...options,\n resolveAuthorNames: options.resolveAuthorNames ?? options.resolveAuthorAddresses ?? false,\n resolveAuthorAddresses: options.resolveAuthorAddresses ?? options.resolveAuthorNames ?? false,\n});\n\nconst addMissingChainProviders = (options: Record<string, any>) => {\n const optionsWithChainProviders = { ...options };\n if (!optionsWithChainProviders.chainProviders) {\n optionsWithChainProviders.chainProviders = {};\n }\n for (const chainTicker in chainProviders) {\n if (!optionsWithChainProviders.chainProviders[chainTicker]) {\n optionsWithChainProviders.chainProviders[chainTicker] = chainProviders[chainTicker];\n }\n }\n return optionsWithChainProviders;\n};\n\nexport const getDefaultChainProviders = () => {\n // @ts-ignore\n const defaultWindowOptions = window.defaultPkcOptions;\n const windowChainProviders = defaultWindowOptions?.chainProviders\n ? JSON.parse(JSON.stringify(defaultWindowOptions.chainProviders))\n : undefined;\n return addMissingChainProviders({\n chainProviders: windowChainProviders,\n }).chainProviders as ChainProviders;\n};\n\n// default options aren't saved to database so they can be changed\nexport const getDefaultPkcOptions = () => {\n // default PKC options defined by the electron process\n // @ts-ignore\n const defaultWindowOptions = window.defaultPkcOptions;\n if (defaultWindowOptions) {\n // @ts-ignore\n const defaultPkcOptions: any = JSON.parse(\n JSON.stringify({ ...defaultWindowOptions, libp2pJsClientsOptions: undefined }),\n );\n delete defaultPkcOptions.chainProviders;\n delete defaultPkcOptions.nameResolversChainProviders;\n // @ts-ignore\n defaultPkcOptions.libp2pJsClientsOptions = defaultWindowOptions.libp2pJsClientsOptions; // libp2pJsClientsOptions is not always just json\n return aliasProtocolOptions({ ...defaultPkcOptions, ...overwritePkcOptions });\n }\n // default PKC options for web client\n return aliasProtocolOptions({\n ipfsGatewayUrls: [\n \"https://ipfsgateway.xyz\",\n \"https://gateway.plebpubsub.xyz\",\n \"https://gateway.forumindex.com\",\n ],\n kuboRpcClientsOptions: undefined,\n pubsubKuboRpcClientsOptions: [\n \"https://pubsubprovider.xyz/api/v0\",\n \"https://plebpubsub.xyz/api/v0\",\n \"https://rannithepleb.com/api/v0\",\n ],\n httpRoutersOptions: [...DEFAULT_HTTP_ROUTER_URLS],\n ...overwritePkcOptions,\n });\n};\n\n// the gateway to use in <img src> for nft avatars\n// @ts-ignore\nconst defaultMediaIpfsGatewayUrl = window.defaultMediaIpfsGatewayUrl || \"https://ipfs.io\";\n\nconst generateDefaultAccount = async () => {\n const pkcOptions = getDefaultPkcOptions();\n const chainProviders = getDefaultChainProviders();\n const pkc = await PkcJs.PKC(\n getPkcClientOptions(\n {\n chainProviders,\n pkcOptions,\n },\n pkcOptions,\n ),\n );\n // handle errors or error events are uncaught\n // no need to log them because pkc-js already logs them\n pkc.on(\"error\", (error: any) =>\n log.error(\"uncaught pkc instance error, should never happen\", { error }),\n );\n\n const signer = await pkc.createSigner();\n const author = {\n address: signer.address,\n wallets: {\n eth: await chain.getEthWalletFromPkcPrivateKey(signer.privateKey, signer.address),\n },\n };\n\n const accountName = await getNextAvailableDefaultAccountName();\n\n // communities where the account has a role, like moderator, admin, owner, etc.\n const communities: { [communityAddress: string]: AccountCommunity } = {};\n\n const account = normalizeAccountProtocolConfig(\n withProtocolAliases(\n {\n id: uuid(),\n version: accountsDatabase.accountVersion,\n name: accountName,\n author,\n signer,\n chainProviders,\n pkcOptions,\n subscriptions: [],\n blockedAddresses: {},\n blockedCids: {},\n communities,\n mediaIpfsGatewayUrl: defaultMediaIpfsGatewayUrl,\n },\n pkc,\n pkcOptions,\n ),\n chainProviders,\n );\n return account;\n};\n\nconst getNextAvailableDefaultAccountName = async () => {\n const accountIds: string[] | null =\n await accountsDatabase.accountsMetadataDatabase.getItem(\"accountIds\");\n const accountNames = [];\n if (accountIds?.length) {\n const accounts: Accounts | null = await accountsDatabase.getAccounts(accountIds);\n for (const accountId of accountIds) {\n accountNames.push(accounts[accountId].name);\n }\n }\n let accountNumber = 1;\n if (!accountNames?.length) {\n return `Account ${accountNumber}`;\n }\n validator.validateAccountsDatabaseAccountNames(accountNames);\n\n const accountNamesSet = new Set(accountNames);\n while (true) {\n const accountName = `Account ${accountNumber}`;\n if (!accountNamesSet.has(accountName)) {\n return accountName;\n }\n accountNumber++;\n }\n};\n\nconst accountGenerator = {\n generateDefaultAccount,\n getDefaultPkcOptions,\n};\n\nexport default accountGenerator;\n"]}
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "publishConfig": {
14
14
  "access": "public"
15
15
  },
16
- "version": "0.1.20",
16
+ "version": "0.1.22",
17
17
  "packageManager": "yarn@4.13.0",
18
18
  "files": [
19
19
  "CHANGELOG.md",
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@bitsocial/bso-resolver": "0.0.8",
51
- "@pkcprotocol/pkc-js": "0.0.48",
51
+ "@pkcprotocol/pkc-js": "0.0.53",
52
52
  "@pkcprotocol/pkc-logger": "0.1.0",
53
53
  "assert": "2.0.0",
54
54
  "ethers": "5.8.0",
@@ -69,12 +69,12 @@
69
69
  "resolutions": {
70
70
  "follow-redirects": "1.16.0",
71
71
  "postcss": "8.5.10",
72
- "protobufjs": "7.5.8",
72
+ "protobufjs": "7.6.3",
73
73
  "uuid": "14.0.0",
74
74
  "axios": "1.16.0",
75
75
  "vite": "8.0.16",
76
- "tar": "7.5.11",
77
- "undici": "7.24.0",
76
+ "tar": "7.5.16",
77
+ "undici": "7.28.0",
78
78
  "minimatch": "3.1.4",
79
79
  "brace-expansion@npm:^1.1.7": "1.1.13",
80
80
  "elliptic": "6.6.1",
@@ -88,14 +88,16 @@
88
88
  "picomatch@npm:^2.3.1": "2.3.2",
89
89
  "picomatch@npm:^4.0.1": "4.0.4",
90
90
  "picomatch@npm:^4.0.3": "4.0.4",
91
- "tmp": "0.2.6",
91
+ "tmp": "0.2.7",
92
92
  "@tootallnate/once": "3.0.1",
93
93
  "@protobufjs/utf8": "1.1.1",
94
94
  "@libp2p/gossipsub": "15.0.23",
95
95
  "@libp2p/kad-dht": "16.2.6",
96
96
  "fast-uri": "3.1.2",
97
97
  "ip-address": "10.1.1",
98
- "ws": "8.20.1"
98
+ "ws": "8.21.0",
99
+ "form-data": "4.0.6",
100
+ "js-yaml": "4.2.0"
99
101
  },
100
102
  "devDependencies": {
101
103
  "@testing-library/dom": "10.4.1",