diff --git a/src/core/modules/impl/TagsParser.ts b/src/core/modules/impl/TagsParser.ts index 753acb14..a9a53f8a 100644 --- a/src/core/modules/impl/TagsParser.ts +++ b/src/core/modules/impl/TagsParser.ts @@ -118,4 +118,10 @@ export class TagsParser { return t.name == WARP_TAGS.REQUEST_VRF && t.value === 'true'; }); } + + hasInteractWriteTag(interaction: GQLNodeInterface, contractTxId: string): boolean { + return interaction.tags.some((t) => { + return t.name == WARP_TAGS.INTERACT_WRITE && t.value === contractTxId; + }); + } } diff --git a/src/core/modules/impl/handler/AbstractContractHandler.ts b/src/core/modules/impl/handler/AbstractContractHandler.ts index b3ad6e40..3aa5ca07 100644 --- a/src/core/modules/impl/handler/AbstractContractHandler.ts +++ b/src/core/modules/impl/handler/AbstractContractHandler.ts @@ -6,9 +6,12 @@ import { SmartWeaveGlobal } from '../../../../legacy/smartweave-global'; import { LoggerFactory } from '../../../../logging/LoggerFactory'; import { deepCopy } from '../../../../utils/utils'; import { ContractError, HandlerApi, InteractionData, InteractionResult } from '../HandlerExecutorFactory'; +import { TagsParser } from '../TagsParser'; +import { Contract } from '../../../../contract/Contract'; export abstract class AbstractContractHandler implements HandlerApi { protected logger = LoggerFactory.INST.create('ContractHandler'); + private readonly tagsParser = new TagsParser(); protected constructor( protected readonly swGlobal: SmartWeaveGlobal, @@ -46,30 +49,39 @@ export abstract class AbstractContractHandler implements HandlerApi(input, this.swGlobal._activeTx, executionContext.signal); + const result = await calleeContract.applyInput(input, activeTx, executionContext.signal); - this.logger.debug('Cache result?:', !this.swGlobal._activeTx.dry); + this.logger.debug('Cache result?:', !activeTx.dry); const shouldAutoThrow = - result.type !== 'ok' && - effectiveThrowOnError && - (!this.swGlobal._activeTx.dry || (this.swGlobal._activeTx.dry && this.swGlobal._activeTx.strict)); + result.type !== 'ok' && effectiveThrowOnError && (!activeTx.dry || (activeTx.dry && activeTx.strict)); const effectiveErrorMessage = shouldAutoThrow ? `Internal write auto error for call [${JSON.stringify(debugData)}]: ${result.errorMessage}` @@ -78,7 +90,7 @@ export abstract class AbstractContractHandler implements HandlerApi implements HandlerApi implements HandlerApi, target: string): boolean { + let current = contract as Contract; + while (current.parent()) { + current = current.parent(); + if (current.txId() === target) { + return true; + } + } + + return false; + } }