Skip to content

Commit 5e0505b

Browse files
committed
refactor: remove dotenv, hardcode config, produce unsigned release APK
- Remove flutter_dotenv dependency and .env asset bundling - Hardcode API URLs, auth credentials, and Sentry DSN in constants.dart - Remove fake keystore generation from Dockerfile.apk - Build unsigned APK when no key.properties is present - Extract APK to host at end of make apk - Use Platform.environment in integration test instead of dotenv
1 parent 3014af1 commit 5e0505b

11 files changed

Lines changed: 51 additions & 72 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
{
2-
"name": "${localWorkspaceFolderBasename}",
3-
"build": {
4-
"dockerfile": "../Dockerfile",
5-
"args": {
6-
"USERNAME": "${localEnv:USER}",
2+
"name": "${localWorkspaceFolderBasename}",
3+
"build": {
4+
"dockerfile": "../Dockerfile",
5+
"args": {
6+
"USERNAME": "${localEnv:USER}"
7+
}
78
},
8-
},
9-
"remoteUser": "${localEnv:USER}",
10-
"updateRemoteUserUID": true,
11-
"shutdownAction": "stopContainer",
12-
"initializeCommand": ".devcontainer/init-ssh-agent.sh",
13-
"runArgs": [
14-
"--name",
15-
"${localWorkspaceFolderBasename}",
16-
"--hostname",
17-
"bull",
18-
"--memory=8g",
19-
"--security-opt",
20-
"label=disable",
21-
],
22-
"mounts": [
23-
"source=${localEnv:HOME}/.ssh,target=/home/${localEnv:USER}/.ssh,type=bind,consistency=cached",
24-
"source=/tmp/ssh-agent.sock,target=/ssh-agent,type=bind,consistency=cached",
25-
"source=${localEnv:HOME}/.gitconfig,target=/home/${localEnv:USER}/.gitconfig,type=bind,consistency=cached",
26-
],
27-
"containerEnv": {
28-
"SSH_AUTH_SOCK": "/ssh-agent",
29-
},
30-
"postCreateCommand": "flutter config --no-analytics && dart --disable-analytics && cp -n .env.template .env",
31-
"postStartCommand": "sudo chown -R --no-dereference ${localEnv:USER}:${localEnv:USER} /home/${localEnv:USER}/.ssh || true; chmod 700 /home/${localEnv:USER}/.ssh; find /home/${localEnv:USER}/.ssh -maxdepth 1 -type f -exec chmod 600 {} + 2>/dev/null || true",
9+
"remoteUser": "${localEnv:USER}",
10+
"updateRemoteUserUID": true,
11+
"shutdownAction": "stopContainer",
12+
"initializeCommand": ".devcontainer/init-ssh-agent.sh",
13+
"runArgs": [
14+
"--name",
15+
"${localWorkspaceFolderBasename}",
16+
"--hostname",
17+
"bull",
18+
"--memory=8g",
19+
"--security-opt",
20+
"label=disable"
21+
],
22+
"mounts": [
23+
"source=${localEnv:HOME}/.ssh,target=/home/${localEnv:USER}/.ssh,type=bind,consistency=cached",
24+
"source=/tmp/ssh-agent.sock,target=/ssh-agent,type=bind,consistency=cached",
25+
"source=${localEnv:HOME}/.gitconfig,target=/home/${localEnv:USER}/.gitconfig,type=bind,consistency=cached"
26+
],
27+
"containerEnv": {
28+
"SSH_AUTH_SOCK": "/ssh-agent"
29+
},
30+
"postCreateCommand": "flutter config --no-analytics && dart --disable-analytics",
31+
"postStartCommand": "sudo chown -R --no-dereference ${localEnv:USER}:${localEnv:USER} /home/${localEnv:USER}/.ssh || true; chmod 700 /home/${localEnv:USER}/.ssh; find /home/${localEnv:USER}/.ssh -maxdepth 1 -type f -exec chmod 600 {} + 2>/dev/null || true"
3232
}

Dockerfile.apk

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ ARG MODE=debug
77
ARG FORMAT=apk
88
# GRADLE_HEAP: JVM heap size for Gradle (e.g. 2g, 4g, 6g)
99
ARG GRADLE_HEAP=4g
10-
# ENV_SOURCE: where to get .env: template (copy from .env.template) or local (use .env from source)
11-
ARG ENV_SOURCE=template
1210
COPY --chown=$USER:$USER . /app/
1311

1412
WORKDIR /app
@@ -21,11 +19,6 @@ RUN fvm flutter pub get
2119
RUN fvm dart run build_runner build --delete-conflicting-outputs
2220
RUN fvm flutter gen-l10n
2321

24-
# Use .env.template unless ENV_SOURCE=local, in which case .env is already present
25-
RUN if [ "$ENV_SOURCE" != "local" ]; then \
26-
cp .env.template .env; \
27-
fi
28-
2922

3023
# Configure Gradle for containerized builds
3124
RUN mkdir -p $HOME/.gradle && \

integration_test/payjoin_test.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ import 'package:bb_mobile/features/send/domain/usecases/prepare_bitcoin_send_use
1616
import 'package:bb_mobile/features/settings/domain/usecases/set_environment_usecase.dart';
1717
import 'package:bb_mobile/locator.dart';
1818
import 'package:bb_mobile/main.dart';
19+
import 'dart:io' show Platform;
20+
1921
import 'package:flutter/material.dart';
20-
import 'package:flutter_dotenv/flutter_dotenv.dart';
2122
import 'package:flutter_test/flutter_test.dart' show TestWidgetsFlutterBinding;
2223
import 'package:test/test.dart';
2324

@@ -36,8 +37,8 @@ Future<void> main({bool isInitialized = false}) async {
3637
final sendWithPayjoinUsecase = locator<SendWithPayjoinUsecase>();
3738
final prepareBitcoinSendUsecase = locator<PrepareBitcoinSendUsecase>();
3839

39-
final receiverMnemonic = dotenv.env['TEST_ALICE_MNEMONIC'];
40-
final senderMnemonic = dotenv.env['TEST_BOB_MNEMONIC'];
40+
final receiverMnemonic = Platform.environment['TEST_ALICE_MNEMONIC'];
41+
final senderMnemonic = Platform.environment['TEST_BOB_MNEMONIC'];
4142

4243
if (receiverMnemonic == null || receiverMnemonic.isEmpty) {
4344
throw Exception('TEST_ALICE_MNEMONIC environment variable is not set');

lib/core/background_tasks/handler.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'package:bb_mobile/core/wallet/domain/usecases/get_wallets_usecase.dart';
66
import 'package:bb_mobile/core/wallet/domain/usecases/sync_wallet_usecase.dart';
77
import 'package:bb_mobile/locator.dart';
88
import 'package:bb_mobile/main.dart';
9-
import 'package:flutter_dotenv/flutter_dotenv.dart';
109
import 'package:get_it/get_it.dart';
1110
import 'package:lwk/lwk.dart';
1211
import 'package:workmanager/workmanager.dart';
@@ -21,7 +20,6 @@ void backgroundTasksHandler() {
2120
Future<bool> tasksHandler(String task) async {
2221
final startTime = DateTime.now();
2322

24-
await dotenv.load(isOptional: true);
2523
await Bull.initLogs();
2624
await LibLwk.init();
2725

lib/core/utils/constants.dart

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'dart:math';
22
import 'package:flutter/material.dart';
3-
import 'package:flutter_dotenv/flutter_dotenv.dart';
43

54
class Device {
65
static late Size screen;
@@ -98,19 +97,22 @@ class ApiServiceConstants {
9897
static const boltzReferralId = 'BULL';
9998

10099
// BullBitcoin API
101-
static String bbApiUrl =
102-
dotenv.env['BB_API_URL'] ?? 'https://api.bullbitcoin.com';
103-
static String bbApiTestUrl =
104-
dotenv.env['BB_API_TEST_URL'] ?? 'https://api05.bullbitcoin.dev';
105-
static String bbAuthUrl = 'https://${dotenv.env['BB_AUTH_URL']}';
106-
static String bbAuthTestUrl = 'https://${dotenv.env['BB_AUTH_TEST_URL']}';
107-
static String bbKycUrl = 'https://app.bullbitcoin.com/kyc';
108-
static String bbKycTestUrl = 'https://bbx05.bullbitcoin.dev/kyc';
109-
static String googleDriveClientId =
110-
dotenv.env['GOOGLE_DRIVE_CLIENT_ID'] ?? '';
100+
static const String bbApiUrl = 'https://api.bullbitcoin.com';
101+
static const String bbApiTestUrl = 'https://api05.bullbitcoin.dev';
102+
static const String bbAuthUrl = 'https://accounts.bullbitcoin.com';
103+
static const String bbAuthTestUrl = 'https://accounts05.bullbitcoin.dev';
104+
static const String bbKycUrl = 'https://app.bullbitcoin.com/kyc';
105+
static const String bbKycTestUrl = 'https://bbx05.bullbitcoin.dev/kyc';
106+
static const String googleDriveClientId =
107+
'97584343569-0mc4e5q9q1qino4vvo97mqomdi89sae5.apps.googleusercontent.com';
111108

112109
// Error reports
113-
static String sentryDsn = dotenv.env['SENTRY_DSN'] ?? '';
110+
static const String sentryDsn =
111+
'https://b6a8d5134da043eda72f231891c6e51a@cc.bullbitcoin.com/1';
112+
113+
// Exchange basic auth
114+
static const String basicAuthUsername = 'bbadmin';
115+
static const String basicAuthPassword = 'We are staging 05!';
114116
}
115117

116118
class LocatorInstanceNameConstants {

lib/features/exchange/ui/screens/exchange_auth_screen.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import 'package:bb_mobile/features/settings/presentation/bloc/settings_cubit.dar
1010
import 'package:bb_mobile/features/wallet/ui/wallet_router.dart';
1111
import 'package:flutter/material.dart';
1212
import 'package:flutter_bloc/flutter_bloc.dart';
13-
import 'package:flutter_dotenv/flutter_dotenv.dart';
1413
import 'package:go_router/go_router.dart';
1514
import 'package:webview_cookie_manager/webview_cookie_manager.dart';
1615
import 'package:webview_flutter/webview_flutter.dart';
@@ -171,8 +170,8 @@ class _ExchangeAuthScreenState extends State<ExchangeAuthScreen> {
171170
onHttpAuthRequest: (HttpAuthRequest request) {
172171
request.onProceed(
173172
WebViewCredential(
174-
user: dotenv.env['BASIC_AUTH_USERNAME'] ?? '',
175-
password: dotenv.env['BASIC_AUTH_PASSWORD'] ?? '',
173+
user: ApiServiceConstants.basicAuthUsername,
174+
password: ApiServiceConstants.basicAuthPassword,
176175
),
177176
);
178177
},

lib/features/exchange/ui/screens/exchange_kyc_screen.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import 'package:bb_mobile/features/exchange/presentation/exchange_cubit.dart';
77
import 'package:bb_mobile/features/settings/presentation/bloc/settings_cubit.dart';
88
import 'package:flutter/material.dart';
99
import 'package:flutter_bloc/flutter_bloc.dart';
10-
import 'package:flutter_dotenv/flutter_dotenv.dart';
1110
import 'package:go_router/go_router.dart';
1211
import 'package:url_launcher/url_launcher.dart';
1312
import 'package:webview_flutter/webview_flutter.dart';
@@ -95,8 +94,8 @@ class _ExchangeKycScreenState extends State<ExchangeKycScreen> {
9594
onHttpAuthRequest: (HttpAuthRequest request) {
9695
request.onProceed(
9796
WebViewCredential(
98-
user: dotenv.env['BASIC_AUTH_USERNAME'] ?? '',
99-
password: dotenv.env['BASIC_AUTH_PASSWORD'] ?? '',
97+
user: ApiServiceConstants.basicAuthUsername,
98+
password: ApiServiceConstants.basicAuthPassword,
10099
),
101100
);
102101
},

lib/main.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import 'package:dart_bbqr/bbqr.dart';
2929
import 'package:flutter/foundation.dart';
3030
import 'package:flutter/material.dart';
3131
import 'package:flutter_bloc/flutter_bloc.dart';
32-
import 'package:flutter_dotenv/flutter_dotenv.dart' show dotenv;
3332
import 'package:lwk/lwk.dart';
3433
import 'package:path_provider/path_provider.dart';
3534
import 'package:payjoin_flutter/common.dart';
@@ -49,7 +48,6 @@ class Bull {
4948

5049
static Future<void> initFlutterRustBridgeDependencies() async {
5150
final initTasks = [
52-
dotenv.load(isOptional: true),
5351
LibLwk.init(),
5452
BoltzCore.init(),
5553
PConfig.initializeApp(),

makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ apk: docker-build
8686
--build-arg MODE=$(MODE) \
8787
--build-arg FORMAT=$(FORMAT) \
8888
--build-arg GRADLE_HEAP=$(or $(GRADLE_HEAP),4g) \
89-
--build-arg ENV_SOURCE=$(or $(ENV_SOURCE),template) \
9089
-t bull-mobile-apk .
9190
@docker rm -f bull-apk-extract > /dev/null 2>&1 || true
9291
@docker create --name bull-apk-extract bull-mobile-apk > /dev/null

pubspec.lock

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -685,14 +685,6 @@ packages:
685685
url: "https://pub.dev"
686686
source: hosted
687687
version: "9.1.1"
688-
flutter_dotenv:
689-
dependency: "direct main"
690-
description:
691-
name: flutter_dotenv
692-
sha256: d4130c4a43e0b13fefc593bc3961f2cb46e30cb79e253d4a526b1b5d24ae1ce4
693-
url: "https://pub.dev"
694-
source: hosted
695-
version: "6.0.0"
696688
flutter_driver:
697689
dependency: transitive
698690
description: flutter

0 commit comments

Comments
 (0)