Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transaction group item info #550

Merged
merged 4 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions back-end/apps/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
FROM node:alpine AS development
FROM node:22-alpine AS development

WORKDIR /usr/src/app

COPY package.json ./
COPY pnpm-lock.yaml ./
COPY tsconfig.json tsconfig.json
COPY nest-cli.json nest-cli.json

Expand All @@ -15,14 +16,15 @@ RUN pnpm install && cd apps/api && pnpm install

RUN pnpm run build api

FROM node:alpine AS production
FROM node:22-alpine AS production

ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}

WORKDIR /usr/src/app

COPY package.json ./
COPY pnpm-lock.yaml ./

RUN npm install -g pnpm

Expand Down
4 changes: 2 additions & 2 deletions back-end/apps/api/src/auth/auth-requests.http
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ content-type: application/json
}

### Log in remote
POST https://34.49.46.8/auth/login
POST https://hederatransactiontool.com/auth/login
content-type: application/json

{
Expand All @@ -38,7 +38,7 @@ POST http://localhost:3000/auth/signout
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjEsImVtYWlsIjoiam9obkB0ZXN0LmNvbSIsImlhdCI6MTcxMDc3NDAzNywiZXhwIjoxNzEwODEwMDM3fQ.h_NwgTMmancbf-ifAlOtH9SuGGqf6MW4COjbryIp14s

### Update password for current user
PATCH http://localhost:3001/auth/change-password
PATCH https://hederatransactiontool.com/auth/change-password
content-type: application/json

{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Expose } from 'class-transformer';

export class TransactionGroupItemDto {
@Expose()
transactionId: number;

@Expose()
groupId: number;

@Expose()
seq: number;
}
5 changes: 5 additions & 0 deletions back-end/apps/api/src/transactions/dto/transaction.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { TransactionStatus, TransactionType } from '@entities';
import { TransactionSignerUserKeyDto } from './transaction-signer.dto';
import { TransactionApproverDto } from './transaction-approver.dto';
import { TransactionObserverDto } from './transaction-observer.dto';
import { TransactionGroupItemDto } from './transaction-group-item.dto';

export class TransactionDto {
@Expose()
Expand Down Expand Up @@ -54,6 +55,10 @@ export class TransactionDto {
@Transform(({ obj }) => (obj.creatorKey ? obj.creatorKey.id : undefined))
@Expose()
creatorKeyId: number;

@Expose()
@Type(() => TransactionGroupItemDto)
groupItem: TransactionGroupItemDto;
}

export class TransactionFullDto extends TransactionDto {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,30 @@
GET http://localhost:3000/transaction-groups

### Create a transaction group
POST http://localhost:3000/transaction-groups
POST http://localhost:3001/transaction-groups
content-type: application/json

{"description":"transaction - [email protected]","atomic":false,"groupItems":[{"seq":0,"transaction":{"name":"first","type":"ACCOUNT CREATE","description":"first account create transaction","body":"0x0a8b012a88010a83010a180a0b08c981e4b2061080a0c21e12070800100018d20918001206080010001802188084af5f220308b401320274785a510a221220d3ef6b5fcf45025d011c18bea660cc0add0d35d4f6c9d4a24e70c4ceba49224b1080b68ce92d30ffffffffffffffff7f38ffffffffffffffff7f40004a050880ceda036a0361636370008801011200","status":"NEW","creatorKeyId":2,"signature":"0x3c7f7f30cfa781a01fbf9a6ba1195d31d9581a3a2805ee742e483b9e4e8001a7521895eb7680123477fffee3bf522fc8ec24a46bb7d67c96311e8125f951f801","validStart":"2024-05-30T22:42:17.064Z","cutoffAt":"2024-05-30T22:45:17.064Z"}}]}
{
"description":"transaction - [email protected]",
"atomic":false,
"groupItems":
[
{"seq":0,
"transaction":
{
"name":"New Account Create Transaction",
"type":"ACCOUNT CREATE",
"description":"first account create transaction",
"body":"0a88012a85010a80010a170a0808f085a7c406100012090800100018ac98a30118001206080010001803188084af5f220308b40132005a510a221220d3ef6b5fcf45025d011c18bea660cc0add0d35d4f6c9d4a24e70c4ceba49224b108084af5f30ffffffffffffffff7f38ffffffffffffffff7f40004a050880ceda036a0668656c6c6f218801011200",
"status":"WAITING FOR SIGNATURES",
"network":"testnet",
"creatorKeyId":2,
"signature":"8d5e5b31cc3ee2c1b1e8443422ca13a8b211ffed4a9c0eea590835835aab15ae88204b1f6fb60b3cb7198b46a08a121a820e4c65a5a350f565e6b92ae035e405",
"validStart":"2024-06-27T16:02:00.000Z"
}
}
]
}

### Delete a transaction group
DELETE http://localhost:3000/transaction-groups/13
13 changes: 7 additions & 6 deletions back-end/apps/api/src/transactions/transactions-requests.http
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
### Get transactions created by User
GET http://localhost:3000/transactions
GET http://localhost:3001/transactions?page=1&size=10

### Get transactions to be signed by User
GET http://localhost:3000/transactions/sign?take=10&skip=0
GET http://localhost:3001/transactions/sign?page=1&size=10

### Get transactions to be approved by User
GET http://localhost:3000/transactions/approve?take=10&skip=0
GET http://localhost:3001/transactions/approve?page=1&size=10

### Get transactions to be observed by User
GET http://localhost:3000/transactions/observe?take=10&skip=0
GET http://localhost:3001/transactions/observe?page=1&size=10

### Get transaction by Id
GET http://localhost:3000/transactions/2
GET http://localhost:3001/transactions/5

### Create a transaction
POST http://34.36.90.246/transactions
POST http://localhost:3001/transactions
content-type: application/json

{
Expand All @@ -24,6 +24,7 @@ content-type: application/json
"body": "0x0a8b012a88010a83010a170a0b08a1b78ab20610c0c8e722120608001000187b180012060800100018021880c2d72f220308b401320274785a520a221220d3ef6b5fcf45025d011c18bea660cc0add0d35d4f6c9d4a24e70c4ceba49224b1080c0d590830130ffffffffffffffff7f38ffffffffffffffff7f40004a050880ceda036a0361636370008801011200",
"status": "NEW",
"creatorKeyId": 2,
"network": "testnet",
"signature": "0xfb228df4984c1d7bd0d6a915683350c2179f5436fc242d394a625f805c25061a50d9922448e88891a2dd6f9933f155c4b3a47195cfbf54a04597bd67ec27670f",
"validStart": "1999-12-11T11:00:00.000Z",
"cutoffAt": "1999-12-11T11:00:00.000Z"
Expand Down
4 changes: 2 additions & 2 deletions back-end/apps/api/src/transactions/transactions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class TransactionsService {

const transaction = await this.repo.findOne({
where: { id },
relations: ['creatorKey', 'creatorKey.user', 'observers', 'observers.user', 'comments'],
relations: ['creatorKey', 'creatorKey.user', 'observers', 'observers.user', 'comments', 'groupItem'],
});

if (!transaction) return null;
Expand Down Expand Up @@ -451,7 +451,7 @@ export class TransactionsService {
async getTransactionWithVerifiedAccess(transactionId: number, user: User) {
const transaction = await this.repo.findOne({
where: { id: transactionId },
relations: ['creatorKey', 'creatorKey.user', 'observers'],
relations: ['creatorKey', 'creatorKey.user', 'observers', 'groupItem'],
});

if (!transaction) throw new NotFoundException('Transaction not found');
Expand Down
2 changes: 2 additions & 0 deletions back-end/apps/chain/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM node:alpine AS development
WORKDIR /usr/src/app

COPY package.json ./
COPY pnpm-lock.yaml ./
COPY tsconfig.json tsconfig.json
COPY nest-cli.json nest-cli.json

Expand All @@ -23,6 +24,7 @@ ENV NODE_ENV=${NODE_ENV}
WORKDIR /usr/src/app

COPY package.json ./
COPY pnpm-lock.yaml ./

RUN npm install -g pnpm

Expand Down
2 changes: 2 additions & 0 deletions back-end/apps/notifications/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM node:alpine AS development
WORKDIR /usr/src/app

COPY package.json ./
COPY pnpm-lock.yaml ./
COPY tsconfig.json tsconfig.json
COPY nest-cli.json nest-cli.json

Expand All @@ -23,6 +24,7 @@ ENV NODE_ENV=${NODE_ENV}
WORKDIR /usr/src/app

COPY package.json ./
COPY pnpm-lock.yaml ./

RUN npm install -g pnpm

Expand Down
12 changes: 6 additions & 6 deletions back-end/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,39 @@ steps:
[
'build',
'-t',
'us-south1-docker.pkg.dev/transaction-tool-dev/api/development',
'gcr.io/transaction-tool-dev/api',
'-f',
'apps/api/Dockerfile',
'.'
]
- name: 'gcr.io/cloud-builders/docker'
args:
['push', 'us-south1-docker.pkg.dev/transaction-tool-dev/api/development']
['push', 'gcr.io/transaction-tool-dev/api']
# Chain service
- name: 'gcr.io/cloud-builders/docker'
args:
[
'build',
'-t',
'us-south1-docker.pkg.dev/transaction-tool-dev/chain/development',
'gcr.io/transaction-tool-dev/chain',
'-f',
'apps/chain/Dockerfile',
'.'
]
- name: 'gcr.io/cloud-builders/docker'
args:
['push', 'us-south1-docker.pkg.dev/transaction-tool-dev/chain/development']
['push', 'gcr.io/transaction-tool-dev/chain']
# Notifications service
- name: 'gcr.io/cloud-builders/docker'
args:
[
'build',
'-t',
'us-south1-docker.pkg.dev/transaction-tool-dev/notifications/development',
'gcr.io/transaction-tool-dev/notifications',
'-f',
'apps/notifications/Dockerfile',
'.'
]
- name: 'gcr.io/cloud-builders/docker'
args:
['push', 'us-south1-docker.pkg.dev/transaction-tool-dev/notifications/development']
['push', 'gcr.io/transaction-tool-dev/notifications']
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import { Column, Entity, JoinColumn, ManyToOne, OneToOne, PrimaryColumn } from 'typeorm';
import { Column, Entity, JoinColumn, ManyToOne, OneToOne, PrimaryColumn, RelationId } from 'typeorm';
import { TransactionGroup, Transaction } from './';

@Entity()
export class TransactionGroupItem {
@Column()
seq: number;

// I believe this is required in addition to transaction because it is the primary column
// This is required in addition to transaction because it is the primary column
@PrimaryColumn()
transactionId: number;

// This is added to allow for the groupId to be returned with the transaction
@Column()
groupId: number;

@OneToOne(() => Transaction, transaction => transaction.groupItem)
@JoinColumn()
transaction: Transaction;

@ManyToOne(() => TransactionGroup, group => group.groupItems)
group: TransactionGroup;

@RelationId((groupItem: TransactionGroupItem) => groupItem.group)
groupId: number;
}
Loading