From a192e1042b0c84be67252f7a18a746daf19878e9 Mon Sep 17 00:00:00 2001 From: Asia Date: Mon, 4 Mar 2024 15:34:49 +0100 Subject: [PATCH] fix: fetch block data for sortKey on viewState evaluation - lint fixes --- src/contract/HandlerBasedContract.ts | 18 ++++++++++++------ yarn.lock | 12 +----------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/contract/HandlerBasedContract.ts b/src/contract/HandlerBasedContract.ts index 5625fffb..cc725491 100644 --- a/src/contract/HandlerBasedContract.ts +++ b/src/contract/HandlerBasedContract.ts @@ -45,6 +45,7 @@ import { ContractInteractionState } from './states/ContractInteractionState'; import { Buffer, Crypto } from 'warp-isomorphic'; import { VrfPluginFunctions } from '../core/WarpPlugin'; import { createData, DataItem, Signer, tagsExceedLimit } from 'warp-arbundles'; +import { BlockData } from 'arweave/node/blocks'; interface InteractionManifestData { [path: string]: string; @@ -850,12 +851,17 @@ export class HandlerBasedContract implements Contract { let executionContext = await this.createExecutionContext(this._contractTxId, sortKey, true, undefined, signal); const blockHeight = sortKey ? await this._sorter.extractBlockHeight(sortKey) : undefined; - const currentBlockData = - this.warp.environment == 'mainnet' && !(this.warp.interactionsLoader.type() === 'arweave') - ? await this._arweaveWrapper.warpGwBlock() - : blockHeight - ? await arweave.blocks.getByHeight(blockHeight) - : await arweave.blocks.getCurrent(); + + let currentBlockData: BlockData; + if (this.warp.environment == 'mainnet' && !(this.warp.interactionsLoader.type() === 'arweave')) { + currentBlockData = await this._arweaveWrapper.warpGwBlock(); + } else { + if (blockHeight) { + currentBlockData = await arweave.blocks.getByHeight(blockHeight); + } else { + currentBlockData = await arweave.blocks.getCurrent(); + } + } // add caller info to execution context let effectiveCaller; diff --git a/yarn.lock b/yarn.lock index 321c9b44..44f2518d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2442,17 +2442,7 @@ arweave-stream-tx@^1.1.0: dependencies: exponential-backoff "^3.1.0" -arweave@1.13.7: - version "1.13.7" - resolved "https://registry.yarnpkg.com/arweave/-/arweave-1.13.7.tgz#cda8534c833baec372a7052c61f53b4e39a886d7" - integrity sha512-Hv+x2bSI6UyBHpuVbUDMMpMje1ETfpJWj52kKfz44O0IqDRi/LukOkkDUptup1p6OT6KP1/DdpnUnsNHoskFeA== - dependencies: - arconnect "^0.4.2" - asn1.js "^5.4.1" - base64-js "^1.5.1" - bignumber.js "^9.0.2" - -arweave@^1.10.13, arweave@^1.10.23, arweave@^1.10.5, arweave@^1.11.4, arweave@^1.13.7: +arweave@1.14.4, arweave@^1.10.13, arweave@^1.10.23, arweave@^1.10.5, arweave@^1.11.4, arweave@^1.13.7: version "1.14.4" resolved "https://registry.yarnpkg.com/arweave/-/arweave-1.14.4.tgz#5ba22136aa0e7fd9495258a3931fb770c9d6bf21" integrity sha512-tmqU9fug8XAmFETYwgUhLaD3WKav5DaM4p1vgJpEj/Px2ORPPMikwnSySlFymmL2qgRh2ZBcZsg11+RXPPGLsA==