Skip to content
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
3 changes: 2 additions & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "tsc"
},
"dependencies": {
"@stellar/stellar-sdk": "^14.5.0",
"@stellar/stellar-sdk": "^16.0.1",
"buffer": "6.0.3"
},
"devDependencies": {
Expand All @@ -18,3 +18,4 @@
"main": "./src/index.ts",
"types": "./src/index.ts"
}

16 changes: 9 additions & 7 deletions packages/types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,13 +570,15 @@ export interface Client {
* Construct and simulate a version transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
* Returns the contract version.
*
* # Returns
* The contract's version number, currently `1`.
* This is a read-only view function: it does not write to ledger storage
* and costs only the base invocation fee. The UI calls this before
* submitting transactions to confirm it is compatible with the deployed
* contract.
*
* # Panics
* Does not panic.
* # Returns
* A [`String`] in the form `"MAJOR.MINOR.PATCH"` (e.g. `"1.0.0"`).
*/
version: (options?: MethodOptions) => Promise<AssembledTransaction<u32>>
version: (options?: MethodOptions) => Promise<AssembledTransaction<string>>

/**
* Construct and simulate a has_role transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
Expand Down Expand Up @@ -1940,7 +1942,7 @@ export class Client extends ContractClient {
public readonly fromJSON = {
get_fee: this.txFromJSON<i128>,
upgrade: this.txFromJSON<Result<void>>,
version: this.txFromJSON<u32>,
version: this.txFromJSON<string>,
has_role: this.txFromJSON<boolean>,
unfreeze: this.txFromJSON<Result<void>>,
get_price: this.txFromJSON<Result<PriceData>>,
Expand Down Expand Up @@ -2020,4 +2022,4 @@ export class Client extends ContractClient {
route_payments_with_swap: this.txFromJSON<Result<i128>>,
route_payment_with_swap_raw: this.txFromJSON<Result<void>>
}
}
}
1 change: 1 addition & 0 deletions stellar-payment-platform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"@opentelemetry/resources": "^1.30.1",
"@opentelemetry/sdk-node": "^0.52.1",
"@prisma/client": "^6.19.3",
"@prisma/extension-read-replicas": "^0.4.0",
"@prisma/instrumentation": "^6.19.3",
"@sentry/node": "^10.68.0",
"@simplewebauthn/server": "^10.0.0",
Expand Down
15 changes: 13 additions & 2 deletions stellar-payment-platform/prismaClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,20 @@ try {
throw new Error('DATABASE_URL is not set');
}
const { PrismaClient } = require('@prisma/client');
prisma = new PrismaClient();
const basePrisma = new PrismaClient();

if (process.env.DATABASE_READ_URL) {
const { readReplicas } = require('@prisma/extension-read-replicas');
prisma = basePrisma.$extends(
readReplicas({
url: process.env.DATABASE_READ_URL,
})
);
} else {
prisma = basePrisma;
}
} catch (err) {
logger.warn('Prisma client not found. Using fallback mock for tests.');
logger.warn('Prisma client not found or extension missing. Using fallback mock for tests.', err);
prisma = {
user: {
update: async () => {
Expand Down
17 changes: 15 additions & 2 deletions stellar-payment-platform/src/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,23 @@ const pool = new Pool({
connectionTimeoutMillis: 10000,
});

const readPool = process.env.DATABASE_READ_URL ? new Pool({
connectionString: process.env.DATABASE_READ_URL,
max: parseInt(process.env.DB_READ_POOL_MAX, 10) || parseInt(process.env.DB_POOL_MAX, 10) || 10,
idleTimeoutMillis: 30000,
connectionTimeoutMillis: 10000,
}) : pool;

pool.on('error', (err) => {
logger.error(err, 'Unexpected error on idle PostgreSQL client');
});

if (readPool !== pool) {
readPool.on('error', (err) => {
logger.error(err, 'Unexpected error on idle PostgreSQL read client');
});
}

(async () => {
if (process.env.NODE_ENV === 'test') {
logger.warn('PostgreSQL schema init skipped in test environment');
Expand Down Expand Up @@ -60,7 +73,7 @@ pool.on('error', (err) => {
})();

const poolGet = async (sql, params = []) => {
const { rows } = await pool.query(sql, params);
const { rows } = await readPool.query(sql, params);
return rows[0] || null;
};

Expand All @@ -70,7 +83,7 @@ const poolRun = async (sql, params = []) => {
};

const poolAll = async (sql, params = []) => {
const { rows } = await pool.query(sql, params);
const { rows } = await readPool.query(sql, params);
return rows;
};

Expand Down
Loading