feat: difference awaited and non-awaited promises

This commit is contained in:
Alex 2025-04-11 01:39:55 +03:00
parent 3ec30e911d
commit d9670b314a
21 changed files with 398 additions and 48 deletions

View File

@ -8,11 +8,12 @@
"scripts": { "scripts": {
"build": "yarn build:cm && yarn build:non-cm", "build": "yarn build:cm && yarn build:non-cm",
"build:production": "yarn build:cm && yarn workspace dapp-ui build:production", "build:production": "yarn build:cm && yarn workspace dapp-ui build:production",
"build:cm": "yarn workspaces foreach -Ap --include 'packages/lib' --include 'packages/cwait' --include 'packages/*.cm' run build", "build:lib": "yarn workspaces foreach -Ap --include 'packages/lib' --include 'packages/cwait' run build",
"build:cm": "yarn build:lib && yarn workspaces foreach -Ap --include 'packages/*.cm' run build",
"build:non-cm": "yarn workspaces foreach -Ap --include 'packages/*' --exclude 'packages/*.cm' --exclude 'packages/lib' --exclude 'packages/cwait' run build", "build:non-cm": "yarn workspaces foreach -Ap --include 'packages/*' --exclude 'packages/*.cm' --exclude 'packages/lib' --exclude 'packages/cwait' run build",
"create-index": "cweb-tool create-index -c ./.cweb-config/config.yaml --profile $REGISTRATION_PROFILE", "create-index": "cweb-tool create-index -c ./.cweb-config/config.yaml --profile $REGISTRATION_PROFILE",
"publish-index": "cweb-tool publish-index -c ./.cweb-config/config.yaml --profile $REGISTRATION_PROFILE", "publish-index": "cweb-tool publish-index -c ./.cweb-config/config.yaml --profile $REGISTRATION_PROFILE",
"deploy-contracts": "yarn publish-actions", "deploy-contracts": "yarn build:cm && yarn publish-actions",
"call-contracts": "yarn call-contracts:prepare && yarn call-contracts:invoke", "call-contracts": "yarn call-contracts:prepare && yarn call-contracts:invoke",
"call-contracts:prepare": "yarn workspaces foreach --all run prepare-for-package && yarn node ./.cweb-config/create-calls.mjs", "call-contracts:prepare": "yarn workspaces foreach --all run prepare-for-package && yarn node ./.cweb-config/create-calls.mjs",
"call-contracts:invoke": "cweb-tool call .cweb-config/calls.yaml -c ./.cweb-config/config.yaml --profile $REGISTRATION_PROFILE", "call-contracts:invoke": "cweb-tool call .cweb-config/calls.yaml -c ./.cweb-config/config.yaml --profile $REGISTRATION_PROFILE",

View File

@ -32,8 +32,9 @@ export const addWord = async (...[word]: AddWordArgs) => {
const newWord3 = (wordClaim?.body.word ?? '') + '!!!'; const newWord3 = (wordClaim?.body.word ?? '') + '!!!';
const newId3 = hashCode(newWord3); const newId3 = hashCode(newWord3);
storeOp(constructClaim(createWordKey(newId1), { word: newWord1 }, '0x0'));
await Promise.all([ await Promise.all([
storeOp(constructClaim(createWordKey(newId1), { word: newWord1 }, '0x0')),
storeOp(constructClaim(createWordKey(newId2), { word: newWord2 }, '0x0')), storeOp(constructClaim(createWordKey(newId2), { word: newWord2 }, '0x0')),
storeOp(constructClaim(createWordKey(newId3), { word: newWord3 }, '0x0')), storeOp(constructClaim(createWordKey(newId3), { word: newWord3 }, '0x0')),
]); ]);

View File

@ -9,3 +9,11 @@ declare module '@coinweb/contract-kit/dist/esm/context' {
declare module '@coinweb/contract-kit/dist/esm/method' { declare module '@coinweb/contract-kit/dist/esm/method' {
export * from '@coinweb/contract-kit/dist/types/method'; export * from '@coinweb/contract-kit/dist/types/method';
} }
declare module '@coinweb/contract-kit/dist/esm/operations/block' {
export * from '@coinweb/contract-kit/dist/types/operations/block';
}
declare module '@coinweb/contract-kit/dist/esm/operations/call' {
export * from '@coinweb/contract-kit/dist/types/operations/call';
}

View File

@ -2,24 +2,26 @@ import {
Context, Context,
extractContractArgs, extractContractArgs,
NewTx, NewTx,
ResolvedOperation,
getMethodArguments, getMethodArguments,
constructContinueTx, constructContinueTx,
constructContractRef, constructContractRef,
constructDataUnverified,
} from '@coinweb/contract-kit'; } from '@coinweb/contract-kit';
import { getCallParameters, queue } from 'lib/onchain'; import { getCallParameters, queue } from 'lib/onchain';
import { ResolvedOp, Task } from '../types';
import { context, getRawContext, setRawContext } from './context'; import { context, getRawContext, setRawContext } from './context';
import { getAwaitedOps } from './promisifedOps/awaited'; import { getAwaitedOps } from './promisifedOps/awaited';
import { pushResolvedOp } from './promisifedOps/resolved'; import { pushResolvedOp } from './promisifedOps/resolved';
let abortExecution: (() => void) | null = null; let abortExecution: ((result: boolean) => void) | null = null;
const handleState = () => { const handleState = () => {
const ctx = getRawContext(); const ctx = getRawContext();
const resolvedOps = extractContractArgs(ctx.tx); const resolvedOps = extractContractArgs(ctx.tx);
const methodArgs = getMethodArguments(ctx) as [unknown, unknown[], ResolvedOperation[]]; const methodArgs = getMethodArguments(ctx) as [unknown, unknown[], ResolvedOp[]];
const initialArgs = methodArgs[1] ?? []; const initialArgs = methodArgs[1] ?? [];
const previousOps = methodArgs[2] ?? []; const previousOps = methodArgs[2] ?? [];
@ -34,51 +36,85 @@ export const executor =
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
(method: (...args: any[]) => Promise<void>) => (method: (...args: any[]) => Promise<void>) =>
async (ctx: Context): Promise<NewTx[]> => { async (ctx: Context): Promise<NewTx[]> => {
console.log('executor-start');
setRawContext(ctx); setRawContext(ctx);
const { args, methodName, ops } = handleState(); const { args, methodName, ops } = handleState();
const execution = new Promise<void>((resolve, reject) => { const execution = new Promise<boolean>((resolve, reject) => {
abortExecution = resolve; abortExecution = resolve;
method(...args).then(() => resolve(), reject); method(...args).then(
() => {
console.log('executor-resolved');
resolve(true);
},
() => {
console.log('executor-rejected');
reject();
}
);
}); });
//@ts-expect-error //@ts-expect-error
// eslint-disable-next-line @typescript-eslint/no-unsafe-call // eslint-disable-next-line @typescript-eslint/no-unsafe-call
os.setTimeout(() => { os.setTimeout(() => {
abortExecution?.(); abortExecution?.(false);
}, 0); }, 0);
await execution; const isFullyExecuted = await execution;
console.log('executor-executed');
const { authInfo, availableCweb } = getCallParameters(ctx); const { authInfo, availableCweb } = getCallParameters(ctx);
const awaitedOps = getAwaitedOps(); const awaitedOps = getAwaitedOps();
if (!awaitedOps.length) { if (!awaitedOps.length) {
return queue.gateway.unlock(ctx); return [constructContinueTx(ctx, [constructDataUnverified({ isFullyExecuted })]), ...queue.gateway.unlock(ctx)];
} }
const txFee = 700n + BigInt(awaitedOps.length) * 100n; const callArgs: Task[] = [];
if (!isFullyExecuted) {
callArgs.push(awaitedOps.pop()!);
}
if (callArgs[0]?.isBatch) {
while (awaitedOps.at(-1)?.isBatch) {
callArgs.push(awaitedOps.pop()!);
}
}
const callFee = 700n + BigInt(callArgs.length) * 100n;
const opTxFee = awaitedOps.length ? 100n + BigInt(awaitedOps.length) * 100n : 0n;
return [ return [
constructContinueTx( constructContinueTx(
ctx, ctx,
[], awaitedOps.map(({ op }) => op),
[ [
{ {
callInfo: { callInfo: {
ref: constructContractRef(context.issuer, []), ref: constructContractRef(context.issuer, []),
methodInfo: { methodInfo: {
methodName, methodName,
methodArgs: [args, ops], methodArgs: [
args,
[
...ops,
...Array(awaitedOps.length).fill({ SlotOp: 0 } satisfies ResolvedOp),
] satisfies ResolvedOp[],
isFullyExecuted,
callArgs,
awaitedOps,
],
}, },
contractInfo: { contractInfo: {
providedCweb: availableCweb - txFee, providedCweb: availableCweb - callFee - opTxFee,
authenticated: authInfo, authenticated: authInfo,
}, },
contractArgs: awaitedOps, contractArgs: callArgs.map(({ op }) => op),
}, },
}, },
] ]

View File

@ -0,0 +1,34 @@
import { markOpBatch } from './promisifedOps/awaited';
export const opMarker = Symbol('opMarker');
const wrapPromiseUtil =
// eslint-disable-next-line @typescript-eslint/no-explicit-any
<T extends (values: any) => any>(nativePromiseUtil: T): T =>
((values: Parameters<T>) => {
let argsWithMarker = 0;
values.forEach((arg) => {
if (arg instanceof Promise && (arg as Promise<unknown> & { [opMarker]: boolean })[opMarker]) {
argsWithMarker++;
}
});
if (argsWithMarker > 0) {
markOpBatch(argsWithMarker);
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return nativePromiseUtil(values);
}) as T;
const nativePromiseAll = Promise.all.bind(Promise);
const nativePromiseRace = Promise.race.bind(Promise);
const nativePromiseAny = Promise.any.bind(Promise);
const nativePromiseSettled = Promise.allSettled.bind(Promise);
const nativePromiseAllSettled = Promise.allSettled.bind(Promise);
globalThis.Promise.all = wrapPromiseUtil(nativePromiseAll);
globalThis.Promise.race = wrapPromiseUtil(nativePromiseRace);
globalThis.Promise.any = wrapPromiseUtil(nativePromiseAny);
globalThis.Promise.allSettled = wrapPromiseUtil(nativePromiseSettled);
globalThis.Promise.allSettled = wrapPromiseUtil(nativePromiseAllSettled);

View File

@ -1,13 +1,20 @@
import { PreparedOperation } from '@coinweb/contract-kit'; import { PreparedOperation } from '@coinweb/contract-kit';
const awaitedOps: PreparedOperation[] = []; import { Task } from '../../types';
import { getStack } from '../utils';
export const pushAwaitedOp = (op: PreparedOperation | PreparedOperation[]) => { const awaitedOps: Task[] = [];
if (Array.isArray(op)) {
awaitedOps.push(...op); export const pushAwaitedOp = (op: PreparedOperation) => {
} else { const stack = getStack({ skip: 2 });
awaitedOps.push(op);
} awaitedOps.push({ op, stack, isBatch: false });
}; };
export const getAwaitedOps = () => awaitedOps; export const getAwaitedOps = () => awaitedOps;
export const markOpBatch = (count: number) => {
for (let i = 1; i <= count; i++) {
awaitedOps.at(i * -1)!.isBatch = true;
}
};

View File

@ -1,17 +1,29 @@
import { BlockFilter, constructBlock, extractBlock, isResolvedBlock } from '@coinweb/contract-kit'; import { BlockFilter, constructBlock, extractBlock } from '@coinweb/contract-kit';
import { opMarker } from '../../global';
import { isResolvedBlockOp, isResolvedSlotOp } from '../../utils';
import { pushAwaitedOp } from '../awaited'; import { pushAwaitedOp } from '../awaited';
import { shiftResolvedOp } from '../resolved'; import { shiftResolvedOp } from '../resolved';
export const blockOp = (filters: BlockFilter[]) => export const blockOp = (filters: BlockFilter[]) => {
new Promise<[BlockFilter, boolean][] | null>((resolve, reject) => { console.log('blockOp');
let opMarkerValue = false;
const result = new Promise<[BlockFilter, boolean][] | null>((resolve, reject) => {
try { try {
const { op, isOp } = shiftResolvedOp(); const { op, isOp } = shiftResolvedOp();
if (!isOp) { if (!isOp) {
pushAwaitedOp(constructBlock(filters)); pushAwaitedOp(constructBlock(filters));
opMarkerValue = true;
} else { } else {
if (op && !isResolvedBlock(op)) { if (isResolvedSlotOp(op)) {
console.log('blockOp-slotOp');
return;
}
if (!isResolvedBlockOp(op)) {
console.log('blockOp-error');
throw new Error('Block operation not found'); throw new Error('Block operation not found');
} }
@ -23,3 +35,8 @@ export const blockOp = (filters: BlockFilter[]) =>
reject(error); reject(error);
} }
}); });
(result as Promise<[BlockFilter, boolean][] | null> & { [opMarker]: boolean })[opMarker] = opMarkerValue;
return result;
};

View File

@ -1,8 +1,10 @@
import { Claim, ClaimKey, constructRangeRead, extractRead, isResolvedRead } from '@coinweb/contract-kit'; import { Claim, ClaimKey, constructRangeRead, extractRead } from '@coinweb/contract-kit';
import { ClaimRange } from '@coinweb/contract-kit/dist/types/operations/read'; import { ClaimRange } from '@coinweb/contract-kit/dist/types/operations/read';
import { TypedClaim } from '../../../types'; import { TypedClaim } from '../../../types';
import { context } from '../../context'; import { context } from '../../context';
import { opMarker } from '../../global';
import { isResolvedReadOp, isResolvedSlotOp } from '../../utils';
import { pushAwaitedOp } from '../awaited'; import { pushAwaitedOp } from '../awaited';
import { shiftResolvedOp } from '../resolved'; import { shiftResolvedOp } from '../resolved';
@ -11,14 +13,24 @@ export const rangeReadOp = <TClaims extends Claim[] = TypedClaim[]>(
range: ClaimRange, range: ClaimRange,
maxCount: number maxCount: number
) => { ) => {
return new Promise<TClaims | null>((resolve, reject) => { let opMarkerValue = false;
console.log('rangeReadOp');
const result = new Promise<TClaims | null>((resolve, reject) => {
try { try {
const { op, isOp } = shiftResolvedOp(); const { op, isOp } = shiftResolvedOp();
if (!isOp) { if (!isOp) {
pushAwaitedOp(constructRangeRead(context.issuer, firstPart, range, maxCount)); pushAwaitedOp(constructRangeRead(context.issuer, firstPart, range, maxCount));
opMarkerValue = true;
} else { } else {
if (op && !isResolvedRead(op)) { if (isResolvedSlotOp(op)) {
console.log('rangeReadOp-slotOp');
return;
}
if (!isResolvedReadOp(op)) {
console.log('rangeReadOp-error');
throw new Error('Read operation not found'); throw new Error('Read operation not found');
} }
@ -29,4 +41,8 @@ export const rangeReadOp = <TClaims extends Claim[] = TypedClaim[]>(
reject(error); reject(error);
} }
}); });
(result as Promise<TClaims | null> & { [opMarker]: boolean })[opMarker] = opMarkerValue;
return result;
}; };

View File

@ -1,19 +1,31 @@
import { Claim, ClaimKey, constructRead, extractRead, isResolvedRead } from '@coinweb/contract-kit'; import { Claim, ClaimKey, constructRead, extractRead } from '@coinweb/contract-kit';
import { TypedClaim } from '../../../types'; import { TypedClaim } from '../../../types';
import { context } from '../../context'; import { context } from '../../context';
import { opMarker } from '../../global';
import { isResolvedReadOp, isResolvedSlotOp } from '../../utils';
import { pushAwaitedOp } from '../awaited'; import { pushAwaitedOp } from '../awaited';
import { shiftResolvedOp } from '../resolved'; import { shiftResolvedOp } from '../resolved';
export const readOp = <TClaim extends Claim = TypedClaim>(key: ClaimKey) => { export const readOp = <TClaim extends Claim = TypedClaim>(key: ClaimKey) => {
return new Promise<TClaim | null>((resolve, reject) => { console.log('readOp');
let opMarkerValue = false;
const result = new Promise<TClaim | null>((resolve, reject) => {
try { try {
const { op, isOp } = shiftResolvedOp(); const { op, isOp } = shiftResolvedOp();
if (!isOp) { if (!isOp) {
pushAwaitedOp(constructRead(context.issuer, key)); pushAwaitedOp(constructRead(context.issuer, key));
opMarkerValue = true;
} else { } else {
if (op && !isResolvedRead(op)) { if (isResolvedSlotOp(op)) {
console.log('readOp-slotOp');
return;
}
if (!isResolvedReadOp(op)) {
console.log('readOp-error');
throw new Error('Read operation not found'); throw new Error('Read operation not found');
} }
@ -24,4 +36,8 @@ export const readOp = <TClaim extends Claim = TypedClaim>(key: ClaimKey) => {
reject(error); reject(error);
} }
}); });
(result as Promise<TClaim | null> & { [opMarker]: boolean })[opMarker] = opMarkerValue;
return result;
}; };

View File

@ -1,18 +1,30 @@
import { Claim, constructStore, isResolvedStore } from '@coinweb/contract-kit'; import { Claim, constructStore } from '@coinweb/contract-kit';
import { extractStore } from '@coinweb/contract-kit/dist/esm/operations/store'; import { extractStore } from '@coinweb/contract-kit/dist/esm/operations/store';
import { opMarker } from '../../global';
import { isResolvedSlotOp, isResolvedStoreOp } from '../../utils';
import { pushAwaitedOp } from '../awaited'; import { pushAwaitedOp } from '../awaited';
import { shiftResolvedOp } from '../resolved'; import { shiftResolvedOp } from '../resolved';
export const storeOp = (claim: Claim) => export const storeOp = (claim: Claim) => {
new Promise<Claim | null>((resolve, reject) => { console.log('storeOp');
let opMarkerValue = false;
const result = new Promise<Claim | null>((resolve, reject) => {
try { try {
const { op, isOp } = shiftResolvedOp(); const { op, isOp } = shiftResolvedOp();
if (!isOp) { if (!isOp) {
pushAwaitedOp(constructStore(claim)); pushAwaitedOp(constructStore(claim));
opMarkerValue = true;
} else { } else {
if (op && !isResolvedStore(op)) { if (isResolvedSlotOp(op)) {
console.log('storeOp-slotOp');
return;
}
if (!isResolvedStoreOp(op)) {
console.log('storeOp-error');
throw new Error('Store operation not found'); throw new Error('Store operation not found');
} }
@ -24,3 +36,8 @@ export const storeOp = (claim: Claim) =>
reject(error); reject(error);
} }
}); });
(result as Promise<Claim | null> & { [opMarker]: boolean })[opMarker] = opMarkerValue;
return result;
};

View File

@ -1,18 +1,30 @@
import { constructTake, extractTake, isResolvedTake, Claim, ClaimKey } from '@coinweb/contract-kit'; import { Claim, ClaimKey, constructTake, extractTake } from '@coinweb/contract-kit';
import { TypedClaim } from '../../../types'; import { TypedClaim } from '../../../types';
import { opMarker } from '../../global';
import { isResolvedSlotOp, isResolvedTakeOp } from '../../utils';
import { pushAwaitedOp } from '../awaited'; import { pushAwaitedOp } from '../awaited';
import { shiftResolvedOp } from '../resolved'; import { shiftResolvedOp } from '../resolved';
export const takeOp = <TClaim extends Claim = TypedClaim>(key: ClaimKey) => export const takeOp = <TClaim extends Claim = TypedClaim>(key: ClaimKey) => {
new Promise<TClaim | null>((resolve, reject) => { console.log('takeOp');
let opMarkerValue = false;
const result = new Promise<TClaim | null>((resolve, reject) => {
try { try {
const { op, isOp } = shiftResolvedOp(); const { op, isOp } = shiftResolvedOp();
if (!isOp) { if (!isOp) {
pushAwaitedOp(constructTake(key)); pushAwaitedOp(constructTake(key));
opMarkerValue = true;
} else { } else {
if (op && !isResolvedTake(op)) { if (isResolvedSlotOp(op)) {
console.log('takeOp-slotOp');
return;
}
if (!isResolvedTakeOp(op)) {
console.log('takeOp-error');
throw new Error('Take operation not found'); throw new Error('Take operation not found');
} }
@ -23,3 +35,8 @@ export const takeOp = <TClaim extends Claim = TypedClaim>(key: ClaimKey) =>
reject(error); reject(error);
} }
}); });
(result as Promise<TClaim | null> & { [opMarker]: boolean })[opMarker] = opMarkerValue;
return result;
};

View File

@ -1,8 +1,8 @@
import { ResolvedOperation } from '@coinweb/contract-kit'; import { ResolvedOp } from '../../types';
const resolvedOps: ResolvedOperation[] = []; const resolvedOps: ResolvedOp[] = [];
export const pushResolvedOp = (op: ResolvedOperation | ResolvedOperation[]) => { export const pushResolvedOp = (op: ResolvedOp | ResolvedOp[]) => {
if (Array.isArray(op)) { if (Array.isArray(op)) {
resolvedOps.push(...op); resolvedOps.push(...op);
} else { } else {
@ -17,7 +17,7 @@ export const shiftResolvedOp = () =>
}) as }) as
| { | {
isOp: true; isOp: true;
op: ResolvedOperation | null; op: ResolvedOp | null;
} }
| { | {
isOp: false; isOp: false;

View File

@ -0,0 +1,10 @@
export const getStack = ({ skip = 0 }: { skip?: number } = {}) =>
new Error().stack
?.split('\n')
.slice(2 + skip)
.map((line) => {
const match = line.match(/at\s+([^\s(]+)/);
return match ? match[1] : '';
})
.filter((name) => name && name !== 'Promise')
.join('@') || '';

View File

@ -0,0 +1,2 @@
export * from './callstack';
export * from './typeGuards';

View File

@ -0,0 +1,50 @@
import {
CwebStore,
isResolvedBlock,
isResolvedRead,
isResolvedStore,
isResolvedTake,
ResolvedRead,
ResolvedTake,
} from '@coinweb/contract-kit';
import { CwebCallRefResolved, isResolvedCall } from '@coinweb/contract-kit/dist/esm/operations/call';
import { ResolvedBlock } from '@coinweb/contract-kit/dist/types/operations/block';
import { GBlock, GCall, GRead, GStore, GTake } from '@coinweb/contract-kit/dist/types/operations/generics';
import { ResolvedOp, SlotOp } from '../../types';
export const isResolvedSlotOp = (op?: ResolvedOp | null): op is SlotOp => {
console.log('isResolvedSlotOp', JSON.stringify(op));
console.log('isResolvedSlotOp', !!(op && 'SlotOp' in op));
return !!(op && 'SlotOp' in op);
};
export const isResolvedBlockOp = (op?: ResolvedOp | null): op is GBlock<ResolvedBlock> => {
console.log('isResolvedBlockOp', JSON.stringify(op));
console.log('isResolvedBlockOp', !!(op && !isResolvedSlotOp(op) && isResolvedBlock(op)));
return !!(op && !isResolvedSlotOp(op) && isResolvedBlock(op));
};
export const isResolvedStoreOp = (op?: ResolvedOp | null): op is GStore<CwebStore> => {
console.log('isResolvedStoreOp', JSON.stringify(op));
console.log('isResolvedStoreOp', !!(op && !isResolvedSlotOp(op) && isResolvedStore(op)));
return !!(op && !isResolvedSlotOp(op) && isResolvedStore(op));
};
export const isResolvedCallOp = (op?: ResolvedOp | null): op is GCall<CwebCallRefResolved> => {
console.log('isResolvedCallOp', JSON.stringify(op));
console.log('isResolvedCallOp', !!(op && !isResolvedSlotOp(op) && isResolvedCall(op)));
return !!(op && !isResolvedSlotOp(op) && isResolvedCall(op));
};
export const isResolvedTakeOp = (op?: ResolvedOp | null): op is GTake<ResolvedTake> => {
console.log('isResolvedTakeOp', JSON.stringify(op));
console.log('isResolvedTakeOp', !!(op && !isResolvedSlotOp(op) && isResolvedTake(op)));
return !!(op && !isResolvedSlotOp(op) && isResolvedTake(op));
};
export const isResolvedReadOp = (op?: ResolvedOp | null): op is GRead<ResolvedRead> => {
console.log('isResolvedReadOp', JSON.stringify(op));
console.log('isResolvedReadOp', !!(op && !isResolvedSlotOp(op) && isResolvedRead(op)));
return !!(op && !isResolvedSlotOp(op) && isResolvedRead(op));
};

View File

@ -1,4 +1,4 @@
import { Claim, ClaimKey, OrdJson } from '@coinweb/contract-kit'; import { Claim, ClaimKey, OrdJson, PreparedOperation, ResolvedOperation } from '@coinweb/contract-kit';
export type HexBigInt = `0x${string}`; export type HexBigInt = `0x${string}`;
@ -7,3 +7,15 @@ export type TypedClaim<TBody extends OrdJson = OrdJson, TKey extends ClaimKey =
fees_stored: HexBigInt; fees_stored: HexBigInt;
key: TKey; key: TKey;
}; };
export type Task = {
op: PreparedOperation;
stack: string;
isBatch: boolean;
};
export type SlotOp = {
SlotOp: 0;
};
export type ResolvedOp = ResolvedOperation | SlotOp;

View File

@ -9,5 +9,5 @@
"esModuleInterop": true, "esModuleInterop": true,
"types": ["vitest/globals"] "types": ["vitest/globals"]
}, },
"include": ["**/*.ts", "vitest.*.ts", "__tests__", "scripts/publish.js"] "include": ["**/*.ts", "vitest.*.ts", "__tests__", "scripts/publish.js", "src/onchain/utils"]
} }

View File

@ -1,4 +1,4 @@
VITE_API_URL='https://api-cloud.coinweb.io/wallet' VITE_API_URL='https://api-cloud.coinweb.io/wallet'
VITE_EXPLORER_URL='https://explorer.coinweb.io' VITE_EXPLORER_URL='https://explorer.coinweb.io'
VITE_CONTRACT_ADDRESS="0xbaa19b2ee40d26f7d8bcececf9eeaaaed99fa5583527c80bd2c1c6de3753780c" VITE_CONTRACT_ADDRESS="0x049eedf15331c4c39155b286aa6be8ce50a0bcab15eac345913fd084a1f32bdd"

File diff suppressed because one or more lines are too long