diff --git a/servers/cu/src/domain/client/ao-su.js b/servers/cu/src/domain/client/ao-su.js index 3696d0295..4b452e3e2 100644 --- a/servers/cu/src/domain/client/ao-su.js +++ b/servers/cu/src/domain/client/ao-su.js @@ -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( @@ -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']) @@ -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) } diff --git a/servers/cu/src/domain/lib/loadMessages.js b/servers/cu/src/domain/lib/loadMessages.js index 6559cbbb7..0920fc379 100644 --- a/servers/cu/src/domain/lib/loadMessages.js +++ b/servers/cu/src/domain/lib/loadMessages.js @@ -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 })) diff --git a/servers/cu/src/domain/lib/loadProcess.js b/servers/cu/src/domain/lib/loadProcess.js index bda517074..1b670ab84 100644 --- a/servers/cu/src/domain/lib/loadProcess.js +++ b/servers/cu/src/domain/lib/loadProcess.js @@ -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) @@ -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 @@ -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')) diff --git a/servers/cu/src/domain/model.js b/servers/cu/src/domain/model.js index de5d4805d..c2fa22ff7 100644 --- a/servers/cu/src/domain/model.js +++ b/servers/cu/src/domain/model.js @@ -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