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

Dependencies #121

Merged
merged 4 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
"request": "launch",
"type": "node",
"outputCapture": "std"
},
{
"name": "Launch Chrome",
"request": "launch",
"type": "chrome",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}/ui"
}
]
}
14,963 changes: 3,895 additions & 11,068 deletions server/package-lock.json

Large diffs are not rendered by default.

12 changes: 3 additions & 9 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,17 @@
},
"homepage": "https://github.com/hyperledger/firefly-sandbox#readme",
"dependencies": {
"@hyperledger/firefly-sdk": "^1.2.3",
"@hyperledger/firefly-sdk": "^1.3.0",
"body-parser": "^1.20.0",
"class-transformer": "^0.3.1",
"class-validator": "^0.12.2",
"class-validator-jsonschema": "^2.2.0",
"cors": "^2.8.5",
"express": "^4.17.3",
"multer": "^1.4.4",
"nanoid": "^3.3.2",
"npm": "^8.6.0",
"npm": "^10.5.0",
"reflect-metadata": "^0.1.13",
"routing-controllers": "^0.9.0",
"routing-controllers-openapi": "^3.1.0",
"routing-controllers": "^0.10.4",
"run": "^1.4.0",
"start": "^5.1.0",
"strip-indent": "^3.0.0",
"swagger-ui-express": "^4.3.0",
"ws": "^8.5.0"
},
"devDependencies": {
Expand Down
16 changes: 0 additions & 16 deletions server/src/controllers/common.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Get, InternalServerError, JsonController, Param, QueryParam } from 'routing-controllers';
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
import { getFireflyClient } from '../clients/fireflySDKWrapper';
import { FFNamespace, Organization, Plugin, Plugins, Transaction, Verifier } from '../interfaces';
const DEFAULT_NAMESPACE = process.env.FF_DEFAULT_NAMESPACE || 'default';
Expand All @@ -8,11 +7,8 @@ const DEFAULT_NAMESPACE = process.env.FF_DEFAULT_NAMESPACE || 'default';
* Common Operations - API Server
*/
@JsonController('/common')
@OpenAPI({ tags: ['Common'] })
export class CommonController {
@Get('/organizations')
@ResponseSchema(Organization, { isArray: true })
@OpenAPI({ summary: 'List all organizations in network' })
async organizations(
@QueryParam('exclude_self') exclude_self: boolean,
@QueryParam('ns') namespace: string,
Expand All @@ -27,17 +23,13 @@ export class CommonController {
}

@Get('/organizations/self')
@ResponseSchema(Organization)
@OpenAPI({ summary: 'Look up local organization' })
async self(@QueryParam('ns') namespace: string): Promise<Organization> {
const firefly = getFireflyClient(namespace);
const status = await firefly.getStatus();
return { id: status.org?.id, did: status.org?.did, name: status.org?.name };
}

@Get('/verifiers')
@ResponseSchema(Verifier, { isArray: true })
@OpenAPI({ summary: 'List verifiers (such as Ethereum keys) for all organizations in network' })
async verifiers(@QueryParam('ns') namespace: string): Promise<Verifier[]> {
const firefly = getFireflyClient(namespace);
try {
Expand All @@ -64,8 +56,6 @@ export class CommonController {
}

@Get('/verifiers/self')
@ResponseSchema(Verifier, { isArray: true })
@OpenAPI({ summary: 'List verifiers (such as Ethereum keys) for local organization' })
async verifierSelf(@QueryParam('ns') namespace: string): Promise<Verifier[]> {
const firefly = getFireflyClient(namespace);
const status = await firefly.getStatus();
Expand All @@ -80,8 +70,6 @@ export class CommonController {
}

@Get('/plugins')
@ResponseSchema(Plugins)
@OpenAPI({ summary: 'List plugins on the FireFly node' })
async plugins(@QueryParam('ns') namespace: string): Promise<Plugins> {
const firefly = getFireflyClient(namespace);
const status = await firefly.getStatus();
Expand All @@ -92,8 +80,6 @@ export class CommonController {
}

@Get('/transactions/:id')
@ResponseSchema(Transaction)
@OpenAPI({ summary: 'Look up a FireFly transaction by ID' })
async transaction(
@Param('id') id: string,
@QueryParam('ns') namespace: string,
Expand All @@ -107,8 +93,6 @@ export class CommonController {
}

@Get('/firefly/namespaces')
@ResponseSchema(FFNamespace, { isArray: true })
@OpenAPI({ summary: 'Look up FireFly status' })
async ffNamespaces(): Promise<FFNamespace[] | undefined> {
const firefly = getFireflyClient();
const namespaces = await firefly.getNamespaces();
Expand Down
24 changes: 0 additions & 24 deletions server/src/controllers/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
NotFoundError,
QueryParam,
} from 'routing-controllers';
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
import { getFireflyClient } from '../clients/fireflySDKWrapper';
import { formatTemplate, quoteAndEscape as q } from '../utils';
import {
Expand All @@ -26,17 +25,9 @@ import {
* Smart Contracts - API Server
*/
@JsonController('/contracts')
@OpenAPI({ tags: ['Smart Contracts'] })
export class ContractsController {
@Post('/interface')
@HttpCode(202)
@ResponseSchema(AsyncResponse)
@OpenAPI({
summary: 'Define a new contract interface',
description:
'Schema may be in <a href="https://hyperledger.github.io/firefly/reference/firefly_interface_format">FFI</a> ' +
'or <a href="https://docs.ethers.io/v5/api/utils/abi/formats/#abi-formats--solidity">Solidity JSON ABI</a> format. ',
})
async createInterface(
@Body() body: ContractInterface,
@QueryParam('ns') namespace: string,
Expand All @@ -57,8 +48,6 @@ export class ContractsController {

@Post('/api')
@HttpCode(202)
@ResponseSchema(AsyncResponse)
@OpenAPI({ summary: 'Define a new contract API' })
async createAPI(
@Body() body: ContractAPI,
@QueryParam('ns') namespace: string,
Expand All @@ -80,8 +69,6 @@ export class ContractsController {

@Post('/apifabric')
@HttpCode(202)
@ResponseSchema(AsyncResponse)
@OpenAPI({ summary: 'Define a new contract API with Fabric' })
async createAPIFabric(
@Body() body: ContractAPI,
@QueryParam('ns') namespace: string,
Expand All @@ -103,8 +90,6 @@ export class ContractsController {
}

@Get('/interface')
@ResponseSchema(ContractInterfaceLookup, { isArray: true })
@OpenAPI({ summary: 'List contract interfaces' })
async getContractInterfaces(
@QueryParam('ns') namespace: string,
): Promise<ContractInterfaceLookup[]> {
Expand All @@ -114,8 +99,6 @@ export class ContractsController {
}

@Get('/api')
@ResponseSchema(ContractAPILookup, { isArray: true })
@OpenAPI({ summary: 'List contract APIs' })
async getAPIs(@QueryParam('ns') namespace: string): Promise<ContractAPILookup[]> {
const firefly = getFireflyClient(namespace);
const apis = await firefly.getContractAPIs();
Expand All @@ -127,8 +110,6 @@ export class ContractsController {
}

@Get('/api/:name')
@ResponseSchema(ContractAPILookup)
@OpenAPI({ summary: 'Get contract API details' })
async getAPI(
@Param('name') name: string,
@QueryParam('ns') namespace: string,
Expand All @@ -148,8 +129,6 @@ export class ContractsController {
}

@Get('/api/:name/listener')
@ResponseSchema(ContractListenerLookup, { isArray: true })
@OpenAPI({ summary: 'List contract API listeners' })
async getAPIListeners(
@Param('name') name: string,
@QueryParam('ns') namespace: string,
Expand All @@ -170,8 +149,6 @@ export class ContractsController {
}

@Post('/listener')
@ResponseSchema(ContractListenerLookup)
@OpenAPI({ summary: 'Create a new contract listener' })
async createListener(
@Body() body: ContractListener,
@QueryParam('ns') namespace: string,
Expand Down Expand Up @@ -201,7 +178,6 @@ export class ContractsController {
* For demonstration purposes only.
*/
@JsonController('/contracts/template')
@OpenAPI({ tags: ['Smart Contracts'] })
export class ContractsTemplateController {
@Get('/interface')
interfaceTemplate() {
Expand Down
9 changes: 0 additions & 9 deletions server/src/controllers/datatypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
NotFoundError,
QueryParam,
} from 'routing-controllers';
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
import { getFireflyClient } from '../clients/fireflySDKWrapper';
import { AsyncResponse, DatatypeInterface } from '../interfaces';
import { formatTemplate, quoteAndEscape as q } from '../utils';
Expand All @@ -17,20 +16,15 @@ import { formatTemplate, quoteAndEscape as q } from '../utils';
* Datatypes - API Server
*/
@JsonController('/datatypes')
@OpenAPI({ tags: ['Datatypes'] })
export class DatatypesController {
@Get()
@ResponseSchema(DatatypeInterface, { isArray: true })
@OpenAPI({ summary: 'List all datatypes' })
async getAllDatatypes(@QueryParam('ns') namespace: string): Promise<DatatypeInterface[]> {
const firefly = getFireflyClient(namespace);
const datatypes = await firefly.getDatatypes();
return datatypes.map((d) => ({ id: d.id, name: d.name, version: d.version, schema: d.value }));
}

@Get('/:name/:version')
@ResponseSchema(DatatypeInterface)
@OpenAPI({ summary: 'List datatype by name and version' })
async getAPI(
@Param('name') name: string,
@Param('version') version: string,
Expand All @@ -51,8 +45,6 @@ export class DatatypesController {

@Post()
@HttpCode(202)
@ResponseSchema(AsyncResponse)
@OpenAPI({ summary: 'Creates and broadcasts a new datatype' })
async createDatatype(
@Body() body: DatatypeInterface,
@QueryParam('ns') namespace: string,
Expand All @@ -69,7 +61,6 @@ export class DatatypesController {
}

@JsonController('/datatypes/template')
@OpenAPI({ tags: ['Datatypes'] })
export class DatatypesTemplateController {
@Get()
createDatatypeTemplate() {
Expand Down
14 changes: 0 additions & 14 deletions server/src/controllers/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ import {
Redirect,
QueryParam,
} from 'routing-controllers';
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
import { Request } from 'express';
import { plainToClassFromExist } from 'class-transformer';
import { getFireflyClient } from '../clients/fireflySDKWrapper';
import {
formatTemplate,
quoteAndEscape as q,
FormDataSchema,
getBroadcastMessageBody,
getPrivateMessageBody,
EmptyVal,
Expand All @@ -33,12 +31,9 @@ import {
* Messages - API Server
*/
@JsonController('/messages')
@OpenAPI({ tags: ['Messages'] })
export class MessagesController {
@Post('/broadcast')
@HttpCode(202)
@ResponseSchema(AsyncResponse)
@OpenAPI({ summary: 'Send a FireFly broadcast with an inline value' })
async broadcast(
@Body() body: BroadcastValue,
@QueryParam('ns') namespace: string,
Expand All @@ -51,9 +46,6 @@ export class MessagesController {

@Post('/broadcastblob')
@HttpCode(202)
@FormDataSchema(BroadcastBlob)
@ResponseSchema(AsyncResponse)
@OpenAPI({ summary: 'Send a FireFly broadcast with a binary blob' })
async broadcastblob(
@Req() req: Request,
@UploadedFile('file') file: Express.Multer.File,
Expand All @@ -69,8 +61,6 @@ export class MessagesController {

@Post('/private')
@HttpCode(202)
@ResponseSchema(AsyncResponse)
@OpenAPI({ summary: 'Send a FireFly private message with an inline value' })
async send(
@Body() body: PrivateValue,
@QueryParam('ns') namespace: string,
Expand All @@ -83,9 +73,6 @@ export class MessagesController {

@Post('/privateblob')
@HttpCode(202)
@FormDataSchema(PrivateBlob)
@ResponseSchema(AsyncResponse)
@OpenAPI({ summary: 'Send a FireFly private message with a binary blob' })
async sendblob(
@Req() req: Request,
@UploadedFile('file') file: Express.Multer.File,
Expand All @@ -106,7 +93,6 @@ export class MessagesController {
* For demonstration purposes only.
*/
@JsonController('/messages/template')
@OpenAPI({ tags: ['Messages'] })
export class MessagesTemplateController {
@Get('/broadcast')
broadcastTemplate() {
Expand Down
Loading
Loading