Skip to content

Commit b724807

Browse files
committed
feat: retry and validate IPFS on server instead of client
1 parent 55d5be2 commit b724807

File tree

1 file changed

+1
-26
lines changed

1 file changed

+1
-26
lines changed

src/ipfs.ts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,6 @@ import { Micro } from 'effect';
1010
import { EditProposal } from '~/proto.js';
1111
import type { Op } from './types.js';
1212

13-
class CidValidateError extends Error {
14-
readonly _tag = 'CidValidateError';
15-
}
16-
17-
function validateCid(cid: string) {
18-
return Micro.gen(function* () {
19-
const [, cidContains] = cid.split('ipfs://');
20-
if (!cid.startsWith('ipfs://')) {
21-
yield* Micro.fail(new CidValidateError(`CID ${cid} does not start with ipfs://`));
22-
}
23-
24-
if (cidContains === undefined || cidContains === '') {
25-
yield* Micro.fail(new CidValidateError(`CID ${cid} is not valid`));
26-
}
27-
28-
return true;
29-
});
30-
}
31-
3213
class IpfsUploadError extends Error {
3314
readonly _tag = 'IpfsUploadError';
3415
}
@@ -88,14 +69,8 @@ export async function publishEdit(args: PublishEditProposalArgs): Promise<string
8869
catch: error => new IpfsUploadError(`Could not parse response from IPFS: ${error}`),
8970
});
9071

91-
yield* validateCid(maybeCid);
92-
9372
return maybeCid as `ipfs://${string}`;
9473
});
9574

96-
return await Micro.runPromise(
97-
Micro.retry(upload, {
98-
times: 3,
99-
}),
100-
);
75+
return await Micro.runPromise(upload);
10176
}

0 commit comments

Comments
 (0)