Skip to content

Commit

Permalink
fix: fetch block data for sortKey on viewState evaluation - lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
asiaziola committed Mar 4, 2024
1 parent 40f4f45 commit a192e10
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
18 changes: 12 additions & 6 deletions src/contract/HandlerBasedContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -850,12 +851,17 @@ export class HandlerBasedContract<State> implements Contract<State> {
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;
Expand Down
12 changes: 1 addition & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2442,17 +2442,7 @@ arweave-stream-tx@^1.1.0:
dependencies:
exponential-backoff "^3.1.0"

[email protected]:
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:
[email protected], 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==
Expand Down

0 comments on commit a192e10

Please sign in to comment.