Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/filecoin-pin-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
# Upload to Filecoin using the downloaded build artifacts
# The action will create a CAR file from the downloaded artifacts and upload to Filecoin
- name: Upload to Filecoin
uses: filecoin-project/filecoin-pin/upload-action@master
uses: filecoin-project/filecoin-pin/upload-action@fix/upload-action-pnpm-before-node
with:
path: dist # Path to the downloaded build artifacts
walletPrivateKey: ${{ secrets.WALLET_PRIVATE_KEY }}
Expand Down
7,111 changes: 3,313 additions & 3,798 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/components/ui/accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ function AccordionContent({ className, children, ...props }: React.ComponentProp
)
}

export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger }
2 changes: 1 addition & 1 deletion src/components/ui/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ function ExternalLink(props: ExternalLinkProps) {
return <a {...props} rel="noopener noreferrer" target="_blank" />
}

export { TextLink, ExternalLink }
export { ExternalLink, TextLink }
1 change: 1 addition & 0 deletions src/context/filecoin-pin-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const FilecoinPinProvider = ({ children }: { children: ReactNode }) => {
debugParams,
})

// biome-ignore lint/correctness/useExhaustiveDependencies: `config` can change
const refreshWallet = useCallback(async () => {
setWallet((prev) => ({
status: 'loading',
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/use-data-set-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ export function useDataSetManager({
const effectiveDataSetId = urlDataSetId ?? storedDataSetId
if (urlDataSetId !== null) {
console.debug('[DataSet] Using data set ID from URL override:', urlDataSetId)
} else if (storedDataSetId !== null) {
console.debug('[DataSet] Using data set ID from localStorage:', storedDataSetId)
} else {
} else if (storedDataSetId === null) {
console.debug('[DataSet] No data set ID overrides found, will create or resolve automatically')
} else {
console.debug('[DataSet] Using data set ID from localStorage:', storedDataSetId)
}

// Need to create storage context (either for existing or new data set)
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/use-dataset-pieces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export const useDatasetPieces = () => {
setIsLoading(false)
setHasLoaded(true)
}
}, [dataSetId, providerInfo, wallet, synapse])
}, [dataSetId, providerInfo, wallet, synapse, storageContext])

// Load pieces when storage context is ready
useEffect(() => {
Expand All @@ -159,7 +159,7 @@ export const useDatasetPieces = () => {
setPieces([])
setHasLoaded(false)
}
}, [loadPieces])
}, [loadPieces, storageContext, providerInfo])

const refreshPieces = useCallback(() => {
loadPieces()
Expand Down
10 changes: 5 additions & 5 deletions src/hooks/use-filecoin-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const INPI_ERROR_MESSAGE =
* actions so they stay dumb and declarative.
*/
export const useFilecoinUpload = () => {
const { synapse, storageContext, providerInfo, checkIfDatasetExists, wallet } = useFilecoinPinContext()
const { synapse, storageContext, providerInfo, wallet } = useFilecoinPinContext()

// Use waitable refs to track the latest context values, so the upload callback can access them
// even if the dataset is initialized after the callback is created
Expand Down Expand Up @@ -208,10 +208,10 @@ export const useFilecoinUpload = () => {
const debugParams = getDebugParams()

// Only use storeDataSetIdForProvider if user explicitly provided providerId in URL
if (debugParams.providerId !== null) {
storeDataSetIdForProvider(wallet.data.address, currentProviderInfo.id, currentDataSetId)
} else {
if (debugParams.providerId === null) {
storeDataSetId(wallet.data.address, currentDataSetId)
} else {
storeDataSetIdForProvider(wallet.data.address, currentProviderInfo.id, currentDataSetId)
}
}

Expand Down Expand Up @@ -263,7 +263,7 @@ export const useFilecoinUpload = () => {
}))
}
},
[updateStepState, synapse, checkIfDatasetExists]
[updateStepState, providerInfoRef.wait, storageContextRef.wait, synapseRef.wait, wallet.data, wallet.status]
)

const resetUpload = useCallback(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/use-upload-progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ export function useUploadProgress({ stepStates, cid }: useUploadProgressProps):
},
uploadBadgeStatus,
}
}, [stepStates, cid])
}, [stepStates, cid, announcingCidsStep, finalizingStep])
}
20 changes: 10 additions & 10 deletions src/lib/filecoin-pin/storage-context-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,16 @@ async function getApprovedProviderInfo(
): Promise<ProviderInfo> {
let providerInfo: ProviderInfo | null = null

if (providerId != null) {
if (providerId == null) {
// otherwise, get all approved provider ids and randomly select one.
const approvedProviderIds = await warmStorage.getApprovedProviderIds()
if (approvedProviderIds.length === 0) {
throw new Error('No approved storage providers available for new data set creation')
}
// select a random approved provider id
const randomApprovedProviderId = approvedProviderIds[Math.floor(Math.random() * approvedProviderIds.length)]
providerInfo = await spRegistry.getProvider(randomApprovedProviderId)
} else {
// if given a providerId, check if it is approved and log a warning if it's not an approved provider.
const isProviderApproved = await warmStorage.isProviderIdApproved(providerId)
if (!isProviderApproved) {
Expand All @@ -160,15 +169,6 @@ async function getApprovedProviderInfo(
)
}
providerInfo = await spRegistry.getProvider(providerId)
} else {
// otherwise, get all approved provider ids and randomly select one.
const approvedProviderIds = await warmStorage.getApprovedProviderIds()
if (approvedProviderIds.length === 0) {
throw new Error('No approved storage providers available for new data set creation')
}
// select a random approved provider id
const randomApprovedProviderId = approvedProviderIds[Math.floor(Math.random() * approvedProviderIds.length)]
providerInfo = await spRegistry.getProvider(randomApprovedProviderId)
}

if (providerInfo == null) {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/debug-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ export function logDebugParams(): void {
if (params.providerId !== null || params.dataSetId !== null) {
console.warn(
'[DEBUG MODE] URL parameters detected:',
params.providerId !== null ? `providerId=${params.providerId}` : '',
params.dataSetId !== null ? `dataSetId=${params.dataSetId}` : ''
params.providerId === null ? '' : `providerId=${params.providerId}`,
params.dataSetId === null ? '' : `dataSetId=${params.dataSetId}`
)
}
}
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { playwright } from '@vitest/browser-playwright'
import path from 'path'
import { defineConfig } from 'vite'

const dirname = typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url))
const dirname = typeof __dirname === 'undefined' ? path.dirname(fileURLToPath(import.meta.url)) : __dirname

// More info at: https://storybook.js.org/docs/writing-tests/integrations/vitest-addon
export default defineConfig({
Expand Down
Loading