8000 Use FieldError by illepic · Pull Request #1192 · infinity-keys/ik-landing · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Use FieldError #1192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
May 31, 2024
182 changes: 101 additions & 81 deletions api/src/lib/puzzleForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export const formatCreateSteps = (steps: CreateStepInput[]) => {
stepPage,
type,
stepSimpleText,
stepNftCheck,
stepFunctionCall,
stepTokenIdRange,
stepOriumApi,
}) => {
const stepCommon = {
solutionHint,
Expand All @@ -30,90 +34,106 @@ export const formatCreateSteps = (steps: CreateStepInput[]) => {
},
}

if (type === StepType.SIMPLE_TEXT && stepSimpleText) {
return {
...stepCommon,
type: StepType.SIMPLE_TEXT,
stepSimpleText: {
create: {
solution: stepSimpleText.solution,
solutionCharCount: stepSimpleText.solution.length,
switch (type) {
case StepType.SIMPLE_TEXT: {
if (!stepSimpleText) throw new Error('Simple text step missing')
return {
...stepCommon,
type: StepType.SIMPLE_TEXT,
stepSimpleText: {
create: {
solution: stepSimpleText.solution,
solutionCharCount: stepSimpleText.solution.length,
},
},
},
}
}
case StepType.NFT_CHECK: {
throw new Error(`Step type ${type} not implemented yet`)
if (!stepNftCheck) throw new Error('NFT check step missing')
// return {
// ...stepCommon,
// type: 'NFT_CHECK',
// stepNftCheck: {
// create: {
// requireAllNfts: stepNftCheck.requireAllNfts,
// nftCheckData: {
// create: stepNftCheck.nftCheckData.map((nftCheckDatum) => {
// return {
// contractAddress: nftCheckDatum.contractAddress,
// tokenId: nftCheckDatum.tokenId,
// chainId: nftCheckDatum.chainId,
// poapEventId: nftCheckDatum.poapEventId,
// }
// }),
// },
// },
// },
// }
}
case StepType.FUNCTION_CALL: {
throw new Error(`Step type ${type} not implemented yet`)
if (!stepFunctionCall) throw new Error('Function call step missing')
// return {
// ...stepCommon,
// type: 'FUNCTION_CALL',
// stepFunctionCall: {
// create: {
// methodIds: stepFunctionCall.methodIds,
// contractAddress: stepFunctionCall.contractAddress,
// },
// },
// }
}
case StepType.COMETH_API: {
throw new Error(`Step type ${type} not implemented yet`)
// return {
// ...stepCommon,
// type: 'COMETH_API',
// stepComethApi: {
// // No addition info currently needed for the Cometh API check
// },
// }
}
case StepType.TOKEN_ID_RANGE: {
throw new Error(`Step type ${type} not implemented yet`)
if (!stepTokenIdRange) throw new Error('Token ID range step missing')
// return {
// ...stepCommon,
// type: 'TOKEN_ID_RANGE',
// stepTokenIdRange: {
// create: {
// contractAddress: stepTokenIdRange.contractAddress,
// chainId: stepTokenIdRange.chainId,
// startIds: stepTokenIdRange.startIds,
// endIds: stepTokenIdRange.endIds,
// },
// },
// }
}
case StepType.ORIUM_API: {
throw new Error(`Step type ${type} not implemented yet`)
if (!stepOriumApi) throw new Error('Orium API step missing')
// return {
// ...stepCommon,
// type: 'ORIUM_API',
// stepOriumApi: {
// create: {
// checkType: stepOriumApi.checkType,
// },
// },
// }
}
case StepType.ASSET_TRANSFER:
case StepType.ERC20_BALANCE:
case StepType.LENS_API: {
throw new Error(`Step type ${type} not implemented yet`)
}
default: {
const _exhaustiveCheck: never = type
throw new Error(`Unhandled step type: ${_exhaustiveCheck}`)
}
}

// NOTE: Enable each option when we start supporting it
{
// if (step.type === 'NFT_CHECK' && step.stepNftCheck) {
// return {
// ...stepCommon,
// type: 'NFT_CHECK',
// stepNftCheck: {
// create: {
// requireAllNfts: step.stepNftCheck.requireAllNfts,
// nftCheckData: {
// create: step.stepNftCheck.nftCheckData.map((nftCheckDatum) => {
// return {
// contractAddress: nftCheckDatum.contractAddress,
// tokenId: nftCheckDatum.tokenId,
// chainId: nftCheckDatum.chainId,
// poapEventId: nftCheckDatum.poapEventId,
// }
// }),
// },
// },
// },
// }
// }
// if (step.type === 'FUNCTION_CALL' && step.stepFunctionCall) {
// return {
// ...stepCommon,
// type: 'FUNCTION_CALL',
// stepFunctionCall: {
// create: {
// methodIds: step.stepFunctionCall.methodIds,
// contractAddress: step.stepFunctionCall.contractAddress,
// },
// },
// }
// }
// if (step.type === 'COMETH_API' && step.stepComethApi) {
// return {
// ...stepCommon,
// type: 'COMETH_API',
// stepComethApi: {
// // No addition info currently needed for the Cometh API check
// },
// }
// }
// if (step.type === 'TOKEN_ID_RANGE' && step.stepTokenIdRange) {
// return {
// ...stepCommon,
// type: 'TOKEN_ID_RANGE',
// stepTokenIdRange: {
// create: {
// contractAddress: step.stepTokenIdRange.contractAddress,
// chainId: step.stepTokenIdRange.chainId,
// startIds: step.stepTokenIdRange.startIds,
// endIds: step.stepTokenIdRange.endIds,
// },
// },
// }
// }
// if (step.type === 'ORIUM_API' && step.stepOriumApi) {
// return {
// ...stepCommon,
// type: 'ORIUM_API',
// stepOriumApi: {
// create: {
// checkType: step.stepOriumApi.checkType,
// },
// },
// }
// }
}
throw new Error(`Step type ${type} not implemented yet`)
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { CLOUDINARY_CLOUD_NAME } from '@infinity-keys/constants'
import { cloudinaryUrl } from '@infinity-keys/core'

import Button from 'src/components/Button'

import DisplayImage from '../DisplayImage/DisplayImage'
import DisplayImage from 'src/components/PuzzleForm/DisplayImage/DisplayImage'

export const formatImageSrc = (src: string) => {
if (src.startsWith('https')) return src
Expand Down
Loading
Loading 3E66
0