Skip to content

Commit

Permalink
🧹 Fix logic to compare compute setting to static counterparts, rather…
Browse files Browse the repository at this point in the history
… than evaluating static ComputeSetting directly (#1108)
  • Loading branch information
QuitCrypto authored Dec 4, 2024
1 parent df08538 commit 486c69d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/eight-llamas-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@layerzerolabs/ua-devtools-evm": patch
---

Fixes an breaking issue when running lz:read:resolve-command with map or reduce compute settings
18 changes: 10 additions & 8 deletions packages/ua-devtools-evm/src/read/commandResolver/compute/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ export class ComputerEVM extends EVMViewFunctionBase implements IComputerEVM {
this.validateComputeSetting(computeSetting)

try {
const mapper = ComputeSetting.OnlyReduce
? (this.logger.info('OnlyReduce setting is used. Skipping map step.'),
(r: RequestResponsePair) => r.response)
: (r: RequestResponsePair) => this.lzMap(compute, r, timeMarker)
const reducer = ComputeSetting.OnlyMap
? (this.logger.info('OnlyMap setting is used. Skipping reduce step.'),
(mappedResponses: string[]) => mappedResponses.join(''))
: (mappedResponses: string[]) => this.lzReduce(compute, cmd, mappedResponses, timeMarker)
const mapper =
computeSetting === ComputeSetting.OnlyReduce
? (this.logger.info('OnlyReduce setting is used. Skipping map step.'),
(r: RequestResponsePair) => r.response)
: (r: RequestResponsePair) => this.lzMap(compute, r, timeMarker)
const reducer =
computeSetting === ComputeSetting.OnlyMap
? (this.logger.info('OnlyMap setting is used. Skipping reduce step.'),
(mappedResponses: string[]) => mappedResponses.join(''))
: (mappedResponses: string[]) => this.lzReduce(compute, cmd, mappedResponses, timeMarker)

const applicative = createDefaultApplicative(this.logger)
const mapped = await applicative(responses.map((r) => () => mapper(r)))
Expand Down

0 comments on commit 486c69d

Please sign in to comment.