61 lines
2.2 KiB
TypeScript
61 lines
2.2 KiB
TypeScript
import { implement } from "@conusai-kit/core"
|
|
import * as c from "../contract/index.js"
|
|
import { operationKey, recordBalanced, transition } from "../core/index.js"
|
|
import { ledgerServiceOf } from "./service.js"
|
|
export const LEDGER_PROCEDURES = [
|
|
implement(c.accounts, ({ ctx, input }) => ledgerServiceOf(ctx.container, ctx.kind).accounts(input.after)),
|
|
implement(c.account, ({ ctx, input }) => ledgerServiceOf(ctx.container, ctx.kind).account(input.accountId)),
|
|
implement(c.balances, ({ ctx, input }) =>
|
|
ledgerServiceOf(ctx.container, ctx.kind).balances(input.accountId, input.after),
|
|
),
|
|
implement(c.entries, ({ ctx, input }) =>
|
|
ledgerServiceOf(ctx.container, ctx.kind).entries(input.accountId, input.after),
|
|
),
|
|
implement(c.transactions, ({ ctx, input }) => ledgerServiceOf(ctx.container, ctx.kind).transactions(input.after)),
|
|
implement(c.transaction, ({ ctx, input }) =>
|
|
ledgerServiceOf(ctx.container, ctx.kind).transaction(input.transactionId),
|
|
),
|
|
implement(c.verify, ({ ctx }) => ledgerServiceOf(ctx.container, ctx.kind).verify()),
|
|
implement(c.createAccount, ({ ctx, input }) =>
|
|
ledgerServiceOf(ctx.container, "effect").createAccount(input, operationKey("account", input.requestId)),
|
|
),
|
|
implement(c.updateAccount, ({ ctx, input }) =>
|
|
ledgerServiceOf(ctx.container, "effect").updateAccount(
|
|
input.accountId,
|
|
input,
|
|
input.expectedVersion,
|
|
operationKey("account-update", input.requestId),
|
|
),
|
|
),
|
|
implement(c.record, ({ ctx, input }) =>
|
|
recordBalanced(ledgerServiceOf(ctx.container, "effect"), input.terms, input.requestId),
|
|
),
|
|
implement(c.post, ({ ctx, input }) =>
|
|
transition(
|
|
ledgerServiceOf(ctx.container, "effect"),
|
|
"post",
|
|
input.transactionId,
|
|
input.expectedVersion,
|
|
input.requestId,
|
|
),
|
|
),
|
|
implement(c.voidTransaction, ({ ctx, input }) =>
|
|
transition(
|
|
ledgerServiceOf(ctx.container, "effect"),
|
|
"void",
|
|
input.transactionId,
|
|
input.expectedVersion,
|
|
input.requestId,
|
|
),
|
|
),
|
|
implement(c.reverse, ({ ctx, input }) =>
|
|
transition(
|
|
ledgerServiceOf(ctx.container, "effect"),
|
|
"reverse",
|
|
input.transactionId,
|
|
input.expectedVersion,
|
|
input.requestId,
|
|
),
|
|
),
|
|
]
|