feat: add blockOp

This commit is contained in:
Alex 2025-04-04 16:58:40 +03:00
parent c0e6012d2f
commit d2bbf76d90
2 changed files with 24 additions and 5 deletions

View File

@ -1,5 +1,25 @@
export const blockOp = () => { import { BlockFilter, constructBlock, extractBlock, isResolvedBlock } from '@coinweb/contract-kit';
return new Promise<void>((resolve) => {
resolve(); import { pushAwaitedOp } from './awaited';
import { shiftResolvedOp } from './resolved';
export const blockOp = (filters: BlockFilter[]) =>
new Promise<[BlockFilter, boolean][] | null>((resolve, reject) => {
try {
const { op, isOp } = shiftResolvedOp();
if (!isOp) {
pushAwaitedOp(constructBlock(filters));
} else {
if (op && !isResolvedBlock(op)) {
throw new Error('Block operation not found');
}
const result = op && extractBlock(op);
resolve(result);
}
} catch (error) {
reject(error);
}
}); });
};

View File

@ -11,7 +11,6 @@ export const storeOp = (claim: Claim) =>
if (!isOp) { if (!isOp) {
pushAwaitedOp(constructStore(claim)); pushAwaitedOp(constructStore(claim));
// abort();
} else { } else {
if (op && !isResolvedStore(op)) { if (op && !isResolvedStore(op)) {
throw new Error('Store operation not found'); throw new Error('Store operation not found');