-
Notifications
You must be signed in to change notification settings - Fork 23
/
justfile
771 lines (630 loc) · 25.5 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
# To use this file, install Just: cargo install just
set dotenv-load
line_length := "100"
coordinator_log_file := "$PWD/data/coordinator/regtest.log"
maker_log_file := "$PWD/data/maker/regtest.log"
# location of pubspec
pubspec := "$PWD/mobile/pubspec.yaml"
# public signet constants
public_signet_coordinator := "021eddb3062fddef2c24f16f6de55fbd78ab985b74b41858719def46321d4be7d0@146.0.73.175:9045"
public_signet_electrs := "http://146.0.73.175:3003"
public_coordinator_http_port := "80"
public_signet_oracle_endpoint := "http://146.0.73.175:8081"
public_signet_oracle_pk := "16f88cf7d21e6c0f46bcbc983a4e3b19726c6c98858cc31c83551a88fde171c0"
public_signet_network := 'signet'
mainnet_meme_endoint := "http://api.10101.finance/memes/"
# command to get the local IP of this machine
get_local_ip := if os() == "linux" {
"ip -o route get to 1 | sed -n 's/.*src \\([0-9.]\\+\\).*/\\1/p'"
} else if os() == "macos" {
"ipconfig getifaddr en0"
} else {
"echo 'Only linux and macos are supported';
exit"
}
# RUST_LOG is overriden for FRB codegen invocations it if RUST_LOG isn't info or debug, which means
# a command like `RUST_LOG="warn" just all` would fail
rust_log_for_frb := if env_var_or_default("RUST_LOG", "") =~ "(?i)(trace)|(debug)" {
"debug"
} else {
"info"
}
default: gen
precommit: gen lint
# Install missing dependencies.
deps: deps-gen deps-android deps-ios
deps-gen args="":
cargo install flutter_rust_bridge_codegen@1.78.0 {{args}}
# Install dependencies for Android (build targets and cargo-ndk)
deps-android:
cargo install cargo-ndk
rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android i686-linux-android
# Install dependencies for iOS
deps-ios:
cargo install cargo-lipo
rustup target add aarch64-apple-ios x86_64-apple-ios
gen:
#!/usr/bin/env bash
set -euxo pipefail
cd mobile
flutter pub get
RUST_LOG={{ rust_log_for_frb }} flutter_rust_bridge_codegen \
--rust-input native/src/api.rs \
--c-output ios/Runner/bridge_generated.h \
--extra-c-output-path macos/Runner/ \
--rust-output native/src/bridge_generated/bridge_generated.rs \
--dart-output lib/bridge_generated/bridge_generated.dart \
--dart-decl-output lib/bridge_generated/bridge_definitions.dart \
--dart-format-line-length {{line_length}}
native:
cd mobile/native && cargo build
# Build Rust library for Android native targets
android args="":
cd mobile/native && cargo ndk -t armeabi-v7a -t arm64-v8a -t x86_64 -t x86 -o ../android/app/src/main/jniLibs build {{args}}
# Note that this does not include x86_64 unlike the above, as android x86_64 is only a development
# target and not a deployment target
android-release:
cd mobile/native && cargo ndk -t armeabi-v7a -t arm64-v8a -o ../android/app/src/main/jniLibs build --release --verbose
# Build flutter webapp for cargo run --bin webapp
build-web args="":
cd webapp/frontend && flutter build web {{args}}
build-web-release:
cd webapp/frontend && flutter build web --release
run-web:
cd webapp/frontend && flutter run -d chrome --web-browser-flag "--disable-web-security"
run-web-backend:
cargo run --bin web
# Build Rust library for iOS (debug mode)
ios:
cd mobile/native && CARGO_TARGET_DIR=../../target/ios_debug cargo lipo
cp target/ios_debug/universal/debug/libnative.a mobile/ios/Runner
# Build Rust library for iOS (release mode)
ios-release:
cd mobile/native && cargo lipo --release
cp target/universal/release/libnative.a mobile/ios/Runner
run args="":
#!/usr/bin/env bash
cd mobile && \
flutter run {{args}} \
--dart-define="COMMIT=$(git rev-parse HEAD)" \
--dart-define="BRANCH=$(git rev-parse --abbrev-ref HEAD)" \
--dart-define="REGTEST_FAUCET=http://localhost:8080" \
--dart-define="ELECTRS_ENDPOINT=http://localhost:3000" \
--dart-define="HEALTH_CHECK_INTERVAL_SECONDS=2"
# Run against our public signet server
run-signet args="":
#!/usr/bin/env bash
cd mobile && \
flutter run {{args}} \
--dart-define="COMMIT=$(git rev-parse HEAD)" \
--dart-define="BRANCH=$(git rev-parse --abbrev-ref HEAD)" \
--dart-define="ELECTRS_ENDPOINT={{public_signet_electrs}}" \
--dart-define="NETWORK={{public_signet_network}}" \
--dart-define="COORDINATOR_P2P_ENDPOINT={{public_signet_coordinator}}" \
--dart-define="COORDINATOR_PORT_HTTP={{public_coordinator_http_port}}" \
--dart-define="ORACLE_ENDPOINT={{public_signet_oracle_endpoint}}" \
--dart-define="ORACLE_PUBKEY={{public_signet_oracle_pk}}" \
--dart-define="MEME_ENDPOINT=${mainnet_meme_endpoint}"
# Run against our public mainnet server
run-mainnet args="":
#!/usr/bin/env bash
cd mobile && \
flutter run {{args}} \
--dart-define="COMMIT=$(git rev-parse HEAD)" \
--dart-define="BRANCH=$(git rev-parse --abbrev-ref HEAD)" \
--dart-define="ELECTRS_ENDPOINT=http://api.10101.finance:3000" \
--dart-define="COORDINATOR_P2P_ENDPOINT=022ae8dbec1caa4dac93f07f2ebf5ad7a5dd08d375b79f11095e81b065c2155156@66.248.204.223:9045" \
--dart-define="COORDINATOR_PORT_HTTP=80" \
--dart-define="ORACLE_ENDPOINT=http://oracle.10101.finance" \
--dart-define="NETWORK=mainnet" \
--dart-define="ORACLE_PUBKEY=93051f54feefdb4765492a85139c436d4857e2e331a360c89a16d6bc02ba9cd0" \
--dart-define="MEME_ENDPOINT=http://api.10101.finance/memes/"
# Specify correct Android flavor to run against our public signet server
run-signet-android args="":
#!/usr/bin/env bash
cd mobile && \
flutter run {{args}} \
--dart-define="COMMIT=$(git rev-parse HEAD)" \
--dart-define="BRANCH=$(git rev-parse --abbrev-ref HEAD)" \
--dart-define="ELECTRS_ENDPOINT={{public_signet_electrs}}" \
--dart-define="COORDINATOR_P2P_ENDPOINT={{public_signet_coordinator}}" \
--dart-define="COORDINATOR_PORT_HTTP={{public_coordinator_http_port}}" \
--dart-define="ORACLE_ENDPOINT={{public_signet_oracle_endpoint}}" \
--dart-define="ORACLE_PUBKEY={{public_signet_oracle_pk}}" \
--dart-define="NETWORK={{public_signet_network}}" \
--dart-define="MEME_ENDPOINT=http://api.10101.finance/memes/" \
--flavor test
[unix]
run-local-android args="":
#!/usr/bin/env bash
LOCAL_IP=$({{get_local_ip}})
echo "Android app will connect to $LOCAL_IP for 10101 services"
cd mobile && \
flutter run {{args}} \
--dart-define="COMMIT=$(git rev-parse HEAD)" \
--dart-define="BRANCH=$(git rev-parse --abbrev-ref HEAD)" \
--dart-define="ELECTRS_ENDPOINT=http://${LOCAL_IP}:3000" \
--dart-define="COORDINATOR_P2P_ENDPOINT=02dd6abec97f9a748bf76ad502b004ce05d1b2d1f43a9e76bd7d85e767ffb022c9@${LOCAL_IP}:9045" \
--dart-define="COORDINATOR_PORT_HTTP=8000" \
--dart-define="ORACLE_ENDPOINT=http://${LOCAL_IP}:8081" \
--dart-define="ORACLE_PUBKEY=16f88cf7d21e6c0f46bcbc983a4e3b19726c6c98858cc31c83551a88fde171c0" \
--dart-define="MEME_ENDPOINT=http://${LOCAL_IP}:8080/memes/" \
--flavor local
fund args="":
cargo run -p fund --example fund
# Fund remote regtest instance
fund-regtest:
cargo run -p tests-e2e --example fund -- --faucet=http://34.32.62.120:8080 --coordinator=http://34.32.62.120:80
clean:
#!/usr/bin/env bash
set -euxo pipefail
cd mobile
rm -rf mobile/android/app/src/main/jniLibs/*
flutter clean
cd native && cargo clean
# Wipes everything
wipe: wipe-docker wipe-coordinator wipe-maker wipe-app wipe-webapp
wipe-docker:
#!/usr/bin/env bash
set -euxo pipefail
docker compose down -v
docker compose --profile postgrest down
wipe-coordinator:
pkill -9 coordinator && echo "stopped coordinator" || echo "coordinator not running, skipped"
rm -rf data/coordinator/regtest
git checkout data/coordinator
wipe-webapp:
pkill -9 webapp && echo "stopped webapp" || echo "webapp not running, skipped"
rm -rf data/webapp/regtest
wipe-maker:
#!/usr/bin/env bash
set -euxo pipefail
pkill -9 maker && echo "stopped maker" || echo "maker not running, skipped"
rm -rf data/maker/regtest
wipe-lnd-mock:
#!/usr/bin/env bash
set -euxo pipefail
pkill -9 lnd-mock && echo "stopped lnd-mock" || echo "lnd-mock not running, skipped"
wipe-app:
#!/usr/bin/env bash
set -euxo pipefail
echo "Wiping native 10101 app"
# Locate macOS 10101 application directory if it exists
if [ -d "$HOME/Library/Containers/" ]; then
FOUND_DIR=""
for dir in $HOME/Library/Containers/*/Data/Library/Application\ Support/finance.get10101.app; do
if [ -d "$dir" ]; then
FOUND_DIR="$dir"
break # Exit loop after the first match. Remove if you want all matches.
fi
done
# default to dummy dir if nothing got found to ensure nothing unnecessary gets deleted
MACOS_PATH="${FOUND_DIR:-/path/to/dummy/directory}"
fi
# If no path was found, use a dummy path to avoid errors
if [[ -z ${MACOS_PATH+x} || ! $MACOS_PATH || ! ${MACOS_PATH//[[:space:]]/} ]]; then
echo "no macos path found, setting dummy value"
MACOS_PATH="/path/to/dummy/directory"
fi
# Array of possible app data directories (OS dependent)
directories=(
"$HOME/Library/Containers/finance.get10101.app/Data/Library/Application Support/finance.get10101.app"
"$HOME/Library/Containers/finance.get10101.app/"
"$MACOS_PATH"
"$HOME/.local/share/finance.get10101.app/"
)
# Remove all possible app data directories
for dir in "${directories[@]}"
do
if [[ -d "$dir" ]]; then
echo "App data directory ${dir} exists, removing it now..."
rm -r "$dir"
else
echo "$dir not found, skipping..."
fi
done
echo "Done wiping 10101 app"
lint: lint-flutter clippy
clippy:
cd mobile/native && just cargo-clippy
cd coordinator && just cargo-clippy
for crate in crates/*; do (cd "${crate}" && echo "Running clippy on ${crate}" && just cargo-clippy); done
[private]
cargo-clippy:
cargo clippy --all-targets -- -D warnings
lint-flutter:
cd mobile && flutter analyze --fatal-infos .
cd webapp/frontend && flutter analyze --fatal-infos .
alias flutter-lint := lint-flutter
alias fmt := format
format: dprint flutter-format
dprint:
dprint fmt
# Flutter lacks a dprint plugin, use its own formatter
flutter-format:
cd mobile && dart format . --fix --line-length {{line_length}}
cd webapp && dart format . --fix --line-length {{line_length}}
alias c := coordinator
coordinator args="":
#!/usr/bin/env bash
set -euxo pipefail
settings_target_path="data/coordinator/regtest/coordinator-settings.toml"
if [ ! -f "$settings_target_path" ]; then
cp coordinator/example-settings/test-coordinator-settings.toml "$settings_target_path"
echo "Copied test settings to $(pwd)/$settings_target_path"
else
echo "Using preexisting settings file at $(pwd)/$settings_target_path"
fi
cargo run --bin coordinator -- {{args}}
maker args="":
#!/usr/bin/env bash
set -euxo pipefail
cargo run --bin dev-maker -- {{args}}
lnd-mock:
#!/usr/bin/env bash
set -euxo pipefail
cargo run --package lnd-bridge --example mock
flutter-test:
cd mobile && flutter pub get
cd mobile && flutter pub run build_runner build --delete-conflicting-outputs && flutter test
# Tests for the `native` crate
native-test:
cd mobile/native && cargo test
test: flutter-test native-test
# Run expensive tests from the `xxi-node` crate.
xxi-test args="": docker
# wait a few seconds to ensure that Docker containers started
sleep 2
# adjust the max amount of available file descriptors - we're making a lot of requests, and it might go over the limit
ulimit -n 1024
RUST_BACKTRACE=1 cargo test -p xxi-node -- --ignored --test-threads=1 {{args}}
# Runs background Docker services
docker:
#!/usr/bin/env bash
docker compose up -d
height=$(docker exec bitcoin bitcoin-cli --regtest -rpcuser=admin1 -rpcpassword=123 getblockcount)
height="${height%%[[:cntrl:]]}"
if [ $height -eq 0 ]; then
docker exec bitcoin bitcoin-cli --regtest -rpcuser=admin1 -rpcpassword=123 createwallet "test"
address=$(docker exec bitcoin bitcoin-cli --regtest -rpcuser=admin1 -rpcpassword=123 getnewaddress)
address="${address%%[[:cntrl:]]}"
docker exec bitcoin bitcoin-cli --regtest -rpcuser=admin1 -rpcpassword=123 generatetoaddress 101 $address
fi
docker-logs:
docker compose logs
# Starts coordinator process in the background, piping logs to a file (used in other recipes)
run-coordinator-detached:
#!/usr/bin/env bash
set -euxo pipefail
just wait-for-electrs-to-be-ready
echo "Building coordinator first"
cargo build --bin coordinator
echo "Starting coordinator"
just coordinator &> {{coordinator_log_file}} &
just wait-for-coordinator-to-be-ready
echo "Coordinator successfully started. You can inspect the logs at {{coordinator_log_file}}"
# Starts maker process in the background, piping logs to a file (used in other recipes)
run-maker-detached:
#!/usr/bin/env bash
set -euxo pipefail
echo "Building maker first"
cargo build --bin dev-maker
echo "Starting maker"
just maker &> {{maker_log_file}} &
just wait-for-maker-to-be-ready
echo "Maker successfully started. You can inspect the logs at {{maker_log_file}}"
# Starts maker process in the background, piping logs to a file (used in other recipes)
run-lnd-mock-detached:
#!/usr/bin/env bash
set -euxo pipefail
echo "Building lnd-mock first"
cargo build --package lnd-bridge --example mock
echo "Starting lnd-mock"
just lnd-mock &> /dev/null &
echo "Lnd mock successfully started."
# Attach to the current coordinator logs
coordinator-logs:
#!/usr/bin/env bash
set -euxo pipefail
less +F {{coordinator_log_file}}
# Attach to the current maker logs
maker-logs:
docker logs -f maker
# Run services in the background
services: docker run-lnd-mock-detached run-coordinator-detached postgrest-coordinator run-maker-detached fund
# Run everything at once (docker, coordinator, native build)
# Note: if you have mobile simulator running, it will start that one instead of native, but will *not* rebuild the mobile rust library.
all args="": services gen native
#!/usr/bin/env bash
set -euxo pipefail
just run "{{args}}"
# Run everything at once, tailored for iOS development
all-ios: services gen ios run
# Run iOS on public signet (useful for device testing, where local regtest is not available)
ios-signet: gen ios run-signet
# Run everything at once, tailored for Android development (rebuilds Android)
all-android: services gen android run-local-android
[private]
wait-for-electrs-to-be-ready:
#!/usr/bin/env bash
set +e
check_if_electrs_is_ready ()
{
docker logs electrs 2>&1 | grep "Electrum RPC server running" > /dev/null
return $?
}
while true
do
if check_if_electrs_is_ready; then
echo "Electrum server is ready"
break
else
echo "Waiting for Electrum server to be ready"
sleep 1
fi
done
[private]
wait-for-coordinator-to-be-ready:
#!/usr/bin/env bash
set +e
endpoint="http://localhost:8000/api/newaddress"
max_attempts=600
sleep_duration=1
check_endpoint() {
response=$(curl -s -o /dev/null -w "%{http_code}" "$endpoint")
if [ "$response" -eq 200 ]; then
echo "Coordinator is ready!"
exit 0
else
echo "Coordinator not ready yet. Retrying..."
return 1
fi
}
attempt=1
while [ "$attempt" -le "$max_attempts" ]; do
if check_endpoint; then
exit 0
fi
sleep "$sleep_duration"
attempt=$((attempt + 1))
done
echo "Max attempts reached. Coordinator is still not ready."
exit 1
[private]
wait-for-maker-to-be-ready:
#!/usr/bin/env bash
set +e
MAX_RETRIES=30
RETRY_DELAY=2
for ((i=1; i<=$MAX_RETRIES; i++)); do
response=$(curl -s http://localhost:8000/api/orderbook/orders)
item_count=$(echo "$response" | jq '. | length')
if [[ $item_count -ge 2 ]]; then
echo "Request successful, found $item_count items."
exit 0
else
echo "Retry $i: Found $item_count items. Retrying in $RETRY_DELAY seconds..."
sleep $RETRY_DELAY
fi
done
echo "Maximum retries exceeded. Starting maker failed."
exit 1
build-ipa args="":
#!/usr/bin/env bash
BUILD_NUMBER=$(git rev-list HEAD --count)
args=()
if [ "$NETWORK" = "regtest" ] || [ "$NETWORK" = "signet" ]; then
args+=(--flavor test)
fi
cd mobile && flutter build ipa "${args[@]}" \
--dart-define="ELECTRS_ENDPOINT=${ELECTRS_ENDPOINT}" \
--dart-define="COORDINATOR_P2P_ENDPOINT=${COORDINATOR_P2P_ENDPOINT}" \
--dart-define="NETWORK=${NETWORK}" \
--dart-define="COMMIT=$(git rev-parse HEAD)" \
--dart-define="BRANCH=$(git rev-parse --abbrev-ref HEAD)" \
--dart-define="COORDINATOR_PORT_HTTP=${COORDINATOR_PORT_HTTP}" \
--dart-define="ORACLE_ENDPOINT=${ORACLE_ENDPOINT}" \
--dart-define="ORACLE_PUBKEY=${ORACLE_PUBKEY}" \
--dart-define="MEME_ENDPOINT=${MEME_ENDPOINT}" \
--build-number=${BUILD_NUMBER} \
{{args}}
publish-testflight:
cd mobile && xcrun altool --upload-app --type ios --file ./build/ios/ipa/10101.ipa --apiKey ${ALTOOL_API_KEY} --apiIssuer ${ALTOOL_API_ISSUER}
build-ipa-no-codesign: (build-ipa "--no-codesign")
publish-ios-to-group:
cd mobile/ios/fastlane && bundle exec fastlane add_build_to_review --verbose
publish-testflight-fastlane:
cd mobile/ios/fastlane && bundle exec fastlane closed_beta --verbose
release-testflight: gen ios build-ipa publish-testflight
version:
cargo --version && rustc --version && flutter --version
build-apk-signet:
#!/usr/bin/env bash
BUILD_NAME=$(yq -r .version {{pubspec}})
BUILD_NUMBER=$(git rev-list HEAD --count)
echo "build name: ${BUILD_NAME}"
echo "build number: ${BUILD_NUMBER}"
cd mobile && flutter build apk \
--build-name=${BUILD_NAME} \
--build-number=${BUILD_NUMBER} \
--release \
--dart-define="COMMIT=$(git rev-parse HEAD)" \
--dart-define="BRANCH=$(git rev-parse --abbrev-ref HEAD)" \
--dart-define="ELECTRS_ENDPOINT={{public_signet_electrs}}" \
--dart-define="COORDINATOR_P2P_ENDPOINT={{public_signet_coordinator}}" \
--dart-define="COORDINATOR_PORT_HTTP={{public_coordinator_http_port}}" \
--dart-define="ORACLE_ENDPOINT={{public_signet_oracle_endpoint}}" \
--dart-define="ORACLE_PUBKEY={{public_signet_oracle_pk}}" \
--dart-define="NETWORK={{public_signet_network}}" \
--dart-define="MEME_ENDPOINT={{mainnet_meme_endoint}}" \
--flavor demo
release-apk-signet: gen android-release build-apk-signet
build-app-bundle-signet:
#!/usr/bin/env bash
BUILD_NAME=$(yq -r .version {{pubspec}})
BUILD_NUMBER=$(git rev-list HEAD --count)
echo "build name: ${BUILD_NAME}"
echo "build number: ${BUILD_NUMBER}"
cd mobile && flutter build appbundle \
--build-name=${BUILD_NAME} \
--build-number=${BUILD_NUMBER} \
--release \
--dart-define="COMMIT=$(git rev-parse HEAD)" \
--dart-define="BRANCH=$(git rev-parse --abbrev-ref HEAD)" \
--dart-define="ELECTRS_ENDPOINT={{public_signet_electrs}}" \
--dart-define="COORDINATOR_P2P_ENDPOINT={{public_signet_coordinator}}" \
--dart-define="COORDINATOR_PORT_HTTP={{public_coordinator_http_port}}" \
--dart-define="ORACLE_ENDPOINT={{public_signet_oracle_endpoint}}" \
--dart-define="ORACLE_PUBKEY={{public_signet_oracle_pk}}" \
--dart-define="NETWORK={{public_signet_network}}" \
--dart-define="MEME_ENDPOINT={{mainnet_meme_endoint}}" \
--flavor demo
build-android-app-bundle:
#!/usr/bin/env bash
BUILD_NAME=$(yq -r .version {{pubspec}})
BUILD_NUMBER=$(git rev-list HEAD --count)
echo "build name: ${BUILD_NAME}"
echo "build number: ${BUILD_NUMBER}"
flavor_arg=()
if [ "$NETWORK" = "regtest" ] || [ "$NETWORK" = "signet" ]; then
flavor_arg+=(--flavor demo)
else
flavor_arg+=(--flavor full)
fi
# Replacing package id using the env variable.
os={{os()}}
echo "building on '$os' for '$NETWORK'"
cd mobile && flutter build appbundle \
--build-name=${BUILD_NAME} \
--build-number=${BUILD_NUMBER} \
--release \
--dart-define="ELECTRS_ENDPOINT=${ELECTRS_ENDPOINT}" \
--dart-define="COORDINATOR_P2P_ENDPOINT=${COORDINATOR_P2P_ENDPOINT}" \
--dart-define="NETWORK=${NETWORK}" \
--dart-define="COMMIT=$(git rev-parse HEAD)" \
--dart-define="BRANCH=$(git rev-parse --abbrev-ref HEAD)" \
--dart-define="COORDINATOR_PORT_HTTP=${COORDINATOR_PORT_HTTP}" \
--dart-define="ORACLE_ENDPOINT=${ORACLE_ENDPOINT}" \
--dart-define="ORACLE_PUBKEY=${ORACLE_PUBKEY}" \
--dart-define="MEME_ENDPOINT=${MEME_ENDPOINT}" \
"${flavor_arg[@]}"
build-android-app-apk args="":
#!/usr/bin/env bash
BUILD_NAME=$(yq -r .version {{pubspec}})
BUILD_NUMBER=$(git rev-list HEAD --count)
echo "build name: ${BUILD_NAME}"
echo "build number: ${BUILD_NUMBER}"
flavor_arg=()
if [ "$NETWORK" = "regtest" ] || [ "$NETWORK" = "signet" ]; then
flavor_arg+=(--flavor demo)
else
flavor_arg+=(--flavor full)
fi
# Replacing package id using the env variable.
os={{os()}}
echo "building on '$os' for '$NETWORK'"
cd mobile && flutter build apk {{args}} \
--build-name=${BUILD_NAME} \
--build-number=${BUILD_NUMBER} \
--release \
--dart-define="ELECTRS_ENDPOINT=${ELECTRS_ENDPOINT}" \
--dart-define="COORDINATOR_P2P_ENDPOINT=${COORDINATOR_P2P_ENDPOINT}" \
--dart-define="NETWORK=${NETWORK}" \
--dart-define="COMMIT=$(git rev-parse HEAD)" \
--dart-define="BRANCH=$(git rev-parse --abbrev-ref HEAD)" \
--dart-define="COORDINATOR_PORT_HTTP=${COORDINATOR_PORT_HTTP}" \
--dart-define="ORACLE_ENDPOINT=${ORACLE_ENDPOINT}" \
--dart-define="ORACLE_PUBKEY=${ORACLE_PUBKEY}" \
--dart-define="MEME_ENDPOINT=${MEME_ENDPOINT}" \
"${flavor_arg[@]}"
upload-app-bundle:
#!/usr/bin/env bash
cd mobile/android/fastlane
if [ "$NETWORK" = "regtest" ] || [ "$NETWORK" = "signet" ]; then
echo "Uploading for regtest"
ANDROID_PACKAGE_NAME='finance.get10101.app.demo' FASTLANE_ANDROID_APP_SCHEME='demo' bundle exec fastlane beta
else
echo "Uploading for mainnet"
ANDROID_PACKAGE_NAME='finance.get10101.app' FASTLANE_ANDROID_APP_SCHEME='full' bundle exec fastlane internal
fi
release-app-bundle-signet: gen android-release build-app-bundle-signet upload-app-bundle
# Run prometheus for local debugging (needs it installed, e.g. `brew install prometheus`)
prometheus:
#!/usr/bin/env bash
set -euxo pipefail
cd services/prometheus
prometheus
# Reset gathered prometheus metrics
wipe-prometheus:
#!/usr/bin/env bash
set -euxo pipefail
cd services/prometheus
rm -rf data
alias e2e := tests-e2e
# end-to-end tests
tests-e2e args="": services
#!/usr/bin/env bash
set -euxo pipefail
RUST_BACKTRACE=1 cargo test -p tests-e2e -- --ignored --test-threads=1 {{args}}
# Run a single end-to-end test for debugging purposes
e2e-single test_name="": services
#!/usr/bin/env bash
set -euxo pipefail
RUST_BACKTRACE=1 cargo test -p tests-e2e --test {{test_name}} -- --ignored --nocapture
# Run database migrations for the app
migrate-app:
#!/usr/bin/env bash
set -euxo pipefail
cd mobile/native
export DATABASE_URL="sqlite://app.sql"
diesel setup
echo "Running migrations for the app"
diesel migration run
rm app.sql
echo "Done."
# Run database migrations for the coordinator
# note: requires postgresql to be running
migrate-coordinator: docker
#!/usr/bin/env bash
set -euxo pipefail
cd coordinator
export DATABASE_URL="postgres://postgres:mysecretpassword@localhost:5432"
diesel setup
echo "Running migrations for the coordinator"
diesel migration run
echo "Done."
# Re-run database migrations for both app and coordinator
migrate: migrate-app migrate-coordinator
dart: flutter-format lint-flutter
# Check whether your dev environment is compatible with the project
doctor:
#!/usr/bin/env bash
echo "Checking your dev environment for compatibility with building 10101."
./check_compatibility.sh
db-coordinator-new migration_name="":
#!/usr/bin/env bash
cd coordinator;
diesel migration generate {{ migration_name }} \
--database-url=postgres://postgres:mysecretpassword@localhost:5432/orderbook \
--migration-dir ./migrations \
--config-file ./diesel.toml
db-coordinator-run:
#!/usr/bin/env bash
cd coordinator;
diesel migration run \
--database-url=postgres://postgres:mysecretpassword@localhost:5432/orderbook \
--migration-dir ./migrations \
--config-file ./diesel.toml
db-coordinator-redo:
#!/usr/bin/env bash
cd coordinator;
diesel migration redo \
--database-url=postgres://postgres:mysecretpassword@localhost:5432/orderbook \
--migration-dir ./migrations \
--config-file ./diesel.toml
ln-pay-invoice:
#!/usr/bin/env bash
curl -X POST http://localhost:18080/pay_invoice
postgrest-coordinator:
docker compose --profile postgrest up -d
# vim:expandtab:sw=4:ts=4