Commit graph

42 commits

Author SHA1 Message Date
James Taylor
ad3fd7e832 Update retry logic
Previously transactions were only retried after being successfully endorsed, and always with the same transaction ID

Transactions will now be added to a queue for processing and will also be retried if endorsement fails (with a different transaction id for invalid transactions)

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:23 +00:00
James Taylor
0456a9e94c Move error related functions to errors.ts
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:23 +00:00
James Taylor
fd269237d4 Add comments to fabric.ts
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:23 +00:00
James Taylor
00a2dea50b Add block event listener config
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:23 +00:00
James Taylor
f1a9fea77d Fix lint errors
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:23 +00:00
James Taylor
e6738818e5 Update readmes
Move usage instructions to the node sample directory and add overview/next steps
to top level readme

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:23 +00:00
sapthasurendran
9aec7ffd2a Clear Transaction when no contract found
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:23 +00:00
James Taylor
bf91df7ef3 Update transaction retry to use correct user
Also improves test coverage

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:21 +00:00
James Taylor
82b1249f4e Improve Docker support
- default command should be start, rather than start:dev in the docker image
- added a multistage build
- fixed node-gyp error
- removed dev dependencies
- added a start:dotenv script to support a .env file in production (may be useful for
k8s later)
- updated Readme and generateEnv script to simplify the setup
- updated external network in docker-compose.yaml to match the test network

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:21 +00:00
James Taylor
5d1adddd03 Refactor health routes in to separate file
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:21 +00:00
James Taylor
45683b2a1a Simplify fabric code
Attempt to make fabric code easier to document

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:21 +00:00
James Taylor
862080773e Initial API tests
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:21 +00:00
sapthasurendran
6477333743 redis mock class
code cleanup

created fabric.spec

redis testcases and additional checks

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:21 +00:00
James Taylor
f904adbf6f Add config spec tests
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:20 +00:00
James Taylor
e81a7a8b46 Update port number config
Discovered that env-var will validate port numbers, which is nice

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:20 +00:00
sapthasurendran
5bea58e501 retry condition moved to startretryloop
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:20 +00:00
sapthasurendran
b8509490ad retry count check
build err fix

retry condition testcase

retryCount to maxRetryCount

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:18 +00:00
sapthasurendran
73049e0153 docker file for app
readme update for docker

added dockerignore

added dumb-init

env var added to compose

readme update

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:17 +00:00
James Taylor
4277f4a68f Fix dist output
The jest.config.ts file was causing unintended changes to the dist folder

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:15 +00:00
James Taylor
9f48a42418 Initial test framework
Add Jest test framework

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:15 +00:00
sapthasurendran
9ae66c76da switch gateway based on user org
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

initialized fabric components to global app const

getcontractforOrg for transaction router

removed org and reused identityOrg1

env.sample file update

liveness api update

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:15 +00:00
James Taylor
05f7026e58 Update api key header
Use more common X-Api-Key header with no prefix

Also updates Unauthorized response to include a json error body
and simplifies working with new API key via curl and the vscode
rest client

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:13 +00:00
sapthasurendran
c3a34ef559 apikey auth for Org1
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

removed auth check from live,ready apis..

code format

http file changes for apikey

comments for getting api key

readme update for apikey usage

replaced -H with --header

apikey config made mandatory

fix linting

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:13 +00:00
sapthasurendran
d4318c381a liveness
used fabric protos insted of blockdecoder

changed import statement

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

revert back eslintrc

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

function name change

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

format changes

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:12 +00:00
sapthasurendran
fc769cfcb0 event handler strategy changes
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:11 +00:00
sapthasurendran
31b08b9151 removed txn commit event handler
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:10 +00:00
sapthasurendran
5d6e916436 changed getContract arg
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:09 +00:00
sapthasurendran
550e95f091 Added blockEvent handler
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:05 +00:00
sapthasurendran
804f4a6468 added getNetwork functionality
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:00 +00:00
James Taylor
19e28d817b Fix retry
Adding multiple contracts had broken the retry loop

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:57 +00:00
James Taylor
432da5defd Add get transaction endpoint
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
60aedf1b82 Refactor transaction logic
Remove duplication and handle errors from the asset transfer smart contract

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
400367e8a6 Add get all assets endpoint
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
d810128fcd Add patch endpoint
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
8250359db6 Add delete and put endpoints
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
8ebca62b40 Fix lint errors
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
f06f1eed4b Update logging
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
3b50404763 Initial create asset logic
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
324f1c8683 Specify query handler strategy
Avoid load on a single peer by specifying the PREFER_MSPID_SCOPE_ROUND_ROBIN
strategy

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
9c98450946 Initial asset route
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
1f8bc889cf Enable alwaysStrict compile option
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
063b21dd3f Initial REST API skeleton
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00