Skip to content

Commit

Permalink
chore: remove cala-enterprise
Browse files Browse the repository at this point in the history
  • Loading branch information
bodymindarts committed Jan 17, 2025
1 parent 0683f39 commit b00c09e
Show file tree
Hide file tree
Showing 28 changed files with 74 additions and 580 deletions.
19 changes: 4 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,14 @@ reset-tf-provider:
delete-bq-tables:
cd tf && tofu state list | grep 'module\.setup\.google_bigquery_table\.' | awk '{print "-target='\''" $$1 "'\''"}' | xargs tofu destroy -auto-approve

run-tf:
cd tf && tofu init && tofu apply -auto-approve

init-bq: delete-bq-tables reset-tf-state clean-deps start-deps setup-db
rm tf/import.tf || true
cd tf && tofu init && tofu apply -auto-approve || true
sleep 5
cd tf && tofu apply -auto-approve
git checkout tf/import.tf

reset-deps: reset-tf-state clean-deps start-deps setup-db run-tf
reset-deps: reset-tf-state clean-deps start-deps setup-db

run-server:
cargo run --bin lana-cli --features sim-time -- --config ./bats/lana-sim-time.yml | tee .e2e-logs
Expand All @@ -68,26 +65,18 @@ build:
build-for-tests:
SQLX_OFFLINE=true cargo build --locked --features sim-time

e2e: reset-tf-state clean-deps start-deps build-for-tests run-tf
e2e: reset-tf-state clean-deps start-deps build-for-tests
bats -t bats

e2e-in-ci: bump-cala-docker-image clean-deps start-deps build-for-tests run-tf
e2e-in-ci: clean-deps start-deps build-for-tests
SA_CREDS_BASE64=$$(cat ./dev/fake-service-account.json | tr -d '\n' | base64 -w 0) bats -t bats


sdl:
SQLX_OFFLINE=true cargo run --bin write_sdl > lana/admin-server/src/graphql/schema.graphql
cd apps/admin-panel && pnpm install && pnpm codegen

bump-cala-schema:
curl -H "Authorization: token ${GITHUB_TOKEN}" https://raw.githubusercontent.com/GaloyMoney/cala-enterprise/main/schema.graphql > lana/app/src/ledger/cala/graphql/schema.graphql

bump-cala-docker-image:
docker compose pull cala

bump-cala: bump-cala-docker-image bump-cala-schema

test-in-ci: start-deps setup-db run-tf
test-in-ci: start-deps setup-db
cargo nextest run --verbose --locked

build-x86_64-unknown-linux-musl-release:
Expand Down
30 changes: 0 additions & 30 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ services:
command: sh -c "while :; do sleep 10; done"
depends_on:
- core-pg
- cala-pg
- cala
- otel-agent
- kratos
- kratos-pg
Expand All @@ -24,34 +22,6 @@ services:
interval: 1s
timeout: 1s
retries: 20
cala-pg:
image: postgres:16.4
command: -c 'max_connections=200'
ports:
- "5432:5432"
environment:
- POSTGRES_USER=user
- POSTGRES_PASSWORD=password
- POSTGRES_DB=pg
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 1s
timeout: 1s
retries: 20
cala:
image: us.gcr.io/galoyorg/cala-enterprise:edge
ports:
- "2252:2252"
volumes:
- ./dev/cala.yml:/cala.yml
environment:
- PG_CON=postgresql://user:password@cala-pg:5432/pg
- CALA_CONFIG=/cala.yml
- BFX_LOCAL_TESTING=true
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-agent:4317
depends_on:
- cala-pg
- otel-agent
otel-agent:
ports:
- "4317:4317" # OpenTelemetry receiver
Expand Down
13 changes: 5 additions & 8 deletions lana/app/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use crate::{
credit_facility::CreditFacilities,
customer::Customers,
dashboard::Dashboard,
data_export::Export,
deposit::Deposits,
document::Documents,
governance::Governance,
Expand Down Expand Up @@ -60,17 +59,16 @@ impl LanaApp {
sqlx::migrate!().run(&pool).await?;

let mut jobs = Jobs::new(&pool, config.job_execution);
let export = Export::new(config.ledger.cala_url.clone(), &jobs);
let audit = Audit::new(&pool);
let authz = init_authz(&pool, &audit).await?;
let outbox = Outbox::init(&pool).await?;
let dashboard = Dashboard::init(&pool, &authz, &jobs, &outbox).await?;
let governance = Governance::new(&pool, &authz, &outbox);
let ledger = Ledger::init(config.ledger, &authz).await?;
let price = Price::init(&jobs, &export).await?;
let price = Price::init(&jobs).await?;
let storage = Storage::new(&config.storage);
let documents = Documents::new(&pool, &storage, &authz);
let report = Reports::init(&pool, &config.report, &authz, &jobs, &storage, &export).await?;
let report = Reports::init(&pool, &config.report, &authz, &jobs, &storage).await?;
let users = Users::init(&pool, &authz, &outbox, config.user.superuser_email).await?;

let cala_config = cala_ledger::CalaLedgerConfig::builder()
Expand Down Expand Up @@ -98,8 +96,8 @@ impl LanaApp {
String::from("OMNIBUS_ACCOUNT_ID"),
)
.await?;
let customers = Customers::new(&pool, &config.customer, &deposits, &authz, &export);
let applicants = Applicants::new(&pool, &config.sumsub, &customers, &jobs, &export);
let customers = Customers::new(&pool, &config.customer, &deposits, &authz);
let applicants = Applicants::new(&pool, &config.sumsub, &customers, &jobs);

let collateral_factory = chart_of_accounts.transaction_account_factory(
accounting_init.chart_ids.off_balance_sheet,
Expand Down Expand Up @@ -130,7 +128,6 @@ impl LanaApp {
config.credit_facility,
&governance,
&jobs,
&export,
&authz,
&deposits,
&price,
Expand All @@ -145,7 +142,7 @@ impl LanaApp {
accounting_init.journal_id,
)
.await?;
let terms_templates = TermsTemplates::new(&pool, &authz, &export);
let terms_templates = TermsTemplates::new(&pool, &authz);
jobs.start_poll().await?;

Ok(Self {
Expand Down
2 changes: 0 additions & 2 deletions lana/app/src/applicant/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,4 @@ pub enum ApplicantError {
UuidError(#[from] uuid::Error),
#[error("ApplicantError - JobError: {0}")]
JobError(#[from] crate::job::error::JobError),
#[error("ApplicantError - CalaError: {0}")]
ExportError(#[from] crate::data_export::error::ExportError),
}
50 changes: 22 additions & 28 deletions lana/app/src/applicant/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use sqlx::PgPool;

use crate::{
data_export::{Export, ExportSumsubApplicantData, SumsubContentType},
job::*,
primitives::CustomerId,
};
use crate::{job::*, primitives::CustomerId};

use super::{repo::ApplicantRepo, SumsubClient};

Expand All @@ -20,15 +16,14 @@ impl JobConfig for SumsubExportConfig {
}

pub struct SumsubExportInitializer {
pub(super) export: Export,
pub(super) sumsub_client: SumsubClient,
pub(super) applicants: ApplicantRepo,
}

impl SumsubExportInitializer {
pub fn new(export: Export, sumsub_client: SumsubClient, pool: &PgPool) -> Self {
pub fn new(sumsub_client: SumsubClient, pool: &PgPool) -> Self {
Self {
export,
// export,
sumsub_client,
applicants: ApplicantRepo::new(pool),
}
Expand All @@ -47,7 +42,6 @@ impl JobInitializer for SumsubExportInitializer {
fn init(&self, job: &Job) -> Result<Box<dyn JobRunner>, Box<dyn std::error::Error>> {
Ok(Box::new(SumsubExportJobRunner {
config: job.config()?,
export: self.export.clone(),
sumsub_client: self.sumsub_client.clone(),
applicants: self.applicants.clone(),
}))
Expand All @@ -56,7 +50,7 @@ impl JobInitializer for SumsubExportInitializer {

pub struct SumsubExportJobRunner {
config: SumsubExportConfig,
export: Export,
// export: Export,
sumsub_client: SumsubClient,
applicants: ApplicantRepo,
}
Expand All @@ -67,36 +61,36 @@ impl JobRunner for SumsubExportJobRunner {
async fn run(&self, _: CurrentJob) -> Result<JobCompletion, Box<dyn std::error::Error>> {
match &self.config {
SumsubExportConfig::Webhook { callback_id } => {
let webhook_data = self
let _webhook_data = self
.applicants
.find_webhook_data_by_id(*callback_id)
.await?;

self.export
.export_sum_sub_applicant_data(ExportSumsubApplicantData {
customer_id: webhook_data.customer_id,
content: serde_json::to_string(&webhook_data)?,
content_type: SumsubContentType::Webhook,
uploaded_at: webhook_data.timestamp,
})
.await?;
// self.export
// .export_sum_sub_applicant_data(ExportSumsubApplicantData {
// customer_id: webhook_data.customer_id,
// content: serde_json::to_string(&webhook_data)?,
// content_type: SumsubContentType::Webhook,
// uploaded_at: webhook_data.timestamp,
// })
// .await?;

Ok(JobCompletion::Complete)
}
SumsubExportConfig::SensitiveInfo { customer_id } => {
let content = self
let _content = self
.sumsub_client
.get_applicant_details(*customer_id)
.await?;

self.export
.export_sum_sub_applicant_data(ExportSumsubApplicantData {
customer_id: *customer_id,
content,
content_type: SumsubContentType::SensitiveInfo,
uploaded_at: chrono::Utc::now(),
})
.await?;
// self.export
// .export_sum_sub_applicant_data(ExportSumsubApplicantData {
// customer_id: *customer_id,
// content,
// content_type: SumsubContentType::SensitiveInfo,
// uploaded_at: chrono::Utc::now(),
// })
// .await?;

Ok(JobCompletion::Complete)
}
Expand Down
5 changes: 2 additions & 3 deletions lana/app/src/applicant/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use tracing::instrument;

use crate::{
customer::Customers,
data_export::Export,
job::Jobs,
primitives::{CustomerId, JobId},
};
Expand Down Expand Up @@ -102,11 +101,11 @@ impl Applicants {
config: &SumsubConfig,
users: &Customers,
jobs: &Jobs,
export: &Export,
// export: &Export,
) -> Self {
let sumsub_client = SumsubClient::new(config);
jobs.add_initializer(SumsubExportInitializer::new(
export.clone(),
// export.clone(),
sumsub_client.clone(),
pool,
));
Expand Down
10 changes: 3 additions & 7 deletions lana/app/src/credit_facility/disbursal/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use sqlx::PgPool;

use es_entity::*;

use crate::{data_export::Export, primitives::*};
use crate::primitives::*;

use super::{entity::*, error::DisbursalError};

Expand All @@ -18,15 +18,11 @@ use super::{entity::*, error::DisbursalError};
)]
pub(in crate::credit_facility) struct DisbursalRepo {
pool: PgPool,
_export: Export,
}

impl DisbursalRepo {
pub fn new(pool: &PgPool, export: &Export) -> Self {
Self {
pool: pool.clone(),
_export: export.clone(),
}
pub fn new(pool: &PgPool) -> Self {
Self { pool: pool.clone() }
}
}

Expand Down
17 changes: 1 addition & 16 deletions lana/app/src/credit_facility/interest_accrual/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@ use crate::{

use super::{entity::*, InterestAccrualError};

const BQ_TABLE_NAME: &str = "interest_accrual_events";

#[derive(EsRepo, Clone)]
#[es_repo(
entity = "InterestAccrual",
err = "InterestAccrualError",
columns(
credit_facility_id(ty = "CreditFacilityId", update(persist = false), list_for, parent),
idx(ty = "InterestAccrualIdx", update(persist = false)),
),
post_persist_hook = "export"
)
)]
pub(in crate::credit_facility) struct InterestAccrualRepo {
pool: PgPool,
Expand All @@ -33,16 +30,4 @@ impl InterestAccrualRepo {
export: export.clone(),
}
}

async fn export(
&self,
db: &mut es_entity::DbOp<'_>,
_: &InterestAccrual,
events: impl Iterator<Item = &PersistedEvent<InterestAccrualEvent>>,
) -> Result<(), InterestAccrualError> {
self.export
.es_entity_export(db, BQ_TABLE_NAME, events)
.await?;
Ok(())
}
}
6 changes: 2 additions & 4 deletions lana/app/src/credit_facility/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use tracing::instrument;
use crate::{
audit::AuditInfo,
authorization::{Authorization, CreditFacilityAction, Object},
data_export::Export,
deposit::Deposits,
governance::Governance,
job::*,
Expand Down Expand Up @@ -78,7 +77,6 @@ impl CreditFacilities {
config: CreditFacilityConfig,
governance: &Governance,
jobs: &Jobs,
export: &Export,
authz: &Authorization,
deposits: &Deposits,
price: &Price,
Expand All @@ -92,9 +90,9 @@ impl CreditFacilities {
cala: &CalaLedger,
journal_id: cala_ledger::JournalId,
) -> Result<Self, CreditFacilityError> {
let publisher = CreditFacilityPublisher::new(export, outbox);
let publisher = CreditFacilityPublisher::new(outbox);
let credit_facility_repo = CreditFacilityRepo::new(pool, &publisher);
let disbursal_repo = DisbursalRepo::new(pool, export);
let disbursal_repo = DisbursalRepo::new(pool);
let ledger = CreditLedger::init(cala, journal_id).await?;
let approve_disbursal = ApproveDisbursal::new(
&disbursal_repo,
Expand Down
Loading

0 comments on commit b00c09e

Please sign in to comment.