UNPKG

@nosana/kit

Version:

Nosana KIT

17 lines 767 B
import { ipfsHashToSolBytesArray } from '@nosana/ipfs'; import { JobState } from '../JobsProgram.js'; export async function complete({ job, ipfsResultsHash }, { client, get, getRequiredWallet }) { const wallet = getRequiredWallet(); const jobAccount = await get(job); if (jobAccount.state !== JobState.COMPLETED) throw new Error(`Cannot complete a job that is not in state COMPLETED. Current state: ${JobState[jobAccount.state]}`); if (jobAccount.ipfsResult !== null) { throw new Error('Job has already been completed.'); } return client.getCompleteInstruction({ job, ipfsResult: new Uint8Array(ipfsHashToSolBytesArray(ipfsResultsHash)), authority: wallet, }); } //# sourceMappingURL=complete.js.map