Skip to content

Commit

Permalink
Merge pull request #722 from eea-oasis/feature/698-merkelize-payload
Browse files Browse the repository at this point in the history
Feature/698 merkelize payload
  • Loading branch information
ognjenkurtic authored Aug 11, 2023
2 parents ce1f588 + e2d0a70 commit c5612c6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/bri-3/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Transaction } from '../models/transaction';
import { TransactionStatus } from '../models/transactionStatus.enum';
import { TransactionStorageAgent } from './transactionStorage.agent';
import { TransactionAgent } from './transactions.agent';
import { MerkleTreeService } from '../../merkleTree/services/merkleTree.service';

let transactionAgent: TransactionAgent;

Expand All @@ -20,6 +21,8 @@ const workstepStorageAgentMock: DeepMockProxy<WorkstepStorageAgent> =
const workflowStorageAgentMock: DeepMockProxy<WorkflowStorageAgent> =
mockDeep<WorkflowStorageAgent>();
const authAgentMock: DeepMockProxy<AuthAgent> = mockDeep<AuthAgent>();
const merkleTreeServiceMock: DeepMockProxy<MerkleTreeService> =
mockDeep<MerkleTreeService>();

// TODO: Setup of this test data below is what should be handled in a separate file where we mock only prisma.client
// and implement various test data scenarios that can be selected with a single line of code.
Expand Down Expand Up @@ -77,6 +80,7 @@ beforeAll(async () => {
workstepStorageAgentMock,
workflowStorageAgentMock,
authAgentMock,
merkleTreeServiceMock,
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
import { Transaction } from '../models/transaction';
import { TransactionStatus } from '../models/transactionStatus.enum';

import { Workstep } from '@prisma/client';
import { AuthAgent } from '../../auth/agent/auth.agent';
import { BpiSubjectAccount } from '../../identity/bpiSubjectAccounts/models/bpiSubjectAccount';
import { WorkflowStorageAgent } from '../../workgroup/workflows/agents/workflowsStorage.agent';
Expand All @@ -17,6 +16,8 @@ import {
UPDATE_WRONG_STATUS_ERR_MESSAGE,
} from '../api/err.messages';
import { TransactionStorageAgent } from './transactionStorage.agent';
import { MerkleTreeService } from '../../merkleTree/services/merkleTree.service';
import { Workstep } from '../../workgroup/worksteps/models/workstep';

@Injectable()
export class TransactionAgent {
Expand All @@ -25,6 +26,7 @@ export class TransactionAgent {
private workstepStorageAgent: WorkstepStorageAgent,
private workflowStorageAgent: WorkflowStorageAgent,
private authAgent: AuthAgent,
private merkleTreeService: MerkleTreeService,
) {}

public throwIfCreateTransactionInputInvalid() {
Expand Down Expand Up @@ -166,7 +168,7 @@ export class TransactionAgent {
tx: Transaction,
workstep: Workstep,

Check warning on line 169 in examples/bri-3/src/bri/transactions/agents/transactions.agent.ts

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 16.17.0)

'workstep' is defined but never used
): Promise<boolean> {
// TODO: #698 Merkelize transaction payload
this.merkleTreeService.merkelizePayload(JSON.parse(tx.payload), 'sha256');
// TODO: #701 Fetch circuit attached to the workstep
// TODO: #701 Prepare circuit inputs and execute
// TODO: #701 Return merkelized payload and witness
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { CreateTransactionDto } from './dtos/request/createTransaction.dto';
import { UpdateTransactionDto } from './dtos/request/updateTransaction.dto';
import { NOT_FOUND_ERR_MESSAGE } from './err.messages';
import { TransactionController } from './transactions.controller';
import { MerkleTreeService } from '../../merkleTree/services/merkleTree.service';

describe('TransactionController', () => {
let controller: TransactionController;
Expand Down Expand Up @@ -83,6 +84,7 @@ describe('TransactionController', () => {
WorkstepStorageAgent,
WorkflowStorageAgent,
AuthAgent,
MerkleTreeService,
],
})
.overrideProvider(TransactionStorageAgent)
Expand Down
2 changes: 2 additions & 0 deletions examples/bri-3/src/bri/transactions/transactions.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { GetTransactionByIdQueryHandler } from './capabilities/getTransactionByI
import { UpdateTransactionCommandHandler } from './capabilities/updateTransaction/updateTransactionCommand.handler';
import { TransactionsProfile } from './transactions.profile';
import { AuthModule } from '../auth/auth.module';
import { MerkleModule } from '../merkleTree/merkle.module';

export const CommandHandlers = [
CreateTransactionCommandHandler,
Expand All @@ -32,6 +33,7 @@ export const QueryHandlers = [
WorkstepModule,
WorkflowModule,
AuthModule,
MerkleModule,
],
controllers: [TransactionController],
providers: [
Expand Down

0 comments on commit c5612c6

Please sign in to comment.