Skip to content

Commit c15f94a

Browse files
committed
fix(cu): split mapNode into msg and process types
1 parent c4cf0e7 commit c15f94a

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

servers/cu/src/effects/hb/index.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const isHashChainValidWith = ({ hashChain }) => async (prev, scheduled) =
6363
return expected === actual
6464
}
6565

66-
export const mapNode = pipe(
66+
export const mapNode = (type) => pipe(
6767
juxt([
6868
// derived from assignment
6969
pipe(
@@ -149,10 +149,15 @@ export const mapNode = pipe(
149149
* So checking for any other field, like 'Owner' should tell us
150150
* whether this is an assignment of data on-chain or not.
151151
*/
152-
isAssignment: pipe(
153-
path(['message', 'Target']),
154-
(m) => isNil(m) || isEmpty(m)
155-
)
152+
isAssignment: type === 'message'
153+
? pipe(
154+
path(['message', 'Owner']),
155+
isNil
156+
)
157+
: pipe(
158+
path(['message', 'Target']),
159+
(m) => isNil(m) || isEmpty(m)
160+
)
156161
}),
157162
// static
158163
always({ Cron: false })
@@ -213,7 +218,7 @@ export const loadProcessWith = ({ fetch, logger }) => {
213218
})
214219
.then(resToJson)
215220
.then(nodeAt(0))
216-
.then(mapNode)
221+
.then(mapNode('process'))
217222
.then(applySpec({
218223
owner: applySpec({
219224
address: path(['message', 'Owner']),
@@ -450,7 +455,7 @@ export const loadMessagesWith = ({ hashChain, fetch, logger: _logger, pageSize }
450455
/**
451456
* Map to the expected shape
452457
*/
453-
mapNode,
458+
mapNode('message'),
454459
(scheduled) => {
455460
scheduled.AoGlobal = AoGlobal
456461
return scheduled
@@ -537,7 +542,7 @@ export const loadMessageMetaWith = ({ fetch, logger }) => {
537542
})
538543
.then(resToJson)
539544
.then(nodeAt(0))
540-
.then(mapNode)
545+
.then(mapNode('message'))
541546
.then(applySpec({
542547
timestamp: path(['message', 'Timestamp']),
543548
nonce: path(['message', 'Nonce']),

servers/cu/src/effects/hb/index.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe('hb-su', () => {
4848
}
4949

5050
test('should map a scheduled message', () => {
51-
const res = mapNode({
51+
const res = mapNode('message')({
5252
message: {
5353
Id: messageId,
5454
Owner: 'owner-123',
@@ -88,7 +88,7 @@ describe('hb-su', () => {
8888
})
8989

9090
describe('should map an assignment tx', () => {
91-
const res = mapNode({
91+
const res = mapNode('message')({
9292
message: {
9393
Id: assignedMessageId
9494
},

0 commit comments

Comments
 (0)