Closed iosonopersia closed 2 years ago
See documentation of iExec SDK: IExecTaskModule:obsTask.
The obsTask function could be of great help in refactoring and vastly simplifying the code from getQueryResult in the Desmo module.
obsTask
getQueryResult
Desmo
Code would become something like this:
const taskId = await this.retrieveTaskID(); const taskObservable = await this.iexec.task.obsTask(taskId, { dealid: this.dealId, }); const taskCompletion: Promise<ethers.Bytes> = new Promise((resolve, reject) => { taskObservable.subscribe({ next: ({ message }) => console.log(message), error: (e) => reject(e), complete: async () => { const tx = await this.contract.receiveResult(taskId, '0x00'); await tx.wait(); const result: ethers.Bytes = await this.contract.getQueryResult(taskId); resolve(result); }, }); }); const result = await taskCompletion; // TODO: Decode the result return { requestId: '', taskId, result: result.toString() };
These changes were proposed in PR #7.
Done in #7.
See documentation of iExec SDK: IExecTaskModule:obsTask.
The
obsTask
function could be of great help in refactoring and vastly simplifying the code fromgetQueryResult
in theDesmo
module.Code would become something like this: