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

Feat/XRPL connector v2 #128

Merged
merged 45 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
bb9e7df
Updating .gitignore.
Danilo-Araujo-Silva Feb 17, 2023
df59dad
Add XRPL & XRPLDEX connector (v1)
mlguys Feb 17, 2023
8ed27ad
add unified clob swagger schema
mlguys Feb 27, 2023
f01cf29
Fix swagger missing field error for get orderbook
mlguys Mar 1, 2023
14d0e87
update yarn lock
mlguys Mar 24, 2023
b0a0bc1
wip
mlguys Jun 1, 2023
22b585c
WIP
mlguys Jun 4, 2023
a820ae3
WIP
mlguys Jun 6, 2023
f2a2bbc
Add order tracker logic wip
mlguys Jun 6, 2023
b1411d7
Finish connecter and add routes test
mlguys Jun 8, 2023
ad5704a
Remove old implementation and disable comments
mlguys Jun 8, 2023
8ba3776
Remove artifacts
mlguys Jun 8, 2023
3f49fba
Move order tracker to chain directory
mlguys Jun 8, 2023
b2b589e
add space
mlguys Jun 8, 2023
056e212
WIP
mlguys Jun 9, 2023
0af5945
Add basic e2e test scripts + fix bugs
mlguys Jun 26, 2023
6609840
Finish order posting and cancelling scenario test
mlguys Jun 27, 2023
1111b27
Finish fixing order tracking
mlguys Jun 30, 2023
4547c7e
merge development + fix test cases
mlguys Jul 14, 2023
d7844c8
Add tracking fills
mlguys Jul 26, 2023
edc2d9c
add orderhash to filldata
mlguys Jul 27, 2023
1737d24
fix balances chain endpoint for xrpl
mlguys Aug 1, 2023
32d96ea
update getTokens endpoint
mlguys Aug 1, 2023
7c81471
add get midprice for a market
mlguys Aug 2, 2023
a6f1a2b
fix getTokens
mlguys Aug 2, 2023
be86ef0
Fix bugs
mlguys Aug 8, 2023
8443ba3
fix getting order status & trading fees
mlguys Aug 10, 2023
d941a4e
Prepare PR WIP
mlguys Aug 11, 2023
7d48910
polish test cases
mlguys Aug 11, 2023
7e79813
fix getting order from db
mlguys Aug 15, 2023
67e6cb6
rebase latest changes
mlguys Aug 22, 2023
b08cf97
Remove network.routes.ts
mlguys Aug 22, 2023
e4d7778
Fix test errors on CI/CD
mlguys Aug 29, 2023
7b98601
fix client not disconect on close
mlguys Aug 29, 2023
2a8a778
fix tests
mlguys Aug 29, 2023
a05c732
Merge branch 'development' into feat/xrpl-connector-v2
mlguys Aug 29, 2023
0c74069
Merge branch 'development' into feat/xrpl-connector-v2
mlguys Aug 30, 2023
ceec75f
remove swagger doc changes
mlguys Sep 7, 2023
ba86d93
Merge branch 'development' into feat/xrpl-connector-v2
mlguys Sep 7, 2023
6280dff
Merge branch 'development' into feat/xrpl-connector-v2
mlguys Nov 10, 2023
a1a1ef5
fix UNKNOW state due to double offer cancel
mlguys Nov 10, 2023
8a2c1e2
Merge branch 'development' into feat/xrpl-connector-v2
mlguys Nov 10, 2023
b84f8d7
update test
mlguys Nov 11, 2023
6f6bd8f
update yarn
mlguys Nov 13, 2023
d35d850
Merge branch 'development' into feat/xrpl-connector-v2
mlguys Nov 14, 2023
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/dist
/db
/.idea
/*.iml
package-lock.json
/certs
/coverage
Expand All @@ -13,4 +14,4 @@ package-lock.json

# VSCode
.vscode/
.history
.history
63 changes: 25 additions & 38 deletions docs/swagger/definitions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'goerli'
example: 'kovan'
mlguys marked this conversation as resolved.
Show resolved Hide resolved

NonceResponse:
type: 'object'
Expand Down Expand Up @@ -70,7 +70,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'goerli'
example: 'kovan'

AllowancesResponse:
type: 'object'
Expand Down Expand Up @@ -189,7 +189,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'goerli'
example: 'kovan'

ApproveResponse:
type: 'object'
Expand Down Expand Up @@ -243,7 +243,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'goerli'
example: 'kovan'

PollResponse:
type: 'object'
Expand Down Expand Up @@ -328,7 +328,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'goerli'
example: 'kovan'

PriceResponse:
type: 'object'
Expand Down Expand Up @@ -418,7 +418,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'goerli'
example: 'kovan'
connector:
type: 'string'
example: 'uniswap'
Expand Down Expand Up @@ -496,7 +496,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'goerli'
example: 'kovan'

CancelResponse:
type: 'object'
Expand All @@ -518,32 +518,19 @@ definitions:
type: 'string'
example: '0xa321bbe8888c3bc88ecb1ad4f03f22a71e6f5715dfcb19e0a2dca9036c981b6d' # noqa: documentation

AddWalletRequest:
GetWalletRequest:
type: 'object'
required:
- 'chainName'
- 'privateKey'
properties:
chainName:
type: 'string'
example: 'ethereum'
privateKey:
type: 'string'
example: '6078d949c953351685fd2026646028f2a862e6148d25d504967ba63898d720c0' # noqa: documentation

RemoveWalletRequest:
type: 'object'
required:
- 'chainName'
- 'address'
- 'chain'
- 'network'
properties:
chainName:
chain:
type: 'string'
example: 'ethereum'
address:
network:
type: 'string'
example: '0xd0A1E359811322d97991E03f863a0C30C2cF029C'

example: 'testnet'
GetWalletResponse:
type: 'object'
required:
Expand Down Expand Up @@ -639,7 +626,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'goerli'
example: 'kovan'
connector:
type: 'string'
example: 'uniswap'
Expand Down Expand Up @@ -715,7 +702,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'goerli'
example: 'kovan'
connector:
type: 'string'
example: 'uniswapLP'
Expand All @@ -735,7 +722,7 @@ definitions:
properties:
network:
type: 'string'
example: 'goerli'
example: 'kovan'
timestamp:
type: 'integer'
example: 1636368085740
Expand Down Expand Up @@ -781,7 +768,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'goerli'
example: 'kovan'
connector:
type: 'string'
example: 'uniswapLP'
Expand All @@ -800,7 +787,7 @@ definitions:
properties:
network:
type: 'string'
example: 'goerli'
example: 'kovan'
timestamp:
type: 'integer'
example: 1636368085740
Expand Down Expand Up @@ -843,7 +830,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'goerli'
example: 'kovan'
connector:
type: 'string'
example: 'uniswapLP'
Expand All @@ -862,7 +849,7 @@ definitions:
properties:
network:
type: 'string'
example: 'goerli'
example: 'kovan'
timestamp:
type: 'integer'
example: 1636368085740
Expand Down Expand Up @@ -897,7 +884,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'goerli'
example: 'kovan'
connector:
type: 'string'
example: 'uniswapLP'
Expand All @@ -920,7 +907,7 @@ definitions:
properties:
network:
type: 'string'
example: 'goerli'
example: 'kovan'
timestamp:
type: 'integer'
example: 1636368085740
Expand Down Expand Up @@ -984,7 +971,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'goerli'
example: 'kovan'
connector:
type: 'string'
example: 'uniswapLP'
Expand All @@ -1002,7 +989,7 @@ definitions:
properties:
network:
type: 'string'
example: 'goerli'
example: 'kovan'
timestamp:
type: 'integer'
example: 1636368085740
Expand Down
12 changes: 11 additions & 1 deletion docs/swagger/wallet-routes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ paths:
operationId: 'get'
produces:
- 'application/json'
parameters:
- in: 'body'
name: 'body'
required: true
schema:
$ref: '#/definitions/GetWalletRequest'
responses:
'200':
description: 'Wallet list'
Expand All @@ -27,7 +33,11 @@ paths:
required: true
schema:
$ref: '#/definitions/AddWalletRequest'
responses: '200'
responses:
'200':
description: 'Added wallet address'
schema:
$ref: '#/definitions/AddWalletResponse'

/wallet/remove:
delete:
Expand Down
65 changes: 65 additions & 0 deletions docs/swagger/xrpl-routes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
paths:
mlguys marked this conversation as resolved.
Show resolved Hide resolved
/xrpl:
get:
tags:
- 'xrpl'
summary: 'View the XRPL network and RPC URL that gateway is configured to use'
description: 'The user can change this by editing src/chains/xrpl/xrpl.config.ts'
operationId: 'root'
produces:
- 'application/json'
parameters:
- in: 'body'
name: 'body'
required: true
schema:
$ref: '#/definitions/XRPLConfigRequest'
responses:
'200':
description: 'XRPL config'
schema:
$ref: '#/definitions/XRPLConfigResponse'

/xrpl/balances:
get:
tags:
- 'xrpl'
summary: 'Get the balances of an XRPL secret key'
operationId: 'balances'
consumes:
- 'application/json'
produces:
- 'application/json'
parameters:
- in: 'body'
name: 'body'
required: true
schema:
$ref: '#/definitions/XRPLBalancesRequest'
responses:
'200':
description: 'XRPL wallet balances'
schema:
$ref: '#/definitions/XRPLBalancesResponse'

/xrpl/poll:
get:
tags:
- 'xrpl'
summary: 'Get transaction details from transaction hash'
operationId: 'poll'
consumes:
- 'application/json'
produces:
- 'application/json'
parameters:
- in: 'body'
name: 'body'
required: true
schema:
$ref: '#/definitions/XRPLPollRequest'
responses:
'200':
description: 'XRPL transaction details'
schema:
$ref: '#/definitions/XRPLPollResponse'
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"express": "^4.17.1",
"express-winston": "^4.1.0",
"fs-extra": "^10.0.0",
"http-status-codes": "^2.2.0",
"js-yaml": "^4.1.0",
"level": "^8.0.0",
"lodash": "^4.17.21",
Expand All @@ -95,6 +96,7 @@
"winston": "^3.3.3",
"winston-daily-rotate-file": "^4.5.5",
"xsswap-sdk": "^1.0.1",
"xrpl": "^2.7.0",
"yarn": "^1.22.17"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const startGateway = async () => {
Math.random().toString(16).substr(2, 14)
);
}
logger.info(`Gateway Version: ${gateway_version}`) // display gateway version
logger.info(`Gateway Version: ${gateway_version}`); // display gateway version
logger.info(`⚡️ Starting Gateway API on port ${port}...`);
if (ConfigManagerV2.getInstance().get('server.unsafeDevModeWithHTTP')) {
logger.info('Running in UNSAFE HTTP! This could expose private keys.');
Expand Down
24 changes: 24 additions & 0 deletions src/chains/xrpl/xrpl-middlewares.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { HttpException } from '../../services/error-handler';
import { XRPL } from './xrpl';
import { NextFunction, Request, Response } from 'express';

export const verifyXRPLIsAvailable = async (
req: Request,
_res: Response,
next: NextFunction
) => {
if (!req || !req.body || !req.body.network) {
throw new HttpException(404, 'No XRPL network informed.');
}

const xrpl = await XRPL.getInstance(req.body.network);
if (!xrpl.ready) {
await xrpl.init();
}

if (!xrpl.isConnected()) {
await xrpl.client.connect();
}

return next();
};
Loading