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

fix/ add XRPL testnet fix to staging #261

Merged
merged 9 commits into from
Dec 26, 2023
1 change: 1 addition & 0 deletions src/chains/xrpl/xrpl.controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export class XRPLController {
validateXRPLPollRequest(req);

const initTime = Date.now();
await xrplish.ensureConnection();
const currentLedgerIndex = await xrplish.getCurrentLedgerIndex();
const txData = await xrplish.getTransaction(req.txHash);
const txStatus = await xrplish.getTransactionStatusCode(txData);
Expand Down
18 changes: 11 additions & 7 deletions src/chains/xrpl/xrpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,17 @@ export class XRPL implements XRPLish {

async getReserveInfo() {
await this.ensureConnection();
const reserveInfoResp = await this._client.request({
command: 'server_info',
});
this._reserveBaseXrp =
reserveInfoResp.result.info.validated_ledger?.reserve_base_xrp ?? 0;
this._reserveIncrementXrp =
reserveInfoResp.result.info.validated_ledger?.reserve_inc_xrp ?? 0;
try {
const reserveInfoResp = await this._client.request({
command: 'server_info',
});
this._reserveBaseXrp =
reserveInfoResp.result.info.validated_ledger?.reserve_base_xrp ?? 0;
this._reserveIncrementXrp =
reserveInfoResp.result.info.validated_ledger?.reserve_inc_xrp ?? 0;
} catch (error) {
throw new Error("Can't get reserve info: " + String(error));
}
}

public get chain(): string {
Expand Down
8 changes: 8 additions & 0 deletions src/templates/lists/xrpl_markets_testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,39 @@
"id": 1,
"marketId": "SOLO-XRP",
"baseIssuer": "rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN",
"baseCode": "534F4C4F00000000000000000000000000000000",
"quoteIssuer": "",
"quoteCode": "XRP",
"baseTokenID": 3,
"quoteTokenID": 0
},
{
"id": 2,
"marketId": "SOLO-USD",
"baseIssuer": "rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN",
"baseCode": "534F4C4F00000000000000000000000000000000",
"quoteIssuer": "rh8LssQyeBdEXk7Zv86HxHrx8k2R2DBUrx",
"quoteCode": "USD",
"baseTokenID": 3,
"quoteTokenID": 2
},
{
"id": 3,
"marketId": "USD-XRP",
"baseIssuer": "rh8LssQyeBdEXk7Zv86HxHrx8k2R2DBUrx",
"baseCode": "USD",
"quoteIssuer": "",
"quoteCode": "XRP",
"baseTokenID": 2,
"quoteTokenID": 0
},
{
"id": 4,
"marketId": "USD-VND",
"baseIssuer": "rh8LssQyeBdEXk7Zv86HxHrx8k2R2DBUrx",
"baseCode": "USD",
"quoteIssuer": "rh8LssQyeBdEXk7Zv86HxHrx8k2R2DBUrx",
"quoteCode": "VND",
"baseTokenID": 2,
"quoteTokenID": 1
}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/lists/xrpl_tokens_testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
{
"id": 3,
"code": "SOLO",
"code": "534F4C4F00000000000000000000000000000000",
"issuer": "rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN",
"title": "Sologenic",
"trustlines": 999,
Expand Down
4 changes: 2 additions & 2 deletions src/templates/xrpl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ networks:
marketListSource: "/home/gateway/conf/lists/xrpl_markets_devnet.json"
nativeCurrencySymbol: "XRP"
network: "xrpl"
requestTimeout: 2000
connectionTimeout: 2000
requestTimeout: 5000
connectionTimeout: 5000
feeCushion: 1.2
maxFeeXRP: "2"
orderDbPath: "db/xrpl.level"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Wallet } from 'xrpl';
import { XRPL } from '../../../src/chains/xrpl/xrpl';
import { XRPLCLOB } from '../../../src/connectors/xrpl/xrpl';
import { getsSequenceNumberFromTxn } from '../../../src/connectors/xrpl/xrpl.utils';
import { patch, unpatch } from '../../services/patch';
import { patch, unpatch } from '../../../test/services/patch';
import { Order } from '../../../src/connectors/xrpl/xrpl.types';

let xrpl: XRPL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { XRPL } from '../../../src/chains/xrpl/xrpl';
import { XRPLCLOB } from '../../../src/connectors/xrpl/xrpl';
import {} from '../../../src/chains/xrpl/xrpl.order-tracker';
import { Order } from '../../../src/connectors/xrpl/xrpl.types';
import { patch, unpatch } from '../../services/patch';
import { patch, unpatch } from '../../../test/services/patch';

let xrpl: XRPL;
let xrplCLOB: XRPLCLOB;
Expand Down Expand Up @@ -293,6 +293,7 @@ beforeAll(async () => {
// eslint-disable-next-line @typescript-eslint/no-empty-function
beforeEach(() => {
patchConnect();
patchGetReserveInfo();
patchFee();
patchOrderTracking();
patchCurrentBlockNumber();
Expand Down Expand Up @@ -403,6 +404,12 @@ const patchGasPrices = () => {
});
};

const patchGetReserveInfo = () => {
patch(xrpl, 'getReserveInfo', async () => {
return Promise.resolve();
});
};

describe('GET /clob/markets', () => {
it('should return 200 with proper request', async () => {
patchMarkets();
Expand Down
Loading