feat: add blockOp
This commit is contained in:
parent
c0e6012d2f
commit
d2bbf76d90
@ -1,5 +1,25 @@
|
||||
export const blockOp = () => {
|
||||
return new Promise<void>((resolve) => {
|
||||
resolve();
|
||||
import { BlockFilter, constructBlock, extractBlock, isResolvedBlock } from '@coinweb/contract-kit';
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -11,7 +11,6 @@ export const storeOp = (claim: Claim) =>
|
||||
|
||||
if (!isOp) {
|
||||
pushAwaitedOp(constructStore(claim));
|
||||
// abort();
|
||||
} else {
|
||||
if (op && !isResolvedStore(op)) {
|
||||
throw new Error('Store operation not found');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user