Skip to content

Commit

Permalink
feat(cu): add process tags to AoGlobal.process.tags #192
Browse files Browse the repository at this point in the history
  • Loading branch information
TillaTheHun0 committed Dec 11, 2023
1 parent 33674f6 commit 49b8083
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
8 changes: 4 additions & 4 deletions servers/cu/src/domain/client/ao-su.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const loadMessagesWith = ({ fetch, SU_URL, logger: _logger, pageSize }) =
return tag.value
}

function mapAoMessage ({ processId, processOwner }) {
function mapAoMessage ({ processId, processOwner, processTags }) {
return async function * (edges) {
for await (const edge of edges) {
yield pipe(
Expand Down Expand Up @@ -185,7 +185,7 @@ export const loadMessagesWith = ({ fetch, SU_URL, logger: _logger, pageSize }) =
timestamp: path(['block', 'timestamp'])
}),
AoGlobal: applySpec({
process: always({ id: processId, owner: processOwner }),
process: always({ id: processId, owner: processOwner, tags: processTags }),
block: applySpec({
height: path(['block', 'height']),
timestamp: path(['block', 'timestamp'])
Expand All @@ -200,10 +200,10 @@ export const loadMessagesWith = ({ fetch, SU_URL, logger: _logger, pageSize }) =
return (args) =>
of(args)
.map(mapBounds)
.map(({ processId, owner: processOwner, from, to }) => {
.map(({ processId, owner: processOwner, tags: processTags, from, to }) => {
return pipeline(
fetchAllPages({ processId, from, to }),
Transform.from(mapAoMessage({ processId, processOwner })),
Transform.from(mapAoMessage({ processId, processOwner, processTags })),
(err) => {
if (err) logger('Encountered err when mapping Sequencer Messages', err)
}
Expand Down
1 change: 1 addition & 0 deletions servers/cu/src/domain/lib/loadMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ function loadSequencedMessagesWith ({ loadMessages, loadBlocksMeta, logger }) {
.chain(args => loadMessages({
processId: args.id,
owner: args.owner,
tags: args.tags,
from: args.from, // could be undefined
to: args.to // could be undefined
}))
Expand Down
17 changes: 12 additions & 5 deletions servers/cu/src/domain/lib/loadProcess.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ function getProcessMetaWith ({ loadProcess, findProcess, saveProcess, logger })
: Rejected(`Tag '${name}' of value '${tags[name]}' was not valid on transaction`)

/**
* Load the process from chain, extracting the metadata,
* Load the process from the SU, extracting the metadata,
* and then saving to the db
*
* TODO: could we eventually load all of this from the SU?
* for now, just loading Block, since that's the only bit that doesn't finalize
*/
function loadFromSu (processId) {
return loadProcess(processId)
Expand Down Expand Up @@ -136,8 +133,18 @@ function loadLatestEvaluationWith ({ findLatestEvaluation, logger }) {
* is always added to context
*/
const ctxSchema = z.object({
/**
* The wallet address of of the process owner
*/
owner: z.string().min(1),
/**
* The tags on the process
*/
tags: z.array(rawTagSchema),
/**
* The block height and timestamp, according to the SU,
* that was most recent when this process was spawned
*/
block: rawBlockSchema,
/**
* The most recent state. This could be the most recent
Expand Down Expand Up @@ -199,7 +206,7 @@ export function loadProcessWith (env) {
.chain(ctx =>
loadLatestEvaluation(ctx)
.map(mergeRight(ctx))
// { id, owner, ..., buffer, result, from, evaluatedAt }
// { id, owner, tags, ..., buffer, result, from, evaluatedAt }
)
.map(ctxSchema.parse)
.map(logger.tap('Loaded process and appended to ctx'))
Expand Down
3 changes: 2 additions & 1 deletion servers/cu/src/domain/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ export const messageSchema = z.object({
AoGlobal: z.object({
process: z.object({
id: z.string(),
owner: z.string()
owner: z.string(),
tags: z.array(rawTagSchema)
}),
block: rawBlockSchema
// TODO: more here
Expand Down

0 comments on commit 49b8083

Please sign in to comment.