Skip to content

Commit

Permalink
feat(cu): add caller to action passed from each interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
TillaTheHun0 committed Oct 4, 2023
1 parent e529036 commit 7d017f0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
23 changes: 12 additions & 11 deletions servers/cu/src/domain/client/warp-sequencer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { fromPromise, of } from 'hyper-async'
import {
__,
applySpec,
assoc,
complement,
Expand Down Expand Up @@ -256,16 +255,18 @@ export function loadInteractionsWith (
*/
map(applySpec({
sortKey: prop('sortKey'),
action: pipe(
path(['tags']),
// { first: tag, second: tag }
reduce((a, t) => assoc(t.name, t.value, a), {}),
// "{\"function\": \"balance\"}"
prop('Input'),
// { function: "balance" }
(input) => JSON.parse(input),
assoc('input', __, {})
),
action: applySpec({
input: pipe(
path(['tags']),
// { first: tag, second: tag }
reduce((a, t) => assoc(t.name, t.value, a), {}),
// "{\"function\": \"balance\"}"
prop('Input'),
// { function: "balance" }
(input) => JSON.parse(input)
),
caller: path(['owner', 'address'])
}),
/**
* TODO: is this the right layer to be mapping this?
* Should it be done in BL, or is it the responsibility of the client?
Expand Down
1 change: 1 addition & 0 deletions servers/cu/src/domain/client/warp-sequencer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe('warp-sequencer', () => {
const [firstInteraction] = res
assert.ok(firstInteraction.action)
assert.ok(firstInteraction.action.input.function)
assert.ok(firstInteraction.action.caller)
assert.ok(firstInteraction.sortKey)
assert.ok(firstInteraction.SWGlobal)
// attach contract meta to SWGlobal
Expand Down
6 changes: 3 additions & 3 deletions servers/cu/src/domain/lib/readState/load-actions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ describe('load-actions', () => {
const loadActions = loadActionsWith({
loadInteractions: async ({ id, from, to }) => ([
{
action: { input: { function: 'createOrder' } },
action: { input: { function: 'createOrder' }, caller: 'caller-123' },
sortKey: 'abcd,123,fsdf',
SWGlobal
},
{
action: { input: { function: 'createOrder' } },
action: { input: { function: 'createOrder' }, caller: 'caller-456' },
sortKey: 'fdsa,456,cdskjfs',
SWGlobal
}
Expand Down Expand Up @@ -72,7 +72,7 @@ describe('load-actions', () => {
const loadActionsNoSortKey = loadActionsWith({
loadInteractions: async ({ id, from, to }) => ([
{
action: { input: { function: 'createOrder' } },
action: { input: { function: 'createOrder' }, caller: 'caller-123' },
noSortKey: 'abcd,123,fsdf'
}
]),
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 @@ -4,7 +4,8 @@ export const interactionSchema = z.object({
action: z.object({
input: z.object({
function: z.string()
}).passthrough()
}).passthrough(),
caller: z.string()
}).passthrough(),
sortKey: z.string(),
SWGlobal: z.object({
Expand Down

0 comments on commit 7d017f0

Please sign in to comment.